/* ═════════════ RESET & SYSTEM TOKENS ═════════════ */
*,
::before,
::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent
}

:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.85);
  --surface2: #ffffff;
  --surface3: #e8e8ed;
  --sidebar-bg: rgba(246, 246, 248, 0.8);
  --text: #1d1d1f;
  --text2: #515154;
  --text3: #86868b;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --accent: #0071e3;
  --accent2: #5856d6;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --danger: #ff453a;
  --success: #32d74b;
  --warning: #ff9f0a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-lg: 24px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out: cubic-bezier(0.15, 0.85, 0.35, 1);
  --nav-w: 250px;
  --inspector-w: 350px;
  --toolbar-h: 56px;
  --tab-bar-h: 64px;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: rgba(28, 28, 30, 0.85);
  --surface2: #1c1c1e;
  --surface3: #2c2c2e;
  --sidebar-bg: rgba(22, 22, 23, 0.8);
  --text: #f5f5f7;
  --text2: #a1a1a6;
  --text3: #6e6e73;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #0071e3;
  --accent2: #6366f1;
  --accent-soft: rgba(0, 113, 227, 0.2);
  --danger: #ff453a;
  --success: #30d158;
  --warning: #ff9f0a;
}

[data-theme="oled"] {
  --bg: #000000;
  --surface: rgba(10, 10, 10, 0.9);
  --surface2: #0a0a0a;
  --surface3: #1c1c1e;
  --sidebar-bg: rgba(0, 0, 0, 0.9);
  --text: #ffffff;
  --text2: #8e8e93;
  --text3: #48484a;
  --border: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.1);
  --accent: #0071e3;
  --accent2: #6366f1;
  --accent-soft: rgba(0, 113, 227, 0.25);
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit
}

button {
  background: none;
  border: none;
  cursor: pointer;
  user-select: none
}

a {
  color: var(--accent);
  text-decoration: none
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text3)
}

/* ═════════════ APP SHELL ═════════════ */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr var(--inspector-w);
  grid-template-rows: 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden
}

/* Sidebar panel */
.sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--sat)
}

.sidebar-header {
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  gap: 10px
}

.sidebar-header .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 12px var(--accent-soft)
}

.sidebar-header .logo-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em
}

.sidebar-header .logo-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent)
}

.sidebar-section {
  padding: 8px
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px 4px
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1px;
  width: 100%;
  text-align: left
}

.nav-item:hover {
  background: var(--surface3)
}

.nav-item.active {
  background: var(--accent);
  color: #fff
}

.nav-item.active .nav-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center
}

.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface3);
  color: var(--text2);
  min-width: 24px;
  text-align: center
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border)
}

.storage-info {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface2);
  font-size: 11.5px;
  color: var(--text2);
  box-shadow: var(--shadow-sm)
}

.storage-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface3);
  overflow: hidden;
  margin: 8px 0 4px
}

.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  transition: width 0.4s
}

/* Main Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative
}

.toolbar {
  height: calc(var(--toolbar-h) + var(--sat));
  padding-top: var(--sat);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-left: 20px;
  padding-right: 20px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10
}

.toolbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em
}

.toolbar-subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-left: 8px
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm)
}

.tb-btn:hover {
  background: var(--surface3)
}

.tb-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent
}

.tb-btn.primary:hover {
  filter: brightness(1.08)
}

.tb-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed
}

.tb-btn.primary.processing {
  animation: pulse 1.5s ease-in-out infinite
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0.6
  }
}

.tb-btn.icon-only {
  padding: 8px;
  width: 36px;
  height: 36px;
  justify-content: center
}

.tb-btn kbd {
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface3);
  color: var(--text2);
  margin-left: 6px;
  border: 1.5px solid var(--border)
}

.tb-btn.primary kbd {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2)
}

.tb-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px
}

.content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch
}

.content-inner {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: 80px
}

/* Dropzone Empty view */
.dropzone-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  pointer-events: none;
  transition: opacity 0.3s;
  min-height: 60vh
}

.dropzone-empty.hidden {
  display: none
}

