/* Stories Console: shared styles for index.html and login.html. */

:root {
  color-scheme: dark;
  /* Surfaces: a blue-tinted slate that steps lighter as it sits higher. */
  --bg: #161b24;
  --surface: #1e2430;
  --surface-2: #252c3a;
  --surface-3: #2f3747;
  --surface-3-hover: #3a4356;
  --row-hover: #283042;
  --inset: #11151d;
  --line: #343d4e;
  --line-strong: #6b778c;
  /* Text: off-white rather than pure white, to cut glare; every pair clears WCAG AA (4.5:1). */
  --fg: #e8ecf2;
  --muted: #b4bdcb;
  --faint: #98a3b5;
  --link: #7cb4ff;
  --ok: #6fdc9a;
  --warn: #f3c969;
  --bad: #ff9aa7;
  /* Solid fills and the text that sits on them. Fills darken on hover. */
  --on-solid: #ffffff;
  --primary: #2f6bd3;
  --primary-hover: #275dbd;
  --primary-soft: #1f3354;
  --danger: #c8354a;
  --danger-hover: #ad2c40;
  --ok-solid: #1c7c46;
  --ok-soft: #1c3b2a;
  --run-solid: #2563c9;
  --bad-solid: #c8354a;
  --bad-soft: #45202a;
  --warn-solid: #e5a823;
  --on-warn: #1f1600;
  --idle-solid: #5b6678;
  --waiting-solid: #3d4659;
  --backdrop: rgba(5, 8, 14, 0.7);
  --shadow: rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); font-size: 14px; }
body.locked { overflow: hidden; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* --- controls --- */

button, .btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-3); color: var(--fg); cursor: pointer; font: inherit; font-size: 0.85rem; line-height: 1.3; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-3-hover); text-decoration: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { border-color: var(--primary); background: var(--primary); color: var(--on-solid); font-weight: 600; }
button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
button.danger { border-color: var(--danger); background: var(--danger); color: var(--on-solid); }
button.danger:hover { border-color: var(--danger-hover); background: var(--danger-hover); }
button.ghost { border-color: transparent; background: none; color: var(--muted); }
button.ghost:hover { background: var(--surface-3); color: var(--fg); }
button.small, .btn.small { padding: 3px 8px; font-size: 0.74rem; }

input, select, textarea { width: 100%; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--inset); color: var(--fg); font: inherit; font-size: 0.85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; font-family: var(--mono); font-size: 0.78rem; }
label { display: block; font-size: 0.74rem; color: var(--muted); margin-bottom: 0.2rem; }

/* --- text --- */

.muted { color: var(--muted); font-size: 0.85rem; }
.faint { color: var(--faint); }
.error { color: var(--bad); font-size: 0.85rem; margin: 0.5rem 0 0; }
.mono { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); }
.wrap { overflow-wrap: anywhere; }
.trunc { display: inline-block; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.trunc.xs { max-width: 90px; }
.trunc.sm { max-width: 120px; }
.trunc.md { max-width: 180px; }
.trunc.lg { max-width: 260px; }
.trunc.full { max-width: 100%; }
.spacer { margin-left: auto; }

/* --- app shell --- */

.shell { display: flex; min-height: 100vh; }
.content { flex: 1 1 auto; min-width: 0; }
main { padding: 1.5rem; max-width: 1440px; margin: 0 auto; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { padding: 6px; border-color: transparent; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }

.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; background: var(--primary); color: var(--on-solid); font-weight: 800; font-size: 0.95rem; }

.sidebar { position: sticky; top: 0; flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); overflow: hidden; z-index: 20; transition: flex-basis 0.15s ease, width 0.15s ease; }
.brand { display: flex; align-items: center; gap: 0.6rem; padding: 1rem 0.9rem; border-bottom: 1px solid var(--line); }
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-text h1 { margin: 0; font-size: 0.95rem; color: var(--fg); white-space: nowrap; }
.brand-text span { font-size: 0.72rem; color: var(--faint); }
.brand .collapse-btn { margin-left: auto; }
.drawer-close { display: none; margin-left: auto; }

.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0.2rem 0.6rem 1rem; }
.nav-group { margin-top: 0.85rem; }
.nav-title { display: block; padding: 0 0.65rem 0.35rem; font-size: 0.68rem; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.nav-item { position: relative; display: flex; width: 100%; align-items: center; gap: 0.65rem; margin-top: 2px; padding: 0.45rem 0.65rem; border: none; border-radius: 7px; background: none; color: var(--muted); font-size: 0.87rem; text-align: left; }
.nav-item:hover { background: var(--surface-3); color: var(--fg); }
.nav-item.on { background: var(--primary); color: var(--on-solid); font-weight: 600; }
.nav-item .label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .live { min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--ok-solid); color: var(--on-solid); font-size: 0.68rem; font-weight: 700; text-align: center; }

