/* ==========================================================================
   GIGIOTER — global stylesheet

   The rule here is that the HTML tag carries the look. A class is only
   written when a tag genuinely cannot say what something is, because a
   class has to be remembered at every call site and a tag does not.
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  src: url("fonts/inter.260c81a4759b.woff2") format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Surfaces, darkest to lightest. */
  --bg:          #0d0d0f;
  --surface:     #16161a;
  --surface-2:   #1e1e24;
  --surface-3:   #26262e;
  --border:      #2a2a32;
  --border-lit:  #3a3a46;

  /* Ink, strongest to faintest. */
  --text:        #e8e8f0;
  --text-dim:    #9191a8;
  --text-muted:  #6b6b80;

  /* One accent, and the states everything else reports through. */
  --accent:      #a855f7;
  --accent-dim:  #7c3aed;
  --accent-glow: rgba(168,85,247,.15);
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --on-accent:   #fff;

  /* One height for everything that sits on a line together: buttons,
     links styled as buttons, inputs, selects, an empty textarea. */
  --control-h:   32px;
  --control-h-sm: 26px;

  /* One radius. */
  --radius:      8px;
  --radius-sm:   6px;
  --radius-pill: 999px;

  /* One spacing step. */
  --gap:         8px;
  --gap-lg:      16px;
  --pad:         16px;

  --font:        'Inter', system-ui, sans-serif;
  --font-mono:   'Menlo', 'Monaco', 'Consolas', monospace;

  --sidebar-w:   220px;
  --rail-w:      68px;
  --header-h:    56px;
  --pipeline-h:  52px;

  --speed:       .15s;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DOCUMENT ────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; min-width: 0; }

/* ── HEADINGS ────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
h5, h6 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

/* ── TEXT ────────────────────────────────────────────── */
p { color: var(--text-dim); }
strong, b { font-weight: 600; color: var(--text); }
em, i { font-style: italic; }
small { font-size: 11.5px; color: var(--text-muted); }
mark { background: var(--accent-glow); color: var(--text); padding: 0 3px; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
del { color: var(--text-muted); }
ins { text-decoration: none; color: var(--success); }
sub, sup { font-size: 75%; line-height: 0; }
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
code, samp, var {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
pre {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  overflow: auto;
}
pre code { font-size: inherit; }
blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  color: var(--text-dim);
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--gap-lg) 0;
}

/* ── LINKS ───────────────────────────────────────────── */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--speed);
}
a:hover { color: var(--accent-dim); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── LISTS ───────────────────────────────────────────── */
ul, ol { padding-left: 18px; color: var(--text-dim); }
li::marker { color: var(--text-muted); }
nav ul, nav ol { list-style: none; padding-left: 0; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--gap-lg); }
dt { font-size: 11.5px; color: var(--text-muted); }
dd { color: var(--text); }

/* ── TABLES ──────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
caption {
  text-align: left;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-bottom: var(--gap);
}
th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ── MEDIA ───────────────────────────────────────────── */
img, video, canvas, svg { max-width: 100%; display: block; }
figure { margin: 0; }
figcaption { font-size: 11px; color: var(--text-muted); }
audio { width: 100%; height: var(--control-h); }
iframe { border: none; }

/* ── FORMS ───────────────────────────────────────────── */
/* Everything that sits on a line together is the same height, so a
   button beside a field needs no nudging to line up. */
fieldset { border: none; }
legend {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding-bottom: var(--gap);
}
label { font-size: 11.5px; color: var(--text-muted); }
form { min-width: 0; }
output { font-size: 12px; color: var(--text-dim); }

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

input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,
textarea {
  height: var(--control-h);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0 10px;
  outline: none;
  transition: border-color var(--speed);
}
textarea {
  height: auto;
  min-height: var(--control-h);
  padding: 6px 10px;
  line-height: 1.6;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled, button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
input[type=checkbox], input[type=radio] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type=file] { font-size: 12px; color: var(--text-muted); }
input[type=range] { accent-color: var(--accent); height: var(--control-h); }
input[type=color] {
  width: var(--control-h);
  padding: 2px;
  cursor: pointer;
}

/* The platform's own arrow ignores the theme, so it is drawn here. */
select {
  appearance: none;
  padding-right: 26px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 12px center, right 7px center;
  background-repeat: no-repeat;
}
select option { background: var(--surface); color: var(--text); }