.dropzone-card {
  max-width: 540px;
  width: 100%;
  text-align: center;
  pointer-events: auto;
  background: var(--surface);
  padding: 40px 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px)
}

.dropzone-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 12px 30px var(--accent-soft);
  color: #fff
}

.dropzone-icon svg {
  width: 40px;
  height: 40px;
  stroke-width: 1.75
}

.dropzone-card h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 10px
}

.dropzone-card p {
  color: var(--text2);
  font-size: 14.5px;
  margin-bottom: 28px;
  line-height: 1.6
}

.dropzone-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px
}

.dropzone-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  font-size: 11.5px;
  color: var(--text3)
}

.dropzone-hint {
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--surface3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border)
}

/* Dragover overlay */
.workspace.drag-active::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 113, 227, 0.08);
  border: 3px dashed var(--accent);
  z-index: 20;
  pointer-events: none;
  animation: dragPulse 0.8s ease-out infinite alternate
}

@keyframes dragPulse {
  from {
    opacity: 0.4
  }

  to {
    opacity: 0.8
  }
}

.workspace.drag-active::after {
  content: 'Drop to add images';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 21;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  pointer-events: none;
  background: var(--accent);
  padding: 14px 28px;
  border-radius: 100px;
  box-shadow: var(--shadow-xl)
}

/* Image Grid */
.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px
}

.grid-toolbar h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em
}

.grid-toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center
}

.view-toggle {
  display: inline-flex;
  border-radius: 10px;
  background: var(--surface3);
  padding: 3px
}

.view-toggle button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2)
}

.view-toggle button.active {
  background: var(--surface2);
  color: var(--text);
  box-shadow: var(--shadow-sm)
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px
}

.image-grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px
}

.image-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  position: relative;
  animation: cardIn 0.35s var(--ease) both;
  box-shadow: var(--shadow-sm)
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(5px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

.image-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong)
}

.image-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow)
}

.card-thumb {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg);
  overflow: hidden
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease)
}

.image-card:hover .card-thumb img {
  transform: scale(1.03)
}

.card-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2
}

.image-card:hover .card-checkbox,
.image-card.selected .card-checkbox {
  opacity: 1
}

.image-card.selected .card-checkbox {
  background: var(--accent);
  border-color: #fff
}

.card-actions {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.15s;
  z-index: 3
}

.image-card:hover .card-actions {
  opacity: 1;
  transform: translateY(0)
}

.card-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s
}

.card-action-btn:hover {
  background: rgba(0, 0, 0, 0.8)
}

.card-action-btn.danger:hover {
  background: var(--danger)
}

.card-format-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  z-index: 2
}

.card-status-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(3px)
}

.card-status-overlay .spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

.card-savings {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--success);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(50, 215, 75, 0.3);
  z-index: 2
}

.card-download-overlay-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.35);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  z-index: 4;
  transition: transform 0.15s var(--ease), background 0.15s;
}

.card-download-overlay-btn:hover {
  transform: scale(1.1);
  background: #0066cc;
}

.card-info {
  padding: 12px 14px
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px
}

.card-meta {
  font-size: 11.5px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px
}

.card-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text3)
}

/* List view specifications */
.image-grid.list-view .image-card {
  display: grid;
  grid-template-columns: 36px 48px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  aspect-ratio: auto;
}

.image-grid.list-view .card-checkbox {
  position: static;
  opacity: 1;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
}

.image-grid.list-view .card-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  aspect-ratio: 1/1;
}

.image-grid.list-view .card-info {
  padding: 0;
  overflow: hidden;
}

.image-grid.list-view .card-name {
  margin-bottom: 3px;
}

.list-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-right: 4px;
}

.list-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: all 0.15s;
}

.list-action-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border-strong);
}

.list-action-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px var(--accent-soft);
}

.list-action-btn.primary:hover {
  background: #0066cc;
}

.list-action-btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.meta-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface3);
  color: var(--text2);
  letter-spacing: 0.02em;
}

.meta-savings {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
}

/* Inspector Panel */
.inspector {
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--sat)
}

.inspector-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between
}

.inspector-header h3 {
  font-size: 13px;
  font-weight: 700
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 16px
}

.insp-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
}

