/* Kwantum flash cards. Tokens match the lesson and starter pages. Every surface sets its own text colour (dark mode on iPad). */
:root {
  --paper: #F3F5F8; --surface: #FFFFFF; --ink: #0E1626; --muted: #4D586B; --rule: #D6DCE5; --soft: #E9EDF3;
  --accent: #1F4FD1; --accent-ink: #FFFFFF; --accent-text: #1F4FD1;
  --ok: #16794A; --ok-soft: #E2F2E9; --no: #B42318; --no-soft: #FDECEA; --mid: #A86400; --mid-soft: #FFF4DC;
  --shadow: 0 1px 2px rgba(14, 22, 38, .05), 0 10px 28px -12px rgba(14, 22, 38, .22);
  --font: "Lexend", "Segoe UI", system-ui, sans-serif; --display: "Bricolage Grotesque", "Lexend", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace; --math: "STIX Two Text", "Cambria Math", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0A101B; --surface: #111A29; --ink: #E8EDF5; --muted: #A3AEC1; --rule: #26334A; --soft: #1A2538;
    --accent: #3E6BEA; --accent-text: #86A6FF;
    --ok: #5BD08E; --ok-soft: #10301F; --no: #FF8A80; --no-soft: #3A1715; --mid: #F2B04A; --mid-soft: #33260F;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0A101B; --surface: #111A29; --ink: #E8EDF5; --muted: #A3AEC1; --rule: #26334A; --soft: #1A2538;
  --accent: #3E6BEA; --accent-text: #86A6FF;
  --ok: #5BD08E; --ok-soft: #10301F; --no: #FF8A80; --no-soft: #3A1715; --mid: #F2B04A; --mid-soft: #33260F;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
#fc-app { max-width: 880px; margin: 0 auto; padding: 18px 16px 56px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }

/* top */
.fc-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 18px; margin: 4px 0 14px; }
.fc-top h1 { font-family: var(--display); font-size: 1.45rem; line-height: 1.2; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.fc-crumb { flex-basis: 100%; margin: 0; font-family: var(--mono); font-size: .78rem; }
.fc-stats { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .9rem; color: var(--muted); }
.fc-stats b { color: var(--ink); font-family: var(--mono); font-weight: 600; }

/* buttons */
.fc-go { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0 0 22px; }
.fc-btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; min-height: 58px; padding: 10px 16px; border-radius: 12px;
  border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink); font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
.fc-btn small { font-family: var(--mono); font-weight: 400; font-size: .74rem; color: var(--muted); }
.fc-btn:hover { border-color: var(--ink); }
.fc-btn[disabled] { opacity: .55; cursor: default; border-color: var(--rule); }
.fc-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.fc-primary small { color: rgba(255, 255, 255, .86); }
.fc-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.fc-link { background: none; border: 0; padding: 4px 0; color: var(--accent-text); text-decoration: underline; cursor: pointer; }

/* unit tiles */
.fc-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0 0 8px; }
.fc-row h2 { font-family: var(--display); font-size: 1.05rem; margin: 0; }
.fc-row p { margin: 0; font-size: .84rem; color: var(--muted); }
.fc-units { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.fc-unit { position: relative; display: grid; grid-template-columns: 1fr; gap: 2px; width: 100%; height: 100%; min-height: 148px; padding: 10px 12px 12px; text-align: left; cursor: pointer;
  border-radius: 12px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink); }
.fc-unit::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; border-radius: 10px 10px 0 0; background: var(--c); }
.fc-unit:hover { border-color: var(--c); }
.fc-unit.on { border-color: var(--c); box-shadow: inset 0 0 0 1.5px var(--c); }
.fc-unit.on::after { content: "✓"; position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
.fc-n { font-family: var(--mono); font-size: .72rem; color: var(--muted); margin-top: 4px; }
.fc-sym { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; color: var(--c); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fc-sym { filter: brightness(1.35) saturate(.9); } }
:root[data-theme="dark"] .fc-sym { filter: brightness(1.35) saturate(.9); }
.fc-ut { font-weight: 600; font-size: .92rem; line-height: 1.25; align-self: start; }
.fc-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--soft); align-self: end; margin-top: 6px; }
.fc-bar i { display: block; background: var(--ok); } .fc-bar i.l { background: var(--mid); opacity: .7; }
.fc-um { font-family: var(--mono); font-size: .7rem; color: var(--muted); }

