/* Everyone Can Learn Program — styles
   Quiet and neutral, in the spirit of LeetCode: white surfaces on a light grey
   page (neutral greys in dark mode, never navy), thin borders and soft shadows
   for depth. There is no brand hue in the chrome: navigation, tabs and primary
   buttons use the text colour (ink), and green means "submit / passed / go on".
   Colour is kept for meaning and for the course art, so it stands out:
   blue = range / still considering, yellow = current step, green = done / passed,
   red = error, grey = locked / ruled out; teal / amber / red mark the three
   exercise tiers the way easy / medium / hard are marked. Courses, badges and
   icons are grey and ink: no purple, no rainbow of course hues.
   Icons are inline SVG from js/icons.js (24px grid, 2px stroke); no emoji. */

:root {
  --bg: #FFFFFF;
  --bg-work: #F0F1F3;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EFF0F2;
  --border: #E7E8EB;
  --border-strong: #D3D5DA;
  --text: #262626;
  --muted: #6B6E75;
  --faint: #A0A3A9;
  --ink: #262626;
  --ink-text: #FFFFFF;
  --brand: #262626;
  --brand-hover: #404040;
  --brand-2: #5C5F66;
  --brand-ink: #FFFFFF;
  --brand-text: #262626;
  --brand-soft: #F2F3F5;
  --btn: #F0F1F3;
  --btn-hover: #E6E7EA;
  --go: #167F3B;
  --go-hover: #146C33;
  --go-ink: #FFFFFF;
  --accent: var(--brand);
  --accent-ink: var(--brand-ink);
  --focus: #262626;
  --robot: #4B4F56;
  --s-blue: #2A64E0;
  --s-blue-soft: #EEF3FD;
  --s-yellow: #A16207;
  --s-yellow-dot: #E2A400;
  --s-yellow-soft: #FEF7E0;
  --s-green: #167F3B;
  --s-green-soft: #E9F6EE;
  --s-red: #C53037;
  --s-red-soft: #FDEEEE;
  --s-orange: #C2410C;
  --s-orange-soft: #FFF2E8;
  --s-grey: #A0A3A9;
  --s-grey-soft: #F2F3F5;
  --star: #F5B301;
  --star-off: #DCDDE0;
  --badge-on-1: #55585E;
  --badge-on-2: #26272A;
  --badge-off-1: #F0F1F3;
  --badge-off-2: #DCDEE2;
  --badge-off-ink: #A4A7AD;
  --tile: #F2F3F5;
  --flame: #F57A15;
  --side-w: 236px;
  --code-bg: #FFFFFF;
  --code-gutter: #FAFAFA;
  --code-text: #262626;
  --tok-kw: #1F55C0;
  --tok-str: #18794E;
  --tok-num: #B4570B;
  --tok-com: #8C8F94;
  --tok-fn: #7A4E0E;
  --wall: #D6D8DC;
  --toast: #262626;
  --toast-ink: #FFFFFF;
  --dots: rgba(0, 0, 0, .07);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .03);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 16px rgba(0, 0, 0, .06);
  --sh-3: 0 16px 44px rgba(0, 0, 0, .16);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 12px;
  --top: 56px;
  --font: "Inter", "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