.side-foot { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 0.7rem; display: flex; flex-direction: column; gap: 0.55rem; font-size: 0.8rem; }
.side-foot .line { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); min-width: 0; }
.side-foot .line .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-card { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.45rem 0.4rem 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.status-card .refresh { margin-left: auto; padding: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok-solid); flex: 0 0 auto; box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.down { background: var(--bad-solid); box-shadow: 0 0 0 3px var(--bad-soft); }
.status-text { color: var(--ok); font-weight: 600; }
.status-text.down { color: var(--bad); }
.user-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0.1rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--fg); font-weight: 700; font-size: 0.82rem; }
.user-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-name .faint { font-size: 0.7rem; }

/* Wide screens: the icon-only rail. Labels hide, and each control keeps a title. */
@media (min-width: 901px) {
  .shell.collapsed .sidebar { flex-basis: 68px; width: 68px; }
  .shell.collapsed .brand { flex-direction: column; justify-content: center; gap: 0.5rem; padding: 0.8rem 0; }
  .shell.collapsed .brand .collapse-btn { margin-left: 0; }
  .shell.collapsed .brand-text,
  .shell.collapsed .label { display: none; }
  .shell.collapsed .nav { padding: 0.4rem 0.6rem 1rem; }
  .shell.collapsed .nav-title { height: 1px; margin: 0 0.4rem 0.5rem; padding: 0; overflow: hidden; background: var(--line); font-size: 0; }
  .shell.collapsed .nav-item { justify-content: center; padding: 0.6rem 0; }
  .shell.collapsed .nav-item .live { position: absolute; top: 3px; right: 3px; min-width: 16px; padding: 0 4px; font-size: 0.6rem; }
  .shell.collapsed .status-card { align-items: center; padding: 0.5rem 0; }
  .shell.collapsed .status-card .line { flex-direction: column; gap: 0.5rem; }
  .shell.collapsed .status-card .refresh { margin-left: 0; }
  .shell.collapsed .user-row { flex-direction: column; }
}

.topbar { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 0.6rem; position: sticky; top: 0; z-index: 15; padding: 0.55rem 0.8rem; background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar h1 { margin: 0; font-size: 0.95rem; color: var(--fg); }
  .topbar .brand-mark { width: 26px; height: 26px; font-size: 0.85rem; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-100%); transition: transform 0.18s ease; }
  .sidebar.open { transform: none; box-shadow: 8px 0 24px var(--shadow); }
  .drawer-close { display: inline-flex; }
  .collapse-btn { display: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: var(--backdrop); z-index: 19; }
  main { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .icon.spin { transition: none; animation: none; }
}

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

.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .titles { flex: 1 1 280px; min-width: 0; }
.page-head h2 { margin: 0; font-size: 1.2rem; display: flex; align-items: baseline; gap: 0.5rem; }
.page-head h2 .count { font-family: var(--mono); font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.page-head p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.85rem; }
.page-head .head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px var(--shadow); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 0.75rem; font-size: 0.92rem; }
.card.flush { padding: 0; }
.card.flush > .table-wrap { border: none; }
.card.flush > .pager, .card.flush > .empty, .card.flush > .error { padding: 0 1rem 1rem; }

details.help { margin-bottom: 1rem; font-size: 0.84rem; color: var(--muted); }
details.help summary { cursor: pointer; color: var(--muted); width: max-content; }
details.help summary:hover { color: var(--fg); }
details.help ul { margin: 0.5rem 0 0; padding-left: 1.2rem; line-height: 1.6; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.7rem; align-items: end; }
.fields .span-2 { grid-column: span 2; }
.fields .span-all { grid-column: 1 / -1; }
.time-list { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.time-slot { display: inline-flex; align-items: center; gap: 0.2rem; }
.time-slot input { width: auto; }
@media (max-width: 560px) { .fields .span-2 { grid-column: 1 / -1; } }
.chk { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--fg); margin: 0; padding: 7px 0; }
.actions { margin-top: 0.9rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 240px; min-width: 0; }

.empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* --- tables --- */

