:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1b2129;
  --raised: #222a34;
  --line: #29323d;
  --line-strong: #364150;
  --text: #e7eaee;
  --muted: #a1abb8;
  --faint: #828d9b;
  --accent: #4c8dff;
  --accent-strong: #6ea2ff;
  --accent-ink: #08142b;
  --ok: #3fb67a;
  --ok-soft: rgb(63 182 122 / 0.14);
  --bad: #f06363;
  --bad-soft: rgb(240 99 99 / 0.14);
  --warn: #e6a740;
  --warn-soft: rgb(230 167 64 / 0.14);
  --info-soft: rgb(76 141 255 / 0.14);
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.35), 0 1px 2px rgb(0 0 0 / 0.4);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-color: var(--line-strong) var(--bg); }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgb(76 141 255 / 0.38); color: #fff; }
input, textarea, select { caret-color: var(--accent); }
a { color: var(--accent-strong); text-underline-offset: 3px; }
a:hover { color: #9cc0ff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.375rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 650; }
h3 { font-size: 0.875rem; font-weight: 650; color: var(--muted); }
p { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, table { font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: 0.8125rem; }

/* ---- Shell -------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; }
.brand svg { color: var(--accent); width: 22px; height: 22px; stroke-width: 2.25; }
.brand small { display: block; font-weight: 400; color: var(--faint); font-size: 0.75rem; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--raised); color: var(--text); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 7px;
  border-radius: 11px; background: var(--raised); color: var(--text);
  font-size: 0.75rem; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.nav a[aria-current="page"] .count { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.nav .count.alert { background: var(--warn); color: #1d1405; font-weight: 650; }
.nav .spacer { flex: 1; }
.nav .who { padding: 10px; border-top: 1px solid var(--line); margin-top: 8px; color: var(--muted); font-size: 0.8125rem; }
.nav .who strong { display: block; color: var(--text); font-weight: 600; }

main { padding: 28px 36px 64px; min-width: 0; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 0.8125rem; margin-bottom: 10px; }
.crumb:hover { color: var(--text); }
.crumb svg { width: 15px; height: 15px; }

/* ---- Controls ----------------------------------------------------------- */

.button, button.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px;
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), transform 150ms var(--ease);
}
.button:hover { background: #2a3440; border-color: #46536a; color: var(--text); }
.button:active { transform: translateY(1px); }
.button:disabled, .button[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.button[aria-busy="true"]::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.approve { background: var(--ok); border-color: var(--ok); color: #04160d; }
.button.approve:hover { background: #52c98b; border-color: #52c98b; }
.button.danger { background: transparent; border-color: rgb(240 99 99 / 0.55); color: #ff8f8f; }
.button.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: #ffb0b0; }
.button.danger.solid { background: var(--bad); border-color: var(--bad); color: #1f0505; }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.ghost:hover { background: var(--panel-2); color: var(--text); }
.button.small { height: 28px; padding: 0 10px; font-size: 0.8125rem; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--panel-2); color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: grid; gap: 6px; font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--faint); }
input[type="text"], input[type="email"], input[type="search"], input[type="url"], input[type="number"], textarea, select {
  width: 100%; height: 36px; padding: 0 11px;
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1abb8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover, select:hover { border-color: #46536a; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(76 141 255 / 0.25); }
input[aria-invalid="true"] { border-color: var(--bad); }
.code-input { height: 52px; font: 600 1.5rem/1 var(--mono); letter-spacing: 0.3em; text-align: center; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="search"] { max-width: 340px; }
.toolbar select { width: auto; min-width: 150px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; }
.segmented button { height: 28px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--text); }

/* ---- Surfaces ----------------------------------------------------------- */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel > header .actions { margin-left: auto; display: flex; gap: 6px; }
.panel .body { padding: 16px; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.8125rem; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; color: #d6dbe1; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; font-size: 0.8125rem; }
dl.facts dt { color: var(--faint); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  background: var(--raised); color: var(--muted);
}
.chip.warn { background: var(--warn-soft); color: #f2c071; }
.chip.bad { background: var(--bad-soft); color: #ff9c9c; }
.chip.ok { background: var(--ok-soft); color: #74d6a2; }
.chip.info { background: var(--info-soft); color: #9cc0ff; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.live { color: #5fcf94; }
.status.in_review, .status.pending { color: #8db4ff; }
.status.hidden, .status.denied { color: #ecb35a; }
.status.removed, .status.rejected { color: #ff8585; }
.status.unlisted, .status.deleted, .status.superseded, .status.withdrawn, .status.approved { color: var(--faint); }
.status.approved { color: #5fcf94; }

/* ---- Tables and lists --------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
table.data th { text-align: left; font-weight: 600; color: var(--faint); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.link { cursor: pointer; transition: background 120ms var(--ease); }
table.data tbody tr.link:hover { background: var(--panel-2); }
a.cell-title { color: var(--text); text-decoration: none; }
tr.link:hover a.cell-title { text-decoration: underline; }
table.data td.right, table.data th.right { text-align: right; }
.table-wrap { overflow-x: auto; }

.queue { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.queue a {
  display: grid; grid-template-columns: 112px 1fr auto; gap: 16px; align-items: center;
  padding: 12px 16px 12px 12px; background: var(--panel); color: inherit; text-decoration: none;
  transition: background 120ms var(--ease);
}
.queue a:hover { background: var(--panel-2); }
.queue .thumb { width: 112px; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background: var(--raised) center / cover no-repeat; }
.queue .title { font-weight: 600; font-size: 0.9375rem; }
.queue .meta { color: var(--muted); font-size: 0.8125rem; margin-top: 2px; }
.queue .chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.queue .when { color: var(--faint); font-size: 0.8125rem; text-align: right; white-space: nowrap; }

.empty { padding: 44px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 48ch; margin: 0 auto; }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Review layout ------------------------------------------------------ */

.review { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.review aside { position: sticky; top: 20px; display: grid; gap: 16px; }
.gallery { display: grid; gap: 8px; }
.gallery .main {
  display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: var(--radius);
  background: var(--raised) center / contain no-repeat; cursor: zoom-in;
}
.gallery .strip { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery .strip button {
  width: 96px; aspect-ratio: 16 / 9; padding: 0; border-radius: var(--radius-sm);
  border: 2px solid transparent; background: var(--raised) center / cover no-repeat; cursor: pointer;
}
.gallery .strip button[aria-pressed="true"] { border-color: var(--accent); }
.diff { display: grid; gap: 10px; }
.diff .was { color: var(--faint); text-decoration: line-through; text-decoration-color: rgb(240 99 99 / 0.6); }
.change-new { color: #74d6a2; }
.change-changed { color: #f2c071; }
.change-unchanged { color: var(--faint); }

.decision { border-color: var(--line-strong); box-shadow: var(--shadow); }
.decision .body { display: grid; gap: 12px; }
.decision .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reveal { display: grid; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); animation: reveal 200ms var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }

.code-box { display: grid; gap: 8px; }
.code-box output { display: block; max-height: 86px; overflow: hidden; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); color: var(--faint); font: 0.75rem/1.45 var(--mono); word-break: break-all; mask-image: linear-gradient(#000 55%, transparent); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: #c3d8ff; font-size: 0.8125rem; }
.notice.warn { background: var(--warn-soft); color: #f5d199; }
.notice.bad { background: var(--bad-soft); color: #ffc1c1; }
.notice svg { margin-top: 1px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---- Sign-in ------------------------------------------------------------ */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #17202c 0%, var(--bg) 60%); }
.signin .card { width: min(400px, 100%); padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.signin .card h1 { font-size: 1.25rem; }
.signin .card p { color: var(--muted); }
.signin .brand { padding: 0; }
.secret { display: block; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); font: 600 1rem/1.6 var(--mono); letter-spacing: 0.08em; text-align: center; word-spacing: 0.3em; user-select: all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); font: 600 0.875rem/1.6 var(--mono); text-align: center; }
.error-text { color: #ff9c9c; font-size: 0.8125rem; }

/* ---- Overlays ----------------------------------------------------------- */

#lightbox { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 94vh; }
#lightbox::backdrop { background: rgb(5 7 10 / 0.86); }
#lightbox img { display: block; max-width: 96vw; max-height: 94vh; border-radius: var(--radius); }
#lightbox form { position: fixed; top: 14px; right: 14px; }
#lightbox .icon-button { background: rgb(21 26 33 / 0.9); color: var(--text); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  padding: 10px 16px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: var(--bad); color: #ffb0b0; }

@media (max-width: 1100px) {
  .review { grid-template-columns: 1fr; }
  .review aside { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav .brand, .nav .spacer { display: none; }
  .nav .who { display: none; }
  main { padding: 20px 16px 48px; }
  .queue a { grid-template-columns: 80px 1fr; }
  .queue .thumb { width: 80px; }
  .queue .when { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
