:root {
  color-scheme: light;
  --page: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1d1b18;
  --ink-2: #57524a;
  --muted: #8c867b;
  --line: rgba(29, 27, 24, 0.13);
  --line-strong: rgba(29, 27, 24, 0.3);
  --accent: #b4473a;
  --good: #2f8a4f;
  --over: #c0392b;
  --under: #a0761a;
  --button: #1d1b18;
  --button-ink: #fffdf8;
  --r: 4px;
  --sans: "Petrov Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: Fraunces, Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121110;
    --surface: #1c1a18;
    --ink: #f1ede6;
    --ink-2: #c6bfb3;
    --muted: #8c867b;
    --line: rgba(255, 250, 240, 0.11);
    --line-strong: rgba(255, 250, 240, 0.26);
    --accent: #e0705f;
    --good: #4fbf76;
    --over: #ef6b5b;
    --under: #d9a63a;
    --button: #f1ede6;
    --button-ink: #121110;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 380 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }

header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
h1 { font: 500 22px/1.1 var(--serif); letter-spacing: -0.01em; margin: 0; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.step { color: var(--ink-2); text-decoration: none; padding: 0 6px; font-size: 15px; }
.step:hover { color: var(--accent); }
.to-today { margin-left: 4px; padding: 2px 9px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 12px; }
.to-today:hover { color: var(--accent); border-color: var(--accent); }
.icon {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2);
}

.word { text-align: center; margin: 0 0 30px; }
.label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.the-word {
  font: italic 400 clamp(40px, 12vw, 56px)/1.05 var(--serif);
  margin: 6px 0 0; color: var(--accent);
}

.poem {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 18px 14px;
}
.line { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 12px; padding-top: 14px; }
.line input {
  width: 100%; min-width: 0;
  font: 400 20px/1.4 var(--serif);
  color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--line-strong);
  padding: 4px 0; border-radius: 0;
}
.line input::placeholder { color: var(--muted); opacity: 0.6; font-style: italic; }
.line input:focus { outline: none; border-bottom-color: var(--ink); }
.count {
  font: 500 13px/1 var(--sans); font-variant-numeric: tabular-nums;
  color: var(--muted); padding-bottom: 9px; min-width: 3.2em; text-align: right;
}
.count.ok { color: var(--good); }
.count.over { color: var(--over); }
.count.under { color: var(--under); }
.words { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 10px; min-height: 22px; padding-top: 5px; }
.chip {
  font: 400 12.5px/1.5 var(--sans); color: var(--ink-2);
  background: none; border: 0; padding: 0;
}
.chip sub { font-size: 10px; color: var(--muted); margin-left: 1px; vertical-align: -0.15em; }
.chip.guess .wt, .guess-eg { text-decoration: underline dashed var(--under); text-underline-offset: 3px; }
.chip.guess:hover .wt { color: var(--ink); }
.chip.adjusted sub { color: var(--under); font-weight: 600; }

.verdict { min-height: 24px; margin: 14px 2px 0; color: var(--ink-2); font-size: 14px; }
.verdict p { margin: 0 0 2px; }
.verdict.good b { color: var(--good); font-weight: 600; }
.adj { color: var(--under); font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.primary, .secondary {
  border-radius: var(--r); padding: 10px 18px; font-weight: 500;
  border: 1px solid var(--button);
}
.primary { background: var(--button); color: var(--button-ink); }
.secondary { background: transparent; color: var(--ink); }
.primary:disabled, .secondary:disabled { opacity: 0.35; cursor: default; }
.link { color: var(--ink-2); font-size: 14px; text-underline-offset: 3px; }
.saved { color: var(--good); font-size: 13.5px; margin: 10px 2px 0; }

.others { margin-top: 34px; display: grid; gap: 14px; }
.other { border-top: 1px solid var(--line); padding-top: 14px; }
.other h2 { font: 500 11px/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.haiku { font: 400 19px/1.55 var(--serif); margin: 0; }
.other .adj { margin: 6px 0 0; }

.error { color: var(--over); margin-top: 16px; }

dialog {
  max-width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); padding: 22px 22px 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { font: 500 20px/1.2 var(--serif); margin: 0 0 12px; }
dialog p { margin: 0 0 10px; color: var(--ink-2); }
dialog .primary { margin-top: 6px; width: 100%; }
