@font-face { font-family: Newsreader; font-weight: 400; font-style: normal; font-display: swap; src: url(/fonts/newsreader-400-normal.woff2) format("woff2"); }
@font-face { font-family: Newsreader; font-weight: 400; font-style: italic; font-display: swap; src: url(/fonts/newsreader-400-italic.woff2) format("woff2"); }
@font-face { font-family: Newsreader; font-weight: 600; font-style: normal; font-display: swap; src: url(/fonts/newsreader-600-normal.woff2) format("woff2"); }
@font-face { font-family: Caveat; font-weight: 600; font-display: swap; src: url(/fonts/caveat-600-normal.woff2) format("woff2"); }
@font-face { font-family: Caveat; font-weight: 700; font-display: swap; src: url(/fonts/caveat-700-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(/fonts/inter-500-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(/fonts/inter-600-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(/fonts/inter-700-normal.woff2) format("woff2"); }

:root {
  --bg: #fbfaf4;
  --dot: #c3cbdf;
  --surface: #ffffff;
  --ink: #1f2b52;
  --muted: #5a6894;
  --faint: #8793b4;
  --line: #9aa7c7;
  --note: #2a5cc4;
  --sticky: #ffe680;
  --accent-ink: #fbfaf4;
  --shadow: rgba(31, 43, 82, .3);
  --card-shadow: rgba(31, 43, 82, .18);
  --bar-h: 64px;
  --serif: Newsreader, Georgia, serif;
  --hand: Caveat, "Segoe Print", cursive;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --c1: #ffe680; --c2: #c6f0d8; --c3: #dcd2fa; --c4: #ffd6c2;
  --g1: #d05a3c; --g2: #2f8f6a; --g3: #7a5bd0; --g4: #c48a1a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161f;
    --dot: #2b3046;
    --surface: #1c2030;
    --ink: #e8ebf7;
    --muted: #a3acd0;
    --faint: #7c86ad;
    --line: #4a5478;
    --note: #8fb0ff;
    --sticky: #ffe680;
    --accent-ink: #14161f;
    --shadow: rgba(0, 0, 0, .55);
    --card-shadow: rgba(0, 0, 0, .4);
    --g1: #ff8f70; --g2: #5fd7a3; --g3: #b7a0ff; --g4: #f0be5a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.3px, transparent 1.4px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) max(20px, env(safe-area-inset-right)) calc(var(--bar-h) + env(safe-area-inset-bottom) + 100px) max(20px, env(safe-area-inset-left));
}
a { color: var(--note); }
a.tlink { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font-family: inherit; color: inherit; }

/* keeps scrolled content out from under the iPhone status bar */
#topcover { position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--bg); z-index: 40; pointer-events: none; }
body { min-height: 100vh; min-height: 100dvh; }

/* header */
.head { display: flex; align-items: center; gap: 8px; min-height: 60px; }
.head h1 { font: 600 30px/1.15 var(--serif); margin: 0; flex: 1; }
.head .back { margin-left: -12px; margin-right: -4px; }
.back { appearance: none; border: 0; background: none; color: var(--ink); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn { appearance: none; width: 44px; height: 44px; border: 1.5px solid var(--ink); background: var(--bg); border-radius: 12px; display: grid; place-items: center; color: var(--ink); cursor: pointer; text-decoration: none; }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sub { font: 600 22px/1 var(--hand); color: var(--note); margin: -4px 0 0; }

/* sticky pill */
.sticky { display: inline-block; background: var(--sticky); color: #1f2b52; font-weight: 700; font-size: 14px; padding: 7px 13px; border-radius: 5px; box-shadow: 1px 2px 0 var(--shadow); transform: rotate(-1.2deg); text-decoration: none; border: 0; }
button.sticky { min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-family: var(--sans); }
button.sticky svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
button.sticky[aria-expanded="true"] svg { transform: rotate(180deg); }

/* difficulty dial */
.dialpop { position: absolute; right: 0; top: 66px; z-index: 30; width: 300px; max-width: calc(100vw - 40px); background: var(--surface); border: 1.5px solid var(--ink); border-radius: 14px; padding: 14px 14px 10px; box-shadow: 3px 4px 0 var(--card-shadow); }
.dialpop svg { display: block; margin: 0 auto; width: 100%; height: auto; }
.dialpop path.seg { cursor: pointer; fill: none; stroke-width: 22; }
.dialpop .needle { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; transition: all .2s ease; }
.dialpop .hub { fill: var(--ink); }
.dialpop .names { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; margin-top: 2px; }
.dialpop .names button { appearance: none; border: 0; background: none; font: 600 12.5px/1.2 var(--sans); color: var(--muted); min-height: 44px; padding: 0 2px; cursor: pointer; border-radius: 8px; }
.dialpop .names button[aria-checked="true"] { color: var(--ink); font-weight: 700; }
.headwrap { position: relative; }

/* problem card */
.statement { font: 400 24px/1.4 var(--serif); margin: 22px 2px 0; }
.statement p { margin: 0 0 12px; }
.cue { font: 600 24px/1.2 var(--hand); color: var(--note); margin: 18px 2px 0; }
.steps { margin: 0 2px; }
.step { margin-top: 24px; animation: rise .22s ease-out; }
.step h3 { margin: 0 0 4px; font: 700 13px/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.step .hint { font: 600 25px/1.12 var(--hand); color: var(--note); }
.step .hint p { margin: 4px 0; }
.step .hint ul, .step .hint ol { padding-left: 22px; margin: 6px 0; }
.step .hint .katex { font-size: 1.05em; }
.step.solution .body { font: 400 19px/1.6 var(--serif); }
.step.solution p { margin: 10px 0; }
.step ul, .step ol { padding-left: 24px; }
.step .chips { margin: 8px 0 8px; }
.src { color: var(--muted); font-size: 13px; padding-top: 12px; margin-top: 14px; border-top: 1.5px dashed var(--line); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .step { animation: none; } .dialpop .needle { transition: none; } }

/* action bar */
.actions { position: fixed; left: 0; right: 0; z-index: 10; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); padding: 14px max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); background: linear-gradient(to top, var(--bg) 72%, transparent); }
.actions .row { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; }
.btn { appearance: none; border: 1.5px solid var(--ink); background: var(--bg); color: var(--ink); font: 600 16px/1.2 var(--sans); min-height: 52px; padding: 8px 12px; border-radius: 12px; cursor: pointer; flex: 1; }
.btn.primary { background: var(--ink); color: var(--accent-ink); flex: 3; box-shadow: 3px 3px 0 var(--sticky); }
.btn.small { flex: 0 0 auto; min-width: 52px; }
.btn.rate { font-size: 15px; }
.btn.rate.got { background: var(--ink); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--sticky); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .back:focus-visible, .iconbtn:focus-visible, #tabs a:focus-visible, a:focus-visible, .dialpop button:focus-visible, button.sticky:focus-visible { outline: 2.5px solid var(--note); outline-offset: 2px; }

/* tab bar */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; height: calc(var(--bar-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--bg); border-top: 1.5px solid var(--ink); }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--faint); font-size: 12px; font-weight: 600; }
#tabs a span { padding-bottom: 1px; border-bottom: 3px solid transparent; }
#tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }
#tabs a[aria-current="page"] span { border-bottom-color: #ffc933; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* grouped lists */
.gh { font: 700 26px/1.1 var(--hand); margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; }
.gh::after { content: ""; flex: 1; border-top: 2px dashed var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; padding-bottom: 8px; }
.tile { display: block; position: relative; text-decoration: none; color: inherit; background: var(--surface); border: 1.5px solid var(--ink); border-radius: 14px; height: 68px; box-shadow: 2px 3px 0 var(--card-shadow); }
.tile .glyph { position: absolute; left: 11px; top: 8px; font: 400 26px/1 var(--serif); color: var(--g1); white-space: nowrap; }
.tile .pill { position: absolute; left: 6px; bottom: -9px; max-width: calc(100% - 8px); background: var(--c1); color: #1f2b52; font-weight: 700; font-size: 12.5px; line-height: 1.15; padding: 5px 9px; border-radius: 5px; box-shadow: 1px 2px 0 var(--shadow); transform: rotate(-1.4deg); }
.tile.k2 .glyph { color: var(--g2); } .tile.k2 .pill { background: var(--c2); transform: rotate(1.2deg); }
.tile.k3 .glyph { color: var(--g3); } .tile.k3 .pill { background: var(--c3); transform: rotate(-.8deg); }
.tile.k4 .glyph { color: var(--g4); } .tile.k4 .pill { background: var(--c4); transform: rotate(1.4deg); }
.ring { position: absolute; right: 9px; top: 9px; width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--ink) calc(var(--p) * 1%), color-mix(in srgb, var(--line) 45%, transparent) 0); }
.ring::after { content: ""; position: absolute; inset: 4.5px; border-radius: 50%; background: var(--surface); }
.footer-link { display: block; margin: 28px 0 0; text-align: center; color: var(--muted); font-size: 14px; }

/* technique page */
.sec { margin: 28px 0 0; }
.sec > h2 { font: 700 26px/1.1 var(--hand); margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.sec > h2::after { content: ""; flex: 1; border-top: 2px dashed var(--line); }
.prose p { margin: 10px 0; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.ex { background: var(--surface); border: 1.5px solid var(--ink); border-radius: 14px; padding: 14px 16px; margin: 14px 0; box-shadow: 2px 3px 0 var(--card-shadow); }
.ex h3 { margin: 0 0 6px; font: 600 20px/1.2 var(--serif); }
.ex .prob { padding-bottom: 6px; }
.ex ol { list-style: none; counter-reset: s; padding: 0; margin: 4px 0; }
.ex ol li { counter-increment: s; position: relative; padding: 8px 0 8px 34px; border-top: 1.5px dashed var(--line); animation: rise .22s ease-out; }
.ex ol li::before { content: counter(s); position: absolute; left: 0; top: 9px; width: 24px; height: 24px; border-radius: 50%; background: var(--sticky); color: #1f2b52; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.ex .btn { flex: none; width: 100%; margin-top: 8px; min-height: 46px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips a { text-decoration: none; background: var(--sticky); color: #1f2b52; font-weight: 700; font-size: 14px; padding: 8px 13px; border-radius: 5px; box-shadow: 1px 2px 0 var(--shadow); min-height: 40px; display: inline-flex; align-items: center; transform: rotate(-1deg); }
.chips a:nth-child(even) { transform: rotate(1deg); background: var(--c2); }
.chips a:nth-child(3n) { background: var(--c3); }

/* history */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.filters button { appearance: none; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--ink); border-radius: 5px; background: var(--bg); color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--sticky); color: #1f2b52; border-color: transparent; font-weight: 700; box-shadow: 1px 2px 0 var(--shadow); transform: rotate(-1deg); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { margin: 0 0 12px; }
.hist a { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1.5px solid var(--ink); border-radius: 12px; padding: 12px 14px; box-shadow: 2px 3px 0 var(--card-shadow); max-height: 8.2em; overflow: hidden; position: relative; }
.hist a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: linear-gradient(transparent, var(--surface)); }
.hist .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.hist .st { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 4px; color: #1f2b52; box-shadow: 1px 1px 0 var(--shadow); transform: rotate(-1deg); background: var(--c2); }
.hist .st.struggled { background: var(--c4); transform: rotate(1deg); }
.hist .st.later { background: var(--c3); transform: rotate(.8deg); }
.hist .tn { font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; }
.hist .txt { font: 400 17px/1.4 var(--serif); }
.empty { text-align: center; color: var(--muted); padding: 56px 8px; }
.tag { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: block; }

/* tables / math */
.tablewrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; font-size: 15px; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.06em; }

.hint .chips a, .step .chips a { font-family: var(--sans); font-size: 14px; line-height: 1.2; }
