/* ============================================================
   cc101 — Claude Code 101  ·  design system
   Warm terminal aesthetic · bilingual JA/EN · light & dark
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg: #faf9f5;
  --bg-soft: #f2efe8;
  --panel: #ffffff;
  --ink: #2a2620;
  --muted: #6f6a5e;
  --faint: #a39d8f;
  --line: #e6e2d7;
  --line-strong: #d5d0c2;
  --accent: #c15f3c;
  --accent-soft: #f5e3db;
  --accent-ink: #a04c2e;
  --green: #3d8b57;
  --green-soft: #e2f0e7;
  --amber: #b07818;
  --amber-soft: #f7ecd8;
  --red: #b3363b;
  --red-soft: #f7e0e1;
  --violet: #7a5cc4;
  --violet-soft: #ece5f8;
  --blue: #3a6ea8;
  --blue-soft: #e1ebf5;

  --lv0: #3d8b57;
  --lv1: #3a6ea8;
  --lv2: #b07818;
  --lv3: #7a5cc4;
  --lv4: #c15f3c;

  --term-bg: #1f1c16;
  --term-panel: #2a261e;
  --term-ink: #e8e2d4;
  --term-dim: #9a927f;
  --term-green: #7fc98b;
  --term-amber: #e5b567;
  --term-red: #e07a7a;
  --term-coral: #ef9376;

  --shadow: 0 1px 2px rgba(42, 38, 32, .06), 0 6px 24px -8px rgba(42, 38, 32, .12);
  --shadow-lift: 0 2px 4px rgba(42, 38, 32, .08), 0 14px 40px -12px rgba(42, 38, 32, .22);
  --radius: 12px;
  --radius-lg: 18px;

  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --serif: "Iowan Old Style", "Palatino", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --mono: "SF Mono", ui-monospace, Menlo, Monaco, "Osaka-Mono", monospace;

  --header-h: 58px;
}

/* dark-mode contrast: accents lighten, so CTA text goes dark */
html[data-theme="dark"] .btn.primary,
html[data-theme="dark"] .complete-btn,
html[data-theme="dark"] .level-head .lv-badge { color: #231409; }
html[data-theme="dark"] .complete-btn.done { color: #0e2413; }

html[data-theme="dark"] {
  --bg: #17150f;
  --bg-soft: #1e1b14;
  --panel: #211e17;
  --ink: #ece7db;
  --muted: #a89f8d;
  --faint: #6f6858;
  --line: #332f25;
  --line-strong: #453f31;
  --accent: #e98862;
  --accent-soft: #3a2a21;
  --accent-ink: #f0a184;
  --green: #6dbd85;
  --green-soft: #22301f;
  --amber: #dcab4e;
  --amber-soft: #362c17;
  --red: #e07a7a;
  --red-soft: #3a2323;
  --violet: #a98ee0;
  --violet-soft: #2b2438;
  --blue: #7aa5d8;
  --blue-soft: #1f2a38;

  --lv0: #6dbd85;
  --lv1: #7aa5d8;
  --lv2: #dcab4e;
  --lv3: #a98ee0;
  --lv4: #e98862;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 14px 40px -12px rgba(0, 0, 0, .65);
}

/* ---------- language switching ---------- */
html:not([data-lang="en"]) .en { display: none !important; }
html[data-lang="en"] .ja { display: none !important; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "palt";
  transition: background .25s, color .25s;
}
h1, h2, h3, h4 { line-height: 1.45; letter-spacing: .01em; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { max-width: 100%; }
code { font-family: var(--mono); font-size: .88em; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: .1em .4em; }
pre code { background: none; border: none; padding: 0; font-size: inherit; }
kbd {
  font-family: var(--sans); font-size: .82em; font-weight: 600;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong); border-bottom-width: 2.5px;
  border-radius: 7px; padding: .15em .55em; white-space: nowrap;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- app header (injected) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.appbar .logo {
  font-family: var(--mono); font-weight: 700; font-size: 19px;
  color: var(--ink); text-decoration: none; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 2px; flex: none;
}
.appbar .logo .dot { color: var(--accent); }
.appbar .logo .cursor {
  display: inline-block; width: .55em; height: 1.05em; margin-left: 3px;
  background: var(--accent); border-radius: 2px;
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.appbar .spacer { flex: 1; }
.menu-btn {
  display: none; flex: none;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; padding: 6px 10px; font-size: 15px; cursor: pointer;
}
.progress-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 12px 5px 7px;
  text-decoration: none; white-space: nowrap;
}
.progress-pill:hover { border-color: var(--accent); color: var(--ink); }
.progress-pill .bar {
  width: 54px; height: 7px; border-radius: 99px; background: var(--bg-soft);
  border: 1px solid var(--line); overflow: hidden;
}
.progress-pill .bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}
.lang-switch {
  display: flex; border: 1px solid var(--line); border-radius: 9px;
  overflow: hidden; background: var(--panel); flex: none;
}
.lang-switch button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 700; padding: 6px 11px; cursor: pointer;
  font-family: var(--sans);
}
.lang-switch button.on { background: var(--ink); color: var(--bg); }
.theme-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; width: 34px; height: 34px; cursor: pointer; font-size: 15px;
  flex: none; line-height: 1;
}
.theme-btn:hover, .lang-switch button:not(.on):hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); }
.content { max-width: 780px; margin: 0 auto; padding: 40px 30px 90px; }
body:not(.lesson-page) .content { max-width: 1080px; }