/* Dark: the same neutral greys, one step apart (page, panel, raised). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1A1A; --bg-work: #141414; --surface: #262626; --surface-2: #2C2C2C; --surface-3: #363636;
    --border: #353535; --border-strong: #4A4A4A; --text: #EBEBEB; --muted: #A6A6A6; --faint: #757575;
    --ink: #EBEBEB; --ink-text: #1A1A1A;
    --brand: #EBEBEB; --brand-hover: #FFFFFF; --brand-2: #BDBDBD; --brand-ink: #1A1A1A; --brand-text: #F5F5F5; --brand-soft: #323232;
    --btn: #363636; --btn-hover: #414141;
    --go: #2CB75B; --go-hover: #3CC66A; --go-ink: #08210F;
    --focus: #D9D9D9; --robot: #C4C4C4;
    --s-blue: #6EA8FF; --s-blue-soft: #222A35; --s-yellow: #F2C14E; --s-yellow-dot: #F2C14E; --s-yellow-soft: #352F1C;
    --s-green: #4CC38A; --s-green-soft: #1E3329; --s-red: #FF7B80; --s-red-soft: #3A2325;
    --s-orange: #FF9F66; --s-orange-soft: #38281C;
    --s-grey: #757575; --s-grey-soft: #2E2E2E;
    --star: #F7C744; --star-off: #474747;
    --badge-on-1: #6A6A6A; --badge-on-2: #3C3C3C; --badge-off-1: #3A3A3A; --badge-off-2: #2E2E2E; --badge-off-ink: #6E6E6E;
    --tile: #333333; --flame: #FF9A3D;
    --code-bg: #1E1E1E; --code-gutter: #1A1A1A; --code-text: #E3E3E3;
    --tok-kw: #7FB0FF; --tok-str: #7EDDA6; --tok-num: #FFB86B; --tok-com: #7D7D7D; --tok-fn: #E3C27A;
    --wall: #3D3D3D; --toast: #3A3A3A; --toast-ink: #F5F5F5; --dots: rgba(255, 255, 255, .06);
    --sh-1: 0 1px 2px rgba(0, 0, 0, .3);
    --sh-2: 0 2px 4px rgba(0, 0, 0, .25), 0 8px 22px rgba(0, 0, 0, .3);
    --sh-3: 0 18px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1A1A1A; --bg-work: #141414; --surface: #262626; --surface-2: #2C2C2C; --surface-3: #363636;
  --border: #353535; --border-strong: #4A4A4A; --text: #EBEBEB; --muted: #A6A6A6; --faint: #757575;
  --ink: #EBEBEB; --ink-text: #1A1A1A;
  --brand: #EBEBEB; --brand-hover: #FFFFFF; --brand-2: #BDBDBD; --brand-ink: #1A1A1A; --brand-text: #F5F5F5; --brand-soft: #323232;
  --btn: #363636; --btn-hover: #414141;
  --go: #2CB75B; --go-hover: #3CC66A; --go-ink: #08210F;
  --focus: #D9D9D9; --robot: #C4C4C4;
  --s-blue: #6EA8FF; --s-blue-soft: #222A35; --s-yellow: #F2C14E; --s-yellow-dot: #F2C14E; --s-yellow-soft: #352F1C;
  --s-green: #4CC38A; --s-green-soft: #1E3329; --s-red: #FF7B80; --s-red-soft: #3A2325;
  --s-orange: #FF9F66; --s-orange-soft: #38281C;
  --s-grey: #757575; --s-grey-soft: #2E2E2E;
  --star: #F7C744; --star-off: #474747;
  --badge-on-1: #6A6A6A; --badge-on-2: #3C3C3C; --badge-off-1: #3A3A3A; --badge-off-2: #2E2E2E; --badge-off-ink: #6E6E6E;
  --tile: #333333; --flame: #FF9A3D;
  --code-bg: #1E1E1E; --code-gutter: #1A1A1A; --code-text: #E3E3E3;
  --tok-kw: #7FB0FF; --tok-str: #7EDDA6; --tok-num: #FFB86B; --tok-com: #7D7D7D; --tok-fn: #E3C27A;
  --wall: #3D3D3D; --toast: #3A3A3A; --toast-ink: #F5F5F5; --dots: rgba(255, 255, 255, .06);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .3);
  --sh-2: 0 2px 4px rgba(0, 0, 0, .25), 0 8px 22px rgba(0, 0, 0, .3);
  --sh-3: 0 18px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 24px 0 10px; }
h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
code, pre, kbd { font-family: var(--mono); }
svg.i { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; }
.h-ico { width: 1.05em; height: 1.05em; margin-right: 8px; color: var(--brand); vertical-align: -0.15em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 26px;
  padding: 0 24px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1rem; white-space: nowrap; letter-spacing: -.01em; }
.topbar .brand img { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px var(--border); }
.nav { display: flex; gap: 4px; align-self: stretch; }
.nav a {
  position: relative; display: flex; align-items: center; padding: 0 12px; text-decoration: none; color: var(--muted); font-weight: 500;
  font-size: .94rem; transition: color .15s;
}
.nav a::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); transform: scaleX(0); transition: transform .2s; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav a[aria-current="page"]::after { transform: scaleX(1); }
.nav a:focus-visible { outline-offset: -4px; border-radius: 8px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-btn {
  border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); height: 32px;
  padding: 0 10px; cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--muted); transition: background .15s, color .15s;
}
.lang-btn:hover { color: var(--text); background: var(--btn); }
.top-sep { width: 1px; height: 22px; background: var(--border); }
.me-link {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 3px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 500; font-size: .9rem; border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s;
}
.me-link:hover { color: var(--text); background: var(--surface-2); }
.me-link[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--btn); }
.me-link .avatar { transition: box-shadow .15s; }
.me-link:hover .avatar, .me-link[aria-current="page"] .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong); }
.member-chip { font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; white-space: nowrap; transition: color .15s, border-color .15s; }
.member-chip:hover { color: var(--text); border-color: var(--border-strong); }
.member-chip.on { color: var(--s-green); border-color: var(--s-green); background: var(--s-green-soft); }
.tabbar { display: none; }
@media (max-width: 860px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .nav { display: none; }
  .topbar .brand { min-width: 0; flex: 0 1 auto; }
  .topbar .brand span { max-width: 48vw; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .top-right { gap: 8px; flex: none; }
  .top-sep, .me-label { display: none; }
  .me-link { padding: 0; height: auto; border: 0; background: none !important; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--border); padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; font-size: .7rem; text-decoration: none; color: var(--muted); }
  .tabbar a[aria-current="page"] { color: var(--text); font-weight: 600; }
  .tabbar svg { width: 21px; height: 21px; }
  body { padding-bottom: 64px; }
}

/* ---------- avatar ---------- */
.avatar {
  --c1: #6B6E75; --c2: #34363B;
  display: inline-grid; place-items: center; border-radius: 50%; flex: none; overflow: hidden; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 55%; height: 55%; }
.avatar.sm { width: 32px; height: 32px; font-size: .82rem; }
.avatar.md { width: 44px; height: 44px; font-size: 1rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 2rem; box-shadow: 0 0 0 4px var(--surface), var(--sh-2); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 30px 24px 56px; outline: none; }
main.wide { max-width: none; padding: 0; }
main.narrow { max-width: 820px; }
@media (max-width: 600px) { main { padding: 20px 16px 40px; } }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; display: flex; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 600px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--sh-1); }
.card.flush { padding: 0; overflow: hidden; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
a.card { display: block; text-decoration: none; transition: transform .18s, box-shadow .18s, border-color .18s; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--border-strong); }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--sh-1); }
.list.flat { box-shadow: none; border-radius: var(--radius); }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border);
  text-decoration: none; color: inherit; min-height: 52px; transition: background .12s;
}
.list-row:first-child { border-top: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); }
button.list-row { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: none; text-align: left; cursor: pointer; }
.list-row .title { flex: 1; min-width: 0; font-weight: 500; }
.list-row .title small { display: block; color: var(--muted); font-weight: 400; font-size: .83rem; }
.list-row.locked { color: var(--faint); }
.list-row .row-go { color: var(--faint); transition: transform .15s, color .15s; }
a.list-row:hover .row-go, button.list-row:hover .row-go { color: var(--text); transform: translateX(2px); }
.list-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-head h3 { margin: 0; font-size: .98rem; }
.stage-no { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--text); font-weight: 700; font-size: .82rem; flex: none; border: 1px solid var(--border-strong); }
.list-head .stage-no + .kicker { display: none; }
.empty-box { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 26px 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); box-shadow: none; }
.empty-box svg.i { width: 22px; height: 22px; color: var(--faint); }

