/* ---------- theme tokens ---------- */
:root[data-theme="dark"] {
  --bg: #0d1018; --panel: #151a26; --panel2: #1b2130; --fg: #e7ecf3; --mut: #93a0b4;
  --line: #262d3b; --accent: #7c83ff; --accent-2: #a4a9ff; --on-accent: #0b0e18;
  --green: #37c26b; --green-line: #2c9c56; --greenbg: rgba(55,194,107,.16);
  --red: #e5566a; --red-line: #b83a4d; --redbg: rgba(229,86,106,.16);
  --amber: #e0a13a; --shadow: 0 10px 30px rgba(0,0,0,.45); --code: #cfe0ff;
}
:root[data-theme="light"] {
  --bg: radial-gradient(125% 95% at 88% -12%, #e7e2ff 0%, #eef3ff 42%, #e9fbf2 100%) fixed;
  --panel: #ffffff; --panel2: #f2f3fc; --fg: #1a1c2b; --mut: #5b6479;
  --line: #e4e3f4; --accent: #5b5ef0; --accent-2: #4548d8; --on-accent: #ffffff;
  --green: #12a150; --green-line: #12a150; --greenbg: rgba(18,161,80,.15);
  --red: #e23a5e; --red-line: #e23a5e; --redbg: rgba(226,58,94,.14);
  --amber: #e08a1e; --shadow: 0 8px 24px rgba(80,70,160,.14); --code: #3a3fbf;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 -apple-system, system-ui, "Segoe UI", sans-serif;
  transition: background .2s, color .2s;
}
.serif, h1, h2, .brand { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
em { color: var(--fg); font-style: italic; }
code, .output, .kv .v { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px 22px; flex-wrap: wrap;
  padding: 12px 28px; background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--fg); line-height: 1.15; }
.brand:hover { text-decoration: none; }
.drop { fill: var(--accent); }
.links { display: flex; gap: 6px; }
.links a { color: var(--mut); padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.links a:hover { color: var(--fg); text-decoration: none; background: var(--panel2); }
.links a.active { color: var(--fg); background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line); }
.ghost { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--accent); color: var(--fg); border-radius: 9px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.ghost:hover { background: color-mix(in srgb, var(--accent) 14%, var(--panel2)); }

/* ---------- hero ---------- */
.hero { padding: 34px 32px 6px; max-width: 1180px; margin: 0 auto; }
.hero h1 { text-transform: capitalize; }
h1 { margin: 0; font-size: 38px; font-weight: 800; letter-spacing: -.5px; }
h1.wm { line-height: 1.5; }
h1.wm .w { display: inline-block; padding: 2px 12px; border-radius: 10px; }
h1.wm .w.g { color: var(--green); background: var(--greenbg); box-shadow: inset 0 0 0 2px var(--green-line); }
h1.wm .w.r { color: var(--red); background: var(--redbg); box-shadow: inset 0 0 0 2px var(--red-line); }
.wm-link { display: inline-block; text-decoration: none; }
.wm-link:hover { text-decoration: none; }
.wm-link:hover .w { transform: translateY(-1px); }
.wm-link .w { transition: transform .12s; }
.kicker { margin: 14px 0 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 26px; font-weight: 800; letter-spacing: -.3px; color: var(--accent); }
.sub { margin: 6px 0 0; color: var(--mut); font-size: 16px; max-width: 640px; }

/* ---------- playground layout ---------- */
main.play {
  display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; gap: 18px;
  padding: 20px 32px 48px; max-width: 1180px; margin: 0 auto; align-items: start;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow); position: relative;
}
.card::before { /* ink accent rule */
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px;
  border-radius: 3px; background: var(--accent); opacity: .5;
}
.detect-card { position: sticky; top: 74px; }
h2 { margin: 0 0 12px; font-size: 19px; }
.lbl { display: block; font-weight: 600; font-size: 13px; margin: 13px 0 5px; }
.mut { color: var(--mut); font-weight: 400; }
select, textarea, input[type=text], input[type=number] {
  width: 100%; background: var(--panel2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit;
}
textarea { resize: vertical; }
.status { font-size: 12px; color: var(--mut); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.badge { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); border: 1px solid var(--green-line); border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.badge.off { background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); border-color: var(--amber); }
.seg { display: flex; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-top: 4px; }
.seg button { flex: 1; background: transparent; color: var(--mut); border: 0; border-radius: 7px; padding: 8px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.box { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; background: var(--panel2); }
.box summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
button.primary { width: 100%; margin-top: 16px; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 11px; padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer; }
button.primary:hover { background: var(--accent-2); }
button.primary:disabled { opacity: .55; cursor: default; }
button.secondary { width: 100%; margin-top: 12px; background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 11px; font-weight: 600; cursor: pointer; }
button.secondary:hover { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--mut); margin: 12px 0 0; }

/* ---------- info tooltips ---------- */
.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 5px; vertical-align: middle;
  border-radius: 50%; border: 1px solid var(--accent); color: var(--accent);
  background: transparent; font-size: 10px; font-weight: 700; font-style: normal;
  font-family: -apple-system, system-ui, sans-serif; line-height: 1;
  cursor: help; position: relative; user-select: none; transition: background .12s, color .12s;
}
.info:hover, .info.open { background: var(--accent); color: var(--on-accent); }
.info .tip {
  display: none; position: absolute; z-index: 40; left: 50%; top: calc(100% + 8px);
  transform: translateX(-50%); width: max-content; max-width: 260px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; font-size: 12px; font-weight: 400;
  font-family: -apple-system, system-ui, sans-serif; line-height: 1.45;
  text-align: left; white-space: normal; box-shadow: var(--shadow); cursor: auto;
}
.info .tip::before {
  content: ""; position: absolute; left: 50%; top: -5px; transform: translateX(-50%) rotate(45deg);
  width: 9px; height: 9px; background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
}
.info:hover .tip, .info.open .tip { display: block; }
.row { display: flex; justify-content: space-between; align-items: center; }
.legend { font-size: 12px; color: var(--mut); display: flex; gap: 14px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.output { min-height: 440px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.tok { border-radius: 4px; }
.tok.g { background: var(--greenbg); box-shadow: inset 0 0 0 1px var(--green-line); }
.tok.r { background: var(--redbg); box-shadow: inset 0 0 0 1px var(--red-line); }

/* ---------- detection result ---------- */
.result { margin-top: 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.verdict { font-size: 20px; font-weight: 800; max-width: 190px; }
.verdict.strong { color: var(--green); } .verdict.weak { color: var(--amber); } .verdict.none { color: var(--fg); }
.conf { float: right; font-size: 12px; color: var(--mut); text-align: right; }
.bar { height: 8px; border-radius: 5px; margin: 12px 0; background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); position: relative; }
.bar .pin { position: absolute; top: -3px; width: 3px; height: 14px; background: var(--fg); border-radius: 2px; }
.kv { display: flex; justify-content: space-between; font-size: 13px; margin: 7px 0; }
.kv .k { color: var(--mut); } .kv .v { font-weight: 700; }
.note { font-size: 12px; color: var(--mut); margin-top: 12px; }

/* ---------- explainer page ---------- */
.doc { max-width: 820px; margin: 0 auto; padding: 8px 28px 64px; }
.doc section { margin-top: 40px; }
.doc p { color: var(--fg); }
.doc h1, .doc h2 { text-transform: capitalize; }
.doc h2 { font-size: 24px; margin-bottom: 10px; }
.ink.green { color: var(--green); font-weight: 600; }
.ink.red { color: var(--red); font-weight: 600; }
.pill { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-right: 8px; vertical-align: middle; font-family: -apple-system, system-ui, sans-serif; }
.pill.hard { background: var(--redbg); color: var(--red); box-shadow: inset 0 0 0 1px var(--red-line); }
.pill.soft { background: var(--greenbg); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-line); }
.pill.tour { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.try { font-size: 14px; color: var(--mut); border-left: 3px solid var(--accent); padding-left: 12px; }
.cta { font-weight: 700; }
.tiers { list-style: none; padding: 0; }
.tiers li { margin: 10px 0; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.dot.strong { background: var(--green); } .dot.weak { background: var(--amber); } .dot.none { background: var(--mut); }

/* ---------- svg visuals ---------- */
.viz { margin: 20px 0 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.viz svg { width: 100%; height: auto; display: block; }
.viz figcaption { color: var(--mut); font-size: 13px; margin-top: 10px; text-align: center; }
.viz .t { fill: var(--fg); font-size: 13px; font-family: -apple-system, system-ui, sans-serif; }
.viz .t.in { fill: var(--fg); text-anchor: middle; font-weight: 600; }
.viz .mut-t { fill: var(--mut); }
.viz .box { fill: var(--panel2); stroke: var(--line); }
.viz .box.accent { fill: color-mix(in srgb, var(--accent) 16%, var(--panel2)); stroke: var(--accent); }
.viz .g { fill: var(--greenbg); stroke: var(--green-line); }
.viz .r { fill: var(--redbg); stroke: var(--red-line); }
.viz .win { stroke-width: 2.5; }
.viz .arrow { fill: var(--mut); }
.viz .wire { stroke: var(--mut); stroke-width: 1.5; fill: none; }
.viz .axis { stroke: var(--line); stroke-width: 1.5; }
.viz .bar-g { fill: var(--greenbg); stroke: var(--green-line); }
.viz .bar-r { fill: var(--redbg); stroke: var(--red-line); }
.viz .boost { fill: var(--green); opacity: .5; }
.viz .xmark line { stroke: var(--red); stroke-width: 2.5; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  main.play { grid-template-columns: 1fr; }
  .detect-card { position: static; }
  h1 { font-size: 30px; }
}
