/* Blog Hub design system. The ONLY place colour tokens are defined.
   Rules: brand tokens below, tints of ink/surface/brand made with alpha, status colours only in
   badges and alerts. Spacing uses 4/8/12/16/24/32 only. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter-600.woff2") format("woff2"); }

:root {
  /* Brand tokens */
  --bg: #F2F2F2;
  --surface: #FFFFFF;
  --ink: #152029;
  --ink-muted: #5A6570;
  --brand: #FF4917;
  --brand-dark: #C2300A;

  /* Tints made from the brand tokens */
  --ink-4: rgba(21, 32, 41, 0.04);
  --ink-8: rgba(21, 32, 41, 0.08);
  --ink-10: rgba(21, 32, 41, 0.10);
  --ink-16: rgba(21, 32, 41, 0.16);
  --ink-20: rgba(21, 32, 41, 0.20);
  --ink-50: rgba(21, 32, 41, 0.50);
  --on-ink: #FFFFFF;
  --on-ink-muted: rgba(255, 255, 255, 0.64);
  --on-ink-6: rgba(255, 255, 255, 0.06);
  --on-ink-10: rgba(255, 255, 255, 0.10);
  --on-ink-24: rgba(255, 255, 255, 0.24);
  --brand-24: rgba(255, 73, 23, 0.24);

  /* Status set: badges, alerts and the danger button only */
  --st-draft-bg: #E5E7EB;       --st-draft-fg: #374151;
  --st-pending-bg: #FEF3C7;     --st-pending-fg: #92400E;
  --st-changes-bg: #FFEDD5;     --st-changes-fg: #9A3412;
  --st-approved-bg: #DCFCE7;    --st-approved-fg: #166534;
  --st-rejected-bg: #FEE2E2;    --st-rejected-fg: #991B1B;
  --st-unpub-bg: #E2E8F0;       --st-unpub-fg: #334155;
  --danger: #B91C1C;            --danger-pressed: #991B1B;

  /* Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --radius-sm: 6px;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 240px;
  --content-max: 1200px;
  --form-max: 720px;
  --page-pad: 32px;
}
@media (max-width: 1024px) { :root { --page-pad: 24px; } }
@media (max-width: 640px)  { :root { --page-pad: 16px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11";
}
img { max-width: 100%; height: auto; }
h1, h2, h3 { margin: 0 0 var(--sp-3); line-height: 1.3; letter-spacing: -0.005em; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 var(--sp-4); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
strong, b { font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 13px; }
small { font-size: 13px; }
small, .muted { color: var(--ink-muted); }
.num, .tabular, time { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon { flex: 0 0 auto; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.skip-link {
  position: absolute; left: var(--sp-2); top: -48px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--ink-20); border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--sp-2); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--ink); color: var(--on-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (min-width: 901px) {
  /* Paint the sidebar column the full page height, also on long pages. */
  .shell { background: linear-gradient(90deg, var(--ink) var(--sidebar-w), var(--bg) var(--sidebar-w)); }
}
.brandbar { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.logo { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--on-ink); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.logo:hover { color: var(--on-ink); text-decoration: none; }
.logo-mark { width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--brand); display: inline-block; }
.logo.on-light { color: var(--ink); }