/* status dot (check done, dot current, ring open, lock) */
.st { width: 22px; height: 22px; flex: none; display: grid; place-items: center; font-size: .72rem; border-radius: 50%; font-weight: 700; }
.st svg.i { width: 13px; height: 13px; stroke-width: 3; }
.st.done { color: var(--surface); background: var(--s-green); }
.st.current { border: 2px solid var(--s-yellow-dot); }
.st.current::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--s-yellow-dot); }
.st.open { border: 1.5px solid var(--border-strong); }
.st.locked { color: var(--faint); }
.st.locked svg.i { width: 15px; height: 15px; stroke-width: 2; }

/* tags */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; line-height: 1.6; }
.tag svg.i { width: 12px; height: 12px; stroke-width: 3; }
.tag.green { background: var(--s-green-soft); color: var(--s-green); }
.tag.yellow { background: var(--s-yellow-soft); color: var(--s-yellow); }
.tag.blue { background: var(--s-blue-soft); color: var(--s-blue); }
.tag.red { background: var(--s-red-soft); color: var(--s-red); }
.tag.brand { background: var(--brand-soft); color: var(--brand-text); }
/* exercise tiers, coloured like easy / medium / hard */
.tier-predict { --t: #0E9384; --t-soft: #E0F5F2; }
.tier-modify { --t: #B45309; --t-soft: #FDF1DC; }
.tier-write { --t: #C53037; --t-soft: #FDEEEE; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tier-predict { --t: #4FD1C5; --t-soft: #1C3231; }
  :root:not([data-theme="light"]) .tier-modify { --t: #F6C15B; --t-soft: #382F1C; }
  :root:not([data-theme="light"]) .tier-write { --t: #FF8A8F; --t-soft: #3A2325; }
}
:root[data-theme="dark"] .tier-predict { --t: #4FD1C5; --t-soft: #1C3231; }
:root[data-theme="dark"] .tier-modify { --t: #F6C15B; --t-soft: #382F1C; }
:root[data-theme="dark"] .tier-write { --t: #FF8A8F; --t-soft: #3A2325; }
.tag.tier-predict, .tag.tier-modify, .tag.tier-write { background: var(--t-soft); color: var(--t); }
.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.kicker { font-size: .74rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* progress */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--s-green); border-radius: inherit; transition: width .4s; }
.progress.brand i { background: var(--brand); }
.ring { --p: 0; width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: radial-gradient(closest-side, var(--surface) 76%, transparent 78% 100%), conic-gradient(var(--s-green) calc(var(--p) * 1%), var(--surface-3) 0); }

/* stars */
.stars { display: inline-flex; gap: 1px; align-items: center; vertical-align: middle; }
svg.i.star { width: 15px; height: 15px; }
svg.i.star.on { color: var(--star); }
svg.i.star.off { color: var(--star-off); }

/* stats */
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-tile { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.stat-tile b { display: block; font-size: 1.3rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-tile small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.stat-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.stat-ico svg.i { width: 19px; height: 19px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 15px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--btn); color: var(--text);
  font-weight: 550; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, color .15s;
}
.btn:hover { background: var(--btn-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: var(--sh-1); }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.go { background: var(--go); border-color: var(--go); color: var(--go-ink); font-weight: 650; box-shadow: var(--sh-1); }
.btn.go:hover:not(:disabled) { background: var(--go-hover); border-color: var(--go-hover); }
.btn.primary:disabled, .btn.go:disabled { background: var(--btn); border-color: var(--btn); color: var(--faint); opacity: 1; box-shadow: none; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: var(--btn); }
.btn.danger { color: var(--s-red); }
.btn.danger:hover { background: var(--s-red-soft); }
.btn.small { height: 30px; padding: 0 11px; font-size: .83rem; gap: 6px; }
.btn.small svg.i { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn.pulse { animation: pulse 1.6s ease-out 3; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--go) 55%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.btn.primary.pulse { animation-name: pulse-brand; }
@keyframes pulse-brand {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.kbd { font-size: .7rem; font-weight: 600; opacity: .55; font-family: var(--font); padding: 1px 5px; border-radius: 4px; background: var(--surface-3); }
.field { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 550; }
.field small { font-weight: 400; line-height: 1.45; }
textarea, input[type="text"], input[type="search"], input[type="url"], input[type="password"], select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--mono); font-size: .9rem; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 4px 13px; cursor: pointer; font-weight: 550; font-size: .85rem; border-radius: 6px; color: var(--muted); transition: all .15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1), 0 0 0 1px var(--border); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- callouts & messages ---------- */
.callout { border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; border: 1px solid var(--border); background: var(--surface-2); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 650; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.callout-title svg.i { width: 18px; height: 18px; }
.callout.ok { background: var(--s-green-soft); border-color: color-mix(in srgb, var(--s-green) 25%, transparent); }
.callout.ok .callout-title, .callout.ok > b { color: var(--s-green); }
.callout.warn { background: var(--s-yellow-soft); border-color: color-mix(in srgb, var(--s-yellow) 25%, transparent); }
.callout.warn .callout-title { color: var(--s-yellow); }
.callout.info, .callout.now { background: var(--surface-2); border-color: var(--border); border-left: 3px solid var(--border-strong); }
.err-box { border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; background: var(--s-red-soft); color: var(--text); font-family: var(--font); white-space: normal; border-left: 3px solid var(--s-red); }
.err-box b { color: var(--s-red); font-weight: 600; }
.err-box .raw { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: 6px; white-space: pre-wrap; }
.loading { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: .85rem; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--muted); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- markdown ---------- */
.md > :first-child { margin-top: 0; }
.md table, table.data { border-collapse: collapse; width: 100%; margin: 10px 0 14px; font-size: .9rem; }
.md th, .md td, table.data th, table.data td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
.md th, table.data th { background: var(--surface-2); font-weight: 600; }
.md pre, pre.block {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
  overflow-x: auto; font-size: .88rem; line-height: 1.55; margin: 10px 0 14px;
}
.md code, .inline-code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: .86em; }
.md pre code { background: none; padding: 0; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--faint); }
.md blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
blockquote.def { margin: 8px 0 14px; padding: 14px 16px; border-left: 3px solid var(--text); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
blockquote.def .en { font-weight: 500; }
blockquote.def .zh { color: var(--muted); margin-top: 6px; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px 32px; align-items: center; margin-bottom: 8px; padding: 4px 0 8px; }
@container (max-width: 680px) { .hero { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero h1 { font-size: 1.75rem; letter-spacing: -.02em; }
.hero .lead { color: var(--muted); font-size: 1rem; max-width: 560px; }
.hero-side { display: grid; gap: 10px; }
.continue-card { display: flex; gap: 16px; align-items: center; }
.continue-card .robot-mini { width: 54px; height: 54px; flex: none; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.dir { display: flex; gap: 12px; align-items: flex-start; padding: 16px; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; text-decoration: none; box-shadow: var(--sh-1); transition: transform .18s, box-shadow .18s, border-color .18s; }
.dir:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--sh-2); }
.dir[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 1px var(--text), var(--sh-2); }
.dir .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); color: var(--text); display: grid; place-items: center; flex: none; }
.dir .ico svg { width: 19px; height: 19px; }
.dir b { display: block; font-weight: 600; }
.dir small { display: block; color: var(--muted); font-size: .83rem; line-height: 1.45; margin-top: 2px; }
.dir .check { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; display: grid; place-items: center; font-size: .7rem; color: transparent; }
.dir[aria-pressed="true"] .check { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.route-phase { margin-bottom: 18px; }
.route-phase h3 { margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.route-phase h3 small { color: var(--muted); font-weight: 400; font-size: .83rem; }
.route-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }

/* course tiles (js/icons.js): the course glyph in ink on a light grey square */
.course-tile {
  width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; flex: none; color: var(--text);
  background: var(--tile);
}
.course-tile svg { width: 54%; height: 54%; }
.course-tile.xs { width: 22px; height: 22px; border-radius: 6px; }
.course-tile.xs svg { width: 62%; height: 62%; }
.course-tile.sm { width: 28px; height: 28px; border-radius: 8px; }
.course-tile.lg { width: 52px; height: 52px; border-radius: 13px; }
.course-tile.xl { width: 68px; height: 68px; border-radius: 16px; }
.course-tile.off { color: var(--faint); }
/* course cards: tile, title, two lines, progress. No cover band, no hue. */
.course-card { position: relative; display: flex !important; flex-direction: column; gap: 10px; padding: 18px 18px 16px; box-shadow: none; }
a.course-card:hover { transform: none; box-shadow: var(--sh-2); border-color: var(--border); }
.course-card-top { display: flex; align-items: flex-start; gap: 12px; }
.course-card-top .tag { margin-left: auto; background: none; padding: 0; color: var(--faint); font-weight: 500; }
.course-card h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.course-card p { margin: 0; color: var(--muted); font-size: .87rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-card-foot { margin-top: auto; padding-top: 4px; display: flex; gap: 10px; align-items: center; }
.course-card-foot .progress { flex: 1; height: 4px; }
.course-card-foot span { flex: none; font-variant-numeric: tabular-nums; }

/* ---------- course page (study plan) ---------- */
.course-head { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; margin-bottom: 24px; }
.course-intro { display: flex; gap: 20px; align-items: flex-start; }
@media (max-width: 860px) { .course-head { grid-template-columns: 1fr; } .course-intro .course-tile.xl { width: 56px; height: 56px; } }
.course-side { display: grid; gap: 14px; box-shadow: var(--sh-2); }
.star-count { display: flex; align-items: center; gap: 4px; }
.star-count svg.i { color: var(--star); fill: currentColor; width: 14px; height: 14px; }
.stage-block { margin-bottom: 18px; }
.lesson-num { width: 26px; text-align: right; color: var(--faint); font-size: .83rem; font-variant-numeric: tabular-nums; flex: none; }
.free-note { font-size: .78rem; color: var(--muted); }

/* problems table */
.solved-card { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.solved-card small { display: block; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; height: 36px; padding: 4px 11px; font-size: .88rem; }
.filters input { min-width: 220px; flex: 1; max-width: 360px; }
table.problems { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.problems th { white-space: nowrap; text-align: left; font-weight: 550; color: var(--muted); font-size: .8rem; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.problems td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.problems tbody tr { transition: background .12s; }
table.problems tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.problems tbody tr:hover td { background: var(--surface-3); }
table.problems tr:last-child td { border-bottom: 0; }
table.problems a { text-decoration: none; font-weight: 550; }
table.problems a:hover { text-decoration: underline; text-decoration-color: var(--border-strong); }
table.problems .c-st { width: 64px; }
table.problems .locked a, table.problems .locked { color: var(--faint); }
.course-cell { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 700px) { table.problems .c-course, table.problems .c-type { display: none; } }

/* pricing */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.plan { display: flex !important; flex-direction: column; gap: 10px; }
.plan.featured { border-color: var(--text); box-shadow: 0 0 0 1px var(--text), var(--sh-2); }
.plan .price { font-size: 1.6rem; font-weight: 750; }
.plan .price small { font-size: .85rem; font-weight: 400; color: var(--muted); }
.plan ul { padding-left: 18px; margin: 0; color: var(--muted); font-size: .9rem; }
.plan .btn { margin-top: auto; }
.pay-note { margin: 12px 2px 0; }
/* overseas site, visitor in mainland China: offer the China site */
.site-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 16px; }
.site-hint > span:first-child { flex: 1 1 320px; }

/* ---------- lesson: split view ---------- */
.lesson { display: flex; flex-direction: column; height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); background: var(--bg-work); }
.lesson-bar { display: flex; align-items: center; gap: 10px; padding: 6px 18px; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; min-height: 44px; }
.lesson-bar .stars svg.i.star { width: 17px; height: 17px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: .88rem; min-width: 0; color: var(--muted); }
.crumbs a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.crumbs a:hover { color: var(--text); }
.crumbs > span { color: var(--faint); }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.split { flex: 1; display: grid; grid-template-columns: var(--left, 46%) 10px minmax(0, 1fr); min-height: 0; padding: 10px; }
.pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; box-shadow: var(--sh-1); }
.gutter-x { cursor: col-resize; position: relative; touch-action: none; }
.gutter-x::after { content: ""; position: absolute; top: 50%; left: 4px; width: 2px; height: 32px; margin-top: -16px; border-radius: 2px; background: var(--border-strong); opacity: .6; transition: opacity .15s, background .15s; }
.gutter-x:hover::after, .gutter-x.drag::after { opacity: 1; background: var(--muted); }
.pane-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); background: var(--surface); overflow-x: auto; scrollbar-width: none; flex: none; padding: 0 8px; }
.pane-tabs::-webkit-scrollbar { display: none; }
.pane-tabs button {
  position: relative; border: 0; background: none; padding: 10px 10px 9px; font-size: .85rem; color: var(--muted); cursor: pointer; white-space: nowrap;
  display: inline-flex; gap: 7px; align-items: center; font-weight: 500; transition: color .15s;
}
.pane-tabs button::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); transform: scaleX(0); transition: transform .2s; }
.pane-tabs button svg.i { width: 15px; height: 15px; }
.pane-tabs button:hover:not(:disabled) { color: var(--text); }
.pane-tabs button[aria-selected="true"] { color: var(--text); font-weight: 650; }
.pane-tabs button[aria-selected="true"]::after { transform: scaleX(1); }
.pane-tabs button:disabled { color: var(--faint); cursor: not-allowed; }
.pane-tabs .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.pane-tabs .done .dot { background: var(--s-green); }
/* the eight lesson steps */
.pane-tabs.steps button { padding-left: 8px; padding-right: 8px; }
.step-n { width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: .68rem; font-weight: 700; background: var(--surface-3); color: var(--muted); flex: none; }
.step-n svg.i { width: 11px; height: 11px; stroke-width: 3.2; }
.pane-tabs.steps button.done .step-n { background: var(--s-green-soft); color: var(--s-green); }
.pane-tabs.steps button[aria-selected="true"] .step-n { background: var(--brand); color: var(--brand-ink); }
.pane-tabs.steps button:disabled .step-n { background: transparent; border: 1px solid var(--border); color: var(--faint); }
.step-progress { height: 2px; background: var(--surface-3); flex: none; }
.step-progress i { display: block; height: 100%; width: 0; background: var(--s-green); transition: width .35s; border-radius: 0 3px 3px 0; }
.pane-body { flex: 1; overflow-y: auto; padding: 20px 22px 30px; min-height: 0; }
.pane-body > h2:first-child { margin-top: 0; }
.pane-body > h2 { font-size: 1.3rem; }
.pane-foot { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); flex: none; background: var(--surface); }
.pane-foot .foot-note { text-align: right; }
@media (max-width: 960px) {
  .lesson { height: auto; }
  .split { display: flex; flex-direction: column; padding: 8px; gap: 8px; }
  .gutter-x { display: none; }
  .pane-body { overflow: visible; }
  .ws { min-height: 580px; }
}

/* workspace (editor + console) */
.ws { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ws-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--border); flex: none; font-size: .84rem; color: var(--muted); min-height: 44px; background: var(--surface); }
.ws-head .lang { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; color: var(--text); flex: none; }
.ws-head .lang-ico { color: var(--s-green); width: 17px; height: 17px; }
.ws-head .ws-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 10px; border-left: 1px solid var(--border); }
.ws-head .py-loading { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-head .ws-reset { flex: none; }
@media (max-width: 640px) {
  .ws-head .ws-title { display: none; }
  .ws-foot .kbd { display: none; }
}
.ws-stage { flex: none; padding: 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ws-stage svg.world { width: 100%; height: auto; display: block; max-height: min(280px, 30vh); margin: 0 auto; }
.ws-editor { flex: 1 1 0; min-height: 96px; overflow: auto; background: var(--code-bg); }
.ws-editor { display: flex; flex-direction: column; }
.ws-editor > .edhost { flex: 1 0 auto; display: flex; flex-direction: column; }
.ws-editor .ed { border: 0; border-radius: 0; flex: 1 0 auto; }
.gutter-y { height: 9px; flex: none; cursor: row-resize; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); touch-action: none; position: relative; }
.gutter-y::after { content: ""; position: absolute; left: 50%; top: 3px; width: 32px; height: 2px; margin-left: -16px; border-radius: 2px; background: var(--border-strong); }
.gutter-y:hover::after { background: var(--muted); }
.ws-console { flex: 0 1 var(--console, 40%); min-height: 90px; display: flex; flex-direction: column; background: var(--surface); }
.ws-console .pane-tabs { background: var(--surface); }
.ws-out { flex: 1; overflow: auto; padding: 14px 16px; font-size: .88rem; min-height: 0; }
.ws-out pre.out { margin: 0; font-family: var(--mono); font-size: .86rem; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }
.ws-out .placeholder { color: var(--faint); }
.ws-out .term .cmd { color: var(--muted); }
.ws-out .term .cmd b { color: var(--s-green); font-weight: 600; }
.ws-out .term pre.out { background: none; padding: 0; }
.ws-out iframe.preview { width: 100%; height: 100%; min-height: 220px; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: block; }
.ws-out table.data { font-family: var(--mono); font-size: .82rem; margin: 6px 0 12px; width: auto; min-width: 50%; }
.ws-out table.data td.null { color: var(--faint); font-style: italic; }
.ws-out .tbl-cap { font-size: .78rem; color: var(--muted); }
.ws-out .warn-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.ws-foot { display: flex; gap: 8px; align-items: center; padding: 9px 12px; border-top: 1px solid var(--border); flex: none; flex-wrap: wrap; background: var(--surface); }
.ws-foot .status { font-size: .84rem; color: var(--muted); display: inline-flex; gap: 7px; align-items: center; min-width: 0; flex: 1 1 200px; line-height: 1.4; }
.ws-foot .status svg.i { width: 17px; height: 17px; }
.ws-foot .status.ok { color: var(--s-green); font-weight: 650; }
.ws-foot .status.bad { color: var(--s-red); font-weight: 650; }
.ws-foot .status.guide svg.i { color: var(--muted); }
.ws-foot .spacer { flex: 0 0 0; }
.ws-run .i { width: 13px; height: 13px; color: var(--s-green); }
.ws textarea.predict-input, .ws textarea.stdin-box { border: 1px solid var(--border-strong); background: var(--code-bg); font-size: .88rem; resize: vertical; min-height: 76px; }
.schema { display: grid; gap: 8px; }
.schema details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 11px; }
.schema summary { cursor: pointer; font-family: var(--mono); font-size: .85rem; font-weight: 600; }
.schema .cols { font-family: var(--mono); font-size: .8rem; color: var(--muted); }

/* lesson content pieces */
.lead-q { font-size: 1.18rem; font-weight: 650; line-height: 1.45; margin: 0 0 16px; padding: 14px 16px; border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface-2); border-left: 3px solid var(--text); }
.example { border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0 18px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.example.active { border-color: var(--border-strong); box-shadow: 0 0 0 1px var(--border-strong), var(--sh-2); }
.example-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.example-head h3 { margin: 0; font-size: .92rem; flex: 1; }
.example-body { padding: 12px 14px; }
.example-body > :last-child { margin-bottom: 0; }
.example pre.block { margin: 8px 0; }
.trace { display: grid; gap: 5px; margin-top: 8px; }
.trace-step { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .88rem; transition: all .12s; }
.trace-step:hover { border-color: var(--border-strong); background: var(--surface-2); }
.trace-step .ln { font-family: var(--mono); font-size: .76rem; color: var(--muted); min-width: 30px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); text-align: center; }
.trace-step .state { margin-left: auto; font-family: var(--mono); font-size: .78rem; color: var(--muted); white-space: pre; padding-left: 8px; }
.trace-step.now { border-color: var(--s-yellow-dot); background: var(--s-yellow-soft); }
.trace-step.past { opacity: .7; }
.pitfall { border: 1px solid var(--border); border-left: 3px solid var(--s-yellow-dot); padding: 12px 16px; margin: 14px 0 18px; border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface); }
.pitfall h3 { margin: 0 0 4px; }
.pitfall > :last-child { margin-bottom: 0; }
.quiz-q { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; background: var(--surface); }
.quiz-q h3 { margin: 0 0 10px; font-size: .96rem; }
.options { display: grid; gap: 7px; margin-top: 10px; }
.options.out-opts { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.option {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .9rem; transition: all .12s;
}
.option:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.option > b { font-size: .75rem; color: var(--muted); min-width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.option pre { margin: 0; font-size: .85rem; white-space: pre-wrap; }
.option.picked-ok { border-color: var(--s-green); background: var(--s-green-soft); }
.option.picked-ok > b { background: var(--s-green); color: var(--surface); }
.option.picked-bad { border-color: var(--s-red); background: var(--s-red-soft); }
.option.ruled-out { opacity: .55; text-decoration: line-through; text-decoration-color: var(--s-grey); }
.option:disabled { cursor: default; }
/* typed short answer (Computer Basics) */
.answer-form { display: grid; gap: 6px; margin-top: 12px; max-width: 520px; }
.answer-row { display: flex; gap: 8px; }
.answer-row input { flex: 1; min-width: 0; height: 40px; font-family: var(--mono); font-size: 1rem; letter-spacing: .02em; color: var(--text); }
.answer-row .btn { height: 40px; flex: none; }
.feedback:empty { display: none; }
.problem-title { margin: 0 0 4px !important; font-size: 1.2rem !important; }
.problem-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 14px; }
.solved-tag:empty { display: none; }
.ex-list { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 18px; }
.ex-chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 5px; font-size: .82rem; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 550; transition: all .15s; }
.ex-chip .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 700; background: var(--t-soft, var(--surface-3)); color: var(--t, var(--muted)); }
.ex-chip .n svg.i { width: 11px; height: 11px; stroke-width: 3.2; }
.ex-chip:hover { border-color: var(--border-strong); color: var(--text); }
.ex-chip[aria-current="true"] { border-color: var(--text); color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.ex-chip.passed .n { background: var(--s-green); color: var(--surface); }
.reqs { margin: 8px 0 14px; padding: 0; list-style: none; display: grid; gap: 5px; font-size: .88rem; }
.reqs li { display: flex; gap: 8px; }
.reqs li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); margin-top: .55em; flex: none; }
.hints { display: grid; gap: 8px; margin-top: 8px; }
.hint { border: 1px solid color-mix(in srgb, var(--s-yellow-dot) 35%, var(--border)); background: var(--s-yellow-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .9rem; }
.hint > b { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--s-yellow); margin-bottom: 2px; }
.hint > :last-child { margin-bottom: 0; }
.help-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.test-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; font-size: .88rem; }
.test-list li { padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.test-list li.ok { border-color: color-mix(in srgb, var(--s-green) 30%, transparent); }
.test-list li.ok > .mark { color: var(--s-green); background: var(--s-green-soft); }
.test-list li.bad { border-color: color-mix(in srgb, var(--s-red) 35%, transparent); background: color-mix(in srgb, var(--s-red-soft) 40%, var(--surface)); }
.test-list li.bad > .mark { color: var(--s-red); background: var(--s-red-soft); }
.test-list .mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; margin-right: 8px; vertical-align: -5px; }
.test-list .mark svg.i { width: 12px; height: 12px; stroke-width: 3.2; }
.test-list .name { font-weight: 550; }
.test-list pre { margin: 7px 0 0; font-size: .8rem; background: var(--surface-2); padding: 7px 9px; border-radius: 5px; white-space: pre-wrap; }
.result-head { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 1.3rem; margin-bottom: 6px; letter-spacing: -.01em; }
.result-head svg.i { width: 26px; height: 26px; }
.result-head.ok { color: var(--s-green); }
.result-head.bad { color: var(--s-red); }
.result-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.chip.ok { background: var(--s-green-soft); border-color: transparent; color: var(--s-green); }
.chip.bad { background: var(--s-red-soft); border-color: transparent; color: var(--s-red); }
.paywall { text-align: center; padding: 28px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-top: 12px; background: var(--surface-2); }
.paywall h3 { margin-top: 0; }