/* ── BUTTONS ─────────────────────────────────────────── */
/* A button is an action wherever it is written. The accent one is the
   one action a screen is for, so it is asked for with [data-primary]
   rather than assumed. */
button, input[type=submit], input[type=reset] {
  height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--speed), border-color var(--speed),
              background var(--speed);
}
button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-lit);
}
button[data-primary] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
button[data-primary]:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent);
}
button[data-danger]:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}
/* A button that is only its icon is square, not a wide slab. */
button[data-icon] { width: var(--control-h); padding: 0; }
/* A button carrying no chrome at all, for tools inside dense rows. */
button[data-bare] {
  height: auto;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
}
button[data-bare]:hover:not(:disabled) {
  background: none;
  border: none;
  color: var(--text);
}

/* ── DISCLOSURE & DIALOG ─────────────────────────────── */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: '▸ '; color: var(--text-muted); }
details[open] summary::before { content: '▾ '; }

dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: var(--pad);
}
dialog::backdrop { background: rgba(0,0,0,.7); }

progress {
  width: 100%;
  height: 4px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--border);
  accent-color: var(--accent);
}
progress::-webkit-progress-bar {
  background: var(--border);
  border-radius: var(--radius-pill);
}
progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: var(--radius-pill);
}
meter { width: 100%; height: 4px; }

/* ── ICONS ───────────────────────────────────────────── */
.icon {
  width: 1.05em;
  height: 1.05em;
  display: inline-block;
  vertical-align: -0.18em;
  flex-shrink: 0;
}
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }

/* ── TOP BAR ─────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}
.topbar-brand {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
  border-right: 1px solid var(--border);
  height: 100%;
}
.topbar-brand .logo-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-accent);
  flex-shrink: 0;
}
.topbar-brand .logo-dot .icon { width: 16px; height: 16px; }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.topbar-badge span { color: var(--accent); font-weight: 600; }
/* The base select already carries the shape; this only dims it a shade
   and is kept because it is spelled across a dozen templates. */
.model-select { color: var(--text-dim); font-size: 12px; }
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ── LAYOUT ──────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--rail-w);
  overflow-y: auto;
  padding: 16px 0 24px;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }

.sidebar-section { margin-bottom: 6px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
}
.nav-item .step-num {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--text-muted);
}
.nav-item.active .step-num {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── LOCKED NAV ──────────────────────────────────────── */
.nav-item.locked {
  opacity: .45;
  cursor: default;
  pointer-events: none;
}
.nav-item.locked .lock-icon {
  margin-left: auto;
  width: 12px; height: 12px;
  opacity: .7;
}
.nav-item.locked .step-num + .lock-icon { margin-left: 6px; }

/* ── LOCKED OVERLAY ──────────────────────────────────── */
.locked-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: calc(var(--rail-w) + var(--sidebar-w));
  right: 0; bottom: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.locked-overlay.visible { display: flex; }
.locked-overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 48px;
  text-align: center;
  pointer-events: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  max-width: 400px;
}
.locked-overlay-card .lock-big {
  width: 40px; height: 40px;
  margin: 0 auto 16px;
  display: block;
  color: var(--text-muted);
}
.locked-overlay-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.locked-overlay-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.main.blurred {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  transition: filter .4s ease;
}

.pipeline-connector {
  width: 2px;
  height: 10px;
  background: var(--border);
  margin: 0 0 0 38px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 16px;
}

/* ── MAIN CONTENT ────────────────────────────────────── */
.main {
  margin-left: var(--rail-w);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
}
/* Padding belongs to the content, not to the area: a page that draws its
   own full-width bar needs the area to start flush against the rail. */
.page-pad { padding: 16px; }
/* A page that draws a sidebar has to step around it. */
.page-pad.with-sidebar { margin-left: var(--sidebar-w); }

/* ── FORM CONTROLS ───────────────────────────────────── */
/* On the tags themselves, so a field looks right wherever it is put
   rather than only where someone remembered the class. The height
   matches a button's, so a field and a button sit on one line. */
