:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #5b6475;
  --line: #e3e7ee;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #ccfbf1;
  --accent: #f59e0b;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 14px;
  color-scheme: light;
}
html.dark {
  --bg: #0b1120;
  --card: #131c2e;
  --ink: #e6eaf2;
  --muted: #98a2b6;
  --line: #24304a;
  --brand: #14b8a6;
  --brand-ink: #04201d;
  --brand-soft: #0f3b38;
  --good-soft: #10331f;
  --bad-soft: #3a1416;
  --warn-soft: #3a2a0c;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* Layout */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.top .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--ink); }
.top .logo img { width: 28px; height: 28px; }
.top .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--brand-soft); color: var(--ink); white-space: nowrap;
}
.chip.fire { background: var(--warn-soft); }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 10px; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); }
.icon-btn:hover { background: var(--bg); }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.nav a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 4px 0; border-radius: 10px;
}
.nav a span { font-size: 21px; line-height: 1.2; }
.nav a.on { color: var(--brand); background: var(--brand-soft); }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; border: 1px solid var(--line); }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
h1.page { font-size: 22px; margin: 4px 0 4px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

/* Hero / level */
.hero { background: linear-gradient(135deg, #0f766e, #115e59 60%, #134e4a); color: #fff; border: 0; }
html.dark .hero { background: linear-gradient(135deg, #115e59, #0f3b38); }
.hero .kicker, .hero .muted { color: rgba(255,255,255,.8); }
.hero .lv { font-size: 24px; font-weight: 800; margin: 2px 0; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .5s ease; }
.hero .bar { background: rgba(255,255,255,.25); }
.hero .bar > i { background: #5eead4; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: rgba(255,255,255,.12); border-radius: 12px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; }
.stat small { opacity: .85; font-size: 12px; }

/* Next step */
.next { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.next .ico { font-size: 28px; width: 48px; height: 48px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; flex: none; }
.next b { display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Journey */
.phase { padding: 0; overflow: hidden; }
.phase summary { list-style: none; cursor: pointer; padding: 14px 16px; }
.phase summary::-webkit-details-marker { display: none; }
.phase .ph-head { display: flex; align-items: center; gap: 12px; }
.phase .ph-num { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); display: grid; place-items: center; font-weight: 800; flex: none; }
.phase.complete .ph-num { background: var(--good); color: #fff; }
.phase .ph-title { font-weight: 700; }
.phase .bar { margin-top: 10px; }
.items { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--bg); }
.item .t-ico { font-size: 20px; width: 28px; text-align: center; flex: none; }
.item .t-main { flex: 1; min-width: 0; }
.item .t-main small { display: block; color: var(--muted); font-size: 12.5px; }
.item .xp { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.item.done .t-title { color: var(--muted); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 13px; }
.item.done .check, .check.on { background: var(--good); border-color: var(--good); color: #fff; }
.item.next-up { background: var(--brand-soft); }

/* Lesson content */
.content { font-size: 16.5px; }
.content h3 { font-size: 17px; margin: 22px 0 8px; }
.content p { margin: 0 0 12px; }
.content ul, .content ol { padding-left: 22px; margin: 0 0 12px; }
.content li { margin: 4px 0; }
.content blockquote { margin: 14px 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--warn-soft); border-radius: 0 10px 10px 0; }
.content table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 14.5px; }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.content th { font-size: 13px; color: var(--muted); }
.content code { background: var(--bg); padding: 1px 5px; border-radius: 6px; font-size: 14px; }
.box { border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.box.practice { background: var(--brand-soft); }
.box.mistakes { background: var(--bad-soft); }
.box h4 { margin: 0 0 6px; font-size: 14px; }
.box ul { margin: 0; padding-left: 20px; }
.pager { display: flex; gap: 10px; justify-content: space-between; margin-top: 10px; }
.pager a { flex: 1; }

/* Quiz */
.q { margin: 0 0 18px; }
.q .qt { font-weight: 650; margin-bottom: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin: 6px 0; cursor: pointer; background: var(--card); }
.opt input { margin-top: 4px; accent-color: var(--brand); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.explain { font-size: 14px; color: var(--muted); margin-top: 6px; }
.score { font-size: 40px; font-weight: 800; }

/* Forms */
label.f { display: block; font-size: 13.5px; font-weight: 600; margin: 10px 0 4px; }
input.in, select.in, textarea.in {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-weight: 600; font-size: 14.5px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; min-height: 1em; }

/* Login */
.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.auth img { width: 64px; height: 64px; }
.auth h1 { margin: 12px 0 4px; }
.auth input.in { text-align: center; font-size: 24px; letter-spacing: .4em; }

/* Money / chart */
.money { font-size: 26px; font-weight: 800; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 0 2px; position: relative; margin-top: 12px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.chart .b { width: 100%; max-width: 44px; background: var(--line); border-radius: 8px 8px 3px 3px; min-height: 3px; height: 0; transition: height .5s ease; }
.chart .b.hit { background: var(--good); }
.chart .b.some { background: var(--brand); }
.chart .lbl { font-size: 11.5px; color: var(--muted); }
.chart .goal { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--accent); }
.chart .goal span { position: absolute; right: 0; top: -20px; font-size: 11.5px; color: var(--muted); background: var(--card); padding: 0 4px; }

/* Jobs */
.job { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.job:last-child { border-bottom: 0; }
.job .t-ico { font-size: 22px; }
.job .t-main { flex: 1; min-width: 0; }
.job .v { font-weight: 700; white-space: nowrap; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); margin-left: 4px; }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; background: var(--card); }
.badge .bi { font-size: 34px; line-height: 1.2; }
.badge b { display: block; font-size: 14px; margin-top: 4px; }
.badge small { display: block; color: var(--muted); font-size: 12.5px; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.levels .lvrow { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.levels .lvrow.cur { font-weight: 800; color: var(--brand); }

/* Toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: 86px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: pop .25s ease; max-width: 520px; }
.toast.xp { background: var(--brand); color: var(--brand-ink); }
.toast.gold { background: var(--accent); color: #1f1300; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li b { color: var(--brand); white-space: nowrap; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; font-size: 14.5px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.steps .step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.steps .step:last-child { border-bottom: 0; }
.steps .step.done span.txt { color: var(--muted); text-decoration: line-through; }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }
.phase .t-main { flex: 1; min-width: 0; }
.mt { margin-top: 14px; }
.hint { margin-top: 12px; }
