/* ═══════════════════════════════════════════
   Research Paper Guide — page-specific styles
   Builds on the tokens in style.css
   ═══════════════════════════════════════════ */

.rp-page {
  --surface: var(--bg-card);
  --surface-2: #1a2136;
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: rgba(255,255,255,0.08);
  --accent-ink: var(--bg-primary);
  --accent-soft: rgba(0, 212, 170, 0.1);
  --ok: #6ccb93;  --ok-soft: rgba(108, 203, 147, 0.12);
  --warn: #e3a84a; --warn-soft: rgba(227, 168, 74, 0.12);
  --bad: #f08a80; --bad-soft: rgba(240, 138, 128, 0.12);
  --s1: #00d4aa; --s2: #6fa3d6; --s3: #9a8fd6; --s4: #d08aae;
  --s5: #d9a15c; --s6: #8dba68; --s7: #8e99a8; --s8: #6e8fb5;
  --r: 12px;
}

.rp-page .wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}
.rp-page .mono { font-family: var(--font-mono); }
.rp-page .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rp-page :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.rp-page button { font: inherit; color: inherit; }

/* ───── Header extras ───── */
.rp-back {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color 0.2s;
}
.rp-back:hover { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 2rem; }
.chip {
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-secondary);
}
.chip b { font-weight: 600; color: var(--text-primary); }

.formula {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.5rem;
  font-weight: 600;
}
.formula .t { background: var(--bg-card); border: 1px solid var(--line); padding: 0.4rem 0.9rem; border-radius: 8px; }
.formula .t.res { border-color: var(--border-accent); color: var(--accent); background: var(--accent-soft); }
.formula .op { color: var(--text-muted); font-family: var(--font-mono); }

/* ───── Section sub-nav (sticky under main navbar) ───── */
.rp-subnav {
  position: sticky;
  top: 72px;
  z-index: 900;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.rp-subnav .wrap {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  overflow-x: auto;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}
.rp-subnav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--text-secondary);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}
.rp-subnav a:hover { background: var(--surface-2); color: var(--text-primary); }
.rp-subnav a.on { background: var(--accent-soft); color: var(--accent); }

/* ───── Sections ───── */
.rp-section { padding: 5rem 0; border-bottom: 1px solid var(--border); }
.rp-section:nth-of-type(even) { background: var(--bg-secondary); }
.rp-section:last-of-type { border-bottom: 0; }
.rp-section[id] { scroll-margin-top: 130px; }
.rp-section .section-header { margin-bottom: 3rem; }
.rp-page h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.3px; line-height: 1.25; }