input[type=text],
input[type=password],
input[type=number],
input[type=email],
input[type=search],
select {
  height: var(--control-h);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  padding: 7px 10px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* The stock arrow is drawn by the platform and ignores the theme. */
select {
  appearance: none;
  padding-right: 26px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 12px center, right 7px center;
  background-repeat: no-repeat;
}
select option { background: var(--surface); color: var(--text); }

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.page-header .breadcrumb a { color: var(--text-dim); text-decoration: none; }
.page-header .breadcrumb a:hover { color: var(--text); }
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header h1 .icon { width: 26px; height: 26px; color: var(--accent); }
.page-header p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── GRID ────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── PLACEHOLDER / STUB ──────────────────────────────── */
.stub-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  gap: 12px;
  color: var(--text-muted);
}
.stub-icon {
  width: 48px; height: 48px;
  opacity: .5;
  color: var(--text-muted);
}
.stub-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
}
.stub-desc {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  max-width: 340px;
  line-height: 1.6;
}
.stub-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .05em;
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s ease;
}
.btn .icon { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn:disabled, .btn.is-loading {
  opacity: .55;
  cursor: wait;
  pointer-events: none;
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
}
.btn.is-loading {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: .85; }
}

/* ── UTILITIES ───────────────────────────────────────── */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex   { display: flex; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── BADGES (status / source) ────────────────────────── */
.status-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap;
}
.st-0 { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.3);  color: var(--info); }
.st-1 { background: rgba(168,85,247,.1);  border: 1px solid rgba(168,85,247,.3);  color: var(--accent); }
.st-2, .st-3, .st-4, .st-5, .st-6 {
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3); color: var(--warning);
}
.st-7 { background: rgba(34,197,94,.08);  border: 1px solid rgba(34,197,94,.3);  color: var(--success); }
.st-8 { background: rgba(34,197,94,.15);  border: 1px solid rgba(34,197,94,.4);  color: var(--success); }

.active-badge { background: var(--accent-glow); border: 1px solid var(--accent); color: var(--accent); }

/* ── TABS (idea / script lists) ──────────────────────── */
.idea-tabs {
  display: flex; gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.idea-tab {
  padding: 10px 20px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  user-select: none;
}
.idea-tab:hover { color: var(--text); }
.idea-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.idea-tab .tab-count {
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1px 7px; margin-left: 6px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── CARDS (char + script) ───────────────────────────── */
.char-card, .script-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin: 6px 0;
  cursor: pointer; transition: border-color .15s;
}
.char-card:hover, .script-card:hover { border-color: var(--accent); }
.char-card.active, .script-card.active { border-color: var(--accent); background: var(--accent-glow); }

.card-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.char-title, .card-title-list {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}

.card-detail {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.char-card.expanded .card-detail,
.script-card.expanded .card-detail { display: block; }
.char-body, .card-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 8px;
}
.char-tags, .card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.char-tag, .card-tag {
  font-size: 10px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm); padding: 2px 7px;
}

/* ── RENAME PENCIL ───────────────────────────────────── */
.rename-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px 4px; line-height: 1; border-radius: var(--radius-sm);
  opacity: 0; transition: opacity .15s, color .15s;
}
.rename-btn .icon { width: 13px; height: 13px; }
.char-card.expanded .rename-btn,
.script-card.expanded .rename-btn { opacity: 1; }
.rename-btn:hover { color: var(--accent); }

/* ── SEARCH BOX ──────────────────────────────────────── */
.search-box {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px;
  padding: 9px 14px; outline: none;
  transition: border-color .15s; box-sizing: border-box;
}
.search-box:focus { border-color: var(--accent); }

/* ── MODALS ──────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}
.modal input, .modal select, .modal textarea,
.modal-input, .modal-textarea { width: 100%; }
.modal textarea, .modal-textarea {
  resize: vertical; min-height: 90px;
}
.modal-close-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; line-height: 1; padding: 0;
}
.modal-close-btn .icon { width: 18px; height: 18px; }
.modal-cancel-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius);
  padding: 9px 18px; font-size: 13px; cursor: pointer;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px;
}
.modal-field {
  display: flex; flex-direction: column; gap: 5px;
}
.modal-field > span {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
}
.editable-row {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.editable-row input[type=text],
.editable-row textarea {
  background: var(--surface);
  font-size: 12.5px;
  resize: vertical;
}
.editable-row .name-input { font-weight: 700; }

/* ── EDIT-SCRIPT EDITOR ──────────────────────────────── */
.script-editor {
  width: 100%;
  min-height: 520px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-mono);
  line-height: 1.8;
  padding: 18px 20px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.script-editor:focus { border-color: var(--accent); }

