:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --border: #dde2e8;
  --accent: #0f6e8c;
  --accent-soft: #e3f1f6;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --l1: #e3f1f6; --l2: #e7f0ea; --l3: #fff4e0; --l4: #efeaf7; --l5: #fde9e7; --l6: #0f6e8c;
  --l6-text: #ffffff;
  --done: #2e8b57;
  --ref: #6b4fbb;
  --rev: #c2185b;
  --rev-soft: #fde7ef;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1a2029; --text: #e6eaf0; --muted: #9aa5b4; --border: #2c3542;
    --accent: #4fb3d4; --accent-soft: #16323d; --warn: #f0b45a; --warn-soft: #3a2c14;
    --l1: #16323d; --l2: #1b3324; --l3: #3a2c14; --l4: #2a2340; --l5: #3d1f1c; --l6: #4fb3d4; --l6-text: #0b1218;
  --ref: #b39ddb; --rev: #f48fb1; --rev-soft: #3d1a28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1a2029; --text: #e6eaf0; --muted: #9aa5b4; --border: #2c3542;
  --accent: #4fb3d4; --accent-soft: #16323d; --warn: #f0b45a; --warn-soft: #3a2c14;
  --l1: #16323d; --l2: #1b3324; --l3: #3a2c14; --l4: #2a2340; --l5: #3d1f1c; --l6: #4fb3d4; --l6-text: #0b1218;
  --ref: #b39ddb; --rev: #f48fb1; --rev-soft: #3d1a28;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 52px; gap: 12px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.top-nav { display: flex; gap: 14px; overflow-x: auto; }
.top-nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.top-nav a:hover { color: var(--accent); }

h1, h2, h3 { text-wrap: balance; }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; margin: 8px 0 12px; }
h2 { font-size: 24px; margin: 48px 0 16px; }
h3 { font-size: 18px; margin: 28px 0 10px; }
h4 { font-size: 15px; margin: 14px 0 6px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 32px 0 0; }
.lede { font-size: 17px; color: var(--muted); max-width: 70ch; }
.zh { background: var(--accent-soft); color: var(--text); padding: 10px 14px; border-radius: 8px; font-size: 15px; }
.note { color: var(--muted); font-size: 14px; }

.progress-box { margin-top: 18px; max-width: 420px; }
.progress-label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 6px 0 10px; }
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.step.done .num { background: var(--done); }

.stack { display: grid; gap: 6px; }
.layer { display: grid; grid-template-columns: 200px 1fr; gap: 12px; padding: 10px 14px; border-radius: 8px; font-size: 15px; }
.layer span { color: var(--text); opacity: .85; }
.l1 { background: var(--l1); } .l2 { background: var(--l2); } .l3 { background: var(--l3); }
.l4 { background: var(--l4); } .l5 { background: var(--l5); }
.l6 { background: var(--l6); color: var(--l6-text); } .l6 span { color: var(--l6-text); }

.toc { columns: 2; padding-left: 20px; font-size: 15px; }
.toc a { text-decoration: none; }

.step, .tool, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin: 16px 0;
}
.step header { display: flex; align-items: center; gap: 12px; }
.step header h3 { margin: 0; }
.num {
  flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--surface);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.tip { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 4px; font-size: 15px; }

