/* ==========================================================================
   图语 PROMPTLENS — darkroom / contact-sheet
   ========================================================================== */

:root {
  --topbar-h: 68px;
  --font-display: "Smiley Sans Oblique", "Smiley Sans", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", sans-serif;
  --font-body: "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  --font-label: "Bahnschrift", "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif;

  --bg: #0c0d0e;
  --bg-2: #101214;
  --panel: #15181a;
  --panel-2: #1a1e20;
  --panel-3: #202528;
  --topbar-bg: rgba(12, 13, 14, 0.78);
  --text: #ece7dd;
  --muted: #949087;
  --faint: #6b6861;
  --line: rgba(236, 231, 221, 0.095);
  --line-strong: rgba(236, 231, 221, 0.22);
  --accent: #e9a13b;
  --accent-2: #f3bd6b;
  --accent-soft: rgba(233, 161, 59, 0.11);
  --teal: #63c6b9;
  --teal-soft: rgba(99, 198, 185, 0.1);
  --red: #e8655a;
  --red-soft: rgba(232, 101, 90, 0.1);
  --glow-amber: rgba(233, 161, 59, 0.085);
  --glow-teal: rgba(99, 198, 185, 0.045);
  --grain: 0.055;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  --radius: 3px;
}

html[data-theme="light"] {
  --bg: #efeae0;
  --bg-2: #e7e1d5;
  --panel: #faf6ed;
  --panel-2: #f4eee2;
  --panel-3: #ece5d6;
  --topbar-bg: rgba(239, 234, 224, 0.8);
  --text: #1c1d1e;
  --muted: #6f6a60;
  --faint: #8e8779;
  --line: rgba(28, 29, 30, 0.11);
  --line-strong: rgba(28, 29, 30, 0.24);
  --accent: #a95f11;
  --accent-2: #8d4c07;
  --accent-soft: rgba(169, 95, 17, 0.09);
  --teal: #18766c;
  --teal-soft: rgba(24, 118, 108, 0.09);
  --red: #b23a30;
  --red-soft: rgba(178, 58, 48, 0.09);
  --glow-amber: rgba(196, 122, 28, 0.13);
  --glow-teal: rgba(24, 118, 108, 0.06);
  --grain: 0.035;
  --shadow: 0 22px 50px rgba(63, 48, 24, 0.13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #14110c; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 620px at 82% -12%, var(--glow-amber), transparent 64%),
    radial-gradient(760px 560px at -8% 104%, var(--glow-teal), transparent 62%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: var(--grain);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- shared ---------- */

.index {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.label {
  font-family: var(--font-label);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.rail-title { display: flex; align-items: center; min-width: 0; }

.icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.corner {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
  opacity: 0.75;
}
.corner.tl { top: 5px; left: 5px; border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.corner.tr { top: 5px; right: 5px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); }
.corner.bl { bottom: 5px; left: 5px; border-bottom: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.corner.br { bottom: 5px; right: 5px; border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); }

kbd {
  display: inline-block;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--muted);
  line-height: 1.45;
}

.text-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.text-btn:hover { color: var(--accent); text-decoration: underline; }
.text-btn.danger:hover { color: var(--red); }
.text-btn:disabled { opacity: 0.32; cursor: default; text-decoration: none; color: var(--muted); }
.text-btn.armed { color: var(--red); }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #17120a;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #17120a; }
.btn.primary.is-done { background: var(--teal); border-color: var(--teal); color: #07110f; }
.btn.ghost { background: transparent; }
.btn.small { height: 27px; padding: 0 10px; font-size: 9px; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

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

/* ---------- topbar ---------- */

.topbar {
  position: relative;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(1.1);
}

.brand { display: flex; align-items: center; gap: 12px; }

.lens {
  position: relative;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 8deg, var(--accent) 0deg 21deg, transparent 21deg 60deg);
  filter: drop-shadow(0 0 10px var(--accent-soft));
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.brand:hover .lens { transform: rotate(30deg); }
.lens::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--bg);
}
.lens-core {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
}
.brand-text span {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.34em;
  color: var(--muted);
}

.top-tools { display: flex; align-items: center; gap: 10px; }

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--panel);
  cursor: default;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
}
.model-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: pulse 1.3s ease-in-out infinite;
}
.model-chip[data-state="ready"] .dot { background: var(--teal); animation: none; box-shadow: 0 0 7px var(--teal); }
.model-chip[data-state="ready"] { color: var(--text); }
.model-chip[data-state="error"] .dot { background: var(--red); animation: none; box-shadow: 0 0 7px var(--red); }
.model-chip[data-state="error"] { color: var(--red); border-color: var(--red); }

.icon-btn {
  appearance: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.sun-icon { display: none; }
.moon-icon { display: block; }
html[data-theme="light"] .sun-icon { display: block; }
html[data-theme="light"] .moon-icon { display: none; }

/* ---------- layout ---------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  height: calc(100% - var(--topbar-h));
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 22px 20px 18px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 38%);
}

.rail-head { display: flex; align-items: center; justify-content: space-between; }
.counter {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--faint);
  letter-spacing: 0.08em;
}

/* ---------- dropzone ---------- */

.dropzone {
  position: relative;
  padding: 24px 16px 16px;
  border: 1px dashed var(--line-strong);
  background:
    radial-gradient(120% 100% at 50% 0%, var(--accent-soft), transparent 62%),
    var(--panel);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.dropzone:hover { border-color: var(--accent); background: var(--panel-2); }
.dropzone:active { transform: translateY(1px); }
.dropzone .corner { width: 13px; height: 13px; opacity: 0.5; }

.drop-icon {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
  margin-bottom: 9px;
  animation: slow-spin 36s linear infinite;
}
.drop-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: 0.03em;
}
.drop-sub { margin: 5px 0 0; font-size: 10.5px; color: var(--muted); }
.drop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.drop-foot .text-btn { font-size: 9px; color: var(--muted); }

/* ---------- film ---------- */

.film-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.film-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.film-actions .text-btn { font-size: 8.5px; }

.filmstrip {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-height: 96px;
  padding: 14px 2px;
  overflow-x: auto;
  overflow-y: hidden;
}
.filmstrip::before,
.filmstrip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 7px;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--line-strong) 1.15px, transparent 1.3px);
  background-size: 11px 7px;
  background-repeat: repeat-x;
  opacity: 0.55;
}
.filmstrip::before { top: 0; }
.filmstrip::after { bottom: 0; }

