:root {
  --bg: #0f1420;
  --panel: #161d2e;
  --panel-2: #1b2438;
  --line: #2a3550;
  --text: #e6ebf5;
  --muted: #93a0bd;
  --accent: #5b8cff;
  --accent-2: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.5;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px 60px; }

/* <main class="app"> is a sibling of .wrap and had NO rule at all, so it
   rendered at the full viewport width (measured 2026-11-13: 1440px). Cap it to
   the same column. */
.app { width: 100%; max-width: 900px; margin: 0 auto; padding: 0 16px 60px; }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.brand span { color: var(--accent); }
.topnav { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topnav a:hover { color: var(--text); }
.topnav a.donate {
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
  border-radius: 999px;
  padding: 4px 12px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 4px;
}
.tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab:active { transform: translateY(1px); }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  /* Dark text on #db2777 measured 4.12:1 and a darker pink made it worse
     (3.14:1). White is the readable pairing for this accent. */
  color: #ffffff;
  font-weight: 700;
}

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 14px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0 0 14px; font-size: 20px; }
.badge { color: var(--muted); font-size: 13px; }

/* ---------- inputs ---------- */
.test-config { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.test-config label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.test-config label.wide { flex: 1 1 340px; }
input[type="text"], input[type="search"], textarea, select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
input[type="text"]:focus, textarea:focus, select:focus, input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; font-family: "Cascadia Code", "Consolas", monospace; }
.flags { display: flex; gap: 14px; align-items: center; }
.checkline { flex-direction: row !important; align-items: center !important; gap: 5px !important; }

/* ---------- quick picks ---------- */
.quickpicks { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin-bottom: 12px; }
.quickpicks legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.quickpick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quickpick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.quickpick:hover { border-color: var(--accent); color: var(--text); }
.quickpick:active { transform: translateY(1px); }
.quickpick input { margin: 0; accent-color: var(--accent); }
.quickpick.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1020;
  font-weight: 700;
}
.quickpick.selected input { accent-color: #0b1020; }

.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field textarea { margin-top: 4px; }

.hint { color: var(--muted); font-size: 13.5px; }
.summary {
  color: var(--accent-2);
  font-weight: 600;
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
}
@keyframes summary-flash {
  0% { background-color: rgba(52,211,153,0.5); transform: scale(1.03); }
  100% { background-color: transparent; transform: scale(1); }
}
.summary.flash { animation: summary-flash 0.7s ease-out; }
.err { color: var(--danger); background: rgba(248,113,113,0.1); border: 1px solid var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* ---------- buttons ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); filter: brightness(0.88); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.85); }
.btn-ghost { background: transparent; }
.btn-secondary { background: var(--panel); }
.deeplink { color: var(--accent); font-size: 13px; word-break: break-all; }

/* pressed-flash ring shared by every clickable control */
@keyframes click-flash {
  0% { box-shadow: 0 0 0 3px rgba(91,140,255,0.6); }
  100% { box-shadow: 0 0 0 0 rgba(91,140,255,0); }
}
button.clicked, .tab.clicked, .quickpick.clicked, .gym-card.clicked {
  animation: click-flash 0.45s ease-out;
}