.ai-status {
  display: none;
  font-size: 12.5px; color: var(--text-muted);
  align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ai-status.visible { display: flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.idea-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.65;
}

.version-tabs {
  display: flex; gap: 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.version-tab {
  padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color .15s, border-color .15s;
  display: flex; align-items: center; gap: 5px;
}
.version-tab:hover { color: var(--text); }
.version-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.version-rename-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0 2px; line-height: 1;
}
.version-rename-btn .icon { width: 12px; height: 12px; }
.version-rename-btn:hover { color: var(--accent); }

/* ── HOT TOPICS ──────────────────────────────────────── */
.iwc-tabs { display: flex; gap: 6px; }
.iwc-tab {
  padding: 7px 16px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
  line-height: 1.4; box-sizing: border-box;
  display: inline-flex; align-items: center; gap: 6px;
}
.iwc-tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.iwc-tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }

.iwc-period-btn {
  padding: 7px 16px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  line-height: 1.4;
  display: inline-block;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text-muted);
}
.iwc-period-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.iwc-list { display: none; }
.iwc-list.active { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }

.iwc-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 12.5px; transition: border-color .15s;
  text-decoration: none;
}
.iwc-row:hover { border-color: var(--accent); }
.iwc-rank {
  font-size: 11px; font-weight: 800;
  color: var(--accent); background: var(--accent-glow);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 1px 6px; min-width: 26px; text-align: center;
}
.iwc-info { flex: 1; min-width: 0; }
.iwc-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iwc-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: var(--radius);
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.loading { opacity: .6; pointer-events: none; }

.iwc-meta { font-size: 11.5px; color: var(--text-muted); }
.iwc-meta .ok   { color: var(--success); }
.iwc-meta .warn { color: var(--warning); }

.cat-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 12.5px;
  transition: border-color .15s, background .15s;
  cursor: pointer; user-select: none;
}
.cat-row:hover { border-color: var(--accent); }
.cat-row.selected { border-color: var(--accent); background: var(--accent-glow); }
.cat-row.selected .iwc-rank { background: var(--accent); color: var(--on-accent); }
.cat-row.disabled { opacity: .4; pointer-events: none; }

.gen-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
  transform: translateY(100%); transition: transform .2s ease;
}
.gen-bar.visible { transform: translateY(0); }
.gen-bar-info { font-size: 13px; color: var(--text-dim); }
.gen-bar-info strong { color: var(--text); }
.gen-bar-btn {
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--radius); padding: 10px 22px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.gen-bar-btn:hover { background: var(--accent-dim); }
.gen-bar-btn:disabled { opacity: .5; pointer-events: none; }

.info-block {
  background: rgba(59,130,246,.06);
  border: 1px solid rgba(59,130,246,.2);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 12.5px; color: var(--text-dim);
  margin-bottom: 14px; line-height: 1.55;
  display: flex; align-items: flex-start; gap: 10px;
}
.info-block .icon { color: var(--info); flex-shrink: 0; margin-top: 2px; }

/* ── IMAGE GENERATION ────────────────────────────────── */
.hidden { display: none !important; }

.analysis-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.analysis-section { display: flex; flex-direction: column; gap: 6px; }
.analysis-label {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent);
}
.analysis-row {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}
.analysis-row strong { color: var(--text); }

.scene-chip {
  font-size: 10.5px; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  display: inline-flex; align-items: center; gap: 4px;
}
.scene-chip .icon { width: 11px; height: 11px; }

.scene-block { margin-bottom: 8px; }
.scene-block-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px;
}
.scene-block-label .icon { width: 11px; height: 11px; }
.scene-block-text {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}
.scene-block-evolution {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  background: var(--accent-glow);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
}
.scene-block-evolution .scene-block-label { color: var(--accent); }

.scene-prompt-details {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 6px 0 10px;
}
.scene-prompt-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}
.scene-prompt-details summary:hover { color: var(--text); }
.scene-prompt-text {
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-dim);
  white-space: pre-wrap;
}


.scene-list { display: flex; flex-direction: column; gap: 14px; }
.scene-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.scene-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.scene-num {
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  min-width: 30px; text-align: center;
}
.scene-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 10px;
}
.scene-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.scene-actions .btn { font-size: 12px; padding: 7px 14px; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.image-tile {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}
.image-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.image-tile .img-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  color: var(--on-accent);
  font-size: 11px;
  padding: 18px 10px 8px;
  line-height: 1.4;
}
.image-tile .img-delete {
  position: absolute;
  top: 6px; right: 6px;
  margin: 0;
}
.image-tile .img-delete form { margin: 0; }
.image-tile .img-delete button {
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex; align-items: center;
}
.image-tile .img-delete button:hover { background: var(--danger); }
.image-tile .img-delete .icon { width: 13px; height: 13px; }