/* ---------- code editor ---------- */
.ed { position: relative; display: flex; background: var(--code-bg); overflow: hidden; font-size: 14px; line-height: 22px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ed-gutter {
  flex: none; padding: 10px 12px 10px 8px; text-align: right; color: var(--faint); user-select: none;
  font-family: var(--mono); font-size: 13px; line-height: 22px; background: var(--code-gutter); min-width: 44px; border-right: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.ed-gutter div { height: 22px; }
.ed-gutter .mark-now { color: var(--text); font-weight: 700; }
.ed-gutter .mark-err { color: var(--s-red); font-weight: 700; }
.ed-scroll { position: relative; flex: 1; overflow-x: auto; overflow-y: hidden; display: flex; flex-direction: column; min-width: 0; }
.ed-layer { position: relative; flex: 1 0 auto; width: max-content; min-width: 100%; }
.ed-lines { position: absolute; inset: 10px 0 auto 0; pointer-events: none; }
.ed-lines div { position: absolute; left: 0; right: 0; height: 22px; }
.ed-lines .now { background: var(--s-yellow-soft); box-shadow: inset 2px 0 0 var(--s-yellow-dot); }
.ed-lines .err { background: var(--s-red-soft); box-shadow: inset 2px 0 0 var(--s-red); }
.ed pre, .ed textarea {
  margin: 0; padding: 10px 14px; border: 0; font-family: var(--mono); font-size: 14px; line-height: 22px;
  white-space: pre; tab-size: 4; letter-spacing: 0; word-spacing: 0;
}
.ed pre { position: relative; pointer-events: none; color: var(--code-text); min-height: 100%; }
.ed textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden;
  background: transparent; color: transparent; caret-color: var(--text); outline: none; border-radius: 0; box-shadow: none !important;
}
.ed textarea::selection { background: color-mix(in srgb, var(--s-blue) 28%, transparent); }
.ed.readonly textarea { caret-color: transparent; }
.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-fn { color: var(--tok-fn); }
.symbar { display: none; gap: 6px; overflow-x: auto; padding: 6px 2px; scrollbar-width: none; }
.symbar button { flex: none; min-width: 38px; height: 38px; border-radius: 8px; border: 1px solid transparent; background: var(--btn); font-family: var(--mono); font-size: 15px; cursor: pointer; }
@media (pointer: coarse) {
  .symbar.show { display: flex; }
  .kbd { display: none; }
}
.symbar.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; margin: 0; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--border); }
@media (pointer: coarse) { body.in-editor { padding-bottom: 64px; } }

