/* QuestCode Academy — styles. Dark "night coding" look of the original app,
   tidied: one spacing scale, 44 px touch targets, visible focus, phone
   layout with tabs and a bottom dock. Written for old Safari too: no flex
   gap, no inset, vh fallbacks before dvh. */
:root {
  --bg: #0e0b1a; --bg2: #15112a; --panel: #1b1633; --panel2: #221b40; --panel3: #2b2352;
  --accent: #6a5ae0; --accent-d: #5646c8; --accent2: #b9afff; --text: #efebff; --muted: #a9a1d3;
  --ok: #5fd06b; --no: #ff7a90; --gold: #ffd23f; --line: #332b60; --code: #0c0a1b;
  --c: var(--accent); --top: 56px; --tabs: 48px; --dockh: 64px; --r: 14px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior-y: none; }
body { margin: 0; min-height: 100vh; background: var(--bg); background: radial-gradient(1100px 560px at 50% -12%, #251b52, transparent 70%), var(--bg); color: var(--text); font: 16px/1.55 var(--sans); }
a { color: var(--accent2); }
a:hover { color: #fff; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: 3px solid var(--gold); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
code { font-family: var(--mono); font-size: .92em; background: rgba(185, 175, 255, .12); color: #e7e2ff; padding: .08em .35em; border-radius: 5px; }
pre { font-family: var(--mono); }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; }

/* ── header ─────────────────────────────────────────────────────────── */
.qc-top { position: -webkit-sticky; position: sticky; top: 0; z-index: 40; display: flex; align-items: center; height: var(--top); padding: 0 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right));
  background: rgba(14, 11, 26, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.qc-top > * + * { margin-left: 10px; }
.qc-top .oxf-back { flex: none; }
.qc-logo { display: flex; align-items: center; text-decoration: none; color: var(--text); font: bold 18px var(--head); white-space: nowrap; }
.qc-logo .mark { width: 32px; height: 32px; display: inline-grid; place-items: center; margin-right: 8px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #3ce8a0); font-size: 17px; }
.qc-logo b { color: var(--accent2); }
.qc-nav { display: flex; }
.qc-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.qc-nav a + a { margin-left: 4px; }
.qc-nav a:hover { color: var(--text); background: var(--panel); }
.qc-nav a[aria-current] { color: #fff; background: var(--panel2); }
.qc-sp { flex: 1; }
.qc-iconbtn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 16px; padding: 0 10px; }
.qc-iconbtn:hover { border-color: var(--accent); }
.qc-iconbtn kbd { font: 11px var(--mono); color: var(--muted); margin-left: 6px; }
.qc-status { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.qc-status .qc-st-t { margin-left: 6px; }
.qc-st-saved { color: var(--ok); }
.qc-st-offline, .qc-st-denied { color: var(--gold); border-color: rgba(255, 210, 63, .35); }
.qc-user { display: inline-flex; align-items: center; white-space: nowrap; font-size: 14px; }
.qc-ava { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; }
.qc-uname { margin-left: 8px; font-weight: 600; }
.qc-uexp { margin-left: 8px; color: var(--gold); font-weight: 700; font-size: 13px; }
.qc-login { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; }
@media (max-width: 1100px) {
  /* four menu items: icons only, the names stay for screen readers */
  .qc-nav .t { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .qc-nav a { padding: 0 10px; font-size: 18px; }
  .qc-iconbtn kbd { display: none; }
}
@media (max-width: 900px) { .qc-logo .t { display: none; } }
@media (max-width: 760px) {
  .qc-logo .t, .qc-uname, .qc-uexp, .qc-status .qc-st-t, .qc-iconbtn kbd { display: none; }
  .qc-top > * + * { margin-left: 6px; }
  .qc-top { padding: 0 8px; }
}
/* phones: only what fits in one row (the Map icon is the way home; sound is on the home page) */
@media (max-width: 560px) {
  .qc-logo, #qc-sound { display: none; }
  .qc-nav a { padding: 0 8px; min-width: 40px; justify-content: center; }
  .qc-nav a + a { margin-left: 2px; }
  .qc-top .oxf-back { padding: 8px 10px; }
  .qc-top .oxf-back span { display: none; }
  .qc-top .oxf-back svg { margin: 0; }
}
@media (max-width: 400px) {
  #qc-search { display: none; }
  .qc-nav a { padding: 0 6px; min-width: 38px; }
}
@media (max-width: 380px) { .qc-ptabs button span[aria-hidden] { display: none; } }
/* phones: course cards with the icon beside the text (half the height) */
@media (max-width: 560px) {
  .qc-course { display: -ms-grid; display: grid; grid-template-columns: 56px 1fr; grid-column-gap: 14px; align-items: start; padding: 16px; }
  .qc-course .qc-course-ico { margin: 0; grid-row: 1 / span 3; }
  .qc-course-t, .qc-course .qc-bar, .qc-course-n { grid-column: 2; }
  .qc-course-t { margin-bottom: 10px; }
}
.sr-only-focus:focus, a.sr-only:focus { position: fixed; top: 8px; left: 8px; z-index: 200; width: auto; height: auto; clip: auto; margin: 0; padding: 10px 14px; background: var(--accent); color: #fff; border-radius: 10px; }

/* ── layout ─────────────────────────────────────────────────────────── */
/* main itself has no padding at all (the level fills it edge to edge); the
   other pages put their content in .qc-page */
main { display: block; min-height: calc(100vh - var(--top)); margin: 0; padding: 0; }
.qc-page { max-width: 1180px; margin: 0 auto; padding: 24px 18px 56px; padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
.qc-page > h1, .qc-chead h1, .qc-hero h1 { margin: 0 0 6px; font-size: 30px; font-size: clamp(26px, 5vw, 36px); }
.qc-sub { color: var(--muted); margin: 0 0 6px; }
.qc-h2 { font-size: 20px; margin: 30px 0 12px; }
.qc-small { color: var(--muted); font-size: 14px; }
.qc-crumbs { margin: 0 0 14px; }
.qc-crumbs a { text-decoration: none; font-weight: 600; }
.qc-foot { text-align: center; color: #6e679a; font-size: 12px; padding: 14px 10px 26px; }
.qc-loading, .qc-error { padding: 60px 10px; text-align: center; color: var(--muted); }
.qc-spin { display: inline-block; width: 22px; height: 22px; vertical-align: -5px; margin-right: 8px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: qcspin .8s linear infinite; }
@keyframes qcspin { to { transform: rotate(360deg); } }

/* buttons */
.qc-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s, transform .1s; }
.qc-btn > span[aria-hidden] { margin-right: 6px; }
.qc-btn:hover { border-color: var(--accent); color: #fff; }
.qc-btn:active { transform: translateY(1px); }
.qc-btn[disabled] { opacity: .55; cursor: default; transform: none; }
.qc-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.qc-btn-primary:hover { background: var(--accent-d); }
.qc-btn-run { background: #183a26; border-color: #2c6a43; color: #b9f5c6; }
.qc-btn-run:hover { border-color: var(--ok); }
.qc-btn-ghost { background: transparent; }
.qc-btn-danger { background: #4a1b27; border-color: #8e3248; color: #ffd2db; }
.qc-btn-lg { min-height: 52px; font-size: 17px; padding: 0 24px; }
.qc-btn-sm { min-height: 40px; font-size: 14px; padding: 0 14px; }

/* ── home ───────────────────────────────────────────────────────────── */
.qc-hero { display: grid; grid-template-columns: 1fr; grid-gap: 18px; align-items: center; padding: 6px 0 4px; }
@media (min-width: 860px) { .qc-hero { grid-template-columns: 1.2fr 1fr; } }
.qc-continue { display: flex; align-items: center; padding: 18px; border-radius: 18px; text-decoration: none; color: var(--text); background: linear-gradient(135deg, var(--panel2), var(--panel)); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0, 0, 0, .35); position: relative; overflow: hidden; }
.qc-continue::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.qc-continue:hover { border-color: var(--c); color: var(--text); }
.qc-cont-ico { font-size: 34px; width: 60px; height: 60px; flex: none; display: grid; place-items: center; background: var(--bg); border-radius: 14px; margin-right: 14px; }
.qc-cont-t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.qc-cont-k { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; }
.qc-cont-t b { font-size: 20px; line-height: 1.25; }
.qc-cont-s { color: var(--muted); font-size: 14px; }
.qc-cont-go { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 22px; margin-left: 10px; }
.qc-offer { display: flex; flex-wrap: wrap; align-items: center; margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: #2a2148; border: 1px solid #4b3f86; }
.qc-offer > span { font-size: 22px; margin-right: 10px; }
.qc-offer p { flex: 1 1 260px; margin: 4px 10px 4px 0; }
.qc-offer .qc-btn { margin: 4px 8px 4px 0; }
.qc-offer-info { background: #1d2440; border-color: #33427a; }
.qc-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-gap: 16px; }
.qc-course { display: flex; flex-direction: column; padding: 18px; border-radius: 18px; text-decoration: none; color: var(--text); background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); position: relative; overflow: hidden; transition: transform .15s, border-color .15s; }
.qc-course::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--c); }
.qc-course:hover { transform: translateY(-3px); border-color: var(--c); color: var(--text); }
.qc-course-ico { font-size: 32px; width: 56px; height: 56px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; flex: none; }
.qc-course-t { display: flex; flex-direction: column; margin-bottom: 14px; flex: 1; }
.qc-course-t b { font-size: 20px; }
.qc-course-t span { color: var(--muted); font-size: 14px; }
.qc-course-n { color: var(--muted); font-size: 13px; margin-top: 8px; display: block; }
.qc-bar { display: block; height: 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.qc-bar i { display: block; height: 100%; background: var(--c); border-radius: 6px; transition: width .5s; }
.qc-bar-lg { height: 10px; max-width: 420px; margin-top: 10px; }
.qc-extras { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); grid-gap: 12px; margin-top: 26px; }
.qc-extra { display: flex; align-items: center; text-align: left; padding: 14px; min-height: 64px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.qc-extra > span { font-size: 26px; margin-right: 12px; }
.qc-extra div { display: flex; flex-direction: column; }
.qc-extra div span { color: var(--muted); font-size: 13px; }
a.qc-extra:hover, button.qc-extra:hover { border-color: var(--accent); color: var(--text); }

/* ── course map ─────────────────────────────────────────────────────── */
.qc-chead { display: flex; flex-wrap: wrap; align-items: center; padding: 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 18px; }
.qc-chead .qc-course-ico { margin: 0 16px 0 0; }
.qc-chead > div { flex: 1 1 240px; }
.qc-chead .qc-btn { margin-top: 10px; }
.qc-chapter { margin: 0 0 22px; }
.qc-ch-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 8px; }
.qc-ch-head h2 { font-size: 19px; margin: 0; }
.qc-ch-n { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--c); }
.qc-ch-p { color: var(--muted); font-weight: 700; }
/* a chapter's difficulty and the reward for finishing it */
.qc-ch-meta { display: flex; flex-wrap: wrap; align-items: center; margin: 2px 0 4px -8px; }
.qc-ch-meta > * { margin: 0 0 6px 8px; }
.qc-diff { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.qc-diff > span { color: var(--gold); letter-spacing: 1px; margin-right: 6px; }
.qc-diff i { color: #4c4478; font-style: normal; }
.qc-ch-prize { display: inline-flex; align-items: center; flex-wrap: wrap; padding: 3px 10px; border-radius: 999px; background: rgba(255, 210, 63, .08); border: 1px dashed rgba(255, 210, 63, .45); color: #ffe7a3; font-size: 13px; font-weight: 600; }
.qc-ch-prize .qc-small { margin-left: 4px; font-size: 12px; }
.qc-ch-prize.got { border-style: solid; border-color: rgba(95, 208, 107, .5); background: rgba(95, 208, 107, .1); color: #c8f6cf; }
/* home: the way into the Studio */
.qc-studio-cta { display: grid; grid-template-columns: 1fr; grid-gap: 12px; }
@media (min-width: 760px) { .qc-studio-cta { grid-template-columns: 1.6fr 1fr; } }
.qc-scard { display: flex; align-items: center; padding: 16px 18px; min-height: 84px; border-radius: 18px; text-decoration: none; color: var(--text); background: linear-gradient(135deg, #1c2a3f, var(--panel)); border: 1px solid var(--line); position: relative; overflow: hidden; }
.qc-scard-main { background: linear-gradient(135deg, #1d3a3a, #1b1f3d 60%, var(--panel)); border-color: #2d5a5a; }
.qc-scard:hover { border-color: #3ce8a0; color: var(--text); }
.qc-scard-i { flex: none; width: 54px; height: 54px; display: grid; place-items: center; margin-right: 14px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); font-size: 28px; }
.qc-scard-t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.qc-scard-t b { font-size: 18px; }
.qc-scard-t span { color: var(--muted); font-size: 14px; }
.qc-scard .qc-cont-go { background: #2a9d74; }
.qc-levels { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); grid-gap: 10px; }
.qc-lv { display: flex; align-items: center; padding: 10px 12px; min-height: 64px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); text-decoration: none; position: relative; }
a.qc-lv:hover { border-color: var(--c); color: var(--text); }
.qc-lv-n { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; margin-right: 10px; background: var(--bg); border: 2px solid var(--line); font-weight: 700; }
.qc-lv-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.qc-lv-t b { font-size: 15px; line-height: 1.25; }
.qc-lv-m { font-size: 12px; color: var(--muted); }
.qc-lv-done .qc-lv-n { background: var(--ok); border-color: var(--ok); color: #053a12; }
.qc-lv-current { border-color: var(--c); box-shadow: 0 0 0 2px var(--c) inset; }
.qc-lv-current .qc-lv-n { background: var(--c); border-color: var(--c); color: #160f2e; }
.qc-lv-locked { opacity: .55; cursor: not-allowed; }
.qc-lt-bughunt .qc-lv-n { border-color: #ff9f7a; }
.qc-lt-project .qc-lv-n { border-color: var(--gold); }
.qc-stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; margin-left: 6px; flex: none; }
.qc-stars i { color: #4c4478; font-style: normal; }

/* trophies */
.qc-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-gap: 14px; margin-top: 16px; }
.qc-badge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); opacity: .6; }
.qc-badge.got { opacity: 1; border-color: var(--accent); box-shadow: 0 8px 22px rgba(123, 108, 240, .22); }
.qc-badge-i { font-size: 40px; margin-bottom: 8px; }
.qc-badge span { color: var(--muted); font-size: 13px; }

/* ── level ──────────────────────────────────────────────────────────── */
body.qc-in-level main, main[data-tab] { max-width: none; padding: 0; }
body.qc-in-level .qc-foot { display: none; }
.qc-ptabs { display: none; }
.qc-dock { display: none; }
.qc-level { display: grid; grid-template-columns: minmax(330px, .82fr) minmax(0, 1.18fr); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); }
.qc-p-lesson { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 18px 22px 40px; border-right: 1px solid var(--line); background: linear-gradient(180deg, var(--panel), var(--bg2)); }
.qc-work { display: -ms-grid; display: grid; grid-template-rows: minmax(220px, 1.05fr) minmax(180px, .95fr); min-height: 0; min-width: 0; }
.qc-p-code { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.qc-edhead { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 14px; background: #0a0816; border-bottom: 1px solid var(--line); }
.qc-file { font: 13px var(--mono); color: var(--muted); }
.qc-edtools { display: flex; }
.qc-icon { min-width: 40px; min-height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.qc-icon + .qc-icon { margin-left: 2px; }
.qc-icon:hover { color: #fff; border-color: var(--line); background: var(--panel); }
.qc-ed { flex: 1; min-height: 160px; position: relative; }
.qc-actions { display: flex; justify-content: flex-end; padding: 8px 10px; background: #0a0816; border-top: 1px solid var(--line); }
.qc-actions .qc-btn + .qc-btn { margin-left: 8px; }
.qc-outwrap { display: flex; flex-direction: column; min-height: 0; border-top: 2px solid var(--line); background: #08070f; }
.qc-otabs { display: flex; background: #0a0816; border-bottom: 1px solid var(--line); padding: 0 6px; }
.qc-otabs button { min-height: 42px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 700; font-size: 14px; }
.qc-otabs button[aria-selected=true] { color: #fff; border-bottom-color: var(--accent); }
.qc-dbg-n { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 10px; background: var(--no); color: #2a0610; font-size: 12px; margin-left: 4px; }
.qc-p-output, .qc-p-debug { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
main[data-out=output] .qc-p-debug, main[data-out=debug] .qc-p-output { display: none; }
.qc-out-head { display: none; }
.qc-p-output { display: flex; flex-direction: column; }
.qc-preview { flex: 1 1 auto; min-height: 200px; display: flex; flex-direction: column; }
.qc-preview iframe { display: block; width: 100%; flex: 1 1 auto; height: 100%; min-height: 200px; border: 0; background: #fff; }
.qc-preview:not([hidden]) + .qc-console:not([hidden]) { flex: 0 0 auto; max-height: 40%; overflow: auto; }
.qc-console { padding: 10px 14px 16px; font: 14px/1.55 var(--mono); }
.qc-preview + .qc-console:not(:empty) { border-top: 1px solid var(--line); background: #08070f; }
.qc-log { white-space: pre-wrap; word-break: break-word; color: #b8f3c4; padding: 1px 0; }
.qc-log-error { color: #ffb0bd; }
.qc-log-warn { color: #ffe28a; }
.qc-log-info { color: var(--muted); font-style: italic; }
.qc-pyout { margin: 0; white-space: pre-wrap; word-break: break-word; color: #b8f3c4; font: 14px/1.55 var(--mono); }
.qc-empty { padding: 24px 16px; color: #8b84b6; text-align: center; font-family: var(--sans); background: #08070f; min-height: 100%; }
.qc-preview .qc-empty { min-height: 160px; }
.qc-input-box { padding: 10px 14px; border-top: 1px solid var(--line); }
.qc-input-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.qc-input-box textarea { width: 100%; font: 16px/1.5 var(--mono); background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); resize: vertical; }
main.qc-stale .qc-p-output, main.qc-stale .qc-p-debug { opacity: .75; }

/* lesson panel */
.qc-back { display: inline-block; margin-bottom: 10px; font-weight: 600; text-decoration: none; }
.qc-badges-row { display: flex; flex-wrap: wrap; margin: 0 0 8px -6px; }
.qc-tag { display: inline-flex; align-items: center; margin: 0 0 6px 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #160f2e; }
.qc-tag-lesson, .qc-tag-plain { background: var(--panel3); color: var(--text); }
.qc-tag-exercise { background: #1f4a5a; color: #c8f1ff; }
.qc-tag-bughunt { background: #5a2b1f; color: #ffd7c8; }
.qc-tag-project { background: #5a4a14; color: #fff1b8; }
.qc-tag-done { background: #1d4a27; color: #c6f5cf; }
.qc-lhead h1 { font-size: 27px; font-size: clamp(24px, 4vw, 30px); margin: 4px 0 6px; }
.qc-sec { margin: 18px 0 0; }
.qc-sec h2 { font-size: 17px; margin: 0 0 8px; color: #fff; }
.qc-sec h2 span { margin-right: 4px; }
.qc-sec p { margin: 0 0 10px; }
.qc-analogy { background: rgba(255, 210, 63, .08); border-left: 3px solid var(--gold); padding: 10px 12px; border-radius: 10px; }
.qc-anat { background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.qc-anat-code { font: 17px/1.8 var(--mono); word-break: break-all; margin-bottom: 8px; }
.qc-anat-list { margin: 0; padding-left: 22px; font-size: 15px; }
.qc-anat-list li { margin: 4px 0; }
.qc-ap { border-radius: 5px; padding: 1px 2px; font-family: var(--mono); white-space: pre-wrap; }
.qc-ap0 { background: #4a2a72; color: #e8d6ff; } .qc-ap1 { background: #1d4a6a; color: #cdeaff; } .qc-ap2 { background: #5e4214; color: #ffe7b0; }
.qc-ap3 { background: #1d5232; color: #c9f7d6; } .qc-ap4 { background: #6a2238; color: #ffd0dd; } .qc-ap5 { background: #3a3a3a; color: #eee; }
.qc-ex { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code); }
.qc-ex-code { margin: 0; padding: 10px 0; overflow-x: auto; font-size: 14.5px; line-height: 1.6; }
.qc-ex-ln { display: inline-block; min-width: 100%; padding-right: 12px; }
.qc-ex-n { display: inline-block; width: 2.4em; padding-right: .8em; text-align: right; color: #5d5788; user-select: none; -webkit-user-select: none; }
.qc-ex-notes { margin: 0; padding: 10px 14px 10px 30px; border-top: 1px solid var(--line); background: #110e24; font-size: 14.5px; }
.qc-ex-notes li { margin: 4px 0; }
.qc-ex-out { border-top: 1px solid var(--line); background: #fff; }
.qc-ex-out iframe, .qc-try-out iframe { display: block; width: 100%; height: 170px; border: 0; background: #fff; }
.qc-ex-cons { border-top: 1px solid var(--line); padding: 8px 14px; }
.qc-ex-cons span, .qc-wr span, .qc-expect span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.qc-ex-cons pre { margin: 0; color: #b8f3c4; white-space: pre-wrap; }
.qc-example .qc-btn { margin-top: 10px; }
.qc-try { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.qc-try-ed { height: 180px; position: relative; }
.qc-try-bar { display: flex; align-items: center; padding: 8px 10px; background: #0a0816; border-top: 1px solid var(--line); }
.qc-try-bar .qc-small { margin-left: 10px; font-size: 13px; }
.qc-try-out { background: #08070f; max-height: 240px; overflow: auto; padding: 0; }
.qc-try-out .qc-log, .qc-try-out .qc-pyout { padding: 2px 12px; }
.qc-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; }
.qc-steps li { position: relative; padding: 8px 10px 8px 46px; margin: 0 0 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; counter-increment: s; }
.qc-steps li::before { content: counter(s); position: absolute; left: 10px; top: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #160f2e; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.qc-reward { color: var(--muted); font-size: 14px; }
.qc-reward b { color: var(--gold); }
.qc-hint { background: #2a2148; border: 1px solid #4b3f86; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.qc-hint b { color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.qc-hint p { margin: 4px 0 0; }
#qc-hints .qc-btn { margin: 0 8px 8px 0; }
.qc-mistakes summary { cursor: pointer; list-style: none; }
.qc-mistakes summary::-webkit-details-marker { display: none; }
.qc-mistakes summary h2 { display: inline; }
.qc-mistakes summary::after { content: " ▾"; color: var(--muted); }
.qc-mistakes[open] summary::after { content: " ▴"; }
.qc-recap ul { margin: 0; padding-left: 20px; }
.qc-recap li { margin: 4px 0; }

/* debug panel */
.qc-p-debug { padding: 12px 14px 24px; }
.qc-dbg-status { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 15.5px; }
.qc-dbg-ok { background: rgba(95, 208, 107, .14); border: 1px solid rgba(95, 208, 107, .4); color: #c8f6cf; }
.qc-dbg-bad { background: rgba(255, 122, 144, .12); border: 1px solid rgba(255, 122, 144, .35); color: #ffd1da; }
.qc-dbg-todo { background: rgba(185, 175, 255, .1); border: 1px solid var(--line); }
.qc-dbg-note { font-size: 14px; color: var(--muted); }
.qc-prob { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--no); }
.qc-prob-warn { border-left-color: var(--gold); }
.qc-prob h3 { font-size: 16px; margin: 0 0 6px; }
.qc-prob p { margin: 0 0 6px; }
.qc-why, .qc-fix { font-size: 15px; }
.qc-chip { display: inline-block; font: 600 12px var(--mono); padding: 2px 8px; border-radius: 999px; background: var(--panel3); color: var(--accent2); text-decoration: none; vertical-align: 1px; }
a.qc-chip:hover { background: var(--accent); color: #fff; }
.qc-wr, .qc-expect { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 8px; margin: 8px 0; }
@media (max-width: 520px) { .qc-wr, .qc-expect { grid-template-columns: 1fr; } }
.qc-wr pre, .qc-expect pre { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--code); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.qc-wr > div:first-child pre { border: 1px solid rgba(255, 122, 144, .4); }
.qc-wr > div:last-child pre { border: 1px solid rgba(95, 208, 107, .45); }
.qc-req-h { font-size: 15px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.qc-req { list-style: none; margin: 0; padding: 0; }
.qc-req li { display: flex; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qc-req-i { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; margin-right: 10px; font-weight: 800; font-size: 14px; }
.qc-req li.ok .qc-req-i { background: var(--ok); color: #053a12; }
.qc-req li.no .qc-req-i { background: var(--no); color: #3a0613; }
.qc-req li.wait .qc-req-i { border: 2px solid var(--line); color: var(--muted); }
.qc-req-hint { display: block; color: #ffd1da; font-size: 14px; margin-top: 2px; }
.qc-req li.ok { color: #d6f7dc; }

/* code colours (editor, examples, anatomy) */
.t-com { color: #8a84b8; font-style: italic; }
.t-str { color: #a8e6a1; }
.t-num { color: #f9b46b; }
.t-kw { color: #d0a2ff; }
.t-fn { color: #8fb6ff; }
.t-tag { color: #ff8aa0; }
.t-attr { color: #ffd27f; }
.t-prop { color: #8fe1ff; }
.t-sel { color: #ffd27f; }
.t-val { color: #f3efff; }
.t-punc { color: #b9b2e3; }

/* ── the editor ─────────────────────────────────────────────────────── */
.qce { --qce-fs: 15px; --qce-lh: calc(var(--qce-fs) * 1.6); --qce-pad: 12px; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--code); }
.qc-try-ed .qce { position: absolute; }
.qce-scroll { position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.qce-inner { display: flex; min-height: 100%; min-width: 100%; width: -webkit-max-content; width: max-content; }
.qce-gutter { position: -webkit-sticky; position: sticky; left: 0; z-index: 2; flex: none; min-width: 2.8em; padding: var(--qce-pad) 8px var(--qce-pad) 8px; text-align: right; color: #5d5788; background: #0f0c22; border-right: 1px solid #221c42; font: var(--qce-fs)/var(--qce-lh) var(--mono); -webkit-user-select: none; user-select: none; }
.qce-gutter span { display: block; }
.qce-gutter .qce-err { color: var(--no); font-weight: 800; }
.qce-gutter .qce-warn { color: var(--gold); font-weight: 800; }
.qce-code { position: relative; flex: 1 0 auto; }
.qce-hl, .qce-ta { margin: 0; padding: var(--qce-pad) 20px var(--qce-pad) 12px; font-family: var(--mono); font-size: var(--qce-fs); line-height: var(--qce-lh); tab-size: 4; -moz-tab-size: 4; white-space: pre; word-wrap: normal; overflow-wrap: normal; letter-spacing: 0; font-variant-ligatures: none; font-kerning: none; border: 0; }
.qce-hl { min-height: 100%; color: #ece8ff; pointer-events: none; }
.qce-hl code { font: inherit; background: none; padding: 0; color: inherit; }
.qce-ta { position: absolute; top: 0; left: 0; width: 100%; height: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: #fff; outline: none; z-index: 1; border-radius: 0; -webkit-appearance: none; appearance: none; }
.qce-ta::selection { background: rgba(123, 108, 240, .5); }
/* the empty editor's hint: the textarea's own text is see-through (the
   colours are drawn underneath), so its placeholder needs its own colour */
.qce-ta::placeholder { color: #8e86bd; -webkit-text-fill-color: #8e86bd; opacity: 1; font-family: var(--sans); font-style: italic; }
.qce-ta::-webkit-input-placeholder { color: #8e86bd; -webkit-text-fill-color: #8e86bd; opacity: 1; }
.qce-ta::-moz-selection { background: rgba(123, 108, 240, .5); }
.qce-marks { position: absolute; top: 0; left: 0; right: 0; }
.qce-mark { position: absolute; left: 0; right: 0; height: var(--qce-lh); background: rgba(255, 122, 144, .16); box-shadow: inset 3px 0 0 var(--no); }
.qce-mark-warn { background: rgba(255, 210, 63, .1); box-shadow: inset 3px 0 0 var(--gold); }
.qce.qce-focus { box-shadow: inset 0 0 0 2px rgba(123, 108, 240, .7); }
.qce-ro .qce-ta { caret-color: transparent; }

/* ── dialogs, celebration, toasts ───────────────────────────────────── */
.qc-modal-back { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 4, 16, .72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.qc-modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--accent); border-radius: 18px; padding: 20px; box-shadow: 0 30px 70px rgba(0, 0, 0, .55); }
.qc-modal-wide { max-width: 720px; }
.qc-modal h2 { margin: 0 0 10px; font-size: 21px; }
.qc-modal-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; margin: 14px -4px 0; }
.qc-modal-btns .qc-btn { margin: 4px; }
.qc-check { display: flex; align-items: center; min-height: 44px; margin-top: 8px; color: var(--muted); }
.qc-check input { width: 22px; height: 22px; margin-right: 10px; }
.qc-sol { background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font-size: 14px; max-height: 50vh; }
#qc-search-in { width: 100%; min-height: 48px; font-size: 17px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--code); color: var(--text); }
.qc-sres { padding: 12px 4px; border-bottom: 1px solid var(--line); }
.qc-sres p { margin: 4px 0; }
.qc-win { text-align: center; max-width: 440px; border-color: var(--gold); }
.qc-win h2 { font-size: 26px; }
.qc-win-stars { font-size: 40px; color: var(--gold); letter-spacing: 4px; line-height: 1; margin-bottom: 8px; }
.qc-win-stars i { color: #4c4478; font-style: normal; }
.qc-win-sub { color: var(--muted); }
.qc-win-reward { color: var(--gold); font-weight: 700; min-height: 1.4em; }
.qc-win-save { font-size: 14px; color: var(--muted); }
.qc-win-bugs { text-align: left; background: var(--panel2); border-radius: 12px; padding: 10px 12px; font-size: 14.5px; }
.qc-win-bugs ul { margin: 6px 0 0; padding-left: 18px; }
.qc-win-badges span { display: inline-block; margin: 4px; padding: 4px 10px; border-radius: 999px; background: var(--panel3); }
.qc-win-ch { margin: 10px 0 4px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(255, 210, 63, .12), rgba(106, 90, 224, .14)); border: 1px solid rgba(255, 210, 63, .45); }
.qc-win-ch p { margin: 0 0 6px; }
.qc-win-ch p:last-child { margin-bottom: 0; }
.qc-win-ch-h { font-size: 16px; }
.qc-win-ch-r { color: var(--gold); font-weight: 700; }
.qc-win .qc-modal-btns { justify-content: center; }
.qc-win-timer { height: 4px; background: var(--line); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.qc-win-timer i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 2s linear; }
#qc-toasts { position: fixed; left: 50%; bottom: 20px; z-index: 120; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; width: calc(100% - 24px); max-width: 520px; pointer-events: none; }
.qc-toast { margin-top: 8px; padding: 12px 18px; border-radius: 14px; background: #2a2250; border: 1px solid var(--accent); color: #fff; font-weight: 600; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); opacity: 0; transform: translateY(14px); transition: opacity .3s, transform .3s; text-align: center; }
.qc-toast.show { opacity: 1; transform: none; }
.qc-toast-ok { border-color: var(--ok); }
.qc-toast-bad { border-color: var(--no); }
body.qc-in-level #qc-toasts { bottom: 90px; }
#qc-fx { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 110; }

/* ── phones and portrait tablets: tabs + a dock ─────────────────────── */
@media (max-width: 899px) {
  .qc-ptabs { display: flex; position: -webkit-sticky; position: sticky; top: var(--top); z-index: 30; height: var(--tabs); background: #0a0816; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .qc-ptabs button { flex: 1 0 auto; min-height: var(--tabs); padding: 0 10px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 700; font-size: 15px; white-space: nowrap; }
  .qc-ptabs button[aria-selected=true] { color: #fff; border-bottom-color: var(--accent); }
  .qc-level { display: block; height: auto; }
  .qc-work { display: block; }
  .qc-outwrap { display: block; border: 0; background: none; }
  .qc-otabs, .qc-actions { display: none; }
  .qc-out-head { display: block; padding: 8px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: #0a0816; border-bottom: 1px solid var(--line); }
  .qc-panel { display: none; }
  main[data-tab=lesson] .qc-p-lesson, main[data-tab=code] .qc-p-code, main[data-tab=output] .qc-p-output, main[data-tab=debug] .qc-p-debug { display: block; }
  main[data-tab=code] .qc-p-code { display: flex; }
  main[data-out] .qc-p-debug, main[data-out] .qc-p-output { display: none; }
  main[data-tab=output][data-out] .qc-p-debug, main[data-tab=debug][data-out] .qc-p-debug { display: none; }
  main[data-tab=output][data-out] .qc-p-output { display: flex; }
  main[data-tab=debug][data-out] .qc-p-debug { display: block; }
  .qc-p-lesson { border: 0; padding: 14px 16px calc(var(--dockh) + 30px); min-height: calc(100vh - var(--top) - var(--tabs)); overflow: visible; }
  .qc-p-code { height: calc(100vh - var(--top) - var(--tabs) - var(--dockh)); height: calc(100dvh - var(--top) - var(--tabs) - var(--dockh) - env(safe-area-inset-bottom)); }
  .qc-p-output, .qc-p-debug { min-height: calc(100vh - var(--top) - var(--tabs) - var(--dockh)); padding-bottom: calc(var(--dockh) + 20px); overflow: visible; }
  .qc-p-output .qc-preview iframe { height: calc(100vh - var(--top) - var(--tabs) - var(--dockh) - 120px); min-height: 300px; }
  .qc-dock { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: rgba(10, 8, 22, .97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .qc-dock-btns { display: flex; padding: 8px 10px; }
  .qc-dock-btns .qc-btn { flex: 1 1 0; padding: 0 8px; }
  .qc-dock-btns .qc-btn + .qc-btn { margin-left: 8px; }
  .qc-dock-btns .qc-btn-primary { flex: 1.4 1 0; }
  .qc-symbols { display: none; overflow-x: auto; white-space: nowrap; padding: 6px 6px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .qc-symbols::-webkit-scrollbar { display: none; }
  .qc-symbols button { display: inline-block; min-width: 44px; height: 44px; margin: 0 3px 0 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: #fff; font: 700 18px var(--mono); -webkit-user-select: none; user-select: none; touch-action: manipulation; }
  body.qc-typing .qc-symbols { display: block; }
  body.qc-typing { --dockh: 114px; }
  body.qc-kb .qc-top, body.qc-kb .qc-ptabs { display: none; }
  body.qc-kb .qc-p-code { height: calc(var(--vvh, 50vh) - var(--dockh)); }
  #qc-toasts { bottom: calc(var(--dockh) + 16px); }
  .qc-edhead { padding-left: 12px; }
}
@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
  :root { --top: 48px; --tabs: 42px; }
  .qc-dock-btns { padding: 4px 10px; }
  .qc-dock-btns .qc-btn { min-height: 40px; }
  :root { --dockh: 52px; }
}
@media (pointer: fine) { .qc-symbols { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .qc-win-timer i { transition: none !important; }
}

/* ── stars: why a level got them, how to get all 3 (qc-app.js starWhy / drawStars) ── */
.qc-starbox { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: rgba(255, 210, 63, .08); border: 1px solid rgba(255, 210, 63, .4); font-size: 15px; }
.qc-starbox p { margin: 0 0 8px; }
.qc-starbox p:last-child { margin-bottom: 0; }
.qc-starbox .qc-stars { font-size: 16px; margin-left: 0; }
.qc-starbox-3 { background: rgba(95, 208, 107, .08); border-color: rgba(95, 208, 107, .4); }
.qc-starbox-try { background: rgba(106, 90, 224, .14); border-color: var(--accent); }
.qc-star-key { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.qc-star-key .qc-stars { margin: 0 2px 0 8px; font-size: 12px; }
.qc-star-key .qc-stars:first-child { margin-left: 0; }
.qc-win-up { margin: 4px 0 8px; font-weight: 800; color: var(--ok); }
.qc-win-up .qc-stars { font-size: 15px; margin: 0 2px; }
.qc-win-why { text-align: left; margin: 10px 0 6px; padding: 12px 14px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); font-size: 14.5px; }
.qc-win-why p { margin: 0 0 6px; }
.qc-win-why p:last-child { margin-bottom: 0; }
.qc-win-why .qc-stars { margin-left: 2px; }
.qc-win-why-b { padding-top: 2px; }

/* working with a friend (qc-pair.js, ../../js/oxf-pair.js): "With a friend?" / "👥 Zeynep" */
.qc-pairbtn { font-size: 14px; font-weight: 700; gap: 4px; }
.qc-pairbtn.is-paired { background: #ffd23f; border-color: #e0a100; color: #1d2433; }
@media (max-width: 720px) { .qc-pairbtn .oxp-bt { display: none; } .qc-pairbtn.is-paired .oxp-bt { display: inline; } }