/* ───── Stage flow ───── */
.flow { background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; }
.groups { display: grid; grid-template-columns: 4fr 2fr 2fr; gap: 8px; margin-bottom: 8px; }
.groups div { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); border-top: 2px solid var(--line); padding-top: 6px; }
.stages { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.stage { appearance: none; border: 1px solid var(--line); background: var(--bg-primary); border-radius: 10px; padding: 10px 8px; text-align: left; cursor: pointer; display: grid; gap: 4px; transition: border-color .2s, background .2s; }
.stage:hover { border-color: var(--border-accent); }
.stage .n { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.stage .t { font-weight: 600; font-size: 0.88rem; line-height: 1.25; }
.stage.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 24px var(--accent-glow-strong); }
.stage.on .n { color: var(--accent-ink); opacity: .75; }
.stage.done { border-color: var(--border-accent); }
.stage.done .n::after { content: " ✓"; color: var(--accent); }
.progress-line { height: 4px; background: var(--surface-2); border-radius: 4px; margin: 14px 0 18px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #54f0d1); width: 12.5%; transition: width .35s ease; }
.stage-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stage-title h3 { font-size: 1.4rem; }
.stepper-btns { display: flex; gap: 8px; }
.stage-detail { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 16px; }
.stage-detail > div { min-width: 0; }
.box { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--bg-primary); color: var(--text-secondary); font-size: 0.93rem; }
.box h4 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.box ul { padding-left: 18px; display: grid; gap: 4px; }
.box.out { background: var(--accent-soft); border-color: var(--border-accent); color: var(--text-primary); }
.box.out h4 { color: var(--accent); }
.box.trap { background: var(--warn-soft); border-color: transparent; color: var(--text-primary); }
.box.trap h4 { color: var(--warn); }
.jump { font-size: 0.86rem; margin-top: 10px; display: inline-block; color: var(--accent); text-decoration: none; }
.jump:hover { text-decoration: underline; }

/* ───── Buttons ───── */
.rp-page .btn { appearance: none; border: 1px solid var(--line); background: var(--bg-card); padding: 0.45rem 1rem; border-radius: 8px; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: all 0.2s; }
.rp-page .btn:hover { border-color: var(--border-accent); color: var(--accent); }
.rp-page .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rp-page .btn.primary:hover { background: #00eabb; box-shadow: 0 0 20px var(--accent-glow-strong); color: var(--accent-ink); }
.rp-page .btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* ───── Panels / sorter / builder ───── */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.two > * { min-width: 0; }
.panel { background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; }
.panel > h3 { margin-bottom: 6px; }
.panel > p.sub { color: var(--text-secondary); font-size: 0.92rem; margin-bottom: 16px; }
.sort-item { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 8px; }
.sort-item:first-of-type { border-top: 0; }
.sort-q { font-size: 0.95rem; }
.sort-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sbtn { appearance: none; border: 1px solid var(--line); background: var(--bg-primary); border-radius: 100px; padding: 4px 11px; font-size: 0.8rem; cursor: pointer; transition: border-color .2s; }
.sbtn:hover { border-color: var(--border-accent); }
.sbtn.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.sbtn.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.verdict { font-size: 0.86rem; color: var(--text-secondary); }
.verdict b { color: var(--text-primary); }
.score { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 0.8rem; font-weight: 600; }
.field label span { font-weight: 400; color: var(--text-muted); }
.field textarea { width: 100%; resize: vertical; min-height: 52px; border: 1px solid var(--line); background: var(--bg-primary); border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 0.92rem; color: var(--text-primary); }
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.preview { border-left: 3px solid var(--accent); background: var(--bg-primary); padding: 12px 14px; border-radius: 0 8px 8px 0; font-size: 1.02rem; font-weight: 500; line-height: 1.5; margin: 6px 0 12px; }
.lint { list-style: none; display: grid; gap: 6px; font-size: 0.86rem; color: var(--text-secondary); }
.lint li { display: flex; gap: 8px; align-items: flex-start; }
.rp-page .dot { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; margin-top: 2px; }
.rp-page .dot.ok { background: var(--ok-soft); color: var(--ok); }
.rp-page .dot.warn { background: var(--warn-soft); color: var(--warn); }
.note { font-size: 0.78rem; color: var(--text-muted); margin-top: 10px; }

/* ───── Approaches ───── */
.res { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 20px; }
.rchip { appearance: none; border: 1px solid var(--line); background: var(--bg-card); border-radius: 100px; padding: 6px 13px; font-size: 0.85rem; cursor: pointer; color: var(--text-secondary) !important; transition: all .2s; }
.rchip:hover { border-color: var(--border-accent); }
.rchip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent) !important; border-color: var(--accent); }
.matchinfo { font-size: 0.86rem; color: var(--text-muted); margin: -4px 0 20px; text-align: center; }
.appr-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr); gap: 1.25rem; align-items: start; }
.appr-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ap { appearance: none; text-align: left; border: 1px solid var(--line); background: var(--bg-card); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; transition: opacity .2s, border-color .2s; }
.ap:hover { border-color: var(--border-accent); }
.ap .k { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }
.ap .t { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.ap.dim { opacity: .35; }
.ap.match { border-color: var(--border-accent); box-shadow: inset 3px 0 0 var(--accent); }
.ap.on { background: var(--accent-soft); border-color: var(--accent); }
.ap-detail { position: sticky; top: 140px; }
.ap-detail .q { font-size: 1.08rem; font-weight: 500; line-height: 1.45; margin: 10px 0 14px; padding: 12px 14px; background: var(--bg-primary); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; }
.ap-detail h4 { margin: 14px 0 6px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.ap-detail ul { padding-left: 18px; display: grid; gap: 3px; font-size: 0.93rem; color: var(--text-secondary); }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { font-family: var(--font-mono); font-size: 0.72rem; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--text-muted); }
.callout { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--ok-soft); font-size: 0.9rem; }
.callout b { color: var(--ok); }

/* ───── Anatomy ───── */
.toggle-row { text-align: center; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--bg-card); gap: 2px; }
.toggle button { appearance: none; border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); }
.toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.budget { margin: 18px 0 6px; position: relative; }
.bar { display: flex; height: 54px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.seg { appearance: none; border: 0; border-right: 1px solid var(--bg-primary); cursor: pointer; display: grid; place-items: center; color: var(--bg-primary) !important; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; transition: flex-grow .45s ease, filter .2s; min-width: 0; overflow: hidden; padding: 0; }
.seg:last-child { border-right: 0; }
.seg:hover { filter: brightness(1.12); }
.seg.on { box-shadow: inset 0 -5px 0 var(--text-primary); }
.pages { position: relative; height: 22px; margin-top: 4px; }
.pages span { position: absolute; top: 0; transform: translateX(-50%); font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.pages span::before { content: ""; position: absolute; left: 50%; top: -30px; height: 26px; border-left: 1px dashed var(--text-muted); opacity: .6; }
.pages span:first-child { transform: none; }
.pages span:first-child::before { left: 0; }
.pages span:last-child { transform: translateX(-100%); }
.pages span:last-child::before { left: 100%; }
.anat { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.3fr); gap: 1.25rem; margin-top: 22px; align-items: start; }
.sec-list { display: grid; gap: 6px; }
.srow { appearance: none; text-align: left; display: grid; grid-template-columns: 12px 52px 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--bg-card); border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: 0.9rem; transition: border-color .2s; }
.srow:hover { border-color: var(--border-accent); }
.srow.on { border-color: var(--accent); background: var(--accent-soft); }
.srow .sw { width: 12px; height: 12px; border-radius: 3px; }
.srow .rn, .srow .pg { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sdet .ans { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.3px; margin: 8px 0 12px; line-height: 1.35; }
.sdet ul { padding-left: 18px; display: grid; gap: 3px; color: var(--text-secondary); }
.sdet .warnline { margin-top: 14px; font-size: 0.88rem; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); }

