/* C# Lab — site styles.
   Design language aligned with Xiaomi's official UI (mi.com / HyperOS):
   MiSans-first font stack, signature orange accent, big radii, airy spacing,
   high-contrast code terminal kept for readability. Light/dark via [data-theme]. */

:root {
  --bg: #f7f6f4;                       /* warm paper white, not clinical gray */
  --bg-soft: #ffffff;
  --fg: #1a1a1a;                        /* near-black text, Xiaomi style */
  --muted: #737373;
  --line: #e8e6e3;
  --brand: #ff6900;                     /* Xiaomi signature orange */
  --brand-strong: #e55e00;
  --brand-soft: #fff1e8;
  --ok: #0f8a4f;
  --ok-soft: #e8f7ef;
  --err: #d94040;
  --err-soft: #fdeeee;
  --warn: #c07f00;
  --code-bg: #191b1f;                   /* terminal stays dark in BOTH themes */
  --code-fg: #e8eaf0;
  --tok-k: #ff9d5c;                     /* keywords: orange family on dark */
  --tok-s: #7ed49a;
  --tok-c: #7d8590;
  --tok-sd: #f2a3c0;
  --tok-n: #ffd07e;
  --radius-lg: 24px;                    /* HyperOS-scale rounding */
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 16, 12, .04), 0 10px 32px rgba(20, 16, 12, .06);
  --nav-h: 60px;
}
[data-theme="dark"] {
  --bg: #101013;
  --bg-soft: #1a1b1f;
  --fg: #f2f2f0;
  --muted: #9b9b9b;
  --line: #2a2b30;
  --brand: #ff7d1f;                     /* slightly lifted orange for dark bg */
  --brand-strong: #ff8f3d;
  --brand-soft: #2c1c0f;
  --ok: #4ade80;
  --ok-soft: #10261a;
  --err: #f87171;
  --err-soft: #2e1518;
  --warn: #fbbf24;
  --code-bg: #121317;
  --code-fg: #e8eaf0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 32px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
/* keep anchor targets and scrolled-to elements clear of the sticky header */
.runnable, h1, h2, h3 { scroll-margin-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  font: 16px/1.65 MiSans, "MI Lan Pro", "HarmonyOS Sans SC", -apple-system, BlinkMacSystemFont,
        "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; color: var(--brand-strong); }
code, pre, textarea.editor, .term-title {
  font-family: "Cascadia Code", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
code {
  background: var(--brand-soft);
  color: var(--brand-strong);
  padding: .1em .4em;
  border-radius: 6px;
  font-size: .92em;
}
[data-theme="dark"] code { color: var(--brand); }
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.6;
  font-size: 14px;
  margin: 16px 0;
  position: relative;
}
pre code { background: none; padding: 0; color: inherit; font-size: 1em; }
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-s { color: var(--tok-s); }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-sd { color: var(--tok-sd); }
.tok-n { color: var(--tok-n); }
.tok-p { color: var(--tok-n); }

/* ---------- header: white bar, black text, orange active — mi.com style ---------- */
header.site {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
nav.nav {
  max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
}
nav.nav::-webkit-scrollbar { display: none; }
a.brand {
  font-weight: 900; font-size: 19px; color: var(--fg);
  letter-spacing: -.02em; display: flex; align-items: center; gap: 8px;
  white-space: nowrap; flex-shrink: 0;
}
a.brand::before {                       /* small square logo mark, mi-orange */
  content: ""; width: 22px; height: 22px; border-radius: 6px;
  background: var(--brand);
  -webkit-mask: none; display: inline-block;
  box-shadow: inset 0 0 0 22px var(--brand);
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><text x="12" y="18" font-size="16" font-weight="bold" text-anchor="middle" fill="black">C#</text></svg>') center / contain no-repeat;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><text x="12" y="18" font-size="16" font-weight="bold" text-anchor="middle" fill="black">C#</text></svg>') center / contain no-repeat;
}
a.link { color: var(--fg); font-size: 15px; padding: 4px 0; white-space: nowrap; position: relative; }
a.link:hover { color: var(--brand); }
a.link.active { color: var(--brand); font-weight: 600; }
a.link.active::after {                  /* short orange underline, mi.com pattern */
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 2px; border-radius: 2px; background: var(--brand);
}
a.lang-switch { font-size: 13px; color: var(--muted); }
button.theme-toggle {
  margin-left: auto; background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 15px;
  color: var(--fg); flex-shrink: 0;
}
footer.site { border-top: 1px solid var(--line); margin-top: 72px; }
footer.site .wrap {
  max-width: 1200px; margin: 0 auto; padding: 28px 24px;
  display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 14px;
}

/* ---------- layout ---------- */
main.wrap { max-width: 920px; margin: 0 auto; padding: 44px 24px 24px; }

/* hand-drawn marker underline — the site's visual signature */
main.wrap.prose h2,
.directory h2 {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8 C 22 3 44 10 62 6 S 100 3 117 7' fill='none' stroke='%23FF6900' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat left bottom / 110px 10px;
  padding-bottom: 13px;
}
.hero h1 {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M4 10 C 40 4 90 12 130 7 S 180 4 196 9' fill='none' stroke='%23FF6900' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat left bottom / 210px 13px;
  padding-bottom: 16px;
}
[data-theme="dark"] main.wrap.prose h2,
[data-theme="dark"] .directory h2 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8 C 22 3 44 10 62 6 S 100 3 117 7' fill='none' stroke='%23FF7D1F' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
[data-theme="dark"] .hero h1 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M4 10 C 40 4 90 12 130 7 S 180 4 196 9' fill='none' stroke='%23FF7D1F' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* floating hand-drawn doodles (hero accents) */
.hero { position: relative; }
.doodle {
  position: absolute; pointer-events: none; color: var(--brand); opacity: .26;
}
.doodle path {
  fill: none; stroke: currentColor;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.doodle-brace { top: -10px; right: 6%; width: 36px; transform: rotate(14deg); }
.doodle-slash { top: -16px; left: 1.5%; width: 22px; transform: rotate(-8deg); opacity: .22; }
.doodle-inline {
  display: inline-block; width: 34px; height: 15px; vertical-align: -3px;
  margin-right: 6px; color: var(--brand); opacity: .8;
}
.doodle-inline path {
  fill: none; stroke: currentColor;
  stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
}
@media (max-width: 640px) {
  .doodle-brace, .doodle-slash { display: none; }
  .doodle-inline { width: 26px; }
}

/* hand-drawn spark on collapsible sections (hints / solution) */
details > summary::before {
  content: ""; display: inline-block; width: 13px; height: 13px;
  margin-right: 9px; vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 3 L10 17 M4 6 C8 9 12 11 16 14 M16 6 C12 9 8 11 4 14' fill='none' stroke='%23FF6900' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
[data-theme="dark"] details > summary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 3 L10 17 M4 6 C8 9 12 11 16 14 M16 6 C12 9 8 11 4 14' fill='none' stroke='%23FF7D1F' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

main.wrap.prose h1 { font-size: 40px; line-height: 1.15; margin: 8px 0 12px; letter-spacing: -.025em; font-weight: 800; }
main.wrap.prose h2 { font-size: 26px; margin-top: 48px; letter-spacing: -.015em; font-weight: 700; }
main.wrap.prose h3 { font-size: 19px; margin-top: 30px; font-weight: 650; }
.tagline { color: var(--muted); font-size: 18px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13.5px; }
.card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 8px 24px; box-shadow: var(--shadow);
}
.badge {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  border-radius: 999px; padding: 4px 14px; background: var(--brand-soft);
  color: var(--brand-strong);
}
.badge.b-easy { background: var(--ok-soft); color: var(--ok); }
.badge.b-med { background: #fff4e0; color: var(--warn); }
[data-theme="dark"] .badge.b-med { background: #2e2410; }

/* ---------- hero: airy, big type, orange chips ---------- */
.hero { padding: 20px 0 8px; position: relative; }
/* notebook paper grid — subtle, fades out at the edges */
.hero::before {
  content: ""; position: absolute; inset: -18px -28px 0; z-index: -1;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(120% 90% at 30% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 30% 0%, #000 0%, transparent 72%);
  opacity: .5;
  pointer-events: none;
}
.hero h1 { font-size: 44px; margin: 8px 0 10px; letter-spacing: -.03em; font-weight: 900; }
.hero-chips { display: flex; gap: 10px; flex-wrap: wrap; padding: 0; margin: 18px 0 0; }
.chip {
  list-style: none; font-size: 13px; color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px;
  background: var(--bg-soft);
}
.chip::before { content: "●"; color: var(--brand); font-size: 9px; margin-right: 8px; vertical-align: 2px; }
.chip em { font-style: normal; position: relative; }
/* a hand-drawn circle around the emphasised word — the "annotated notes" look */
.chip em::after {
  content: ""; position: absolute; inset: -7px -9px; 
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40' preserveAspectRatio='none'%3E%3Cpath d='M10 20 C 10 8 40 4 62 6 C 92 8 112 12 110 21 C 108 31 76 36 52 34 C 24 32 8 28 10 19 C 11 14 16 10 24 8' fill='none' stroke='%23FF6900' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  opacity: .55; pointer-events: none;
}

/* ---------- stat strip: real numbers, not marketing fluff ---------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0; margin: 34px 0 6px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-soft); box-shadow: var(--shadow); overflow: hidden;
}
.stat { padding: 18px 16px; text-align: center; border-left: 1px solid var(--line); }
.stat:first-child { border-left: none; }
.stat b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); line-height: 1.1; }
.stat span { display: block; margin-top: 5px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ---------- hand-drawn section divider ---------- */
.divider {
  height: 14px; margin: 46px 0 0; border: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M2 9 C 24 4 42 12 64 8 C 86 4 104 12 126 8 C 148 4 168 11 198 7' fill='none' stroke='%23c9c5bf' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center / 200px 14px;
  opacity: .7;
}
[data-theme="dark"] .divider {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M2 9 C 24 4 42 12 64 8 C 86 4 104 12 126 8 C 148 4 168 11 198 7' fill='none' stroke='%233a3c44' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ---------- feature cards with hand-drawn icons ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-top: 30px; }
a.feature {
  display: block; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 24px 20px; color: var(--fg);
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
a.feature:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(20, 16, 12, .1); border-color: transparent; }
a.feature h3 { margin: 0 0 8px; font-size: 17px; color: var(--fg); }
a.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
a.feature::after { content: "→"; color: var(--brand); font-weight: 700; display: inline-block; margin-top: 10px; }
.f-icon {
  width: 44px; height: 44px; border-radius: 13px; margin-bottom: 14px;
  display: grid; place-items: center;
  background: var(--brand-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M6 34 C 14 30 20 36 28 33' fill='none' stroke='%23FF6900' stroke-width='0'/%3E%3C/svg%3E");
}
.f-icon svg { width: 24px; height: 24px; }
.f-icon path, .f-icon circle, .f-icon line, .f-icon polyline {
  fill: none; stroke: var(--brand); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- playground ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 30px 0 14px; }
button.primary, button.run-btn, .judge-actions button {
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  font: 600 15px/1 inherit; padding: 12px 26px; border-radius: 999px;
  transition: background .15s ease, transform .1s ease;
}
button.primary:hover, button.run-btn:hover { background: var(--brand-strong); }
button.primary:active, button.run-btn:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
.judge-actions button:not(.primary) {
  background: var(--bg-soft); color: var(--fg); border: 1px solid var(--line);
}
.term {
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow); background: var(--code-bg);
}
.term-bar {
  display: flex; align-items: center; gap: 7px; padding: 12px 18px;
  background: #23252b; border-bottom: 1px solid #303339;
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.term-title { margin-left: 8px; font-size: 12.5px; color: #9aa0aa; }
textarea.editor {
  display: block; width: 100%; min-height: 320px; padding: 20px;
  border: none; outline: none; resize: vertical;
  background: var(--code-bg); color: var(--code-fg);
  font-size: 14px; line-height: 1.65; tab-size: 4;
}
details.stdin { margin: 14px 0; }
details.stdin summary { cursor: pointer; color: var(--muted); font-size: 14px; }
textarea.stdin-box {
  width: 100%; min-height: 64px; margin-top: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--fg);
  font-family: "Cascadia Code", ui-monospace, Menlo, Consolas, monospace; font-size: 14px;
}

/* ---------- output ---------- */
.out {
  background: var(--code-bg); color: var(--code-fg);
  border-radius: var(--radius-md);
  padding: 16px 18px; margin-top: 16px;
  font-family: "Cascadia Code", ui-monospace, Menlo, Consolas, monospace; font-size: 14px;
  white-space: pre-wrap; word-break: break-word; min-height: 24px;
}
.out.ok { border: 1px solid rgba(74, 222, 128, .35); }
.out.err { border: 1px solid rgba(248, 113, 113, .4); color: var(--err); }
.out .meta { margin-top: 10px; color: #9aa0aa; font-size: 12.5px; }

/* ---------- runnable blocks ---------- */
.runnable { margin: 22px 0; }
.run-row { display: flex; align-items: center; gap: 12px; margin-top: -4px; }
.run-row .status { color: var(--muted); font-size: 13px; }
textarea.run-in {
  display: block;
  width: 100%;
  max-width: 440px;
  margin: 6px 0 12px;
  padding: 9px 13px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--fg);
  font-family: "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13.5px;
  resize: vertical;
}
textarea.run-in:focus { border-color: var(--brand); border-style: solid; outline: none; }
pre.run-out {
  margin-top: 10px; display: block; white-space: pre-wrap; word-break: break-word; min-height: 20px;
}
pre.run-out.ok { border: 1px solid rgba(74, 222, 128, .35); }
pre.run-out.err { border: 1px solid rgba(248, 113, 113, .4); color: var(--err); }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255, 255, 255, .08); color: #cfd4dd;
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px;
  font-size: 12px; padding: 4px 12px; cursor: pointer; opacity: 0;
  transition: opacity .15s ease;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn.done { color: #7ed49a; border-color: #7ed49a; }

/* ---------- judge panel ---------- */
.judge-panel { margin-top: 20px; }
.judge-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.summary { border-radius: var(--radius-md); padding: 14px 18px; font-size: 15px; margin-bottom: 14px; }
.summary.accepted { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.summary.failed { background: var(--err-soft); color: var(--err); }
.summary.running { background: var(--brand-soft); color: var(--brand-strong); }
[data-theme="dark"] .summary.running { color: var(--brand); }
.test-result { border: 1px solid var(--line); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; background: var(--bg-soft); }
.test-result.pass { border-color: rgba(74, 222, 128, .35); }
.test-result.fail { border-color: rgba(248, 113, 113, .4); }
.t-head { padding: 10px 16px; font-size: 14px; font-weight: 600; }
.test-result.pass .t-head { color: var(--ok); background: var(--ok-soft); }
.test-result.fail .t-head { color: var(--err); background: var(--err-soft); }
.t-io { display: grid; gap: 12px; padding: 14px 16px; }
.t-io.three { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.io-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.io-box pre { margin: 0; font-size: 13px; padding: 10px 12px; min-height: 38px; background: var(--code-bg); color: var(--code-fg); }
.io-box pre.good { border: 1px solid rgba(74, 222, 128, .35); }
.io-box pre.bad { border: 1px solid rgba(248, 113, 113, .45); }

/* ---------- misc ---------- */
table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 14.5px; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; }
th { background: var(--brand-soft); color: var(--brand-strong); font-weight: 650; }
[data-theme="dark"] th { color: var(--brand); }
details { margin: 14px 0; }
details summary { cursor: pointer; font-weight: 600; }
.directory h2 { margin-top: 40px; }
.directory ul { padding-left: 0; list-style: none; }
.directory li { margin: 12px 0; }
.directory .item-desc { color: var(--muted); font-size: 14.5px; }
@media (hover: none) {
  .copy-btn { opacity: .85; }
}
@media (max-width: 640px) {
  .hero::before { opacity: .3; background-size: 22px 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: none; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .divider { margin-top: 34px; }
  main.wrap { padding-top: 26px; }
  .hero h1 { font-size: 32px; }
  main.wrap.prose h1 { font-size: 30px; }
  main.wrap.prose h2 { font-size: 22px; }
  textarea.editor { min-height: 240px; }
  nav.nav { gap: 16px; padding: 0 16px; }
  a.link { font-size: 14px; }
  button.theme-toggle { padding: 4px 8px; }
}

/* ---------- inner-page accents: progress rail + eyebrow rule ---------- */
/* a thin orange rail down the left of long-form pages, like a ruled margin */
.wrap.prose { position: relative; }
@media (min-width: 900px) {
  .wrap.prose::before {
    content: ""; position: absolute; left: -26px; top: 42px; bottom: 40px; width: 3px;
    border-radius: 3px;
    background: linear-gradient(to bottom,
      var(--brand) 0%, var(--brand) 12%,
      color-mix(in srgb, var(--brand) 18%, transparent) 30%,
      color-mix(in srgb, var(--brand) 8%, transparent) 100%);
    opacity: .5;
  }
}
/* the small badge at the top of a lesson/article becomes a proper eyebrow */
main.wrap.prose > p:first-child .badge {
  background: transparent; border: 1px solid var(--brand);
  color: var(--brand); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  font-size: 11.5px; padding: 4px 13px;
}
[data-theme="dark"] main.wrap.prose > p:first-child .badge { border-color: var(--brand); }

/* code blocks get a faint paper tint so they read as "examples", not body text */
pre.codeblock { border: 1px solid var(--line); }
pre.codeblock::after {
  content: "example"; position: absolute; top: 8px; right: 10px;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--code-fg) 38%, transparent); pointer-events: none;
}

/* ---------- "error scene": the failing line, drawn ---------- */
.err-scene {
  margin-top: 10px; border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--err) 42%, var(--line));
  background: var(--code-bg);
  font-family: "Cascadia Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--err) 10%, transparent);
  animation: errIn .18s ease-out;
}
@keyframes errIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.err-scene-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: color-mix(in srgb, var(--err) 15%, var(--code-bg));
  border-bottom: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
}
.err-stamp {
  font-weight: 700; font-size: 11.5px; letter-spacing: .06em;
  padding: 2px 9px; border-radius: 5px;
  color: #fff; background: var(--err);
}
.err-where { font-size: 12px; color: color-mix(in srgb, var(--err) 70%, var(--code-fg)); opacity: .85; }

.err-code {
  margin: 0; padding: 10px 0; background: transparent; border: none;
  font-size: 13px; line-height: 1.75; overflow-x: auto;
}
.err-line { display: block; white-space: pre; }
.err-line.is-bad {
  background: color-mix(in srgb, var(--err) 13%, transparent);
  box-shadow: inset 3px 0 0 var(--err);
}
.err-gutter {
  display: inline-block; width: 3.2em; padding-right: .9em;
  text-align: right; color: color-mix(in srgb, var(--code-fg) 34%, transparent);
  user-select: none;
}
.err-line.is-bad .err-gutter { color: var(--err); font-weight: 700; }
.err-src { position: relative; }
.err-line.is-bad .err-src {
  /* the classic spell-checker squiggle, drawn with a repeating gradient */
  text-decoration: underline wavy var(--err);
  text-decoration-thickness: 1.4px;
  text-underline-offset: 4px;
}

.err-msg {
  padding: 10px 14px 12px;
  font-size: 12.5px; line-height: 1.55;
  color: color-mix(in srgb, var(--err) 82%, var(--code-fg));
  border-top: 1px dashed color-mix(in srgb, var(--err) 26%, transparent);
  white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 640px) {
  .err-code { font-size: 12px; }
  .err-gutter { width: 2.6em; }
}

/* ---------- playground egg ---------- */
pre.egg {
  margin: 12px 0 0; padding: 14px 16px;
  background: transparent; border: none;
  border-left: 3px solid var(--brand);
  color: var(--brand);
  font-size: 13px; line-height: 1.6;
  white-space: pre-wrap;
  opacity: .95;
  animation: eggIn .35s ease-out;
}
@keyframes eggIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: .95; transform: none; } }

/* ---------- egg hint in the footer (a quiet 🥚) ---------- */
a.egg-hint {
  margin-left: auto; text-decoration: none; font-size: 15px;
  opacity: .35; transition: opacity .18s ease, transform .18s ease;
  filter: grayscale(1);
}
a.egg-hint:hover { opacity: 1; transform: rotate(-14deg) scale(1.15); filter: none; }
