:root {
  --ink: #06080f; --navy: #0d1322; --slate: #141c30; --steel: #1c2840;
  --line: #283448; --line-2: #344056; --ice: #7d8fa8; --frost: #b0c4de;
  --white: #f0f4fa; --blue: #3b82f6; --teal: #2dd4bf; --amber: #f59e0b;
  --rose: #f43f5e; --violet: #a78bfa; --lime: #84cc16;
  --good: #84cc16; --mid: #f59e0b; --bad: #f43f5e;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --maxw: 760px;
  --nav-h: 62px;
  --ease: cubic-bezier(.22,1,.36,1);
  font-synthesis: none;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--ink);
  color: var(--frost);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: rgba(45,212,191,.3); }

/* ---------- layout ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  min-height: 100dvh;
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  margin: 0 -18px 4px;
  background: rgba(6,8,15,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--steel); color: var(--frost); font-size: 20px; flex-shrink: 0;
}
.topbar .back:active { transform: scale(.94); }
.topbar .brand { display: flex; flex-direction: column; min-width: 0; }
.topbar .brand b { color: var(--white); font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.topbar .brand span { color: var(--teal); font-size: 11px; font-weight: 600; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .badge { font-size: 11px; font-weight: 700; color: var(--ice); background: var(--steel); border-radius: 999px; padding: 6px 12px; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center; gap: 2px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(13,19,34,.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bottomnav .tab {
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: 12px;
  color: var(--ice); font-size: 10.5px; font-weight: 600;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.bottomnav .tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
.bottomnav .tab.active { color: var(--teal); }
.bottomnav .tab:active { background: var(--steel); }

/* ---------- type ---------- */
h1 { font-size: 23px; font-weight: 800; color: var(--white); line-height: 1.25; }
h2 { font-size: 18px; font-weight: 700; color: var(--white); }
h3 { font-size: 15px; font-weight: 700; color: var(--white); }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--teal); }
.muted { color: var(--ice); }
.lead { color: var(--frost); font-size: 14.5px; }
.section-gap { height: 26px; }
.small { font-size: 12.5px; }

/* ---------- cards ---------- */
.card {
  background: var(--slate); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 18px;
}
.card + .card { margin-top: 12px; }
.tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--slate); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 15px 16px;
  transition: transform .12s var(--ease), border-color .15s;
}
.tile:active { transform: scale(.985); border-color: var(--line-2); }
.tile .ic {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,.14); color: var(--blue); font-size: 21px;
}
.tile .tx { flex: 1; min-width: 0; }
.tile .tx b { display: block; color: var(--white); font-size: 15px; font-weight: 700; }
.tile .tx span { display: block; color: var(--ice); font-size: 12.5px; line-height: 1.45; margin-top: 1px; }
.tile .chev { color: var(--ice); font-size: 18px; flex-shrink: 0; }

.grid { display: grid; gap: 12px; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }

/* ---------- progress ---------- */
.ring { --p: 0; --size: 46px; width: var(--size); height: var(--size); flex-shrink: 0; position: relative; }
.ring .c {
  width: 100%; height: 100%; border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--p) * 1%), var(--steel) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 70%, #000 71%);
  mask: radial-gradient(closest-side, transparent 70%, #000 71%);
}
.ring .n { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--white); }
.bar { height: 8px; background: var(--steel); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 999px; transition: width .4s var(--ease); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--r-md);
  font-size: 14.5px; font-weight: 700; color: var(--white);
  background: var(--steel); border: 1px solid var(--line);
  transition: transform .1s var(--ease), background .15s;
}
.btn:active { transform: scale(.97); }
.btn.full { width: 100%; }
.btn.primary { background: var(--blue); border-color: transparent; color: #fff; }
.btn.teal { background: var(--teal); border-color: transparent; color: #04201b; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--steel); color: var(--frost); }
.pill.teal { background: rgba(45,212,191,.14); color: var(--teal); }
.pill.blue { background: rgba(59,130,246,.14); color: var(--blue); }
.pill.amber { background: rgba(245,158,11,.14); color: var(--amber); }
.pill.rose { background: rgba(244,63,94,.14); color: var(--rose); }
.pill.violet { background: rgba(167,139,250,.14); color: var(--violet); }
.pills { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---------- teach shell / games ---------- */
.context-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(45,212,191,.06); border: 1px solid rgba(45,212,191,.16);
  border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--frost);
}
.context-note .lbl { color: var(--teal); font-weight: 700; }
.worked {
  background: var(--steel); border-radius: var(--r-md); padding: 13px 15px; margin: 14px 0;
  font-size: 13.5px; color: var(--frost); border-left: 3px solid var(--violet); border-top-left-radius: 0; border-bottom-left-radius: 0;
}
.worked .lbl { display: block; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--violet); font-weight: 700; margin-bottom: 5px; }
.qtext { font-size: 16px; font-weight: 700; color: var(--white); line-height: 1.4; margin: 16px 0 14px; }
.qtext .blank { color: var(--teal); border-bottom: 2px dashed var(--teal); padding: 0 18px; }

