/* DevOps Learning Hub - theme and layout.
   Palette and motion follow the Sierra Stores Directory; the sidebar follows the OMS JSON Fixer. */

:root {
  --orange: #E97B1F; --orange-2: #F4A04A; --orange-3: #C45F0A;
  --bg: #FCF3E8; --bg-2: #F7EADB;
  --panel: #FFFFFF; --panel-2: #FFFAF4;
  --sidebar: rgba(255, 250, 244, 0.78);
  --text: #2A1A0D; --text-soft: #6B5544; --text-mute: #A08C78;
  --border: #EEE0CD; --border-strong: #DCC7AA;
  --accent: var(--orange); --accent-soft: #FFEBD6; --accent-deep: var(--orange-3);
  --glass-hover: rgba(255, 255, 255, 0.62); --glass-border: rgba(233, 123, 31, 0.14);
  --success: #16A34A; --success-soft: #DCFCE7; --danger: #DC2626; --danger-soft: #FEE2E2;
  --shadow-sm: 0 1px 3px rgba(180, 90, 20, 0.07);
  --shadow-md: 0 6px 20px rgba(180, 90, 20, 0.09);
  --shadow-lg: 0 18px 50px rgba(180, 90, 20, 0.14);
  --radius: 16px; --radius-sm: 10px; --radius-xs: 7px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --sb-w: 292px; --rail-w: 76px; --top-h: 60px;
  --font: "Plus Jakarta Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Roboto", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, "SFMono-Regular", monospace;
  --must: #D26A14; --must-bg: #FFE8D2; --should: #2E8A57; --should-bg: #DFF3E6;
  --nice: #2F6DB5; --nice-bg: #E2ECF9; --deep: #7B5234; --deep-bg: #F1E6DB;
  --stripe: linear-gradient(90deg, #F5C9A6 0 12.5%, #E07B2F 12.5% 25%, #C3E6CD 25% 37.5%, #2F6DB5 37.5% 50%,
                            #C7DAF2 50% 62.5%, #2E8A57 62.5% 75%, #DECBB9 75% 87.5%, #7B5234 87.5% 100%);
  --code-bg: #FFFCF8; --out-bg: #FBF5EC;
  --c-why: #EAF3FD; --c-why-b: #5B9BD5; --c-prod: #EDF7E6; --c-prod-b: #6AA84F;
  --c-mis: #FDECEA; --c-mis-b: #D9534F; --c-lab: #F1EEFD; --c-lab-b: #7E6FD8;
  --c-ex: #FDF8DC; --c-ex-b: #C9A227; --c-sce: #FFF0DD; --c-sce-b: #E97B1F;
  --c-int: #FBEAF6; --c-int-b: #B55AA0;
  --hl-co: #A89683; --hl-st: #3F7D3A; --hl-va: #B5540A; --hl-kw: #8B3FA8; --hl-fn: #1F6FB2; --hl-pa: #0E7C86; --hl-nu: #B45309;
  --fs: 1;
  color-scheme: light;
}
html.dark {
  --bg: #1A120A; --bg-2: #251A0E;
  --panel: #2A1D10; --panel-2: #322113;
  --sidebar: rgba(34, 23, 13, 0.82);
  --text: #FAF3E8; --text-soft: #D4C0A4; --text-mute: #8B7860;
  --border: #3D2A17; --border-strong: #5A3F23;
  --accent: #F4A04A; --accent-soft: #3A2615; --accent-deep: #FFB870;
  --glass-hover: rgba(255, 235, 214, 0.07); --glass-border: rgba(244, 160, 74, 0.18);
  --success: #4ADE80; --success-soft: #14361F; --danger: #F87171; --danger-soft: #3A1717;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3); --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.45);
  --must: #F7A565; --must-bg: rgba(224, 123, 47, 0.2); --should: #7FD1A2; --should-bg: rgba(46, 138, 87, 0.22);
  --nice: #93BCF2; --nice-bg: rgba(47, 109, 181, 0.24); --deep: #D9B597; --deep-bg: rgba(123, 82, 52, 0.28);
  --code-bg: #221710; --out-bg: #1E150D;
  --c-why: rgba(91, 155, 213, 0.13); --c-prod: rgba(106, 168, 79, 0.13); --c-mis: rgba(217, 83, 79, 0.14);
  --c-lab: rgba(126, 111, 216, 0.15); --c-ex: rgba(201, 162, 39, 0.12); --c-sce: rgba(233, 123, 31, 0.13); --c-int: rgba(181, 90, 160, 0.14);
  --hl-co: #8B7860; --hl-st: #A5D394; --hl-va: #FFB870; --hl-kw: #DDAAF0; --hl-fn: #93C1F5; --hl-pa: #74D7DE; --hl-nu: #F4B77E;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--fs)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
  background-image: radial-gradient(at 12% 0%, rgba(244, 160, 74, 0.13) 0%, transparent 46%),
                    radial-gradient(at 92% 4%, rgba(255, 214, 170, 0.28) 0%, transparent 42%);
  background-attachment: fixed; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
html.dark body {
  background-image: radial-gradient(at 10% 0%, rgba(244, 160, 74, 0.07) 0%, transparent 50%),
                    radial-gradient(at 90% 0%, rgba(244, 160, 74, 0.04) 0%, transparent 50%);
}
a { color: var(--accent-deep); text-underline-offset: 0.18em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
kbd { font-family: var(--mono); font-size: 0.72rem; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text-soft); }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-soft); transition: background .2s var(--ease), color .2s var(--ease); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--glass-hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--glass-border); }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.main { margin-left: var(--sb-w); min-width: 0; transition: margin-left .32s var(--ease); }
html.rail .main { margin-left: var(--rail-w); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sb-w); z-index: 60; display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  transition: width .32s var(--ease), transform .34s var(--ease), box-shadow .3s var(--ease);
}
.sb-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 12px 16px; border-bottom: 1px solid var(--border); min-height: 72px; }
.sb-brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.sb-logo { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--orange-2), #D9650F); box-shadow: 0 6px 16px rgba(217, 101, 15, 0.28); }
.sb-logo svg { width: 30px; height: 30px; }
.sb-titles { display: flex; flex-direction: column; min-width: 0; }
.sb-title { font-weight: 750; font-size: 0.95rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-tagline { font-size: 0.75rem; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-rail-btn svg { transition: transform .32s var(--ease); }
html.rail .sb-rail-btn svg { transform: rotate(180deg); }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.nav-section-label { display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: var(--text-mute); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; padding: 14px 12px 6px; white-space: nowrap; }
.nav-spacer { flex: 1; min-height: 16px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px 9px 12px; border: 0; border-radius: 11px;
  background: transparent; color: var(--text); font-size: 0.875rem; font-weight: 550; text-align: left; text-decoration: none; cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.nav-item:hover { background: var(--glass-hover); box-shadow: inset 0 0 0 1px var(--glass-border); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 650; box-shadow: inset 0 0 0 1px rgba(232, 119, 34, 0.2); }
.nav-icon { width: 22px; flex: 0 0 22px; text-align: center; font-size: 1rem; line-height: 1; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { background: var(--bg-2); color: var(--text-soft); padding: 2px 8px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; font-family: var(--mono); white-space: nowrap; }
.nav-item.active .nav-badge { background: var(--accent); color: #fff; }
.nav-chev { display: grid; place-items: center; width: 22px; height: 22px; margin-right: -4px; border: 0; border-radius: 6px; background: transparent; color: var(--text-mute); }
.nav-chev svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.nav-chev:hover { background: var(--bg-2); color: var(--text); }
.nav-group.open > .nav-item .nav-chev svg { transform: rotate(90deg); }
.nav-children { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .34s var(--ease); }
.nav-group.open > .nav-children { grid-template-rows: 1fr; }
.nav-children > div { overflow: hidden; min-height: 0; }
.nav-track + .nav-children > div { padding-left: 14px; }
.nav-module { font-size: 0.83rem; font-weight: 550; padding: 7px 8px 7px 12px; color: var(--text-soft); margin-top: 1px; }
.nav-module .nav-label { white-space: normal; line-height: 1.3; }
.nav-module + .nav-children > div { margin-left: 12px; padding-left: 8px; border-left: 1px solid var(--border); }
.nav-page { display: flex; align-items: flex-start; gap: 9px; padding: 6px 8px 6px 10px; margin: 1px 0; border-radius: 9px; color: var(--text-soft); text-decoration: none; font-size: 0.8rem; line-height: 1.35; transition: background .18s ease, color .18s ease; }
.nav-page:hover { background: var(--glass-hover); color: var(--text); }
.nav-page.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 650; }
.nav-page .pg-mark { flex: 0 0 14px; display: grid; place-items: center; height: 1.35em; font-size: 0.72rem; }
.nav-page .pg-label { flex: 1; min-width: 0; }
.nav-page .pg-done { color: var(--success); font-weight: 700; font-size: 0.75rem; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.dot-must { background: #E07B2F; } .dot-should { background: #2E8A57; } .dot-nice { background: #2F6DB5; } .dot-deep { background: #7B5234; }
.is-soon > .nav-item .nav-label { color: var(--text-mute); }
.sb-foot { padding: 10px 16px 14px; border-top: 1px solid var(--border); font-size: 0.72rem; color: var(--text-mute); display: flex; justify-content: space-between; gap: 8px; }

/* rail (collapsed) mode on desktop: icons only, peek open on hover */
@media (min-width: 1024px) {
  html.rail .sidebar { width: var(--rail-w); }
  html.rail .sidebar:not(:hover) .sb-titles, html.rail .sidebar:not(:hover) .nav-label, html.rail .sidebar:not(:hover) .nav-badge,
  html.rail .sidebar:not(:hover) .nav-chev, html.rail .sidebar:not(:hover) .nav-children, html.rail .sidebar:not(:hover) .nav-section-label,
  html.rail .sidebar:not(:hover) .sb-foot, html.rail .sidebar:not(:hover) .nav-more, html.rail .sidebar:not(:hover) .nav-add { display: none; }
  html.rail .sidebar:not(:hover) .nav-item { justify-content: center; padding: 10px; }
  html.rail .sidebar:not(:hover) .sb-head { flex-direction: column; padding: 14px 8px; }
  html.rail .sidebar:hover { width: var(--sb-w); box-shadow: var(--shadow-lg); }
}

/* admin controls inside the sidebar */
.nav-more { display: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-mute); font-weight: 700; line-height: 1; }
html.admin .nav-item:hover .nav-more, html.admin .nav-page:hover .nav-more, .nav-more[aria-expanded="true"] { display: grid; place-items: center; }
.nav-more:hover { background: var(--bg-2); color: var(--text); }
.nav-add { display: none; width: 100%; margin: 3px 0 6px; padding: 6px 10px; border: 1px dashed var(--border-strong); border-radius: 9px; background: transparent; color: var(--text-mute); font-size: 0.76rem; text-align: left; }
html.admin .nav-add { display: block; }
.nav-add:hover { color: var(--accent-deep); border-color: var(--accent); background: var(--accent-soft); }
.sb-add { display: none; border: 0; background: transparent; color: var(--text-mute); font-size: 0.95rem; padding: 0 4px; border-radius: 6px; }
html.admin .sb-add { display: inline-block; }
.sb-add:hover { color: var(--accent-deep); background: var(--accent-soft); }
.is-hidden-item { opacity: 0.45; }
.is-hidden-item > .nav-item .nav-label::after, .nav-page.is-hidden-item .pg-label::after { content: " (hidden)"; font-style: italic; font-weight: 400; }
.drop-before { box-shadow: inset 0 2px 0 var(--accent) !important; }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent) !important; }
.dragging { opacity: 0.35; }
.rename-input { flex: 1; min-width: 0; font-size: inherit; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 6px; background: var(--panel); outline: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 72%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.drawer-btn { display: none; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: min(420px, 100%); height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--panel); color: var(--text-mute); font-size: 0.88rem; box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search-trigger svg { width: 17px; height: 17px; flex: 0 0 17px; }
.search-trigger-text { flex: 1; text-align: left; }
.search-trigger:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; font-weight: 750; font-size: 0.95rem; color: #fff;
  background: linear-gradient(160deg, var(--orange-2), #D9650F); box-shadow: 0 4px 12px rgba(217, 101, 15, 0.28); transition: transform .25s var(--ease);
}
.avatar:hover { transform: scale(1.05); }
html.admin .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.status-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); font-size: 0.8rem; font-weight: 650; color: var(--text-soft); box-shadow: var(--shadow-sm); transition: all .25s var(--ease);
}
.status-chip[hidden] { display: none; }
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); }
.status-chip.is-draft { color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); }
.status-chip.is-draft::before { background: var(--accent); }
.status-chip.is-busy::before { background: var(--accent); animation: pulse-o 1.2s ease-in-out infinite; }
.status-chip.is-live { color: var(--success); }
.status-chip.is-live::before { background: var(--success); animation: pulse-g 2s ease-in-out infinite; }
.status-chip.is-error { color: var(--danger); background: var(--danger-soft); }
.status-chip.is-error::before { background: var(--danger); }
.status-chip.is-offline::before { background: var(--text-mute); }
@keyframes pulse-g { 0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); } 50% { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); } }
@keyframes pulse-o { 0%, 100% { box-shadow: 0 0 0 0 rgba(233, 123, 31, 0.55); } 50% { box-shadow: 0 0 0 5px rgba(233, 123, 31, 0); } }

