/* NNNN Newsroom — Noobenheim Nerd News Network. Self-contained, no external assets. */

:root {
  --bg: #090c12;
  --bg-2: #0d1219;
  --surface: #121924;
  --surface-2: #18212e;
  --surface-3: #202b3b;
  --border: #233042;
  --border-2: #31405a;
  --text: #e6ecf5;
  --text-2: #a6b2c4;
  --text-3: #6c7a90;
  --accent: #3ee6a8;
  --accent-strong: #25cc90;
  --accent-ink: #03140d;
  --accent-soft: rgba(62, 230, 168, 0.12);
  --violet: #a194ff;
  --violet-soft: rgba(161, 148, 255, 0.15);
  --ok: #3ee6a8;
  --ok-soft: rgba(62, 230, 168, 0.13);
  --warn: #ffc65c;
  --warn-soft: rgba(255, 198, 92, 0.14);
  --error: #ff6b6b;
  --error-soft: rgba(255, 107, 107, 0.14);
  --info: #6cb6ff;
  --info-soft: rgba(108, 182, 255, 0.14);
  --faint: #6c7a90;
  --faint-soft: rgba(108, 122, 144, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.28);
  --ring: 0 0 0 3px rgba(62, 230, 168, 0.35);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 236px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-2: #eceff5;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eaeef4;
  --border: #dde3ec;
  --border-2: #c7d0dd;
  --text: #0f1724;
  --text-2: #445167;
  --text-3: #79859a;
  --accent: #0b9f6c;
  --accent-strong: #08865b;
  --accent-ink: #ffffff;
  --accent-soft: rgba(11, 159, 108, 0.1);
  --violet: #6b56e6;
  --violet-soft: rgba(107, 86, 230, 0.1);
  --ok: #0b9f6c;
  --ok-soft: rgba(11, 159, 108, 0.1);
  --warn: #b27300;
  --warn-soft: rgba(214, 145, 0, 0.12);
  --error: #d43d3d;
  --error-soft: rgba(212, 61, 61, 0.1);
  --info: #1f6fd1;
  --info-soft: rgba(31, 111, 209, 0.1);
  --faint: #79859a;
  --faint-soft: rgba(121, 133, 154, 0.14);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 18px rgba(16, 24, 40, 0.06);
  --ring: 0 0 0 3px rgba(11, 159, 108, 0.25);
  color-scheme: light;
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 8px; }
sub { font-size: 0.7em; }
small, .small { font-size: 12px; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 0.92em; }
.ok-text { color: var(--ok); }
.err-text { color: var(--error); }
.warn-text { color: var(--warn); }
.hidden { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.pre-wrap { white-space: pre-wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
::selection { background: var(--accent-soft); }

input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="url"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea { resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; min-height: 420px; }
textarea.guide { font-family: var(--mono); font-size: 13px; min-height: 340px; }
select { cursor: pointer; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); }
.input-lg { font-size: 18px !important; font-weight: 650; padding: 10px 12px !important; }
.num-sm { width: 80px !important; flex: 0 0 auto; }
.select-sm { width: auto; padding: 5px 8px; font-size: 13px; }

/* ------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-2); border-right: 1px solid var(--border);
  padding: 16px 12px;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 4px 6px 12px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; }
.bm-bg { fill: var(--surface-3); }
.bm-n { fill: var(--accent); }
.bm-dot { fill: var(--violet); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: 0.02em; }
.brand-text small { color: var(--text-3); font-size: 10.5px; letter-spacing: 0.02em; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; cursor: pointer; color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 550;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a span { flex: 1 1 auto; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }
.nav-badge { display: none; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 10px; font-size: 11px; line-height: 20px; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 750; }
.nav-badge.show { display: inline-block; }
.nav-badge.warn { background: var(--warn); color: #1d1300; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px 0; border-top: 1px solid var(--border); }
.conn { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.conn-open .conn-dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: live 2.4s infinite; }
.conn-open { color: var(--text-2); }
.conn-reconnecting .conn-dot, .conn-connecting .conn-dot { background: var(--warn); }
.conn-closed .conn-dot { background: var(--error); }
.theme-btn { width: 34px; padding: 4px 0 !important; justify-content: center; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.view { padding: 24px clamp(16px, 3vw, 36px) 64px; max-width: 1480px; width: 100%; margin: 0 auto; outline: none; }
.view > div > * + * { margin-top: 16px; }

/* ------------------------------------------------------------ banners */
.banner-stack:empty { display: none; }
.banner-stack { display: flex; flex-direction: column; }
.banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 10px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.banner.banner-col { flex-direction: column; align-items: stretch; }
.banner-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.banner > span:not(.spinner):not(.banner-icon) { flex: 1 1 260px; }
.banner-row > span:not(.banner-icon) { flex: 1 1 260px; }
.banner-icon { font-weight: 800; }
.banner.tone-warn { background: var(--warn-soft); }
.banner.tone-warn .banner-icon { color: var(--warn); }
.banner.tone-error { background: var(--error-soft); }
.banner.tone-error .banner-icon { color: var(--error); }
.banner.tone-info { background: var(--info-soft); }
.banner.tone-info .banner-icon { color: var(--info); }
.banner-x { background: none; border: 0; color: var(--text-3); font-size: 18px; cursor: pointer; padding: 0 4px; }
.banner .login-flow { background: var(--surface); }

/* ------------------------------------------------------------ page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin: 4px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions.ingest { gap: 10px; }
.eyebrow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.back { display: inline-block; color: var(--text-3); font-size: 13px; margin-bottom: 4px; }
.back:hover { color: var(--accent); }
.story-h1, .draft-h1 { font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
.title-input { font-size: 22px !important; font-weight: 700; }

/* ------------------------------------------------------------ cards & grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card.highlight { border-color: var(--violet); box-shadow: 0 0 0 1px var(--violet-soft), var(--shadow); }
.card > * + * { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head p { margin: 2px 0 0; }
details.card > summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--text-3); transition: transform 0.15s; }
details.card[open] > summary::before { transform: rotate(90deg); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2.tight { gap: 16px; }
.view .grid-2 > .card + .card { margin-top: 0; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.dash-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash-side { position: sticky; top: 16px; min-width: 0; }
.detail-grid, .draft-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; align-items: start; }
.detail-main, .detail-side, .draft-main, .draft-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.voice-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
#v-editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.social-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .field-wide { grid-column: 1 / -1; }
.steps-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.step span { color: var(--text-2); font-size: 13px; }

/* ------------------------------------------------------------ tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.tile {
  display: block; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.12s;
}
a.tile:hover { text-decoration: none; border-color: var(--border-2); transform: translateY(-1px); }
.tile-label { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; }
.tile-value { font-size: 28px; font-weight: 780; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 15px; color: var(--text-3); font-weight: 600; }
.tile-sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.tile.tone-accent { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }
.tile.tone-accent .tile-value { color: var(--accent); }
.tile.tone-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.tile.tone-warn .tile-value { color: var(--warn); }
.tile.tone-faint .tile-sub { color: var(--text-3); }
.ingest-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  font-weight: 620; font-size: 13.5px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--error) 45%, var(--border)); color: var(--error); }
.btn-danger-ghost:hover { background: var(--error-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-2); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn-primary.busy::after { border-color: var(--accent-ink); border-right-color: transparent; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.file-btn { cursor: pointer; }
.push-right { margin-left: auto; }

/* ------------------------------------------------------------ badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--faint-soft); color: var(--text-2); white-space: nowrap;
}
.badge.tone-info { background: var(--info-soft); color: var(--info); }
.badge.tone-accent { background: var(--accent-soft); color: var(--accent); }
.badge.tone-violet { background: var(--violet-soft); color: var(--violet); }
.badge.tone-warn { background: var(--warn-soft); color: var(--warn); }
.badge.tone-ok { background: var(--ok-soft); color: var(--ok); }
.badge.tone-error { background: var(--error-soft); color: var(--error); }
.badge.tone-faint { background: var(--faint-soft); color: var(--text-3); }
.badge.pulse::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s ease-in-out infinite; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.chip.src-chip { padding-right: 3px; }
.chip .w { display: inline-block; min-width: 18px; text-align: center; padding: 0 4px; border-radius: 4px; font-size: 11px; font-weight: 750; }
.w-hi { background: var(--accent-soft); color: var(--accent); }
.w-mid { background: var(--info-soft); color: var(--info); }
.w-lo { background: var(--faint-soft); color: var(--text-3); }
.chip.more { color: var(--text-3); }
.chip-cat { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip-error { background: var(--error-soft); border-color: transparent; color: var(--error); }
.chip-btn { cursor: pointer; white-space: normal; text-align: left; }
.chip-btn:hover { border-color: var(--accent); color: var(--text); }
.chip-x { background: none; border: 0; padding: 0 0 0 2px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }
.chip-cloud, .terms-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pin { color: var(--warn); font-weight: 700; }
.pill { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); padding: 5px 12px; border-radius: 999px; font-weight: 650; cursor: pointer; font-size: 12.5px; }

/* ------------------------------------------------------------ score bars */
.scorebar { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.scorebar.compact { min-width: 130px; gap: 8px; }
.scorebar-track { position: relative; flex: 1 1 auto; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.scorebar.compact .scorebar-track { height: 6px; }
.scorebar-fill { height: 100%; width: 0; border-radius: inherit; transition: width 0.5s ease; }
.scorebar-fill.cool { background: var(--info); }
.scorebar-fill.warm { background: linear-gradient(90deg, var(--info), var(--warn)); }
.scorebar-fill.hot { background: linear-gradient(90deg, var(--warn), #ff8a4c); }
.scorebar-fill.full { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); box-shadow: 0 0 12px var(--accent-soft); }
.scorebar-label { font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }

/* ------------------------------------------------------------ callouts, empty, loading */
.callout { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13.5px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout-error { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 30%, transparent); color: var(--text); }
.callout-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.explainer { line-height: 1.6; }
.empty { text-align: center; padding: 28px 12px; color: var(--text-2); }
.empty p { margin: 0 0 4px; }
.empty-glyph { font-size: 28px; color: var(--text-3); margin-bottom: 4px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 18px 4px; }
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: 0 0 auto; vertical-align: middle; }

/* ------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table.compact th, .table.compact td { padding: 6px 8px; }
.table tfoot td { font-weight: 650; border-bottom: 0; }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: 4px; }
.group-row th { background: var(--bg-2) !important; color: var(--violet) !important; font-size: 12px !important; text-transform: uppercase; letter-spacing: 0.06em; position: static !important; }
.is-disabled td { opacity: 0.55; }
.src-cell { max-width: 420px; }
.src-name { font-weight: 650; }
.weight-input { width: 64px !important; text-align: center; font-weight: 750; padding: 5px 4px !important; }
.weight-input.w-hi { color: var(--accent); }
.weight-input.w-mid { color: var(--info); }
.weight-input.w-lo { color: var(--text-3); }
.boost-row td { color: var(--violet); }
.log-row td { background: var(--bg-2); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.health-ok { background: var(--ok); }
.health-warn { background: var(--warn); }
.health-error { background: var(--error); }
.health-idle { background: var(--faint); }
.health-disabled { background: transparent; border: 2px solid var(--faint); }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card > .field + .field { margin-top: 12px; }
.label { font-size: 12.5px; font-weight: 650; color: var(--text-2); display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.help { color: var(--text-3); font-size: 12px; }
.field-row { flex-direction: row; align-items: center; gap: 10px; }
.field-text { display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1 1 auto; min-width: 0; }
.num-row { display: flex; gap: 10px; align-items: center; }
.num-row input[type="number"] { width: 96px; flex: 0 0 auto; }
.counter { margin-left: auto; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--error); font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; cursor: pointer; }

.toggle { position: relative; display: inline-flex; flex: 0 0 auto; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; transition: background 0.15s, border-color 0.15s; }
.toggle-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-3); transition: transform 0.15s, background 0.15s; }
.toggle input:checked + .toggle-ui { background: var(--accent-soft); border-color: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(16px); background: var(--accent); }
.toggle input:focus-visible + .toggle-ui { box-shadow: var(--ring); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar > input[type="search"] { max-width: 300px; }
.toolbar > select { width: auto; max-width: 260px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab { background: none; border: 0; padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-weight: 600; cursor: pointer; font-size: 13px; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 12px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------ lists: rows, stories, drafts */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; padding-bottom: 0; }
.row-item:first-child { padding-top: 0; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; }
.row-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.row-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-title { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.row-title:hover { color: var(--accent); }
.row-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.story-list, .draft-list { display: flex; flex-direction: column; gap: 10px; }
.story-card, .draft-card {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); border-left: 3px solid var(--border-2);
}
.draft-card { flex-direction: column; align-items: stretch; gap: 6px; }
.story-card.st-ready, .draft-card.st-ready { border-left-color: var(--accent); }
.story-card.st-writing, .story-card.st-queued, .draft-card.st-generating { border-left-color: var(--warn); }
.story-card.st-written, .story-card.st-sent, .draft-card.st-sent { border-left-color: var(--ok); }
.story-card.st-ignored, .draft-card.st-discarded { opacity: 0.65; }
.story-card.st-failed, .draft-card.st-failed { border-left-color: var(--error); }
.story-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.story-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.story-title, .draft-title { font-size: 16px; overflow-wrap: anywhere; }
.story-title a, .draft-title a { color: var(--text); }
.story-title a:hover, .draft-title a:hover { color: var(--accent); text-decoration: none; }
.story-sources { display: flex; flex-wrap: wrap; gap: 4px; }
.story-score { flex: 0 0 220px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.story-score .scorebar { width: 100%; }
.terms { font-style: italic; }
.draft-dek { color: var(--text-2); margin: 0; }

.cov-list { list-style: none; margin: 0; padding: 0; }
.cov-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.cov-item:last-child { border-bottom: 0; }
.cov-item.blocked { opacity: 0.55; }
.cov-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cov-title { font-weight: 620; overflow-wrap: anywhere; }
.cov-summary { color: var(--text-2); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.coverage { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------------------ wire */
.wire-card { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.wire-mini { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; }
.wire-mini-item { padding: 10px 0 10px 10px; border-bottom: 1px solid var(--border); border-left: 2px solid transparent; display: flex; flex-direction: column; gap: 4px; }
.wire-mini-item.blocked { opacity: 0.5; }
.wm-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wm-title { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.wm-title a, .wire-title a, .cov-title a { color: var(--text); }
.wm-title a:hover, .wire-title a:hover, .cov-title a:hover { color: var(--accent); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--error); display: inline-block; animation: live-red 1.8s infinite; }

.wire-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.wire-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; align-items: start; }
.wire-item:last-child { border-bottom: 0; }
.wire-item.blocked { opacity: 0.5; }
.wire-time { color: var(--text-3); font-size: 12px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.wire-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wire-line { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.wire-title { font-weight: 620; font-size: 14.5px; overflow-wrap: anywhere; }
.wire-summary { color: var(--text-2); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.load-more { display: flex; justify-content: center; padding: 12px; }
.flash { animation: flash-in 1.8s ease-out; }

/* ------------------------------------------------------------ activity */
.act-mini-list, .act-list { list-style: none; margin: 0; padding: 0; }
.act-mini { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.act-mini:last-child { border-bottom: 0; }
.act-mini .act-msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); flex: 0 0 auto; transform: translateY(-1px); }
.lvl-success .act-dot { background: var(--ok); }
.lvl-warn .act-dot { background: var(--warn); }
.lvl-error .act-dot { background: var(--error); }
.act-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.act { display: grid; grid-template-columns: 10px 70px auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: 0; }
.act-time { color: var(--text-3); font-size: 12px; }
.act-body { min-width: 0; overflow-wrap: anywhere; }
.act.lvl-error .act-msg { color: var(--error); }
.act.lvl-warn .act-msg { color: var(--warn); }

/* ------------------------------------------------------------ drafts detail */
.alt-titles { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.article-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: block; }
.social-block { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.social-head { display: flex; align-items: center; gap: 8px; }
.social-head b { flex: 1 1 auto; }
.social-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.quality-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 13.5px; }
.checklist input { margin-top: 3px; }
.checklist input:checked + span { color: var(--text-3); text-decoration: line-through; }
.sources-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ voice */
.profile-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.profile-btn { width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.profile-btn:hover { background: var(--surface-2); }
.profile-btn.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.profile-name { font-weight: 650; }
.profile-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.guide-pre { white-space: pre-wrap; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; max-height: 420px; overflow: auto; margin: 6px 0 0; }
.guide-pre.proposed { border-color: var(--violet); }
.sample-list { list-style: none; margin: 0; padding: 0; }
.sample { padding: 10px 0; border-bottom: 1px solid var(--border); }
.sample:last-child { border-bottom: 0; }
.sample-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sample-excerpt { color: var(--text-2); font-size: 13px; margin: 4px 0 0; }
.add-sample { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.steps { padding-left: 18px; margin: 6px 0 12px; }

/* ------------------------------------------------------------ rules */
.formula-line { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; color: var(--accent); overflow-x: auto; }
.formula-notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.formula-notes b { color: var(--text); }

/* ------------------------------------------------------------ codex */
.login-flow { border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--bg-2); display: flex; flex-direction: column; gap: 10px; }
.login-flow.waiting { border-color: var(--warn); }
.login-flow.ok { border-color: var(--ok); color: var(--ok); }
.login-flow.err { border-color: var(--error); }
.login-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.login-url { font-weight: 650; overflow-wrap: anywhere; }
.login-code { display: inline-block; font-family: var(--mono); font-size: 22px; font-weight: 800; letter-spacing: 0.12em; padding: 4px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); border: 1px dashed var(--accent); margin: 0 6px; }
.login-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.log { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; color: var(--text-2); }
.log.tall { max-height: 60vh; min-height: 240px; }
.log.small { font-size: 11.5px; max-height: 200px; }

/* ------------------------------------------------------------ templates & tests */
.templates > summary { padding: 2px 0; }
.template { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.template-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.test-items { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; }

/* ------------------------------------------------------------ toasts & dialog */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.2s ease-out;
}
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--error); }
.toast-warn { border-left-color: var(--warn); }
.toast-msg { flex: 1 1 auto; overflow-wrap: anywhere; }
.toast-action { font-weight: 700; white-space: nowrap; }
.toast-x { background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.dialog { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.dialog::backdrop { background: rgba(4, 7, 12, 0.6); backdrop-filter: blur(2px); }
.dlg-title { font-size: 17px; margin-bottom: 8px; }
.dlg-msg { color: var(--text-2); white-space: pre-wrap; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ------------------------------------------------------------ animation */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(62, 230, 168, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(62, 230, 168, 0); } 100% { box-shadow: 0 0 0 0 rgba(62, 230, 168, 0); } }
@keyframes live-red { 0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.55); } 70% { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); } }
@keyframes flash-in {
  0% { background: var(--accent-soft); border-left-color: var(--accent); transform: translateY(-4px); opacity: 0.2; }
  15% { transform: none; opacity: 1; }
  100% { background: transparent; border-left-color: transparent; }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-side { position: static; }
  .wire-card { max-height: 560px; }
}
@media (max-width: 1050px) {
  .detail-grid, .draft-grid { grid-template-columns: minmax(0, 1fr); }
  .voice-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 50; height: auto; flex-direction: column; padding: 10px 16px; gap: 0; }
  .brand { padding: 0; }
  .brand-text small { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav, .sidebar-foot { display: none; }
  body.nav-open .nav { display: flex; padding-top: 8px; max-height: 70vh; }
  body.nav-open .sidebar-foot { display: flex; padding-bottom: 4px; }
  .grid-2, .steps-strip, .diff-grid { grid-template-columns: minmax(0, 1fr); }
  .story-card { flex-direction: column; align-items: stretch; }
  .story-score { flex-basis: auto; align-items: stretch; }
  .view { padding: 16px 16px 48px; }
  h1 { font-size: 22px; }
}
@media (max-width: 600px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 24px; }
  .wire-item { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .wire-time { order: -1; }
  .row-item { flex-direction: column; align-items: stretch; }
  .row-side { justify-content: space-between; }
  .act { grid-template-columns: 10px auto minmax(0, 1fr); }
  .act .chip { display: none; }
  .toolbar > input[type="search"], .toolbar > select { max-width: none; flex: 1 1 140px; }
  .page-actions { width: 100%; }
  .input-row { flex-wrap: wrap; }
  .login-code { font-size: 18px; }
}
