:root {
  --ink: #1e2430;
  --ink-2: #34404c;
  --paper: #f6f7fb;
  --panel: #ffffff;
  --line: #dfe3e9;
  --green: #2eb8a6;
  --green-dark: #197f74;
  --mint: #d8f3ee;
  --amber: #d4af37;
  --rust: #b85435;
  --blue: #6366f1;
  --shadow: 0 16px 48px rgba(30, 36, 48, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; overflow-x: clip; }
body { margin: 0; min-height: 100vh; background: var(--paper); overflow-x: clip; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.skip-link { position: fixed; top: -60px; left: 1rem; z-index: 50; background: var(--ink); color: white; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }
.app-shell { display: grid; grid-template: 76px 1fr / 230px minmax(0, 1fr); min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; padding: 0 2rem; border-bottom: 1px solid rgba(30,36,48,.12); background: rgba(246,247,251,.92); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20; }
.brand { border: 0; padding: 0; background: none; display: flex; align-items: center; gap: .75rem; cursor: pointer; text-align: left; }
.brand strong { display: block; letter-spacing: .18em; font-size: .96rem; }
.brand small { display: block; color: #6d7582; font-size: .69rem; margin-top: .08rem; letter-spacing: .04em; }
.brand-mark { width: 42px; height: 42px; display: block; }
.top-stats { margin-left: auto; display: flex; gap: 1.5rem; font-size: .82rem; color: #596d64; }
.top-stats b { color: var(--ink); font-size: 1rem; }
.icon-button { border: 1px solid var(--ink); border-radius: 999px; background: transparent; padding: .45rem .8rem; cursor: pointer; }
.account-button { border: 0; background: none; color: var(--green-dark); font-size: .8rem; font-weight: 750; cursor: pointer; }
.sync-state { display: inline-flex; align-items: center; gap: .4rem; color: #66786f; font-size: .78rem; }
.sync-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #91a098; }
.sync-state.synced::before { background: var(--green); }
.sync-state.syncing::before { background: var(--amber); }
.sync-state.problem::before { background: var(--rust); }

.side-nav { position: sticky; top: 76px; align-self: start; height: calc(100vh - 76px); padding: 2rem 1rem; border-right: 1px solid rgba(16,33,27,.13); display: flex; flex-direction: column; gap: .35rem; }
.side-nav button { border: 0; border-radius: 10px; background: transparent; padding: .8rem .75rem; text-align: left; color: #596d64; cursor: pointer; }
.side-nav button span { display: inline-block; width: 2rem; color: #91a098; font: 600 .65rem ui-monospace, monospace; letter-spacing: .08em; }
.side-nav button:hover { background: rgba(255,255,255,.5); color: var(--ink); }
.side-nav button.active { background: var(--ink); color: white; }
.side-nav button.active span { color: var(--amber); }

main { min-width: 0; }
#app { max-width: 1160px; margin: 0 auto; padding: 3rem clamp(1.25rem, 4vw, 4rem) 6rem; }
.mobile-nav { display: none; }
.eyebrow { color: var(--green); font: 700 .72rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: .15em; margin: 0 0 .65rem; }
h1, h2, h3 { margin: 0; line-height: 1.08; font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
h1 { font-size: clamp(2.35rem, 5vw, 4.75rem); max-width: 13ch; letter-spacing: -.04em; }
h2 { font-size: clamp(1.65rem, 3vw, 2.5rem); letter-spacing: -.025em; }
h3 { font-size: 1.25rem; }
p { line-height: 1.62; }
.lede { color: #53665e; font-size: 1.05rem; max-width: 62ch; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }

.hero { position: relative; overflow: hidden; color: white; background: linear-gradient(135deg, #1e2430 0%, #252d3a 68%, #253b3d 100%); border-radius: 28px; padding: clamp(2rem, 5vw, 4.25rem); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; width: 340px; height: 340px; right: -130px; top: -130px; border: 2px dashed rgba(46,184,166,.42); border-radius: 50%; box-shadow: 0 0 0 45px rgba(154,161,173,.07), 0 0 0 90px rgba(212,175,55,.05); }
.hero .eyebrow { color: var(--amber); }
.hero p { color: #c7d4ce; max-width: 57ch; }
.hero-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.65rem; position: relative; z-index: 1; }
.hero-note { font-size: .8rem; color: #b8c7c0; }
.button { border: 0; border-radius: 999px; padding: .84rem 1.2rem; background: var(--green); color: white; font-weight: 750; cursor: pointer; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); background: var(--green-dark); }
.button.primary { background: var(--amber); color: var(--ink); }
.button.primary:hover { background: #ffc568; }
.button.secondary { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.button.secondary:hover { background: white; }
.button.danger { background: transparent; color: var(--rust); border: 1px solid #e7b7aa; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1rem 0 2.25rem; }
.stat-card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-card { padding: 1.2rem; }
.stat-card b { display: block; font: 600 1.8rem Georgia, serif; }
.stat-card span { color: #66786f; font-size: .78rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.7rem 0 1rem; }
.section-title a, .text-button { border: 0; background: none; padding: 0; color: var(--green); font-weight: 700; cursor: pointer; text-decoration: none; }

.briefing { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; margin-top: 1rem; }
.card { padding: 1.35rem; }
.mission-card { min-height: 230px; display: flex; flex-direction: column; justify-content: space-between; }
.mission-card .tag, .tag { display: inline-flex; width: fit-content; padding: .28rem .55rem; border-radius: 999px; color: var(--green-dark); background: var(--mint); font: 700 .65rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: .06em; }
.mission-card p { color: #5a6b64; }
.progress-track { height: 8px; background: #e5e1d7; border-radius: 99px; overflow: hidden; }
.progress-track i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.route-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: .45rem; margin: 1.3rem 0; }
.route-step { height: 6px; background: #d9d5ca; border-radius: 10px; }
.route-step.done { background: var(--green); }
.route-step.current { background: var(--amber); }

.track-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; }
.track-card { padding: 1.2rem; min-height: 195px; display: flex; flex-direction: column; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.track-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.track-card .track-code { font: 700 .67rem ui-monospace, monospace; color: var(--green); letter-spacing: .12em; }
.track-card h3 { margin: .75rem 0 .5rem; }
.track-card p { margin: 0 0 1rem; color: #66786f; font-size: .88rem; }
.track-card footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: .72rem; color: #718077; }
.skills-empty { grid-column: 1 / -1; text-align: left; }
.skills-empty p { max-width: 58ch; margin-left: auto; margin-right: auto; }
.skills-empty .hero-actions { justify-content: center; }
.group-filter { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .48rem .75rem; cursor: pointer; font-size: .8rem; }
.filter-button.active { background: var(--ink); color: white; border-color: var(--ink); }

.exercise-wrap { max-width: 800px; margin: 0 auto; }
.exercise-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.exercise-top .progress-track { flex: 1; }
.exercise-top span { font: 700 .75rem ui-monospace, monospace; color: #65756e; }
.exercise-card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(1.5rem, 5vw, 3rem); }
.exercise-card h2 { margin-top: .85rem; }
.exercise-visual { margin: 1.35rem 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--paper); }
.exercise-visual img { display: block; width: 100%; height: auto; aspect-ratio: 5 / 3; object-fit: contain; }
.exercise-visual figcaption { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem .85rem; border-top: 1px solid var(--line); color: #607068; font-size: .76rem; line-height: 1.4; }
.visual-downloads { display: inline-flex; gap: .6rem; flex: 0 0 auto; }
.visual-downloads a { color: var(--green-dark); font-weight: 750; }
.audio-lab { margin: 1.35rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: #eef5f1; }
.audio-lab p { margin: 0 0 .8rem; font-weight: 700; }
.audio-lab small { display: block; margin-top: .7rem; color: #607068; }
.audio-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.audio-button { border: 1px solid var(--green); border-radius: 999px; padding: .65rem .9rem; background: white; color: var(--green-dark); font-weight: 750; cursor: pointer; }
.audio-button:hover, .audio-button.playing { color: white; background: var(--green); }
.scenario { border-left: 4px solid var(--amber); background: #faf5e8; padding: 1rem 1.1rem; margin: 1.35rem 0; line-height: 1.55; }
.choices { display: grid; gap: .65rem; margin: 1.4rem 0; }
.choice { display: flex; gap: .8rem; align-items: flex-start; border: 1px solid var(--line); background: white; border-radius: 12px; padding: .95rem 1rem; text-align: left; cursor: pointer; }
.choice:hover { border-color: #93ae9f; }
.choice.selected { border-color: var(--green); background: #edf7f1; box-shadow: 0 0 0 1px var(--green); }
.choice.correct { border-color: var(--green); background: #e3f4ea; }
.choice.wrong { border-color: var(--rust); background: #fff0eb; }
.choice-key { display: grid; place-items: center; flex: 0 0 1.65rem; height: 1.65rem; border: 1px solid currentColor; border-radius: 50%; font: 700 .72rem ui-monospace, monospace; }
.confidence { border: 0; padding: 0; margin: 1.2rem 0; }
.confidence legend { font-weight: 700; font-size: .82rem; margin-bottom: .55rem; }
.confidence label { display: inline-flex; margin-right: .4rem; }
.confidence input { position: absolute; opacity: 0; }
.confidence span { border: 1px solid var(--line); border-radius: 999px; padding: .42rem .7rem; cursor: pointer; font-size: .77rem; }
.confidence input:checked + span { background: var(--ink); color: white; border-color: var(--ink); }
.feedback { padding: 1rem 1.1rem; border-radius: 12px; margin: 1.25rem 0; background: #edf2ef; }
.feedback.good { background: #e1f2e8; }
.feedback.adjust { background: #fff0e7; }
.feedback strong { display: block; margin-bottom: .3rem; }
.dive-offer, .teach-offer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem; border: 1px solid #b8d9d2; border-radius: 14px; background: #f0faf7; }
.dive-offer h3, .teach-offer h3 { margin-top: .55rem; }
.dive-offer p, .teach-offer p { margin: .35rem 0 0; color: #607068; }
.dive-offer .button, .teach-offer .button { flex: 0 0 auto; }
.tutorial-card h1, .teach-card h1 { max-width: 16ch; font-size: clamp(2rem, 4vw, 3.4rem); }
.tutorial-steps { display: grid; gap: .7rem; padding: 0; margin: 1.5rem 0; list-style: none; }
.tutorial-steps li { display: grid; grid-template-columns: 36px 1fr; gap: .8rem; align-items: center; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; }
.tutorial-steps li > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--amber); font-weight: 800; }
.tutorial-steps p { margin: 0; }
.worked-example { margin: 1.25rem 0; padding: 1rem 1.1rem; border-left: 4px solid var(--green); background: #eef5f1; }
.worked-example p { margin: .65rem 0 0; }
.mental-check { margin: 1.25rem 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; }
.mental-check summary { cursor: pointer; font-weight: 750; }
.mental-check p { margin-bottom: 0; color: #53665e; }
.teach-offer { margin: 1.5rem 0; border-color: #e3c46f; background: #fff8e7; }
.exercise-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.points { color: var(--green); font-weight: 750; }

.mission-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.lane-grid { display: grid; gap: 1rem; }
.lane-card { padding: 1.5rem; }
.lane-card header { display: flex; align-items: center; gap: 1rem; }
.lane-card header .eyebrow { margin-bottom: .3rem; }
.lane-code { display: grid; place-items: center; flex: 0 0 54px; height: 54px; border-radius: 50%; color: var(--amber); background: var(--ink); font: 700 1rem Georgia, serif; }
.lane-card > p { color: #607068; }
.lane-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1.15rem 0; }
.lane-step { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .45rem; padding: .55rem; border: 1px solid var(--line); border-radius: 10px; color: #718077; }
.lane-step i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #e3dfd4; font: 700 .7rem ui-monospace, monospace; font-style: normal; }
.lane-step small { overflow: hidden; text-overflow: ellipsis; }
.lane-step.done { color: var(--green-dark); border-color: #9dcbb3; background: #edf7f1; }
.lane-step.done i { color: white; background: var(--green); }
.lane-step.next { color: var(--ink); border-color: var(--amber); background: #fff6e6; }
.lane-step.next i { background: var(--amber); }
.lane-next { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.lane-next span small, .lane-next span b { display: block; }
.lane-next span small { color: var(--green); font-weight: 750; margin-bottom: .2rem; }
.field-card { min-height: 250px; position: relative; overflow: hidden; }
.field-card::before { content: attr(data-number); position: absolute; right: 1rem; bottom: -.6rem; font: 700 5.5rem Georgia, serif; color: rgba(31,114,82,.08); }
.field-card p { color: #607068; }
.field-card .button { margin-top: .6rem; }

.memory-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-stack { display: grid; gap: .75rem; }
.form-stack label { display: grid; gap: .35rem; font-weight: 700; font-size: .8rem; }
.form-stack input, .form-stack textarea, .form-stack select { width: 100%; padding: .75rem; border: 1px solid var(--line); background: white; border-radius: 9px; color: var(--ink); }
.memory-list { display: grid; gap: .6rem; max-height: 420px; overflow: auto; }
.memory-item { display: grid; grid-template-columns: 48px 1fr auto; gap: .75rem; align-items: center; padding: .7rem; background: white; border: 1px solid var(--line); border-radius: 10px; }
.memory-key { display: grid; place-items: center; height: 42px; border-radius: 8px; background: var(--ink); color: var(--amber); font: 700 .8rem ui-monospace, monospace; }
.memory-item b, .memory-item small { display: block; }
.memory-item small { color: #718077; margin-top: .15rem; }
.delete-memory { border: 0; background: none; color: var(--rust); cursor: pointer; }

.library-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.library-card { padding: 1.2rem; }
.library-card code { display: block; white-space: normal; font-size: 1rem; padding: .8rem; border-radius: 9px; background: #eef0e9; margin: .8rem 0; }
.library-card p { color: #617168; font-size: .87rem; }
.search { width: min(420px,100%); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: white; }

.chart { display: grid; gap: .8rem; }
.chart-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr 42px; align-items: center; gap: .75rem; font-size: .8rem; }
.chart-bar { height: 11px; background: #e1ddd2; border-radius: 99px; overflow: hidden; }
.chart-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.milestone-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: .8rem; }
.milestone { border-top: 4px solid var(--line); padding-top: .75rem; }
.milestone.reached { border-color: var(--amber); }
.milestone b, .milestone small { display: block; }
.milestone small { color: #6b7c73; margin-top: .25rem; }
.empty { text-align: center; padding: 3rem 1rem; color: #64766d; }
.notice { padding: 1rem; border: 1px solid #e3c46f; background: #fff5d6; border-radius: 10px; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 100; background: var(--ink); color: white; border-radius: 10px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.install-dialog { width: min(520px, calc(100% - 2rem)); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.install-dialog::backdrop { background: rgba(16,33,27,.65); backdrop-filter: blur(3px); }
.dialog-close { float: right; border: 0; background: transparent; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.sync-card { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
.sync-card p { margin-bottom: 0; color: #617168; }
.sync-actions { display: flex; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 68px 1fr 66px; }
  .topbar { padding: 0 1rem; }
  .side-nav { display: none; }
  .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5,1fr); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
  .mobile-nav button { border: 0; background: none; padding: .6rem .2rem; font-size: .67rem; color: #65766d; }
  .mobile-nav button span { display: block; font-size: 1rem; margin-bottom: .12rem; }
  .mobile-nav button.active { color: var(--green); font-weight: 800; }
  #app { padding: 2rem 1rem 6rem; }
  .track-grid { grid-template-columns: repeat(2,1fr); }
  .top-stats span:first-child { display: none; }
  .account-button { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 620px) {
  .top-stats { gap: .6rem; }
  .briefing, .mission-grid, .memory-layout, .library-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .track-grid { grid-template-columns: 1fr; }
  .page-head { align-items: start; flex-direction: column; }
  .milestone-grid { grid-template-columns: repeat(2,1fr); }
  .chart-row { grid-template-columns: 105px 1fr 32px; }
  .hero { border-radius: 20px; }
  .exercise-card { border-radius: 18px; }
  .exercise-visual figcaption { align-items: flex-start; flex-direction: column; }
  .sync-card { grid-template-columns: 1fr; }
  .sync-actions { justify-content: flex-start; }
  .lane-steps { grid-template-columns: repeat(2, 1fr); }
  .lane-next { align-items: flex-start; flex-direction: column; }
  .dive-offer, .teach-offer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