/* ---------- view + motion ---------- */
.view { padding: 28px clamp(18px, 4vw, 48px) 96px; outline: none; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.view.enter .stagger > * { animation: slideUp .38s var(--ease) both; }
.view.enter .stagger > *:nth-child(2) { animation-delay: .04s; } .view.enter .stagger > *:nth-child(3) { animation-delay: .08s; }
.view.enter .stagger > *:nth-child(4) { animation-delay: .12s; } .view.enter .stagger > *:nth-child(5) { animation-delay: .16s; }
.view.enter .stagger > *:nth-child(n+6) { animation-delay: .2s; }

/* ---------- shared components ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: all .2s var(--ease);
}
.btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html.dark .btn-primary { color: #2A1A0D; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-done { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, transparent); color: var(--success); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.muted { color: var(--text-mute); }
.tier { display: inline-block; font-size: 0.66rem; font-weight: 700; padding: 0.2em 0.65em; border-radius: 999px; vertical-align: 0.28em; white-space: nowrap; letter-spacing: 0.01em; }
.tier-must { color: var(--must); background: var(--must-bg); } .tier-should { color: var(--should); background: var(--should-bg); }
.tier-nice { color: var(--nice); background: var(--nice-bg); } .tier-deep { color: var(--deep); background: var(--deep-bg); }
.progress { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange-2), var(--orange)); transition: width .6s var(--ease); }

/* ---------- home ---------- */
.home { max-width: 1080px; }
.hero { position: relative; padding: 34px 34px 30px; margin-bottom: 26px; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 34px; bottom: 0; width: 180px; height: 5px; border-radius: 3px 3px 0 0; background: var(--stripe); }
.hero-greet { margin: 0 0 6px; color: var(--text-soft); font-weight: 600; font-size: 0.95rem; }
.hero h1 { margin: 0; font-size: clamp(1.9rem, 3.4vw, 2.7rem); line-height: 1.08; letter-spacing: -0.025em; font-weight: 800; max-width: 18ch; }
.hero p.lede { margin: 12px 0 0; color: var(--text-soft); max-width: 58ch; font-size: 1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.continue { display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 26px; text-decoration: none; color: var(--text); transition: all .25s var(--ease); }
.continue:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.continue-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); font-size: 1.2rem; flex: 0 0 42px; }
.continue small { display: block; color: var(--text-mute); font-weight: 600; font-size: 0.75rem; }
.continue strong { display: block; font-size: 0.98rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-title h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.section-title span { color: var(--text-mute); font-size: 0.82rem; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.track-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; text-decoration: none; color: var(--text); transition: all .25s var(--ease); min-height: 172px; }
.track-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: var(--border-strong); }
.track-card .tc-top { display: flex; align-items: center; gap: 12px; }
.track-card .tc-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; background: var(--accent-soft); }
.track-card h3 { margin: 0; font-size: 1.02rem; }
.track-card p { margin: 0; color: var(--text-soft); font-size: 0.85rem; flex: 1; }
.track-card .tc-meta { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--text-mute); font-weight: 600; }
.track-card.is-soon { background: var(--panel-2); border-style: dashed; box-shadow: none; }
.track-card.is-soon .tc-ico { filter: grayscale(0.4); opacity: .8; }
.soon-pill { font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg-2); color: var(--text-soft); margin-left: auto; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat b { display: block; font-size: 1.45rem; letter-spacing: -0.02em; }
.stat span { color: var(--text-mute); font-size: 0.8rem; font-weight: 600; }