.image-tile.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
}
.image-tile.placeholder .spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ── LIGHTBOX ─────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.93);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  cursor: default;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: var(--on-accent);
  border-radius: 50%;
  width: 38px; height: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.18); }
.lightbox-close .icon { width: 18px; height: 18px; }

/* ── LOGIN PAGE ──────────────────────────────────────── */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 30px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  margin-bottom: 22px;
}
.login-brand .logo-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-accent);
}
.login-brand .logo-dot .icon { width: 16px; height: 16px; }
.login-title {
  font-size: 20px; font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  letter-spacing: -.3px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.login-form input {
  width: 100%;
  height: 40px;
  font-size: 13.5px;
  padding: 0 14px;
}
.login-submit {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
}
.login-error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}

/* ── TOPBAR USER ─────────────────────────────────────── */
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.topbar-user .username { color: var(--text); font-weight: 600; }
.topbar-user .badge-admin {
  font-size: 9px; font-weight: 800;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.logout-btn {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.logout-btn:hover { color: var(--danger); }
.logout-btn .icon { width: 14px; height: 14px; }

/* ── STORYBOARD ───────────────────────────────────── */
.scene-chip.stage-empty  { color: var(--text-muted); }
.scene-chip.stage-seed   { color: var(--info);    border-color: var(--info); }
.scene-chip.stage-clips  { color: var(--warning); border-color: var(--warning); }
.scene-chip.stage-ready  { color: var(--success); border-color: var(--success); }

.model-select.saved {
  border-color: var(--success);
  transition: border-color .2s;
}

.scene-progress {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.scene-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.scene-progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .4s;
}
.scene-progress-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── MODEL LIBRARY ────────────────────────────────── */

/* ── SUPPORT ──────────────────────────────────────── */

/* ── SECTION RAIL ─────────────────────────────────── */
.rail {
  width: var(--rail-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 60;
}
.rail-sections { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rail-logo {
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  margin: 0 0 10px;
  text-decoration: none;
}
.rail-logo .icon { width: 22px; height: 22px; }
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  margin: 0 8px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.rail-item .icon { width: 20px; height: 20px; }
.rail-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
}
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

/* ── PIPELINE BAR ─────────────────────────────────── */
.pipeline-bar {
  height: var(--pipeline-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 18px;
  overflow-x: auto;
}
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.pipeline-step .icon { width: 15px; height: 15px; }
.pipeline-step:hover { background: var(--surface-2); color: var(--text); }
.pipeline-step.active { background: var(--accent-glow); color: var(--accent); }
.pipeline-step.locked { opacity: .45; }
.pipeline-num {
  font-size: 10px;
  font-weight: 800;
  min-width: 17px; height: 17px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
}
.pipeline-step.active .pipeline-num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.pipeline-arrow {
  color: var(--border);
  display: inline-flex;
  flex-shrink: 0;
}
.pipeline-arrow .icon { width: 13px; height: 13px; }

/* ── RAIL FOOT: character and account ─────────────── */
.rail-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin: 0 8px;
  position: relative;
}
.rail-btn, .rail-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.rail-btn:hover { background: var(--surface); color: var(--text); }
.rail-btn .icon { width: 17px; height: 17px; }
.rail-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.rail-avatar:hover { filter: brightness(1.12); }

.rail-menu {
  display: none;
  position: absolute;
  left: calc(100% + 10px);
  bottom: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
  z-index: 200;
}
.rail-menu.open { display: block; }
.rail-menu-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 7px 10px 8px;
  display: flex; align-items: center; gap: 6px;
}
.rail-menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.rail-menu-item:hover { background: var(--surface-2); color: var(--text); }
.rail-menu-item.current { color: var(--accent); }
/* A leading icon stays with its label; only the tick on the current entry
   is pushed to the far edge. */
.rail-menu-item .icon { width: 14px; height: 14px; flex-shrink: 0; }
.rail-menu-item.current .icon { color: var(--accent); margin-left: auto; }
.rail-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}
.rail-menu-empty {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 10px;
}

/* ── PROFILE ──────────────────────────────────────── */
.profile-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--on-accent);
  font-size: 18px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-facts {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 9px 16px;
  margin: 0;
  font-size: 13px;
}
.profile-facts dt {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  padding-top: 2px;
}
.profile-facts dd { margin: 0; color: var(--text); }