/* ---------- tester ---------- */
.ts-lines { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ts-line {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.ts-line.miss { opacity: 0.65; }
.ts-line mark {
  background: rgba(91,140,255,0.5);
  color: #e4edff;
  border-radius: 3px;
  padding: 0 2px;
  box-shadow: 0 0 0 1px rgba(91,140,255,0.55);
  font-weight: 600;
}

/* ---------- explainer ---------- */
.ex-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; }
.ex-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
.ex-item.d1 { margin-left: 20px; }
.ex-item.d2 { margin-left: 40px; }
.ex-item.d3 { margin-left: 60px; }
.ex-raw {
  font-family: "Cascadia Code", "Consolas", monospace;
  color: var(--accent-2);
  background: rgba(52,211,153,0.12);
  border-radius: 5px;
  padding: 1px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 45%;
  overflow-x: auto;
}
.ex-desc { color: var(--text); font-size: 14px; }
.ex-item.error { border-color: var(--danger); }
.ex-item.error .ex-desc { color: var(--danger); }

/* ---------- generator ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.gen-result {
  margin-top: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.gen-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.pattern-big {
  display: block;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 20px;
  color: var(--accent-2);
  margin: 10px 0;
  word-break: break-all;
}
.breakdown { color: var(--muted); font-size: 13.5px; margin: 6px 0; }
.neg-warn {
  color: var(--warn);
  background: rgba(251,191,36,0.1);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin: 8px 0;
}
.alts { color: var(--muted); font-size: 13px; }
.alts code { color: var(--text); }

/* ---------- gym ---------- */
.gym-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 10px; }
.gym-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.gym-card:hover { border-color: var(--accent); }
.gym-card:active { transform: translateY(1px); }
.gym-card.solved { border-color: var(--accent-2); }
.gym-card h4 { margin: 0 0 4px; font-size: 15px; }
.gym-card p { margin: 0; color: var(--muted); font-size: 13px; }
.gym-card .gym-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.difficulty { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.diff-1 { color: var(--accent-2); background: rgba(52,211,153,0.15); }
.diff-2 { color: var(--warn); background: rgba(251,191,36,0.15); }
.diff-3 { color: var(--danger); background: rgba(248,113,113,0.15); }
.gym-view { margin-top: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.gym-tests { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 10px 0; }
.gym-test { display: flex; justify-content: space-between; font-family: "Cascadia Code", "Consolas", monospace; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; }
.gym-test .exp { color: var(--muted); }
.gym-results { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.gym-r { display: flex; justify-content: space-between; font-family: "Cascadia Code", "Consolas", monospace; font-size: 13px; background: var(--panel); border-radius: 6px; padding: 6px 10px; }
.gym-r.pass { color: var(--ok); }
.gym-r.fail { color: var(--danger); }
.solution { color: var(--accent-2); font-family: "Cascadia Code", "Consolas", monospace; margin-top: 8px; background: rgba(52,211,153,0.1); border-radius: 8px; padding: 10px 12px; }

/* ---------- library ---------- */
.search { margin: 12px 0; }
.lib-list { display: flex; flex-direction: column; gap: 10px; }
.lib-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.lib-card h4 { margin: 0 0 2px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lib-card p { margin: 2px 0; color: var(--muted); font-size: 13.5px; }
.lib-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  margin-right: 6px;
}
.lib-pattern {
  font-family: "Cascadia Code", "Consolas", monospace;
  color: var(--accent-2);
  background: var(--panel);
  border-radius: 6px;
  padding: 6px 10px;
  display: inline-block;
  margin: 6px 0;
  word-break: break-all;
}
.lib-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.lib-tag { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }

/* Deep-linked library card (?tool=library&id=X) — a visible highlight so the
   visitor can tell which pattern the link pointed at (F10). */
.lib-card.lib-deeplink {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.18);
}

/* ---------- ad / hub / footer ---------- */
.ad { margin: 16px 0; min-height: 90px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.hub { margin-top: 26px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.hub p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.hub a { display: inline-block; margin: 0 14px 8px 0; color: var(--hub-ink, #c3cede); text-decoration: none; font-size: 14px; }
.hub a:hover { text-decoration: underline; }
footer {
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 50;
}

/* >>> theme-by-name (2026-11-02) >>> */
/* Theme derived from the site's MEANING, not a random variant.
 * Patterns and code = editor dark with violet. It sits beside a terminal all day.
 * Ad layout is deliberately NOT set here — container width and rail geometry are
 * measured and verified separately by check-ad-layout.mjs.
 */
:root {
  --bg: #0d1218;
  --card: #141b23;
  --ink: #e6edf5;
  --muted: #8b97a8;
  --line: #1f2733;
  --brand: #7c3aed;
  --brand-strong: #7c3aed;
  --accent: #7c3aed;
  --radius: 8px;
  --font-sans: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  --panel: #161d2e;
  --panel-2: #1b2438;
}
body { font-family: var(--font-sans); background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-family: var(--font-sans); font-weight: 500; letter-spacing: -0.015em; }
.card, .panel, section[class*="card"] { border-radius: var(--radius); }
/* <<< theme-by-name <<< */

/* Privacy architecture section (2026-11-08) — the selling point of every site. */
.privacy-section{margin-top:34px;padding-top:24px;border-top:2px solid #e2e8f0}
.privacy-section h2{font-size:1.35em;margin-bottom:10px}
.privacy-section h3{font-size:1.05em;margin:20px 0 8px}
.privacy-steps{margin:10px 0 14px;padding-left:22px}
.privacy-steps li{margin-bottom:8px;line-height:1.6}
.privacy-section kbd{background:#f1f5f9;border:1px solid #cbd5e1;border-bottom-width:2px;
  border-radius:4px;padding:1px 5px;font-size:.85em;font-family:ui-monospace,Menlo,monospace}

/* screen-reader-only: names the page for AT users and search engines
   without altering the designed layout (heading sits inside panels). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
