:root {
  --paper: #ece7d9;
  --face: #f8f4e8;
  --ink: #1c1b18;
  --muted: #7a745f;
  --rule: #cfc8b3;
  --war: #b3261e;
  --peace: #2f6f6a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14130f;
    --face: #211f18;
    --ink: #ece7d8;
    --muted: #918b77;
    --rule: #38352b;
    --war: #e5534b;
    --peace: #63b8ac;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 Georgia, 'Times New Roman', serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

section { margin-bottom: 44px; }

h2 {
  margin: 0;
  font: 600 12px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

a { color: inherit; text-underline-offset: 3px; }

/* ---- meter ---- */

.panel { text-align: center; }

#meter {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto 20px;
  overflow: visible;
}

.m-face { fill: var(--face); stroke: var(--ink); stroke-width: 2; }
.m-scale { fill: none; stroke: var(--ink); stroke-width: 2; }
.m-red { fill: none; stroke: var(--war); stroke-width: 8; }
.m-tick { stroke: var(--ink); stroke-width: 1.5; }
.m-major { stroke-width: 3; }
.m-word {
  fill: var(--ink);
  font: 700 15px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.18em;
}
.m-word-war { fill: var(--war); }
.m-needle { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.m-plate { fill: var(--ink); }
.m-maker {
  fill: var(--face);
  font: 600 11px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.4em;
}

.m-swing, .m-tremble { transform-box: view-box; }
/* Overshoot then settle, like a needle with mass. */
.m-swing { transition: transform 1.6s cubic-bezier(0.3, 1.55, 0.45, 1); }
.m-tremble { animation: tremble 2.7s ease-in-out infinite; }

@keyframes tremble {
  0%, 100% { transform: rotate(-0.35deg); }
  37% { transform: rotate(0.3deg); }
  61% { transform: rotate(-0.1deg); }
  83% { transform: rotate(0.4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .m-swing { transition: none; }
  .m-tremble { animation: none; }
}

.verdict { margin: 0; font-size: clamp(26px, 6vw, 38px); line-height: 1.15; }
.when, .pinned { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.pinned button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- make your own needle ---- */

.maker {
  margin: 28px auto 0;
  color: var(--muted);
  font: 12px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.maker label { display: block; margin-bottom: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.maker-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.maker input {
  width: 9.5em;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--face);
  color: var(--ink);
  font: 16px/1.2 Georgia, 'Times New Roman', serif; /* 16px: iOS zooms the page on anything smaller */
  text-align: center;
}
.maker input:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: transparent; }
.maker button {
  padding: 9px 12px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}
.maker-note { margin: 10px 0 0; color: var(--war); }
.maker a { display: inline-block; margin-top: 14px; }

/* ---- section headers + chips ---- */

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

.chips { display: flex; gap: 4px; }
.chips button {
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: 12px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  cursor: pointer;
}
.chips button:hover { color: var(--ink); }
.chips button[aria-pressed='true'] { border-color: var(--ink); color: var(--ink); }

/* ---- history ---- */

.chart { position: relative; }
.chart svg { display: block; cursor: pointer; touch-action: pan-y; }
.c-grid { stroke: var(--rule); stroke-width: 1; }
.c-mid { stroke-dasharray: 3 5; }
.c-label { fill: var(--muted); font: 11px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.c-line { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; }
.c-dot { fill: var(--ink); }
.c-picked { fill: var(--paper); stroke: var(--war); stroke-width: 2.5; }
.c-cursor { stroke: var(--muted); stroke-width: 1; }

.tip {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font: 11px/1.2 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: nowrap;
  pointer-events: none;
}

/* ---- posts ---- */

.posts { margin: 0; padding: 0; list-style: none; }
.posts li {
  display: grid;
  grid-template-columns: 64px 3.2em 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}

.gauge {
  position: relative;
  align-self: start;
  margin-top: 11px; /* the first text line's middle */
  height: 2px;
  background: linear-gradient(to right, var(--rule) 0 49%, var(--muted) 49% 51%, var(--rule) 51% 100%);
}
.mark {
  position: absolute;
  top: -5px;
  width: 4px;
  height: 12px;
  margin-left: -2px;
  border-radius: 1px;
  background: var(--peace);
}
.mark-right { background: var(--war); }

.pct {
  color: var(--muted);
  font: 12px/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  text-align: right;
}
.text a { text-decoration: none; overflow-wrap: anywhere; }
.text a:hover { text-decoration: underline; }
.sub { color: var(--muted); font-size: 13px; white-space: nowrap; }

footer { color: var(--muted); font-size: 14px; }
footer p { margin: 0 0 12px; }