/* fine tune */
.fc-fine { border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink); margin: 0 0 14px; }
.fc-fine summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.fc-fine-in { padding: 0 14px 10px; }
.fc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.fc-chips > span { flex-basis: 100%; font-family: var(--mono); font-size: .74rem; color: var(--muted); }
.fc-chip { padding: 6px 12px; min-height: 36px; border-radius: 999px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--muted); font-size: .84rem; cursor: pointer; }
.fc-chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.fc-more { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0 0 12px; font-size: .92rem; }
.fc-foot { color: var(--muted); font-size: .84rem; margin: 10px 0 0; max-width: 62ch; }

/* study */
.fc-bar2 { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.fc-x { font-size: .9rem; font-weight: 600; padding: 8px 2px; }
.fc-prog { flex: 1; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.fc-prog i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }
.fc-count { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.fc-stage { position: relative; max-width: 640px; margin: 0 auto; }
.fc-card { position: relative; display: flex; flex-direction: column; min-height: min(52vh, 380px); padding: 16px 20px 14px; border-radius: 16px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--rule); box-shadow: var(--shadow); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: pan-y; overflow: hidden; }
.fc-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--c); }
.fc-card.back { background: var(--surface); border-color: var(--c); }
.fc-card.fc-static { cursor: default; min-height: 0; }
.fc-card[data-sw="y"] { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft), var(--shadow); }
.fc-card[data-sw="n"] { border-color: var(--no); box-shadow: 0 0 0 3px var(--no-soft), var(--shadow); }
.fc-card.turning { animation: fc-turn .28s ease-out; }
@keyframes fc-turn { from { transform: perspective(900px) rotateY(-70deg); opacity: .4; } to { transform: none; opacity: 1; } }
.fc-meta { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: .72rem; color: var(--muted); margin-top: 4px; }
.fc-meta span:last-child { text-align: right; }
.fc-low { margin-top: auto; align-items: center; }
.fc-stage .fc-meta:first-child { padding-right: 34px; }
.fc-face { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 18px 0; gap: 10px; }
.fc-face p { margin: 0; max-width: 100%; }
.fc-ask { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.fc-recap { font-family: var(--font); font-size: .84rem; max-width: 46ch; }
.fc-term { font-family: var(--display); font-weight: 800; font-size: clamp(1.5rem, 5.4vw, 2.1rem); line-height: 1.15; letter-spacing: -.01em; }
.fc-q { font-size: clamp(1.1rem, 3.8vw, 1.35rem); font-weight: 500; line-height: 1.4; }
.fc-a { font-size: clamp(1rem, 3.5vw, 1.15rem); line-height: 1.5; }
.fc-f { font-size: clamp(1.4rem, 5.6vw, 1.9rem); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px; }
.fc-or { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.fc-vars { border-collapse: collapse; font-size: .9rem; text-align: left; }
.fc-vars td { padding: 3px 10px; border-top: 1px solid var(--rule); color: var(--ink); }
.fc-vars tr:first-child td { border-top: 0; }
.fc-vars td:last-child { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }
.fc-sheet { font-family: var(--mono); font-size: .72rem; padding: 3px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.fc-sheet.no { background: var(--mid-soft); color: var(--mid); }
.fc-les { font-family: var(--font); font-size: .82rem; }
.fc-dots { display: inline-flex; gap: 3px; }
.fc-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); } .fc-dots i.on { background: var(--ok); }
.fc-star { position: absolute; top: 9px; right: 8px; width: 40px; height: 40px; padding: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.fc-star.on { color: #E0A100; }
.fc-star svg { width: 100%; height: 100%; display: block; }
.fc-rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 640px; margin: 14px auto 0; align-items: center; }
.fc-rate.wait { grid-template-columns: 1fr; }
.fc-turn { align-items: center; }
.fc-r { display: flex; flex-direction: column; align-items: center; min-height: 58px; justify-content: center; border-radius: 12px; border: 1.5px solid; cursor: pointer; }
.fc-r small { font-family: var(--mono); font-size: .7rem; opacity: .85; }
.fc-r.r1 { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.fc-r.r2 { background: var(--mid-soft); border-color: var(--mid); color: var(--mid); }
.fc-r.r3 { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.fc-keys { display: flex; justify-content: space-between; gap: 12px; max-width: 640px; margin: 10px auto 0; font-size: .8rem; color: var(--muted); min-height: 28px; align-items: center; }
.fc-kb { margin-left: auto; font-family: var(--mono); font-size: .72rem; }
@media (hover: none) { .fc-kb { display: none; } }

/* pick the answer */
.fc-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; max-width: 640px; margin: 14px auto 0; }
.fc-opt { min-height: 60px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; }
.fc-opt:hover:not([disabled]) { border-color: var(--ink); }
.fc-opt[disabled] { cursor: default; opacity: 1; color: var(--ink); }
.fc-opt.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.fc-opt.bad { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.fc-opt .fm { font-size: 1.3rem; }
.fc-verdict { grid-column: span 2; margin: 0; font-weight: 600; } .fc-verdict.ok { color: var(--ok); } .fc-verdict.bad { color: var(--no); }

/* end */
.fc-end { max-width: 640px; margin: 6vh auto 0; }
.fc-endn { display: flex; align-items: baseline; gap: 12px; margin: 0; }
.fc-endn b { font-family: var(--display); font-size: 4rem; line-height: 1; font-weight: 800; color: var(--accent-text); }
.fc-endn span { font-size: 1.1rem; font-weight: 600; }
.fc-ends { color: var(--muted); margin: 6px 0 18px; }

/* lists */
.fc-search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink); margin: 0 0 6px; }
.fc-lh { font-family: var(--mono); font-weight: 500; font-size: .8rem; color: var(--muted); margin: 20px 0 6px; padding-left: 10px; border-left: 4px solid var(--c, var(--rule)); }
.fc-list { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink); overflow: hidden; }
.fc-list li { position: relative; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 4px 18px; padding: 12px 48px 12px 14px; border-top: 1px solid var(--rule); }
.fc-list li:first-child { border-top: 0; }
.fc-list p { margin: 0 0 4px; }
.fc-list .fc-f { justify-content: flex-start; font-size: 1.25rem; } .fc-list .fc-a { font-size: .94rem; }
.fc-list .fc-sheet { display: inline-block; }
.fc-kind { display: block; font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.fc-star.sm { top: 6px; right: 4px; }
.fc-del { position: absolute; top: 8px; right: 12px; font-size: .8rem; }
@media (max-width: 560px) { .fc-list li { grid-template-columns: 1fr; } }
.fc-form { display: grid; gap: 12px; max-width: 560px; }
.fc-form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.fc-form textarea, .fc-form select { padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink); font-weight: 400; }
.fc-form .fc-btn { align-items: center; }

/* formulas */
.fm { font-family: var(--math); font-size: 1.12em; white-space: nowrap; letter-spacing: 0; }
.fm i { font-style: italic; }
.fm sub, .fm sup { font-size: .68em; font-style: normal; }
.fm sub { vertical-align: -.3em; } .fm sup { vertical-align: .55em; line-height: 0; }
.fm .eq { margin: 0 .28em; }
.fm .ft { font-family: var(--font); font-size: .8em; font-style: normal; }
.fm .ovl { text-decoration: overline; text-decoration-thickness: 1px; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .15em; }
.frac > span { padding: 0 .2em; line-height: 1.25; }
.frac > span:first-child { border-bottom: 1.2px solid currentColor; }
.sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0 .1em; }
.sqrt .sq-r { display: block; width: .62em; flex: none; position: relative; }
.sqrt .sq-r svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sqrt .sq-in { border-top: 1.3px solid currentColor; padding: .12em .15em .02em .1em; display: block; white-space: nowrap; }

