/* Acquired Taste. The chrome stays quiet so the snippets get the attention.
   Spacing uses 4px steps. One accent: the redline pink, used only for marks. */

:root {
  --bg: #F5F5F4;
  --surface: #FFFFFF;
  --stage: #EAEAE8;
  --text: #151515;
  --muted: #5C5C5A;
  --line: #DEDEDB;
  --ink: #151515;
  --on-ink: #FFFFFF;
  --mark: #E0245E;
  --mark-soft: rgba(224, 36, 94, 0.08);
  --better: #136C40;
  --better-bg: #E2F3E9;
  --pick-bg: #ECECEA;
  --font: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111;
    --surface: #1A1A1A;
    --stage: #232323;
    --text: #F1F1F0;
    --muted: #A4A4A1;
    --line: #2F2F2E;
    --ink: #F1F1F0;
    --on-ink: #111111;
    --mark: #FF4D86;
    --mark-soft: rgba(255, 77, 134, 0.10);
    --better: #5BD195;
    --better-bg: #12301F;
    --pick-bg: #2A2A29;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --surface: #1A1A1A; --stage: #232323; --text: #F1F1F0; --muted: #A4A4A1;
  --line: #2F2F2E; --ink: #F1F1F0; --on-ink: #111111; --mark: #FF4D86; --mark-soft: rgba(255, 77, 134, 0.10);
  --better: #5BD195; --better-bg: #12301F; --pick-bg: #2A2A29; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/24px var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.wordmark {
  font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.wordmark span { color: var(--mark); }
.progress { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.progress-bar { width: 120px; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .3s ease; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 99px; border: 1px solid transparent;
  font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .3; cursor: not-allowed; }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--text); }
.btn-secondary:hover { background: var(--pick-bg); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 99px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--pick-bg); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; }

