:root {
  --color-black: #000000;
  --color-tan: #86745c;
  --color-light-tan: #c2baab;
  --color-dark-tan: #6a5c48;
  --color-white: #ffffff;
  --color-black-63: rgba(0, 0, 0, 0.63);
  --color-black-80: rgba(0, 0, 0, 0.8);
  --color-black-88: rgba(0, 0, 0, 0.88);
  --color-gold: #b19977;
  --color-accent: #b19977;
  --color-accent-light: #c2baab;
}
:root {
  --bg: #0b0a08; --surface: #15120e; --surface-2: #1d1913; --line: #3a3226;
  --ok: #8fe39a; --bad: #ff9a9a; --info: #8fd3ff; --focus: #f0d9a8;
  --font-ui: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "WildcatMono", "DejaVu Sans Mono", Consolas, "Courier New", monospace;
  color-scheme: dark;
}
@font-face { font-family: "WildcatMono"; src: url("fonts/DejaVuSansMono.ttf") format("truetype"); font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--color-white); font: 15px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 .75em; }
a { color: var(--color-gold); }
code, .mono { font-family: var(--font-mono); }
code { background: #000; color: #f0d9a8; padding: 1px 5px; border-radius: 3px; font-size: .92em; }
.muted { color: var(--color-light-tan); } .small { font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--color-gold); color: #000; padding: 8px 14px; border-radius: 4px; font-weight: 700; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* buttons */
.btn { font: inherit; font-weight: 600; min-height: 36px; padding: 6px 14px; border-radius: 6px; border: 2px solid var(--color-gold); background: transparent; color: var(--color-white); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.btn:hover:not(:disabled) { background: rgba(177,153,119,.22); }
.btn.primary { background: var(--color-gold); color: #000; }
.btn.primary:hover:not(:disabled) { background: var(--color-accent-light); }
.btn.secondary { background: var(--color-dark-tan); border-color: var(--color-tan); }
.btn.ghost { border-color: var(--color-tan); }
.btn.danger-ghost { border-color: var(--bad); color: var(--bad); }
.btn.danger { background: #7a1f1f; border-color: var(--bad); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn.big { min-height: 46px; font-size: 17px; padding: 8px 22px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.btn[role=button] { cursor: pointer; }

/* alerts, toasts, modal */
.alert { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--color-tan); border-left-width: 6px; background: var(--surface-2); margin: 0 0 10px; }
.alert.warn { border-color: #e0b04a; } .alert.info { border-color: var(--info); }
.alerts { padding: 0 12px; } .alerts:empty { display: none; } .alerts .alert { margin-top: 8px; }
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(460px, 92vw); }
.toast { background: #000; border: 2px solid var(--color-gold); border-radius: 8px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.6); }
.toast-x { margin-left: auto; background: none; border: none; color: var(--color-light-tan); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-backdrop { position: fixed; inset: 0; background: var(--color-black-80); z-index: 200; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 2px solid var(--color-gold); border-radius: 10px; width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 20px 22px; }
.modal.wide { width: min(860px, 100%); }
.modal h2 { color: var(--color-gold); font-size: 22px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.tool-frame { width: 100%; height: min(60vh, 520px); border: 2px solid var(--color-tan); border-radius: 6px; background: #16130f; }
.badge-modal { text-align: center; } .badge-modal ul { text-align: left; }

/* start screen */
.start { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); }
.start-hero { background: #000; padding: 48px 48px 32px; border-right: 4px solid var(--color-gold); display: flex; flex-direction: column; justify-content: center; }
.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-row p { margin: 0; } .school { color: var(--color-light-tan); font-size: 15px; } .course { color: var(--color-gold); font-weight: 700; }
.start-hero h1 { font-size: 40px; color: var(--color-gold); margin-bottom: 12px; max-width: 14em; }
.lede { font-size: 18px; max-width: 34em; color: var(--color-light-tan); }
.mission-preview { margin: 18px 0; padding: 0; list-style: none; counter-reset: m; max-width: 36em; }
.mission-preview li { counter-increment: m; display: flex; flex-direction: column; padding: 9px 14px 9px 54px; position: relative; border-left: 3px solid var(--color-tan); margin-bottom: 8px; background: var(--surface); }
.mission-preview li::before { content: counter(m); position: absolute; left: 14px; top: 9px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--color-gold); display: grid; place-items: center; color: var(--color-gold); font-weight: 700; }
.mp-title { font-weight: 700; } .mp-badge { color: var(--color-light-tan); font-size: 13px; }
.start-card { padding: 40px 44px; background: var(--surface); overflow: auto; align-self: stretch; }
.start-card.fatal { max-width: 640px; margin: 10vh auto; border: 2px solid var(--color-gold); border-radius: 10px; align-self: center; }
.start-card h2 { font-size: 22px; color: var(--color-gold); }
.field { margin-bottom: 14px; } .field label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], select { width: 100%; font: inherit; font-size: 17px; padding: 9px 12px; background: #000; color: #fff; border: 2px solid var(--color-tan); border-radius: 6px; }
input[aria-invalid=true] { border-color: var(--bad); }
.field-error { color: var(--bad); min-height: 1.4em; margin: 4px 0 0; font-weight: 600; } .field-error:not(:empty)::before { content: "\26a0  "; }
.resume-card { border: 2px solid var(--color-gold); border-radius: 8px; padding: 14px 16px; margin-bottom: 22px; background: #000; }
.save-note { border-left: 4px solid var(--color-gold); padding: 8px 12px; background: #000; margin-top: 18px; font-weight: 600; }

/* workspace */
.app { display: flex; flex-direction: column; height: 100vh; min-height: 560px; }
.app-header { display: flex; align-items: center; gap: 16px; padding: 6px 14px; background: #000; border-bottom: 3px solid var(--color-gold); min-height: 50px; }
.brand { display: flex; gap: 10px; align-items: center; } .brand p { margin: 0; line-height: 1.15; }
.brand-name { font-weight: 800; color: var(--color-gold); font-size: 17px; } .brand-sub { font-size: 12px; color: var(--color-light-tan); }
.header-mid { flex: 1; display: flex; align-items: center; gap: 12px; max-width: 460px; margin: 0 auto; }
.progress-text { white-space: nowrap; font-size: 13px; color: var(--color-light-tan); }
.progress { flex: 1; height: 12px; background: var(--surface-2); border: 1px solid var(--color-tan); border-radius: 8px; overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; background: var(--color-gold); transition: width .4s ease; }
.header-right { display: flex; align-items: center; gap: 12px; }
.student-chip { border: 1px solid var(--color-tan); border-radius: 20px; padding: 2px 12px; font-weight: 600; white-space: nowrap; }
.save-status { font-size: 13px; min-width: 150px; color: var(--color-light-tan); }
.save-status[data-state=saved] { color: var(--ok); } .save-status[data-state=dirty] { color: #f0d9a8; } .save-status[data-state=failed] { color: var(--bad); font-weight: 700; }
.strip { display: flex; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.mcard { flex: 1 1 0; min-width: 170px; display: flex; gap: 8px; align-items: center; text-align: left; font: inherit; color: #fff; background: #000; border: 2px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.mcard.current { border-color: var(--color-gold); background: var(--surface-2); }
.mcard.done { border-left: 6px solid var(--color-gold); } .mcard.repair { border-style: dashed; border-color: #e0b04a; }
.mcard:disabled { opacity: .55; cursor: not-allowed; }
.mc-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mc-num { font-size: 11px; color: var(--color-light-tan); } .mc-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .mc-status { font-size: 12px; color: var(--color-light-tan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px 12px; grid-template-columns: 340px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "panel editor preview"; grid-template-rows: minmax(0, 1fr); }
.app[data-layout=tabs] .workspace { grid-template-columns: 340px minmax(0, 1fr); grid-template-areas: "panel tabs" "panel pane"; grid-template-rows: auto minmax(0, 1fr); }
.panel { grid-area: panel; background: var(--surface); border: 1px solid var(--color-tan); border-radius: 8px; display: flex; flex-direction: column; min-height: 0; }
.ptabs, .tablist { display: flex; gap: 4px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
.ptab, .tablist button { font: inherit; font-weight: 600; background: transparent; color: var(--color-light-tan); border: 2px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; padding: 6px 12px; cursor: pointer; }
.ptab[aria-selected=true], .tablist button[aria-selected=true] { background: #000; color: #fff; border-color: var(--color-gold); }
.pbody { padding: 12px 14px; overflow: auto; flex: 1; min-height: 0; }
.m-title { font-size: 19px; color: var(--color-gold); }
.badge-pill { display: inline-block; border: 1px solid var(--color-gold); border-radius: 20px; padding: 2px 12px; font-weight: 600; font-size: 13px; }
.goal { font-weight: 600; }
.rich p, .rich ul { margin-bottom: .7em; } .rich ul { padding-left: 1.2em; }
.codeblock { background: #000; border: 1px solid var(--color-tan); border-left: 4px solid var(--color-gold); border-radius: 4px; padding: 8px 10px; overflow: auto; margin: 0 0 .8em; font-size: 13px; }
.codeblock code { background: none; padding: 0; color: #f0d9a8; white-space: pre; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.chk { border: 1px solid var(--line); border-left-width: 6px; border-radius: 6px; padding: 7px 10px; margin-bottom: 6px; background: #000; }
.chk.pass { border-left-color: var(--ok); } .chk.fail { border-left-color: var(--bad); } .chk.unchecked { border-left-color: var(--color-tan); }
.chk-state { display: block; font-size: 12px; font-weight: 700; } .chk.pass .chk-state { color: var(--ok); } .chk.fail .chk-state { color: var(--bad); } .chk.unchecked .chk-state { color: var(--color-light-tan); }
.chk-label { display: block; }
.why { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--color-tan); font-size: 14px; } .why p { margin-bottom: .4em; }
.check-summary { font-weight: 600; padding: 6px 0; } .check-summary:focus { outline: none; }
.earlier h3 { color: #e0b04a; }
.vocab dt { font-weight: 700; color: var(--color-gold); margin-top: 8px; } .vocab dd { margin: 0 0 4px; }
.hint { border: 1px solid var(--color-tan); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; background: #000; } .hint h4 { color: var(--color-gold); }
.hint-live { border-top: 1px dashed var(--color-tan); padding-top: 6px; }
.tool { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; background: #000; }
.gallery { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.gallery li { display: flex; gap: 10px; align-items: center; } .gallery li > div { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.gallery img { border: 1px solid var(--color-tan); border-radius: 4px; background: #fff; width: 96px; height: 72px; object-fit: cover; flex: none; }
.path { word-break: break-all; }
.tablist { display: none; grid-area: tabs; padding: 0; } .app[data-layout=tabs] .tablist { display: flex; }
.editor-pane, .preview-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border: 1px solid var(--color-tan); border-radius: 8px; padding: 8px; }
.editor-pane { grid-area: editor; } .preview-pane { grid-area: preview; }
.app[data-layout=tabs] .editor-pane, .app[data-layout=tabs] .preview-pane { grid-area: pane; }
.app[data-layout=tabs][data-tab=code] .preview-pane { display: none; } .app[data-layout=tabs][data-tab=preview] .editor-pane { display: none; }
.pane-title { font-size: 14px; color: var(--color-light-tan); margin: 0 0 6px; font-weight: 700; }
.editor-wrap { flex: 1; min-height: 0; border: 2px solid var(--color-tan); border-radius: 6px; overflow: hidden; }
.fake-browser { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 2px solid var(--color-tan); border-radius: 6px; overflow: hidden; background: #fff; }
.fake-tabstrip { background: #2b261e; padding: 6px 8px 0; }
.fake-tab { display: inline-flex; align-items: center; gap: 8px; max-width: 70%; background: #fff; color: #000; padding: 5px 14px; border-radius: 8px 8px 0 0; font-size: 13px; font-family: var(--font-ui); }
.fake-tab-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fake-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-gold); flex: none; }
.preview-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.preview-note { margin: 6px 0 0; min-height: 1.3em; }
.actionbar { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px 10px; background: #000; border-top: 3px solid var(--color-gold); flex-wrap: wrap; }
.act-main, .act-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* completion */
.completion { max-width: 900px; margin: 0 auto; padding: 32px 20px 56px; }
.celebrate { text-align: center; border: 2px solid var(--color-gold); border-radius: 12px; background: #000; padding: 26px 16px 20px; margin-bottom: 20px; }
.medal-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 14px; }
.medal-item { display: flex; flex-direction: column; align-items: center; width: 118px; font-size: 13px; font-weight: 600; text-align: center; }
.medal-item .medal { animation: pop .5s ease-out both; }
.medal-item:nth-child(2) .medal { animation-delay: .08s; } .medal-item:nth-child(3) .medal { animation-delay: .16s; } .medal-item:nth-child(4) .medal { animation-delay: .24s; } .medal-item:nth-child(5) .medal { animation-delay: .32s; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate h1 { font-size: 38px; color: var(--color-gold); margin-bottom: 6px; } .celebrate h1:focus { outline: none; }
.done-name { font-size: 28px; font-weight: 800; margin: 0; } .done-lab { color: var(--color-light-tan); margin: 4px 0; }
.summary-card, .downloads { background: var(--surface); border: 1px solid var(--color-tan); border-radius: 8px; padding: 16px 20px; margin-bottom: 18px; }
.summary-card h2 { color: var(--color-gold); font-size: 20px; }
.submit-note { font-size: 18px; font-weight: 700; border-left: 5px solid var(--color-gold); padding: 6px 12px; background: #000; }
.dl-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.dl-status { min-height: 1.4em; color: var(--ok); font-weight: 600; }
.mono { word-break: break-all; }
.recovery { padding: 0; list-style: none; } .recovery li { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 1100px) { .workspace { grid-template-columns: 300px minmax(0, 1fr) minmax(0, 1fr); } .header-mid { display: none; } }
@media (max-width: 900px) {
  .start { grid-template-columns: 1fr; } .start-hero { border-right: 0; border-bottom: 4px solid var(--color-gold); padding: 28px 22px; }
  .app { height: auto; } .workspace, .app[data-layout=tabs] .workspace { grid-template-columns: 1fr; grid-template-areas: "panel" "tabs" "pane"; grid-template-rows: auto; }
  .app .tablist { display: flex; } .editor-pane, .preview-pane { grid-area: pane; min-height: 420px; }
  .app .editor-pane { } .app[data-tab=code] .preview-pane { display: none; } .app[data-tab=preview] .editor-pane { display: none; }
  .panel { max-height: 50vh; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .chk, .btn, .mcard { border: 2px solid CanvasText; } }

/* teacher page */
.teacher { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; } .teacher h1 { color: var(--color-gold); }
.teacher section { background: var(--surface); border: 1px solid var(--color-tan); border-radius: 8px; padding: 14px 18px; margin-bottom: 18px; } .teacher h2 { color: var(--color-gold); font-size: 20px; }
.cfg { list-style: none; padding: 0; } .cfg li.good { color: var(--ok); } .cfg li.bad { color: var(--bad); }
.tbl-wrap { overflow: auto; } .tbl { border-collapse: collapse; width: 100%; font-size: 14px; } .tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; } .tbl th { background: #000; color: var(--color-gold); }