/* print: fold-over cards, two to a row */
.fc-sheet-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 8px; }
.fc-pc { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--ink); break-inside: avoid; min-height: 42mm; }
.fc-pq, .fc-pa { padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; gap: 6px; text-align: center; align-items: center; }
.fc-pq { border-right: 1.5px dashed var(--muted); border-top: 5px solid var(--c); }
.fc-pc p { margin: 0; } .fc-pc .fc-term { font-size: 1.3rem; } .fc-pc .fc-q { font-size: 1rem; } .fc-pc .fc-a { font-size: .9rem; } .fc-pc .fc-f { font-size: 1.3rem; }
.fc-pc .fc-vars { font-size: .78rem; } .fc-pc .fc-kind { align-self: flex-start; }
/* phones: keep the print sheet and the add-a-card form inside the screen */
.fc-sheet-list { grid-template-columns: minmax(0, 1fr); }
.fc-pc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.fc-pq, .fc-pa { min-width: 0; overflow-wrap: anywhere; }
.fc-pc .fm { white-space: normal; }
.fc-pc .fc-vars { max-width: 100%; }
.fc-form { grid-template-columns: minmax(0, 1fr); }
.fc-form textarea, .fc-form select { width: 100%; min-width: 0; box-sizing: border-box; }
@media screen and (max-width: 600px) {
  .fc-pc { grid-template-columns: minmax(0, 1fr); }
  .fc-pq { border-right: 0; border-bottom: 1.5px dashed var(--muted); }
}
@media print {
  @page { size: A4; margin: 10mm; }
  :root { --paper: #fff; --surface: #fff; --ink: #000; --muted: #444; --rule: #999; --ok: #000; --ok-soft: #fff; --mid: #000; --mid-soft: #fff; color-scheme: light; }
  body { background: #fff; font-size: 11pt; }
  .fc-noprint, #kwbar, .kwf-noprint, [data-kwr-fab] { display: none !important; }
  #fc-app { max-width: none; padding: 0; }
  .fc-sheet-list { gap: 0; }
  .fc-pc { border-radius: 0; margin-top: -1.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .fc-sheet { border: 1px solid #000; }
}
@media (prefers-reduced-motion: reduce) { .fc-card.turning { animation: none; } .fc-prog i { transition: none; } }
.fm .int { display: inline-flex; align-items: center; font-size: 1.35em; font-style: normal; line-height: 1; margin-right: .05em; }
.fm .int-l { display: inline-flex; flex-direction: column; justify-content: space-between; font-size: .5em; margin-left: .1em; line-height: 1; height: 2.1em; }
.fm .sum { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin: 0 .1em; font-style: normal; }
.fm .sum > span:not(.sg) { font-size: .62em; min-height: .8em; }
.fm .sum .sg { font-size: 1.45em; line-height: .95; }
.fm .binom { display: inline-flex; align-items: center; font-size: 1em; font-style: normal; }
.fm .binom > .frac.nb { font-size: .95em; }
.frac.nb > span:first-child { border-bottom: 0 !important; }
.fm .binom > .bp { font-size: 2em; font-weight: 300; line-height: 1; }
.colv { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; padding: 1px 6px; margin: 0 2px; border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; border-radius: 7px; line-height: 1.15; font-size: .95em; }
.colv > span { display: block; }
.mat { display: inline-grid; vertical-align: middle; column-gap: .7em; row-gap: .05em; padding: 1px 6px; margin: 0 2px; border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; border-radius: 7px; line-height: 1.2; font-family: var(--math); font-size: .95em; text-align: center; }
.mat.det { border-radius: 0; }
.mat > .aug { border-left: 1px solid currentColor; padding-left: .5em; }
