:root {
  --paper: #edeff2;
  --ink: #1e2430;
  --quiet: #6f7a8d;
  --ghost: #a3acbb;
  --rule: #d6dae1;
  --blue: #2e44d6;
  --rose: #cf4f78;
  --font: "Recursive", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171c27;
    --ink: #e4e8f0;
    --quiet: #8e98ab;
    --ghost: #556079;
    --rule: #2a3142;
    --blue: #8f9dff;
    --rose: #f08aa6;
  }
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body {
  margin: 0;
  font-family: var(--font);
  font-variation-settings: "CASL" 0.2;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
}

.top, .stage, .foot { width: min(1180px, 100% - 3rem); margin-inline: auto; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 1.5rem 0 0; gap: 1rem; }
.mark {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  font-variation-settings: "CASL" 1;
  letter-spacing: -0.01em;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 560;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--quiet); }
.btn.quiet { color: var(--quiet); }
.btn:focus-visible, .btn:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(2rem, 6vw, 6rem);
  padding: clamp(2rem, 7vh, 5rem) 0 2rem;
  align-items: start;
}

/* writing surface: a textarea over a mirror that paints the ghost letters */
.field { position: relative; max-width: 40em; }
.mirror, textarea {
  font: inherit;
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
  font-variation-settings: "CASL" 0.35;
  font-weight: 420;
  line-height: 1.65;
  letter-spacing: 0;
  padding: 0;
  margin: 0;
  border: 0;
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
}
.mirror { position: absolute; inset: 0; color: transparent; pointer-events: none; }
.mirror .g { color: var(--ghost); }
.mirror .g.first { color: var(--blue); opacity: 0.55; }
textarea {
  position: relative;
  display: block;
  background: transparent;
  color: var(--ink);
  caret-color: var(--blue);
  resize: none;
  outline: none;
  min-height: 7em;
  overflow: hidden;
}
textarea::placeholder { color: var(--quiet); opacity: 1; }

.trail {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-top: 2.5rem;
  max-width: 40em;
  overflow: hidden;
}
.trail i { flex: 0 0 3px; height: 14px; border-radius: 2px; background: var(--blue); }
.trail i.m { height: 4px; background: var(--rose); }
.hint { margin: 0.9rem 0 0; color: var(--quiet); font-size: 0.875rem; }
kbd {
  font: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 0.35em;
}

/* the oracle: one big letter whose weight and shape follow the model's confidence */
.oracle { position: sticky; top: 2rem; }
.glyph-wrap { height: 15rem; display: grid; align-content: end; }
.glyph {
  font-size: 12rem;
  line-height: 0.9;
  color: var(--blue);
  font-variation-settings: "wght" 400, "CASL" 0.5;
  transition: font-variation-settings 140ms ease-out, color 140ms;
  min-height: 1em;
  white-space: pre;
}
.glyph.word { font-size: 4.5rem; line-height: 1.6; }
.glyph-label { color: var(--quiet); font-size: 0.875rem; margin-top: 0.75rem; min-height: 1.5em; font-variant-numeric: tabular-nums; }

.runners { list-style: none; margin: 1.75rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.runners li { display: grid; grid-template-columns: 3.5rem 1fr 2.75rem; align-items: center; gap: 0.6rem; font-size: 0.9375rem; }
.runners .ch { font-weight: 700; white-space: pre; }
.runners .ch.sp { font-weight: 450; color: var(--quiet); font-size: 0.8125rem; }
.runners .bar { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.runners .bar b { display: block; height: 100%; background: var(--ink); opacity: 0.75; border-radius: 3px; }
.runners .pc { text-align: right; color: var(--quiet); font-variant-numeric: tabular-nums; font-size: 0.8125rem; }

.stats { margin: 2.5rem 0 0; display: grid; gap: 0.55rem; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.stats dt { color: var(--quiet); font-size: 0.875rem; }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats .lead { padding-bottom: 0.6rem; margin-bottom: 0.2rem; border-bottom: 1px solid var(--rule); }
.stats .lead dt { color: var(--ink); font-size: 1rem; }
.stats .lead dd { font-size: 2rem; font-weight: 800; font-variation-settings: "CASL" 0.6; }

.foot { padding: 2rem 0 2.5rem; color: var(--quiet); font-size: 0.8125rem; max-width: 1180px; }
.foot p { max-width: 60ch; margin: 0; }
.foot a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 860px) {
  .top, .stage, .foot { width: calc(100% - 2.5rem); }
  .stage { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 1.5rem; }
  .oracle {
    order: -1; position: static;
    display: grid; grid-template-columns: auto 1fr; gap: 0 1.5rem; align-items: end;
  }
  .glyph-wrap { height: 7.5rem; }
  .glyph { font-size: 6.5rem; }
  .glyph.word { font-size: 2.5rem; }
  .runners { margin: 0; }
  .runners li { grid-template-columns: 3rem 1fr 2.5rem; }
  .stats { grid-column: 1 / -1; margin-top: 1.25rem; grid-template-columns: repeat(4, auto); column-gap: 1rem; justify-content: space-between; }
  .stats .lead { grid-column: 1 / -1; }
  .stats div:not(.lead) { flex-direction: column-reverse; gap: 0; }
  .stats div:not(.lead) dt { font-size: 0.75rem; }
  .stats div:not(.lead) dd { font-size: 0.9375rem; }
  .btn { font-size: 0.8125rem; padding: 0.35rem 0.75rem; }
  .actions { flex-wrap: nowrap; }
  textarea { min-height: 5em; }
}

@media (prefers-reduced-motion: reduce) {
  .glyph { transition: none; }
}