/* ── IDEA TILES ───────────────────────────────────── */
.idea-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.idea-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 132px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s;
}
.idea-tile:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.idea-tile.current { border-color: var(--accent); background: var(--accent-glow); }
.idea-tile-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.idea-tile-foot {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.idea-tile-stage { color: var(--accent); }

.idea-tile-new {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  font: inherit;
}
.idea-tile-new .icon { width: 30px; height: 30px; }
.idea-tile-new:hover { color: var(--accent); }

/* ── SCRIPT EDITOR ────────────────────────────────── */
/* A row of icons, not a bar: nothing here needs a label or a rule under
   it, and the document should start at the top of the page. */
.script-tools {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 0;
  background: var(--bg);
}
.script-tools-meta {
  margin-right: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.script-tool {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
}
.script-tool:hover { color: var(--text); border-color: var(--text-muted); }
.script-tool .icon { width: 15px; height: 15px; }
.script-tool[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.script-tool.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.script-tool.primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent);
}

/* One page of text: scenes are ruled off from each other, and the fields
   inside a scene by a lighter dashed line. */
.script-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 14px 0;
}
.script-scene {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 14px 20px 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.script-scene:last-child { border-bottom: none; }
.script-scene-body { flex: 1; min-width: 0; }

/* A column to take hold of: the cursor says it can be picked up. */
.script-grip {
  flex: 0 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: grab;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  opacity: .35;
  transition: opacity .15s, background .15s;
}
.script-grip span {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 6px 0 0 currentColor;
  margin-left: -3px;
}
.script-scene:hover .script-grip { opacity: 1; }
.script-grip:hover { background: var(--surface-2); }
.script-grip:active { cursor: grabbing; }

.script-scene.dragging {
  opacity: .5;
  background: var(--surface-2);
}
.script-scene.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.script-scene.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }

.script-scene-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.script-scene-version { font-size: 11px; color: var(--text-muted); }
.script-scene-tools { margin-left: auto; display: flex; gap: 2px; }
.script-scene-tools button {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  padding: 3px 7px;
  cursor: pointer;
  display: inline-flex; align-items: center;
}
.script-scene-tools button:hover {
  color: var(--text);
  border-color: var(--border);
}
.script-scene-tools button.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.script-scene-tools .icon { width: 13px; height: 13px; }

.script-field {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}
.script-field:first-of-type { border-top: none; }
.script-field > span {
  flex: 0 0 104px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted);
  padding-top: 3px;
}
/* Grows with what is typed, one line tall when empty. */
.script-field textarea {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  padding: 1px 0;
  resize: none;
  overflow: hidden;
}
.script-field textarea:focus { outline: none; }
.script-field textarea::placeholder { color: var(--text-muted); opacity: .6; }

.script-insert {
  position: absolute;
  left: 50%; bottom: -13px;
  transform: translateX(-50%);
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  z-index: 10;
}
.script-scene:hover .script-insert { opacity: 1; }
.script-insert:hover { border-color: var(--accent); color: var(--accent); }
.script-insert .icon { width: 13px; height: 13px; }

.script-empty { color: var(--text-muted); font-size: 13px; padding: 20px; }
.link-button {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
/* ── CHARACTER CARDS ──────────────────────────────── */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 150px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: border-color .15s, background .15s, transform .15s;
}
.char-card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.char-card.current { border-color: var(--accent); background: var(--accent-glow); }
.char-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--on-accent);
  font-size: 17px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-avatar-edit { cursor: pointer; }
.char-avatar-edit:hover { filter: brightness(1.12); }
.char-card-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: center;
}
.char-card-people {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}
.char-card-new {
  border-style: dashed;
  color: var(--text-muted);
  justify-content: center;
}
.char-card-new .icon { width: 28px; height: 28px; }
.char-card-new:hover { color: var(--accent); }

.char-card-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.char-modal-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}
.char-people-row { display: flex; flex-wrap: wrap; gap: 6px; }
.char-person-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 4px 11px;
  cursor: pointer;
}
.char-person-btn:hover { color: var(--text); border-color: var(--text-muted); }
.char-person-btn.on { color: var(--accent); border-color: var(--accent); }
.char-person-btn:disabled { opacity: .55; cursor: default; }
.char-person-btn .icon { width: 12px; height: 12px; }

.scene-field input[type=text] { width: 100%; }