.table-wrap { overflow-x: auto; transition: opacity 0.12s ease; }
.table-wrap.dim, .gallery.dim { opacity: 0.55; }
table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.table-wrap table { min-width: 680px; }
th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 700; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.65rem 0.75rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 0.6rem 0.75rem; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:first-child td { border-top: none; }
tbody tr:hover td { background: var(--row-hover); }
/* Page tables scroll inside the card on wide screens, so the header row stays in view. */
@media (min-width: 901px) {
  .card.flush > .table-wrap { max-height: calc(100vh - 220px); overflow: auto; }
}

/* Sortable headers: the button fills the cell; aria-sort on the th picks the arrow. */
.th-sort { padding: 0; border: none; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; gap: 0.3rem; }
.th-sort:hover { background: none; color: var(--fg); }
.th-sort::after { content: "\2195"; opacity: 0; font-size: 0.8rem; }
.th-sort:hover::after { opacity: 1; }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--fg); }
th[aria-sort="ascending"] .th-sort::after { content: "\2191"; opacity: 1; color: var(--link); }
th[aria-sort="descending"] .th-sort::after { content: "\2193"; opacity: 1; color: var(--link); }

/* The filter bar above a table. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.toolbar.bare { padding: 0 0 0.9rem; border-bottom: none; }
.toolbar input, .toolbar select { width: auto; padding: 5px 9px; font-size: 0.8rem; }
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 160px; max-width: 360px; }
.toolbar select { flex: 0 1 auto; max-width: 220px; }
.toolbar select.set, .toolbar input.set { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.toolbar .match { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 2px 4px 2px 9px; border-radius: 999px; background: var(--primary); color: var(--on-solid); font-size: 0.74rem; }
.chip .mono { color: var(--on-solid); }
.chip button { padding: 0 6px; border: none; background: none; color: var(--on-solid); font-size: 0.85rem; }
.chip button:hover { color: var(--on-solid); background: var(--primary-hover); }
@media (max-width: 560px) {
  .toolbar input[type="search"], .toolbar select { flex: 1 1 100%; max-width: none; }
}
td.right, th.right { text-align: right; }
td.btns { white-space: nowrap; text-align: right; }
td.btns > * + * { margin-left: 0.3rem; }
td.nowrap { white-space: nowrap; }
.cell-main { color: var(--fg); }
.cell-main.nowrap { white-space: nowrap; }
.cell-sub a.mono { color: var(--link); }
.cell-sub { margin-top: 0.25rem; color: var(--muted); font-size: 0.8rem; display: flex; align-items: center; gap: 0.4rem; }
.cell-sub.nowrap { white-space: nowrap; }
.multi-select { position: relative; }
.multi-select-btn { width: 100%; justify-content: space-between; padding: 7px 10px; background: var(--inset); font-weight: 400; }
.multi-select-btn:hover { background: var(--inset); border-color: var(--fg); }
.multi-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-select-value.placeholder { color: var(--muted); }
.multi-select-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 260px; overflow-y: auto; padding: 4px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); box-shadow: 0 8px 24px var(--shadow); }
.multi-option { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 7px 8px; border-radius: 4px; font-size: 0.85rem; color: var(--fg); cursor: pointer; }
.multi-option:hover { background: var(--surface-3); }
.multi-option.all { border-bottom: 1px solid var(--line); border-radius: 4px 4px 0 0; margin-bottom: 4px; font-weight: 600; }
.multi-option input { width: auto; margin: 0; }
.multi-empty { margin: 0; padding: 7px 8px; }
.time-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.time-chip { padding: 1px 7px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-strong); font-family: var(--mono); font-size: 0.78rem; color: var(--fg); }
.cell-error { max-width: 280px; margin-top: 0.3rem; color: var(--bad); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chain-jobs .child td:first-child { padding-left: 1.4rem; }
.chain-jobs .child td:first-child::before { content: "\2514\00a0"; color: var(--muted); }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; padding-top: 0.75rem; }
.card.flush > .pager { padding-top: 0.75rem; border-top: 1px solid var(--line); }
.pager .muted { font-size: 0.76rem; font-family: var(--mono); }
.pager .size { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.pager .size select { width: auto; padding: 3px 6px; font-size: 0.74rem; }

/* --- status --- */

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap; background: var(--idle-solid); color: var(--on-solid); }
.pill.on, .pill.COMPLETED { background: var(--ok-solid); }
.pill.RUNNING { background: var(--run-solid); }
.pill.FAILED { background: var(--bad-solid); }
.pill.BLOCKED { background: var(--warn-solid); color: var(--on-warn); }
.pill.HALTED { background: var(--warn); color: var(--on-warn); }
.pill.PENDING, .pill.IDLE { background: var(--waiting-solid); color: var(--fg); }
.pill.ACTIVE { background: var(--ok-solid); }
.pill.ENDED { background: var(--waiting-solid); color: var(--fg); }

