/* PyQuest — freeCodeCamp-inspired: dark header, readable column, dark code panes, one accent. */
:root {
  --bg: #f5f6f7; --paper: #ffffff; --ink: #1b1b32; --muted: #5a5a72; --line: #d0d0d5;
  --header: #0a0a23; --header-ink: #f5f6f7;
  --accent: #f1be32; --accent-ink: #0a0a23; --accent-dark: #d9a318;
  --code-bg: #1b1b32; --code-ink: #dfdfe2; --code-line: #3b3b4f;
  --good: #1e7d32; --good-bg: #e8f5e9; --bad: #b3261e; --bad-bg: #fdecea;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; outline: none; width: 100%; }
a { color: #0f5ea8; }
code { font-family: var(--mono); font-size: .9em; background: #e9e9ef; padding: .08em .35em; border-radius: 3px; }
h1, h2, h3, h4 { line-height: 1.25; }
.spacer { flex: 1; }

/* header */
.topbar { background: var(--header); color: var(--header-ink); display: flex; align-items: center; gap: 1rem; padding: .55rem 1.25rem; position: sticky; top: 0; z-index: 10; }
.brand { color: var(--header-ink); text-decoration: none; font-weight: 700; font-size: 1.25rem; letter-spacing: .02em; display: flex; align-items: center; gap: .5rem; }
.brand-mark { font-family: var(--mono); color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 0 .35rem; font-size: .95rem; }
.topbar-course { color: #b8b8c8; font-size: .95rem; }
.py-status { font-size: .8rem; padding: .15rem .6rem; border-radius: 999px; border: 1px solid #3b3b4f; color: #dfdfe2; white-space: nowrap; }
.py-status.st-ready { border-color: #3f8f4f; color: #acd7b2; }
.py-status.st-busy, .py-status.st-loading { border-color: var(--accent); color: var(--accent); }
.py-status.st-error { border-color: #e57373; color: #ffb4ab; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem 2rem; }
.loading, .fatal { max-width: 46rem; margin: 3rem auto; padding: 0 1.25rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .95rem; font-weight: 600; padding: .45rem 1rem; border-radius: 4px; border: 2px solid var(--accent-dark); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, .btn-link:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid #198eee; outline-offset: 2px; }
.btn-ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-ghost:hover { background: #e4e4ea; }
.btn-ghost.danger { border-color: var(--bad); color: var(--bad); }
.btn-accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-accent:hover { background: #33334d; }
.btn-small { padding: .2rem .65rem; font-size: .85rem; }
.btn-big { font-size: 1.08rem; padding: .65rem 1.4rem; }
.btn-link { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

/* progress bars */
.bar { display: inline-block; width: 16rem; max-width: 100%; height: .75rem; background: #e0e0e6; border-radius: 999px; overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.small { width: 6rem; height: .5rem; }

/* home */
.home { max-width: 58rem; margin: 0 auto; padding: 1.5rem 1.25rem; }
.course-card { background: var(--paper); border: 1px solid var(--line); border-top: 6px solid var(--accent); border-radius: 6px; padding: 1.5rem 1.75rem; }
.course-card h1 { margin: .1rem 0 .5rem; font-size: 2rem; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--muted); font-weight: 700; }
.lead { font-size: 1.05rem; color: #33334d; margin-top: 0; }
.progress-line { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 1rem 0; }
.pct { color: var(--muted); font-size: .95rem; }
.cta-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cta-sub { color: var(--muted); font-size: .92rem; }
.done-banner { font-weight: 700; color: var(--good); }
.last-visited { font-size: .9rem; color: var(--muted); margin-bottom: 0; }
.modules h2, .progress-tools h2 { margin: 2rem 0 .75rem; font-size: 1.35rem; }
.module { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; margin-bottom: .6rem; }
.module > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 1rem; padding: .85rem 1rem; }
.module > summary::-webkit-details-marker { display: none; }
.mod-num { flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--header); color: #fff; display: grid; place-items: center; font-weight: 700; }
.module.complete .mod-num { background: var(--good); }
.mod-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mod-title { font-weight: 700; font-size: 1.05rem; }
.mod-summary { color: var(--muted); font-size: .9rem; }
.mod-prog { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.item-list { list-style: none; margin: 0; padding: 0 1rem .8rem 4.2rem; }
.item-list li a { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; color: var(--ink); text-decoration: none; }
.item-list li a:hover { text-decoration: underline; }
.tick { width: 1.3rem; text-align: center; color: #9a9aac; font-weight: 700; }
.tick.done { color: var(--good); }
.item-kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: .05rem .4rem; border-radius: 3px; background: #e9e9ef; color: var(--muted); min-width: 6.4rem; text-align: center; }
.kind-exercise { background: #fff3cd; color: #6b4e00; }
.kind-project { background: #dbe9ff; color: #0b3d80; }
.progress-tools { margin-top: 1rem; }
.tool-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.tool-msg { min-height: 1.4em; color: var(--good); }
.tool-msg.bad { color: var(--bad); }
.inventory { color: var(--muted); font-size: .85rem; margin-top: 2rem; }

/* lesson + prose */
.lesson { max-width: 46rem; margin: 0 auto; padding: 1.25rem 1.25rem 2rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.lesson h1, .ex-left h1 { font-size: 1.9rem; margin: .2rem 0 1rem; }
.badge { font-size: .8rem; vertical-align: middle; background: var(--good-bg); color: var(--good); border-radius: 999px; padding: .1rem .6rem; font-weight: 600; }
.prose { font-size: 1.05rem; }
.prose h2 { font-size: 1.4rem; margin: 2rem 0 .6rem; }
.prose h3 { font-size: 1.15rem; margin: 1.5rem 0 .4rem; }
.prose p, .prose li { max-width: 42rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.callout { background: #fff8e1; border-left: 5px solid var(--accent); padding: .7rem 1rem; margin: 1rem 0; border-radius: 0 4px 4px 0; }
pre.code-static, pre.sample-output { background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: .9rem; line-height: 1.5; padding: .8rem 1rem; border-radius: 5px; overflow-x: auto; }
pre.code-static code { background: none; padding: 0; color: inherit; font-size: inherit; }
pre.sample-output { background: #0a0a23; color: #c8e6c9; border-left: 4px solid #3f8f4f; }
.item-nav { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* runnable example */
.example { margin: 1.1rem 0; border: 1px solid var(--code-line); border-radius: 6px; overflow: hidden; background: var(--code-bg); }
.example-bar { display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; background: #2a2a40; color: #dfdfe2; font-size: .85rem; }
.example-bar .btn-ghost { color: #dfdfe2; border-color: #6b6b85; }
.example-bar .btn-ghost:hover { background: #3b3b4f; }
.example .console { border-radius: 0; border: 0; border-top: 1px solid var(--code-line); }
.solution { border-radius: 6px; overflow: hidden; margin-top: .8rem; }
.solution pre.code-static { margin: 0; border-radius: 0; }

/* editor */
.editor { display: flex; background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: .92rem; line-height: 1.5; height: 22rem; min-height: 8rem; resize: vertical; overflow: hidden; border-radius: 6px 6px 0 0; }
.editor-compact { border-radius: 0; resize: none; }
.ed-gutter { flex: none; padding: .6rem .5rem .6rem .8rem; color: #6b6b85; text-align: right; white-space: pre; user-select: none; overflow: hidden; min-width: 2.8rem; border-right: 1px solid var(--code-line); }
.ed-main { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-input { position: absolute; inset: 0; margin: 0; padding: .6rem .8rem; font: inherit; line-height: inherit; white-space: pre; overflow: auto; tab-size: 4; border: 0; letter-spacing: normal; word-spacing: normal; }
.ed-hl { pointer-events: none; color: var(--code-ink); overflow: hidden; }
.ed-hl code { font: inherit; background: none; padding: 0; color: inherit; }
.ed-input { background: transparent; color: transparent; caret-color: #fff; resize: none; outline: none; }
.ed-input::selection { background: rgba(120, 160, 255, .35); color: transparent; }
.ed-input:focus-visible { box-shadow: inset 0 0 0 2px #198eee; }
.tok-kw { color: #ff9ac1; } .tok-bi { color: #8bd5ff; } .tok-str { color: #c3e88d; } .tok-num { color: #f78c6c; } .tok-com { color: #8a8aa3; font-style: italic; } .tok-fn { color: #ffd479; }

/* console */
.console { background: #0a0a23; color: #dfdfe2; border-radius: 0 0 6px 6px; border: 1px solid var(--code-line); border-top: 0; }
.console-head { display: flex; justify-content: space-between; padding: .3rem .8rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #8a8aa3; border-bottom: 1px solid #22223a; }
.console-body { margin: 0; padding: .6rem .8rem; font-family: var(--mono); font-size: .9rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; min-height: 4.5rem; max-height: 22rem; overflow: auto; }
.console-body .err { color: #ffb4ab; }
.console-body .note.muted { color: #8a8aa3; font-style: italic; }
.console-body .note.bad { color: #ffb4ab; font-weight: 700; }
.console-input { display: flex; align-items: center; gap: .5rem; padding: .4rem .8rem .7rem; flex-wrap: wrap; }
.ci-prompt { font-family: var(--mono); color: var(--accent); white-space: pre-wrap; }
.ci-field { flex: 1; min-width: 8rem; font-family: var(--mono); font-size: .9rem; background: #1b1b32; color: #fff; border: 1px solid var(--accent); border-radius: 3px; padding: .3rem .5rem; }
.console-input .btn-ghost { color: #dfdfe2; border-color: #6b6b85; }

/* exercise */
.exercise { max-width: 86rem; margin: 0 auto; padding: 1.25rem; }
.ex-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.5rem; align-items: start; }
.ex-left { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem 1.4rem; }
.ex-right { position: sticky; top: 3.6rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.saved-note { font-size: .8rem; color: var(--muted); }
h2.sub { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.tests { list-style: none; padding: 0; margin: 0; }
.test { display: flex; gap: .6rem; padding: .45rem .6rem; border-radius: 4px; margin-bottom: .3rem; background: #f0f0f4; }
.test .t-icon { font-weight: 700; width: 1.1rem; text-align: center; }
.test .t-body { display: flex; flex-direction: column; }
.test .t-msg { font-size: .9rem; color: var(--bad); }
.test.pass { background: var(--good-bg); } .test.pass .t-icon { color: var(--good); }
.test.fail { background: var(--bad-bg); } .test.fail .t-icon { color: var(--bad); }
.result-banner { margin-top: .8rem; padding: .7rem 1rem; border-radius: 5px; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.result-banner.good { background: var(--good-bg); border: 1px solid #a5d6a7; }
.result-banner.bad { background: var(--bad-bg); border: 1px solid #f5b7b1; }
.hints { padding-left: 1.4rem; margin: 0 0 .6rem; }
.hints li { background: #fff8e1; padding: .4rem .7rem; border-radius: 4px; margin-bottom: .4rem; }
.help-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.confirm-box { margin-top: .8rem; background: #fff8e1; border: 1px solid #f0d58c; padding: .8rem 1rem; border-radius: 5px; }
.confirm-box p { margin-top: 0; }

/* narrow screens: stack */
@media (max-width: 960px) {
  .ex-grid { grid-template-columns: 1fr; }
  .ex-right { position: static; }
}
@media (max-width: 640px) {
  html { font-size: 16px; }
  .topbar-course { display: none; }
  .course-card { padding: 1.1rem; }
  .module > summary { flex-wrap: wrap; }
  .mod-prog { flex-direction: row; align-items: center; width: 100%; padding-left: 3.2rem; }
  .item-list { padding-left: 1rem; }
  .item-kind { min-width: 0; }
  .editor { height: 18rem; }
}