/* ───── Sources ───── */
.pipe { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); margin-bottom: 2rem; }
.pnode { position: relative; padding: 14px 14px 14px 0; }
.pnode .c { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-card); border: 2px solid var(--accent); display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); font-weight: 600; position: relative; z-index: 1; box-shadow: 0 0 16px var(--accent-glow); }
.pnode::before { content: ""; position: absolute; left: 34px; right: 0; top: 31px; border-top: 2px solid var(--line); }
.pnode:last-child::before { display: none; }
.pnode h4 { margin: 10px 0 4px; font-size: 0.95rem; }
.pnode p { font-size: 0.83rem; color: var(--text-secondary); }
.refcard { font-family: var(--font-mono); font-size: 0.8rem; background: var(--bg-primary); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 2px; }
.rf { appearance: none; border: 1px solid transparent; background: transparent; text-align: left; display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font: inherit; }
.rf:hover { background: var(--surface-2); }
.rf .l { color: var(--text-muted); }
.rf .v { min-width: 0; overflow-wrap: anywhere; }
.rf.flag { border-color: var(--warn); background: var(--warn-soft); }
.rf.hit { border-color: var(--ok); background: var(--ok-soft); }
.rf.miss { border-color: var(--bad); border-style: dashed; }
.rf.false { border-color: var(--bad); background: var(--bad-soft); }
.rf-exp { font-family: var(--font-display); font-size: 0.82rem; color: var(--text-secondary); grid-column: 2; }
.ai { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai > div { border-radius: 12px; padding: 14px 16px; min-width: 0; border: 1px solid var(--line); }
.ai .can { background: var(--accent-soft); border-color: var(--border-accent); }
.ai .you { background: var(--bg-card); }
.ai h4 { margin: 0 0 8px; font-size: 0.93rem; }
.ai ul { padding-left: 18px; display: grid; gap: 3px; font-size: 0.9rem; color: var(--text-secondary); }
.redline { margin-top: 12px; padding: 12px 16px; border-radius: 12px; background: var(--bad-soft); border: 1px solid rgba(240,138,128,0.25); font-size: 0.92rem; color: var(--text-secondary); }
.redline b { color: var(--bad); }
.box.plain { margin-top: 12px; background: var(--bg-card); }

/* ───── Checklist ───── */
.ck-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ck-meter { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; max-width: 420px; }
.ck-meter .track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.ck-meter .track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #54f0d1); transition: width .3s; }
.ck-meter .num { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ck-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.ck-group h3 { font-size: 1.05rem; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.ck-group h3 span { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.ck { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-top: 1px solid var(--line); cursor: pointer; font-size: 0.92rem; color: var(--text-secondary); }
.ck:first-of-type { border-top: 0; }
.ck input { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--accent); }
.ck input:checked + span { color: var(--text-muted); text-decoration: line-through; }
.done-msg { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.rp-source { margin-top: 2.5rem; }

/* ───── Responsive ───── */
@media (max-width: 900px) {
  .stages { grid-template-columns: repeat(4, 1fr); }
  .groups { display: none; }
  .stage-detail { grid-template-columns: 1fr; }
  .two, .appr-grid, .anat { grid-template-columns: 1fr; }
  .ap-detail { position: static; }
  .pipe { grid-template-columns: 1fr; }
  .pnode { display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; padding: 8px 0; }
  .pnode h4 { margin: 6px 0 2px; }
  .pnode p { grid-column: 2; }
  .pnode::before { left: 16px; top: 42px; bottom: -8px; right: auto; border-top: 0; border-left: 2px solid var(--line); }
  .ck-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .rp-page .wrap { padding: 0 1rem; }
  .rp-section { padding: 3.5rem 0; }
}
@media (max-width: 560px) {
  .stages { grid-template-columns: repeat(2, 1fr); }
  .appr-list { grid-template-columns: 1fr; }
  .ai { grid-template-columns: 1fr; }
  .seg { font-size: 0.62rem; }
  .rf { grid-template-columns: 72px 1fr; }
}

/* ───── Utility (replaces inline styles, which the CSP blocks) ───── */
.ref-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ref-verdict { margin-top: 10px; }
.ap-title { margin-top: 4px; }