.nav { list-style: none; margin: 0; padding: 0 var(--sp-3) var(--sp-4); }
.nav-label { padding: var(--sp-4) var(--sp-3) var(--sp-1); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--on-ink-muted); }
.nav a {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  height: 36px; padding: 0 var(--sp-3); margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--on-ink-muted); font-size: 14px; font-weight: 500;
}
.nav a .icon { color: var(--on-ink-muted); }
.nav a:hover { background: var(--on-ink-6); color: var(--on-ink); text-decoration: none; }
.nav a:hover .icon { color: var(--on-ink); }
.nav a[aria-current="page"] { background: var(--on-ink-10); color: var(--on-ink); }
.nav a[aria-current="page"] .icon { color: var(--brand); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: calc(-1 * var(--sp-3)); top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav a:focus-visible { outline-offset: -2px; }

.sidebar-foot { margin-top: auto; padding: var(--sp-4); border-top: 1px solid var(--on-ink-10); }
.user-block { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); min-width: 0; }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--on-ink-10); color: var(--on-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-block .who { font-size: 14px; font-weight: 500; color: var(--on-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-block .role { font-size: 12px; color: var(--on-ink-muted); text-transform: capitalize; }
.signout {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--on-ink-24);
  background: transparent; color: var(--on-ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.signout:hover { background: var(--on-ink-6); }

.main { flex: 1 1 auto; min-width: 0; }
.content { max-width: calc(var(--content-max) + 2 * var(--page-pad)); margin: 0 auto; padding: var(--page-pad); }
.topbar { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--on-ink-24); background: transparent; color: var(--on-ink); cursor: pointer;
}
.icon-btn:hover { background: var(--on-ink-6); }
.close-btn { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 var(--page-pad);
    background: var(--ink); color: var(--on-ink);
    position: sticky; top: 0; z-index: 30;
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(288px, 85vw); height: 100%;
    transform: translateX(-100%); transition: transform .2s ease; visibility: hidden;
  }
  .sidebar.open { transform: none; visibility: visible; }
  .close-btn { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: var(--ink-50); z-index: 35; }
}
@media (min-width: 901px) { .scrim { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Page header (one component on every screen) ---------- */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.page-header-main { min-width: 0; flex: 1 1 320px; }
.page-back { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: 13px; font-weight: 500; color: var(--ink-muted); margin-bottom: var(--sp-2); }
.page-back:hover { color: var(--ink); text-decoration: none; }
.page-title { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.page-text, .page-meta { margin: var(--sp-1) 0 0; color: var(--ink-muted); font-size: 14px; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.inline-form { display: inline; margin: 0; }

/* ---------- Buttons: primary, secondary, danger ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-4);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover { text-decoration: none; }
.btn .icon { margin-left: -2px; }
/* Dark text on brand, always. Hover and press darken with an ink overlay. */
.btn-primary { background-color: var(--brand); color: var(--ink); border-color: var(--brand); }
.btn-primary:hover { color: var(--ink); background-image: linear-gradient(var(--ink-8), var(--ink-8)); }
.btn-primary:active { background-image: linear-gradient(var(--ink-16), var(--ink-16)); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--ink-20); }
.btn-secondary:hover { color: var(--ink); background: var(--ink-4); border-color: var(--ink-50); }
.btn-secondary:active { background: var(--ink-8); }
.btn-danger { background: var(--danger); color: #FFFFFF; border-color: var(--danger); }
.btn-danger:hover, .btn-danger:active { background: var(--danger-pressed); border-color: var(--danger-pressed); color: #FFFFFF; }
.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: 13px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn.is-loading .icon { display: none; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-dark); cursor: pointer; }
.linklike:hover { text-decoration: underline; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--ink-10); border-radius: var(--radius);
  padding: var(--sp-5); margin-bottom: var(--sp-5);
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.card-head h2 { margin: 0; }
.card-text { color: var(--ink-muted); font-size: 14px; margin-top: calc(-1 * var(--sp-2)); }
.section-title { font-size: 16px; font-weight: 600; margin: var(--sp-5) 0 var(--sp-3); }
.card .section-title:first-child { margin-top: 0; }
.grid { display: grid; gap: var(--sp-5); }
.grid > .card { margin-bottom: 0; }
.grid + * { margin-top: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .card { padding: var(--sp-4); margin-bottom: var(--sp-4); }
  .grid { gap: var(--sp-4); }
  .grid + * { margin-top: var(--sp-4); }
}

.site-card { display: flex; flex-direction: column; gap: var(--sp-4); margin: 0; }
.site-card .domain { font-size: 13px; color: var(--ink-muted); overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0 0 var(--sp-4); font-size: 14px; font-variant-numeric: tabular-nums; }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.reason { font-size: 13px; color: var(--ink-muted); margin: 0; }

.progress { height: 6px; background: var(--ink-8); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--ink-10); border-radius: var(--radius);
  overflow-x: auto; margin-bottom: var(--sp-5); max-width: 100%;
}
.card .table-wrap { margin-bottom: var(--sp-4); }
.card .table-wrap:last-child { margin-bottom: 0; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--ink-8); vertical-align: middle; }
.table td { height: 48px; }
.table thead th {
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-muted);
  background: var(--surface); white-space: nowrap; height: 40px; padding-top: var(--sp-2); padding-bottom: var(--sp-2);
}
.table tbody th { font-weight: 500; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover { background: var(--ink-4); }
.table .num { text-align: right; }
.table td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.table td.actions-cell .btn + .btn, .table td.actions-cell .btn + form, .table td.actions-cell form + form { margin-left: var(--sp-1); }
.table .cell-main { font-weight: 500; color: var(--ink); }
.table .cell-sub { display: block; font-size: 13px; color: var(--ink-muted); }
.table a.cell-main:hover { color: var(--brand-dark); }

/* Phones: rows become stacked cards. Labels come from the column headers (app.js). */
@media (max-width: 640px) {
  .table-wrap:has(.table:not(.table-scroll)) { background: transparent; border: 0; overflow: visible; }
  .table:not(.table-scroll) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table:not(.table-scroll), .table:not(.table-scroll) tbody, .table:not(.table-scroll) tr, .table:not(.table-scroll) td, .table:not(.table-scroll) tbody th { display: block; width: 100%; }
  .table:not(.table-scroll) tr {
    background: var(--surface); border: 1px solid var(--ink-10); border-radius: var(--radius);
    padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3);
  }
  .table:not(.table-scroll) tbody tr:hover { background: var(--surface); }
  /* Label sits in a fixed left column; the cell content keeps its normal flow on the right. */
  .table:not(.table-scroll) td, .table:not(.table-scroll) tbody th {
    position: relative; height: auto; border: 0; text-align: left;
    padding: var(--sp-2) 0 var(--sp-2) calc(38% + var(--sp-3)); min-height: 36px;
  }
  .table:not(.table-scroll) td + td { border-top: 1px solid var(--ink-8); }
  .table:not(.table-scroll) td::before {
    content: attr(data-label); position: absolute; left: 0; top: var(--sp-2); width: 38%;
    font-size: 12px; font-weight: 600; line-height: 22px; color: var(--ink-muted); letter-spacing: 0.02em;
  }
  .table:not(.table-scroll) td:not([data-label])::before, .table:not(.table-scroll) td[data-label=""]::before { content: none; }
  .table:not(.table-scroll) td:not([data-label]), .table:not(.table-scroll) td[data-label=""] { padding-left: 0; }
  .table:not(.table-scroll) td.num { text-align: left; }
  .table:not(.table-scroll) td.actions-cell { width: 100%; text-align: left; display: flex; flex-wrap: wrap; gap: var(--sp-2); padding-top: var(--sp-3); }
  .table:not(.table-scroll) td.actions-cell .btn { margin: 0; }
  .table:not(.table-scroll) td.actions-cell::before { content: none; }
}

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--sp-4); }
.form-card { max-width: var(--form-max); }
.form-row { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding-top: var(--sp-1); }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field label, .label { font-weight: 500; font-size: 14px; }
.field .hint, .hint { font-size: 13px; color: var(--ink-muted); }
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 var(--sp-3);
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--ink-20); border-radius: var(--radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235A6570' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-sm, select.input.input-sm { height: 32px; width: auto; font-size: 13px; }
textarea.input { height: auto; min-height: 96px; padding: var(--sp-2) var(--sp-3); line-height: 1.55; resize: vertical; }
.input::placeholder { color: var(--ink-muted); opacity: .8; }
.input:hover { border-color: var(--ink-50); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-24); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[readonly] { background: var(--ink-4); }
.field-error { color: var(--st-rejected-fg); font-size: 13px; font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 500; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.counter { font-size: 13px; color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--st-rejected-fg); font-weight: 500; }
fieldset { border: 0; padding: 0; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin-bottom: var(--sp-4); }
.filters .field { min-width: 180px; flex: 0 1 220px; }
.filters .clear-link { font-size: 14px; height: 36px; display: inline-flex; align-items: center; }
.search { position: relative; flex: 0 1 360px; min-width: 220px; }
.search .icon { position: absolute; left: 12px; top: 10px; color: var(--ink-muted); pointer-events: none; }
.search .input { padding-left: 38px; }

/* Custom file input: hidden native control, styled button, chosen file name. */
.file-input { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.file-input input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input input[type="file"]:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }
.file-input-name { font-size: 14px; color: var(--ink-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.file-input.has-file .file-input-name { color: var(--ink); font-weight: 500; }

@media (max-width: 640px) {
  .form .form-actions .btn, .form > div > .btn:only-child, .form-actions .btn { width: 100%; }
  .filters .field, .search { flex: 1 1 100%; }
  .filters > .btn { width: 100%; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > form { flex: 1 1 0; }
  .page-actions > form .btn { width: 100%; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 var(--sp-2);
  border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge-draft { background: var(--st-draft-bg); color: var(--st-draft-fg); }
.badge-pending { background: var(--st-pending-bg); color: var(--st-pending-fg); }
.badge-changes_requested { background: var(--st-changes-bg); color: var(--st-changes-fg); }
.badge-approved { background: var(--st-approved-bg); color: var(--st-approved-fg); }
.badge-rejected { background: var(--st-rejected-bg); color: var(--st-rejected-fg); }
.badge-unpublished { background: var(--st-unpub-bg); color: var(--st-unpub-fg); }
.badge-neutral { background: var(--ink-8); color: var(--ink); }

/* ---------- Alerts and flash banners ---------- */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  border: 1px solid var(--ink-10); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); background: var(--surface); font-size: 14px;
}
.alert > .icon { margin-top: 1px; }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert-body > :last-child { margin-bottom: 0; }
.alert-success { border-color: rgba(22, 101, 52, 0.2); background: var(--st-approved-bg); color: var(--st-approved-fg); }
.alert-error { border-color: rgba(153, 27, 27, 0.2); background: var(--st-rejected-bg); color: var(--st-rejected-fg); }
.alert-warning { border-color: rgba(146, 64, 14, 0.2); background: var(--st-pending-bg); color: var(--st-pending-fg); }
.alert-info { background: var(--surface); color: var(--ink); }
.alert ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-5); }
.alert p { margin-bottom: var(--sp-2); }
.alert-close {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin: -4px -8px -4px 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: inherit; cursor: pointer; opacity: .7;
}
.alert-close:hover { opacity: 1; background: var(--ink-8); }

/* Shown-once secrets (invite links, API keys) */
.secret { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.secret input { flex: 1 1 260px; font-family: var(--mono); font-size: 13px; }

/* ---------- Empty and loading states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-6) var(--sp-4); background: var(--surface);
  border: 1px solid var(--ink-10); border-radius: var(--radius); margin-bottom: var(--sp-5);
}
.empty-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ink-4); color: var(--ink-muted);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--sp-3);
}
.empty p { color: var(--ink-muted); margin: 0 0 var(--sp-4); max-width: 420px; }
.empty p:last-child { margin-bottom: 0; }
.empty-inline { color: var(--ink-muted); font-size: 14px; margin: 0; }
.loading { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--ink-muted); font-size: 14px; }
.loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink-muted); border-right-color: transparent; animation: spin .7s linear infinite; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-box { width: 100%; max-width: 400px; margin: 0 auto; padding: 12vh var(--sp-4) var(--sp-6); }
.auth-box .logo { margin-bottom: var(--sp-5); }
.auth-box .card { padding: var(--sp-6); }
.auth-box h1 { font-size: 22px; margin-bottom: var(--sp-1); }
.auth-box .lead { color: var(--ink-muted); font-size: 14px; margin-bottom: var(--sp-5); }
.auth-box .btn { width: 100%; }
.auth-box .form-foot { text-align: center; font-size: 14px; margin: 0; }
@media (max-width: 640px) { .auth-box { padding-top: var(--sp-6); } .auth-box .card { padding: var(--sp-5); } }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: var(--sp-1); list-style: none; padding: 0; margin: 0 0 var(--sp-5); font-variant-numeric: tabular-nums; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--sp-2);
  border: 1px solid var(--ink-20); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 14px;
}
.pagination a:hover { background: var(--ink-4); text-decoration: none; }
.pagination .active span { border-color: var(--ink); font-weight: 600; }
.pagination .disabled span { color: var(--ink-muted); }

/* ---------- Post preview (as on the site) ---------- */
.preview { background: var(--surface); border: 1px solid var(--ink-10); border-radius: var(--radius); padding: var(--sp-6); }
.preview-meta { color: var(--ink-muted); font-size: 13px; margin-bottom: var(--sp-2); }
.preview-title { font-size: 28px; font-weight: 600; line-height: 1.25; margin-bottom: var(--sp-3); }
.preview-excerpt { color: var(--ink-muted); font-size: 16px; margin-bottom: var(--sp-5); }
@media (max-width: 640px) { .preview { padding: var(--sp-4); } .preview-title { font-size: 22px; } }
.prose { max-width: 680px; font-size: 16px; line-height: 1.7; overflow-wrap: break-word; }
.prose h2 { font-size: 20px; margin: var(--sp-6) 0 var(--sp-3); }
.prose h3 { font-size: 17px; margin: var(--sp-5) 0 var(--sp-2); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin: var(--sp-4) 0; padding-left: var(--sp-4); border-left: 3px solid var(--ink-20); color: var(--ink-muted); }
.prose ul, .prose ol { padding-left: var(--sp-5); }
.prose img { border-radius: var(--radius); }
.section-label { font-size: 13px; font-weight: 600; color: var(--ink-muted); margin: 0 0 var(--sp-2); }
.cover { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--ink-10); background: var(--bg); display: block; }
.thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 1px solid var(--ink-10); }

/* ---------- Diff ---------- */
.diff { display: grid; gap: var(--sp-1); font-size: 14px; }
.diff div { padding: var(--sp-1) var(--sp-2); border-radius: 4px; border: 1px solid var(--ink-10); }
.diff .add { background: var(--st-approved-bg); color: var(--st-approved-fg); }
.diff .del { background: var(--st-rejected-bg); color: var(--st-rejected-fg); text-decoration: line-through; }
.diff .same { color: var(--ink-muted); }
.diff-marker { font-weight: 600; margin-right: var(--sp-1); text-decoration: none; display: inline-block; }

/* ---------- Review side panel ---------- */
.side-panel { position: sticky; top: var(--sp-4); }
.side-panel .card { padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4); }
@media (max-width: 1100px) { .side-panel { position: static; } }
.meter { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-variant-numeric: tabular-nums; }
.meter strong { font-size: 15px; }
.meter.over strong { color: var(--st-rejected-fg); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); font-size: 14px; }
.check-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); font-size: 14px; }
.link-list li { min-width: 0; }
.link-list .host { font-weight: 500; }
.link-list .url { display: block; font-size: 12px; color: var(--ink-muted); overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); font-size: 14px; }