.insp-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.insp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding-bottom: 2px;
}

.insp-card-header .chevron-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.25s var(--ease);
}

.insp-card.collapsed .insp-card-content {
  display: none;
}

.insp-card.collapsed .chevron-icon {
  transform: rotate(90deg);
}

.insp-card-content {
  margin-top: 6px;
}

.insp-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between
}

.insp-value {
  font-size: 12.5px;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 700
}

.select,
.input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1 1l4 4 4-4' stroke='%2386868b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px
}

.input {
  background-image: none;
  padding-right: 12px
}

.select:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft)
}

.slider {
  width: 100%;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  margin-top: -7px;
  cursor: pointer;
  transition: transform 0.1s
}

.slider::-webkit-slider-thumb:active {
  transform: scale(1.2)
}

.seg-control {
  display: flex;
  background: var(--surface3);
  border-radius: 8px;
  padding: 2px;
  gap: 2px
}

.seg-control button {
  flex: 1;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.15s
}

.seg-control button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm)
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px
}

.preset-btn {
  padding: 6px 2px;
  border-radius: 6px;
  background: var(--surface3);
  border: 1px solid var(--border);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center
}

.preset-btn:hover {
  background: var(--surface);
  border-color: var(--border-strong)
}

.preset-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

.preset-btn .preset-icon {
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center
}

/* Visual Format Grid */
.visual-format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.fmt-grid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 2px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s var(--ease);
  cursor: pointer;
}

.fmt-grid-btn:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.fmt-grid-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.fmt-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.fmt-desc {
  font-size: 8px;
  opacity: 0.75;
  margin-top: 1px;
}

/* Stats dashboard space savings ring */
.stats-ring-container {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 14px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface3);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s var(--ease);
}

.stats-ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stats-ring-label .pct {
  font-size: 20px;
  font-weight: 800;
  color: var(--success);
  line-height: 1.1;
}

.stats-ring-label .label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.live-rename-preview-box {
  background: var(--surface3);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 11px;
  border: 1.5px dashed var(--border-strong);
}

.live-rename-preview-box .preview-label {
  color: var(--text3);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 8.5px;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.live-rename-preview-box .preview-filename {
  font-family: var(--mono);
  color: var(--text);
  word-break: break-all;
  font-weight: 600;
}

.stats-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px
}

.stat-mini {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface3);
  border: 1px solid var(--border)
}

.stat-mini-label {
  font-size: 9.5px;
  color: var(--text3);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 2px
}

.stat-mini-value {
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--mono)
}

.stat-mini-value.success {
  color: var(--success)
}

.inspector-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13px
}

.inspector-empty .icon-placeholder {
  font-size: 40px;
  opacity: 0.3;
  margin-bottom: 12px
}

/* Icons */
.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
  flex-shrink: 0
}

/* Squoosh Compare Workbench & Viewport Zoom/Pan */
.compare-wrapper {
  position: relative;
  width: 100%;
  height: 68vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--border) 0% 25%, var(--surface2) 0% 50%) 50%/20px 20px;
  box-shadow: var(--shadow-lg)
}

.compare-view {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
  cursor: grab
}

.compare-view:active {
  cursor: grabbing
}

.compare-pane {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none
}

.compressed-pane {
  width: 100%;
  z-index: 2;
  clip-path: inset(0 0 0 50%)
}

.compare-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center
}

.compare-slider-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
  z-index: 10;
  cursor: col-resize
}

.compare-slider-handle {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl);
  border: 3px solid #fff;
  transition: transform 0.1s
}

.compare-slider-handle:hover {
  transform: translate(-50%, -50%) scale(1.08)
}

.compare-label {
  position: absolute;
  bottom: 14px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  z-index: 5
}

.compare-label.left {
  left: 14px
}

.compare-label.right {
  right: 14px
}

.compare-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 8
}

.compare-controls .tb-btn {
  padding: 6px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: none;
  border-radius: 8px;
  backdrop-filter: blur(8px)
}

.compare-controls .tb-btn:hover {
  background: rgba(0, 0, 0, 0.9)
}

