/* ============================================================
   Divitiae — Content Engine. Design tokens + components.
   Dark technical SaaS. Mono-forward, restrained green signal.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700;800&family=Spectral:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=IBM+Plex+Mono:wght@400;500;600;700&family=Unbounded:wght@400;500;600;700;800&display=swap');

/* ---------- Base tokens (dark default) ---------- */
:root {
  --font-ui: 'Golos Text', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-display: 'Spectral', Georgia, 'Times New Roman', serif;

  /* warm graphite canvas (hue ~80) */
  --bg: oklch(0.165 0.007 80);
  --bg-2: oklch(0.195 0.008 80);
  --surface: oklch(0.205 0.009 80);
  --surface-2: oklch(0.235 0.010 80);
  --surface-3: oklch(0.265 0.011 80);
  --line: oklch(0.30 0.011 80);
  --line-2: oklch(0.36 0.013 80);

  --ink: oklch(0.97 0.006 80);
  --ink-2: oklch(0.76 0.013 80);
  --ink-3: oklch(0.58 0.013 80);
  --ink-4: oklch(0.46 0.013 80);

  /* signal accent — crisp lime-green */
  --accent-h: 142;
  --accent: oklch(0.83 0.185 var(--accent-h));
  --accent-2: oklch(0.73 0.175 var(--accent-h));
  --accent-soft: oklch(0.83 0.185 var(--accent-h) / 0.14);
  --accent-line: oklch(0.83 0.185 var(--accent-h) / 0.35);
  --accent-ink: oklch(0.19 0.04 var(--accent-h));

  /* functional status */
  --ok: oklch(0.83 0.185 142);
  --ok-soft: oklch(0.83 0.185 142 / 0.14);
  --warn: oklch(0.82 0.15 78);
  --warn-soft: oklch(0.82 0.15 78 / 0.15);
  --err: oklch(0.70 0.18 28);
  --err-soft: oklch(0.70 0.18 28 / 0.16);
  --info: oklch(0.78 0.10 235);
  --info-soft: oklch(0.78 0.10 235 / 0.15);

  --radius: 9px;
  --radius-sm: 6px;
  --radius-lg: 13px;
  --radius-pill: 999px;

  --sp: 1; /* density multiplier */
  --gap: calc(16px * var(--sp));

  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 8px 30px oklch(0 0 0 / 0.45);
  --shadow-pop: 0 16px 50px oklch(0 0 0 / 0.55);

  --sidebar-w: 248px;
  --topbar-h: 60px;
}

/* ---------- Accent palettes ---------- */
[data-accent="green"]  { --accent-h: 142; }
[data-accent="cyan"]   { --accent-h: 210; --accent-ink: oklch(0.18 0.04 210); }
[data-accent="violet"] { --accent-h: 290; --accent-ink: oklch(0.97 0.01 290); --accent: oklch(0.70 0.17 290); --accent-2: oklch(0.62 0.17 290); --accent-soft: oklch(0.70 0.17 290 / 0.16); --accent-line: oklch(0.70 0.17 290 / 0.4); }
[data-accent="amber"]  { --accent-h: 70;  --accent-ink: oklch(0.22 0.03 70); }

/* ---------- Light theme (warm paper) ---------- */
[data-theme="light"] {
  --bg: oklch(0.975 0.006 85);
  --bg-2: oklch(0.955 0.008 85);
  --surface: oklch(0.995 0.003 85);
  --surface-2: oklch(0.972 0.007 85);
  --surface-3: oklch(0.950 0.009 85);
  --line: oklch(0.90 0.009 85);
  --line-2: oklch(0.84 0.011 85);
  --ink: oklch(0.24 0.014 80);
  --ink-2: oklch(0.42 0.014 80);
  --ink-3: oklch(0.55 0.014 80);
  --ink-4: oklch(0.67 0.013 80);
  --shadow-1: 0 1px 2px oklch(0.3 0.02 80 / 0.06);
  --shadow-2: 0 10px 30px oklch(0.3 0.02 80 / 0.10);
  --shadow-pop: 0 18px 50px oklch(0.3 0.02 80 / 0.16);
  --accent-soft: oklch(0.60 0.17 var(--accent-h) / 0.13);
  --accent-line: oklch(0.60 0.17 var(--accent-h) / 0.32);
  --accent: oklch(0.60 0.17 var(--accent-h));
  --accent-2: oklch(0.53 0.17 var(--accent-h));
  --accent-ink: oklch(0.99 0.02 var(--accent-h));
}
[data-theme="light"][data-accent="amber"] { --accent: oklch(0.70 0.15 70); --accent-2: oklch(0.62 0.15 70); --accent-ink: oklch(0.22 0.04 70); }