/* ---------- track overview ---------- */
.track-page { max-width: 920px; }
.track-head { display: flex; gap: 18px; align-items: flex-start; padding: 26px; margin-bottom: 20px; }
.track-head .tc-ico { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.7rem; background: var(--accent-soft); }
.track-head h1 { margin: 0 0 4px; font-size: 1.7rem; letter-spacing: -0.02em; }
.track-head p { margin: 0 0 14px; color: var(--text-soft); }
.module-list { display: grid; gap: 10px; }
.module-row { display: grid; grid-template-columns: 1fr 160px auto; align-items: center; gap: 18px; padding: 15px 18px; text-decoration: none; color: var(--text); transition: all .22s var(--ease); }
.module-row:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateX(3px); }
.module-row h3 { margin: 0; font-size: 0.97rem; }
.module-row small { color: var(--text-mute); font-weight: 600; }
.module-row .arrow { color: var(--text-mute); }

/* ---------- page / reader ---------- */
.page { max-width: 46rem; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-mute); margin-bottom: 14px; }
.crumbs a { color: var(--text-soft); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent-deep); }
.page-head { padding-bottom: 18px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.page-head h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15; letter-spacing: -0.022em; font-weight: 800; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.draft-flag { font-size: 0.75rem; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; }
.md { font-size: 1.02rem; line-height: 1.72; overflow-wrap: break-word; }
.md > * { max-width: 44rem; }
.md h2 { font-size: 1.32rem; margin: 2.2em 0 0.6em; letter-spacing: -0.015em; line-height: 1.25; }
.md h3 { font-size: 1.1rem; margin: 1.9em 0 0.5em; line-height: 1.3; }
.md h4 { font-size: 1rem; margin: 1.6em 0 0.4em; }
.md p { margin: 0.85em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: 0.8em 0; }
.md li { margin: 0.3em 0; }
.md li > ul, .md li > ol { margin: 0.3em 0; }
.md strong { font-weight: 700; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.md :not(pre) > code { font-family: var(--mono); font-size: 0.86em; padding: 0.1em 0.38em; border-radius: 5px; background: var(--bg-2); color: var(--text); overflow-wrap: anywhere; }
.md .code, .md .table-wrap { max-width: 100%; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); box-shadow: var(--shadow-sm); }
.md table { border-collapse: collapse; width: 100%; font-size: 0.88rem; line-height: 1.5; }
.md th, .md td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.md th { background: var(--panel-2); font-weight: 700; font-size: 0.8rem; color: var(--text-soft); white-space: nowrap; }
.md tbody tr:last-child td { border-bottom: 0; }
.md tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.code { margin: 1.1em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--code-bg); overflow: hidden; box-shadow: var(--shadow-sm); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 5px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.code-lang { font-size: 0.72rem; font-weight: 700; color: var(--text-mute); }
.code-copy { border: 0; background: transparent; color: var(--text-soft); font-size: 0.74rem; font-weight: 650; padding: 4px 10px; border-radius: 7px; transition: all .2s var(--ease); }
.code-copy:hover { background: var(--accent-soft); color: var(--accent-deep); }
.code-copy.copied { color: var(--success); }
.code pre { margin: 0; padding: 13px 16px; overflow-x: auto; font-family: var(--mono); font-size: 0.8rem; line-height: 1.55; tab-size: 4; }
.code-out { background: var(--out-bg); border-style: dashed; box-shadow: none; }
.code-out .code-bar { background: transparent; }
.hl-co { color: var(--hl-co); font-style: italic; } .hl-st { color: var(--hl-st); } .hl-va { color: var(--hl-va); }
.hl-kw { color: var(--hl-kw); font-weight: 600; } .hl-fn { color: var(--hl-fn); } .hl-pa { color: var(--hl-pa); } .hl-nu { color: var(--hl-nu); }
.md blockquote { margin: 1.3em 0; padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 4px solid var(--border-strong); background: var(--panel-2); }
.md blockquote > :first-child { margin-top: 0; } .md blockquote > :last-child { margin-bottom: 0; }
.md blockquote > * { max-width: none; }
.md blockquote .code { background: var(--panel); }
.callout-why { background: var(--c-why) !important; border-color: var(--c-why-b) !important; }
.callout-prod { background: var(--c-prod) !important; border-color: var(--c-prod-b) !important; }
.callout-mistake { background: var(--c-mis) !important; border-color: var(--c-mis-b) !important; }
.callout-lab { background: var(--c-lab) !important; border-color: var(--c-lab-b) !important; }
.callout-exercise { background: var(--c-ex) !important; border-color: var(--c-ex-b) !important; }
.callout-scenario { background: var(--c-sce) !important; border-color: var(--c-sce-b) !important; }
.callout-interview { background: var(--c-int) !important; border-color: var(--c-int-b) !important; }
.callout-connects { background: transparent !important; border-left-style: dashed !important; }
.callout-tier-must { background: var(--must-bg) !important; border-color: #E07B2F !important; }
.callout-tier-should { background: var(--should-bg) !important; border-color: #2E8A57 !important; }
.callout-tier-nice { background: var(--nice-bg) !important; border-color: #2F6DB5 !important; }
.callout-tier-deep { background: var(--deep-bg) !important; border-color: #7B5234 !important; }
.kind-remember .md > blockquote:first-child, .callout-remember { position: relative; background: var(--panel) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; padding-left: 24px !important; box-shadow: var(--shadow-sm); }
.kind-remember .md > blockquote:first-child::before, .callout-remember::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: linear-gradient(180deg, #F5C9A6 0 12.5%, #E07B2F 12.5% 25%, #C3E6CD 25% 37.5%, #2F6DB5 37.5% 50%, #C7DAF2 50% 62.5%, #2E8A57 62.5% 75%, #DECBB9 75% 87.5%, #7B5234 87.5% 100%); }
.reveal { margin-top: 18px; }
.reveal-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--accent-deep); font-weight: 700; font-size: 0.92rem; transition: all .25s var(--ease); }
.reveal-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.reveal-btn svg { width: 16px; height: 16px; transition: transform .35s var(--ease); }
.reveal.open .reveal-btn svg { transform: rotate(180deg); }
.reveal-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease); }
.reveal.open .reveal-body { grid-template-rows: 1fr; }
.reveal-body > div { overflow: hidden; min-height: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--border); }
.pager-link { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: all .22s var(--ease); min-width: 0; }
.pager-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.pager-link small { color: var(--text-mute); font-weight: 650; font-size: 0.74rem; }
.pager-link span { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-link.next { text-align: right; grid-column: 2; }
.empty { padding: 42px 28px; text-align: center; max-width: 560px; margin: 40px auto; }
.empty .big { font-size: 2.2rem; }
.empty h2 { margin: 10px 0 6px; font-size: 1.2rem; }
.empty p { color: var(--text-soft); margin: 0 0 18px; }

/* ---------- overlays: menu, search, modal, popover, toast, banner ---------- */
.menu-panel {
  position: fixed; top: calc(var(--top-h) - 4px); right: 16px; z-index: 90; width: 320px; padding: 8px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  transform-origin: top right; animation: popIn .28s var(--ease) both;
}
.menu-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head .avatar { width: 34px; height: 34px; font-size: 0.85rem; box-shadow: none; }
.menu-head b { display: block; font-size: 0.9rem; } .menu-head small { color: var(--text-mute); font-size: 0.75rem; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; text-decoration: none; color: var(--text); transition: background .18s ease; }
.menu-item:hover { background: var(--glass-hover); box-shadow: inset 0 0 0 1px var(--glass-border); }
.menu-item .mi-ico { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-2); font-size: 0.95rem; }
.menu-item .mi-text { flex: 1; min-width: 0; } .menu-item b { display: block; font-size: 0.86rem; font-weight: 650; }
.menu-item small { display: block; font-size: 0.74rem; color: var(--text-mute); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 999px; background: var(--border-strong); transition: background .25s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .3s var(--ease); }
.switch.on { background: var(--accent); } .switch.on::after { transform: translateX(16px); }
.size-ctl { display: flex; gap: 4px; }
.size-ctl button { width: 30px; height: 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-weight: 700; font-size: 0.8rem; }
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(26, 18, 10, 0.34); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fadeIn .22s ease both; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.search-box { width: min(640px, 100%); max-height: 76vh; display: flex; flex-direction: column; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; animation: popIn .3s var(--ease) both; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-input-row svg { width: 19px; height: 19px; color: var(--text-mute); flex: 0 0 19px; }
.search-input { flex: 1; border: 0; outline: none; background: transparent; font-size: 1.02rem; }
.search-results { overflow-y: auto; padding: 6px; }
.search-hint { padding: 22px 16px; color: var(--text-mute); font-size: 0.88rem; text-align: center; }
.result { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.result.sel, .result:hover { background: var(--accent-soft); }
.result b { display: block; font-size: 0.9rem; } .result small { color: var(--text-mute); font-size: 0.74rem; font-weight: 600; }
.result p { margin: 3px 0 0; font-size: 0.8rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.modal { width: min(520px, 100%); border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: popIn .3s var(--ease) both; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.modal-head .m-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); font-size: 1.1rem; }
.modal-head h2 { margin: 0; font-size: 1.08rem; }
.modal-body { padding: 8px 20px 4px; color: var(--text-soft); font-size: 0.9rem; }
.modal-body p { margin: 0.5em 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 18px; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-soft); margin-bottom: 5px; }
.field small { display: block; color: var(--text-mute); font-size: 0.74rem; margin-top: 4px; }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--panel-2); color: var(--text); outline: none; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.textarea { height: auto; padding: 10px 12px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.form-error { color: var(--danger); font-size: 0.82rem; font-weight: 600; min-height: 1.2em; margin: 6px 0 0; }
.shake { animation: shake .4s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.popover { position: fixed; z-index: 110; min-width: 210px; padding: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: popIn .22s var(--ease) both; }
.popover button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 0.84rem; }
.popover button:hover { background: var(--accent-soft); }
.popover button.danger { color: var(--danger); }
.popover button.danger:hover { background: var(--danger-soft); }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 150; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-lg); transition: opacity .3s var(--ease), transform .35s var(--ease); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: var(--orange-2); margin-left: 8px; }
.toast.error { background: var(--danger); color: #fff; }
.banner { position: fixed; right: 18px; bottom: 18px; z-index: 140; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: popIn .35s var(--ease) both; font-size: 0.87rem; font-weight: 600; max-width: calc(100vw - 36px); }

/* ---------- settings / help ---------- */
.narrow { max-width: 760px; }
.page-title { margin: 0 0 6px; font-size: 1.75rem; letter-spacing: -0.02em; }
.page-sub { margin: 0 0 22px; color: var(--text-soft); }
.panel { padding: 20px 22px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 4px; font-size: 1.02rem; }
.panel > p { margin: 0 0 14px; color: var(--text-soft); font-size: 0.88rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row b { display: block; font-size: 0.9rem; } .row small { display: block; color: var(--text-mute); font-size: 0.78rem; }
.row .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-2); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 650; color: var(--text-soft); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 0.86rem; margin: 6px 0 14px; }
.kv dt { color: var(--text-mute); font-weight: 600; } .kv dd { margin: 0; font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; }
.note { padding: 11px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep); font-size: 0.84rem; font-weight: 600; margin: 10px 0; }
.note.warn { background: var(--danger-soft); color: var(--danger); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 12px 0; }
.help-grid .card { padding: 14px 16px; font-size: 0.86rem; color: var(--text-soft); }
.help-grid .card b { display: block; color: var(--text); margin-bottom: 3px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; font-size: 0.88rem; }