/* ---------- Editor ---------- */
.editor-wrap { position: relative; background: var(--surface); border: 1px solid var(--ink-20); border-radius: var(--radius-sm); }
.editor-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-24); }
.editor-wrap .ql-container { border: 0; font-family: var(--font); font-size: 16px; }
.editor-wrap .ql-editor { min-height: 380px; line-height: 1.7; padding: var(--sp-4) var(--sp-5); color: var(--ink); }
.editor-wrap .ql-editor h2 { font-size: 20px; font-weight: 600; margin: var(--sp-4) 0 var(--sp-2); }
.editor-wrap .ql-editor h3 { font-size: 17px; font-weight: 600; margin: var(--sp-3) 0 var(--sp-2); }
.editor-wrap .ql-editor p { margin: 0 0 var(--sp-3); }
.editor-wrap .ql-editor a { color: var(--brand-dark); text-decoration: underline; }
.editor-wrap .ql-editor blockquote { border-left: 3px solid var(--ink-20); padding-left: var(--sp-4); color: var(--ink-muted); margin: var(--sp-3) 0; }
.editor-wrap .ql-editor.ql-blank::before { color: var(--ink-muted); font-style: normal; left: var(--sp-5); }
.editor-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--ink-10); font-size: 13px; color: var(--ink-muted); }
.editor-bar .hint { margin-left: auto; }
@media (max-width: 640px) { .editor-bar .hint { display: none; } .editor-wrap .ql-editor { padding: var(--sp-3) var(--sp-4); } }

