:root {
  --bg: oklch(0.16 0.008 260);
  --bg-raised: oklch(0.19 0.009 260);
  --bg-card: oklch(0.21 0.009 260);
  --bg-card-hover: oklch(0.235 0.01 260);
  --border: oklch(0.28 0.01 260);
  --border-soft: oklch(0.24 0.009 260);
  --border-strong: oklch(0.38 0.012 260);
  --text: oklch(0.96 0.005 260);
  --text-dim: oklch(0.72 0.008 260);
  --text-faint: oklch(0.52 0.008 260);
  --text-ghost: oklch(0.38 0.008 260);

  --img: #3B9EFF;
  --aud: #F5A623;
  --vid: #9B59F5;
  --doc: #2ECC71;
  --danger: #F5545A;

  --img-soft: color-mix(in oklab, #3B9EFF 18%, transparent);
  --aud-soft: color-mix(in oklab, #F5A623 18%, transparent);
  --vid-soft: color-mix(in oklab, #9B59F5 18%, transparent);
  --doc-soft: color-mix(in oklab, #2ECC71 18%, transparent);

  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* blueprint grid background */
body.grid-on::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, oklch(0.22 0.008 260) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(0.22 0.008 260) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at top, rgba(0,0,0,0.35), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.mono { font-family: var(--font-mono); }

/* ---------- Top Bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 15px;
}
.brand-mark {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--text);
  color: var(--bg);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 800;
}
.brand-sub {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.compact-dropzone {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  transition: all 0.15s;
  cursor: pointer;
}
.compact-dropzone:hover { border-color: var(--text-dim); color: var(--text); }
.compact-dropzone.active { border-style: solid; border-color: var(--text); color: var(--text); }

/* ---------- Hero Dropzone ---------- */
.hero {
  position: relative; z-index: 1;
  max-width: 1440px; margin: 0 auto;
  padding: 64px 28px 40px;
}
.hero-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px;
}
.hero-title {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.hero-title .accent { color: var(--text-faint); font-weight: 400; }
.hero-sub {
  color: var(--text-dim);
  max-width: 520px;
  line-height: 1.55;
}
.hero-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
  letter-spacing: 0.04em;
}
.hero-meta .row { display: block; margin-bottom: 4px; }
.hero-meta .dot { color: var(--doc); }

.dropzone {
  position: relative;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 72px 40px;
  background: linear-gradient(180deg, oklch(0.18 0.009 260) 0%, oklch(0.17 0.008 260) 100%);
  text-align: center;
  transition: all 0.2s;
  overflow: hidden;
}
.dropzone.active {
  border-style: solid;
  border-color: var(--text);
  background: oklch(0.2 0.01 260);
}
.dropzone.active::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.06), transparent 40%);
  pointer-events: none;
}
.dropzone-icon {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-dim);
  background: oklch(0.2 0.009 260);
}
.dropzone.active .dropzone-icon {
  color: var(--text);
  border-color: var(--text);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.dropzone-title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.dropzone-hint {
  color: var(--text-faint);
  font-size: 13px;
}
.dropzone-hint .key {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 0 2px;
  color: var(--text-dim);
}
.supported-formats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin-top: 32px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
}
.fmt-chip {
  padding: 3px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  color: var(--text-faint);
  text-transform: uppercase;
}
.fmt-chip.cat-img { color: var(--img); border-color: color-mix(in oklab, var(--img) 30%, var(--border)); }
.fmt-chip.cat-aud { color: var(--aud); border-color: color-mix(in oklab, var(--aud) 30%, var(--border)); }
.fmt-chip.cat-vid { color: var(--vid); border-color: color-mix(in oklab, var(--vid) 30%, var(--border)); }
.fmt-chip.cat-doc { color: var(--doc); border-color: color-mix(in oklab, var(--doc) 30%, var(--border)); }

.sample-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 24px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: all 0.15s;
}
.sample-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-card); }

