:root {
  --ink: #111315;
  --ink-2: #2a2e33;
  --muted: #5b6168;
  --line: #d9dde1;
  --soft: #f3f5f2;
  --bg: #ffffff;
  --accent: #c5ff00;
  --accent-ink: #4d6600;
  --accent-soft: #f4ffd6;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --bad: #a3221b;
  --bad-soft: #fde8e6;
  --good: #1f6b3a;
  --good-soft: #e3f4e8;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef0f2;
    --ink-2: #c9cdd2;
    --muted: #9aa1a9;
    --line: #2f343a;
    --soft: #1a1d21;
    --bg: #111315;
    --accent-ink: #c5ff00;
    --accent-soft: #232b0e;
    --warn: #ffcf7a;
    --warn-soft: #2e2511;
    --bad: #ff8f87;
    --bad-soft: #321614;
    --good: #8fdca8;
    --good-soft: #13281b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 80px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: #111315; color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark { width: 10px; height: 22px; background: var(--accent); border-radius: 2px; }
.brand-sub { font-weight: 500; color: #b9bec4; margin-left: 6px; }
.who { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: #d6dade; }
.who button { color: #fff; border-color: #444a50; background: transparent; }
@media (max-width: 560px) { .brand-sub { display: none; } }

/* type */
h1 { font-size: 1.75rem; line-height: 1.2; margin: 8px 0 6px; }
h2 { font-size: 1.2rem; margin: 32px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 4px; }

/* buttons and inputs */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); }
.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.primary:hover { opacity: 0.9; }
.danger { color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label.field { display: block; margin: 0 0 18px; }
.field > .label { display: block; font-weight: 700; margin-bottom: 2px; }
.field > .help { display: block; color: var(--muted); font-size: 0.875rem; margin-bottom: 6px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly], textarea[readonly] { background: var(--soft); }

/* cards and lists */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg); }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none;
}
.row:hover { border-color: var(--muted); }
.row .meta { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { font-size: 0.875rem; font-weight: 500; padding: 6px 10px; border-radius: 999px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* badges */
.badge { font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.draft { background: var(--soft); color: var(--muted); }
.badge.ready { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--good-soft); color: var(--good); }
.note-dot { display: inline-block; width: 8px; height: 8px; background: var(--accent-ink); border-radius: 50%; margin-left: 6px; }

/* banners */
.banner { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 18px; border: 1px solid var(--line); }
.banner.example { background: var(--accent-soft); border-color: #9dcc00; }
.banner.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.banner.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.banner.notes { background: var(--soft); }
.banner ul { margin: 6px 0 0; padding-left: 20px; }

/* editor */
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.savestate { font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }
.savestate.bad { color: var(--bad); }
.back { text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.footer-actions { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

/* grids: a table on wide screens, stacked cards on phones */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th { text-align: left; font-size: 0.8rem; font-weight: 700; color: var(--muted); padding: 0 6px 6px; }
.grid td { padding: 4px; vertical-align: top; }
.grid td.rowlabel { font-weight: 700; font-size: 0.9rem; padding-top: 12px; width: 84px; white-space: nowrap; }
.grid textarea { min-height: 58px; font-size: 0.95rem; }
@media (max-width: 720px) {
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid thead { display: none; }
  .grid tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
  .grid td { padding: 4px 0; }
  .grid td.rowlabel { padding-top: 0; }
  .grid td[data-col]::before { content: attr(data-col); display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
}

/* login */
.login { max-width: 380px; margin: 48px auto; }
.error { color: var(--bad); margin: 8px 0 0; min-height: 1.4em; }

/* history */
.history li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 600; }

/* spacing utilities (no inline styles: the CSP blocks them) */
.mt4 { margin: 4px 0 0; }
.mt8 { margin: 8px 0 0; }
.mt12 { margin-top: 12px; }
.mt24 { margin-top: 24px; }
.pre { white-space: pre-wrap; }
