/* Shared design tokens and components. site.css (light pages) and console.css (case console)
   only set their own palette and layout on top of this. */
:root {
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  /* light palette (default) */
  --bg: #faf8f4; --surface: #ffffff; --ink: #1c2229; --muted: #5d6773; --line: #e6e1d8;
  --accent: #0b6b6b; --accent-ink: #ffffff; --accent-soft: #e3f1ef;
  --good: #1f7a45; --bad: #b3261e; --warn: #9a5b00;
  --easy-bg: #e3f1e6; --easy: #1f6b34; --mid-bg: #fbefd9; --mid: #8a5600; --hard-bg: #f6e1e1; --hard: #9b2c2c;
  /* levels: tier / case difficulty, shown as signal pips */
  --l1: #1f7fb0; --l2: #b7791f; --l3: #c2413b; --pro: #6a4bd6; --pro-soft: #efeaff; --pro-ink: #3f2a99;
  --shadow: 0 8px 30px rgba(20, 30, 40, .12);
  color-scheme: light;
}
/* Dark palette. js/theme.js sets data-theme from the user's choice (system, light or dark).
   The media query covers the moment before it runs, and browsers without script. */
:root[data-theme="dark"] {
  --bg: #12161b; --surface: #181e25; --ink: #e8ecf0; --muted: #98a3af; --line: #29313b;
  --accent: #5fc9b8; --accent-ink: #0b1a18; --accent-soft: #17302d;
  --good: #6fd197; --bad: #f08a84; --warn: #e3b05b;
  --easy-bg: #183024; --easy: #7fd69a; --mid-bg: #33290f; --mid: #e8b861; --hard-bg: #3a1c1c; --hard: #f09a9a;
  --l1: #5fb8e6; --l2: #e6b158; --l3: #f07a72; --pro: #a58cff; --pro-soft: #241d45; --pro-ink: #cdbfff;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #12161b; --surface: #181e25; --ink: #e8ecf0; --muted: #98a3af; --line: #29313b;
    --accent: #5fc9b8; --accent-ink: #0b1a18; --accent-soft: #17302d;
    --good: #6fd197; --bad: #f08a84; --warn: #e3b05b;
    --l1: #5fb8e6; --l2: #e6b158; --l3: #f07a72; --pro: #a58cff; --pro-soft: #241d45; --pro-ink: #cdbfff;
    --shadow: 0 8px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--ink); }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* text */
.meta { color: var(--muted); font-size: .84rem; }
.eyebrow, .kicker { color: var(--accent); font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; padding: 10px 18px; border-radius: 8px; font-weight: 600; text-decoration: none; transition: filter .12s, transform .12s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.done { background: var(--good); }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; font-size: inherit; }

/* small pieces */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.Beginner { background: var(--l1); } .dot.Intermediate { background: var(--l2); } .dot.Advanced { background: var(--l3); }
.pill { font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok, .pill.closed { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.active { color: var(--warn); border-color: currentColor; }
/* level chip: three signal pips + a mono label (Tier 1 / Beginner ...) */
.lvl { display: inline-flex; align-items: center; gap: 6px; font: 600 .72rem/1 var(--mono); letter-spacing: .02em; white-space: nowrap;
  color: var(--lc); padding: 3px 7px 3px 6px; border: 1px solid color-mix(in srgb, var(--lc) 40%, transparent); border-radius: 4px; }
.lvl.l1 { --lc: var(--l1); } .lvl.l2 { --lc: var(--l2); } .lvl.l3 { --lc: var(--l3); }
.pips { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.pips i { width: 3px; border-radius: 1px; background: color-mix(in srgb, var(--lc) 25%, transparent); }
.pips i:nth-child(1) { height: 4px; } .pips i:nth-child(2) { height: 7px; } .pips i:nth-child(3) { height: 10px; }
.pips i.on { background: var(--lc); }
.did { font: 600 .74rem/1 var(--mono); color: var(--muted); margin-right: 8px; letter-spacing: .02em; }
.owner-tag { background: var(--ink) !important; color: var(--bg) !important; border-color: var(--ink) !important; }
.pro-tag { font: 700 .64rem/1.4 var(--mono); letter-spacing: .08em; color: var(--pro-ink); background: var(--pro-soft); border: 1px solid color-mix(in srgb, var(--pro) 45%, transparent); padding: 0 5px; border-radius: 3px; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: .76rem; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; }
.chip.off { opacity: .55; border-style: dashed; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s ease; }
.empty { color: var(--muted); padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 0 0 10px; } .empty p:last-child { margin: 0; }
.empty.error { border-color: var(--bad); color: var(--ink); }

/* forms */
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: .86rem; font-weight: 600; }
.field input { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field small { color: var(--muted); font-size: .8rem; }
.pw { position: relative; }
.pw input { padding-right: 64px; }
.reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: .8rem; font-weight: 600; padding: 6px 8px; border-radius: 6px; }
.reveal:hover { color: var(--ink); }
.form-err { color: var(--bad); font-size: .88rem; min-height: 1.3em; margin: 0 0 10px; }

/* loading */
.skeleton { padding: 34px 40px; max-width: 900px; }
.sk { height: 14px; border-radius: 6px; margin: 12px 0; background: linear-gradient(90deg, var(--line) 25%, var(--surface) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.sk-title { height: 30px; width: 45%; margin-bottom: 22px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; max-width: 360px; animation: toast-in .2s ease; transition: opacity .3s, transform .3s; }
.toast.ok::before { content: "✓  "; color: var(--good); font-weight: 700; }
.toast.error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