/* ---------- Workspace Action Bar ---------- */
.workspace {
  position: relative; z-index: 1;
  max-width: 1440px; margin: 0 auto;
  padding: 24px 28px 64px;
}
.action-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 28px;
  position: sticky; top: 53px; z-index: 10;
}
.ab-stats {
  display: flex; align-items: center; gap: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.ab-stats .num {
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}
.ab-stats .divider {
  width: 1px; height: 14px;
  background: var(--border);
}
.ab-spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-dim);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-card);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: oklch(0.88 0.005 260);
  border-color: oklch(0.88 0.005 260);
  color: var(--bg);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 30%, var(--border)); }
.btn.danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: color-mix(in oklab, var(--danger) 12%, transparent); }

.btn-sm { padding: 6px 10px; font-size: 11px; }

/* ---------- Category Section ---------- */
.thumb-size-control {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-right: 4px;
}
.thumb-size-control input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 70px; height: 3px;
  background: var(--border); border-radius: 2px;
}
.thumb-size-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--cat, var(--text));
  cursor: pointer;
}
.thumb-size-control input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cat, var(--text));
  border: none; cursor: pointer;
}
.ts-btn {
  background: transparent;
  border: none;
  padding: 2px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px;
  transition: background 120ms;
}
.ts-btn:hover { background: var(--bg-alt); }
.ts-btn:hover .ts-icon-sm, .ts-btn:hover .ts-icon-lg {
  border-color: var(--text);
}
.ts-icon-sm, .ts-icon-lg {
  border: 1px solid var(--text-faint);
  border-radius: 1px;
  display: block;
  transition: border-color 120ms;
}
.ts-icon-sm { width: 7px; height: 7px; }
.ts-icon-lg { width: 11px; height: 11px; }
.category {
  margin-bottom: 40px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-raised);
  overflow: hidden;
  --cat: var(--text);
}
.category.cat-img { --cat: var(--img); --cat-soft: var(--img-soft); }
.category.cat-aud { --cat: var(--aud); --cat-soft: var(--aud-soft); }
.category.cat-vid { --cat: var(--vid); --cat-soft: var(--vid-soft); }
.category.cat-doc { --cat: var(--doc); --cat-soft: var(--doc-soft); }

.cat-header {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(90deg, var(--cat-soft) 0%, transparent 60%);
}
.cat-label {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.cat-badge {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--cat);
  box-shadow: 0 0 12px var(--cat);
}
.cat-name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}
.cat-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.cat-header-spacer { flex: 1; }

.format-selector {
  display: flex; align-items: center; gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.format-selector .fs-label {
  padding: 5px 10px 5px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border-right: 1px solid var(--border);
  margin-right: 2px;
}
.fs-pill {
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: 3px;
  letter-spacing: 0.03em;
  transition: all 0.1s;
}
.fs-pill:hover { color: var(--text); background: var(--bg-card); }
.fs-pill.active {
  background: var(--cat);
  color: var(--bg);
  font-weight: 600;
}

.card-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
}

/* ---------- File Card ---------- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  display: flex; flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--cat);
  box-shadow: 0 0 0 1px var(--cat-soft), 0 8px 24px rgba(0,0,0,0.3);
}
.card.error { border-color: color-mix(in oklab, var(--danger) 40%, var(--border)); }

.thumb {
  position: relative;
  background: oklch(0.14 0.007 260);
  overflow: hidden;
  display: grid; place-items: center;
  border-bottom: 1px solid var(--border-soft);
}
.thumb.clickable { cursor: zoom-in; }
.thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-duration {
  position: absolute; bottom: 8px; right: 8px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(0,0,0,0.72);
  color: var(--text);
  border-radius: 3px;
  letter-spacing: 0.02em;
}
.thumb-pages {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--doc-soft);
  color: var(--doc);
  border: 1px solid color-mix(in oklab, var(--doc) 40%, transparent);
  border-radius: 3px;
}
.play-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,0);
  transition: background 0.15s;
  cursor: pointer;
}
.card:hover .play-overlay { background: rgba(0,0,0,0.3); }
.play-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  display: grid; place-items: center;
  opacity: 0;
  transform: scale(0.85);
  transition: all 0.18s;
  backdrop-filter: blur(4px);
}
.card:hover .play-btn { opacity: 1; transform: scale(1); }
.play-btn.playing { opacity: 1; transform: scale(1); background: var(--cat); border-color: var(--cat); color: var(--bg); }

/* waveform thumb */
.waveform {
  width: 100%; height: 100%;
  padding: 16px;
  display: flex; align-items: center; gap: 2px;
  background: linear-gradient(180deg, oklch(0.14 0.01 80) 0%, oklch(0.12 0.008 80) 100%);
}
.wf-bar {
  flex: 1;
  background: color-mix(in oklab, var(--aud) 45%, var(--text-ghost));
  border-radius: 1px;
  min-height: 4%;
  transition: background 0.1s;
}
.wf-bar.active { background: var(--aud); }