.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 50px; padding: 12px 14px; margin-bottom: 9px;
  border-radius: var(--r-md); background: var(--slate); border: 1.5px solid var(--line);
  color: var(--frost); font-size: 14px; font-weight: 500; line-height: 1.4;
  transition: border-color .12s, background .12s, transform .1s var(--ease);
}
.opt:active { transform: scale(.99); }
.opt .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ice); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; }
.opt.correct { border-color: var(--good); background: rgba(132,204,22,.1); }
.opt.correct .dot { background: var(--good); border-color: var(--good); }
.opt.wrong { border-color: var(--bad); background: rgba(244,63,94,.1); }
.opt.wrong .dot { background: var(--bad); border-color: var(--bad); }
.opt.chosen { border-color: var(--blue); }
.opt[disabled] { pointer-events: none; }

.feedback {
  border-radius: var(--r-md); padding: 13px 15px; margin-top: 14px; font-size: 13.5px; line-height: 1.55;
  border: 1px solid var(--line); background: var(--steel);
}
.feedback.ok { border-color: rgba(132,204,22,.3); background: rgba(132,204,22,.08); }
.feedback.no { border-color: rgba(244,63,94,.3); background: rgba(244,63,94,.08); }
.feedback .lbl { font-weight: 700; display: block; margin-bottom: 4px; }
.feedback.ok .lbl { color: var(--good); }
.feedback.no .lbl { color: var(--bad); }
.feedback .concept { color: var(--ice); margin-top: 8px; }

.progress-dots { display: flex; gap: 6px; margin: 4px 0 2px; }
.progress-dots i { flex: 1; height: 4px; border-radius: 999px; background: var(--steel); }
.progress-dots i.done { background: var(--teal); }
.progress-dots i.cur { background: var(--frost); }

/* flashcard */
.flash {
  perspective: 1200px; min-height: 200px; margin: 16px 0;
}
.flash .inner { position: relative; width: 100%; min-height: 200px; transition: transform .5s var(--ease); transform-style: preserve-3d; }
.flash.flipped .inner { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 22px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--slate);
  font-size: 16px; color: var(--white); line-height: 1.5;
}
.flash .back { transform: rotateY(180deg); background: var(--steel); color: var(--frost); font-size: 14.5px; }
.flash .face .tag { position: absolute; top: 12px; left: 14px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; }
.flash .front .tag { color: var(--teal); }
.flash .back .tag { color: var(--violet); }

