/* ==========================================================================
   Design D, "cinematic dark" (site_design.py, Oct 14, 2026).
   Loaded AFTER style.css, and only while SITE_DESIGN_D is on for the viewer (or an admin's ?preview=d).
   It re-points style.css's own tokens and restyles the shared building blocks (sidebar, cards, buttons, fields,
   tables), so every logged-in page picks up the look without its template changing.
   Contrast: body text #f2efe8 and muted #a9a49a on #10121a cards are 15:1 and 7.5:1; button text is white on
   #7454ff (4.7:1, a hair deeper than the mockup's #7c5cff, which is 4.35:1 and just misses 4.5:1).
   ========================================================================== */
:root {
  --bg: #07080c;
  --bg-soft: #0a0b10;
  --surface: #10121a;
  --surface-2: #171a24;
  --surface-3: #1e2130;
  --border: #1f2230;
  --border-strong: #2c3040;
  --text: #f2efe8;
  --muted: #a9a49a;
  --faint: #8e897f;
  --accent: #7c5cff;
  --accent-hover: #c4b5fd;
  --accent-soft: rgba(124, 92, 255, .16);
  --accent-glow: rgba(124, 92, 255, .28);
  --grad: linear-gradient(#7454ff, #7454ff);
  --gold: #d6b35a;
  --gold-soft: rgba(214, 179, 90, .14);
  --action: #7454ff;
  --action-hover: #6646f2;
  --active: #1a1830;
  --radius: 18px;
  --radius-sm: 12px;
  --font-heading: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-word: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --card: var(--surface);
}

html, body { background: var(--bg); }
body { color: var(--text); font-family: var(--font-body); overflow-x: hidden; }
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: -0.025em; color: #fff; }
h1 { font-weight: 800; letter-spacing: -0.03em; }
a { color: var(--accent-hover); }
a:hover { color: #e2dbff; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Buttons ---------- */
button, .btn {
  background: var(--action); border-radius: var(--radius-sm); box-shadow: none; min-height: 44px;
}
button:hover, .btn:hover { background: var(--action-hover); filter: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-ghost, .btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-sm, button.btn-sm { background: var(--surface-2); border-color: var(--border-strong); min-height: 36px; }
.btn-sm:hover, button.btn-sm:hover { background: var(--surface-3); }
button:disabled, .btn[aria-disabled="true"] { background: var(--surface-3); color: var(--muted); box-shadow: none; cursor: not-allowed; }

/* ---------- Fields ---------- */
textarea, input[type=email], input[type=password], input[type=text], input[type=number], input[type=file],
input[type=url], input[type=search], input[type=tel] {
  background: var(--surface-2); border-color: var(--border-strong); border-radius: var(--radius-sm); color: var(--text);
}
select { background-color: var(--surface-2); border-color: var(--border-strong); }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { color: var(--muted); }

/* ---------- Surfaces ---------- */
.card, .composer, .st-card, .auth-card { background: var(--surface); border-color: var(--border); border-radius: var(--radius); }
.composer { border-radius: 24px; border-color: var(--border-strong); }
table { background: var(--surface); border-color: var(--border); border-radius: var(--radius-sm); }
th { background: var(--surface-2); color: var(--muted); }
th, td { border-bottom-color: var(--border); }
.pkg .num, .stat .num, .credit-total .num { font-family: var(--font-heading); }
.kind-tag { border-radius: 999px; }
.tool-tab.active, button.tool-tab.active { background: var(--active); border-color: var(--accent); }
.scene.in-use { background: var(--active); }

/* ---------- Brand ---------- */
.brand-logo { font-family: var(--font-word); }
.brand-logo span { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--gold); letter-spacing: .32em; }
.d-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.d-brand:hover { color: var(--text); }
.d-brand .helm { flex: none; }
.d-word { display: flex; flex-direction: column; gap: 4px; }
.d-word-main { font: 800 17px/1 var(--font-word); letter-spacing: -0.01em; }
.d-word-sub { font: 700 8.5px/1 var(--font-word); letter-spacing: .32em; color: var(--gold); }

/* ---------- App shell: the design D sidebar (templates/_appnav_d.html) ---------- */
.sidebar { background: var(--bg-soft); border-right-color: #171922; }
.side-label { color: var(--faint); font-size: .72rem; letter-spacing: .1em; padding: 16px 12px 6px; }
.side-link { color: #cfcac0; font-size: .95rem; padding: 10px 12px; min-height: 44px; border-radius: 10px; }
.side-link:hover { background: var(--surface-2); color: #fff; }
.side-link.active { background: var(--active); color: #fff; box-shadow: none; font-weight: 600; }
.side-link.active svg { color: var(--gold); }
.credit-box { background: var(--surface); border-color: var(--border); border-radius: 16px; }
.credit-box .balance { color: var(--gold); }
.d-add, .credit-box .d-add { background: var(--action); color: #fff; border: 0; }
.d-add:hover { background: var(--action-hover); color: #fff; }
.d-mobile-credits { display: none; }
.d-menu-btn { display: none; }
.verify-banner { background: var(--surface); border-color: var(--border-strong); border-radius: var(--radius-sm); }
.flash { border-radius: var(--radius-sm); }

/* Studio / landing top bars (studio_base.html and the public pages) */
.st-bar, .site-bar, .lp-nav { background: rgba(7,8,12,.82); border-bottom-color: #171922; }
.st-studios a.on { background: var(--active); border-color: var(--accent); }
.eyebrow { color: var(--gold); }
.preview-note { background: var(--active); border-bottom-color: var(--accent); }

@media (max-width: 860px) {
  .sidebar { background: rgba(10,11,16,.96); border-bottom-color: #171922; padding-top: 10px; }
  .sidebar-d .sidebar-top { gap: 10px; flex-wrap: wrap; }
  .sidebar-d .d-mobile-credits { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
  .sidebar-d .balance-mobile { color: var(--gold); background: var(--surface); border-color: var(--border); padding: 8px 12px; min-height: 40px; display: inline-flex; align-items: center; }
  .sidebar-d .d-add-mobile { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 12px; border-radius: 12px; font-weight: 600; font-size: .85rem; }
  .sidebar-d .d-menu-btn { display: inline-flex; margin: 0; width: 44px; height: 44px; min-height: 44px; padding: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; }
  .sidebar-d .d-menu-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
  /* Phones: the menu stacks under the top bar. With scripts on it starts folded behind the Menu button;
     without scripts it simply shows, wrapped, so nothing is ever out of reach. */
  .sidebar-d .side-nav { flex-direction: row; flex-wrap: wrap; overflow: visible; gap: 6px; padding: 4px 12px 12px; }
  .sidebar-d.d-collapsible:not(.open) .side-nav { display: none; }
  .sidebar-d.d-collapsible.open .side-nav { flex-direction: column; flex-wrap: nowrap; }
  .sidebar-d.d-collapsible.open .side-label { display: block; }
  .sidebar-d .side-link { border-color: var(--border); min-height: 44px; font-size: .92rem; }
  .sidebar-d.d-collapsible.open .side-link { border: 0; border-radius: 10px; }
  .sidebar-d .side-studio, .sidebar-d .side-studios-all { display: flex; }
  .app-main { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 420px) {
  .sidebar-d .d-word-sub { display: none; }
}

/* Three studios side panel (studio_hubs.py, Oct 20): the "soon" tag on Lesson Studio */
.sidebar-d .side-soon { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #c9bcff; background: #1e1838; padding: 2px 6px; border-radius: 999px; margin-left: 4px; }