/* The chain pipeline: one cell per job type, coloured by its state. */
.steps { display: grid; grid-template-columns: repeat(7, minmax(64px, 1fr)); gap: 3px; min-width: 500px; }
.halt-banner { margin: 0 0 1rem; padding: 0.6rem 0.8rem; border: 1px solid var(--warn-solid); border-radius: var(--radius); background: var(--surface-2); color: var(--fg); font-size: 0.85rem; }
.step { padding: 4px 8px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 0.7rem; line-height: 1.3; }
.step b { display: block; font-weight: 700; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.05em; }
.step span { font-family: var(--mono); }
.step.done { background: var(--ok-solid); color: var(--on-solid); }
.step.running { background: var(--run-solid); color: var(--on-solid); }
.step.failed { background: var(--bad-solid); color: var(--on-solid); }
.step.waiting { background: var(--waiting-solid); color: var(--fg); }
.step.halted { background: var(--warn); color: var(--on-warn); }
.steps.large { margin: 0.9rem 0 0.4rem; }
.steps.large .step { padding: 8px 10px; font-size: 0.78rem; }

/* --- modal --- */

.backdrop { position: fixed; inset: 0; background: var(--backdrop); display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 40; }
.modal { background: var(--surface); border: 1px solid var(--line); box-shadow: 0 20px 50px var(--shadow); border-radius: 12px; width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1180px, 100%); }
.modal.narrow { width: min(680px, 100%); }
.modal-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.modal-head h3 { margin: 0; font-size: 0.95rem; min-width: 0; }
.modal-head h3.grow { flex: 1 1 200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-body h4 { margin: 1.4rem 0 0.5rem; font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.modal-body > h4:first-child { margin-top: 0; }
.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; margin-top: 0.9rem; background: var(--surface-2); }
.section h5 { margin: 0 0 0.3rem; font-size: 0.82rem; }
.section p { margin: 0 0 0.6rem; }
@media (max-width: 700px) {
  .backdrop { padding: 0; }
  .modal, .modal.wide, .modal.narrow { width: 100%; height: 100%; max-height: none; border-radius: 0; border: none; }
}

.summary { display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; }
.summary div { font-size: 0.8rem; min-width: 0; }
.summary .k { display: block; color: var(--faint); font-weight: 600; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.1rem; }
.summary .v { font-family: var(--mono); overflow-wrap: anywhere; }
.summary .v.bad { color: var(--bad); }

.logs { max-height: 380px; overflow: auto; background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem; }
.logline { white-space: pre-wrap; font-family: var(--mono); font-size: 0.74rem; color: var(--fg); line-height: 1.5; }
.logline.warn { color: var(--warn); }
.logline.err { color: var(--bad); }
.json { margin: 0; max-height: 420px; overflow: auto; padding: 0.7rem 0.8rem; background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); font-family: var(--mono); font-size: 0.74rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- stories and images --- */

.cover-thumb { width: 96px; height: 50px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; display: block; }
.cover { width: 100%; max-width: 640px; height: auto; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.cover.fill { max-width: 100%; }
.clickable { cursor: zoom-in; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.shot { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: zoom-in; }
.shot:hover { border-color: var(--line-strong); }
.shot img { width: 100%; aspect-ratio: 40 / 21; object-fit: cover; display: block; }
.shot figcaption { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.6rem 0.7rem; font-size: 0.8rem; }
.story-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 0.9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; }
.sources { margin: 0; padding-left: 1.4rem; font-size: 0.82rem; line-height: 1.6; }
.sources a { overflow-wrap: anywhere; }

.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 2rem); background: var(--fg); border: 1px solid var(--fg); color: var(--surface); box-shadow: 0 8px 24px var(--shadow); padding: 8px 16px; border-radius: var(--radius); font-size: 0.85rem; z-index: 60; }

/* --- story reader --- */

