/* Excel in depth. Quiet page, one accent; the grid is the loud part.
   Fonts are the ones already on the learner's Windows machine, so the course
   needs no network and the grid reads like Excel's. */
:root {
  --paper: #f5f6f3;
  --surface: #ffffff;
  --ink: #18211d;
  --muted: #5d6963;
  --line: #d7dcd7;
  --grid-line: #e2e5e1;
  --head: #eef0ed;
  --accent: #0e6b4e;
  --accent-soft: #e4f1eb;
  --warn: #8a5200;
  --warn-soft: #fbf1dc;
  --input: #1f4fbf;
  --ref0: #2b63d9; --ref1: #c2362f; --ref2: #7a3fb0; --ref3: #1e8a5a; --ref4: #c76a00;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --sheet: "Aptos Narrow", Aptos, Calibri, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, Menlo, monospace;
  --top: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--ui); }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2 { font-family: var(--display); font-weight: 600; letter-spacing: -0.012em; line-height: 1.2; margin: 0; }
p { margin: 0 0 0.9em; }
code, kbd, pre { font-family: var(--mono); font-size: 0.9em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); font-size: 0.82em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ref0 { color: var(--ref0); } .ref1 { color: var(--ref1); } .ref2 { color: var(--ref2); } .ref3 { color: var(--ref3); } .ref4 { color: var(--ref4); }

