/* Bar model guide pages: same look as the homepage (Fredoka + Lexend, graph-paper background, ink #1f2544).
   The worked-example styles (.q, .work, .lines, .frac, .ans, .ansbox) are copied from the app so the
   bar model, the question and the working look exactly as they do in Bar Model Snap. */
:root {
  --paper: #f6f8fc; --grid: #e4eaf4; --card: #ffffff; --ink: #1f2544; --muted: #5d6584; --line: #cfd7e6;
  --accent: #7a3fe0; --accent-soft: #efe7fd; --green: #00a650; --green-dark: #007a3d; --hl: #ffed59;
  --red: #d62b30; --ans: #0d5fb0;
  --display: "Fredoka", "Lexend", system-ui, sans-serif;
  --body: "Lexend", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.6;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}
a { color: var(--ink); }
a:hover { color: #5a2bb0; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* header + footer (as on the homepage) */
.top { max-width: 1100px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 26px; background: linear-gradient(transparent 55%, var(--hl) 55%, var(--hl) 92%, transparent 92%); padding: 0 4px; }
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topnav a { padding: 10px 12px; text-decoration: none; font-weight: 500; }
.topnav a.try { margin-left: 6px; padding: 11px 22px; border-radius: 999px; background: var(--red); color: #fff; font-weight: 700; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.topnav a.try:hover { color: #fff; }
.foot { background: var(--ink); color: #c9cfe6; margin-top: 64px; }
.foot-in { max-width: 1100px; margin: 0 auto; padding: 36px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; font-size: 15px; }
.foot-name { font-family: var(--display); font-weight: 700; font-size: 22px; color: #fff; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.foot a { color: #fff; }

/* page */
main { max-width: 860px; margin: 0 auto; padding: 8px 24px 0; }
.crumbs { font-size: 14px; color: var(--muted); margin: 6px 0 18px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.crumbs li + li::before { content: "›"; margin-right: 8px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(32px, 5vw, 46px); line-height: 1.12; letter-spacing: -.3px; }
h1 span { background: linear-gradient(transparent 58%, var(--hl) 58%, var(--hl) 94%, transparent 94%); }
h2 { margin: 44px 0 10px; font-family: var(--display); font-weight: 700; font-size: clamp(25px, 3.6vw, 31px); line-height: 1.2; }
h3 { margin: 26px 0 8px; font-family: var(--display); font-weight: 600; font-size: 21px; }
p { margin: 0 0 14px; }
.lead { font-size: 19px; color: #4a5275; margin: 18px 0 22px; max-width: 38em; }
.pill { display: inline-block; margin: 0 0 14px; padding: 6px 16px; border-radius: 999px; background: #ede4ff; color: #5a2bb0; font-weight: 600; font-size: 15px; font-family: var(--display); }
.btn { display: inline-block; padding: 15px 28px; border-radius: 14px; background: var(--red); color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.btn:hover { color: #fff; transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.keys { list-style: none; margin: 14px 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.keys li { background: #fff6b8; border: 1.5px solid var(--ink); border-radius: 999px; padding: 3px 14px; font-weight: 500; font-size: 15px; }
.steps { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.steps li { counter-increment: s; position: relative; padding-left: 46px; min-height: 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; font-family: var(--display); font-weight: 600; display: grid; place-items: center; }
.note { border-left: 6px solid var(--green); background: #fff; border-radius: 0 14px 14px 0; padding: 14px 18px; margin: 0; }
.note.warn { border-left-color: var(--red); }
.note h2 { margin-top: 0; font-size: 24px; }
.note p:last-child { margin-bottom: 0; }

/* worked example */
.example { margin-top: 44px; background: #fff; border: 2px solid var(--ink); border-radius: 22px; box-shadow: 8px 8px 0 var(--ink); padding: 22px; }
.example > h2 { margin: 0 0 14px; }
.q { font-size: 1.05rem; line-height: 2.1; background: var(--paper); border-radius: 12px; padding: 14px 16px; border: 1.5px solid var(--line); margin: 0; }
.q mark { background: var(--hl); color: #1f2544; padding: 0 2px; border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.q .frac { line-height: 1.05; vertical-align: middle; margin: 2px 2px; }
.q mark .frac { background: var(--hl); color: #1f2544; border-radius: 3px; padding: 1px 1px; }
.think { font-size: .92rem; color: var(--muted); margin: 10px 2px 0; }
.model-box { margin: 18px 0 0; }
.model-box svg { display: block; width: 100%; height: auto; margin: 0 auto; }
.bm-wide { display: none; }
.bm-narrow svg { max-width: 480px; }
@media (min-width: 700px) { .bm-wide { display: block; } .bm-narrow { display: none; } .bm-wide svg { max-width: 760px; } }
.work { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; background: var(--paper); min-width: 0; }
.lines { display: grid; gap: 10px; font-size: 1.08rem; }
.wgroup { display: grid; grid-template-columns: 2.2em minmax(0, max-content) minmax(0, 1fr); column-gap: .3em; align-items: center; }
.ln { display: flex; align-items: center; flex-wrap: wrap; white-space: pre-wrap; min-height: 2.3em; }
.ln.tag { font-weight: 600; }
.ln.lhs { justify-content: flex-end; text-align: right; }
.ln.full { grid-column: 2 / -1; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 3px; font-size: .92em; line-height: 1.15; }
.frac > span:first-child { border-bottom: 1.6px solid currentColor; padding: 0 3px 1px; }
.frac > span:last-child { padding: 1px 3px 0; }
.ans { color: var(--ans); font-weight: 700; }
.ansbox { border: 2.5px solid var(--accent); border-radius: 12px; padding: 14px; text-align: center; display: grid; align-content: center; gap: 4px; background: #fff; margin-top: 22px; }
.ansbox .lab { font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--muted); }
.ansbox .val { font-size: 1.35rem; font-weight: 700; color: var(--ans); white-space: pre-line; }
.stmt { margin: 12px 0 0; font-size: 1.08rem; font-weight: 500; }

/* call to action + cards */
.cta { margin-top: 48px; background: var(--ink); color: #fff; border-radius: 22px; padding: 32px 28px; text-align: center; }
.cta h2 { margin: 0 0 8px; color: #fff; font-size: clamp(24px, 3.4vw, 30px); }
.cta p { color: #c9cfe6; max-width: 34em; margin: 0 auto 20px; }
.cta .btn { border-color: #fff; box-shadow: 4px 4px 0 #ffed59; }
.cta .btn:hover { box-shadow: 6px 6px 0 #ffed59; }
.cards { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.cards a { display: block; height: 100%; background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 16px 18px; text-decoration: none; box-shadow: 4px 4px 0 var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.cards a:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); color: var(--ink); }
.cards strong { display: block; font-family: var(--display); font-size: 19px; line-height: 1.25; }
.cards span { display: block; margin-top: 4px; font-size: 15px; color: #4a5275; }
.back { margin-top: 26px; font-weight: 600; }
.group + .group { margin-top: 8px; }
.group h2 { margin-top: 36px; }

@media (max-width: 640px) {
  /* narrow screens: each side of a working line gets its own row, so long lines never clip */
  .wgroup { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .ln.tag:empty, .ln.lhs:empty { display: none; }
  .ln.lhs { justify-content: flex-start; text-align: left; margin-top: 8px; min-height: 0; }
  .ln.rhs { min-height: 0; }
  .ln.full, .ln.tag { grid-column: 1 / -1; }
  .ln.full { min-height: 0; margin-top: 8px; }
  body { font-size: 16px; }
  .top { padding: 14px 16px; }
  .brand-name { font-size: 22px; }
  main { padding: 4px 16px 0; }
  .example { padding: 16px 14px; box-shadow: 5px 5px 0 var(--ink); }
  .foot-in { padding: 28px 16px; }
  .btn { display: block; text-align: center; padding: 15px 18px; }
  .cta { padding: 26px 18px; }
}
@media (prefers-reduced-motion: reduce) { .btn, .cards a { transition: none; } }

/* quick answer box under the H1 (answer-first summary) */
.quick { margin: 20px 0 4px; background: #fff; border: 2px solid var(--ink); border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); padding: 16px 20px 14px; }
.quick h2 { display: inline-block; margin: 0 0 8px; padding: 3px 12px; border-radius: 999px; background: #dff6e8; color: var(--green-dark); font-size: 15px; font-weight: 700; line-height: 1.4; }
.quick p { margin: 0 0 10px; font-size: 17px; }
.quick-facts { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1.5px dashed var(--line); display: grid; gap: 4px; font-size: 15px; color: #4a5275; }
.quick-facts b { color: var(--ink); font-weight: 600; }
.quick + .lead { margin-top: 18px; }

/* short FAQ near the end of each guide */
.faq h3 { margin: 20px 0 4px; font-size: 19px; }
.faq p { margin: 0; color: #4a5275; }

/* about page */
.facts { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.facts li { background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 14px 16px; box-shadow: 4px 4px 0 var(--ink); }
.facts strong { display: block; font-family: var(--display); font-size: 30px; line-height: 1.1; }
.facts span { font-size: 15px; color: #4a5275; }
@media (max-width: 640px) { .quick { padding: 14px 16px 12px; box-shadow: 4px 4px 0 var(--ink); } .quick p { font-size: 16px; } }