.modal.xl { width: min(1440px, 96vw); height: 94vh; max-height: 94vh; }
.story-head h3.grow { font-size: 1rem; }
.story-layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.story-main { min-width: 0; overflow-y: auto; background: var(--bg); }
.story-side { min-width: 0; overflow-y: auto; padding: 0.4rem 1.1rem 1.5rem; background: var(--surface); border-left: 1px solid var(--line); }
.story-cover { display: block; width: 100%; max-height: 460px; object-fit: cover; border-bottom: 1px solid var(--line); background: var(--inset); }
.story-content { max-width: 780px; margin: 0 auto; padding: 1.8rem 2rem 3rem; }
.story-title { margin: 0 0 0.5rem; font-size: 1.9rem; line-height: 1.25; letter-spacing: -0.01em; color: var(--fg); }
.story-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0 0 1.1rem; font-size: 0.82rem; color: var(--faint); }
.story-lead { margin: 0 0 1.4rem; padding-left: 0.9rem; border-left: 3px solid var(--primary); font-size: 1.08rem; line-height: 1.6; color: var(--muted); }
.story-raw { max-height: none; font-size: 0.8rem; }

/* A 2 button switch. */
.seg { display: inline-flex; margin-bottom: 1.2rem; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.seg button { padding: 4px 12px; border: none; border-radius: 6px; background: none; color: var(--muted); font-size: 0.8rem; }
.seg button:hover { background: var(--surface-3); color: var(--fg); }
.seg button.on { background: var(--primary); color: var(--on-solid); font-weight: 600; }

/* The rendered article: long-form reading type. */
.prose { color: var(--fg); font-size: 1.02rem; line-height: 1.75; overflow-wrap: anywhere; }
.prose p { margin: 0 0 1.05rem; }
.prose h2 { margin: 2rem 0 0.7rem; font-size: 1.4rem; line-height: 1.3; }
.prose h3 { margin: 1.6rem 0 0.6rem; font-size: 1.18rem; }
.prose h4 { margin: 1.3rem 0 0.5rem; font-size: 1.02rem; color: var(--fg); text-transform: none; letter-spacing: 0; }
.prose ul, .prose ol { margin: 0 0 1.05rem; padding-left: 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose blockquote { margin: 1.2rem 0; padding: 0.4rem 1rem; border-left: 3px solid var(--line-strong); color: var(--muted); font-style: italic; }
.prose code { padding: 1px 5px; border-radius: 4px; background: var(--surface-3); font-family: var(--mono); font-size: 0.86em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose figure { margin: 1.6rem 0; }
.prose figure img, .prose img { display: block; width: 100%; height: auto; aspect-ratio: auto 40 / 21; background: var(--inset); border-radius: var(--radius); border: 1px solid var(--line); cursor: zoom-in; }
.prose img:hover, .thumb:hover { border-color: var(--link); }
.prose figcaption { margin-top: 0.45rem; font-size: 0.82rem; color: var(--faint); text-align: center; }
.img-missing { margin: 1.2rem 0; padding: 0.8rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--faint); font-family: var(--mono); font-size: 0.78rem; text-align: center; }

/* The sidebar blocks. */
.side-block { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.side-block:last-child { border-bottom: none; }
.side-block h4 { margin: 0 0 0.6rem; font-size: 0.72rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.side-block p { margin: 0 0 0.5rem; font-size: 0.84rem; }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 0.4rem 0.6rem; margin: 0; font-size: 0.84rem; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; min-width: 0; color: var(--fg); }
.thumb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.thumb { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--inset); }
.thumb img { display: block; width: 100%; aspect-ratio: 40 / 21; object-fit: cover; cursor: zoom-in; }
.thumb figcaption { padding: 0.3rem 0.45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.66rem; }
.regen { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
.regen button { align-self: flex-start; }
.regen p { margin: 0; font-size: 0.78rem; }
.story-side .sources { padding-left: 1.2rem; font-size: 0.8rem; }

@media (max-width: 1000px) {
  .story-layout { display: block; overflow-y: auto; }
  .story-main, .story-side { overflow: visible; }
  .story-side { border-left: none; border-top: 1px solid var(--line); }
  .story-content { padding: 1.2rem 1rem 2rem; }
  .story-title { font-size: 1.5rem; }
}
@media (max-width: 700px) {
  .modal.xl { width: 100%; height: 100%; max-height: none; border-radius: 0; }
}

/* --- login --- */

body.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; width: min(360px, 100%); }
.login-card h1 { font-size: 1.05rem; margin: 0 0 0.25rem; letter-spacing: 0.02em; color: var(--fg); }
.login-card .muted { margin: 0 0 1.2rem; }
.login-card .field { margin-bottom: 0.9rem; }
.login-card input { padding: 8px 10px; font-size: 0.9rem; }
.login-card button { width: 100%; justify-content: center; padding: 8px 12px; font-size: 0.9rem; font-weight: 600; margin-top: 0.3rem; border-color: var(--primary); background: var(--primary); color: var(--on-solid); }
.login-card button:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.login-card .turnstile { margin-bottom: 0.9rem; min-height: 65px; }