ul.check { list-style: none; padding: 0; margin: 12px 0; }
ul.check li { position: relative; padding: 6px 0 6px 32px; cursor: pointer; border-top: 1px dashed var(--border); }
ul.check li:first-child { border-top: 0; }
ul.check li::before {
  content: ""; position: absolute; left: 4px; top: 9px; width: 16px; height: 16px;
  border: 2px solid var(--muted); border-radius: 4px;
}
ul.check li.on { color: var(--muted); text-decoration: line-through; }
ul.check li.on::before { background: var(--accent); border-color: var(--accent); }
ul.check li.on::after {
  content: ""; position: absolute; left: 10px; top: 11px; width: 5px; height: 10px;
  border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.sub li { margin: 6px 0; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.cols ul { padding-left: 20px; margin: 4px 0; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.matrix td:nth-child(n+2):nth-child(-n+5) { text-align: center; }

input, select {
  width: 100%; font: inherit; font-size: 15px; padding: 7px 9px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); }
label input, label select { margin-top: 4px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }

.items { min-width: 760px; }
.items input, .items select { padding: 5px 6px; font-size: 14px; }
.items select { min-width: 120px; }
.items td { padding: 4px; }
.items .c-desc { min-width: 180px; }
.items .c-num { width: 90px; }
.items .c-unit { width: 70px; }
.items .cost { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.csv-out { width: 100%; font: 13px/1.4 "IBM Plex Mono", ui-monospace, monospace; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
button:focus-visible, li:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } #progressBar { transition: none; } }
.del { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }

.btn {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--surface);
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.by-cat div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.totals { margin: 0; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .big { font-size: 18px; border-bottom: 2px solid var(--accent); }
.totals .big dd { color: var(--accent); }
.small-totals { max-width: 420px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card { margin: 0; }
.card h4 { margin-top: 0; }
.card ul, .card ol { padding-left: 20px; margin: 0; font-size: 15px; }
.card.warn { background: var(--warn-soft); border-color: var(--warn); }

blockquote { margin: 0; padding: 14px 18px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; font-size: 16px; }
.qa details { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; padding: 10px 14px; }
.qa summary { cursor: pointer; font-weight: 600; }
.qa p { margin: 8px 0 2px; }
.notes-grid input { background: var(--surface); }

.card.key { border-color: var(--accent); }
.facts { margin: 0; display: grid; gap: 6px; font-size: 15px; }
.facts div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; white-space: nowrap; }
.qa p.en { font-style: italic; }
.card > .check { margin-top: 4px; }
.card.warn li + li { margin-top: 8px; }
.email-wrap { display: grid; gap: 8px; justify-items: start; }
.email { margin: 0; width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font: 14px/1.55 "IBM Plex Mono", ui-monospace, monospace; color: var(--text); }
#interview > .card { margin-top: 14px; }
.sources { font-size: 14px; padding-left: 20px; }
.foot { margin-top: 48px; padding: 20px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  .top-nav { gap: 10px; }
  .brand { font-size: 15px; }
  .layer { grid-template-columns: 1fr; gap: 2px; }
  .toc { columns: 1; }
  .cols, .summary, .grid3 { grid-template-columns: 1fr; }
}


/* ---------- Worked example ---------- */
.method { margin: 14px 0; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.banner { margin: 14px 0; padding: 10px 14px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 8px; font-size: 14px; }
.rev-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 52px); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin: 16px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.rev-note { color: var(--muted); }
.tight td, .tight th { padding: 5px 8px; }
.calc-table { min-width: 560px; }
.calc-table td.n, .calc-table th.n, .tight td.n, .tight th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-table tfoot td, .tight tfoot td { font-weight: 600; border-top: 2px solid var(--border); border-bottom: 0; }
.calc-table tr.group td { background: var(--bg); font-weight: 600; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.calc-table tr.subtotal td { font-weight: 600; }
.calc-table tr.grand td { font-weight: 700; font-size: 16px; color: var(--accent); border-top: 2px solid var(--accent); }
tr.changed td { background: var(--rev-soft); }
tr.changed td:first-child { box-shadow: inset 3px 0 0 var(--rev); }
#example .summary { align-items: start; }
#example .summary > * { min-width: 0; }
#example .facts div { grid-template-columns: 80px 1fr; }

.drawing-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
#planSvg { display: block; width: 100%; min-width: 620px; height: auto; }
#planSvg .wall { fill: none; stroke: var(--text); stroke-width: 3; }
#planSvg .room { fill: none; stroke: var(--muted); stroke-width: 1.2; }
#planSvg .core { fill: var(--bg); }
#planSvg .revb-room { fill: var(--rev-soft); stroke: var(--rev); stroke-width: 2; }
#planSvg .lbl { fill: var(--text); font: 12px "IBM Plex Sans", system-ui, sans-serif; }
#planSvg .small { font-size: 10px; fill: var(--muted); }
#planSvg .big { font-size: 15px; font-weight: 600; fill: var(--muted); }
#planSvg .mid { text-anchor: middle; }
#planSvg .end { text-anchor: end; }
#planSvg .revb-txt { fill: var(--rev); font-weight: 600; }
#planSvg .oa { stroke: var(--accent); stroke-width: 6; stroke-linecap: square; }
#planSvg .oa-br { fill: none; stroke: var(--accent); stroke-width: 3; }
#planSvg .ex { fill: none; stroke: var(--warn); stroke-width: 3; stroke-dasharray: 8 4; }
#planSvg .rf { fill: none; stroke: var(--ref); stroke-width: 1.5; stroke-dasharray: 2 3; }
#planSvg .flex { stroke: var(--accent); stroke-width: 1; opacity: .7; }
#planSvg .diff { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
#planSvg .rg { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 2; }
#planSvg .fcu { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
#planSvg .fan { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
#planSvg .ev { fill: var(--surface); stroke: var(--warn); stroke-width: 1.5; }
#planSvg .louvre { fill: var(--text); }
#planSvg .riser { fill: var(--ref); }
#planSvg .revb { stroke: var(--rev) !important; }
#planSvg .fcu.revb, #planSvg .diff.revb, #planSvg .rg.revb { fill: var(--rev-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 10px; border-radius: 2px; }
.sw-fcu { border: 2px solid var(--text); }
.sw-diff { border: 2px solid var(--accent); width: 10px; }
.sw-rg { border: 2px dashed var(--muted); width: 10px; }
.sw-oa { height: 5px; background: var(--accent); }
.sw-ex { height: 0; border-top: 3px dashed var(--warn); }
.sw-rf { height: 0; border-top: 2px dotted var(--ref); }
.sw-fan { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--text); }
.sw-revb { background: var(--rev-soft); border: 2px solid var(--rev); }
@media (max-width: 700px) { .rev-bar { top: calc(env(safe-area-inset-top, 0px) + 52px); } }
#sumTable { min-width: 0; }

/* ---------- Site chrome ---------- */
.top-nav a[aria-current="page"] { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); padding-bottom: 2px; }
.jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.jump a { font-size: 14px; text-decoration: none; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.jump a:hover { border-color: var(--accent); }

/* ---------- Home ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 24px 0; }
.home-card { display: grid; gap: 6px; align-content: start; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.home-card:hover { border-color: var(--accent); }
.home-card .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 600; }
.home-card b { font-size: 18px; }
.home-card span { color: var(--muted); font-size: 15px; }

/* ---------- CV ---------- */
.cv-head { display: grid; gap: 6px; margin: 32px 0 8px; }
.cv-head h1 { margin: 0; }
.cv-role { font-size: 18px; color: var(--muted); margin: 0; }
.cv-contact { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; margin: 6px 0 0; padding: 0; list-style: none; }
.cv-section { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 28px; padding: 22px 0; border-top: 1px solid var(--border); }
.cv-section > h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 4px; }
.cv-section p { margin: 0 0 8px; max-width: 70ch; }
.job + .job { margin-top: 22px; }
.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; align-items: baseline; }
.job-head h3 { margin: 0; font-size: 17px; }
.job-head .when { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.job .org { color: var(--accent); font-weight: 600; font-size: 15px; margin: 2px 0 6px; }
.job ul, .cv-list { margin: 0; padding-left: 20px; }
.job li, .cv-list li { margin: 4px 0; max-width: 72ch; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li { font-size: 14px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.skill-rows { display: grid; gap: 10px; }
.skill-rows div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: start; }
.skill-rows dt { color: var(--muted); font-size: 14px; padding-top: 3px; }
.skill-rows dd { margin: 0; }
.edu div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 4px 0; }
.edu .when { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Portfolio ---------- */
.proj-table td:first-child { min-width: 180px; }

@media (max-width: 700px) {
  .cv-section { grid-template-columns: 1fr; }
  .skill-rows div { grid-template-columns: 1fr; gap: 2px; }
}