.film-empty {
  margin: auto 0;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.frame {
  appearance: none;
  position: relative;
  flex: none;
  width: 88px;
  height: 88px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: #0a0b0c;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.86;
  transition: opacity 0.16s ease, transform 0.3s ease;
}
.frame:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.frame:hover img { opacity: 1; transform: scale(1.035); }
.frame.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 22px rgba(0, 0, 0, 0.32);
}
.frame.active img { opacity: 1; }

.frame-no {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 0 4px;
  background: rgba(6, 7, 8, 0.72);
  color: #f0e9dc;
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.frame-state {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 2px rgba(6, 7, 8, 0.55);
}
.frame[data-status="queued"] .frame-state { background: var(--muted); }
.frame[data-status="analyzing"] .frame-state { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.frame[data-status="done"] .frame-state { background: var(--teal); }
.frame[data-status="error"] .frame-state { background: var(--red); }
.frame-count {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 0 4px;
  background: rgba(6, 7, 8, 0.72);
  color: #dce9e6;
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1.5;
}
.frame-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  background: rgba(6, 7, 8, 0.78);
  color: #f0e9dc;
  cursor: pointer;
  padding: 0;
}
.frame-remove .icon { width: 10px; height: 10px; }
.frame:hover .frame-remove, .frame:focus-within .frame-remove { display: flex; }
.frame-remove:hover { color: var(--red); }

.rail-note {
  margin: -2px 0 0;
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  color: var(--faint);
}

.rail-foot {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--line);
}
.model-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.model-line > span {
  flex: none;
  width: 42px;
  font-family: var(--font-label);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--faint);
}
.model-line strong {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-line code {
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.45;
  color: var(--faint);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
}
.model-alert {
  margin-top: 4px;
  padding: 8px 9px;
  border: 1px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-size: 10px;
  line-height: 1.6;
  word-break: break-word;
}

/* ---------- stage ---------- */

.stage {
  min-height: 0;
  padding: 26px 34px 56px;
  overflow-y: auto;
  background-image:
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 132px 100%;
  background-position: -1px 0;
}
.stage > * { position: relative; z-index: 1; }

/* ---------- empty ---------- */

.empty {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - var(--topbar-h) - 84px);
  padding: 24px 0;
}
.empty::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 1%;
  top: 50%;
  width: min(38vw, 460px);
  aspect-ratio: 1;
  transform: translateY(-50%);
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--line-strong) 0deg 1.2deg, transparent 1.2deg 15deg);
  mask: radial-gradient(circle, transparent 0 58%, #000 58.4% 62%, transparent 62.4%);
  -webkit-mask: radial-gradient(circle, transparent 0 58%, #000 58.4% 62%, transparent 62.4%);
  opacity: 0.8;
  animation: slow-spin 110s linear infinite;
  pointer-events: none;
}
.empty > * { position: relative; z-index: 1; }
.empty-num {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--faint);
  margin-bottom: 26px;
}
.empty-num span { color: var(--accent); }
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-label);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--accent);
}
.empty-hero h1 {
  margin: 0 0 24px;
  font-family: var(--font-display);
  font-size: clamp(62px, 8vw, 118px);
  font-weight: 400;
  line-height: 0.94;
  letter-spacing: -0.015em;
}
.empty-hero h1 em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 1.2px var(--accent);
  position: relative;
  left: 0.05em;
}
.lede {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.95;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.empty-hero > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.empty-hero .eyebrow { animation-delay: 0.04s; }
.empty-hero h1 { animation-delay: 0.1s; }
.empty-hero .lede { animation-delay: 0.18s; }

.empty-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 720px;
  margin-top: 42px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  animation: rise 0.7s 0.26s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.empty-facts > div {
  padding: 15px 18px 15px 0;
}
.empty-facts > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.empty-facts span {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.empty-facts p {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--text);
}
.empty-facts small {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}
.empty-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-top: 24px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  animation: rise 0.7s 0.34s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.empty-badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 6px var(--teal);
}