/* Floating selection toolbar */
.bubble {
  position: absolute; z-index: 20; display: flex; align-items: center; gap: 2px;
  padding: var(--sp-1); background: var(--ink); color: var(--on-ink);
  border-radius: var(--radius); box-shadow: 0 8px 24px var(--ink-20);
}
.bubble button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 var(--sp-2); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--on-ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.bubble button:hover { background: var(--on-ink-10); }
.bubble button[aria-pressed="true"] { color: var(--brand); background: var(--on-ink-10); }
.bubble .sep { width: 1px; height: 20px; background: var(--on-ink-24); margin: 0 2px; }
.bubble::after {
  content: ""; position: absolute; left: var(--arrow-x, 50%); bottom: -5px; width: 10px; height: 10px;
  background: var(--ink); transform: translateX(-50%) rotate(45deg);
}
.bubble.below::after { bottom: auto; top: -5px; }
@media (pointer: coarse) { .bubble button { min-width: 40px; height: 40px; } }

.link-pop {
  position: absolute; z-index: 21; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center;
  width: min(380px, calc(100% - 16px)); padding: var(--sp-2);
  background: var(--surface); border: 1px solid var(--ink-20); border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--ink-16);
}
.link-pop .input { flex: 1 1 200px; }
.link-pop .link-pop-error { flex-basis: 100%; font-size: 12px; color: var(--st-rejected-fg); }

