/* Site styles. One file, no build step.
   Sections: fonts, tokens, base, layout, components, pages, print. */

/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/bricolage-grotesque-wght.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #F5F1E8;
  --bg-2: #EDE6D8;
  --surface: #FFFDF8;
  --surface-2: #F8F4EC;
  --raised: #FFFFFF;
  --ink: #13213A;
  --ink-2: #47526A;
  --ink-3: #5E6779;
  --line: #E3DBCB;
  --line-2: #D2C7B2;
  --green: #1B7A50;
  --green-fill: #2C9E67;
  --green-btn: #1D7C51;
  --green-soft: #DCEFE2;
  --green-ink: #FFFFFF;
  --amber: #9A5A00;
  --amber-fill: #EFA638;
  --amber-soft: #FBEBD1;
  --coral: #E2533B;
  --coral-soft: #FBE2DB;
  --focus: #E2533B;
  --btn: #13213A;
  --btn-ink: #FFFDF8;
  --dot: rgba(19, 33, 58, 0.075);
  --shadow-1: 0 1px 0 rgba(19, 33, 58, 0.06), 0 1px 3px rgba(19, 33, 58, 0.06);
  --shadow-2: 0 1px 0 rgba(19, 33, 58, 0.05), 0 8px 24px -8px rgba(19, 33, 58, 0.18);
  --shadow-3: 0 18px 50px -12px rgba(19, 33, 58, 0.35);
  --img-bg: #FBF8F2;
  --mark-plate: #13213A;
  --mark-stud: #2C3D5E;
  --mark-tick: #2C9E67;

  --font-head: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  --tap: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0D1524;
    --bg-2: #0A111E;
    --surface: #152139;
    --surface-2: #19263F;
    --raised: #1C2A45;
    --ink: #F2EDE3;
    --ink-2: #BCC3D2;
    --ink-3: #9BA5B9;
    --line: #253350;
    --line-2: #34446A;
    --green: #4CC98C;
    --green-fill: #39B377;
    --green-btn: #39B377;
    --green-soft: #15382B;
    --green-ink: #07170F;
    --amber: #F3B755;
    --amber-fill: #E89E2E;
    --amber-soft: #3A2B12;
    --coral: #FF7C62;
    --coral-soft: #3D1F1A;
    --focus: #FF8A72;
    --btn: #F2EDE3;
    --btn-ink: #0D1524;
    --dot: rgba(242, 237, 227, 0.06);
    --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.25);
    --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
    --shadow-3: 0 20px 60px -10px rgba(0, 0, 0, 0.7);
    --img-bg: #F4F1EA;
    --mark-plate: #F2EDE3;
    --mark-stud: #C9CFDA;
    --mark-tick: #39B377;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1524;
  --bg-2: #0A111E;
  --surface: #152139;
  --surface-2: #19263F;
  --raised: #1C2A45;
  --ink: #F2EDE3;
  --ink-2: #BCC3D2;
  --ink-3: #9BA5B9;
  --line: #253350;
  --line-2: #34446A;
  --green: #4CC98C;
  --green-fill: #39B377;
  --green-btn: #39B377;
  --green-soft: #15382B;
  --green-ink: #07170F;
  --amber: #F3B755;
  --amber-fill: #E89E2E;
  --amber-soft: #3A2B12;
  --coral: #FF7C62;
  --coral-soft: #3D1F1A;
  --focus: #FF8A72;
  --btn: #F2EDE3;
  --btn-ink: #0D1524;
  --dot: rgba(242, 237, 227, 0.06);
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.25);
  --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-3: 0 20px 60px -10px rgba(0, 0, 0, 0.7);
  --img-bg: #F4F1EA;
  --mark-plate: #F2EDE3;
  --mark-stud: #C9CFDA;
  --mark-tick: #39B377;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; outline: none; }
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 1.3rem + 3.2vw, 3.4rem); font-weight: 750; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.85rem); }
h3, .h3 { font-size: 1.15rem; letter-spacing: -0.01em; }
p, li, dd { text-wrap: pretty; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--coral); }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--green-soft); }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.num, .tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--btn); color: var(--btn-ink); padding: 10px 16px; border-radius: var(--r);
  font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip:focus { top: 12px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(28px, 5vw, 56px); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; }
.section-sub { margin: 0; color: var(--ink-3); }
.eyebrow {
  font: 650 .78rem/1.2 var(--font-body); letter-spacing: .09em; text-transform: uppercase;
  color: var(--green); margin: 0 0 12px;
}
.lede { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); color: var(--ink-2); max-width: 40em; }