/* Mobile layouts and overlays */
.tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-bar-h) + var(--sab));
  padding-bottom: var(--sab);
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border);
  z-index: 90;
  justify-content: space-around;
  align-items: stretch
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text2);
  font-size: 10px;
  font-weight: 600;
  transition: color 0.15s;
  padding: 8px 4px 6px;
  position: relative
}

.tab-item.active {
  color: var(--accent)
}

.tab-item .tab-icon {
  font-size: 22px
}

@media(max-width:900px) {
  .app {
    grid-template-columns: 1fr !important
  }

  /* Mobile Sidebar drawer */
  .sidebar {
    display: none !important
  }

  .sidebar.mobile-open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 275px;
    height: 100vh;
    height: 100dvh;
    z-index: 300;
    box-shadow: var(--shadow-xl);
    animation: sidebarIn 0.28s var(--ease);
  }

  .mobile-only {
    display: inline-flex !important;
  }

  #closeSidebarMobile {
    display: inline-flex !important;
    color: var(--text2);
    align-items: center;
    justify-content: center;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
  }

  #closeSidebarMobile:hover {
    background: var(--surface2);
    color: var(--text);
  }

  #sidebarPresetsCard {
    display: none !important
  }

  .inspector {
    display: none !important
  }

  .workspace {
    padding-bottom: calc(var(--tab-bar-h) + var(--sab))
  }

  .tab-bar {
    display: flex
  }

  .toolbar {
    padding-left: 10px;
    padding-right: 16px
  }

  .toolbar .desktop-only {
    display: none
  }

  .toolbar-subtitle {
    display: none
  }

  #toolbarTitle {
    display: none !important
  }

  #mobileLogoImg {
    display: inline-block !important
  }

  .content-inner {
    padding: 12px 10px 40px
  }

  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px
  }

  .dropzone-card h1 {
    font-size: 22px
  }

  .dropzone-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px
  }

  .inspector.mobile-open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border-left: none;
    border-top: none;
    z-index: 200;
    padding-top: var(--sat);
    box-shadow: var(--shadow-xl);
    animation: sheetIn 0.3s var(--ease)
  }

  /* Mobile Upload highlight pulsing */
  #uploadBtn {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 14px var(--accent-soft) !important;
    animation: gentlePulse 1.8s infinite alternate var(--ease);
  }

  #mobileMenuBtn {
    display: inline-flex !important;
  }
}

@keyframes sidebarIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes gentlePulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.06);
  }
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(25px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.mobile-close-inspector {
  display: flex !important
}

@media(max-width:600px) {

  /* Mobile Text Compacting */
  body {
    font-size: 13px;
  }

  .toolbar-title {
    font-size: 14px;
  }

  .card-name {
    font-size: 12px;
  }

  .card-meta {
    font-size: 10px;
  }

  .fmt-title {
    font-size: 11px;
  }

  .fmt-desc {
    font-size: 8px;
  }

  .insp-card-header {
    font-size: 10px;
  }

  .insp-label {
    font-size: 9.5px;
  }

  .select,
  .input {
    font-size: 12.5px;
    padding: 6px 10px;
  }

  .image-grid {
    grid-template-columns: 1fr
  }

  .preset-list {
    grid-template-columns: repeat(2, 1fr)
  }

  .compare-wrapper {
    height: 55vh
  }

  /* Compact list cards on mobile */
  .image-grid.list-view .image-card {
    grid-template-columns: 28px 40px 1fr auto;
    gap: 8px;
    padding: 6px 8px;
  }

  .image-grid.list-view .card-checkbox {
    width: 18px;
    height: 18px;
  }

  .image-grid.list-view .card-thumb {
    width: 40px;
    height: 40px;
  }

  .list-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  .list-action-btn svg {
    width: 14px;
    height: 14px;
  }
}

@media(min-width:901px) and (max-width:1200px) {
  :root {
    --inspector-w: 300px;
    --nav-w: 210px
  }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s var(--ease)
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.modal-backdrop.hidden {
  display: none
}

.modal {
  background: var(--surface2);
  border-radius: var(--radius-lg);
  max-width: 98vw;
  max-height: 92vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1050px;
  animation: modalIn 0.35s var(--ease)
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border)
}

.modal-head h3 {
  font-size: 15px;
  font-weight: 700
}

.modal-head-actions {
  display: flex;
  gap: 8px;
  align-items: center
}

.modal-body-el {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  background: var(--bg);
  position: relative
}

.modal-edit-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  flex-wrap: wrap
}