/* ---------- Density ---------- */
[data-density="compact"] { --sp: 0.8; --topbar-h: 52px; }

/* ---------- Radius ---------- */
[data-radius="sharp"] { --radius: 4px; --radius-sm: 3px; --radius-lg: 6px; }
[data-radius="soft"]  { --radius: 14px; --radius-sm: 10px; --radius-lg: 22px; }

/* ---------- Fonts toggle (display family) ---------- */
[data-font="editorial"] { --font-display: 'Spectral', Georgia, serif; }
[data-font="technical"] { --font-display: 'Unbounded', system-ui, sans-serif; }
[data-font="technical"] .brand-name,
[data-font="technical"] .page-head h1,
[data-font="technical"] .metric .val { letter-spacing: -0.04em; }

/* ============================================================ Reset ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
#root { height: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--font-mono); }
a { color: inherit; text-decoration: none; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: padding-box; }

/* ============================================================ App shell ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100%; overflow: hidden; }
.app[data-collapsed="true"] { --sidebar-w: 68px; }

/* ----- Sidebar ----- */
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sb-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 16px; flex-shrink: 0; box-shadow: 0 0 0 1px var(--accent-line), 0 0 22px var(--accent-soft); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-name span { color: var(--ink-3); font-weight: 500; }
.app[data-collapsed="true"] .brand-name, .app[data-collapsed="true"] .nav-item span, .app[data-collapsed="true"] .nav-sec, .app[data-collapsed="true"] .sb-foot-text { display: none; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 12px 12px 6px; }
.nav-sec { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; padding: 14px 10px 6px; font-family: var(--font-mono); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; font-size: 13.5px; position: relative; transition: background .12s, color .12s; white-space: nowrap; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-item .ico { color: var(--ink-3); flex-shrink: 0; }
.nav-item.active .ico, .nav-item:hover .ico { color: var(--accent); }
.nav-item .badge-mini { margin-left: auto; }
.app[data-collapsed="true"] .nav-item .badge-mini { display: none; }
.app[data-collapsed="true"] .nav-item { justify-content: center; padding: 9px 0; }

.sb-foot { border-top: 1px solid var(--line); padding: 10px 12px; flex-shrink: 0; }
.usage { padding: 10px; }
.usage-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-bottom: 7px; }
.usage-row b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > i { background: var(--warn); }

/* ----- Topbar ----- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: var(--topbar-h); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px; background: color-mix(in oklch, var(--bg), transparent 8%); backdrop-filter: blur(8px); flex-shrink: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.crumbs b { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--ink-4); }
.topbar-spacer { flex: 1; }

/* factory switcher */
.fac-switch { display: flex; align-items: center; gap: 9px; padding: 6px 11px 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; min-width: 158px; }
.fac-switch:hover { border-color: var(--line-2); background: var(--surface-2); }
.fac-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.fac-switch .nm { font-weight: 600; font-size: 13px; white-space: nowrap; }
.fac-switch .tag { font-size: 10.5px; color: var(--ink-3); font-family: var(--font-mono); white-space: nowrap; }

/* lang toggle */
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-pill); overflow: hidden; background: var(--surface); }
.lang button { border: 0; background: transparent; color: var(--ink-3); font-size: 11.5px; font-weight: 700; padding: 5px 11px; letter-spacing: 0.03em; }
.lang button.on { background: var(--accent); color: var(--accent-ink); }

