/* LearnExcel static pages (/reference, /practice, /case-studies, /projects).
   Mirrors the app's design tokens and components in index.html: same palette, type, navbar
   tabs, theme switch, reference card, tables and buttons. Light is the default; dark applies
   only when the visitor picked it with the theme switch (saved as localStorage
   "learnexcel-theme", shared with the app). */

:root {
  color-scheme: light;
  --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F5F2FC;
  --ink: #1C1B29; --ink-soft: #5B5A72; --ink-faint: #6F6D87;
  --accent: #0A8550; --accent-ink: #FFFFFF; --accent-soft: #E1F7EA; --accent-bright: #0E9F62;
  --qa-bg: #F2FBF6; --qa-border: #CDE9D9; --hero-ink: #07170F;
  --grid-line: #E7E3F3; --grid-header: #F1EEFA;
  --shadow: 0 1px 2px rgba(28, 27, 41, 0.06), 0 8px 24px -12px rgba(28, 27, 41, 0.16);
  --radius: 10px;
  --font-display: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14121E; --surface: #1C1930; --surface-2: #242038;
  --ink: #EDEBF7; --ink-soft: #B3AFC9; --ink-faint: #827D9B;
  --accent: #34D399; --accent-ink: #07170F; --accent-soft: #163327; --accent-bright: #34D399;
  --qa-bg: #13261E; --qa-border: #1F4535;
  --grid-line: #322D4A; --grid-header: #251F3B;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px 64px; }

/* ---- navbar: same structure and styling as the app's .navbar ---- */
.navbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; flex-wrap: wrap; border-bottom: 1px solid var(--grid-line); margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .mark { position: relative; width: 34px; height: 34px; display: block; flex: none; }
.brand .mark .sq { position: absolute; width: 22px; height: 22px; border-radius: 6px; }
.brand .mark .sq-a { left: 0; top: 0; background: var(--ink); }
.brand .mark .sq-b { right: 0; bottom: 0; background: var(--accent); mix-blend-mode: multiply; }
:root[data-theme="dark"] .brand .mark .sq-b { mix-blend-mode: normal; }
.brand .name { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.nav-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.nav-links { display: flex; align-items: stretch; border-bottom: 1px solid var(--grid-line); }
.nav-link { position: relative; border-right: 1px solid var(--grid-line); background: var(--surface-2); padding: 9px 15px 8px; font-size: 13px; font-weight: 600; line-height: 1.5; color: var(--ink-soft); text-decoration: none; white-space: nowrap; transition: color 150ms ease, background 150ms ease; }
.nav-link:first-child { border-top-left-radius: 6px; }
.nav-link:last-child { border-top-right-radius: 6px; }
.nav-link:hover { color: var(--ink); background: var(--surface); }
.nav-link.active { background: var(--surface); color: var(--ink); }
.nav-link.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.theme-switch { position: relative; flex-shrink: 0; width: 46px; height: 26px; padding: 0; border-radius: 999px; border: 1px solid var(--grid-line); background: var(--surface-2); cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.theme-switch.is-dark { background: var(--accent-soft); border-color: var(--accent); }
.theme-switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 999px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; transition: transform 0.2s ease; }
.theme-switch.is-dark .theme-switch-thumb { transform: translateX(20px); }
.theme-switch .icn-moon { display: none; }
.theme-switch.is-dark .icn-moon { display: block; }
.theme-switch.is-dark .icn-sun { display: none; }

/* ---- article card: mirrors the app's .ref-article ---- */
.article { max-width: 860px; margin: 0 auto; background: var(--surface); border: 1px solid var(--grid-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 36px 36px; }
.breadcrumb { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin: 0 0 18px; }
.breadcrumb a, .article .breadcrumb a { color: var(--ink-faint); font-weight: 400; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.eyebrow { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.eyebrow::before { content: ''; width: 16px; height: 1.5px; background: var(--accent); flex: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; text-wrap: balance; color: var(--ink); }
h1 { font-size: 36px; line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 12px; }
h2 { font-size: 22px; line-height: 1.25; letter-spacing: -0.01em; margin: 40px 0 12px; }
h3 { font-size: 17px; line-height: 1.3; margin: 28px 0 8px; }
.dek { font-size: 18px; line-height: 1.55; color: var(--ink-soft); margin: 0 0 28px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 22px; margin: 0 0 18px; }
li { margin-bottom: 6px; }
.article a { color: var(--accent); font-weight: 500; text-decoration: none; }
.article a:hover { text-decoration: underline; text-underline-offset: 2px; }
code { font-family: var(--font-mono); background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-size: 0.86em; }

.syntax-box, .formula-box { font-family: var(--font-mono); background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 14px 16px; margin: 10px 0 20px; font-size: 14px; overflow-x: auto; white-space: pre; }
table.args-table { width: 100%; border-collapse: collapse; margin: 6px 0 22px; font-size: 14.5px; }
table.args-table th { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--ink-faint); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid-line); }
table.args-table td { padding: 10px; border-bottom: 1px solid var(--grid-line); vertical-align: top; }
table.args-table td.argname, table.args-table td:first-child { font-family: var(--font-mono); color: var(--accent); white-space: nowrap; }
.example { border-left: 3px solid var(--accent); padding: 4px 0 4px 18px; margin: 18px 0 24px; }
.ex-title { font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 10px; }
table.ex-sheet { border-collapse: collapse; font-size: 13.5px; margin-bottom: 10px; max-width: 100%; overflow-x: auto; display: block; }
table.ex-sheet th, table.ex-sheet td { border: 1px solid var(--grid-line); padding: 7px 12px; text-align: left; min-width: 52px; }
table.ex-sheet th { background: var(--grid-header); font-family: var(--font-mono); font-weight: 400; color: var(--ink-faint); text-align: center; }
table.ex-sheet td.rownum { background: var(--grid-header); font-family: var(--font-mono); color: var(--ink-faint); text-align: center; }
.result-line { font-family: var(--font-mono); font-size: 13.5px; background: var(--accent-soft); color: var(--ink); border-radius: 8px; padding: 8px 12px; display: inline-block; }
ul.mistakes li { margin-bottom: 10px; }

.cta-block { background: var(--surface-2); border: 1px solid var(--grid-line); border-radius: 14px; padding: 26px 24px; margin: 40px 0 6px; text-align: center; }
.cta-block h3 { margin: 0 0 8px; font-size: 19px; }
.cta-block p { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 18px; }
.cta-btn, .article a.cta-btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 13px 24px; font-weight: 600; font-size: 15px; text-decoration: none; transition: transform 120ms ease, filter 120ms ease; }
.cta-btn:hover { filter: brightness(1.06); text-decoration: none; }
.cta-btn:active { transform: scale(0.97); }

/* hub lists */
.hub-group { margin: 34px 0 6px; }
.hub-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.hub-list li { border: 1px solid var(--grid-line); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; margin: 0; transition: border-color 150ms ease, transform 150ms ease; }
.hub-list li:hover { border-color: var(--accent); }
.hub-list a, .article .hub-list a { color: var(--ink); font-weight: 600; }
.hub-list p { margin: 4px 0 0; font-size: 14px; color: var(--ink-soft); }
@media (min-width: 720px) { .hub-list { grid-template-columns: 1fr 1fr; } }

/* interview pages */
details.answer { margin: 10px 0 4px; border: 1px solid var(--grid-line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface-2); }
details.answer summary { cursor: pointer; font-weight: 600; }
details.answer[open] summary { margin-bottom: 8px; }
.q-links { font-size: 14px; margin: 8px 0 0; }
.q-links a { margin-right: 14px; }
.level-table td:first-child { font-weight: 600; white-space: nowrap; }

/* ---- footer: mirrors the app's .site-footer ---- */
.site-footer { max-width: 860px; margin: 40px auto 0; padding: 22px 4px; border-top: 1px solid var(--grid-line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; color: var(--ink-faint); font-size: 12.5px; }
.site-footer a { color: var(--ink-faint); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
.site-footer .links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .wrap { padding: 0 14px 48px; }
  .navbar { padding: 10px 0; gap: 8px; margin-bottom: 16px; }
  .brand .mark { width: 26px; height: 26px; }
  .brand .mark .sq { width: 17px; height: 17px; }
  .brand .name { font-size: 19px; }
  .nav-right { flex: 1 1 100%; order: 3; }
  .nav-links { overflow-x: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-width: 0; scrollbar-width: thin; }
  .nav-link { padding: 6px 10px 5px; font-size: 12px; flex-shrink: 0; }
  .article { padding: 20px 18px 26px; }
  h1 { font-size: 28px; }
  .dek { font-size: 16.5px; }
}

/* ---- Round 78: function guide v2 (quick answer + side rail) ---- */
.article-layout { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.article.has-rail { flex: 999 1 560px; min-width: 0; max-width: none; margin: 0; }
.rail { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 980px) { .rail { position: sticky; top: 20px; } }
.rail-card { background: var(--surface); border: 1px solid var(--grid-line); border-radius: 14px; padding: 18px 20px; }
.rail-title { font-weight: 700; font-size: 17px; }
.rail-sub { color: var(--ink-soft); font-size: 14.5px; margin: 4px 0 14px; }
.bar { height: 8px; border-radius: 999px; background: var(--grid-header); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent-bright); }
.rail-count { font-size: 13px; color: var(--ink-soft); margin: 6px 0 14px; }
.rail-btn, .article a.rail-btn, a.rail-btn { display: block; text-align: center; color: var(--accent-ink); }
.toc-list { list-style: none; padding: 0; margin: 8px 0 0; }
.toc-list li { margin: 0 0 8px; font-size: 15px; line-height: 1.35; }
.toc-list a { color: var(--accent); text-decoration: none; font-weight: 500; }
.toc-list a:hover { text-decoration: underline; }
.author-card { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border-color: transparent; font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); }
.author-card img { width: 44px; height: 44px; border-radius: 999px; object-fit: cover; flex: none; }
.author-card a { color: var(--ink); text-decoration: none; }
.author-card a:hover { text-decoration: underline; }
.quick-answer { border: 1px solid var(--qa-border); background: var(--qa-bg); border-radius: 14px; padding: 20px 22px; margin: 4px 0 28px; }
.qa-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.quick-answer p { font-size: 17.5px; line-height: 1.55; margin: 0 0 12px; }
.quick-answer p:last-child { margin-bottom: 0; }
.qa-syntax { font-family: var(--font-mono); font-size: 14.5px; background: var(--surface); border: 1px solid var(--qa-border); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
ul.chips { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 10px; }
ul.chips li { margin: 0; }
.article ul.chips a { display: inline-block; font-family: var(--font-mono); font-weight: 400; font-size: 14px; padding: 7px 14px; border: 1px solid var(--grid-line); border-radius: 999px; color: var(--ink); text-decoration: none; }
.article ul.chips a:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Round 78: interview prep hub (dark hero in both themes) ---- */
.hub-hero { max-width: 1180px; margin: 0 auto 24px; background: #1C1B29; color: #FFFFFF; border-radius: 18px; padding: 28px 36px 40px; }
.hub-grid { display: flex; flex-wrap: wrap; gap: 36px; align-items: flex-end; }
.hub-copy { flex: 1 1 520px; min-width: 0; }
.hub-hero .breadcrumb, .hub-hero .breadcrumb a { color: #C9C6DD; }
.hub-hero .breadcrumb { margin-bottom: 26px; }
.hub-hero .eyebrow { color: #34D399; }
.hub-hero .eyebrow::before { background: #34D399; }
.hub-hero h1 { color: #FFFFFF; font-size: 50px; line-height: 1.05; letter-spacing: -0.035em; margin: 0 0 16px; }
.hub-sub { color: #C9C6DD; font-size: 18.5px; line-height: 1.55; max-width: 580px; margin: 0 0 24px; }
.level-picker { border: none; padding: 0; margin: 0 0 24px; }
.level-picker legend { color: #C9C6DD; font-size: 14.5px; margin-bottom: 10px; padding: 0; }
.level-row { display: flex; gap: 10px; flex-wrap: wrap; }
.level-btn { font-family: inherit; font-size: 15px; font-weight: 600; padding: 11px 18px; min-height: 44px; border-radius: 999px; border: 1px solid #4A4766; background: transparent; color: #FFFFFF; cursor: pointer; }
.level-btn:hover { border-color: #8F8AB0; }
.level-btn[aria-pressed="true"] { background: #34D399; border-color: #34D399; color: #07170F; }
.hub-ctas { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
a.hub-primary { background: #34D399; color: #07170F; }
a.hub-secondary { color: #FFFFFF; text-decoration: none; font-weight: 600; padding: 12px 20px; border-radius: 8px; border: 1px solid #4A4766; }
a.hub-secondary:hover { border-color: #8F8AB0; }
.hub-card { flex: 1 1 300px; min-width: 0; background: #262338; border: 1px solid #3A3654; border-radius: 16px; padding: 22px; }
.hub-card .qa-label { color: #C9C6DD; }
.hub-facts { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.hub-facts > div { display: flex; justify-content: space-between; gap: 16px; }
.hub-facts dt { color: inherit; opacity: .85; }
.hub-facts dd { margin: 0; font-weight: 700; text-align: right; }
ol.plan { list-style: none; padding: 0; margin: 14px 0 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.plan-day { margin: 0; }
.plan-day a, .article .plan-day a { display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 150px; padding: 16px; border: 1px solid var(--grid-line); border-radius: 14px; color: var(--ink); text-decoration: none; font-weight: 400; background: var(--surface); }
.plan-day a:hover { border-color: var(--accent); }
.plan-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.plan-topic { font-weight: 700; font-size: 16.5px; line-height: 1.25; }
.plan-meta { font-size: 13.5px; color: var(--ink-soft); margin-top: auto; }
.plan-status { font-size: 13px; font-weight: 700; color: var(--ink-soft); min-height: 1em; }
.plan-day.is-done a { background: var(--qa-bg); border-color: var(--qa-border); }
.plan-day.is-done .plan-status, .plan-day.is-done .plan-label { color: var(--accent); }
.plan-day.is-today a { border: 2px solid var(--ink); padding: 15px; }
.plan-day.is-today .plan-status { color: var(--ink); }
.graders { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 10px 0 30px; }
.graders > div { background: var(--surface-2); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.graders span { color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; }

/* ---- Round 78: mock test ---- */
.mock-root { border: 1px solid var(--grid-line); border-radius: 14px; padding: 22px 24px; margin: 6px 0 30px; background: var(--surface); }
.mock-root:focus { outline: none; }
.mock-facts { margin-bottom: 18px; }
.mock-best { font-weight: 600; color: var(--accent); }
.mock-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; font-size: 14px; color: var(--ink-soft); }
.mock-bar .bar { flex: 1; }
.mock-timer { font-family: var(--font-mono); font-weight: 600; color: var(--ink); background: var(--surface-2); padding: 4px 10px; border-radius: 8px; }
h2.mock-q { font-size: 20px; line-height: 1.4; margin: 6px 0 16px; }
h2.mock-q:focus { outline: none; }
.mock-sheet { margin: 4px 0 14px; }
.mock-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.mock-option { display: flex; gap: 12px; align-items: center; text-align: left; font-family: inherit; font-size: 15.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--grid-line); border-radius: 12px; padding: 13px 14px; min-height: 48px; cursor: pointer; }
.mock-option:hover { border-color: var(--accent); }
.mock-option[aria-checked="true"] { border: 2px solid var(--accent); padding: 12px 13px; background: var(--qa-bg); }
.mock-option .mono { font-family: var(--font-mono); font-size: 14.5px; overflow-wrap: anywhere; }
.mock-letter { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.mock-next[disabled] { opacity: .45; cursor: not-allowed; }
button.cta-btn { border: none; cursor: pointer; font-family: inherit; }
.mock-score { font-size: 54px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 6px; }
.mock-note { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.mock-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 10px 0 26px; }
.mock-topic { border: 1px solid var(--grid-line); border-radius: 12px; padding: 14px 16px; }
.mock-topic.weak { border-color: #E3A37A; background: color-mix(in srgb, #FF8A3D 8%, var(--surface)); }
.mock-topic .rail-sub { margin-bottom: 6px; }
@media (max-width: 760px) {
  .hub-hero { padding: 20px 18px 28px; border-radius: 14px; }
  .hub-hero h1 { font-size: 34px; }
  .mock-root { padding: 16px; }
}
@media (max-width: 760px) {
  table.args-table { display: block; overflow-x: auto; }
  table.args-table td.argname, table.args-table td:first-child { white-space: normal; overflow-wrap: anywhere; }
}
.result-line { max-width: 100%; overflow-wrap: anywhere; }
.article { overflow-wrap: break-word; }
.article code { overflow-wrap: anywhere; }

/* Round 80: second line in a quick answer (e.g. the IFERROR VLOOKUP pattern) */
.quick-answer .qa-syntax + p { margin-top: 12px; margin-bottom: 0; }