.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-thumb {
  width: 100%; height: 100%;
  padding: 12px;
  background: oklch(0.94 0.004 260);
  display: flex; flex-direction: column; gap: 3px;
  position: relative;
  overflow: hidden;
}
.doc-thumb .doc-line {
  height: 3px;
  background: oklch(0.75 0.008 260);
  border-radius: 1px;
}
.doc-thumb .doc-line.short { width: 60%; }
.doc-thumb .doc-line.mid { width: 85%; }
.doc-thumb .doc-heading {
  height: 5px;
  background: oklch(0.2 0.008 260);
  border-radius: 1px;
  width: 45%;
  margin-bottom: 4px;
}
.doc-thumb .doc-gap { height: 6px; }

.card-body {
  padding: 10px 12px 8px;
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.card-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.card-filename .arrow {
  color: var(--text-ghost);
  margin: 0 4px;
}
.card-filename .ext-to {
  color: var(--cat);
  font-weight: 600;
}
.card-filename.same .ext-to { color: var(--text-faint); }
.filename-edit {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--cat);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.card-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.card-footer {
  display: flex; align-items: center;
  padding: 6px 6px 6px 10px;
  border-top: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--bg) 60%, transparent);
}
.card-status {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-ghost);
}
.status-dot.queued { background: var(--text-faint); }
.status-dot.converting { background: var(--cat); animation: blink 1s ease-in-out infinite; }
.status-dot.done { background: var(--doc); box-shadow: 0 0 6px var(--doc); }
.status-dot.error { background: var(--danger); }
.status-dot.same { background: var(--text-ghost); border: 1px solid var(--text-faint); background: transparent; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.card-actions {
  display: flex; gap: 2px;
}
.icon-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 4px;
  color: var(--text-faint);
  transition: all 0.12s;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.help-btn { margin-right: 6px; }
.icon-btn.active-download { color: var(--doc); }
.icon-btn.active-download:hover { background: color-mix(in oklab, var(--doc) 15%, transparent); color: var(--doc); }

/* conversion progress overlay */
.conv-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.55));
  pointer-events: none;
  padding: 12px;
}
.conv-percent {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.conv-bar {
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
}
.conv-bar-fill {
  height: 100%;
  background: var(--cat);
  transition: width 0.15s;
  box-shadow: 0 0 8px var(--cat);
}

.done-badge {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--doc);
  color: var(--bg);
  display: grid; place-items: center;
  animation: pop 0.3s ease-out;
  z-index: 1;
}
@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* audio inline player */
.audio-controls {
  padding: 8px 10px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
}
.ac-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  min-width: 34px;
}
.ac-track {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}
.ac-track-fill {
  height: 100%;
  background: var(--aud);
  border-radius: 2px;
}

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 50;
  animation: fade 0.15s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  z-index: 51;
  overflow-y: auto;
  animation: slide 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
