/* ============================================================
   P vs NP: The Question That Could Break the Internet
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-start: #667eea;
  --bg-end: #764ba2;
  --dark: #2c3e50;
  --ink: #1a1a2e;
  --muted: #555;
  --accent: #667eea;
  --light: #f7f9fc;
  --border: #eef0f4;
  --code-bg: #2c3e50;
  --code-fg: #ecf0f1;
  --warn: #e67e22;
  --warn-bg: #fef5e7;
  --tip-bg: #eef3ff;
  --tip-border: #667eea;
  --good: #27ae60;
  --bad: #e74c3c;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  min-height: 100vh;
  color: var(--ink);
  line-height: 1.65;
}

.app-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.app-header {
  text-align: center;
  color: white;
  padding: 2rem 0 1.5rem;
}

.back-link {
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding: 0.4rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 25px;
  transition: background 0.25s, border-color 0.25s;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.65);
  color: white;
}

.app-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 1.1rem;
  opacity: 0.92;
  max-width: 820px;
  margin: 0 auto;
  line-height: 1.7;
}

.app-subtitle code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.16);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.toc {
  background: white;
  border-radius: 15px;
  padding: 1.5rem 1.75rem;
  margin: 1.75rem 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.toc h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.toc ol {
  list-style: none;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  margin-bottom: 0.35rem;
}

.toc a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-block;
  padding: 0.15rem 0;
  transition: color 0.2s;
}

.toc a::before {
  content: counter(toc) ". ";
  color: var(--accent);
  font-weight: 700;
}

.toc a:hover {
  color: var(--accent);
}

.section {
  background: white;
  border-radius: 15px;
  padding: 2.25rem 2.25rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.section h2 {
  font-size: 1.7rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 3px solid var(--accent);
  display: inline-block;
}

.section h3 {
  font-size: 1.25rem;
  color: var(--accent);
  margin: 1.75rem 0 0.6rem;
}

.section h4 {
  font-size: 1.05rem;
  color: var(--ink);
  margin: 1.25rem 0 0.4rem;
}

.section p {
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.section ul, .section ol {
  margin: 0.5rem 0 1rem 1.4rem;
  color: var(--muted);
}

.section li {
  margin-bottom: 0.45rem;
}

.section li strong {
  color: var(--ink);
}

.code-block {
  position: relative;
  background: var(--code-bg);
  border-radius: 10px;
  margin: 1rem 0 1.25rem;
  overflow: hidden;
}

.code-block pre {
  padding: 0.6rem 1rem 1rem;
  overflow-x: auto;
}

.code-block code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.86rem;
  color: var(--code-fg);
  line-height: 1.65;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.32rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.copy-btn.copied {
  background: #27ae60;
  border-color: #27ae60;
  color: white;
}

.pro-tip, .warning {
  border-radius: 10px;
  padding: 0.95rem 1.15rem;
  margin: 1rem 0;
  font-size: 0.94rem;
  line-height: 1.6;
}

.pro-tip {
  background: var(--tip-bg);
  border-left: 4px solid var(--tip-border);
  color: #2c3e50;
}

.warning {
  background: var(--warn-bg);
  border-left: 4px solid var(--warn);
  color: #5a3d12;
}

.pro-tip .label, .warning .label {
  font-weight: 800;
  letter-spacing: 0.3px;
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--light);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

td {
  color: var(--muted);
}

td code, p code, li code, .flow-node code, .pro-tip code, .warning code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--light);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: #5a3fc0;
}

.flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.25rem 0;
}

.flow-node {
  background: white;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 460px;
}

.flow-node small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.flow-arrow {
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
  margin: 0.15rem 0;
  font-weight: 700;
}

.widget {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  margin: 1.1rem 0 1.4rem;
  background: var(--light);
}

.widget-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.widget-head h4 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.widget-btns {
  display: flex;
  gap: 0.5rem;
}

.step-btn, .reset-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.42rem 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.step-btn {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}

.step-btn:hover {
  background: #5568d8;
}

.step-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.reset-btn {
  background: white;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.reset-btn:hover {
  background: var(--tip-bg);
}

.step-progress {
  height: 6px;
  background: #e3e7f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.9rem;
}

.step-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--bg-end));
  transition: width 0.35s ease;
}

.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.step-list li {
  position: relative;
  padding: 0.55rem 0.7rem 0.55rem 2.6rem;
  margin: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  opacity: 0.5;
  transition: opacity 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.step-list li + li {
  margin-top: 0.3rem;
}

.step-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0.7rem;
  top: 0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #d9deee;
  color: #5a5f7a;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-list li.active {
  background: white;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.step-list li.done {
  opacity: 0.85;
}

.step-list li.done::before {
  background: #27ae60;
  color: white;
}

.step-list li.active::before {
  background: var(--accent);
  color: white;
}

.step-list code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: #eceef5;
  padding: 0.08rem 0.32rem;
  border-radius: 4px;
  color: #5a3fc0;
}

.builder-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.builder-note.ok {
  color: var(--good);
  font-weight: 600;
}

.app-footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  padding: 2.5rem 0 1rem;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--dark);
  color: white;
  padding: 0.65rem 1.5rem;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}


/* ============================================================
   P vs NP specific widgets
   ============================================================ */