/* ---------- robot ---------- */
.robot-stage { background: var(--surface-2); border-radius: var(--radius); padding: 10px; }
.robot-stage svg.world { width: 100%; height: auto; display: block; max-height: 360px; margin: 0 auto; }
.map-tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.map-tabs:empty { display: none; }
.map-tab { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 2px 10px; font-size: .8rem; font-weight: 550; cursor: pointer; }
.map-tab.active { border-color: var(--s-yellow-dot); box-shadow: inset 0 0 0 1px var(--s-yellow-dot); }
.map-tab.ok { background: var(--s-green-soft); border-color: var(--s-green); }
.map-tab.bad { background: var(--s-red-soft); border-color: var(--s-red); }
.robot-status { font-size: .88rem; min-height: 1.4em; }
.robot-status .callout { margin: 6px 0 0; padding: 8px 10px; }
.cell-floor { fill: var(--surface); }
.cell-wall { fill: var(--wall); }
.speed { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.speed input { width: 90px; accent-color: var(--muted); }

/* ---------- me ---------- */
.profile { padding: 0; overflow: hidden; }
.profile-banner {
  --c1: #8E9096; --c2: #4B4F56;
  height: 96px; background: color-mix(in srgb, var(--c2) 6%, var(--surface-2)); position: relative; border-bottom: 1px solid var(--border);
}
.profile-banner::after { content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--dots) 1px, transparent 1.4px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000); mask-image: linear-gradient(90deg, transparent 20%, #000); }
.profile-main { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 18px; padding: 12px 24px 0; flex-wrap: wrap; }
.profile-main > .avatar { margin-top: -52px; }
.profile-id { flex: 1; min-width: 200px; padding-top: 2px; }
.profile-id h1 { margin: 0 0 2px; font-size: 1.5rem; }
.profile-id p { margin: 0; color: var(--muted); }
.profile-main #edit-profile { margin-top: 4px; }
.profile-form { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px 16px; padding: 18px 24px 4px; }
.profile-form .field:nth-child(3), .profile-form .row { grid-column: 1 / -1; }
@media (max-width: 640px) { .profile-form { grid-template-columns: 1fr; } }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; transition: box-shadow .15s, transform .15s; }
.swatch:hover span { transform: scale(1.08); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 4px; }
.profile-level { display: flex; align-items: center; gap: 14px; padding: 18px 24px 0; }
.level-info { flex: 1; min-width: 0; display: grid; gap: 8px; }
.level-info .progress { height: 8px; }
.level-badge {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 0; flex: none;
  background: var(--brand); color: var(--brand-ink); font-size: 1.35rem; font-weight: 800; line-height: 1;
  box-shadow: var(--sh-2);
}
.level-badge small { font-size: .55rem; font-weight: 700; letter-spacing: .08em; opacity: .85; margin-bottom: 2px; }
.profile .stat-tiles { padding: 16px 24px 22px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.ach { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 18px 14px 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-1); transition: transform .18s, box-shadow .18s; }
.ach:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.badge-art { width: 64px; height: 64px; margin-bottom: 6px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .14)); }
.ach.locked .badge-art { filter: none; }
.ach b { display: block; font-size: .92rem; font-weight: 650; }
.ach small { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.ach.locked b { color: var(--muted); }
.ach.locked small { color: var(--faint); }
.ach-when { margin-top: 6px; font-size: .72rem; color: var(--faint); display: inline-flex; gap: 4px; align-items: center; }
.ach-when svg.i { width: 12px; height: 12px; }
.kcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.kcard { padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-1); display: flex; flex-direction: column; gap: 7px; position: relative; overflow: hidden; }
.kcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--s-blue); }
.kcard.mastered::before { background: var(--s-green); }
.kcard .term { font-weight: 650; }
.kcard .term .en { color: var(--muted); font-weight: 500; }
.kcard .def { font-size: .9rem; }
.kcard .src { font-size: .78rem; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.kcard > div:last-child { margin-top: auto; }
.settings { display: grid; }
.setting { display: flex; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.setting:first-child { padding-top: 0; }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting .txt { flex: 1; min-width: 200px; font-weight: 550; }
.setting .txt small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- roadmap (personal edition) ---------- */
.layer { margin: 0 0 22px; }
.layer-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; }
.layer-head h3 { margin: 0; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.track { padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 7px; box-shadow: var(--sh-1); transition: transform .18s, box-shadow .18s, border-color .18s; }
a.track:hover, .track-linked:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--sh-2); }
.track.planned { background: var(--surface-2); box-shadow: none; border-style: dashed; }
.track-main { display: flex; flex-direction: column; gap: 7px; color: inherit; text-decoration: none; flex: 1; }
.track-title { display: flex; align-items: center; gap: 10px; }
.track b { font-weight: 650; }
.track small { color: var(--muted); font-size: .82rem; }
.track .progress { margin-top: 2px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 22px 24px 28px; color: var(--muted); font-size: .85rem; background: var(--surface); }
.footer-in { max-width: 1160px; margin: 0 auto; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.footer img { height: 22px; width: auto; display: block; }
.footer .by { display: flex; align-items: center; gap: 10px; }
.footer a { color: var(--muted); }
/* China site: filing numbers (ICP 备案号, 公安联网备案号), centred under the footer */
.footer-filing { max-width: 1160px; margin: 14px auto 0; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px; font-size: .78rem; color: var(--muted); }
.footer-filing a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.footer-filing a:hover { color: var(--text); }
.footer .footer-filing img { height: 16px; width: 16px; display: inline-block; }
.footer-filing .filing-sep { color: var(--faint); }
.footer-filing .filing-slot { border: 1px dashed var(--border-strong); border-radius: 4px; padding: 1px 6px; }
body.in-lesson .footer { display: none; }
@media (max-width: 960px) { body.in-lesson .footer { display: block; } }
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }

