/* ================================================================
   DreamyNite Admin – admin.css
   Hand-written, no build step. Colours live in the tokens below; the dark
   set applies when the visitor's system asks for it, unless they picked a
   theme in the panel (data-theme on <html>).
   ================================================================ */

:root {
  color-scheme: light;
  --bg: #f3f8f6;
  --surface: #ffffff;
  --surface-2: #eaf3ef;
  --surface-3: #dcebe5;
  --line: #cfdcd5;
  --ink: #10271f;
  --ink-2: #3f4d47;
  --muted: #566660;
  --brand: #006d4e;
  --brand-ink: #ffffff;
  --brand-soft: rgba(0, 109, 78, 0.1);
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, 0.1);
  --warn: #7a5200;
  --warn-soft: #fff0c7;
  --ok: #0b6b4c;
  --ok-soft: rgba(11, 107, 76, 0.12);
  --info: #1d4f91;
  --info-soft: rgba(29, 79, 145, 0.1);
  --chart: #006d4e;
  --chart-grid: #dbe6e0;
  --shadow: 0 1px 2px rgba(16, 39, 31, 0.06), 0 6px 20px rgba(16, 39, 31, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --font-head: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Be Vietnam Pro', system-ui, sans-serif;
  --sidebar: 264px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1713;
    --surface: #13221c;
    --surface-2: #182b24;
    --surface-3: #1f372e;
    --line: #2a4338;
    --ink: #e7f3ed;
    --ink-2: #bacdc4;
    --muted: #93aaa0;
    --brand: #5cd0a8;
    --brand-ink: #062a1e;
    --brand-soft: rgba(92, 208, 168, 0.14);
    --danger: #ffb4ab;
    --danger-soft: rgba(255, 180, 171, 0.12);
    --warn: #f2c66b;
    --warn-soft: rgba(242, 198, 107, 0.14);
    --ok: #7fdcb9;
    --ok-soft: rgba(127, 220, 185, 0.14);
    --info: #9cc3ff;
    --info-soft: rgba(156, 195, 255, 0.12);
    --chart: #5cd0a8;
    --chart-grid: #24392f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1713;
  --surface: #13221c;
  --surface-2: #182b24;
  --surface-3: #1f372e;
  --line: #2a4338;
  --ink: #e7f3ed;
  --ink-2: #bacdc4;
  --muted: #93aaa0;
  --brand: #5cd0a8;
  --brand-ink: #062a1e;
  --brand-soft: rgba(92, 208, 168, 0.14);
  --danger: #ffb4ab;
  --danger-soft: rgba(255, 180, 171, 0.12);
  --warn: #f2c66b;
  --warn-soft: rgba(242, 198, 107, 0.14);
  --ok: #7fdcb9;
  --ok-soft: rgba(127, 220, 185, 0.14);
  --info: #9cc3ff;
  --info-soft: rgba(156, 195, 255, 0.12);
  --chart: #5cd0a8;
  --chart-grid: #24392f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.95rem/1.5 var(--font-body);
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 200;
  background: var(--brand); color: var(--brand-ink); padding: 0.6rem 1rem; border-radius: var(--radius-sm); font-weight: 700;
}
.skip-link:focus { top: 1rem; }
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 22px; line-height: 1; vertical-align: middle; display: inline-block; flex-shrink: 0;
  user-select: none;
}
.material-symbols-outlined.sm { font-size: 18px; }
.material-symbols-outlined.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---------------- Access gate ---------------- */
.gate {
  min-height: 100vh; display: grid; place-content: center; gap: 1rem; text-align: center;
  padding: 2rem; color: var(--ink-2);
}
.gate h1 { font: 800 1.5rem var(--font-head); color: var(--ink); }
.gate .btn { justify-self: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Layout ---------------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); z-index: 60;
}
.brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1.25rem 1rem; text-decoration: none; color: inherit; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand strong { display: block; font: 800 1.05rem var(--font-head); color: var(--brand); line-height: 1.1; }
.brand span { font-size: 0.75rem; color: var(--muted); }