/* ---------- editor ---------- */
.editor { max-width: none; }
.editor-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.editor-title { flex: 1 1 320px; height: 44px; font-size: 1.15rem; font-weight: 750; }
.editor-state { font-size: 0.8rem; color: var(--text-mute); font-weight: 600; min-width: 90px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; margin-bottom: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); box-shadow: var(--shadow-sm); }
.editor-toolbar button { min-width: 34px; height: 32px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; font-size: 0.82rem; font-weight: 650; color: var(--text-soft); }
.editor-toolbar button:hover { background: var(--accent-soft); color: var(--accent-deep); }
.editor-toolbar .sep { width: 1px; margin: 4px 4px; background: var(--border); }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; height: calc(100vh - 230px); min-height: 420px; }
.editor-src { height: 100%; resize: none; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--code-bg); font-family: var(--mono); font-size: 0.82rem; line-height: 1.6; outline: none; }
.editor-src:focus { border-color: var(--accent); }
.editor-preview { height: 100%; overflow-y: auto; padding: 8px 22px 22px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); }

/* ---------- responsive ---------- */
@media (max-width: 1023.98px) {
  .main, html.rail .main { margin-left: 0; }
  .sidebar { transform: translateX(-104%); width: min(var(--sb-w), 86vw); box-shadow: none; }
  html.drawer-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sb-rail-btn { display: none; }
  .backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(20, 14, 8, 0.32); opacity: 0; pointer-events: none; transition: opacity .28s ease; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
  html.drawer-open .backdrop { opacity: 1; pointer-events: auto; }
  .drawer-btn { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; }
  .editor-split { grid-template-columns: 1fr; height: auto; }
  .editor-src, .editor-preview { height: 60vh; }
}
@media (max-width: 640px) {
  .view { padding: 18px 16px 80px; }
  .search-trigger-text { display: none; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd { display: none; }
  .hero { padding: 24px 20px 26px; } .hero::after { left: 20px; }
  .module-row { grid-template-columns: 1fr auto; } .module-row .progress { display: none; }
  .track-head { flex-direction: column; padding: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: flex-start; } .row .actions { justify-content: flex-start; }
  .pager { grid-template-columns: 1fr; } .pager-link.next { grid-column: 1; }
  .md { font-size: 1rem; }
  .menu-panel { right: 8px; left: 8px; width: auto; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .topbar, .pager, .page-actions, .code-copy, .backdrop { display: none !important; }
  .main { margin: 0 !important; } .view { padding: 0; }
  .reveal-body { grid-template-rows: 1fr !important; } .reveal-btn { display: none; }
  body { background: #fff; }
}
.modal-body ul { margin: 8px 0 4px; padding-left: 1.2em; }
.modal-body li { margin: 3px 0; }
.nav-module .nav-more { margin-left: auto; }