/* The wrapper takes the grid cell so the tile keeps its own shape. */
.idea-tile-wrap { position: relative; display: flex; }
.idea-tile-wrap .idea-tile { flex: 1; min-width: 0; }
.idea-tile-tools {
  position: absolute;
  top: 8px; right: 8px;
  display: inline-flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.idea-tile-wrap:hover .idea-tile-tools { opacity: 1; }
.idea-tile-tools button {
  width: 26px; height: 26px;
  border-radius: var(--radius);
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.idea-tile-tools button:hover { color: var(--accent); border-color: var(--accent); }
.idea-tile-tools button.danger:hover { color: var(--danger); border-color: var(--danger); }
.idea-tile-tools .icon { width: 13px; height: 13px; }

/* ── IMAGES ─────────────────────────────────────────────────────────── */
/* A field that has just saved itself says so without a dialog. */
.script-field textarea.saved {
  animation: field-saved 1.2s ease-out;
}
@keyframes field-saved {
  0%   { background: var(--accent-glow); }
  100% { background: transparent; }
}

/* The pictures of one scene, left to right in the order they will be used. */
.image-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px dashed var(--border);
}
.image-strip-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.image-tile {
  position: relative;
  width: 148px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  cursor: grab;
}
.image-tile.dragging { opacity: 0.4; }
.image-tile img {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: cover;
}
.image-tile figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  font-size: 10.5px;
  color: var(--text-muted);
}
.image-tile figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-tile figcaption button {
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.image-tile figcaption button.danger:hover { color: var(--danger); }

.image-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
}
/* A file picker is a label, but it acts as a button, so it looks like
   one: the input itself is hidden and unstyleable across browsers. */
.image-upload {
  height: var(--control-h);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--speed), border-color var(--speed);
}
.image-upload:hover { color: var(--text); border-color: var(--border-lit); }

/* A scene being written: dimmed, with the job's own progress on top. */
.script-scene.busy .script-scene-head,
.script-scene.busy .script-field,
.script-scene.busy .script-insert {
  opacity: 0.35;
  pointer-events: none;
}
/* display:flex would otherwise beat the hidden attribute's own rule. */
.scene-busy[hidden] { display: none; }
.scene-busy {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px;
}
.scene-busy-label {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.scene-busy-track {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border);
  overflow: hidden;
}
.scene-busy-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.scene-busy-fill.sweeping {
  width: 35%;
  animation: scene-sweep 1.2s ease-in-out infinite;
}
@keyframes scene-sweep {
  0%   { margin-left: -35%; }
  100% { margin-left: 100%; }
}

/* A modal that asks for the few things a generation needs. */
.modal-label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: -4px;
}
.modal-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── LAYOUT PRIMITIVES ───────────────────────────────── */
/* The few arrangements the tags cannot express. Everything else that
   was once an inline style is a tag or an attribute above. */
.row {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}
.row[data-tight] { gap: 4px; }
.row[data-wide] { gap: var(--gap-lg); }
.row[data-between] { justify-content: space-between; }
.row[data-end] { justify-content: flex-end; }
.row[data-top] { align-items: flex-start; }
.col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }

.scene-chip[data-accent] { border-color: var(--accent); color: var(--accent); }

small[data-accent] { color: var(--accent); }
small[data-info] { color: var(--info); }

/* ── IDEAS (characters.html) ─────────────────────────── */
.idea-card .clamp-3 {
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.idea-card .push-top { margin-top: auto; }
.idea-card p[data-warning] { color: var(--warning); }

/* ── EXPORTS (exports.html) ──────────────────────────── */
/* A video tile is as tall as its clip, so the square ratio is dropped. */
.export-tile {
  aspect-ratio: auto;
  padding: 0 2px 2px;
}
.export-tile video {
  display: block;
  width: 100%;
  border-radius: var(--radius);
}
.export-tile > .scene-chip { position: absolute; left: 6px; top: 6px; }
.export-tile .col { gap: 4px; padding: 8px 2px 2px; }
.export-tile a[download] { align-self: flex-start; }

/* ── NOTICES ─────────────────────────────────────────── */
/* One shape; the state picks the colour it is tinted with. */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px var(--pad);
  color: var(--text-dim);
  margin-bottom: var(--gap-lg);
}
.notice[data-danger]  { color: var(--danger);  border-color: var(--danger); }
.notice[data-warning] { color: var(--warning); border-color: var(--warning); }
.notice[data-info]    { color: var(--info);    border-color: var(--info); }
.notice[data-success] { color: var(--success); border-color: var(--success); }