/* ---------------------------------------------------------------- top */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 18px; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--display); font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.crumb { color: var(--muted); white-space: nowrap; }
.toplinks { margin-left: auto; }
.steps { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.steps a { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.steps a.done { background: var(--accent); opacity: 0.45; }
.steps a.here { background: var(--ink); opacity: 1; }
.steps a.here.done { background: var(--accent); }
.steps .count { margin-left: 8px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-block; font: inherit; font-size: 0.95rem; line-height: 1.2; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #0a573f; }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); padding-inline: 8px; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* --------------------------------------------------------------- home */
.home, .ref-page { max-width: 920px; margin: 0 auto; padding: 56px 24px 96px; }
.hero { margin-bottom: 64px; }
.hero-fx { margin: 0 0 22px; }
.hero-fx code { display: inline-block; font-size: 0.95rem; padding: 7px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3rem); max-width: 17em; margin-bottom: 20px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 40em; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.topic { color: var(--muted); font-size: 0.95rem; margin: 0 0 14px; }
.next[hidden] { display: none; }
.status-note { margin-top: 26px; font-size: 0.92rem; color: var(--muted); max-width: 44em; border-left: 3px solid var(--line); padding-left: 12px; }
.module { margin-top: 44px; }
.module h2 { font-size: 1.3rem; display: flex; align-items: baseline; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.mnum { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.lessons { list-style: none; margin: 0; padding: 0; }
.lessons li { display: grid; grid-template-columns: 3.2em 15em 1fr 4.5em; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.lessons .code { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.lessons .ltitle { font-weight: 600; }
.lessons .outcome { color: var(--muted); font-size: 0.95rem; }
.lessons .state { text-align: right; font-size: 0.85rem; color: var(--accent); white-space: nowrap; }
.lessons .planned .ltitle { font-weight: 400; }

/* ------------------------------------------------------------- lesson */
.lesson { display: grid; grid-template-rows: minmax(0, 1fr); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); overflow: hidden; }
.lesson.with-grid { grid-template-columns: minmax(320px, 27vw) minmax(0, 1fr); }
.pane-text { overflow-y: auto; }
.text-inner { padding: 34px 26px 28px; display: flex; flex-direction: column; min-height: 100%; }
.lesson.solo .text-inner { max-width: 660px; margin: 0 auto; padding-top: 64px; }
.pane-text h1 { font-size: 1.65rem; margin-bottom: 18px; }
.lesson.solo h1 { font-size: 2rem; }
.body p { max-width: 36em; }
.anatomy { margin: 4px 0 16px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; white-space: pre-wrap; word-break: break-word; font-size: 0.86rem; line-height: 1.5; }
.anatomy b { color: var(--accent); font-weight: 600; }
.anatomy i { font-style: normal; color: var(--ref0); }
.task { margin: 6px 0 16px; padding: 12px 14px; background: var(--surface); border-left: 3px solid var(--accent); }
.task b { font-family: var(--mono); font-size: 0.92em; }
.goals { margin: 6px 0 16px; padding: 0; list-style: none; counter-reset: goal; }
.goals li { counter-increment: goal; position: relative; padding: 10px 12px 10px 40px; background: var(--surface); border-left: 3px solid var(--line); margin-bottom: 6px; color: var(--muted); }
.goals li::before { content: counter(goal); position: absolute; left: 14px; font-variant-numeric: tabular-nums; }
.goals li.now { border-left-color: var(--accent); color: var(--ink); }
.goals li.done { border-left-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.goals li.done::before { content: "\2713"; color: var(--accent); }
.keys-used { display: block; font-size: 0.86rem; color: var(--muted); margin-top: 2px; }
.onward { margin: 4px 0 18px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.feedback { font-size: 0.97rem; }
.feedback:empty { display: none; }
.feedback.ok, .feedback.no { padding: 11px 14px; margin-bottom: 14px; border-left: 3px solid; }
.feedback.ok { background: var(--accent-soft); border-color: var(--accent); }
.feedback.no { background: var(--warn-soft); border-color: var(--warn); }
.feedback p { margin: 8px 0 6px; }
.feedback .anatomy { margin-bottom: 0; }
.hint { font-size: 0.95rem; color: var(--ink); padding: 9px 0 9px 14px; margin: 0 0 6px; border-left: 3px solid var(--line); }
.hint p { margin: 0 0 6px; }
.more { margin: 8px 0 18px; font-size: 0.94rem; color: var(--muted); }
.more summary { cursor: pointer; color: var(--accent); width: fit-content; padding: 4px 0; }
.more[open] summary { margin-bottom: 8px; }
.options { display: grid; gap: 8px; margin: 8px 0 18px; }
.option { font: inherit; text-align: left; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--ink); }
.option:hover { border-color: var(--muted); }
.option code:empty { display: none; }
.option code { font-size: 1.02rem; }
.option.right { border-color: var(--accent); background: var(--accent-soft); }
.option.wrong { border-color: var(--warn); background: var(--warn-soft); }
.workbook { margin: 10px 0 20px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.workbook h2 { font-size: 1.15rem; margin-bottom: 10px; }
.small { font-size: 0.9rem; color: var(--muted); margin: 0; }
.nav { margin-top: auto; padding-top: 22px; display: flex; justify-content: space-between; }

/* --------------------------------------------------------------- grid */
.pane-grid { min-width: 0; border-left: 1px solid var(--line); background: var(--surface); }
.grid { height: 100%; display: flex; flex-direction: column; font-family: var(--sheet); font-size: 13.5px; }
.fbar { display: flex; align-items: stretch; height: 32px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.namebox { width: 92px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-align: center; font-variant-numeric: tabular-nums; outline: none; padding: 0 4px; }
.namebox:focus { box-shadow: inset 0 0 0 2px var(--accent); text-align: left; }
.fx-mark { width: 34px; display: flex; align-items: center; justify-content: center; font-style: italic; color: var(--muted); border-right: 1px solid var(--line); font-family: Georgia, "Times New Roman", serif; }
.fwrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.fhl, .finput { position: absolute; inset: 0; margin: 0; border: 0; padding: 0 10px; font: 13.5px/32px var(--mono); letter-spacing: 0; white-space: pre; }
.fhl { pointer-events: none; color: var(--ink); width: max-content; min-width: 100%; }
.finput { width: 100%; background: transparent; color: transparent; caret-color: var(--ink); outline: none; }
.finput::selection { background: rgba(14, 107, 78, 0.22); color: transparent; }
.gscroll { flex: 1; min-height: 0; overflow: auto; outline: none; scroll-padding: 56px 12px 12px 52px; background: #fafbf9; }
.gcanvas { position: relative; width: max-content; }
.grid table { border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--surface); }
.grid th, .grid td { height: 25px; padding: 0 6px; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); white-space: nowrap; overflow: hidden; }
.grid th { background: var(--head); color: var(--muted); font-weight: 400; font-size: 12px; text-align: center; user-select: none; }
.grid th.on { background: #dfe6e1; color: var(--ink); }
.grid thead th { position: sticky; top: 0; z-index: 6; border-bottom-color: var(--line); }
.grid th.rowhead, .grid th.corner { position: sticky; left: 0; z-index: 5; width: 40px; min-width: 40px; border-right-color: var(--line); }
.grid th.corner { z-index: 7; }
.grid td { cursor: cell; text-overflow: ellipsis; background: var(--surface); }
.grid td.head { position: sticky; top: 26px; z-index: 4; font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--muted); }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.bool, .grid td.err { text-align: center; }
.grid td.textnum { position: relative; }
.grid td.textnum::before { content: ""; position: absolute; left: 0; top: 0; border: 4px solid transparent; border-left-color: #1e8a5a; border-top-color: #1e8a5a; }
.grid td.thead { background: #1f6f55; color: #fff; font-weight: 600; border-right-color: #1f6f55; }
.grid td.tband { background: #f0f6f3; }
.grid td.input { color: var(--input); }
.grid td.answer { background: #f1f8f4; box-shadow: inset 0 0 0 1px rgba(14, 107, 78, 0.28); }
.grid td.sel { background: #e7efe9; }
.grid td.answer.sel { background: #dcebe2; }
.grid td.active { box-shadow: inset 0 0 0 2px var(--accent); }
.grid td.editing { overflow: visible; text-align: left; position: relative; z-index: 3; box-shadow: inset 0 0 0 2px var(--accent); }
.grid td.editing span { position: relative; display: inline-block; min-width: 100%; background: var(--surface); padding-right: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 21px; box-shadow: 8px 0 0 var(--surface); }
.overlays { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.refbox { position: absolute; border: 2px solid currentColor; background: color-mix(in srgb, currentColor 7%, transparent); }
.spillbox { position: absolute; border: 1px solid var(--ref0); box-shadow: 0 0 0 1px rgba(43, 99, 217, 0.18); }
.fhl.ghost { color: #9aa39e; }
.fhl.ghost span { color: inherit; }
.fillbox { position: absolute; border: 2px dashed var(--accent); }
.fill-handle { position: absolute; width: 8px; height: 8px; background: var(--accent); border: 1px solid #fff; cursor: crosshair; z-index: 3; display: none; }
.gstatus { flex: none; display: flex; gap: 16px; align-items: center; min-height: 28px; padding: 3px 12px; border-top: 1px solid var(--line); background: var(--head); font-size: 12.5px; color: var(--muted); }
.gmode { min-width: 44px; }
.gnote { flex: 1; color: var(--warn); font-family: var(--ui); }
.gstats { white-space: pre; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------- Power Query (sim) */
.pq { position: relative; height: 100%; display: flex; flex-direction: column; background: #f3f3f1; font-family: var(--ui); font-size: 13.5px; color: var(--ink); }
.pq-title { flex: none; display: flex; align-items: baseline; gap: 12px; padding: 8px 14px; background: #e9ebe8; border-bottom: 1px solid var(--line); }
.pq-title b { font-weight: 600; }
.pq-sim { color: var(--muted); font-size: 12px; }
.pq-fx { flex: none; display: flex; align-items: stretch; min-height: 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pq-fx code { flex: 1; min-width: 0; padding: 7px 10px; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.pq-main { flex: 1; min-height: 0; display: flex; }
.pq-data { flex: 1; min-width: 0; overflow: auto; background: var(--surface); }
.pq-grid { border-collapse: separate; border-spacing: 0; font-family: var(--sheet); }
.pq-grid th, .pq-grid td { height: 27px; padding: 0 10px; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); white-space: nowrap; text-align: left; }
.pq-grid thead th { position: sticky; top: 0; z-index: 2; background: #f4f6f3; font-weight: 600; padding: 0 12px 4px 4px; min-width: 132px; }
.pq-grid th.pq-corner, .pq-grid th.pq-row { min-width: 34px; width: 34px; padding: 0; text-align: center; background: #f4f6f3; color: var(--muted); font-weight: 400; font-size: 12px; }
.pq-col { vertical-align: middle; }
.pq-type { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; min-width: 34px; height: 21px; margin-right: 6px; padding: 0 4px; border: 1px solid transparent; border-radius: 3px; background: none; color: var(--muted); font: 600 10.5px/1 var(--ui); letter-spacing: 0.02em; cursor: pointer; }
.pq-type:hover, .pq-type:focus-visible { border-color: var(--muted); background: var(--surface); color: var(--ink); }
.pq-quality { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(to right, #2f9166 calc(100% - var(--bad, 0%)), #c2362f calc(100% - var(--bad, 0%))); }
.pq-grid thead th { position: sticky; }
.pq-grid td.pq-right { text-align: right; font-variant-numeric: tabular-nums; }
.pq-grid td.pq-error { color: #b3261e; background: #fdf1ef; }
.pq-side { flex: none; width: 236px; padding: 14px; border-left: 1px solid var(--line); background: #f3f3f1; overflow-y: auto; }
.pq-side h3 { font: 600 14px/1.2 var(--display); margin: 0 0 14px; }
.pq-label { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.pq-name { margin: 0 0 16px; padding: 5px 8px; background: var(--surface); border: 1px solid var(--line); }
.pq-steps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--surface); }
.pq-steps li { display: flex; align-items: center; }
.pq-steps li.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.pq-step { flex: 1; min-width: 0; text-align: left; font: inherit; padding: 6px 8px 6px 12px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.pq-x { flex: none; width: 26px; height: 26px; border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; border-radius: 3px; }
.pq-x:hover, .pq-x:focus-visible { background: #f3dcd9; color: #b3261e; }
.pq-note { margin: 12px 0 0; font-size: 12px; color: var(--warn); }
.pq-status { flex: none; padding: 4px 14px; border-top: 1px solid var(--line); background: #e9ebe8; font-size: 12px; color: var(--muted); }
.pq-layer { position: absolute; inset: 0; display: none; z-index: 10; }
.pq-layer.open { display: block; }
.pq-layer.modal { background: rgba(24, 33, 29, 0.28); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pq-menu { position: absolute; min-width: 190px; padding: 4px 0; background: var(--surface); border: 1px solid var(--muted); box-shadow: 0 6px 18px rgba(24, 33, 29, 0.16); }
.pq-menu button { display: block; width: 100%; text-align: left; font: inherit; padding: 6px 14px 6px 26px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.pq-menu button:hover, .pq-menu button:focus-visible { background: var(--accent-soft); }
.pq-menu button.on { background: no-repeat 9px center / 9px linear-gradient(var(--ink), var(--ink)); background-size: 6px 6px; }
.pq-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.pq-dialog { width: min(470px, 100%); padding: 20px 22px; background: var(--surface); border: 1px solid var(--muted); box-shadow: 0 10px 30px rgba(24, 33, 29, 0.25); }
.pq-dialog h3 { font: 600 16px/1.2 var(--display); margin: 0 0 10px; }
.pq-dialog p { margin: 0 0 14px; }
.pq-form label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.pq-form select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.pq-sample { font-size: 12.5px; color: var(--muted); }
.pq-buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 900px) { .pq-main { flex-direction: column; } .pq-side { width: auto; border-left: 0; border-top: 1px solid var(--line); } }

.grid { position: relative; }
.tool-strip, .pq-tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; background: #eef0ed; border-bottom: 1px solid var(--line); font-family: var(--ui); }
.tool-tab { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 6px; }
.pq-tool { font: 12.5px/1.2 var(--ui); padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); cursor: pointer; }
.pq-tool:hover, .pq-tool:focus-visible { border-color: var(--muted); }
.pq-tool.strong { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pq-event { font: 12.5px/1.2 var(--ui); padding: 5px 10px; border: 1px dashed var(--warn); border-radius: 4px; background: var(--warn-soft); color: var(--ink); cursor: pointer; margin-left: auto; }
.pq-headbtn { float: right; margin-left: 8px; border: 1px solid transparent; border-radius: 3px; background: none; color: var(--muted); font-size: 12px; line-height: 1; padding: 3px 4px; cursor: pointer; }
.pq-headbtn:hover, .pq-headbtn:focus-visible { border-color: var(--muted); color: var(--ink); background: var(--surface); }
.pq-grid thead th.picked, .pq-grid td.picked { background: #dcebe2; }
.pq-grid thead th { cursor: default; user-select: none; }
.pq-grid td.pq-null { color: #9aa39e; font-style: italic; }
.pq-grid td.pq-link { color: var(--ref3); }
.pq-loaded thead th { background: #1f6f55; color: #fff; padding: 0 12px; }
.pq-loaded tbody tr:nth-child(even) td { background: #f0f6f3; }
.pq-mini { margin: 0 0 12px; font-size: 12.5px; }
.pq-mini thead th { min-width: 0; padding: 2px 10px; cursor: pointer; position: static; }
.pq-mini th, .pq-mini td { height: 23px; }
.pq-form label.check { display: flex; grid-template-columns: none; gap: 6px; align-items: baseline; color: var(--ink); font-size: 13.5px; margin-bottom: 6px; }
.pq-form label.check.sep { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.pq-form label.check.off { color: var(--muted); }
.pq-form input:not([type=checkbox]):not([type=radio]) { font: inherit; padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.pq-inline { display: flex; gap: 6px; margin: 6px 0 12px; }
.pq-dialog { max-height: calc(100% - 20px); overflow-y: auto; }
.pq-note.pad { padding: 10px 14px; margin: 0; }
.pq-label.gap { margin-top: 18px; }
.pq-other { margin: 0 0 4px; padding: 4px 8px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; }
.pq-status.warn { color: var(--warn); }
.cell-drop { position: absolute; display: none; width: 18px; padding: 0; border: 1px solid var(--muted); background: var(--head); color: var(--ink); font-size: 10px; cursor: pointer; z-index: 3; }

/* --------------------------------------------------- PivotTable (sim) */
.pv-sheet { padding: 18px; }
.pv-table { border: 1px solid var(--grid-line); }
.pv-table th { background: #dde8f3; font-weight: 600; text-align: left; position: static; min-width: 0; padding: 0 12px; }
.pv-table th.pq-right, .pv-table td.pq-right { text-align: right; }
.pv-table tr th:not(:first-child) { text-align: right; }
.pv-table tr:first-child th:nth-child(2) { text-align: left; }
.pv-table td { min-width: 96px; }
.pv-table td:first-child { min-width: 150px; }
.pv-strong { font-weight: 600; }
.pv-grandrow td { background: #dde8f3; border-top: 1px solid #8fa9c4; font-weight: 600; }
.pv-empty { width: 300px; padding: 26px 22px; border: 1px dashed var(--muted); color: var(--muted); font-family: var(--ui); }
.pv-empty b { color: var(--ink); }
.pv-empty p { margin: 8px 0 0; }
.pv-filters { display: flex; gap: 8px; margin-bottom: 14px; }
.pv-filter { font: 13px/1.2 var(--sheet); padding: 5px 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.pv-side { width: 290px; }
.pv-fields { border: 1px solid var(--line); background: var(--surface); padding: 6px 8px; }
.pv-field { display: flex; gap: 8px; align-items: center; padding: 3px 2px; cursor: grab; }
.pv-areas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv-area { min-height: 84px; padding: 6px; border: 1px solid var(--line); background: var(--surface); }
.pv-area.over { border-color: var(--accent); background: var(--accent-soft); }
.pv-areaname { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pv-chip { display: block; width: 100%; text-align: left; font: 12.5px/1.25 var(--ui); padding: 4px 6px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 3px; background: #f4f6f3; color: var(--ink); cursor: grab; white-space: pre-wrap; }
.pv-chip:hover, .pv-chip:focus-visible { border-color: var(--muted); }
@media (max-width: 900px) { .pv-side { width: auto; } }

/* ---------------------------------------------------------- reference */
.ref-page h1 { font-size: 2.2rem; margin-bottom: 12px; }
.search { display: block; width: 100%; max-width: 420px; margin: 26px 0 30px; font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.entry { padding: 22px 0; border-top: 1px solid var(--line); max-width: 44em; }
.entry h2 { font-size: 1.15rem; margin-bottom: 10px; display: flex; align-items: baseline; gap: 12px; }
.kind { font-family: var(--ui); font-weight: 400; font-size: 0.85rem; color: var(--muted); letter-spacing: 0; }
.ex { display: grid; gap: 4px; }
.ex code { font-size: 0.86rem; word-break: break-word; }
.ex span, .from { color: var(--muted); font-size: 0.92rem; }
.from { margin: 0; }
.empty { color: var(--muted); }

/* -------------------------------------------------------------- small */
@media (max-width: 900px) {
  .lesson, .lesson.with-grid { display: block; height: auto; overflow: visible; }
  .pane-grid { border-left: 0; border-top: 1px solid var(--line); height: 70vh; }
  .text-inner { padding: 26px 16px 20px; min-height: 0; }
  .lesson.solo .text-inner { padding-top: 36px; }
  .top { padding: 0 16px; gap: 12px; }
  .crumb { display: none; }
  .steps a { width: 14px; }
  .home, .ref-page { padding: 36px 16px 72px; }
  .lessons li { grid-template-columns: 2.8em 1fr; }
  .lessons .outcome { grid-column: 2; }
  .lessons .state { grid-column: 2; text-align: left; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .option, .steps a { transition: background-color 0.12s, border-color 0.12s; }
}

/* PivotTable simulator: strip, slicers, timeline, model field list, dialogs */
.pv-strip .tool { font: 12.5px/1.2 var(--ui); padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); cursor: pointer; white-space: pre; }
.pv-strip .tool:hover, .pv-strip .tool:focus-visible { border-color: var(--muted); }
.pv-sheet { display: flex; gap: 22px; align-items: flex-start; }
.pv-reports { min-width: 0; }
.pv-other { margin: 22px 0 8px; font: 600 12.5px/1.2 var(--ui); color: var(--muted); }
.pv-panels { display: grid; gap: 14px; flex: none; }
.pv-slicer { width: 176px; padding: 8px; border: 1px solid var(--muted); background: var(--surface); font-family: var(--ui); }
.pv-slicer-head { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pv-slicer-head b { flex: 1 1 100%; font-size: 13px; }
.pv-icon { font: 11px/1.2 var(--ui); padding: 3px 6px; border: 1px solid var(--line); border-radius: 3px; background: none; color: var(--muted); cursor: pointer; }
.pv-icon.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pv-icon:disabled { opacity: 0.45; cursor: default; }
.pv-item { display: block; width: 100%; text-align: left; font: 13px/1.2 var(--sheet); padding: 6px 8px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: #9aa39e; cursor: pointer; }
.pv-item.on { background: #dde8f3; border-color: #8fa9c4; color: var(--ink); }
.pv-item:focus-visible, .pv-month:focus-visible, .pv-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pv-timeline { width: auto; max-width: 420px; }
.pv-level { font-size: 10.5px; color: var(--muted); margin-right: auto; }
.pv-period { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.pv-months { display: flex; padding-top: 16px; }
.pv-month { position: relative; flex: 1; min-width: 34px; font: 11.5px/1.2 var(--ui); padding: 7px 2px; border: 1px solid var(--line); border-left-width: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.pv-month:first-child { border-left-width: 1px; }
.pv-month.on { background: #8fa9c4; border-color: #6c8cab; color: #fff; }
.pv-month[data-year]::before { content: attr(data-year); position: absolute; left: 0; top: -15px; font-size: 10.5px; color: var(--muted); }
.pv-note { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.pv-tablename { margin: 6px 0 2px; font-size: 12.5px; font-weight: 600; }
.pv-tablename:first-child { margin-top: 0; }
.pv-field.sub { padding-left: 14px; }
.pv-fields { max-height: 260px; overflow-y: auto; }
.pv-banner { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; padding: 7px 8px; border: 1px solid #e2c96b; background: #fdf6d8; font-size: 12.5px; }
.pv-banner .btn { margin-left: auto; padding: 3px 9px; font-size: 12px; }
.pv-sub { margin: 12px 0 6px !important; font-size: 12px; font-weight: 600; color: var(--muted); }
.pq-form label.pv-row { grid-template-columns: 150px 1fr; align-items: center; }
.pq-form label.pv-row.tall { align-items: start; }
.pq-form textarea { font: 13px/1.4 var(--mono); padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); resize: vertical; }
.pq-form select:disabled { opacity: 0.5; }
.pq-dialog .pq-error { display: none; margin: 0 0 12px; padding: 7px 9px; font-size: 12.5px; background: #fdf1ef; color: #8c1d18; border-left: 3px solid #b3261e; }
.pq-dialog .pq-error.on { display: block; }
.pq-dialog .pq-error.fine { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); }
.pv-rel { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.pv-rel .btn { margin-left: auto; padding: 3px 9px; font-size: 12px; }
.pv-insert { display: flex; flex-wrap: wrap; gap: 4px; }
.pv-insert button { font: 12px/1.2 var(--ui); padding: 4px 8px; border: 1px solid var(--line); border-radius: 3px; background: #f4f6f3; color: var(--ink); cursor: pointer; }
.pv-table td, .pv-table th { cursor: default; }
@media (max-width: 900px) { .pv-sheet { flex-direction: column; } }

/* Chart simulator */
.ch-strip .tool { font: 12.5px/1.2 var(--ui); padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); cursor: pointer; white-space: pre; }
.ch-strip .tool:hover, .ch-strip .tool:focus-visible { border-color: var(--muted); }
.ch-sheet { padding: 18px; }
.ch-table { border: 1px solid var(--grid-line); outline: 2px solid #1e7145; outline-offset: -1px; }
.ch-table th { position: static; min-width: 0; padding: 0 12px; text-align: left; font-weight: 600; background: var(--surface); }
.ch-table th:not(:first-child) { text-align: right; }
.ch-table td { min-width: 84px; }
.ch-hint { margin: 16px 0 0; color: var(--muted); }
.ch-box { margin-top: 18px; max-width: 680px; padding: 12px 14px 10px; border: 1px solid #bfc6c1; background: var(--surface); }
.ch-title { display: block; margin: 0 auto 4px; padding: 3px 10px; border: 1px dashed transparent; background: none; font: 400 18px/1.3 var(--sheet); color: #595959; cursor: text; }
.ch-title:hover, .ch-title:focus-visible { border-color: var(--muted); }
.ch-titleinput { display: block; width: 86%; margin: 0 auto 4px; padding: 3px 10px; border: 1px solid var(--accent); font: 400 18px/1.3 var(--sheet); color: var(--ink); text-align: center; }
.ch-plot { display: block; width: 100%; height: auto; }
.ch-tick { font: 12px var(--sheet); fill: #595959; }
.ch-label { font: 11px var(--sheet); fill: #404040; }
.ch-label.inv { fill: #fff; }
.ch-grid { stroke: #d9d9d9; stroke-width: 1; }
.ch-axis { stroke: #bfbfbf; stroke-width: 1; }
.ch-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; padding-top: 6px; font: 12.5px var(--sheet); color: #595959; }
.ch-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 6px; }
.ch-legend i.line { width: 20px; height: 3px; vertical-align: middle; }
.ch-side { width: 220px; }

/* Module 6: conditional formats and sparklines on the grid, chart extras, print preview */
.grid td[data-icon]::before { content: attr(data-icon); float: left; margin-right: 4px; font-size: 10px; color: var(--icon); }
.fmt-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 2; }
.fmt-spark { position: absolute; overflow: visible; }
.fmt-group { margin: 6px 0 2px; padding: 0 14px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.pq-form label input[type=text] { width: 100%; box-sizing: border-box; }
.ch-sort { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; white-space: pre; }
.ch-sort:hover, .ch-sort:focus-visible { color: var(--accent); }
.ch-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.ch-row input { min-width: 0; font: inherit; padding: 5px 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.pq-side h3.gap { margin-top: 18px; }
.pr-sheet { padding: 16px 18px; background: #e4e6e3; }
.pr-count { margin: 0 0 12px; font-weight: 600; }
.pr-pages { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.pr-fig { margin: 0; width: 300px; }
.pr-fig figcaption { margin-top: 6px; font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.pr-page { width: 226px; aspect-ratio: 21 / 29.7; padding: 9.1% 8.5%; box-sizing: border-box; background: #fff; box-shadow: 0 1px 4px rgba(24, 33, 29, 0.28); }
.pr-page.land { width: 300px; aspect-ratio: 29.7 / 21; padding: 6% 6.4%; }
.pr-body { display: flex; min-height: 3px; }
.pr-col { min-width: 0; background: #dfe5e1; border-right: 1px solid #fff; overflow: hidden; }
.pr-col.headed { border-top: 3px solid #1f6f55; }
.pr-col span { display: block; padding: 1px 2px; font-size: 9.5px; line-height: 1.25; color: #3d4742; white-space: nowrap; overflow: hidden; }
.pr-side { width: 250px; }
.pr-row { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.pr-row select, .pr-row input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0; }
.pr-scale { margin: 0 0 6px; padding: 7px 9px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); }
.pr-scale.small { background: var(--warn-soft); color: var(--warn); }
.pr-buttons { display: flex; gap: 6px; margin: -4px 0 12px; }
.pr-buttons .btn { padding: 3px 10px; font-size: 12px; }
.pr-side .pq-error.on { display: block; margin: 0 0 10px; padding: 7px 9px; font-size: 12.5px; background: #fdf1ef; color: #8c1d18; border-left: 3px solid #b3261e; }

/* Module 7: tables and the forecast picture in lesson text, What-If dialogs */
.body table.mini { border-collapse: collapse; margin: 0 0 14px; font-size: 13.5px; }
.body table.mini th, .body table.mini td { padding: 3px 12px 3px 0; text-align: right; border-bottom: 1px solid var(--line); }
.body table.mini th:first-child, .body table.mini td:first-child { text-align: left; }
.body table.mini th { font-weight: 600; }
.body svg.season { display: block; width: 100%; height: auto; margin: 4px 0 2px; }
.body svg.season text { font: 10.5px var(--ui); fill: var(--muted); }
.body p.legend { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.body ul { margin: 0 0 14px; padding-left: 20px; }
.body ul li { margin-bottom: 4px; }
.wi-table { border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
.wi-table th, .wi-table td { padding: 3px 10px; border: 1px solid var(--line); text-align: left; }
.wi-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.wi-cons { margin-bottom: 8px; }
.pq-form .pq-inline label.check { display: inline-flex; margin-right: 14px; }

/* Module 8: auditing marks, styles, notes and protection on the grid */
.grid td.au-origin { box-shadow: inset 0 0 0 2px #1f4fbf; }
.grid td.au-pre { box-shadow: inset 0 0 0 2px #1f4fbf; background-image: radial-gradient(circle at 6px 50%, #1f4fbf 0 3px, transparent 3.5px); }
.grid td.au-dep { box-shadow: inset 0 0 0 2px #0e6b4e; background-image: radial-gradient(circle at 6px 50%, #0e6b4e 0 3px, transparent 3.5px); }
.grid td.au-found { box-shadow: inset 0 0 0 2px #b3261e; }
.grid td.au-input { background-color: #ffcc99; color: #3f3f76; }
.grid td.au-open { background-color: #f3faf6; }
.grid td.au-input.au-open { background-color: #ffcc99; }
.grid td.au-formula { text-align: left; font-family: var(--mono); font-size: 11.5px; color: #1f4fbf; }
.grid td.au-note { position: relative; }
.grid td.au-note::after { content: ""; position: absolute; right: 0; top: 0; border: 4px solid transparent; border-right-color: #c0392b; border-top-color: #c0392b; }
.au-step { margin: 0 0 6px !important; padding: 5px 8px; font: 13px/1.4 var(--mono); background: #f4f6f3; color: var(--muted); overflow-wrap: anywhere; }
.au-step.now { background: var(--accent-soft); color: var(--ink); }
.au-change { margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); }
.au-change p { margin: 4px 0 6px; font-size: 13px; overflow-wrap: anywhere; }
.au-when { margin-left: 8px; font-size: 12px; color: var(--muted); }
.pq-form textarea { width: 100%; box-sizing: border-box; }

/* Module 9: the code editor and code in lesson text */
.body pre.code { margin: 0 0 14px; padding: 10px 12px; background: #f0f2ef; border-left: 3px solid var(--line); overflow-x: auto; font: 12px/1.5 var(--mono); white-space: pre; }
.cd-main { flex: 1; min-height: 0; display: flex; }
.cd-editor { flex: 1 1 54%; min-width: 0; padding: 12px 14px; border: 0; border-right: 1px solid var(--line); background: #fbfcfa; color: var(--ink); font: 12.5px/1.55 var(--mono); resize: none; white-space: pre; overflow: auto; tab-size: 4; }
.cd-editor:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.cd-out { flex: 1 1 46%; min-width: 0; padding: 12px 14px; overflow: auto; background: var(--surface); }
.cd-caption { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.cd-table th { background: var(--head); font-weight: 400; color: var(--muted); text-align: center; min-width: 0; padding: 0 8px; position: static; }
.cd-table td { min-width: 56px; }
.cd-log { margin: 10px 0 0; font: 12px/1.4 var(--mono); color: var(--muted); }
.cd-out .pq-error.on { display: block; margin: 0 0 10px; padding: 7px 9px; font-size: 12.5px; background: #fdf1ef; color: #8c1d18; border-left: 3px solid #b3261e; }
@media (max-width: 900px) { .cd-main { flex-direction: column; } .cd-editor { min-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); } }