/* ---------- workspace ---------- */

.workspace { animation: rise 0.42s cubic-bezier(0.2, 0.7, 0.2, 1); }

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.stage-status {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.stage-status[data-busy="true"] { color: var(--accent); }
.stage-status[data-busy="true"]::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.work-top {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.preview-card {
  margin: 0;
  padding: 10px 10px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.preview-frame {
  position: relative;
  height: clamp(280px, 37vh, 378px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(80% 80% at 50% 45%, #16191b, #08090a 78%);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.preview-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 1;
}
.preview-frame .corner { border-color: rgba(255, 255, 255, 0.26); opacity: 0.8; }

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 22%, #fff5e2 50%, var(--accent) 78%, transparent);
  box-shadow: 0 0 16px 1px var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.preview-frame.scanning .scanline { opacity: 0.9; animation: scan 1.45s ease-in-out infinite; }

.preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(7, 8, 9, 0.62);
  backdrop-filter: blur(3px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #f2ece1;
}
.preview-overlay[data-mode="error"] { color: var(--red); }
.preview-overlay[data-mode="error"] .spinner { display: none; }

.spinner {
  width: 17px;
  height: 17px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.preview-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 2px 1px;
  min-width: 0;
}
.preview-card figcaption strong {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-card figcaption span {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background:
    radial-gradient(130% 100% at 100% 0%, var(--accent-soft), transparent 57%),
    var(--panel);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prompt-actions { display: flex; gap: 7px; }
.prompt-actions .btn { height: 29px; font-size: 9.5px; }

#prompt {
  flex: 1;
  width: 100%;
  min-height: 222px;
  margin-top: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.19);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.78;
  letter-spacing: 0.01em;
  resize: none;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.16s ease, background 0.16s ease;
}
#prompt:focus { border-color: var(--accent); background: rgba(0, 0, 0, 0.24); }
#prompt::placeholder { color: var(--faint); font-style: italic; }
html[data-theme="light"] #prompt { background: rgba(255, 255, 255, 0.58); }
html[data-theme="light"] #prompt:focus { background: rgba(255, 255, 255, 0.82); }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0.03em;
}
.rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.rating::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
}
.rating[data-rating="general"] { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 55%, transparent); }
.rating[data-rating="general"]::before { background: var(--teal); }
.rating[data-rating="sensitive"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.rating[data-rating="sensitive"]::before { background: var(--accent); }
.rating[data-rating="questionable"] { color: #d98a62; border-color: rgba(217, 138, 98, 0.55); }
.rating[data-rating="questionable"]::before { background: #d98a62; }
.rating[data-rating="explicit"] { color: var(--red); border-color: color-mix(in srgb, var(--red) 60%, transparent); }
.rating[data-rating="explicit"]::before { background: var(--red); }

/* ---------- controls ---------- */

.control-bar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.control { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.control.grow { flex: 1 1 240px; }
.control.compact { flex: none; }
.control label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-label);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.control label .hint { font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.02em; color: var(--faint); text-transform: none; }
.control output {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 14px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 35%), var(--line-strong) var(--fill, 35%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-soft);
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
}

.control input[type="number"] {
  width: 76px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  outline: none;
}
.control input[type="number"]:focus { border-color: var(--accent); }

#advanced-toggle .chevron { transition: transform 0.2s ease; width: 13px; height: 13px; }
#advanced-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
#advanced-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.advanced {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  animation: slide-down 0.18s ease both;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-family: var(--font-label);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.field input, .field select {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--faint); }

/* ---------- tags ---------- */

.tags-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.tags-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tag-summary {
  margin-left: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  color: var(--faint);
}
.tag-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.filter span { opacity: 0.55; font-size: 8px; }
.filter:hover { color: var(--text); border-color: var(--line-strong); }
.filter.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 65%, transparent); background: var(--accent-soft); }

.tags {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 68px;
  max-height: 318px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  overflow-y: auto;
}
.tags-empty {
  margin: 4px 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.8;
  color: var(--faint);
}
.tag {
  appearance: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 8px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.012);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, transform 0.14s ease, opacity 0.14s ease;
}
.tag:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.tag .score {
  font-size: 7.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.tag.selected {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 78%, transparent);
  background: var(--accent-soft);
}
.tag.selected .score { color: var(--accent); }
.tag.selected.cat-character {
  border-color: color-mix(in srgb, var(--teal) 72%, transparent);
  background: var(--teal-soft);
}
.tag.selected.cat-character .score { color: var(--teal); }
.tag.manual-off { border-style: dashed; opacity: 0.4; }
.tag.over-limit { opacity: 0.34; border-style: dotted; }

/* ---------- drop overlay ---------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(7, 8, 9, 0.78);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
body.dragging .drop-overlay { opacity: 1; visibility: visible; }
body.dragging .drop-overlay-inner { transform: scale(1); }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 54px 76px;
  border: 1px dashed var(--accent);
  background: rgba(12, 13, 14, 0.5);
  transform: scale(0.985);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.drop-overlay-inner strong {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 400;
  color: #f2ece1;
  line-height: 1;
}
.drop-overlay-inner small {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: #a49e92;
}

/* ---------- toast / misc ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  max-width: min(80vw, 560px);
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { background: var(--red); border-color: var(--red); color: #fff; }
.toast[data-type="success"] { background: var(--teal); border-color: var(--teal); color: #07110f; }

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  padding: 12px;
  border: 1px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  text-align: center;
}

/* ---------- MOSS export ---------- */

.moss-btn .icon { color: var(--accent); }
.moss-btn:hover .icon { color: currentColor; }

.moss-dialog {
  width: min(860px, calc(100vw - 36px));
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.moss-dialog::backdrop { background: rgba(4, 5, 6, 0.74); backdrop-filter: blur(5px); }
.moss-dialog[open] { animation: rise 0.2s ease both; }

.moss-shell { display: flex; flex-direction: column; max-height: calc(100vh - 42px); }

.moss-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 22px 15px;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(120% 170% at 100% 0%, var(--accent-soft), transparent 58%);
}
.moss-heading { min-width: 0; }
.moss-heading .eyebrow { color: var(--accent); font-size: 8px; letter-spacing: 0.28em; margin: 0; }
.moss-heading h2 {
  margin: 5px 0 4px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.1;
}
.moss-sub { margin: 0; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.04em; color: var(--muted); }
.moss-head .icon-btn { flex: none; }

.moss-body { padding: 18px 22px 4px; overflow-y: auto; }

.moss-modes {
  display: inline-flex;
  margin-bottom: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
}
.moss-mode {
  appearance: none;
  height: 30px;
  padding: 0 17px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.moss-mode + .moss-mode { border-left: 1px solid var(--line-strong); }
.moss-mode:hover:not(.active) { color: var(--text); }
.moss-mode.active { background: var(--accent); color: #17120a; font-weight: 600; }

.moss-field { margin-bottom: 14px; }
.moss-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  color: var(--muted);
  text-transform: uppercase;
}
.moss-label-row label { cursor: pointer; }
.moss-label-row span { color: var(--faint); font-size: 8.5px; text-transform: none; letter-spacing: 0.02em; }

#moss-positive,
#moss-negative {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  resize: vertical;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.16s ease, background 0.16s ease;
}
#moss-positive { min-height: 152px; }
#moss-negative { min-height: 66px; color: var(--muted); }
#moss-positive:focus,
#moss-negative:focus { border-color: var(--accent); background: rgba(0, 0, 0, 0.25); }
html[data-theme="light"] #moss-positive,
html[data-theme="light"] #moss-negative { background: rgba(255, 255, 255, 0.62); }
html[data-theme="light"] #moss-positive:focus,
html[data-theme="light"] #moss-negative:focus { background: rgba(255, 255, 255, 0.86); }

.moss-options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  background: rgba(0, 0, 0, 0.07);
}
.moss-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  cursor: pointer;
}
.moss-check input { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); }
.moss-check code { font-family: var(--font-mono); font-size: 9.5px; color: var(--faint); }
html[data-theme="light"] .moss-options { background: rgba(255, 255, 255, 0.36); }