.info-block[data-warning] { border-color: var(--warning); }

/* A row that closes a section off from what follows it. */
.row[data-rule] {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* A destructive confirmation is the accent button turned red. */
button[data-destructive] {
  background: var(--danger);
  border-color: var(--danger);
}
button[data-destructive]:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  opacity: .85;
}

.card[data-narrow] { max-width: 520px; }
.spinner[data-small] { width: 12px; height: 12px; }
.scene-chip[data-corner] { position: absolute; left: 6px; top: 6px; }

/* ── STORYBOARD, LIP SYNC, AUDIO: shared corrections ─────────────────── */
/* An info block that reports a caution rather than a fact. */
.info-block[data-warning] {
  background: rgba(245,158,11,.06);
  border-color: var(--warning);
}
.info-block[data-warning] .icon { color: var(--warning); }

/* A word of caution inside a sentence: the tag already says "important",
   the attribute only says which colour the importance is. */
[data-warn] { color: var(--warning); }

/* A chip pinned to the corner of the tile it describes. */
.scene-chip[data-corner] {
  position: absolute;
  top: 6px; left: 6px;
}
.scene-chip[data-accent] { border-color: var(--accent); color: var(--accent); }
.scene-chip[data-accent] code { color: inherit; }

/* A tile holding a video keeps the clip's own shape instead of a square. */
.image-tile[data-media] {
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  cursor: default;
}
.image-tile[data-media] video { border-radius: var(--radius); }
/* The tools of a tile sit left when the right corner is already taken. */
.image-tile .img-delete[data-left] { right: auto; left: 6px; }

/* A number is read by its last digit, so the field is only as wide as one. */

/* A voiceover beside its own controls: the player takes the room it needs
   and no more, so the button stays on the same line. */
.scene-voice audio { width: auto; flex: 1; }

/* ── STORYBOARD ─────────────────────────────────────────────────────── */
.scene-progress progress { flex: 1; }

/* ── MODEL LIBRARY ──────────────────────────────────────────────────── */
/* A table wider than the screen scrolls on its own rather than stretching
   the page. */
.page-pad h2 { margin-top: 24px; }
/* The model's own id belongs under its name, not beside it. */

/* ── PUBLISH ────────────────────────────────────────────────────────── */
/* A placeholder standing in for a panel, not for a whole page. */
.stub-container[data-short] { min-height: 200px; }
/* A card whose one action is a link across its foot. */
.card > a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h);
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card > a[data-primary] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.card > a[data-primary]:hover { background: var(--accent-dim); color: var(--on-accent); }

/* ── ASSET FEED (standalone page) ────────────────────── */
/* One column at 90%, so the page is the pictures and nothing else. */
.feed {
  display: block;
  width: 90%;
  margin: 0 auto;
  padding: 24px 0 48px;
}
.feed header { margin-bottom: 22px; }
.feed figure { margin-bottom: 30px; }
.feed img, .feed video {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.feed figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-top: var(--gap);
}
.feed time { color: var(--text-muted); }
.feed mark {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
}
.feed nav {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 32px;
}
.feed nav a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  height: var(--control-h);
  display: inline-flex;
  align-items: center;
}
.feed nav a:hover { background: var(--surface-2); }

/* A field holding a number needs only the width of one. */
.num-field { width: 88px; }

/* ── REFERENCE PAGE (standalone) ─────────────────────── */
/* A page of tables that stands on its own: no rail, no section, so it
   depends on nothing the app's layout provides. */
.reference {
  display: block;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px var(--pad) 48px;
}
.reference header { margin-bottom: 22px; }
.reference h2 { margin: 28px 0 10px; }
.reference table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.reference td { vertical-align: top; }
.reference td small { display: block; }
.reference td strong { white-space: nowrap; }

/* ── EXPORTS ─────────────────────────────────────────── */
/* A finished video reads as one entry of the same document the script
   and the images are drawn as. */
.export-video {
  width: 100%;
  max-width: 560px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
/* A link acting as a tool sits on the row like the buttons beside it. */
a.script-tool {
  color: var(--text-muted);
  text-decoration: none;
}
a.script-tool:hover { color: var(--text); border-color: var(--border-lit); }
.script-scene-tools a {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}
.script-scene-tools a:hover { color: var(--text); }