/* match */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.match-cols .colh { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ice); font-weight: 700; margin-bottom: 4px; }
.mitem {
  width: 100%; text-align: left; padding: 11px 12px; margin-bottom: 8px; min-height: 46px;
  border-radius: var(--r-md); background: var(--slate); border: 1.5px solid var(--line);
  color: var(--frost); font-size: 13px; line-height: 1.35; transition: all .12s;
}
.mitem.sel { border-color: var(--blue); background: rgba(59,130,246,.12); }
.mitem.matched { border-color: var(--good); background: rgba(132,204,22,.1); color: var(--ice); opacity: .7; }
.mitem.bad { border-color: var(--bad); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* sequence / sortable */
.seq-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; margin-bottom: 8px; min-height: 50px;
  border-radius: var(--r-md); background: var(--slate); border: 1.5px solid var(--line); color: var(--frost); font-size: 13.5px;
}
.seq-item .grip { color: var(--ice); display: flex; flex-direction: column; gap: 4px; }
.seq-item .grip button { width: 30px; height: 22px; border-radius: 6px; background: var(--steel); color: var(--frost); font-size: 13px; display: flex; align-items: center; justify-content: center; }
.seq-item .num { width: 24px; height: 24px; border-radius: 50%; background: var(--steel); color: var(--teal); font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.seq-item.right { border-color: var(--good); }
.seq-item.wrongpos { border-color: var(--amber); }

/* categorize */
.cat-pool { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cat-chip { padding: 9px 13px; min-height: 42px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--steel); border: 1.5px solid var(--line); color: var(--frost); font-size: 13px; }
.cat-chip.sel { border-color: var(--blue); color: var(--white); }
.cat-bins { display: grid; gap: 10px; }
.cat-bin { border: 1.5px dashed var(--line); border-radius: var(--r-md); padding: 12px; min-height: 64px; }
.cat-bin h4 { font-size: 13px; color: var(--white); margin-bottom: 8px; }
.cat-bin .drop { display: flex; flex-wrap: wrap; gap: 7px; }
.cat-bin .placed { padding: 7px 11px; border-radius: 999px; font-size: 12.5px; background: var(--slate); border: 1px solid var(--line); }
.cat-bin .placed.ok { border-color: var(--good); color: var(--lime); }
.cat-bin .placed.no { border-color: var(--bad); color: var(--rose); }

/* case sim */
.case-step { margin-top: 16px; }
.decision-ctx { font-size: 13px; color: var(--ice); margin: 6px 0 14px; }
.opt .vbadge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px; margin-left: auto; flex-shrink: 0; }
.vbadge.good { background: rgba(132,204,22,.16); color: var(--good); }
.vbadge.mid { background: rgba(245,158,11,.16); color: var(--mid); }
.vbadge.bad { background: rgba(244,63,94,.16); color: var(--bad); }
.opt.revealed.v-good { border-color: var(--good); }
.opt.revealed.v-mid { border-color: var(--amber); }
.opt.revealed.v-bad { border-color: var(--bad); opacity: .8; }
.say-box { background: rgba(59,130,246,.07); border: 1px solid rgba(59,130,246,.2); border-radius: var(--r-md); padding: 13px 15px; margin-top: 14px; font-size: 13.5px; font-style: italic; color: var(--frost); }
.say-box b { color: var(--blue); font-style: normal; }
.risk-list { list-style: none; margin: 10px 0 0; }
.risk-list li { position: relative; padding: 5px 0 5px 22px; font-size: 13px; color: var(--frost); }
.risk-list li::before { content: "!"; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: rgba(245,158,11,.18); color: var(--amber); font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* study guide */
.sg-body { font-size: 14px; color: #aebacb; line-height: 1.72; margin-top: 6px; }
.sg-body b { color: var(--white); font-weight: 600; }
.sg-body p { margin-top: 9px; }
.sg-body p:first-child { margin-top: 0; }
.term { display: inline-block; padding: 2px 9px; border-radius: 7px; background: rgba(45,212,191,.14); color: var(--teal); font-size: 12.5px; font-weight: 600; }

/* readable prose: lead answer + supporting, with highlight-pen key terms */
.sg-lead { font-size: 15px; color: #e9eef6; font-weight: 500; line-height: 1.62; }
.sg-rest { font-size: 13.5px; color: #a7b3c4; line-height: 1.74; margin-top: 9px; }
.sg-rest + .sg-rest { margin-top: 9px; }
.hl { background: rgba(45,212,191,.18); color: #d8f3ed; padding: 0 4px; border-radius: 5px; font-weight: 600; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl.a { background: rgba(167,139,250,.2); color: #e4daff; }
sup.ref { color: var(--blue); font-size: 9.5px; font-weight: 700; vertical-align: super; padding: 0 1px; }
.refs { font-size: 11px; color: var(--ice); line-height: 1.75; margin: 0; padding-left: 18px; }
.refs li { margin-bottom: 3px; }
.refs a { color: var(--blue); word-break: break-word; }

/* table */
.tablewrap { overflow-x: auto; margin: 14px -4px; -webkit-overflow-scrolling: touch; }
table.matrix { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 540px; }
table.matrix th { text-align: left; padding: 9px 10px; background: var(--steel); color: var(--ice); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; position: sticky; top: 0; }
table.matrix td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--frost); vertical-align: top; }
table.matrix td:first-child { color: var(--white); font-weight: 600; white-space: nowrap; }
.yes { color: var(--lime); font-weight: 700; }
.no { color: var(--rose); font-weight: 700; }
.partial { color: var(--amber); font-weight: 700; }

/* service cards */
.svc { margin-bottom: 12px; }
.svc .svc-h { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; margin-bottom: 6px; }
.svc-h b { color: var(--white); font-size: 15.5px; display: block; }
.svc-meta { display: block; color: var(--ice); font-size: 11.5px; margin-top: 2px; }
.svc-row { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.svc-row .k { color: var(--ice); font-weight: 700; min-width: 76px; flex-shrink: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; padding-top: 2px; }
.svc-row .v { color: var(--frost); flex: 1; line-height: 1.5; }
.ag { flex-shrink: 0; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.ag.y { background: rgba(132,204,22,.16); color: var(--lime); }
.ag.n { background: rgba(244,63,94,.16); color: var(--rose); }
.ag.p { background: rgba(245,158,11,.16); color: var(--amber); }

/* mock */
.mock-q { font-size: 18px; font-weight: 700; color: var(--white); line-height: 1.4; }
.reveal-block { margin-top: 12px; }
.reveal-block .ans-lbl { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; margin: 12px 0 5px; }
.ans-lbl.model { color: var(--teal); } .ans-lbl.exp { color: var(--violet); } .ans-lbl.fed { color: var(--rose); } .ans-lbl.risk { color: var(--amber); }
.ans-text { font-size: 13.5px; color: var(--frost); line-height: 1.6; background: var(--steel); border-radius: var(--r-md); padding: 11px 14px; }

.empty { text-align: center; padding: 40px 20px; color: var(--ice); }
.empty .big { font-size: 30px; margin-bottom: 10px; }
.spin { width: 30px; height: 30px; border: 3px solid var(--steel); border-top-color: var(--teal); border-radius: 50%; animation: rot .8s linear infinite; margin: 0 auto 14px; }
@keyframes rot { to { transform: rotate(360deg); } }

.fade-in { animation: fade .3s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%); background: var(--steel); color: var(--white); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 60; animation: fade .2s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