.line-plus {
  position: absolute; z-index: 15; left: -14px; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--ink-20); background: var(--surface); color: var(--ink-muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.line-plus:hover { color: var(--ink); border-color: var(--ink-50); }
.line-menu {
  position: absolute; z-index: 16; display: flex; gap: var(--sp-1); padding: var(--sp-1);
  background: var(--surface); border: 1px solid var(--ink-20); border-radius: var(--radius); box-shadow: 0 8px 24px var(--ink-16);
}
@media (max-width: 640px) { .line-plus { left: 4px; } }

.autosave { font-size: 13px; color: var(--ink-muted); min-height: 20px; margin: var(--sp-3) 0 0; }
.problems { font-size: 13px; }
.problems ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-4); }
.image-preview { display: grid; gap: var(--sp-2); }

/* ---------- Category list (site page) ---------- */
.cat-list { border: 1px solid var(--ink-10); border-radius: var(--radius); margin-bottom: var(--sp-4); }
.cat-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--ink-8); }
.cat-row:last-child { border-bottom: 0; }
.cat-row:hover:not(.cat-head) { background: var(--ink-4); }
.cat-form { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 88px; gap: var(--sp-3); align-items: center; min-width: 0; }
.cat-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 88px 148px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-muted); height: 40px; }
.cat-actions { display: flex; gap: var(--sp-1); flex: 0 0 148px; justify-content: flex-end; }
.cat-slug { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-add { display: grid; grid-template-columns: minmax(0, 1fr) 88px auto; gap: var(--sp-2); max-width: 520px; }
@media (max-width: 640px) {
  .cat-head { display: none; }
  .cat-row { flex-wrap: wrap; padding: var(--sp-3); }
  .cat-form { grid-template-columns: minmax(0, 1fr) 72px; }
  .cat-slug { grid-column: 1 / -1; order: 3; }
  .cat-actions { flex: 1 1 100%; justify-content: flex-start; }
  .cat-add { grid-template-columns: minmax(0, 1fr) 72px; }
  .cat-add .btn { grid-column: 1 / -1; }
}

/* ---------- Modal (crop) ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: var(--ink-50); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal-box { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--ink-10); width: min(920px, 100%); max-height: 100%; overflow: auto; padding: var(--sp-5); }
.crop-area { max-height: 60vh; background: var(--bg); }
.crop-area img { display: block; max-width: 100%; }

/* ---------- Utilities ---------- */
.stack > * + * { margin-top: var(--sp-5); }
.stack > .card { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-4); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--ink-10); margin: var(--sp-4) 0; }

@media (max-width: 640px) {
  .side-panel .actions .btn, .site-card .actions .btn, .modal .actions .btn { flex: 1 1 auto; }
}