.moss-tip {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--faint);
}

.moss-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.moss-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.moss-actions .btn { height: 34px; }
.moss-foot-note { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.03em; color: var(--faint); }
html[data-theme="light"] .moss-dialog::backdrop { background: rgba(63, 48, 24, 0.34); }

/* ---------- animation ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slow-spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}
@keyframes scan {
  0% { top: -2px; }
  100% { top: 100%; }
}

/* ---------- responsive ---------- */

@media (max-width: 1240px) {
  .shell { grid-template-columns: 320px minmax(0, 1fr); }
  .stage { padding: 24px 26px 50px; }
  .empty-hero h1 { font-size: clamp(58px, 7.4vw, 92px); }
  .advanced { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .work-top { grid-template-columns: minmax(0, 1fr); }
  .preview-frame { height: clamp(260px, 32vh, 330px); }
  #prompt { min-height: 200px; }
  .empty::before { opacity: 0.45; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .shell { display: block; height: auto; }
  .rail {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px 20px 20px;
  }
  .filmstrip { max-height: 130px; }
  .rail-foot { margin-top: 6px; }
  .model-line code { -webkit-line-clamp: 3; }
  .stage { overflow: visible; padding: 22px 22px 46px; background-size: 96px 100%; }
  .empty { min-height: 62vh; }
  .empty::before { display: none; }
  .empty-facts { margin-top: 30px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; }
  .brand-text span { display: none; }
  .model-chip { max-width: 138px; font-size: 9px; }
  .stage { padding: 18px 14px 40px; background-size: 78px 100%; }
  .rail { padding: 16px 14px 18px; }
  .dropzone { padding: 20px 12px 14px; }
  .drop-title { font-size: 22px; }
  .empty-hero h1 { font-size: clamp(48px, 14vw, 66px); }
  .lede { font-size: 11.5px; }
  .lede br { display: none; }
  .empty-facts { grid-template-columns: 1fr; }
  .empty-facts > div { padding: 11px 0; }
  .empty-facts > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .preview-frame { height: 240px; }
  .control-bar { gap: 12px; }
  .control.grow { flex-basis: 100%; }
  .advanced { grid-template-columns: 1fr; }
  .tags { max-height: 360px; }
  .tag { font-size: 10px; }
  .tags-head { align-items: flex-start; }
  .tag-summary { display: block; margin: 4px 0 0 0; }
  .film-head { align-items: flex-start; }
  .moss-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .moss-shell { max-height: calc(100vh - 22px); }
  .moss-head { padding: 16px 16px 13px; }
  .moss-heading h2 { font-size: 22px; }
  .moss-body { padding: 14px 16px 2px; }
  .moss-modes { display: flex; width: 100%; }
  .moss-mode { flex: 1; }
  #moss-positive { min-height: 140px; }
  .moss-foot { padding: 12px 16px; }
  .moss-actions { width: 100%; }
  .moss-actions .btn { flex: 1 1 calc(50% - 4px); }
  .moss-foot-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
