:root {
  --bg: #fffdfc;
  --panel: #ffffff;
  --ink: #1d1626;
  --muted: #6b5f73;
  --line: #eadde5;
  --soft: #fff0f5;
  --accent: #c2255c;
  --on-accent: #ffffff;
  --ok: #1b7a4b;
  --warn: #8f5400;
  --bad: #b42318;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  --bg: #15101a;
  --panel: #1b1522;
  --ink: #f7eef4;
  --muted: #b9aab6;
  --line: #2e2330;
  --soft: #24182a;
  --accent: #ff8fb3;
  --on-accent: #1d1626;
  --ok: #5fd39a;
  --warn: #f2b45a;
  --bad: #ff8a80;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 170px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: 66px;
}
a { color: inherit; }
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 14px; z-index: 100; border-radius: 8px; }
.skip:focus { top: 8px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 var(--gutter); }

.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.045em; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.brand span { color: var(--accent); }
.top nav { display: flex; align-items: center; gap: 4px; }
.top nav a, .icon-btn {
  min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; border-radius: 12px; border: 0; background: transparent; text-decoration: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}
.top nav a:hover, .icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }

.crumbs { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 14px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; }

.hero { padding: 20px 0 14px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
h1 { font-size: clamp(36px, 10vw, 84px); line-height: .94; letter-spacing: -.055em; font-weight: 800; margin: 0; }
h1 em { font-style: normal; color: var(--accent); }
.lead { display: none; margin: 14px 0 0; color: var(--muted); max-width: 52ch; }

.dock { position: sticky; top: 0; z-index: 30; background: var(--bg); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.dock-inner { padding-top: 10px; }
.field { display: block; }
#in {
  width: 100%; resize: none; border: 0; background: transparent; padding: 6px 0 8px;
  font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -.02em; min-height: 48px; max-height: 110px;
}
#in::placeholder { color: var(--muted); font-weight: 500; }
#in:focus-visible { outline: none; }
.field:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.meter-row { display: flex; align-items: center; gap: 10px; min-height: 44px; border-top: 1px solid var(--line); }
.meter-row select {
  min-height: 44px; border: 0; background: transparent; font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; padding: 0 22px 0 0; max-width: 54%; text-overflow: ellipsis;
}
.meter { margin-left: auto; font-family: var(--mono); font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.meter b { font-weight: 700; }
.meter.over b { color: var(--bad); }
.meter .bar { width: 56px; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .25s var(--ease); }
.meter.over .bar i { background: var(--bad); }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; min-height: 44px; padding: 0 12px; border: 0; background: transparent; font-family: var(--mono);
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

.ad {
  display: grid; place-items: center; height: 100px; margin: 16px 0; border: 1px dashed var(--line);
  color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; border-radius: 10px;
}
.ad.tall { height: 250px; }
.anchor-ad {
  position: fixed; left: 0; right: 0; bottom: 0; height: 50px; z-index: 40; display: grid; place-items: center;
  background: var(--bg); border-top: 1px dashed var(--line); color: var(--muted); font-family: var(--mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase;
}

.opts { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 4px 0 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; background: transparent; border: 0; padding: 0; font-size: 14px; }
.switch .track { width: 40px; height: 24px; border-radius: 24px; background: var(--line); position: relative; transition: background .2s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch[aria-checked="true"] .track { background: var(--accent); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); }
.info-btn { min-height: 44px; min-width: 44px; border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 12px; text-decoration: underline; }

.legend { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.legend b { color: var(--ink); font-weight: 600; }

.recent { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; align-items: center; }
.recent::-webkit-scrollbar { display: none; }
.recent:empty { display: none; }
.recent .lbl { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); flex: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel);
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { border-color: var(--accent); }

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "meta meta" "pv act"; column-gap: 12px; row-gap: 4px;
  padding: 14px 0 14px; border-bottom: 1px solid var(--line);
}
.row .meta { grid-area: meta; display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); flex-wrap: wrap; }
.row .meta .name { color: var(--ink); font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: 6px; }
.tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.tag.r1 i { background: var(--warn); }
.tag.r2 { color: var(--bad); border: 1px solid var(--bad); border-radius: 6px; padding: 1px 6px; }
.tag.r2 i { background: var(--bad); }
.cnt.over { color: var(--bad); font-weight: 700; }
.pv {
  grid-area: pv; text-align: left; border: 0; background: transparent; padding: 6px 0; min-height: 44px; font-size: 22px; line-height: 1.35;
  overflow-wrap: anywhere; white-space: pre-wrap; border-radius: 8px; word-break: break-word;
}
.pv.ghost { opacity: .55; }
.pv:hover { color: var(--accent); }
.plain { grid-area: pv; }
.act { grid-area: act; display: flex; gap: 6px; align-items: flex-start; }
.btn {
  min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px; transition: transform .15s var(--ease), background .15s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:active { transform: scale(.96); }
.fav { min-height: 44px; min-width: 44px; border: 0; background: transparent; border-radius: 50%; display: grid; place-items: center; }
.fav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.fav[aria-pressed="true"] svg { fill: var(--accent); stroke: var(--accent); }
.fav:hover { background: var(--soft); }
.plain-line { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

.section-h { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; font-weight: 400; }
.sym-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sym-row .meta { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); font-weight: 700; }
.sym-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sym-chips button { min-width: 44px; min-height: 44px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 0 10px; font-size: 20px; }
.sym-chips button:hover { border-color: var(--accent); }

.empty { padding: 36px 0; color: var(--muted); }

.explain { margin: 28px 0 0; border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px; background: var(--panel); }
.explain summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.explain p { margin: 0 0 14px; color: var(--muted); }

.prose { padding: 36px 0 8px; max-width: 64ch; }
.prose h2 { font-size: 28px; letter-spacing: -.035em; margin: 0 0 12px; line-height: 1.1; }
.prose p { margin: 0 0 14px; }
.faq { padding: 12px 0; }
.faq h2 { font-size: 28px; letter-spacing: -.035em; margin: 20px 0 8px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { min-height: 52px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.faq p { margin: 0 0 14px; color: var(--muted); max-width: 64ch; }

.related { padding: 12px 0 28px; }
.related h2 { font-size: 28px; letter-spacing: -.035em; margin: 20px 0 10px; }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; border-top: 1px solid var(--ink); }
.related a { display: flex; min-height: 48px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 500; }
.related a::after { content: "\2192"; color: var(--muted); }
.related a:hover { color: var(--accent); }

footer { border-top: 1px solid var(--line); padding: 20px 0 30px; font-size: 13px; color: var(--muted); }
footer .wrap { display: flex; flex-direction: column; gap: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 74px; transform: translate(-50%, 12px); background: var(--ink); color: var(--bg); padding: 10px 18px;
  border-radius: 22px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 60;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 760px) {
  :root { --gutter: 28px; }
  body { padding-bottom: 0; }
  .anchor-ad { display: none; }
  #toast { bottom: 28px; }
  .hero { padding: 56px 0 30px; }
  .lead { display: block; }
  .row { grid-template-columns: 210px 1fr auto; grid-template-areas: "meta pv act"; align-items: start; padding: 18px 0; column-gap: 24px; }
  .row .meta { flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 12px; }
  .pv { font-size: 26px; }
  .related ul { grid-template-columns: repeat(3, 1fr); }
  .sym-row { grid-template-columns: 210px 1fr; gap: 24px; padding: 14px 0; }
  .sym-row .meta { padding-top: 12px; }
  .tabs { margin: 0; padding: 0; }
  html { scroll-padding-top: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