/* ---------- Header and footer ---------- */
.site-head {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.head-row { display: flex; align-items: center; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: var(--tap); }
.mark { width: 32px; height: 32px; flex: none; }
.mark-plate { fill: var(--mark-plate); }
.mark-stud { fill: var(--mark-stud); }
.mark-tick { fill: var(--mark-tick); }
.mark-tick-path { fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wordmark { font: 760 1.32rem/1 var(--font-head); letter-spacing: -0.03em; }
.wm-b { color: var(--green); }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-radius: 999px;
  text-decoration: none; font-weight: 550; color: var(--ink-2); font-size: .95rem;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.icon-btn {
  width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn:hover { border-color: var(--line-2); }
.theme-toggle .i-moon { fill: currentColor; stroke: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

@media (max-width: 760px) {
  .head-row { gap: 0 8px; padding-top: 6px; }
  .theme-toggle { margin-left: auto; }
  .nav { order: 3; width: calc(100% + 2 * var(--gutter)); margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter) 8px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 0 13px; font-size: .92rem; flex: none; }
}

.site-foot { margin-top: 64px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: .9rem; }
.foot-grid { display: grid; grid-template-columns: 1.2fr .6fr 1.6fr; gap: 24px 40px; padding-block: 36px 40px; }
.brand-sm .mark { width: 26px; height: 26px; }
.brand-sm .wordmark { font-size: 1.1rem; }
.foot-tag { margin: 8px 0 0; max-width: 24em; }
.foot-links { display: flex; flex-direction: column; gap: 0; }
.foot-links a { min-height: 36px; display: inline-flex; align-items: center; text-decoration: none; font-weight: 550; color: var(--ink); }
.foot-links a:hover { text-decoration: underline; }
.foot-legal p { margin: 0 0 8px; }
@media (max-width: 760px) {
  .foot-grid { grid-template-columns: 1fr; gap: 18px; }
  .foot-links { flex-direction: row; gap: 20px; }
}

/* ---------- Buttons and controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .95rem; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn-primary:hover { border-color: var(--btn); filter: brightness(1.15); }
.btn-green { background: var(--green-btn); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn-green { color: var(--green-ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-danger { color: var(--coral); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .88rem; }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; }

.chip-link {
  min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px dashed var(--line-2);
  background: transparent; font-weight: 600; font-size: .9rem; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chip-link:hover { color: var(--ink); border-style: solid; }

.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--ink-2); white-space: nowrap; }
.seg input:checked + span { background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg-sm span { min-height: 34px; padding: 0 12px; font-size: .86rem; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--green-fill); margin: 0; flex: none; }
.check-inline { display: inline-flex; }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--raised); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.5; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .92rem; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: transparent; }

/* ---------- Search ---------- */
.search { position: relative; max-width: 640px; }
.search-icon { position: absolute; left: 18px; top: 50%; translate: 0 -50%; width: 22px; height: 22px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; pointer-events: none; z-index: 2; }
.search-input {
  width: 100%; min-height: 62px; padding: 0 20px 0 52px !important; border-radius: 999px !important;
  border: 2px solid var(--ink) !important; background: var(--raised) !important;
  font-size: 1.12rem; font-weight: 500; box-shadow: 0 6px 0 -2px var(--line-2), var(--shadow-2);
}
.search-input::placeholder { color: var(--ink-3); opacity: 1; }
.search-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.search-sm .search-input { min-height: 50px; font-size: 1rem; border-width: 1.5px !important; box-shadow: var(--shadow-1); padding-left: 46px !important; }
.search-sm .search-icon { left: 16px; width: 20px; height: 20px; }
.search-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 10px); z-index: 30;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); overflow: hidden;
}
.search-status { margin: 0; padding: 10px 16px 6px; font-size: .82rem; color: var(--ink-3); font-weight: 550; }
.search-status:empty { display: none; }
.results { list-style: none; margin: 0; padding: 4px; max-height: min(62vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
.result {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 4px 14px;
  padding: 8px 10px; border-radius: var(--r); text-decoration: none; color: var(--ink); cursor: pointer;
  min-height: 64px;
}
.result[aria-selected="true"], .result:hover { background: var(--surface-2); }
.result-img { width: 64px; height: 48px; border-radius: 8px; background: var(--img-bg); object-fit: contain; display: block; }
.result-img.ph { display: grid; place-items: center; }
.result-name { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-meta { font-size: .84rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.result-num { font: 700 .86rem/1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 6px 8px; border-radius: 8px; white-space: nowrap; }
.result mark { background: transparent; color: inherit; text-decoration: underline 2px var(--amber-fill); text-underline-offset: 3px; }
.result-empty { padding: 18px 16px 20px; color: var(--ink-2); }
.result-empty strong { color: var(--ink); }

/* ---------- Home ---------- */
.hero { padding-block: clamp(36px, 7vw, 84px) clamp(24px, 4vw, 40px); position: relative; }
.hero-title { font-size: clamp(2.35rem, 1.2rem + 5vw, 4.6rem); max-width: 13em; margin-bottom: 18px; }
.hero .lede { margin-bottom: 28px; }
.try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 0; color: var(--ink-3); font-size: .9rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 196px), 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-1); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.tile-hero { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.tile-hero .tile-text { color: color-mix(in srgb, var(--btn-ink) 78%, transparent); }
.tile-art { width: 56px; height: 56px; margin-bottom: 8px; }
.tile-art svg { width: 100%; height: 100%; }
.tile-title { font: 700 1.2rem/1.2 var(--font-head); letter-spacing: -0.015em; }
.tile-text { color: var(--ink-2); font-size: .94rem; text-wrap: pretty; }
.a-fill { fill: var(--green-fill); }
.a-fill2 { fill: var(--amber-fill); }
.a-fill3 { fill: var(--coral); }
.a-paper { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 2; }
.a-line { stroke: var(--ink-3); stroke-width: 3; stroke-linecap: round; fill: none; }
.a-line-inv { stroke: var(--surface); stroke-width: 2.5; stroke-linecap: round; }
.a-tick { stroke: #fff; stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tile-hero .a-fill { fill: var(--green-fill); }
.tile-hero .a-line { stroke: color-mix(in srgb, var(--btn-ink) 70%, transparent); }
.a-c1 { fill: #A0A5A9; } .a-c2 { fill: #6C6E68; } .a-c3 { fill: #6D6E5C; } .a-c4 { fill: #9BA19D; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; counter-reset: step; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.steps h3 { margin: 12px 0 6px; }
.steps p { margin: 0; color: var(--ink-2); }
.step-no { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--green-soft); color: var(--green); font: 750 1rem/1 var(--font-head); }

.resume-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.resume-card {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-1); transition: border-color .2s, box-shadow .2s;
}
.resume-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.resume-img { width: 72px; height: 56px; object-fit: contain; background: var(--img-bg); border-radius: 10px; }
.resume-name { font-weight: 650; line-height: 1.25; margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.resume-meta { font-size: .84rem; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-bottom: 8px; }

/* ---------- Progress: studs and bars ---------- */
.studs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 14px); gap: 4px; }
.stud { width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--line); box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); position: relative; flex: none; }
.stud::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.stud.on { background: var(--green-fill); }
.stud.part { background: linear-gradient(90deg, var(--green-fill) var(--p, 50%), var(--line) var(--p, 50%)); }
.studs-lg { display: grid; grid-template-columns: repeat(24, minmax(0, 18px)); gap: clamp(3px, .7vw, 6px); }
.studs-lg .stud { width: 100%; height: auto; aspect-ratio: 1; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w, 0%); background: var(--green-fill); border-radius: inherit; transition: width .3s var(--ease); }
.bar.amber > i { background: var(--amber-fill); }