.mono, .ss-num, .kv code, .pow-out, .rsa-log, .race-body {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

.app-header em { font-style: italic; }

.inline-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.inline-label select,
.rsa-msg input,
.pow-data input {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.38rem 0.5rem;
  border: 1px solid #d7dbe8;
  border-radius: 7px;
  background: white;
  color: var(--ink);
}

.rsa-msg input:focus,
.pow-data input:focus,
.inline-label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.step-btn.danger { background: var(--bad); border-color: var(--bad); }
.step-btn.danger:hover { background: #c0392b; }
.reset-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Growth slider ---------- */

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.slider-wrap input[type=range] {
  width: 220px;
  accent-color: var(--accent);
}

.growth-rows { display: flex; flex-direction: column; gap: 0.45rem; }

.growth-row {
  display: grid;
  grid-template-columns: 70px 1fr 200px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.growth-name {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-weight: 700;
  color: var(--ink);
}

.growth-track {
  height: 18px;
  background: repeating-linear-gradient(90deg, #e3e7f0 0, #e3e7f0 1px, white 1px, white calc(100% / 9));
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.growth-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease, background 0.25s ease;
}

.growth-bar.poly { background: linear-gradient(90deg, #6fcf97, var(--good)); }
.growth-bar.exp  { background: linear-gradient(90deg, #f5a462, var(--bad)); }

.growth-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.growth-time strong { color: var(--ink); }
.growth-time.bad strong { color: var(--bad); }

/* ---------- Subset sum ---------- */

.target-pill {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.05rem 0.6rem;
  border-radius: 20px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.ss-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.ss-num {
  min-width: 52px;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  border: 1.5px solid #d7dbe8;
  background: white;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
}

.ss-num:hover { border-color: var(--accent); transform: translateY(-2px); }
.ss-num.selected { background: var(--accent); border-color: var(--accent); color: white; }
.ss-num.probe { background: #fff4e0; border-color: var(--warn); }
.ss-num.win { background: var(--good); border-color: var(--good); color: white; }

.ss-status {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.ss-status.ok { border-color: var(--good); color: #1d7a4b; background: #e6f7ef; }

.ss-brute-out {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- Venn ---------- */

.big-quote {
  font-size: 1.35rem;
  text-align: center;
  color: var(--ink);
  margin: 1.25rem auto;
  max-width: 640px;
  padding: 1rem 1.5rem;
  border-left: 5px solid var(--accent);
  background: var(--tip-bg);
  border-radius: 10px;
}

.venn-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.venn-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  background: var(--light);
}

.venn-card h4 { margin: 0 0 0.75rem; font-size: 1rem; }
.venn-card p { font-size: 0.9rem; margin: 0.75rem 0 0; }

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.tag-good { background: #e6f7ef; color: #1d7a4b; }
.tag-bad { background: #fdecec; color: #b03a2e; }

.venn { display: flex; justify-content: center; }

.venn-np {
  position: relative;
  width: 260px;
  height: 160px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-end);
  background: rgba(118, 75, 162, 0.08);
  font-weight: 800;
  color: var(--bg-end);
  padding: 0.6rem 0 0 1.6rem;
}

.venn-p, .venn-npc {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.venn-p {
  width: 92px; height: 92px;
  left: 30px; top: 46px;
  border: 2.5px solid var(--good);
  background: rgba(39, 174, 96, 0.12);
  color: #1d7a4b;
}

.venn-npc {
  width: 104px; height: 70px;
  right: 22px; top: 50px;
  border: 2.5px solid var(--bad);
  background: rgba(231, 76, 60, 0.1);
  color: #b03a2e;
  text-align: center;
  line-height: 1.1;
  padding: 0 0.4rem;
}

.venn-merged {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  border-color: var(--bad);
  color: #b03a2e;
  background: rgba(231, 76, 60, 0.08);
}

/* ---------- Horizontal flow ---------- */

.flow.flow-row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.flow.flow-row .flow-node { width: auto; max-width: none; flex: 0 1 auto; }
.flow.flow-row .flow-arrow { align-self: center; }

/* ---------- Multiply vs factor ---------- */

.race {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.race-lane {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
}

.race-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.race-body {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 72px;
  word-break: break-all;
  margin-bottom: 0.5rem;
}

.race-body strong { color: var(--ink); }
.race-body .fast { color: var(--good); font-weight: 700; }
.race-body .slow { color: var(--bad); font-weight: 700; }

/* ---------- RSA ---------- */

.rsa-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.rsa-panel {
  background: white;
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rsa-alice { border-top-color: var(--good); }
.rsa-eve { border-top-color: var(--bad); }

.rsa-panel h5 { font-size: 0.95rem; color: var(--ink); margin-bottom: 0.2rem; }
.rsa-panel .small { font-size: 0.82rem; margin: 0; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.kv code {
  background: var(--light);
  color: #5a3fc0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

.kv code.wrap { white-space: normal; word-break: break-all; text-align: right; }
.kv.secret code { background: #e6f7ef; color: #1d7a4b; }

.rsa-msg, .pow-data {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink);
}

.pow-data { margin-bottom: 0.8rem; }

.rsa-log {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  min-height: 60px;
}

.rsa-log .hit { color: var(--bad); font-weight: 700; }

/* ---------- TLS stepper extras ---------- */

.relies {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: #8a4b0f;
  background: var(--warn-bg);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s;
  padding-top: 0;
  padding-bottom: 0;
}

.step-list li.active .relies,
.step-list li.done .relies {
  max-height: 120px;
  opacity: 1;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

/* ---------- Use cards ---------- */

.uses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.use-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: var(--light);
  transition: transform 0.25s, box-shadow 0.25s;
}

.use-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); }
.use-ico { font-size: 1.6rem; }
.use-card h5 { font-size: 0.95rem; color: var(--ink); margin: 0.25rem 0; }
.use-card p { font-size: 0.82rem; margin: 0; }

/* ---------- PoW ---------- */

.pow-out {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.7;
  word-break: break-all;
  min-height: 90px;
}

.pow-out .zeros { color: #6fcf97; font-weight: 700; }
.pow-out .dim { color: #95a5a6; }
.pow-out .ok { color: #6fcf97; font-weight: 700; }

/* ---------- P = NP switch ---------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.switch-label { font-weight: 700; color: var(--ink); }

.world-switch {
  position: relative;
  width: 64px;
  height: 34px;
  border-radius: 34px;
  border: none;
  background: #cfd5e6;
  cursor: pointer;
  transition: background 0.25s;
}

.world-switch span {
  position: absolute;
  top: 4px; left: 4px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease;
}

.world-switch[aria-checked="true"] { background: var(--bad); }
.world-switch[aria-checked="true"] span { transform: translateX(30px); }

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem;
}

.world-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}

.world-card h5 { font-size: 0.92rem; color: var(--ink); margin-bottom: 0.3rem; }
.world-card p { font-size: 0.84rem; margin: 0; }

.world-grid.flipped .world-card {
  border-color: var(--bad);
  background: #fdecec;
  animation: shake 0.4s ease;
}

.world-grid.flipped .world-card.good {
  border-color: var(--good);
  background: #e6f7ef;
  animation: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ---------- FAQ ---------- */

.faq details {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: var(--light);
  overflow: hidden;
}

.faq summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "▸ "; color: var(--accent); transition: transform 0.2s; display: inline-block; }
.faq details[open] summary::before { transform: rotate(90deg); }
.faq details p { padding: 0 1rem 0.9rem; margin: 0; animation: fadeIn 0.25s ease; }

td.ok { color: var(--good); font-weight: 600; }
td.no { color: var(--bad); font-weight: 600; }
td.meh { color: var(--warn); font-weight: 600; }

/* ---------- Quiz ---------- */

.quiz-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
  background: var(--light);
  animation: fadeInUp 0.35s ease both;
}

.quiz-q { font-weight: 700; color: var(--ink); margin-bottom: 0.55rem; }

.quiz-opts { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.quiz-opt {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.42rem 0.85rem;
  border-radius: 20px;
  border: 1px solid #d7dbe8;
  background: white;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.right { background: var(--good); border-color: var(--good); color: white; }
.quiz-opt.wrong { background: var(--bad); border-color: var(--bad); color: white; }

.quiz-explain {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.55rem;
  animation: fadeIn 0.25s ease;
}

.quiz-score {
  font-weight: 700;
  color: var(--accent);
  margin: 0.5rem 0 1rem;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section { animation: fadeInUp 0.45s ease both; }

@media (max-width: 768px) {
  .app-title { font-size: 1.9rem; }
  .app-subtitle { font-size: 0.95rem; }
  .section { padding: 1.5rem 1.25rem; }
  .section h2 { font-size: 1.4rem; }
  .widget-head { flex-direction: column; align-items: flex-start; }
  .race, .rsa-grid { grid-template-columns: 1fr; }
  .growth-row { grid-template-columns: 60px 1fr; }
  .growth-time { grid-column: 1 / -1; font-size: 0.8rem; }
  .slider-wrap input[type=range] { width: 160px; }
}

@media (max-width: 480px) {
  .app-container { padding: 1rem 0.75rem 2rem; }
  .app-title { font-size: 1.55rem; }
  .section { padding: 1.15rem 0.9rem; }
  .code-block code { font-size: 0.78rem; }
  .toc { padding: 1.1rem 1rem; }
}