/* Today */
.today { padding-top: 64px; padding-bottom: 96px; }
.hero h1 { font-size: 48px; line-height: 52px; letter-spacing: -0.03em; font-weight: 600; margin: 0; }
.hero p { margin: 8px 0 0; font-size: 18px; line-height: 28px; color: var(--muted); max-width: 30em; }
.today-card {
  margin-top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; max-width: 480px;
}
.today-card .date { font-size: 14px; color: var(--muted); }
.today-card .big { font-size: 24px; line-height: 32px; font-weight: 600; margin-top: 4px; }
.today-card .meta { display: flex; gap: 16px; margin-top: 4px; color: var(--muted); font-size: 14px; }
.today-card .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.today-card .note { margin-top: 12px; font-size: 14px; color: var(--muted); }
.streak { color: var(--text); font-weight: 500; }
.how-link { margin-top: 16px; }
.how { margin-top: 80px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.how h2 { grid-column: 1 / -1; font-size: 14px; font-weight: 500; color: var(--muted); margin: 0 0 -8px; }
.how li { list-style: none; }
.how ol { display: contents; }
.how .n { font-family: var(--mono); font-size: 12px; color: var(--mark); }
.how p { margin: 4px 0 0; font-size: 15px; line-height: 22px; }

/* Pair */
.screen { padding-top: 24px; padding-bottom: 120px; }
.prompt h1 { font-size: 28px; line-height: 36px; letter-spacing: -0.02em; font-weight: 600; margin: 0; }
.prompt p { margin: 0; color: var(--muted); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; align-items: stretch; }
.side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.side-head { display: flex; align-items: center; gap: 8px; height: 24px; }
.side-letter { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.tag-pick { background: var(--pick-bg); color: var(--text); }
.tag-better { background: var(--better-bg); color: var(--better); }
.tag-better::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; margin-right: 6px; }

.frame {
  position: relative; flex: 1; min-height: 300px; background: var(--stage); border-radius: 16px;
  display: flex; align-items: center; justify-content: center; padding: 32px 24px; overflow: hidden;
  border: 2px solid transparent; transition: border-color .15s ease, filter .2s ease;
}
.frame.pickable { cursor: pointer; }
.frame.pickable:hover { border-color: var(--line); }
.frame.selected, .frame.selected:hover { border-color: var(--ink); }
.frame.gray .host { filter: grayscale(1); }
.host { position: relative; flex: none; }
.marks { position: absolute; inset: 0; pointer-events: none; }

/* Marks: drawn on top of the snippets, crit style */
.m-line { position: absolute; background: var(--mark); }
.m-line.v { width: 1px; }
.m-line.h { height: 1px; }
.m-line.v::before, .m-line.v::after { content: ""; position: absolute; left: -3px; width: 7px; height: 1px; background: var(--mark); }
.m-line.v::before { top: 0; } .m-line.v::after { bottom: 0; }
.m-line.h::before, .m-line.h::after { content: ""; position: absolute; top: -3px; height: 7px; width: 1px; background: var(--mark); }
.m-line.h::before { left: 0; } .m-line.h::after { right: 0; }
.m-dash { position: absolute; border-left: 1px dashed var(--mark); }
.m-box { position: absolute; border: 1px dashed var(--mark); border-radius: 4px; background: var(--mark-soft); }
.m-badge {
  position: absolute; white-space: nowrap; background: var(--mark); color: #fff;
  font: 500 11px/16px var(--mono); padding: 2px 6px; border-radius: 4px;
}
.m-badge.pass::after { content: " ✓"; }
.m-badge.fail { background: #fff; color: var(--mark); box-shadow: inset 0 0 0 1px var(--mark); }
.m-badge.fail::after { content: " ✕"; }
.hide-marks .marks { display: none; }

/* Reason */
.reason { margin-top: 24px; max-width: 560px; }
.reason label { display: block; font-size: 14px; font-weight: 500; }
.reason input {
  margin-top: 4px; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 0 16px; font: inherit; font-size: 15px;
}
.reason input:focus { outline: none; border-color: var(--ink); }
.reason .hint { margin-top: 4px; font-size: 13px; line-height: 20px; color: var(--muted); }

.bottom-bar { display: flex; align-items: center; gap: 16px; margin-top: 24px; }

/* Reveal */
.result-line { font-size: 28px; line-height: 36px; letter-spacing: -0.02em; font-weight: 600; margin: 0; }
.controls { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 16px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 32px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 99px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(12px); background: var(--on-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }

.principle {
  margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px 40px;
}
.principle .group { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.principle h2 { font-size: 22px; line-height: 28px; margin: 4px 0 0; letter-spacing: -0.01em; }
.principle .rule { margin: 8px 0 0; font-size: 16px; line-height: 24px; }
.principle .why { margin: 8px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.principle .snob { margin: 0; font-size: 18px; line-height: 26px; font-style: italic; border-left: 2px solid var(--mark); padding-left: 16px; }
.principle .said { margin: 16px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.principle .said q { color: var(--text); }
.principle .from { margin: 16px 0 0; font-size: 13px; line-height: 20px; color: var(--muted); }

/* Results */
.score { font-size: 80px; line-height: 80px; font-weight: 600; letter-spacing: -0.04em; margin: 0; }
.score-line { font-size: 20px; line-height: 28px; margin: 8px 0 0; }
.squares { display: flex; gap: 6px; margin-top: 24px; }
.sq { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--ink); }
.sq.right { background: var(--ink); }
.results-list { margin-top: 32px; border-top: 1px solid var(--line); max-width: 640px; padding: 0; }
.results-list li { list-style: none; }
.results-list button {
  width: 100%; display: grid; grid-template-columns: 32px 1fr auto auto; gap: 12px; align-items: center;
  padding: 12px 8px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer;
}
.results-list button:hover { background: var(--pick-bg); }
.results-list .num { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.results-list .grp { font-size: 13px; color: var(--muted); }
.results-list .res { font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; min-width: 64px; justify-content: flex-end; }
.res .dot { width: 8px; height: 8px; border-radius: 99px; border: 2px solid var(--ink); }
.res.right .dot { background: var(--ink); }

/* Dialog */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialog { background: var(--surface); border-radius: 20px; padding: 24px; width: 100%; max-width: 640px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 20px; line-height: 28px; }
.dialog img { display: block; width: 100%; height: auto; border-radius: 12px; margin-top: 16px; border: 1px solid var(--line); }
.dialog .actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* Toast: top centre, 24px from the top */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 99px;
  padding: 8px 16px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.08); transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Phone */
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .hero h1 { font-size: 36px; line-height: 40px; }
  .today { padding-top: 40px; }
  .how { grid-template-columns: 1fr; gap: 16px; margin-top: 48px; }
  .prompt h1, .result-line { font-size: 24px; line-height: 32px; }
  .pair { grid-template-columns: 1fr; }
  .frame { min-height: 220px; padding: 24px 16px; }
  .principle { grid-template-columns: 1fr; padding: 20px; }
  .progress-bar { width: 64px; }
  .bottom-bar.sticky {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line); z-index: 5;
  }
  .bottom-bar.sticky .btn-primary { flex: 1; }
  .score { font-size: 64px; line-height: 64px; }
  .results-list button { grid-template-columns: 32px 1fr auto; }
  .results-list .grp { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