/* ---------- Panels, toolbars, page heads ---------- */
.page-head { padding-block: clamp(28px, 5vw, 56px) clamp(16px, 3vw, 28px); }
.page-head h1 { margin-bottom: 14px; }
.page-head .lede { margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(16px, 2.5vw, 24px); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; }
.result-count { color: var(--ink-3); font-size: .9rem; margin: 0 0 14px; font-variant-numeric: tabular-nums; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 6px; }
.field-note { font-size: .85rem; color: var(--ink-3); margin: 6px 0 0; }
.field-error { color: var(--coral); font-weight: 600; font-size: .88rem; margin: 8px 0 0; grid-column: 1 / -1; }
.field-error:empty { display: none; }

/* ---------- Empty, error and loading states ---------- */
.empty-state { text-align: center; padding: clamp(40px, 8vw, 90px) 0; max-width: 620px; margin-inline: auto; }
.empty-state .lede { margin-inline: auto; }
.empty-state .actions-row { justify-content: center; margin-top: 22px; }
.empty-art { width: 120px; height: 120px; margin: 0 auto 18px; }
.empty-art svg { width: 100%; height: 100%; }
.e-plate { fill: var(--surface); stroke: var(--line-2); stroke-width: 3; }
.e-stud { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 3; }
.e-hole { fill: none; stroke: var(--coral); stroke-width: 3; stroke-dasharray: 6 6; }
.empty-inline { padding: 28px 20px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty-inline strong { display: block; color: var(--ink); font: 700 1.1rem/1.3 var(--font-head); margin-bottom: 4px; }
.empty-inline p { margin: 0 auto; max-width: 34em; }
.sk { background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface-2) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
.set-skeleton { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding-block: 36px; }
.sk-photo { height: 140px; }
.sk-lines { display: grid; gap: 14px; align-content: center; }
.sk-line { height: 16px; }
.sk-line.tall { height: 40px; }
.w40 { width: 40%; } .w60 { width: 60%; } .w80 { width: 80%; }

/* ---------- Toast ---------- */
.toast-zone { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); translate: -50% 0; z-index: 90; display: grid; gap: 8px; width: min(94vw, 460px); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px;
  background: var(--btn); color: var(--btn-ink); border-radius: 16px; box-shadow: var(--shadow-3);
  font-weight: 550; animation: toast-in .25s var(--ease);
}
.toast-msg { flex: 1; min-width: 0; padding-block: 6px; }
.toast .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--btn-ink) 35%, transparent); min-height: 38px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-xl); padding: 0; background: var(--raised); color: var(--ink);
  width: min(94vw, 480px); box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(10, 16, 28, .55); backdrop-filter: blur(2px); }
