:root {
  --bg: #0b0b0d;
  --surface: #131316;
  --surface-2: #191a1f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ececea;
  --text-dim: #9a9ca1;
  --text-faint: #6d6f76;
  --accent: #b8e14c;
  --accent-dim: rgba(184, 225, 76, 0.12);
  --accent-ink: #131703;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --radius: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #efefec;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #17171a;
  --text-dim: #5c5e64;
  --text-faint: #8b8d93;
  --accent: #a3c81f;
  --accent-dim: rgba(163, 200, 31, 0.14);
  --accent-ink: #151a02;
  --shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-2: #efefec;
    --line: rgba(0, 0, 0, 0.09);
    --line-strong: rgba(0, 0, 0, 0.16);
    --text: #17171a;
    --text-dim: #5c5e64;
    --text-faint: #8b8d93;
    --accent: #a3c81f;
    --accent-dim: rgba(163, 200, 31, 0.14);
    --accent-ink: #151a02;
    --shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: #131316;
  --surface-2: #191a1f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ececea;
  --text-dim: #9a9ca1;
  --text-faint: #6d6f76;
  --accent: #b8e14c;
  --accent-dim: rgba(184, 225, 76, 0.12);
  --accent-ink: #131703;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.topbar {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 17px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  font-family: var(--mono);
}

.brand-mark.small {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  font-size: 10px;
  margin-right: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

.icon-btn .icon-moon { display: none; }
:root[data-theme="light"] .icon-btn .icon-sun { display: none; }
:root[data-theme="light"] .icon-btn .icon-moon { display: block; }
:root:not([data-theme]) .icon-btn .icon-moon { display: block; }
:root:not([data-theme]) .icon-btn .icon-sun { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-btn .icon-moon { display: none; }
  :root:not([data-theme]) .icon-btn .icon-sun { display: block; }
}

main.container { flex: 1; }

.hero { padding: 56px 0 8px; }

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 22px;
}

h1 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 800;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 17px;
  max-width: 52ch;
  margin: 0;
}

.strip-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 26px 0 6px;
}

.strip-list-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.chips li {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--surface);
}

.dropzone {
  display: block;
  margin-top: 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.dropzone:hover { border-color: var(--accent); background: var(--surface-2); }

.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: scale(1.005);
}

.dz-icon {
  color: var(--accent);
  margin-bottom: 14px;
}

.dz-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.dz-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.dz-hint {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.group { display: flex; flex-direction: column; gap: 8px; }

.group-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.group-label b { color: var(--text); font-weight: 600; }

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg {
  font-family: var(--mono);
  font-size: 12.5px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg:hover { color: var(--text); }

.seg[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.quality-group { flex: 0 1 240px; }

.quality-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.actions {
  margin-left: auto;
  flex-direction: row;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.btn:active { transform: scale(0.97); }

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

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

.batch-bar .dot { color: var(--text-faint); }

.batch-bar .btn { margin-left: auto; }

.lock-hint {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

.empty {
  text-align: center;
  padding: 56px 0 72px;
  color: var(--text-dim);
}

.empty p { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.empty p.dim { font-weight: 400; color: var(--text-faint); font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px 0 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%),
    linear-gradient(45deg, var(--surface-2) 25%, var(--bg) 25%, var(--bg) 75%, var(--surface-2) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

.badge {
  position: absolute;
  top: 8px;
  left: 48px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text);
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 3px 8px;
  backdrop-filter: blur(4px);
}

.sel-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.12s ease, background 0.15s ease;
  backdrop-filter: blur(4px);
}

.card:hover .sel-btn, .sel-btn:focus-visible { opacity: 1; }
.sel-btn:active { transform: scale(0.9); }

.sel-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  opacity: 1;
}

.dl-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.12s ease;
  backdrop-filter: blur(4px);
}

.card:hover .dl-btn, .dl-btn:focus-visible { opacity: 1; }
.dl-btn:active { transform: scale(0.9); }

.card .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card .error-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #fff;
  background: var(--danger);
  border-radius: 6px;
  padding: 3px 8px;
}

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

.card-body { padding: 10px 12px 12px; }

.new-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.old-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: line-through;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.meta .st-done { color: var(--ok); }
.meta .st-error { color: var(--danger); }
.meta .st-processing { color: var(--accent); }

.footer {
  border-top: 1px solid var(--line);
  padding: 22px 0;
  color: var(--text-faint);
  font-size: 13px;
}

.footer p { margin: 0; display: flex; align-items: center; }

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .container { padding: 0 18px; }
  .hero { padding-top: 40px; }
  h1 { font-size: clamp(2.1rem, 10vw, 3rem); }
  .hero-sub { font-size: 15.5px; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1; justify-content: center; }
  .quality-group { flex: 1 1 100%; }
  .batch-bar .btn { margin-left: 0; width: 100%; justify-content: center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
  .card:hover { transform: none; }
  .dropzone.dragging { transform: none; }
}