.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius); border: 1px solid transparent; color: var(--ink-2); background: transparent; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--ink); border: 1px solid var(--line-2); }

/* ----- Page ----- */
.page { flex: 1; overflow-y: auto; min-height: 0; }
.page-in { padding: calc(26px * var(--sp)) clamp(22px, 3vw, 38px); max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: calc(22px * var(--sp)); flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.12; }
.page-head p { color: var(--ink-3); margin: 7px 0 0; font-size: 13.5px; }
.page-head .grow { flex: 1; }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================ Primitives ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 13px; transition: background .12s, border-color .12s, transform .04s, box-shadow .12s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 0 0 1px var(--accent-line), 0 6px 22px var(--accent-soft); }
.btn--primary:hover { background: var(--accent-2); border-color: transparent; }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { color: var(--err); border-color: color-mix(in oklch, var(--err), transparent 60%); background: var(--err-soft); }
.btn--danger:hover { background: color-mix(in oklch, var(--err), transparent 80%); }
.btn--sm { height: 31px; padding: 0 11px; font-size: 12px; gap: 6px; }
.btn--lg { height: 44px; padding: 0 22px; font-size: 14px; }
.btn--icon { width: 38px; padding: 0; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.card-head .sub { color: var(--ink-3); font-size: 12px; }
.card-head .grow { flex: 1; }
.card-body { padding: 18px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.01em; border: 1px solid transparent; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge--ok { color: var(--ok); background: var(--ok-soft); }
.badge--warn { color: var(--warn); background: var(--warn-soft); }
.badge--err { color: var(--err); background: var(--err-soft); }
.badge--info { color: var(--info); background: var(--info-soft); }
.badge--neutral { color: var(--ink-2); background: var(--surface-3); border-color: var(--line); }
.badge-mini { font-size: 10.5px; height: 18px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-family: var(--font-mono); font-weight: 600; display: inline-grid; place-items: center; }
.badge-mini.accent { background: var(--accent-soft); color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: 12px; color: var(--ink-2); background: var(--surface); font-weight: 500; white-space: nowrap; }
.chip.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chip[role="button"] { cursor: pointer; }

.status-dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; flex-shrink: 0; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.status-dot.off { background: var(--ink-4); }

/* channel monogram chip (neutral, no brand logos) */
.ch { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 11px; color: #fff; flex-shrink: 0; letter-spacing: -0.02em; }
.ch--tg { background: linear-gradient(160deg,#2aabee,#2280c4); }
.ch--vk { background: linear-gradient(160deg,#3a6cd6,#2a4f9e); }
.ch--ok { background: linear-gradient(160deg,#f0902a,#e26a18); }
.ch--yt { background: linear-gradient(160deg,#e8503a,#c0331f); }
.ch--max { background: linear-gradient(160deg,#6f5bf0,#4d38c4); }
.ch--wp { background: linear-gradient(160deg,#3f4a57,#2a323c); }
.ch--ig { background: linear-gradient(140deg,#c93aab,#e26a3a,#f0a93a); }
.ch--tt { background: linear-gradient(160deg,#2a2f38,#11151b); }
.ch--pin { background: linear-gradient(160deg,#e8344e,#bd081c); }
.ch--zen { background: linear-gradient(160deg,#3a3f4a,#1d2025); }
.ch--sm { width: 24px; height: 24px; font-size: 9.5px; border-radius: 7px; }
.ch--lg { width: 40px; height: 40px; font-size: 13px; border-radius: 11px; }

/* metric */
.metric { padding: 18px; }
.metric .lbl { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; font-family: var(--font-mono); display: flex; align-items: center; gap: 7px; }
.metric .val { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 10px; line-height: 1; }
.metric .val small { font-size: 15px; color: var(--ink-3); font-weight: 500; }
.metric .delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; margin-top: 9px; font-family: var(--font-mono); }
.metric .delta.up { color: var(--ok); }
.metric .delta.down { color: var(--err); }
.metric .delta.flat { color: var(--ink-3); }

/* grids */
.grid { display: grid; gap: var(--gap); }
.grid > * { min-width: 0; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2,1fr); } .cols-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 720px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* table */
.tscroll { overflow-x: auto; overflow-y: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-4); font-weight: 600; font-family: var(--font-mono); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td b, .table td .t-title { color: var(--ink); font-weight: 600; }

/* forms */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.label .hint { color: var(--ink-4); font-weight: 400; }
.input, .textarea, .select { width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink); padding: 10px 12px; font-size: 13.5px; transition: border-color .12s, box-shadow .12s; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

/* switch */
.switch { width: 40px; height: 23px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .15s, border-color .15s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 99px; background: var(--ink-3); transition: transform .15s, background .15s; }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(17px); background: var(--accent-ink); }

/* segmented */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--ink-3); font-weight: 600; font-size: 12.5px; padding: 6px 13px; border-radius: calc(var(--radius) - 3px); transition: background .12s, color .12s; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* misc */
.divline { height: 1px; background: var(--line); margin: var(--gap) 0; }
.muted { color: var(--ink-3); }
.kbd { font-family: var(--font-mono); font-size: 11px; background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink-2); }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ico { color: var(--ink-4); margin-bottom: 12px; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; align-items: center; gap: 10px; }
.row > .col { min-width: 0; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; } .gap-lg { gap: 18px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 38px; }
.spark > i { flex: 1; background: var(--accent-soft); border-radius: 2px 2px 0 0; min-height: 3px; }
.spark > i.hi { background: var(--accent); }

/* progress pipeline meter */
.meter { display: flex; height: 9px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.meter > i { height: 100%; }

/* tooltip-ish caption */
.cap { font-size: 11.5px; color: var(--ink-4); font-family: var(--font-mono); }

/* modal */
.scrim { position: fixed; inset: 0; background: oklch(0.1 0.01 255 / 0.6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 24px; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; font-family: var(--font-display); }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* editor overlay */
.editor-ov { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; }
.editor-top { height: var(--topbar-h); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 18px; flex-shrink: 0; background: var(--bg-2); }
.editor-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.editor-col { overflow-y: auto; min-height: 0; padding: 24px clamp(18px, 2.5vw, 32px); }
.editor-form { display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--line); }
.editor-prev { background: var(--bg-2); }
@media (max-width: 900px) { .editor-body { grid-template-columns: 1fr; } .editor-form { border-right: none; border-bottom: 1px solid var(--line); } }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .9s linear infinite; }

/* ---- engine-console identity layer ---- */
.metric .val, .mono, .table td .mono, .badge, .kbd, .cap { font-variant-numeric: tabular-nums; }

/* mono kicker above every page title — echoes the landing's "// CONTENT ENGINE" */
.page-head h1::before { content: "//"; display: block; font-family: var(--font-mono); color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; margin-bottom: 6px; }

/* command bar in the topbar */
.cmd { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; flex: 0 1 380px; min-width: 200px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink-3); font-size: 13px; transition: border-color .12s, box-shadow .12s; cursor: text; }
.cmd:hover { border-color: var(--line-2); }
.cmd:focus-within, .cmd.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cmd .pr { color: var(--accent); font-family: var(--font-mono); font-weight: 600; }
.cmd .ph { flex: 1; color: var(--ink-4); }
.cmd kbd { margin-left: auto; }

/* engine status strip in sidebar */
.engine-status { display: flex; align-items: center; gap: 8px; padding: 9px 11px; margin: 2px 2px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-2); position: relative; overflow: hidden; white-space: nowrap; }
.engine-status .es-model { margin-left: auto; color: var(--ink-4); }
.engine-status .status-dot { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--ok-soft); } 50% { box-shadow: 0 0 0 4px transparent; } }
.app[data-collapsed="true"] .engine-status { justify-content: center; }
.app[data-collapsed="true"] .engine-status span:not(.status-dot) { display: none; }
@media (prefers-reduced-motion: reduce) { .engine-status .status-dot { animation: none; } }


/* fade-in */
@keyframes fadeUp { from { transform: translateY(8px); } to { transform: none; } }
.fade { opacity: 1; animation: fadeUp .32s cubic-bezier(.2,.7,.2,1); }
@media (prefers-reduced-motion: reduce) { .fade { animation: none; } }

/* === Premium light UI refinement (2026-06-15) === */
[data-theme="light"] body { background: var(--bg); }
[data-theme="light"] .sidebar { background: #ffffff; border-right: 1px solid var(--line); }
[data-theme="light"] .topbar { background: rgba(255,255,255,0.82); }
[data-theme="light"] .sb-brand { border-bottom: 1px solid var(--line); }
.brand-name { font-family: var(--font-ui); font-weight: 600; letter-spacing: -0.02em; }
.brand-name span { color: var(--ink-4); }
.sb-scroll { padding: 14px 12px 6px; }
.nav-sec { font-family: var(--font-ui); text-transform: none; letter-spacing: 0; font-size: 11.5px; font-weight: 600; color: var(--ink-4); padding: 16px 12px 6px; }
.nav-item { border-radius: 10px; padding: 9px 12px; font-size: 14px; margin: 1px 0; font-weight: 500; transition: background .14s, color .14s; }
.nav-item:hover { background: color-mix(in oklch, var(--ink) 6%, transparent); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.nav-item.active::before { display: none; }
.nav-item.active .ico, .nav-item:hover .ico { color: var(--accent-2); }
.engine-status { display: none; }
.usage { display: none; }
[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06); }
[data-theme="light"] .btn--primary { box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

/* === Sidebar buttons: kill UA border, premium look === */
.sidebar .nav-item { border: 1px solid transparent; background: transparent; box-shadow: none; -webkit-appearance: none; appearance: none; outline: none; width: 100%; }
.sidebar .nav-item:hover { background: color-mix(in oklch, var(--ink) 5%, transparent); border-color: transparent; }
.sidebar .nav-item.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-2); }
.sb-foot .nav-item { border: 1px solid transparent; background: transparent; }
.sb-foot .nav-item:hover { background: color-mix(in oklch, var(--ink) 5%, transparent); }

/* === Mobile: sidebar becomes a slide-in drawer === */
.mob-backdrop { display: none; }
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  /* drawer sidebar — full labels regardless of desktop "collapsed" state */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 300px);
    z-index: 80; transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-pop); border-right: 1px solid var(--line);
  }
  .app[data-mobnav="true"] .sidebar { transform: none; }
  .mob-backdrop { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.45); }
  /* neutralise desktop collapse rules inside the drawer */
  .app[data-collapsed="true"] { --sidebar-w: 0px; }
  .app .brand-name, .app .nav-item span, .app .nav-sec, .app .sb-foot-text,
  .app .nav-item .badge-mini { display: revert !important; }
  .app .nav-item { justify-content: flex-start !important; padding: 9px 12px !important; }
  .app .engine-status span:not(.status-dot) { display: revert !important; }

  /* topbar tightening */
  .topbar { padding: 0 12px; gap: 8px; }
  .cmd { display: none; }
  .page-in { padding: 16px 14px; }
  .page-head { gap: 10px; }
  .fac-switch .tag { display: none; }
  /* wide tables (admin) scroll horizontally instead of breaking layout */
  .card > table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
}

/* --- Review card: doc-like rendering of article HTML (rc-prose) --- */
.rc-prose h1,.rc-prose h2,.rc-prose h3{font-weight:700;line-height:1.25;margin:14px 0 6px}
.rc-prose h2{font-size:1.18em}
.rc-prose h3{font-size:1.05em}
.rc-prose p{margin:0 0 10px}
.rc-prose ul,.rc-prose ol{margin:0 0 10px;padding-left:22px}
.rc-prose li{margin:2px 0}
.rc-prose a{color:var(--accent);text-decoration:underline}
.rc-prose img{max-width:100%;height:auto;border-radius:8px;border:1px solid var(--line);margin:8px 0}
.rc-prose:first-child,.rc-prose > :first-child{margin-top:0}
.rc-editor:focus{border-color:var(--accent)}
.rc-editor:empty:before{content:attr(data-ph);color:var(--muted)}
