:root {
  --bg: #f6f4ef; --panel: #fff; --ink: #1a1a1a; --muted: #6a6a6a;
  --line: #dcd7cc; --accent: #c25a1a; --ok: #1d8f4a; --danger: #c81a1a;
  font-family: 'Iowan Old Style', 'Palatino', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }
button {
  font: 14px -apple-system, system-ui, sans-serif; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 11px; cursor: pointer; min-width: 38px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.35; cursor: default; }
button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
button.danger { color: var(--danger); }
kbd {
  font: 11px 'SF Mono', Menlo, monospace; background: #fafaf5; border: 1px solid var(--line);
  border-radius: 3px; padding: 0 4px;
}

.list { max-width: 960px; margin: 40px auto; padding: 0 18px; }
.list h1 { font-weight: 500; font-size: 28px; margin: 0 0 4px; }
.topline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.account { display: flex; align-items: baseline; gap: 5px; min-width: 0; white-space: nowrap; font: 13px -apple-system, system-ui, sans-serif; color: var(--muted); }
.email { display: inline-block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.account a, .account button { color: var(--ink); }
.account button { border: 0; background: none; padding: 0; min-width: 0; text-decoration: underline; font: inherit; }
.login { max-width: 460px; margin: 72px auto; padding: 0 24px; font-family: -apple-system, system-ui, sans-serif; }
.login h1 { font: 500 30px 'Iowan Old Style', 'Palatino', serif; margin: 28px 0 8px; }
.login .sub { margin-bottom: 24px; line-height: 1.5; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; gap: 10px; }
.login button[type=submit] { padding: 10px 18px; }
.login .junk { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 14px 2px 0; }
.login .back { color: var(--muted); text-decoration: none; font-size: 14px; }
.login form { display: flex; gap: 8px; flex-wrap: wrap; }
.login input { flex: 1; min-width: 200px; font: 16px -apple-system, system-ui, sans-serif; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.login #code { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.login .hint { width: 100%; font-size: 13px; margin: 4px 0 0; }
.login .hint a { color: var(--muted); }
.msg { color: var(--danger); font-size: 14px; min-height: 1.2em; }
.src { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filters span { color: var(--muted); font-size: 12px; }
.filters button.on span { color: #ccc; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 2px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
}
.tile:hover { border-color: var(--accent); }
.tile b { font-size: 20px; font-weight: 500; }
.tile span { font: 12px -apple-system, system-ui, sans-serif; color: var(--muted); }
.tile i { position: absolute; top: 8px; right: 10px; font-style: normal; color: var(--accent); }
.tile.done { border-color: var(--ok); }
.tile.done i { color: var(--ok); }

.ex-page { padding-bottom: 140px; }
.bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2;
}
.bar h1 { font-size: 20px; font-weight: 500; margin: 0; }
.bar .back, .bar .nav { text-decoration: none; color: var(--muted); font: 14px -apple-system, system-ui, sans-serif; }
.bar .nav.off { visibility: hidden; }
.bar .attempts { position: relative; }
.picker { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 10px; min-width: 0; white-space: nowrap; }
.picker svg { width: 10px; height: 6px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.picker[aria-expanded="true"] { border-color: var(--ink); }
.picker[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 230px; max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px;
  box-shadow: 0 10px 30px rgba(40, 30, 10, .12), 0 2px 6px rgba(40, 30, 10, .06);
}
.menu button {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; width: 100%;
  border: 0; border-radius: 6px; background: none; padding: 8px 10px; text-align: left; font-size: 13px;
}
.menu button:hover, .menu button:focus-visible { background: var(--bg); outline: none; }
.menu button[aria-checked="true"] { font-weight: 600; }
.menu button[aria-checked="true"] .when::before { content: "• "; color: var(--accent); }
.menu .tag { color: var(--muted); font-size: 12px; font-weight: 400; }
.menu button[aria-checked] .tag:not(:empty) { font-variant-numeric: tabular-nums; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu .danger { color: var(--danger); }
.bar .save { color: var(--muted); font: 12px -apple-system, system-ui, sans-serif; min-width: 60px; text-align: right; }
.bar .meta { margin-left: auto; color: var(--muted); font: 13px -apple-system, system-ui, sans-serif; }
.ex-page main { max-width: 1200px; margin: 0 auto; padding: 12px 12px 0; }
#scan { margin-bottom: 8px; }
#scan summary { cursor: pointer; color: var(--muted); font: 13px -apple-system, system-ui, sans-serif; }
#scan img { display: block; width: 100%; max-width: 1100px; margin-top: 6px; mix-blend-mode: multiply; }
#score { background: var(--bg); touch-action: manipulation; cursor: crosshair; user-select: none; }
#score svg { display: block; }
.empty { padding: 30px; color: var(--muted); }
.help { color: var(--muted); font: 12px/1.9 -apple-system, system-ui, sans-serif; }

.tools {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line);
}
.tools .group { display: flex; gap: 4px; }
.tools .wide { min-width: 84px; }
.tools .voice { font-weight: 600; color: var(--vc); border-color: var(--vc); }
.tools .voice.on { background: var(--vc); color: #fff; }
#done.on { background: var(--ok); border-color: var(--ok); }
@media (max-width: 600px) {
  .help { display: none; }
  .bar .meta { display: none; }
  .bar .save { margin-left: auto; }
  .tools button { padding: 9px 10px; }
}

.home-link { color: var(--muted); text-decoration: none; font: 13px -apple-system, system-ui, sans-serif; }
header.site {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 960px; margin: 0 auto; padding: 18px;
}
header.site .brand { font-size: 18px; text-decoration: none; color: var(--ink); }
header.site nav { display: flex; gap: 18px; font: 14px -apple-system, system-ui, sans-serif; }
header.site nav a, header.site nav span { color: var(--muted); text-decoration: none; }
header.site nav a:hover { color: var(--accent); }
.home { max-width: 960px; margin: 0 auto; padding: 24px 18px 40px; }
.hero { display: grid; grid-template-columns: 1fr 260px; gap: 48px; align-items: center; padding: 32px 0 48px; }
.hero h1 { font-size: 40px; font-weight: 500; line-height: 1.15; margin: 0 0 18px; }
.lead { font-size: 19px; line-height: 1.55; margin: 0 0 28px; }
.cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0; }
.button {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  font: 500 16px -apple-system, system-ui, sans-serif; padding: 12px 22px; border-radius: 6px;
}
.button:hover { background: #a84b12; }
.count { color: var(--muted); font: 14px -apple-system, system-ui, sans-serif; }
.portrait { margin: 0; }
.portrait img { display: block; width: 100%; height: auto; border-radius: 4px; filter: sepia(0.25) contrast(1.05); mix-blend-mode: multiply; }
.portrait figcaption { color: var(--muted); font: 13px -apple-system, system-ui, sans-serif; margin-top: 8px; text-align: center; }
.about { border-top: 1px solid var(--line); padding-top: 32px; max-width: 640px; }
.about h2 { font-size: 24px; font-weight: 500; margin: 0 0 12px; }
.about p { font-size: 17px; line-height: 1.6; margin: 0 0 14px; }
footer.site {
  max-width: 960px; margin: 0 auto; padding: 24px 18px 40px; border-top: 1px solid var(--line);
  color: var(--muted); font: 13px -apple-system, system-ui, sans-serif;
}
@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
  .hero h1 { font-size: 30px; }
  .portrait { max-width: 200px; }
}

.mpanel, .mbars { display: none; }
body.mobile .tools, body.mobile .help, body.mobile .bar .meta, body.mobile #prev, body.mobile #next { display: none; }
body.mobile { padding-bottom: 320px; }
body.mobile .bar { gap: 8px; padding: 8px 12px; }
body.mobile .bar .attempts { display: none; }
body.mobile.logged-in .bar .attempts.has-attempts { display: block; margin-left: auto; }
body.mobile .menu { position: fixed; top: auto; left: 8px; right: 8px; min-width: 0; }
body.mobile .menu button { padding: 12px; font-size: 16px; }
body.mobile main { padding: 6px 0 0; }
body.mobile #scan { padding: 0 12px; }
body.mobile #score { touch-action: pan-y; cursor: default; }
body.mobile .mbars {
  display: flex; align-items: center; justify-content: space-between; padding: 4px 8px;
  font: 13px -apple-system, system-ui, sans-serif; color: var(--muted);
}
body.mobile .mbars button { border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 14px; color: var(--ink); }
.mpanel .mstep { display: flex; justify-content: center; gap: 12px; }
.mpanel .mstep button { flex: 0 0 96px; font-size: 20px; padding: 8px 0; border-radius: 10px; }
.mpanel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  flex-direction: column; gap: 10px;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--line);
}
body.mobile .mpanel { display: flex; }
.mpanel .mrow { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mpanel button { touch-action: manipulation; padding: 10px 0; min-width: 40px; flex: 1; font-size: 16px; }
.mpanel .group { display: flex; gap: 4px; flex: 1; }
.mpanel .mrow:first-child { gap: 12px; }
.mpanel .wide { flex: 2; }
.mpanel .wheel { gap: 10px; }
.mpanel .wheel .big { flex: 2; font-size: 26px; padding: 14px 0; border-radius: 12px; }
.mpanel .wheel .side { flex: 1; font-size: 22px; padding: 14px 0; border-radius: 12px; }
.mpanel .pitch {
  flex: 2; text-align: center; font: 600 30px 'Iowan Old Style', 'Palatino', serif;
  font-variant-numeric: tabular-nums;
}
body.mobile, body.mobile * { touch-action: manipulation; }
body.mobile #score { touch-action: pan-y; }
body.mobile .mpanel, body.mobile .mbars, body.mobile #score { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mpanel .mchips { width: 100%; }
.mpanel .mchips .group { min-width: 0; width: 100%; }
.mpanel .mchips button { min-width: 0; padding: 7px 0; }
.mpanel .mvoices button:disabled { display: none; }
header.site nav { align-items: baseline; min-width: 0; }
@media (max-width: 600px) {
  header.site { padding: 14px 16px; }
  header.site .brand { white-space: nowrap; }
  header.site nav { gap: 12px; }
  .email { max-width: 14ch; }
}