.dlg-body { padding: 24px; }
.dlg-body h2 { font-size: 1.4rem; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; }
.choice { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; cursor: pointer; align-items: flex-start; }
.choice:has(input:checked) { border-color: var(--green-fill); background: var(--green-soft); }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--green-fill); flex: none; }
.choice b { display: block; }
.choice span { color: var(--ink-2); font-size: .9rem; }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.menu-list button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 52px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.menu-list button:hover { border-color: var(--line-2); }
.menu-list small { color: var(--ink-3); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Set page ---------- */
.set-head {
  display: grid; grid-template-columns: auto 1fr; gap: 20px 28px; align-items: center;
  padding-block: clamp(22px, 4vw, 40px) 18px;
}
.set-photo { width: clamp(112px, 22vw, 220px); aspect-ratio: 4 / 3; object-fit: contain; background: var(--img-bg); border-radius: var(--r-lg); border: 1px solid var(--line); padding: 8px; }
.set-photo-ph { display: grid; place-items: center; }
.set-photo-ph .mark { width: 48px; height: 48px; opacity: .25; }
.set-title { margin: 0 0 10px; font-size: clamp(1.75rem, 1.1rem + 3vw, 3rem); }
.set-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .86rem; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pill-strong { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }

.set-head .progress-card { grid-column: 1 / -1; }
.progress-card {
  display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 20px;
  box-shadow: var(--shadow-1);
}
.progress-big { font: 750 clamp(1.5rem, 1.1rem + 1.8vw, 2.2rem)/1 var(--font-head); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.progress-big small { font: 600 .95rem/1 var(--font-body); color: var(--ink-3); letter-spacing: 0; margin-left: 6px; }
.progress-label { font-size: .88rem; color: var(--ink-2); margin-top: 6px; font-weight: 550; }
.progress-label .ok { color: var(--green); font-weight: 700; }
.progress-card .studs { grid-column: 1 / -1; }
.pct { font: 750 1.05rem/1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--green); background: var(--green-soft); padding: 8px 12px; border-radius: 999px; }
.progress-card.complete { border-color: var(--green-fill); background: linear-gradient(0deg, var(--green-soft), var(--surface)); }

.sticky-progress {
  position: sticky; top: 0; z-index: 15; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  transform: translateY(-100%); opacity: 0; pointer-events: none; transition: transform .2s var(--ease), opacity .2s; margin-bottom: -53px;
}
.sticky-progress.show { transform: none; opacity: 1; pointer-events: auto; }
.sticky-row { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.sticky-name { font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-count { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sticky-row .bar { width: 90px; flex: none; }

.set-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 22px 0 16px; }
.tab {
  min-height: 48px; padding: 0 16px; border: 0; background: none; font-weight: 650; color: var(--ink-3);
  border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 8px;
}
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.tab .tcount { font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tab[aria-selected="true"] .tcount { background: var(--amber-soft); border-color: transparent; color: var(--amber); }

.groups { display: grid; gap: 10px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: clip; }
.group.done { border-color: color-mix(in srgb, var(--green-fill) 45%, var(--line)); }
.group-head {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 16px; background: none; border: 0; text-align: left;
}
.group-head:hover { background: var(--surface-2); }
.group-swatch { width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(0,0,0,.18); outline: 1px solid var(--line-2); outline-offset: 0; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), inset 0 2px 0 rgba(255,255,255,.25); flex: none; position: relative; }
.group-swatch.trans { background-image: linear-gradient(135deg, rgba(255,255,255,.55) 0 30%, transparent 30%); }
.group-swatch.icon { background: var(--surface-2); display: grid; place-items: center; border-color: var(--line); box-shadow: none; }
.group-swatch.icon svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 2; }
.group-name { font-weight: 650; line-height: 1.25; }
.group-sub { display: block; font-size: .82rem; color: var(--ink-3); font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }
.group-head .bar { width: clamp(50px, 12vw, 120px); }
.group-tick { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line); }
.group.done .group-tick { background: var(--green-fill); }
.group-tick svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.group.done .group-tick svg { opacity: 1; }
.chev { width: 20px; height: 20px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; transition: rotate .2s var(--ease); }
.group-head[aria-expanded="true"] .chev { rotate: 180deg; }
.group-head .group-tick { display: none; }
.group.done .group-head .group-tick { display: grid; }
.group.done .group-head .bar { display: none; }
.group-body { padding: 4px 12px 14px; border-top: 1px solid var(--line); }
.group-tools { display: flex; justify-content: flex-end; padding: 8px 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 172px), 1fr)); gap: 10px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r); overflow: clip; transition: border-color .2s, opacity .3s, transform .3s;
}
.card-tap { display: block; padding: 0; border: 0; background: var(--img-bg); aspect-ratio: 1; position: relative; width: 100%; }
.card-tap img { width: 100%; height: 100%; object-fit: contain; padding: 10%; display: block; }
.card-tap .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #8a8f99; font-size: .8rem; font-weight: 600; }
.card-tap::after {
  content: '+1'; position: absolute; right: 8px; top: 8px; font: 750 .78rem/1 var(--font-body); color: #13213A;
  background: rgba(255,255,255,.92); border: 1px solid rgba(19,33,58,.12); border-radius: 99px; padding: 5px 7px; opacity: 0; transition: opacity .15s;
}
.card-tap:hover::after, .card-tap:focus-visible::after { opacity: 1; }
.card-info { padding: 10px 12px 4px; flex: 1; }
.pname { font: 600 .9rem/1.3 var(--font-body); letter-spacing: 0; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.pmeta { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .78rem; color: var(--ink-3); min-width: 0; font-variant-numeric: tabular-nums; }
.pmeta .sw { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); box-shadow: 0 0 0 1px var(--surface), 0 0 0 2px var(--line-2); flex: none; }
.pmeta .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.counter { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; gap: 4px; padding: 8px 8px 4px; }
.counter button { height: var(--tap); border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; }
.counter button svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.counter .plus { background: var(--green-btn); border-color: transparent; color: #fff; }
:root[data-theme="dark"] .counter .plus { color: var(--green-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .counter .plus { color: var(--green-ink); } }
.counter .minus:disabled { opacity: .35; cursor: default; }
.count { text-align: center; font: 750 1.2rem/1 var(--font-body); font-variant-numeric: tabular-nums; }
.count small { font-size: .85rem; color: var(--ink-3); font-weight: 600; }
.allbtn { margin: 4px 8px 10px; min-height: 36px; border: 0; background: none; color: var(--ink-2); font-size: .82rem; font-weight: 650; border-radius: 8px; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.allbtn:hover { color: var(--ink); background: var(--surface-2); }
.card.done { border-color: var(--green-fill); background: var(--green-soft); }
.card.done .card-tap img { opacity: .55; }
.card.done .count { color: var(--green); }
.card.done .plus { background: var(--surface); color: var(--ink-3); border-color: var(--line-2); }
.card .badge-done { position: absolute; left: 8px; top: 8px; display: none; align-items: center; gap: 4px; padding: 4px 9px 4px 6px; border-radius: 99px; background: var(--green-btn); color: #fff; font: 700 .74rem/1 var(--font-body); }
.card .badge-done svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.card.done .badge-done { display: inline-flex; }
.card.bump { animation: bump .25s var(--ease); }
@keyframes bump { 50% { transform: scale(1.025); } }
.card.leaving { opacity: 0; transform: scale(.96); }
.only-missing .card.done:not(.leaving) { display: none; }
.card-fig .card-tap img { padding: 4%; }
.spare-cards .card { background: var(--surface-2); }
.spare-qty { padding: 0 12px 12px; font-size: .84rem; font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.missing-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.missing-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.mrow { display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 14px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; }
.mrow img, .mrow .mimg { width: 56px; height: 56px; object-fit: contain; background: var(--img-bg); border-radius: 10px; padding: 4px; display: block; }
.mname { font-weight: 600; line-height: 1.3; }
.mmeta { font-size: .82rem; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.mmeta .sw { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(0,0,0,.2); display: inline-block; vertical-align: -2px; margin-right: 4px; }
.mneed { text-align: right; }
.mneed b { display: block; font: 750 1.25rem/1 var(--font-body); color: var(--amber); font-variant-numeric: tabular-nums; }
.mneed a { font-size: .8rem; font-weight: 600; display: inline-flex; align-items: center; min-height: 32px; }
.mgroup-head { padding: 12px 14px 8px; background: var(--surface-2); font: 700 .8rem/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border-top: 1px solid var(--line); }
.mgroup-head:first-child { border-top: 0; }

.celebrate {
  position: relative; overflow: hidden; text-align: center; padding: 28px 20px; margin: 16px 0 0; border-radius: var(--r-lg);
  background: var(--btn); color: var(--btn-ink);
}
.celebrate h2 { margin: 0 0 6px; font-size: clamp(1.6rem, 1.2rem + 2vw, 2.4rem); }
.celebrate p { margin: 0; opacity: .8; }
.celebrate .burst { position: absolute; inset: 0; pointer-events: none; }
.celebrate .burst i { position: absolute; left: 50%; top: 55%; width: 12px; height: 12px; border-radius: 50%; background: var(--c); opacity: 0; animation: pop 1.3s var(--ease) var(--d) forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1); }
}

/* ---------- Pile ---------- */
#pile-root { display: grid; gap: 18px; }
.pile-sets .search { max-width: none; }
.pile-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.pile-set { display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 10px 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); }
.pile-set img, .pile-set .ph { width: 56px; height: 44px; object-fit: contain; background: var(--img-bg); border-radius: 8px; }
.pile-set-name { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.pile-set-name a { text-decoration: none; }
.pile-set-name a:hover { text-decoration: underline; }
.pile-set-meta { font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.pile-set .icon-btn { width: 40px; height: 40px; border-color: transparent; background: transparent; }
.pile-set .icon-btn:hover { background: var(--surface-2); }
.pile-empty-note { margin: 14px 0 0; color: var(--ink-3); font-size: .92rem; }
.merged-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin: 8px 0 12px; }
.merged-head h2 { margin: 0; }
.prow-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.prow {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 4px 14px; align-items: center; padding: 10px 10px 10px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  content-visibility: auto; contain-intrinsic-size: auto 96px;
}
.prow-img { width: 72px; height: 72px; background: var(--img-bg); border-radius: 10px; object-fit: contain; padding: 6px; display: block; }
.prow-name { font-weight: 600; line-height: 1.3; margin: 0 0 2px; font-size: .95rem; }
.prow-split { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.split-chip { font-size: .76rem; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: var(--amber-soft); color: var(--amber); font-variant-numeric: tabular-nums; border: 0; min-height: 28px; display: inline-flex; align-items: center; }
.split-chip.ok { background: var(--green-soft); color: var(--green); }
button.split-chip:hover { outline: 1px solid currentColor; }
.prow-act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.prow-need { font: 750 1.2rem/1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--amber); white-space: nowrap; }
.prow-need small { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.prow.done .prow-need { color: var(--green); }
.prow.done { background: var(--green-soft); border-color: color-mix(in srgb, var(--green-fill) 40%, var(--line)); }
.prow .btn-green { min-width: 96px; }
.colour-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; font-weight: 700; font-size: .92rem; }
.colour-divider:first-child { margin-top: 0; }
.colour-divider .sw { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(0,0,0,.2); box-shadow: 0 0 0 1px var(--line-2); }
.colour-divider small { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Labels ---------- */
.labels-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 24px; align-items: start; }
.label-controls { align-self: start; }
.field-group { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.field-group legend { font: 700 1.02rem/1.2 var(--font-head); padding: 0; margin-bottom: 10px; }
.source-pane { margin-top: 12px; }
.picked { margin: 10px 0 0; font-size: .9rem; color: var(--ink-2); }
.picked:empty { display: none; }
.picked b { color: var(--ink); }
.custom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.custom-grid label { font-size: .82rem; font-weight: 600; display: grid; gap: 4px; }
.print-box { border-top: 1px solid var(--line); padding-top: 16px; }
.label-count { font-weight: 650; margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.label-preview { min-width: 0; }
.ruler-check { margin-bottom: 16px; }
.cal-line { height: 18px; width: 100mm; max-width: 100%; border: 2px solid var(--ink); border-top: 0; position: relative; }
.cal-line::after { content: '100 mm'; position: absolute; left: 50%; translate: -50% 0; top: -2px; font-size: .75rem; font-weight: 700; }
.sheets { display: grid; gap: 18px; }
.sheet-frame { position: relative; overflow: hidden; border-radius: 4px; box-shadow: var(--shadow-2); background: #fff; }
.sheet-frame .sheet { transform-origin: 0 0; }
.sheet-cap { font-size: .82rem; color: var(--ink-3); margin: 0 0 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.labels-empty { margin-top: 8px; }

/* The printed sheet. Everything inside is in millimetres. */
.sheet { position: relative; background: #fff; color: #111; overflow: hidden; font-family: var(--font-body); }
.lbl { position: absolute; display: flex; align-items: center; gap: 1.6mm; padding: 1.4mm 2mm; overflow: hidden; box-sizing: border-box; }
.sheet.cut .lbl { outline: 0.2mm dashed #9aa0aa; outline-offset: -0.1mm; }
.lbl.blank { visibility: hidden; }
.sheet.measure .lbl { background: #d9d9d9; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.lbl-img { flex: none; height: 100%; aspect-ratio: 1; max-width: 42%; object-fit: contain; display: block; }
.lbl-text { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: .6mm; }
.lbl-num { --fs: 4.4mm; font: 800 calc(var(--fs) * min(1, 7 / var(--nl, 5)))/1.05 var(--font-body); letter-spacing: -0.02em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lbl-name { font: 500 2.5mm/1.2 var(--font-body); color: #333; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lbl-col { display: flex; align-items: center; gap: 1mm; font: 600 2.2mm/1.1 var(--font-body); color: #444; white-space: nowrap; overflow: hidden; }
.lbl-col i { width: 2.4mm; height: 2.4mm; border-radius: .5mm; border: .15mm solid rgba(0,0,0,.35); flex: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.lbl-qty { position: absolute; right: 1.4mm; top: 1.2mm; font: 800 2.6mm/1 var(--font-body); background: #111; color: #fff; padding: .5mm 1mm; border-radius: .8mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet.small .lbl { padding: 1mm 1.4mm; gap: 1mm; }
.sheet.small .lbl-num { --fs: 3.4mm; }
.sheet.small .lbl-name { font-size: 1.9mm; -webkit-line-clamp: 2; }
.sheet.small .lbl-col { font-size: 1.8mm; }
.sheet.large .lbl-num { --fs: 6.2mm; }
.sheet.large .lbl-name { font-size: 3.2mm; -webkit-line-clamp: 3; }
.sheet.large .lbl-col { font-size: 2.8mm; }
.cal-page { position: relative; background: #fff; color: #111; font-family: var(--font-body); }
.cal-page .cal-inner { position: absolute; left: 20mm; top: 25mm; right: 20mm; }
.cal-page h2 { font: 800 8mm/1.1 var(--font-head); margin: 0 0 4mm; color: #111; }
.cal-page p { font-size: 4mm; line-height: 1.45; margin: 0 0 3mm; color: #222; }
.cal-bar { width: 100mm; height: 10mm; border: .4mm solid #111; border-top: 0; position: relative; margin: 10mm 0 3mm; }
.cal-bar i { position: absolute; bottom: 0; width: .3mm; background: #111; height: 4mm; }
.cal-bar i:nth-child(2n+1) { height: 7mm; }
.cal-sq { width: 50mm; height: 50mm; border: .4mm solid #111; margin-top: 8mm; display: grid; place-items: center; font-size: 4mm; font-weight: 700; }

@media (max-width: 900px) {
  .labels-layout { grid-template-columns: 1fr; }
  .label-controls { position: static; max-height: none; }
}

/* ---------- Colours ---------- */
.colour-toolbar .search { flex-basis: 280px; }
.colour-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.ccard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; content-visibility: auto; contain-intrinsic-size: auto 230px; }
.cswatch { height: 84px; position: relative; border-bottom: 1px solid rgba(0,0,0,.12); }
.cswatch.trans::before { content: ''; position: absolute; inset: 0; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px; z-index: 0; }
.cswatch i { position: absolute; inset: 0; z-index: 1; }
.cswatch .tag { position: absolute; right: 10px; top: 10px; z-index: 2; font: 700 .72rem/1 var(--font-body); background: rgba(255,255,255,.92); color: #13213A; padding: 5px 8px; border-radius: 99px; }
.cbody { padding: 12px 14px 14px; display: grid; gap: 8px; }
.cname { font: 700 1.05rem/1.2 var(--font-head); margin: 0; }
.cfacts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; margin: 0; }
.cfacts b { color: var(--ink-2); font-weight: 650; }
.alike { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.alike-label { font-size: .76rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; width: 100%; }
.alike button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); font-size: .8rem; font-weight: 600; max-width: 100%; }
.alike button:hover { border-color: var(--line-2); }
.alike .sw { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); flex: none; }
.alike .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--focus); } }

/* ---------- Ruler ---------- */
.ruler-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.conv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 16px; }
.conv-grid label { display: grid; gap: 6px; font-size: .86rem; font-weight: 650; color: var(--ink-2); }
.conv-grid input { font: 700 1.3rem/1 var(--font-body); font-variant-numeric: tabular-nums; min-height: 54px; }
.diagram { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow-x: auto; }
.diagram svg { display: block; max-width: 100%; height: auto; }
.diagram figcaption { font-size: .8rem; color: var(--ink-3); margin-top: 8px; }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: minmax(7.5em, 34%) 1fr; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { font-weight: 650; }
.facts dd { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dg-brick { fill: var(--green-fill); stroke: color-mix(in srgb, var(--green-fill) 60%, #000); stroke-width: 1; }
.dg-plate { fill: var(--amber-fill); stroke: color-mix(in srgb, var(--amber-fill) 60%, #000); stroke-width: 1; }
.dg-dim { stroke: var(--ink-2); stroke-width: 1; fill: none; }
.dg-txt { fill: var(--ink-2); font: 600 11px var(--font-body); }

/* ---------- Prose pages ---------- */
.prose { max-width: 720px; padding-block: clamp(28px, 5vw, 56px); }
.prose h1 { margin-bottom: 20px; }
.prose h2 { font-size: 1.35rem; margin-top: 1.8em; }
.prose p, .prose li { font-size: 1.05rem; color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .4em; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .celebrate .burst { display: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .set-head { grid-template-columns: 96px 1fr; gap: 14px 16px; align-items: start; }
  .set-photo { width: 96px; padding: 4px; border-radius: var(--r); }
  .set-head .progress-card { grid-column: 1 / -1; }
  .set-title { font-size: 1.55rem; margin-bottom: 8px; }
  .pill { min-height: 26px; padding: 0 9px; font-size: .78rem; }
  .group-head { padding: 8px 12px; gap: 10px; }
  .group-body { padding: 4px 8px 12px; }
  .cards { gap: 8px; }
  .card-info { padding: 8px 10px 2px; }
  .counter { padding: 6px 6px 2px; gap: 2px; }
  .prow { grid-template-columns: 56px 1fr; }
  .prow-img { width: 56px; height: 56px; }
  .prow-act { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .set-skeleton { grid-template-columns: 96px 1fr; }
  .sk-photo { height: 80px; }
  .set-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .set-actions .btn { padding: 0 10px; font-size: .88rem; }
  .tabs .tab { flex: 1; justify-content: center; padding: 0 8px; }
  .search-input { min-height: 56px; font-size: 1.02rem; }
  .result { grid-template-columns: 56px 1fr; }
  .result-img { width: 56px; height: 44px; }
  .result-num { grid-column: 2; justify-self: start; padding: 4px 6px; font-size: .78rem; }
}

/* ---------- Print ---------- */
.print-sheet { display: none; }
@media print {
  :root { --bg: #fff; --ink: #111; color-scheme: light; }
  body { background: #fff !important; color: #111; display: block; }
  .site-head, .site-foot, .toast-zone, .skip, .no-print, .sticky-progress, dialog { display: none !important; }
  main { display: block; }
  a { color: inherit; text-decoration: none; }
}

/* Set checklist print (body.printing-checklist) */
@media print {
  body.printing-checklist main > :not(#print-sheet) { display: none !important; }
  body.printing-checklist .print-sheet { display: block; }
}
@page checklist { size: A4; margin: 12mm 11mm 14mm; }
.print-sheet { font-family: var(--font-body); color: #111; }
.ps-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; border-bottom: .6mm solid #13213A; padding-bottom: 3mm; margin-bottom: 4mm; }
.ps-brand { display: flex; align-items: center; gap: 2mm; font: 760 3.6mm/1 var(--font-head); color: #13213A; }
.ps-brand .mark { width: 6mm; height: 6mm; }
.ps-brand .mark-plate { fill: #13213A; } .ps-brand .mark-stud { fill: #2C3D5E; } .ps-brand .mark-tick { fill: #2C9E67; }
.ps-title { font: 760 7mm/1.05 var(--font-head); margin: 1.5mm 0 1mm; letter-spacing: -0.02em; color: #111; }
.ps-sub { font-size: 3mm; color: #444; margin: 0; }
.ps-stats { text-align: right; font-size: 2.9mm; color: #333; line-height: 1.5; }
.ps-stats b { font-size: 4.2mm; color: #111; display: block; }
.ps-cols { column-count: 2; column-gap: 7mm; column-rule: .2mm solid #ddd; }
.ps-colour { break-inside: avoid; break-after: avoid; display: flex; align-items: center; gap: 2mm; font: 700 3.1mm/1 var(--font-body); margin: 3mm 0 1.2mm; padding-bottom: 1mm; border-bottom: .3mm solid #13213A; }
.ps-colour i { width: 3.4mm; height: 3.4mm; border-radius: .8mm; border: .2mm solid rgba(0,0,0,.4); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ps-colour small { margin-left: auto; font-weight: 600; color: #555; }
.ps-row { break-inside: avoid; display: grid; grid-template-columns: 4mm 9mm 1fr auto; gap: 2.2mm; align-items: center; padding: .9mm 0; border-bottom: .15mm solid #e4e4e4; font-size: 2.7mm; line-height: 1.2; }
.ps-box { width: 3.6mm; height: 3.6mm; border: .3mm solid #13213A; border-radius: .7mm; }
.ps-row.done .ps-box { background: #2C9E67; border-color: #2C9E67; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ps-row img, .ps-row .ps-noimg { width: 9mm; height: 9mm; object-fit: contain; }
.ps-name { min-width: 0; }
.ps-name b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ps-name span { color: #666; font-size: 2.4mm; font-variant-numeric: tabular-nums; }
.ps-qty { font: 800 3.3mm/1 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-qty small { font-size: 2.3mm; color: #666; font-weight: 600; }
.ps-foot { margin-top: 5mm; padding-top: 2mm; border-top: .2mm solid #ccc; font-size: 2.3mm; color: #666; display: flex; justify-content: space-between; gap: 6mm; }
@media print {
  body.printing-checklist { page: checklist; }
}

/* Label print (body.printing-labels) */
@media print {
  body.printing-labels .labels-layout { display: block; padding: 0; max-width: none; }
  body.printing-labels .label-preview { margin: 0; }
  body.printing-labels .sheets { display: block; }
  body.printing-labels .sheet-cap { display: none; }
  body.printing-labels .sheet-frame { box-shadow: none; border-radius: 0; overflow: visible; width: auto !important; height: auto !important; break-after: page; page-break-after: always; }
  body.printing-labels .sheet-frame:last-child { break-after: auto; page-break-after: auto; }
  body.printing-labels .sheet-frame .sheet { transform: none !important; }
  body.printing-labels .wrap { padding: 0; max-width: none; }
  body.printing-labels .lbl-img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Polish pass 1 ---------- */
/* Part photos sit on white; multiply blends that white into the warm tile colour. */
/* The part tile is the button; multiply blends the photo's white into the tile colour. */
.card-tap img { mix-blend-mode: multiply; }
.card-tap { background-color: var(--img-bg); }
/* Elsewhere pictures sit on clean white, which matches their own background. */
.mrow img, .mrow .mimg, .prow-img, .result-img, .resume-img, .set-photo, .pile-set img, .pile-set .ph { background-color: #fff; }
.mmeta .sw { box-shadow: 0 0 0 1px var(--line-2); border-radius: 50%; }

/* Hero art (desktop) */
.hero-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: center; }
.hero-art { display: none; }
@media (min-width: 980px) {
  .hero-inner { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
  .hero-copy { grid-column: 1; }
  .hero-art { display: block; grid-column: 2; grid-row: 1; justify-self: end; width: 100%; max-width: 400px; }
}
.hero-art svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 24px 40px rgba(19, 33, 58, .22)); }
.ha-plate { fill: var(--btn); }
.ha-stud { fill: color-mix(in srgb, var(--btn) 82%, var(--btn-ink)); }
.ha-ring { fill: none; stroke: color-mix(in srgb, var(--btn-ink) 12%, transparent); stroke-width: 1.5; }
.ha-on { fill: var(--green-fill); }
.ha-miss { fill: none; stroke: var(--amber-fill); stroke-width: 3; stroke-dasharray: 5 4; }
.ha-tick { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ha-tag rect { fill: var(--raised); stroke: var(--line); }
.ha-tag text { font: 700 15px var(--font-body); fill: var(--ink); }
.ha-tag .sub { font: 600 12px var(--font-body); fill: var(--ink-3); }

/* Set header: three columns on wide screens */
@media (min-width: 980px) {
  .set-head { grid-template-columns: auto minmax(0, 1fr) minmax(340px, 400px); }
  .set-head .progress-card { grid-column: 3; grid-row: 1; }
  .set-head .studs-lg { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 4px; }
}

/* Pile rows in two columns on wide screens */
@media (min-width: 1040px) {
  .prow-list { grid-template-columns: 1fr 1fr; }
  .prow-list .colour-divider { grid-column: 1 / -1; }
}

/* Phone: compact tiles and steps */
@media (max-width: 600px) {
  .tiles { gap: 10px; }
  .tile { display: grid; grid-template-columns: 44px 1fr; column-gap: 14px; row-gap: 2px; padding: 14px 16px; align-items: start; }
  .tile-art { width: 44px; height: 44px; margin: 2px 0 0; grid-row: span 2; }
  .tile-title { font-size: 1.08rem; }
  .tile-text { font-size: .9rem; }
  .steps { gap: 10px; }
  .steps li { display: grid; grid-template-columns: 36px 1fr; column-gap: 14px; padding: 14px 16px; }
  .steps .step-no { grid-row: span 2; }
  .steps h3 { margin: 6px 0 4px; }
  .hero-title { font-size: 2.5rem; }
}
.progress-note { font-size: .8rem; color: var(--ink-3); margin-top: 3px; }

@media (max-width: 600px) { .group-sub .kinds { display: none; } }
.result-img.ph, .resume-img.ph { background: var(--surface-2); }
.prose .eyebrow { color: var(--green); font-size: .78rem; }