@keyframes slide { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-title {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.drawer-body { padding: 20px; flex: 1; }
.meta-preview {
  aspect-ratio: 16 / 10;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  margin-bottom: 18px;
  overflow: hidden;
  display: grid; place-items: center;
}
.meta-filename {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-all;
}
.meta-conversion {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}
.meta-group {
  margin-bottom: 16px;
}
.meta-group-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-ghost);
  margin-bottom: 8px;
}
.meta-table { width: 100%; }
.meta-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-soft);
}
.meta-row:last-child { border-bottom: 0; }
.meta-key { color: var(--text-faint); }
.meta-val { color: var(--text); font-family: var(--font-mono); font-size: 11.5px; text-align: right; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 60;
  display: grid; place-items: center;
  padding: 40px;
  animation: fade 0.15s;
}
.lightbox-content {
  max-width: 90vw; max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.lightbox-media-wrap {
  background:
    linear-gradient(45deg, oklch(0.14 0.007 260) 25%, transparent 25%),
    linear-gradient(-45deg, oklch(0.14 0.007 260) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, oklch(0.14 0.007 260) 75%),
    linear-gradient(-45deg, transparent 75%, oklch(0.14 0.007 260) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: oklch(0.1 0.005 260);
  display: flex; align-items: center; justify-content: center;
  min-height: 40vh;
  padding: 20px;
  overflow: hidden;
}
.lightbox-media {
  position: relative;
  display: block;
  line-height: 0;
  overflow: hidden;
  flex-shrink: 0;
}
.lightbox-img {
  display: block;
  width: 100%;
  height: 100%;
}
.lightbox-video-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.35));
  cursor: pointer;
  transition: background 0.15s;
}
.lightbox-video-overlay:hover { background: linear-gradient(180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.5)); }
.lightbox-play {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 1.5px solid rgba(255,255,255,0.5);
  color: white;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
  transition: transform 0.15s;
}
.lightbox-video-overlay:hover .lightbox-play { transform: scale(1.08); background: var(--vid); border-color: var(--vid); }
.lightbox-video-badge {
  position: absolute; bottom: 12px; left: 12px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 11px;
  color: white;
  letter-spacing: 0.04em;
}
.lightbox-caption {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.lightbox-close {
  position: absolute; top: 24px; right: 24px;
  width: 36px; height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  background: rgba(0,0,0,0.5);
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(0,0,0,0.8); }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  background: rgba(0,0,0,0.5);
  display: grid;
  place-items: center;
}
.lightbox-nav.left { left: 24px; }
.lightbox-nav.right { right: 24px; }
.lightbox-nav:hover { background: rgba(0,0,0,0.8); }

/* empty category warning */
.warn-banner {
  margin: 0 20px 20px;
  padding: 10px 14px;
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--danger);
  display: flex; align-items: center; gap: 10px;
}

/* ---------- Help Modal ---------- */
.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 66;
}
.help-modal {
  position: fixed;
  top: 72px;
  right: 20px;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 96px);
  overflow: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  z-index: 67;
}
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.help-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.help-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}
.help-section {
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg);
}
.help-k {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.help-v {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
}
.help-list {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Tweaks ---------- */
.tweaks-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 70;
  width: 280px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
}
.tweaks-head {
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex; justify-content: space-between; align-items: center;
}
.tweaks-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; }
.tweak-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.tweak-toggles { display: flex; gap: 4px; }
.tweak-toggle {
  flex: 1;
  padding: 6px 8px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  text-align: center;
  transition: all 0.1s;
}
.tweak-toggle.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tweak-toggle:hover:not(.active) { color: var(--text); border-color: var(--border-strong); }

/* scroll */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* small utility */
.dim { color: var(--text-faint); }
.no-select { user-select: none; }

@media (max-width: 720px) {
  .hero-title { font-size: 32px; }
  .action-bar { flex-wrap: wrap; }
  .topbar-inner { padding: 12px 16px; }
  .hero, .workspace { padding-left: 16px; padding-right: 16px; }
  .card-grid { gap: 10px; padding: 12px; }
  .drawer { width: 100vw; }
  .lightbox { padding: 14px; }
  .lightbox-nav { display: none; }
  .lightbox-close { top: 12px; right: 12px; }
  .help-modal { top: 56px; right: 12px; width: calc(100vw - 24px); }
}