.modal-edit-bar .tb-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px
}

/* Toasts */
.toast-stack {
  position: fixed;
  top: calc(var(--toolbar-h) + var(--sat) + 12px);
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
  backdrop-filter: blur(10px)
}

@keyframes toastIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.toast.leaving {
  animation: toastOut 0.25s var(--ease) forwards
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(50px) scale(0.9)
  }
}

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff
}

.toast.success .toast-icon {
  background: var(--success)
}

.toast.error .toast-icon {
  background: var(--danger)
}

.toast.info .toast-icon {
  background: var(--accent)
}

.top-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 15;
  overflow: hidden;
  display: none
}

.top-progress.active {
  display: block
}

.top-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.3s var(--ease-out)
}

.select-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 8px 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 120;
  animation: selectBarIn 0.3s var(--ease);
  font-size: 13.5px
}

@keyframes selectBarIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px)
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
  }
}

.select-bar-count {
  font-weight: 700
}

@media(max-width:900px) {
  .select-bar {
    bottom: calc(var(--tab-bar-h) + var(--sab) + 12px);
    left: 12px;
    right: 12px;
    transform: none;
    justify-content: space-between
  }
}

#cropCanvas {
  max-width: 100%;
  max-height: 65vh;
  cursor: crosshair;
  touch-action: none;
  background: repeating-conic-gradient(var(--border) 0% 25%, var(--surface2) 0% 50%) 50%/20px 20px
}

/* Mobile Presets Scrollable Bar */
.mobile-presets-bar {
  display: none;
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--sab));
  left: 0;
  right: 0;
  background: var(--sidebar-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  z-index: 150;
  overflow-x: auto;
  white-space: nowrap;
  gap: 8px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.mobile-presets-bar::-webkit-scrollbar {
  display: none;
}

.mobile-presets-bar.active {
  display: flex;
}

.mobile-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.15s var(--ease);
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-preset-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--accent-soft);
}

.mobile-preset-chip .chip-icon {
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-preset-chip .chip-icon svg {
  width: 14px;
  height: 14px;
}

/* Inline filename edit styles */
.filename-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  color: var(--text3);
  opacity: 0.7;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.15s;
}

.filename-edit-btn:hover {
  color: var(--accent);
  background: var(--surface3);
  opacity: 1;
}

/* Mobile Custom Options Drawer Styling */
.mobile-custom-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--sab) + 48px);
  left: 10px;
  right: 10px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 140;
  box-shadow: var(--shadow-lg);
  animation: slideUpIn 0.22s var(--ease);
}

.mobile-custom-panel.active {
  display: flex;
}

.mobile-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
}

.mobile-custom-row .lbl {
  min-width: 75px;
  color: var(--text2);
}

@keyframes slideUpIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom Tooltip Styling */
.custom-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
  z-index: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -100%);
  margin-top: -12px;
  transition: opacity 0.12s var(--ease);
  opacity: 0;
  white-space: nowrap;
}

.custom-tooltip.visible {
  opacity: 1;
}

/* Modal header wrapping layout for smaller viewports */
@media(max-width:600px) {
  .modal-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
  }

  .modal-head-actions {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  #cropAspectSelect {
    flex: 1;
    min-width: 110px;
  }
}

/* Logo 2-line Typography styling */
.logo-text-2line {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  text-align: left;
}

.logo-text-2line .top {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-text-2line .bottom {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 1px;
}

/* Mobile topbar adjustments */
@media (max-width: 900px) {
  #mobileLogoGroup {
    display: flex !important;
  }

  #downloadBtn {
    display: none !important;
  }

  #gridTitle {
    font-size: 16px !important;
  }

  .toolbar-actions {
    gap: 4px !important;
  }

  .toolbar-actions .tb-btn {
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .toolbar-actions .tb-sep {
    margin: 0 2px !important;
  }
  
  .tab-item:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none !important;
  }
}