.nav { flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem; display: grid; gap: 2px; align-content: start; }
.nav a {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font: 600 0.9rem var(--font-head);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.nav .badge { margin-left: auto; }

.sidebar-foot { padding: 0.75rem; border-top: 1px solid var(--line); display: grid; gap: 0.35rem; }
.sidebar-foot .btn { justify-content: flex-start; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 55; }

.shell { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.5rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-search {
  flex: 1; max-width: 26rem; display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 0.75rem;
}
.topbar-search input { border: 0; background: transparent; padding: 0.6rem 0; width: 100%; outline: none; min-width: 0; }
.topbar-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.who { display: flex; align-items: center; gap: 0.6rem; padding-left: 0.75rem; margin-left: 0.25rem; border-left: 1px solid var(--line); }
.who b { display: block; font: 700 0.85rem var(--font-head); line-height: 1.2; }
.who small { color: var(--muted); font-size: 0.72rem; }
.who-text { text-align: right; }
.icon-btn.menu-toggle { display: none; }

main { padding: 1.75rem 1.5rem 4rem; width: 100%; max-width: 1240px; margin: 0 auto; outline: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .icon-btn.menu-toggle { display: inline-grid; }
  .topbar { padding: 0.6rem 1rem; }
  main { padding: 1.25rem 1rem 3rem; }
  .who-text { display: none; }
}
@media (max-width: 560px) {
  .topbar-search { display: none; }
  .topbar-actions { margin-left: auto; }
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 700 0.85rem var(--font-head); text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger.solid:hover { background: var(--danger); filter: brightness(1.1); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 50%; border: 0; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 10px; height: 10px; border-radius: 50%;
  background: #e0533d; border: 2px solid var(--bg);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  color: #fff; font: 800 0.8rem var(--font-head);
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.72rem; }

/* ---------------- Popovers ---------------- */
.pop-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; width: 340px; max-width: calc(100vw - 2rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 75vh; overflow-y: auto;
}
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); }
.popover-head h2 { font: 800 0.95rem var(--font-head); }
.pop-list { list-style: none; margin: 0; padding: 0; }
.pop-item {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.8rem 1rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line);
}
.pop-item:last-child { border-bottom: 0; }
.pop-item:hover { background: var(--surface-2); }
.pop-item.unread { background: var(--brand-soft); }
.pop-item .material-symbols-outlined { color: var(--brand); margin-top: 1px; }
.pop-item b { display: block; font: 700 0.85rem var(--font-head); }
.pop-item small { color: var(--muted); display: block; font-size: 0.78rem; }
.pop-empty { padding: 1.5rem 1rem; color: var(--muted); text-align: center; }
.menu { padding: 0.4rem; display: grid; gap: 2px; width: 270px; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; padding: 0.65rem 0.75rem;
  border: 0; background: transparent; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 500;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .value { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 0.3rem 0; width: 100%; }

/* ---------------- Page pieces ---------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { font: 800 clamp(1.5rem, 3vw, 2rem)/1.15 var(--font-head); letter-spacing: -0.01em; }
.page-head p { color: var(--muted); margin-top: 0.25rem; max-width: 60ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stack { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .cols-4 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card-head h2 { font: 800 1.05rem var(--font-head); }
.card-head small { color: var(--muted); }

.stat { padding: 1.1rem 1.25rem; display: grid; gap: 0.2rem; text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--brand); }
.stat .label { color: var(--muted); font: 700 0.72rem var(--font-head); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font: 800 2rem/1.1 var(--font-head); letter-spacing: -0.02em; }
.stat .note { color: var(--muted); font-size: 0.8rem; }
.stat .note b { color: var(--ink); }
.delta-up { color: var(--ok); font-weight: 700; }
.delta-down { color: var(--danger); font-weight: 700; }

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px;
  font: 700 0.72rem var(--font-head); background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.badge {
  display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 0.4rem; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font: 800 0.7rem var(--font-head);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.seg button {
  padding: 0.45rem 0.9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font: 700 0.8rem var(--font-head); color: var(--ink-2);
}
.seg button:hover { border-color: var(--brand); color: var(--brand); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------------- Forms ---------------- */
.field { display: grid; gap: 0.3rem; min-width: 0; }
.field > label, .field > .label, fieldset.field > legend { font: 700 0.8rem var(--font-head); color: var(--ink); padding: 0; }
.field .hint { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .search-input {
  width: 100%; padding: 0.6rem 0.8rem; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none;
}
.field textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .search-input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.8rem; font-weight: 600; min-height: 0; }
.field-error:empty { display: none; }
.field-row { display: grid; gap: 0.9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .field-row { grid-template-columns: minmax(0, 1fr); } }
.check { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.search-input { min-width: 12rem; }
.toolbar .search-input { width: auto; flex: 1 1 14rem; max-width: 24rem; }
.toolbar select.input { flex: 0 0 auto; }
select.input, .toolbar select { padding-right: 2rem; }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.85rem; }
.form-error:empty { display: none; }

/* ---------------- Tables & lists ---------------- */
/* `contain: paint` keeps a wide table from widening the whole page on phones. */
.table-wrap { overflow-x: auto; contain: paint; }
table.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th {
  text-align: left; padding: 0.75rem 1rem; font: 700 0.7rem var(--font-head); text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.cell-main b { display: block; font: 700 0.9rem var(--font-head); overflow-wrap: anywhere; }
.cell-main small { color: var(--muted); display: block; font-size: 0.78rem; overflow-wrap: anywhere; }
.thumb {
  width: 52px; height: 40px; border-radius: 8px; background: var(--surface-3); overflow: hidden; flex-shrink: 0;
  display: grid; place-items: center; color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-actions { display: flex; gap: 0.1rem; justify-content: flex-end; flex-wrap: nowrap; }
.table .icon-btn { width: 34px; height: 34px; }
.table td.num, .table td:last-child { white-space: nowrap; }
.table td.when { white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.pager .btns { display: flex; gap: 0.4rem; }
.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); display: grid; gap: 0.5rem; justify-items: center; }
.empty .material-symbols-outlined { font-size: 2.5rem; color: var(--brand); }
.empty h3 { font: 800 1.05rem var(--font-head); color: var(--ink); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.activity { display: flex; gap: 0.8rem; align-items: flex-start; text-decoration: none; color: inherit; }
.activity .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.activity b { display: block; font: 700 0.88rem var(--font-head); overflow-wrap: anywhere; }
.activity small { color: var(--muted); }
.activity time { margin-left: auto; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

/* Horizontal bar list (categories, top stories) */
.hbars { display: grid; gap: 0.85rem; }
.hbar-top { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.88rem; margin-bottom: 0.3rem; }
.hbar-top span:first-child { font-weight: 600; overflow-wrap: anywhere; }
.hbar-top span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.hbar-track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--chart); border-radius: 4px; min-width: 2px; }

/* ---------------- Vertical bar charts ---------------- */
.chart { position: relative; }
.chart-plot {
  position: relative; display: flex; align-items: flex-end; justify-content: space-around; gap: 6px;
  height: 180px; padding: 22px 4px 0;
  background-image: linear-gradient(to top, var(--chart-grid) 1px, transparent 1px);
  background-size: 100% 25%; background-position: bottom; border-bottom: 1px solid var(--chart-grid);
}
.chart-col { flex: 1; max-width: 46px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.chart-bar {
  width: min(26px, 70%); min-height: 2px; background: var(--chart); border-radius: 4px 4px 0 0;
  border: 0; padding: 0; position: relative; transition: filter 0.15s; cursor: default;
}
.chart-bar.zero { background: var(--chart-grid); }
.chart-col:hover .chart-bar, .chart-bar:focus-visible { filter: brightness(1.18); }
.chart-val { font: 700 0.72rem var(--font-head); color: var(--ink); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.chart-axis { display: flex; justify-content: space-around; gap: 6px; padding: 6px 4px 0; }
.chart-axis span { flex: 1; max-width: 46px; text-align: center; font-size: 0.72rem; color: var(--muted); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--surface); padding: 0.35rem 0.6rem; border-radius: 8px; font-size: 0.78rem; white-space: nowrap;
  box-shadow: var(--shadow);
}
.chart-empty { height: 180px; display: grid; place-items: center; color: var(--muted); border-bottom: 1px solid var(--chart-grid); }

/* ---------------- Cards for moderation ---------------- */
.item-card { padding: 1.1rem 1.25rem; display: grid; gap: 0.6rem; }
.item-card + .item-card { margin-top: 0.75rem; }
.item-head { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; }
.item-head b { font: 800 1rem var(--font-head); }
.item-meta { color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; }
.item-text { color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.stars { color: #d99a00; letter-spacing: 1px; font-size: 0.95rem; }
.stars .off { color: var(--line); }

/* ---------------- Popular tales ---------------- */
.slots { display: grid; gap: 0.6rem; }
.slot { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.slot.empty-slot { border-style: dashed; color: var(--muted); }
.slot { min-width: 0; }
.slot .icon-btn { width: 34px; height: 34px; }
@media (max-width: 560px) { .slot .thumb { display: none; } }
.slot .pos { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font: 800 0.75rem var(--font-head); flex-shrink: 0; }
.slot.empty-slot .pos { background: var(--surface-3); color: var(--muted); }
.slot .grow { flex: 1; min-width: 0; }
.slot .grow b { display: block; font: 700 0.88rem var(--font-head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .grow small { color: var(--muted); }
.preview {
  display: grid; gap: 8px; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr 0.8fr; height: 300px;
  grid-template-areas: "a b" "a c" "d d";
}
.preview > * { border-radius: 12px; overflow: hidden; position: relative; background: var(--surface-3); display: grid; }
.preview > :nth-child(1) { grid-area: a; }
.preview > :nth-child(2) { grid-area: b; }
.preview > :nth-child(3) { grid-area: c; }
.preview > :nth-child(4) { grid-area: d; }
.preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview .cap { position: relative; align-self: end; padding: 0.6rem 0.75rem; color: #fff; font: 800 0.85rem var(--font-head); background: linear-gradient(transparent, rgba(0, 0, 0, 0.72)); }
.preview .none { display: grid; place-items: center; color: var(--muted); border: 2px dashed var(--line); background: transparent; font-size: 0.8rem; }
.notice { display: flex; gap: 0.75rem; padding: 0.9rem 1rem; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--ink); }
.notice .material-symbols-outlined { color: var(--info); }
.savebar {
  position: sticky; bottom: 1rem; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.8rem 1rem; background: var(--surface); border: 1px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------------- Dialog ---------------- */
dialog.modal {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--ink);
  width: min(600px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
dialog.modal.wide { width: min(820px, calc(100vw - 2rem)); }
dialog.modal.narrow { width: min(440px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(6, 16, 12, 0.6); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 800 1.15rem var(--font-head); }
.modal-body { padding: 1.25rem 1.4rem; display: grid; gap: 1rem; overflow-y: auto; max-height: calc(100vh - 12rem); }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.reading { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; background: var(--surface-2); border-radius: var(--radius-sm); padding: 1rem; max-height: 40vh; overflow-y: auto; }
.confirm-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: var(--danger-soft); color: var(--danger); }
.confirm-icon.safe { background: var(--brand-soft); color: var(--brand); }
.center { text-align: center; }

/* Subscription setup guide (admin/app.js, showSubscriptionGuide) */
.modal-body .hint { color: var(--muted); font-size: 0.85rem; }
.guide { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 1rem; }
.guide > li { counter-increment: step; position: relative; padding-left: 2.4rem; display: grid; gap: 0.35rem; }
.guide > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font: 800 0.85rem var(--font-head);
}
.guide h3 { font: 800 0.98rem var(--font-head); line-height: 1.7rem; }
.guide code { font-size: 0.85em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
.copy-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.4rem 0.4rem 0.75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.copy-row code { flex: 1; min-width: 0; background: none; padding: 0; }
.env-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.75rem; font-size: 0.88rem; }
.env-list dt, .env-list dd { margin: 0; }
@media (max-width: 520px) {
  .env-list { grid-template-columns: 1fr; gap: 0.15rem; }
  .env-list dd { margin-bottom: 0.4rem; color: var(--muted); }
}

/* ---------------- Plans & Premium (admin/screens/plans.js) ---------------- */
.launch-row { display: flex; align-items: flex-start; gap: 1rem; }
.launch-icon { flex: none; width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.launch-icon.on { background: var(--brand-soft); color: var(--brand); }
.launch-text { flex: 1; min-width: 0; display: grid; gap: 0.35rem; }
.launch-text h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.launch-row > .btn { flex: none; }
.blockers { margin: 0.2rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; font-size: 0.88rem; }
.blockers li { display: flex; align-items: center; gap: 0.4rem; color: var(--warn); }
.blockers code, .env-list code { font-size: 0.85em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .launch-row { flex-wrap: wrap; }
  .launch-row > .btn { width: 100%; justify-content: center; }
}
.offer-row { display: flex; gap: 0.5rem; }
.offer-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.offer-row .btn { flex: none; }
.features-table { min-width: 720px; }
.features-table th, .features-table td { vertical-align: middle; padding-inline: 0.5rem; }
.features-table .feature-cell { width: 34%; min-width: 12rem; }
.feature-name { display: flex; align-items: center; gap: 0.4rem; }
.feature-name .input { flex: 1; min-width: 0; }
.feature-name .lock { color: var(--muted); display: inline-flex; }
.value-pair { display: inline-flex; align-items: center; gap: 0.4rem; }
.value-pair .input { width: auto; }
.value-stack { display: grid; gap: 0.35rem; width: 9.5rem; }
.num-input { width: 5rem; }
.show-box { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
table.compare-preview { min-width: 0; }
.compare-preview td, .compare-preview th[scope="row"] { text-align: left; }
.compare-preview th[scope="row"] {
  font: 600 0.88rem var(--font-body); text-transform: none; letter-spacing: 0; color: var(--ink);
  background: none; border-bottom-color: var(--line); white-space: normal; padding: 0.8rem 1rem;
}
.compare-preview td { white-space: nowrap; }
.compare-preview tr:last-child th { border-bottom: 0; }
@media (max-width: 640px) {
  .table.compare-preview td, .table.compare-preview th { white-space: normal; padding-inline: 0.6rem; }
}
.compare-preview .yes { color: var(--ok); }
.compare-preview .no { color: var(--muted); }

/* ---------------- Toasts ---------------- */
#toasts { position: fixed; inset: auto 1rem 1rem auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; right: 1rem; bottom: 1rem; z-index: 300; display: grid; gap: 0.5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.8rem 0.9rem; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: 0.88rem; animation: rise 0.2s ease;
}
.toast.success .material-symbols-outlined { color: #6fdcb2; }
.toast.error { background: #7d1d16; color: #fff; }
.toast .msg { flex: 1; overflow-wrap: anywhere; }
.toast button { background: none; border: 0; color: inherit; opacity: 0.75; padding: 0; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Loading ---------------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 1rem; }
.sk-block { height: 6rem; }
.error-card { padding: 2rem; text-align: center; display: grid; gap: 0.75rem; justify-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Comic pages in the story editor */
.comic-pages { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.comic-pages:empty { display: none; }
.comic-pages li { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem; border: 1px solid var(--line, #ddd); border-radius: 0.6rem; background: var(--surface-2); }
.comic-pages img { width: 3.5rem; height: 4.5rem; object-fit: cover; border-radius: 0.4rem; flex: none; }
.comic-pages li > span { flex: 1; font-weight: 600; font-size: 0.85rem; min-width: 0; }
.btn-sm { padding: 0.3rem 0.45rem; min-width: 0; }

/* Show / hide button inside a password box */
.pw-wrap { position: relative; }
.field .pw-wrap > input:not([type="checkbox"]):not([type="radio"]) { padding-right: 2.9rem; }
.pw-toggle { position: absolute; top: 50%; right: 0.25rem; transform: translateY(-50%); width: 36px; height: 36px; }
.pw-toggle[aria-pressed="true"] { color: var(--brand); }

/* Story editor: cover picture and the story check */
.cover-row { display: flex; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }
.cover-row input { flex: 1 1 100%; min-width: 0; }
.cover-preview { width: 100%; max-width: 16rem; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.check-panel { display: grid; gap: 0.6rem; padding: 0.9rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.check-panel.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.check-panel.bad { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.check-panel p { margin: 0; }
.check-panel > .btn { justify-self: start; }
.check-head { display: flex; align-items: center; gap: 0.5rem; }
.check-panel.ok .check-head { color: var(--ok); }
.check-panel.bad .check-head { color: var(--warn); }
.check-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.check-issues li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); background: var(--surface); }
.check-msg { flex: 1 1 16rem; min-width: 0; font-size: 0.88rem; overflow-wrap: anywhere; }
.check-msg q { font-style: italic; }

/* ---------------- Image library ---------------- */
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
.media-grid > .empty { grid-column: 1 / -1; }
.media-tile {
  width: 100%; display: grid; gap: 0.45rem; padding: 0.45rem; text-align: left; cursor: pointer; color: inherit; font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color 0.15s, box-shadow 0.15s;
}
.media-tile:hover, .media-tile:focus-visible { border-color: var(--brand); box-shadow: var(--shadow); }
.media-thumb { display: block; aspect-ratio: 4 / 3; border-radius: calc(var(--radius-sm) - 2px); overflow: hidden; background: var(--surface-2); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-caption { display: grid; gap: 0.2rem; min-width: 0; }
.media-caption b { font: 700 0.85rem var(--font-head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-caption b.untitled { color: var(--muted); font-weight: 600; font-style: italic; }
.media-caption small { color: var(--muted); font-size: 0.74rem; display: grid; justify-items: start; gap: 0.25rem; }
.pick-more { display: flex; justify-content: center; margin-top: 0.8rem; }
.media-detail { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.media-big { display: block; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.media-big img { width: 100%; display: block; }
.media-detail .copy-row code { overflow-wrap: anywhere; white-space: normal; font-size: 0.8rem; }
.media-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; margin: 0; font-size: 0.85rem; }
.media-facts dt { color: var(--muted); }
.media-facts dd { margin: 0; overflow-wrap: anywhere; }
.media-used { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.88rem; }
.media-used li { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.media-copies { display: grid; gap: 0.5rem; padding: 0.8rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); }
.media-copies > b { display: flex; align-items: center; gap: 0.35rem; color: var(--warn); }
.media-copies ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.media-copies .hint { margin: 0; }
.media-copies .btn { justify-self: start; }
.media-copy { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.3rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.media-copy:hover { border-color: var(--brand); }
.media-copy:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.media-copy img { width: 2.6rem; height: 2.6rem; object-fit: cover; border-radius: 6px; background: var(--surface-2); flex: none; }
.media-copy > span:not(.pill) { display: grid; flex: 1; min-width: 0; font-size: 0.85rem; }
.media-copy .pill { flex: none; }
.media-copy b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-copy small { color: var(--muted); font-size: 0.74rem; }
.modal-foot .grow { flex: 1; }
label.btn.is-busy { opacity: 0.6; pointer-events: none; }
@media (max-width: 720px) {
  .media-detail { grid-template-columns: minmax(0, 1fr); }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.6rem; }
}

/* ---------------- Review queue: picture and AI check ---------------- */
.sub-body { display: grid; gap: 1rem; grid-template-columns: 13rem minmax(0, 1fr); align-items: start; }
.sub-cover { display: grid; gap: 0.5rem; }
.sub-cover img, .sub-cover-empty { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.sub-cover-empty { display: grid; place-content: center; justify-items: center; gap: 0.25rem; color: var(--muted); font-size: 0.8rem; }
.sub-cover-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sub-cover-actions .btn { flex: 1 1 auto; justify-content: center; }
.ai-review { display: grid; gap: 0.55rem; padding: 0.8rem 0.95rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.ai-review.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.ai-review p { margin: 0; }
.ai-review > .btn, .ai-review > div > .btn { justify-self: start; }
.ai-line { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; font-size: 0.88rem; }
.ai-line .spinner { width: 1rem; height: 1rem; flex: none; }
.ai-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ai-tags .pill { display: inline-flex; align-items: center; gap: 0.25rem; }
.ai-label { font: 700 0.72rem var(--font-head); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ai-overview { font-size: 0.88rem; color: var(--ink-2); }
.ai-issues summary { cursor: pointer; font-weight: 700; font-size: 0.88rem; }
.ai-issues .check-issues { margin-top: 0.5rem; }
.reading mark.flag { background: color-mix(in srgb, var(--warn) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 0.1em; }
.reading mark.flag-bad { background: color-mix(in srgb, var(--danger) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 0.1em; text-decoration: underline wavy var(--danger); text-underline-offset: 3px; }
@media (max-width: 720px) {
  .sub-body { grid-template-columns: minmax(0, 1fr); }
  .sub-cover { max-width: 20rem; }
}
