* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --nav: #16243a; --nav-hover: #233751; --nav-active: #1c56ac; --nav-text: #e8effa;
  --bg: #f3f6fb; --panel: #fff; --text: #121e33; --muted: #4e617c;
  --line: #e0e7f0; --accent: #115acc; --link: #1357bc; --soft: #eaf2ff;
  --success: #15754f; --success-bg: #e6f6ed; --warn: #9b4900; --warn-bg: #fff0df;
  --danger: #aa3342; --danger-bg: #ffedf0; --purple: #6341b0; --purple-bg: #f1eaff;
  --shadow: 0 2px 5px #1429450a; --header-height: 66px;
  font: 15px/1.52 "Inter", "Segoe UI", system-ui, sans-serif;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --nav: #101a2b; --nav-hover: #20344f; --nav-active: #214d8a; --nav-text: #edf3ff;
  --bg: #121c2b; --panel: #1a283b; --text: #f0f5ff; --muted: #afc0d8;
  --line: #314158; --accent: #1c63cf; --link: #9bc4ff; --soft: #213952;
  --success: #9ae3bb; --success-bg: #203f36; --warn: #ffcd9b; --warn-bg: #493629;
  --danger: #ffb0b8; --danger-bg: #502d3a; --purple: #d3baff; --purple-bg: #372d55;
  --shadow: 0 2px 8px #080e1860;
}
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  display: grid; grid-template: auto 1fr auto / 244px minmax(0, 1fr);
}
a { color: var(--link); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; }
button, .button {
  background: var(--accent); color: white; border: 1px solid transparent; padding: .5rem .85rem;
  border-radius: .5rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; text-decoration: none; font-weight: 650;
}
button.secondary, .button.secondary { background: var(--panel); color: var(--link); border-color: var(--line); }
button:disabled { opacity: .55; cursor: wait; }
button:hover, .button:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--link), transparent 65%); }
:focus-visible { outline: 3px solid #f49d3c; outline-offset: 3px; }
input:not([type=checkbox], [type=radio]), select, textarea {
  color: var(--text); background: var(--panel); border: 1px solid var(--line); padding: .56rem .7rem;
  border-radius: .5rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 6rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input[type=file]::file-selector-button { margin-right: .7rem; border: 0; border-radius: .35rem; padding: .25rem .6rem; background: var(--soft); color: var(--link); cursor: pointer; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .55rem; }
label { display: grid; gap: .35rem; font-weight: 550; }
label.choice { display: flex; align-items: baseline; gap: .55rem; }
h1, h2, h3 { line-height: 1.23; letter-spacing: -.023em; }
h1 { font-size: clamp(1.55rem, 2.2vw, 2.25rem); margin: 0 0 .38rem; }
h2 { font-size: 1.15rem; margin: 0 0 .85rem; }
h3 { font-size: 1.04rem; margin: .4rem 0; }
p { margin: .4rem 0 .75rem; }
small, .muted { color: var(--muted); }
.icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.22em; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 4; min-height: var(--header-height);
  display: flex; align-items: center; gap: 1.15rem; padding: .65rem 1.4rem; color: white; background: var(--nav);
  border-bottom: 1px solid #33445a;
}
.brand { display: flex; align-items: center; gap: .65rem; color: white; text-decoration: none; white-space: nowrap; }
.brand strong { display: block; font-size: 1.18rem; line-height: 1.15; }
.brand small { color: #bdcce2; font-size: .76rem; }
.brand-mark { font-size: 2.15rem; color: #ff9a4d; line-height: 1; }
.global-search { margin-left: auto; width: clamp(220px, 32vw, 520px); position: relative; }
.global-search span { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #b7c8df; }
.global-search input[type=search] { background: #20314a; color: #fff; border-color: #415571; padding-left: 2.25rem; }
.global-search input::placeholder { color: #bbcce3; }
.icon-button { background: transparent; color: #e5efff; border: 1px solid #415571; padding: .36rem; width: 2.35rem; height: 2.35rem; }
.menu-toggle { display: none; }
.learner { white-space: nowrap; font-size: .87rem; }
.learner span { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; margin-right: .3rem; background: #3a557a; }
.sidebar {
  grid-column: 1; grid-row: 2; position: sticky; top: var(--header-height); align-self: start;
  height: calc(100dvh - var(--header-height)); overflow: auto; padding: 1rem .85rem;
  background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; gap: 1.1rem;
}
nav { display: grid; gap: .24rem; }
nav a { text-decoration: none; color: inherit; padding: .65rem .72rem; border-radius: .5rem; display: flex; align-items: center; gap: .7rem; }
nav a:hover { background: var(--nav-hover); }
nav a[aria-current=page] { background: var(--nav-active); color: white; font-weight: 650; }
nav [data-icon] { color: #c6d7ed; display: inline-flex; }
.version { margin-top: auto; background: #20314a; border: 1px solid #364c67; padding: .85rem; border-radius: .55rem; font-size: .83rem; }
.version strong { display: block; margin-bottom: .4rem; }
.version div { display: flex; justify-content: space-between; margin-top: .28rem; color: #bdcce2; }
.version span { color: white; }
main { grid-column: 2; grid-row: 2; min-width: 0; padding: 1.2rem clamp(1rem, 1.65vw, 2.25rem) 1.5rem; }
.footer {
  grid-column: 1 / -1; display: flex; justify-content: space-between; gap: .75rem;
  padding: .7rem 1.4rem; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .82rem;
}
#view > header { margin-bottom: 1.05rem; }
#view > header p { margin-bottom: 0; }
.card, details.chapter {
  min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: .72rem;
  padding: 1.05rem; box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.card h2 .icon { color: var(--link); margin-right: .35rem; }
.progress { height: .47rem; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress span { background: var(--accent); display: block; height: 100%; border-radius: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .8rem; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: grid; align-content: start; grid-template-columns: auto minmax(0, 1fr); gap: .75rem; min-height: 105px; }
.stat strong { display: block; margin: .12rem 0 .32rem; font-size: 1.52rem; line-height: 1.1; }
.stat .progress { margin-top: .55rem; }
.stat small { font-weight: 600; }
.tile-icon { display: grid; place-items: center; border-radius: 50%; width: 2.75rem; height: 2.75rem; color: var(--link); background: var(--soft); }
.tile-icon .icon { width: 1.48rem; height: 1.48rem; }
.tile-icon.green { background: var(--success-bg); color: var(--success); }
.tile-icon.red { background: var(--danger-bg); color: var(--danger); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .85rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: .85rem; align-items: start; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; align-items: start; }
.data-grid .import-panel { grid-column: 1 / -1; }
.import-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .75rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.pill { display: inline-block; border-radius: 1rem; padding: .12rem .55rem; background: var(--soft); color: var(--link); font-size: .82rem; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.error { background: var(--danger-bg); color: var(--danger); }
.list { padding: 0; margin: 0; list-style: none; }
.list > li { padding: .52rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.list > li:last-child { border-bottom: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.24fr); gap: .85rem; align-items: start; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr); gap: .85rem; align-items: start; }
.dashboard h2 { margin-bottom: .7rem; }
.roadmap-head { margin-bottom: .6rem; }
.roadmap-head h2 { margin: 0; }
.chapter-row {
  color: var(--text); text-decoration: none; display: grid; grid-template-columns: 2.2rem minmax(0, 1.7fr) minmax(1.8rem, 1fr) 2.25rem 1rem;
  gap: .65rem; align-items: center; min-height: 2.65rem; padding: .43rem .55rem; border: 1px solid var(--line); border-radius: .48rem; margin: .27rem 0;
}
.chapter-row:hover, .chapter-row.active { background: var(--soft); border-color: transparent; }
.chapter-row strong { font-size: .89rem; font-weight: 640; }
.chapter-row small { text-align: right; }
.chapter-code { text-align: center; background: var(--soft); color: var(--link); border-radius: .33rem; font-weight: 750; font-size: .8rem; padding: .2rem; }
.chapter-row.active .chapter-code { background: var(--accent); color: white; }
.chapter-row.reference .chapter-code { background: var(--purple-bg); color: var(--purple); }
.current-banner {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem;
  align-items: center; padding: .95rem 1rem; border-radius: .55rem; background: var(--soft); min-height: 138px;
}
.current-banner p { color: var(--muted); font-size: .87rem; }
.current-banner h3 { margin-top: .45rem; }
.spark-stack { position: relative; display: grid; justify-items: center; align-content: center; width: clamp(64px, 8vw, 128px); height: 96px; color: var(--link); }
.spark-stack .icon { width: 64%; height: auto; stroke-width: 1.15; }
.spark-stack b { color: #ef8127; background: var(--panel); box-shadow: var(--shadow); border-radius: .44rem; padding: .02rem .42rem; font-size: 1.5rem; position: absolute; top: -1px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.quick-action { color: var(--link); background: var(--soft); text-decoration: none; display: grid; justify-items: center; align-content: center; gap: .26rem; padding: .58rem .3rem; border-radius: .52rem; text-align: center; min-height: 70px; font-size: .84rem; font-weight: 650; }
.quick-action .icon { font-size: 1.2rem; }
.quick-action:hover { text-decoration: underline; }
.quick-action.purple { color: var(--purple); background: var(--purple-bg); }
.quick-action.green { color: var(--success); background: var(--success-bg); }
.quick-action.orange { color: var(--warn); background: var(--warn-bg); }
.weak-dot, .event-dot { width: .48rem; height: .48rem; border-radius: 50%; display: inline-block; margin-right: .45rem; background: var(--danger); }
.event-dot { background: var(--link); }
.activity time { display: block; padding-left: 1rem; color: var(--muted); font-size: .77rem; }
.dashboard-lower .list { font-size: .88rem; }
.empty { margin: .35rem 0; font-size: .9rem; color: var(--muted); }
details summary { cursor: pointer; }
details ul { padding-left: 1.25rem; }
details.chapter > summary { font-weight: 700; }
article { overflow: auto; }
article pre, pre.diff { overflow: auto; padding: 1rem; border-radius: .5rem; background: var(--soft); }
pre.diff { white-space: pre-wrap; overflow-wrap: anywhere; }
article table { border-collapse: collapse; }
article td, article th { border: 1px solid var(--line); padding: .35rem .55rem; }
article img { max-width: 100%; }
#answer label.choice {
  align-items: center; min-height: 2.9rem; border: 1px solid var(--line);
  padding: .45rem .7rem; border-radius: .5rem; cursor: pointer;
}
#answer label.choice:has(input:checked) { background: var(--soft); border-color: var(--link); }
#notice:not(:empty) { padding: .7rem 1rem; background: var(--soft); border-radius: .5rem; margin-bottom: .8rem; }
#notice[data-error=true] { color: var(--danger); background: var(--danger-bg); }
.skip { position: fixed; left: .8rem; top: -4rem; z-index: 8; background: var(--panel); padding: .5rem; }
.skip:focus { top: .4rem; }
[hidden] { display: none !important; }
@media (min-width: 901px) { body::before { content: ""; grid-area: 2 / 1; background: var(--nav); } }
@media (max-width: 1260px) {
  .dashboard-lower { grid-template-columns: 1fr; }
  .stat { gap: .48rem; padding: .8rem; }
  .tile-icon { width: 2.15rem; height: 2.15rem; }
}
@media (max-width: 1050px) { .dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  :root { --header-height: 60px; }
  body { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: .6rem; padding: .55rem .85rem; }
  .menu-toggle { display: inline-flex; }
  .sidebar { display: none; position: fixed; z-index: 3; top: var(--header-height); bottom: 0; width: min(85vw, 244px); box-shadow: 5px 0 25px #0e1b3360; }
  .sidebar.open { display: flex; }
  main { grid-column: 1; }
  .dashboard-grid, .dashboard-lower { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .learner { display: none; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; }
  .brand { margin-right: auto; }
  .brand strong { font-size: 1rem; }
  .brand small { display: none; }
  .brand-mark { font-size: 1.7rem; }
  .global-search { order: 5; width: 100%; margin: 0; }
  :root { --header-height: 102px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-height: 91px; }
  .dashboard-grid, .dashboard-lower, .split, .data-grid, .import-form { grid-template-columns: minmax(0, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter-row { gap: .42rem; }
  .footer { padding-inline: .9rem; }
}
