@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --ink: #16211d;
  --muted: #65716c;
  --paper: #f3f1e9;
  --panel: #fffef9;
  --line: #d9d8cf;
  --green: #087f5b;
  --green-soft: #dff3e9;
  --orange: #e76f3c;
  --terminal: #101916;
  --terminal-ink: #e7efe9;
  --mono: "DM Mono", ui-monospace, monospace;
  --sans: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, input { font: inherit; }
button { cursor: pointer; }
code { font-family: var(--mono); font-size: .9em; }

.topbar { height: 68px; padding: 0 4vw; display: flex; align-items: center; gap: 36px; border-bottom: 1px solid var(--line); background: rgba(243,241,233,.92); }
.brand { color: var(--ink); display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: white; background: var(--green); border-radius: 8px; font-size: 20px; }
.lesson-progress { margin-left: auto; width: min(300px, 30vw); display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.lesson-picker { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.lesson-picker select { max-width: 260px; padding: 7px 28px 7px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--panel); font-size: 12px; }
.progress-track { height: 5px; flex: 1; overflow: hidden; border-radius: 10px; background: #d8ddd9; }
#progress-fill { height: 100%; width: 0; background: var(--green); transition: width .35s ease; }
.quiet-button, .terminal-bar button { border: 0; background: none; color: var(--muted); font-size: 12px; }
.quiet-button:hover, .terminal-bar button:hover { color: var(--ink); }

main { padding: 48px 4vw 64px; max-width: 1600px; margin: auto; }
.intro { display: grid; grid-template-columns: 1.3fr .7fr; gap: 7vw; align-items: end; margin-bottom: 35px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
h1 { max-width: 820px; margin: 0; font-size: clamp(34px, 4vw, 64px); line-height: 1.02; letter-spacing: -.05em; }
.lede { max-width: 780px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.6; }
.brief { padding: 22px 24px; border-left: 3px solid var(--orange); background: #ebe8dd; }
.brief-label { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.brief p { margin: 8px 0 0; line-height: 1.5; font-size: 14px; }

.workspace { display: grid; grid-template-columns: minmax(220px, .72fr) minmax(470px, 1.7fr) minmax(250px, .85fr); min-height: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 22px 60px rgba(42,54,48,.08); }
.mobile-workspace-tabs { display: none; }
.mission-panel, .model-panel { min-height: 0; overflow-y: auto; padding: 28px; background: var(--panel); }
.mission-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.model-panel { border-left: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.goal-list { list-style: none; padding: 0; margin: 28px 0; counter-reset: goals; }
.goal-list li { position: relative; padding: 0 0 24px 36px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.goal-list li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 25px; width: 1px; height: calc(100% - 20px); background: var(--line); }
.goal-list li::before { counter-increment: goals; content: counter(goals); position: absolute; left: 0; top: -2px; display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid var(--line); border-radius: 50%; font: 11px var(--mono); background: var(--panel); }
.goal-list li.done { color: var(--ink); }
.goal-list li.done::before { content: "✓"; color: white; border-color: var(--green); background: var(--green); }

.terminal-panel { min-width: 0; display: flex; flex-direction: column; background: var(--terminal); color: var(--terminal-ink); }
.terminal-workspace { min-width: 0; display: flex; flex-direction: column; gap: 1px; background: #26332e; }
.terminal-workspace .terminal-panel { flex: 1 1 0; min-height: 0; }
.terminal-workspace.dual .terminal { min-height: 0; max-height: none; padding-top: 16px; padding-bottom: 16px; }
.terminal-workspace.dual .command-suggestions { min-height: 44px; }
.terminal-bar { height: 48px; display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid #26332e; color: #84938c; font: 11px var(--mono); }
.traffic-lights { display: flex; gap: 6px; margin-right: auto; }
.traffic-lights i { width: 8px; height: 8px; border-radius: 50%; background: #415049; }
.terminal-owner { margin-left: 14px; color: #bdcbc4; font-weight: 500; }
.terminal-path { margin-left: 10px; color: #71837a; }
.terminal-bar button { margin-left: auto; color: #84938c; }
.terminal { flex: 1; min-height: 0; overflow: auto; padding: 24px; font: 12px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal-message { margin-bottom: 14px; }
.terminal .muted { color: #7f9188; }
.terminal .command { color: white; }
.terminal .command::before { content: "❯ "; color: #67d6a6; }
.terminal .error { color: #ff9871; }
.terminal .success { color: #79d9ac; }
.terminal .easter-egg { color: #f0c66d; }
.terminal .hint { padding: 12px 14px; border-left: 2px solid #77bfe8; color: #b8dff5; background: rgba(80, 155, 198, .08); }
.terminal .status span { display: block; }
.terminal .status-staged { color: #79d9ac; }
.terminal .status-unstaged { color: #f0c66d; }
.terminal .status-conflict { color: #ff9871; }
.terminal .status-clean { color: #79d9ac; }
.command-suggestions .revealed-hint { border-color: #77bfe8; color: #b8dff5; }
.command-line { display: flex; align-items: center; gap: 9px; padding: 10px 24px 18px; }
.prompt { display: flex; gap: 7px; white-space: nowrap; color: #8c9b94; font: 12px var(--mono); }
.prompt b { color: #f0c66d; font-weight: 400; }
.prompt em { color: #67d6a6; font-style: normal; }
.command-line input { width: 100%; border: 0; outline: 0; color: white; background: transparent; caret-color: #67d6a6; font: 12px var(--mono); }
.command-submit { display: none; }
.command-suggestions { display: flex; align-items: center; gap: 7px; min-height: 53px; padding: 9px 18px; border-top: 1px solid #26332e; overflow-x: auto; color: #71837a; font: 10px var(--mono); }
.command-suggestions button { padding: 6px 9px; border: 1px solid #34443d; border-radius: 5px; color: #9db0a6; background: transparent; white-space: nowrap; font: 10px var(--mono); }
.command-suggestions button:hover { border-color: #65776e; color: white; }

.git-flow { margin-top: 25px; }
.repo-card { margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #faf9f3; }
.repo-heading { display: flex; justify-content: space-between; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.repo-heading strong { font-size: 12px; }
.repo-heading code { color: var(--green); font-size: 10px; }
.repo-facts { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px 7px; margin: 0; padding: 12px; font-size: 10px; }
.repo-facts dt { color: var(--muted); }
.repo-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-family: var(--mono); }
.safety-note { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; padding: 12px; border-radius: 8px; color: #3d5f52; background: var(--green-soft); font-size: 10px; line-height: 1.45; }
.safety-note strong { color: var(--green); font-size: 11px; }
.flow-zone { position: relative; display: grid; grid-template-columns: 25px 1fr; gap: 10px; padding: 15px 12px; border: 1px solid var(--line); border-radius: 9px; background: #faf9f3; transition: border .25s, background .25s; }
.flow-zone.active { border-color: var(--green); background: #f2fbf7; }
.zone-number { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 6px; color: var(--green); background: var(--green-soft); font: 11px var(--mono); }
.flow-zone strong { display: block; font-size: 12px; }
.flow-zone small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.file-chip, .empty-chip, .flow-zone > code, .commit-dot { grid-column: 2; margin-top: 9px; }
.file-chip { width: fit-content; padding: 5px 7px; border-radius: 4px; color: #8a4d2f; background: #fae6db; font: 9px var(--mono); }
.file-chip b { color: var(--orange); }
.empty-chip { color: #9ca39f; font: 10px var(--mono); }
.flow-zone > code { font-size: 9px; overflow-wrap: anywhere; }
.commit-dot { position: absolute; left: 17px; bottom: 17px; color: var(--green); font-size: 11px; }
.flow-arrow { padding: 8px 0 8px 22px; color: #a0a69f; font-size: 11px; }
.flow-arrow code { margin-left: 6px; color: var(--muted); font-size: 9px; }

.completion { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(10,18,15,.72); backdrop-filter: blur(5px); }
.completion[hidden] { display: none; }
.completion-card { max-width: 460px; padding: 42px; border-radius: 16px; text-align: center; background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.completion-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 22px; border-radius: 50%; color: white; background: var(--green); font-size: 25px; }
.completion-card h2 { margin: 0; font-size: 30px; }
.completion-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.completion-card button { margin-top: 10px; padding: 11px 18px; border: 0; border-radius: 7px; color: white; background: var(--ink); }
.completion-actions { display: flex; justify-content: center; gap: 8px; }
.completion-actions button + button { background: var(--green); }
.loading { display: grid; min-height: 70vh; place-items: center; color: var(--muted); font-size: 14px; }
.loading[hidden] { display: none; }
.loading.error { padding: 30px; color: #9a492c; text-align: center; }
.noscript-content { max-width: 760px; margin: 10vh auto; padding: 30px; }
.noscript-content h1 { font-size: 48px; }
.noscript-content p { color: var(--muted); font-size: 17px; line-height: 1.6; }

@media (min-width: 701px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  .topbar { flex: 0 0 68px; }
  main { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; width: 100%; margin: 0 auto; padding-top: 24px; padding-bottom: 24px; }
  .intro { flex: 0 0 auto; margin-bottom: 20px; }
  .workspace { flex: 1 1 auto; }
  h1 { font-size: clamp(30px, 3.2vw, 50px); }
  .lede { margin-top: 12px; font-size: 15px; line-height: 1.45; }
  .brief { padding-top: 16px; padding-bottom: 16px; }
}

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 250px 1fr; }
  .model-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  #repository-model { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
  .git-flow { display: grid; grid-template-columns: repeat(7, auto); align-items: center; gap: 7px; }
  .flow-arrow { padding: 0; transform: rotate(-90deg); text-align: center; }
  .flow-arrow code { display: none; }
}
@media (max-width: 700px) {
  body { min-width: 0; }
  .topbar { position: sticky; top: 0; z-index: 4; height: 56px; padding: 0 10px; gap: 8px; }
  .brand > span:last-child { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .lesson-progress { display: none; }
  .lesson-picker span { display: none; }
  .lesson-picker { min-width: 0; flex: 1; }
  .lesson-picker select { width: 100%; max-width: none; min-width: 0; padding-top: 9px; padding-bottom: 9px; }
  .quiet-button { flex: 0 0 auto; min-height: 40px; padding: 0 7px; }
  main { padding: 18px 10px 24px; }
  .intro { grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
  h1 { font-size: clamp(27px, 9vw, 36px); }
  .lede { margin-top: 12px; font-size: 14px; line-height: 1.45; }
  .brief { padding: 14px 16px; }
  .brief p { font-size: 13px; }
  .workspace { display: flex; flex-direction: column; overflow: visible; border-radius: 12px; scroll-margin-top: 56px; }
  .mobile-workspace-tabs { position: sticky; top: 56px; z-index: 3; display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .mobile-workspace-tabs button { min-height: 40px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 600; }
  .mobile-workspace-tabs button[aria-selected="true"] { color: white; background: var(--green); }
  .mobile-workspace-tabs span { grid-column: 1 / -1; padding: 4px 4px 0; color: var(--muted); text-align: center; font-size: 10px; }
  .workspace[data-mobile-view="terminal"] .mission-panel,
  .workspace[data-mobile-view="terminal"] .model-panel,
  .workspace[data-mobile-view="mission"] .terminal-workspace,
  .workspace[data-mobile-view="mission"] .model-panel,
  .workspace[data-mobile-view="model"] .mission-panel,
  .workspace[data-mobile-view="model"] .terminal-workspace { display: none; }
  .mission-panel, .model-panel { padding: 20px 18px; border: 0; }
  .mission-panel { border-right: 0; }
  .model-panel { border-left: 0; }
  .goal-list { margin-bottom: 0; }
  .terminal-workspace { height: calc(100dvh - 121px); min-height: 320px; }
  .terminal-workspace .terminal-panel { min-height: 0; }
  .terminal { min-height: 0; padding: 18px 14px; font-size: 12px; }
  .terminal-workspace.dual .terminal { min-height: 0; }
  .terminal-bar { height: 44px; padding: 0 12px; }
  .terminal-owner { margin-left: 9px; }
  .terminal-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .command-line { gap: 7px; padding: 10px 12px; border-top: 1px solid #26332e; }
  .command-line input { min-width: 0; font-size: 16px; }
  .command-submit { display: block; flex: 0 0 auto; min-width: 48px; min-height: 40px; border: 1px solid #426052; border-radius: 7px; color: #dff3e9; background: #1d332a; font: 12px var(--mono); }
  .command-suggestions { min-height: 58px; padding: 8px 12px; }
  .command-suggestions button { min-height: 40px; padding: 8px 11px; }
  .prompt span { display: none; }
  .git-flow { display: block; }
  .flow-arrow { padding: 8px 0 8px 22px; transform: none; text-align: left; }
  .flow-arrow code { display: inline; }
  .completion-card { width: 100%; padding: 30px 20px; }
  .completion-actions { flex-direction: column; }
  .completion-actions button { width: 100%; min-height: 46px; }
}