/* ---------- fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100vw; height: 100vh; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 16px); opacity: 0; z-index: 60;
  background: var(--toast); color: var(--toast-ink); padding: 10px 18px; border-radius: 10px; font-weight: 550; font-size: .9rem;
  transition: all .25s cubic-bezier(.2, .9, .3, 1.2); pointer-events: none; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--sh-3);
  display: flex; align-items: center; gap: 10px;
}
.toast .toast-art svg { width: 30px; height: 30px; display: block; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); backdrop-filter: blur(2px); z-index: 40; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 26px 24px; max-width: 420px; width: 100%; text-align: center; animation: pop .25s cubic-bezier(.2, .9, .3, 1.2); box-shadow: var(--sh-3); }
.modal h2 { margin-top: 0; }
.modal .row { justify-content: center; margin-top: 16px; }
.modal-badge { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #FCD34D, #F59E0B); box-shadow: 0 8px 22px rgba(245, 158, 11, .4); }
.modal-badge svg.i { width: 30px; height: 30px; }
.modal .big-stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.modal .big-stars span { display: inline-block; animation: starIn .45s cubic-bezier(.2, .9, .3, 1.4) both; }
.modal .big-stars svg.i.star { width: 40px; height: 40px; }
.modal .big-stars span:nth-child(2) { animation-delay: .12s; }
.modal .big-stars span:nth-child(2) svg.i.star { width: 48px; height: 48px; margin-top: -6px; }
.modal .big-stars span:nth-child(3) { animation-delay: .24s; }
@keyframes pop { from { transform: translateY(10px) scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes starIn { from { transform: scale(0) rotate(-30deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .modal, .modal .big-stars span, .modal-back, .btn.pulse { animation: none; }
  a.card:hover, .dir:hover, .track-linked:hover, .ach:hover { transform: none; }
}
@media (max-width: 700px) { .hide-sm { display: none !important; } }