/* ---------- sidebar (injected) ---------- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 14px 40px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
}
.sidebar .lv-head {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 6px 6px; font-weight: 800; font-size: 12.5px;
  letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
}
.sidebar .lv-head:first-child { margin-top: 0; }
.sidebar .lv-head .cnt { margin-left: auto; font-weight: 600; color: var(--faint); font-size: 11.5px; }
.sidebar a.lsn {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; line-height: 1.5;
}
.sidebar a.lsn:hover { background: var(--bg-soft); color: var(--ink); }
.sidebar a.lsn.here { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.sidebar a.lsn .st {
  flex: none; width: 19px; height: 19px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: transparent; background: var(--panel);
  transition: all .3s;
}
.sidebar a.lsn.done .st { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- lesson hero ---------- */
.lesson-hero { margin-bottom: 34px; }
.crumb { font-size: 13px; font-weight: 700; letter-spacing: .05em; color: var(--accent-ink); margin: 0 0 4px; }
.lesson-hero h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: .1em 0 .3em; }
.lede { font-size: 1.08rem; color: var(--muted); margin: 0; }

/* ---------- sections ---------- */
.content { counter-reset: step; }
section.step { margin: 46px 0; counter-increment: step; }
section.step > h2 {
  font-size: 1.32rem; margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 12px;
}
section.step > h2::before {
  content: counter(step);
  flex: none; align-self: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
section.step h3 { font-size: 1.07rem; margin: 26px 0 8px; }
p { margin: .7em 0; }
ul, ol { padding-left: 1.5em; }
li { margin: .35em 0; }

/* ---------- callouts ---------- */
.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
  background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px; margin: 22px 0;
  box-shadow: var(--shadow);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
/* the visible language element may not be :first/:last-child (its hidden twin is) */
.callout > .ja:first-of-type, .callout > .en:first-of-type { margin-top: 0; }
.callout > .ja:last-of-type, .callout > .en:last-of-type { margin-bottom: 0; }
.callout::before {
  display: block; font-weight: 800; font-size: 12.5px;
  letter-spacing: .06em; margin-bottom: 4px;
}
.callout.tip { border-left-color: var(--green); }
.callout.tip::before { content: "💡 TIP"; color: var(--green); }
.callout.note { border-left-color: var(--blue); }
.callout.note::before { content: "📝 NOTE"; color: var(--blue); }
.callout.warn { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber-soft) 45%, var(--panel)); }
.callout.warn::before { content: "⚠️ 注意 / CAREFUL"; color: var(--amber); }
.callout.wow {
  border: 1px solid transparent; border-radius: var(--radius);
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(120deg, var(--accent), var(--violet), var(--blue)) border-box;
}
.callout.wow::before { content: "✨ WOW"; background: linear-gradient(90deg, var(--accent), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.callout.try { border: 1.5px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel)); }
.callout.try::before { content: "🎯 やってみよう / TRY IT"; color: var(--accent-ink); }

/* ---------- command & code blocks ---------- */
.cmd, .codeblock { margin: 18px 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; }
.cmd pre, .codeblock pre {
  margin: 0; padding: 14px 52px 14px 18px;
  background: var(--term-bg); color: var(--term-ink);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.75;
  overflow-x: auto;
}
.cmd pre code::before { content: "$ "; color: var(--term-green); font-weight: 700; }
.codeblock .file-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--term-panel); color: var(--term-dim);
  font-family: var(--mono); font-size: 12px;
  padding: 7px 14px; width: 100%;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .07);
  color: var(--term-dim); border-radius: 7px;
  font-size: 11.5px; font-family: var(--sans); font-weight: 600;
  padding: 4px 9px; cursor: pointer; transition: all .15s;
}
.codeblock:has(.file-tab) .copy-btn { top: 42px; } /* safe fallback: stays at 8px without :has() */
.copy-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.copy-btn.ok { color: var(--term-green); border-color: var(--term-green); }
.copy-btn.ng { color: var(--term-red); border-color: var(--term-red); }

/* ---------- terminal demo ---------- */
.term-demo { margin: 26px 0; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lift); }
.term-head {
  display: flex; align-items: center; gap: 8px;
  background: var(--term-panel); padding: 10px 14px;
}
.term-head .dots { display: flex; gap: 7px; }
.term-head .dots i { width: 12px; height: 12px; border-radius: 50%; }
.term-head .dots i:nth-child(1) { background: #f26d5f; }
.term-head .dots i:nth-child(2) { background: #f2be4f; }
.term-head .dots i:nth-child(3) { background: #5fc454; }
.term-head .ttl {
  flex: 1; text-align: center;
  font-family: var(--mono); font-size: 12px; color: var(--term-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.term-head .ctl { display: flex; gap: 6px; }
.term-head .ctl button {
  border: 1px solid rgba(255, 255, 255, .14); background: transparent;
  color: var(--term-dim); border-radius: 6px; font-size: 11px;
  padding: 2px 8px; cursor: pointer; font-family: var(--sans);
}
.term-head .ctl button:hover { color: #fff; border-color: rgba(255, 255, 255, .35); }
.term-body {
  background: var(--term-bg); color: var(--term-ink);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.8;
  padding: 16px 18px; min-height: 130px; max-height: 420px; overflow-y: auto;
}
.term-body .tl { white-space: pre-wrap; word-break: break-word; animation: tl-in .18s ease-out; }
@keyframes tl-in { from { opacity: 0; transform: translateY(3px); } }
.tl .pfx { font-weight: 700; margin-right: 8px; }
/* step classes are prefixed s- so they never collide with content classes like .cmd */
.tl.s-cmd .pfx { color: var(--term-green); }
.tl.s-user { color: var(--term-amber); }
.tl.s-user .pfx { color: var(--term-amber); }
.tl.s-claude { color: var(--term-ink); }
.tl.s-claude .pfx { color: var(--term-coral); }
.tl.s-out { color: var(--term-dim); }
.tl.s-info { color: var(--term-dim); }
.tl.s-ok { color: var(--term-green); }
.tl.s-err { color: var(--term-red); }
.tl.s-think { color: var(--term-dim); font-style: italic; }
.tl.s-think .pfx { display: inline-block; font-style: normal; color: var(--term-coral); animation: spin-star 1.6s linear infinite; }
@keyframes spin-star { to { transform: rotate(360deg); } }
.type-cursor {
  display: inline-block; width: .55em; height: 1.1em;
  background: var(--term-ink); vertical-align: text-bottom;
  margin-left: 1px; border-radius: 1px;
  animation: blink .9s steps(1) infinite;
}

/* ---------- quiz ---------- */
.quiz {
  margin: 44px 0; padding: 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.quiz .quiz-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.15rem; font-weight: 800; margin: 0 0 6px;
}
.quiz .quiz-sub { color: var(--muted); font-size: .92rem; margin: 0 0 18px; }
.qcard { margin: 20px 0 0; padding-top: 18px; border-top: 1px dashed var(--line); }
.qcard .qnum {
  display: inline-block; font-family: var(--mono); font-size: 12px; font-weight: 700;
  background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--muted); border-radius: 7px; padding: 2px 9px; margin-bottom: 6px;
}
.qcard .qtext { font-weight: 700; margin: 4px 0 12px; }
.choices { display: grid; gap: 9px; }
.choice {
  text-align: left; font-family: var(--sans); font-size: 15px; line-height: 1.7;
  color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 11px;
  padding: 11px 15px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.choice:not(:disabled):hover { border-color: var(--accent); transform: translateX(3px); }
.choice:disabled { cursor: default; opacity: .82; }
.choice.correct { border-color: var(--green); background: var(--green-soft); color: var(--ink); opacity: 1; font-weight: 700; }
.choice.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .35s; opacity: 1; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.qexplain {
  margin-top: 12px; padding: 12px 15px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-size: .93rem; animation: tl-in .3s ease-out;
}
.qexplain .verdict { font-weight: 800; display: block; margin-bottom: 3px; }
.qexplain.good .verdict { color: var(--green); }
.qexplain.bad .verdict { color: var(--red); }
.quiz-result {
  margin-top: 22px; padding: 16px 18px; text-align: center;
  border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line);
  animation: tl-in .35s ease-out;
}
.quiz-result .score { font-size: 1.5rem; font-weight: 800; display: block; }
.quiz-result .score em { font-style: normal; color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  border-radius: 12px; padding: 11px 22px; cursor: pointer;
  text-decoration: none; border: 1.5px solid transparent;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- lesson footer (injected) ---------- */
.lesson-foot { margin-top: 60px; }
.complete-wrap { text-align: center; padding: 30px 0 10px; border-top: 1px solid var(--line); }
.complete-btn {
  font-size: 16.5px; padding: 14px 34px; border-radius: 99px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  font-weight: 800; font-family: var(--sans);
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, background .2s;
}
.complete-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: var(--shadow-lift); }
.complete-btn.done { background: var(--green); }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 30px; }
.prevnext a {
  display: block; padding: 15px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
  min-width: 0;
}
.prevnext a:hover { transform: translateY(-2px); border-color: var(--accent); }
.prevnext a.next { text-align: right; grid-column: 2; }
.prevnext .dir { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.prevnext .ttl2 { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- tables / misc content ---------- */
.tablewrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; background: var(--panel); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-size: .85rem; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
details.more { margin: 22px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
details.more summary { cursor: pointer; font-weight: 700; padding: 13px 18px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸ "; color: var(--accent); }
details.more[open] summary::before { content: "▾ "; }
details.more > *:not(summary) { padding: 0 18px; }
details.more > :last-child { padding-bottom: 14px; }
details.more > .ja:last-of-type, details.more > .en:last-of-type { padding-bottom: 14px; }
ul.checklist { list-style: none; padding-left: .2em; }
ul.checklist li { padding-left: 1.7em; position: relative; }
ul.checklist li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--green); font-weight: 800;
}
.nextup { margin-top: 34px; color: var(--muted); font-style: italic; }
.nextup::before { content: "👉 "; font-style: normal; }

/* ---------- index page ---------- */
.hero { text-align: center; padding: 46px 0 30px; }
.hero .mark {
  font-family: var(--mono); font-weight: 800; letter-spacing: -.03em;
  font-size: clamp(3rem, 9vw, 5rem); line-height: 1.1; margin: 0;
}
.hero .mark .c1 { color: var(--accent); }
.hero .mark .cursor {
  display: inline-block; width: .5em; height: .95em; margin-left: .06em;
  background: var(--accent); border-radius: 4px; vertical-align: baseline;
  animation: blink 1.15s steps(1) infinite;
}
.hero .tagline { font-size: clamp(1.05rem, 2.6vw, 1.35rem); font-weight: 700; margin: 14px 0 4px; }
.hero .sub { color: var(--muted); max-width: 620px; margin: 6px auto 0; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 26px 0 8px; }
.hero .term-demo { max-width: 640px; margin: 34px auto 0; text-align: left; }

.stats-row {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  margin: 38px auto 8px;
}
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 14px 22px; box-shadow: var(--shadow);
  min-width: 180px;
}
.stat-card .big { font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.stat-card .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.22, 1, .36, 1); }
.ring-wrap { position: relative; width: 64px; height: 64px; flex: none; }
.ring-wrap .pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; font-family: var(--mono);
}

.home-sect { margin: 64px 0; }
.home-sect > h2 { font-size: 1.5rem; text-align: center; margin-bottom: 8px; }
.home-sect > .sect-sub { text-align: center; color: var(--muted); margin: 0 0 30px; }

.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; text-align: center; box-shadow: var(--shadow);
}
.how-card .ico { font-size: 2rem; display: block; margin-bottom: 8px; }
.how-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.how-card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.8; }

.level-block { margin: 34px 0; }
.level-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.level-head .lv-badge {
  font-family: var(--mono); font-weight: 800; font-size: 13px; color: #fff;
  border-radius: 9px; padding: 4px 10px; flex: none;
}
.level-head h3 { margin: 0; font-size: 1.2rem; }
.level-head .lv-progress { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 700; }
.lesson-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lesson-card {
  position: relative; display: block;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px;
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .16s, border-color .16s, box-shadow .16s;
  overflow: hidden;
}
.lesson-card:hover { transform: translateY(-3px); border-color: var(--card-accent, var(--accent)); box-shadow: var(--shadow-lift); }
.lesson-card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lesson-card .ico { font-size: 1.5rem; }
.lesson-card .lid { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--faint); }
.lesson-card .check {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent; transition: all .3s;
}
.lesson-card.done .check { background: var(--green); border-color: var(--green); color: #fff; }
.lesson-card .t { font-weight: 700; line-height: 1.55; display: block; }
.lesson-card .quiz-stars { display: block; margin-top: 6px; font-size: 11.5px; color: var(--amber); font-weight: 700; }

.badge-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge-card {
  text-align: center; padding: 18px 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  transition: transform .15s;
}
.badge-card:hover { transform: translateY(-2px); }
.badge-card .bico { font-size: 2.1rem; display: block; margin-bottom: 6px; }
.badge-card .bname { font-weight: 800; font-size: .88rem; display: block; }
.badge-card .bdesc { font-size: .76rem; color: var(--muted); line-height: 1.6; display: block; margin-top: 3px; }
.badge-card.locked { opacity: .45; }
.badge-card.locked .bico { filter: grayscale(1); }
.badge-card.earned { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.badge-card.earned .bico { animation: badge-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes badge-pop { 0% { transform: scale(.4); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }

.foot {
  margin-top: 80px; padding: 26px 0 10px; border-top: 1px solid var(--line);
  text-align: center; color: var(--muted); font-size: .85rem; line-height: 2;
}
.foot a { color: var(--muted); }
.foot .heart { color: var(--accent); }

/* ---------- toast ---------- */
.toast-zone { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 14px; padding: 13px 18px; max-width: 340px;
  box-shadow: var(--shadow-lift);
  animation: toast-in .35s cubic-bezier(.34, 1.4, .64, 1);
}
.toast.out { animation: toast-out .3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }
.toast .tico { font-size: 1.7rem; flex: none; }
.toast .tt { font-weight: 800; font-size: .92rem; display: block; }
.toast .td { font-size: .8rem; color: var(--muted); display: block; line-height: 1.6; }
.toast.badge-toast {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(120deg, var(--amber), var(--accent), var(--violet)) border-box;
}

/* ---------- certificate ---------- */
.cert-zone {
  margin: 40px 0; padding: 26px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
  background: var(--panel);
}
.cert-zone.unlocked { border-style: solid; border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.cert-zone input {
  font-family: var(--serif); font-size: 1.1rem; text-align: center;
  border: none; border-bottom: 2px solid var(--line-strong);
  background: transparent; color: var(--ink);
  padding: 8px 6px; margin: 12px 0 18px; width: min(320px, 90%);
}
.cert-zone input:focus { outline: none; border-bottom-color: var(--accent); }
.cert-zone canvas { max-width: 100%; border-radius: 10px; box-shadow: var(--shadow-lift); margin-top: 18px; }

/* ---------- confetti & fx ---------- */
.fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 999; }

/* ---------- sidebar mobile ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .25s; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  body.nav-open { overflow: hidden; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; width: 300px; z-index: 80;
    transform: translateX(-104%); transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    box-shadow: var(--shadow-lift); padding-top: 20px;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .how-grid, .lesson-grid { grid-template-columns: 1fr 1fr; }
  .progress-pill .lbl-title { display: none; }
}
@media (max-width: 620px) {
  .content { padding: 28px 18px 70px; }
  .how-grid, .lesson-grid { grid-template-columns: 1fr; }
  body { font-size: 15.5px; }
  .prevnext { grid-template-columns: 1fr; }
  .prevnext a.next { grid-column: auto; }
  .appbar { gap: 6px; padding: 0 10px; }
  .progress-pill .bar { display: none; }
  .progress-pill { padding: 5px 10px; }
  .lang-switch button { padding: 6px 8px; }
}

/* ---------- print (cheatsheet) ---------- */
@media print {
  .appbar, .toast-zone, .fx-canvas, .copy-btn, .no-print { display: none !important; }
  body { background: #fff; color: #111; font-size: 12px; }
  .content { max-width: none; padding: 0; }
  .tablewrap, .callout, .cmd, .codeblock { box-shadow: none; break-inside: avoid; }
  /* force light tokens even if the on-screen theme was dark */
  :root, html[data-theme="dark"] {
    --bg: #fff; --bg-soft: #f4f3ef; --panel: #fff;
    --ink: #111; --muted: #444; --faint: #777;
    --line: #ccc; --line-strong: #aaa;
    --accent: #b04c2c; --accent-ink: #8a3a20; --accent-soft: #f2e4dd;
  }
  /* terminals & code: browsers strip background colors, so go dark-on-white */
  .cmd pre, .codeblock pre, .term-body { background: #fff !important; color: #111 !important; border: 1px solid #bbb; }
  .codeblock .file-tab { background: #eee; color: #333; border-bottom-color: #ccc; }
  .cmd pre code::before { color: #111; }
  .term-head { background: #eee; }
  .term-head .ttl { color: #333; }
  .term-head .ctl { display: none; }
  .tl.s-out, .tl.s-info, .tl.s-think { color: #555; }
  .tl.s-cmd, .tl.s-user, .tl.s-claude, .tl.s-ok, .tl.s-err { color: #111; }
  .tl .pfx { color: #111 !important; }
  .type-cursor { display: none; }
  code { background: #f4f3ef; border-color: #ccc; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
