/* Mini 4WD Toolkit — H23 Lab Liturgia theme (design system "H23 Lab Liturgia").
   Dark = the night of the lab (default), light = printed paper: <html data-theme="dark|light">.
   Tailwind (CDN) is used only for layout; colour, type and components come from here. */

@font-face { font-family: "Cormorant"; src: url(/assets/fonts/Cormorant-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(/assets/fonts/Cormorant-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(/assets/fonts/Cormorant-500-Italic.woff2) format("woff2"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "Redaction"; src: url(/assets/fonts/Redaction-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Redaction"; src: url(/assets/fonts/Redaction-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Redaction"; src: url(/assets/fonts/Redaction-Italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Redaction 50"; src: url(/assets/fonts/Redaction50-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Px437 IBM VGA 8x16"; src: url(/assets/fonts/Px437_IBM_VGA_8x16.ttf) format("truetype"); font-display: swap; }

:root, [data-theme="dark"] {
  --bg: #060505; --surface: #0f0d0d; --surface-raised: #1a1717; --hairline: #2b2626; --line: #8a8078;
  --ink: #f1ede6; --ink-muted: #b3aba2; --red: #8c0b14; --red-pressed: #6e0810; --red-text: #e8636a; --on-red: #f6f1ea;
  --signal: #33ff66; --ok: #8fc7a6; --warn: #d9ad63; --info: #97b8da; --focus: #f1ede6;
  --lift: 0 28px 48px -28px #000;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eceae6; --surface: #f8f6f3; --surface-raised: #dedad4; --hairline: #cdc8c0; --line: #6b635b;
  --ink: #0b0909; --ink-muted: #4a443e; --red: #7a0a12; --red-pressed: #5c080e; --red-text: #7a0a12; --on-red: #f6f1ea;
  --signal: #006b24; --ok: #1f6b45; --warn: #7a4e00; --info: #1f4f80; --focus: #0b0909;
  --lift: 0 28px 48px -32px #00000059;
  color-scheme: light;
}
:root {
  --font-display: "Cormorant", "Cormorant Garamond", Garamond, serif;
  --font-text: "Redaction", Georgia, serif;
  --font-worn: "Redaction 50", "Redaction", Georgia, serif;
  --font-pixel: "Px437 IBM VGA 8x16", "Courier New", monospace;
  --caps: .24em;
}

/* ── base ── */
*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/26px var(--font-text); font-variant-numeric: lining-nums tabular-nums; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
::placeholder { color: var(--ink-muted); opacity: .9; }
::selection { background: var(--ink); color: var(--bg); }
[v-cloak] { display: none; }
@media (prefers-reduced-motion: no-preference) { .fade-in { animation: l23fade .4s ease both; } }
@keyframes l23fade { from { opacity: 0; } to { opacity: 1; } }

/* ── type ── */
.display-xl { font: 600 56px/56px var(--font-display); letter-spacing: -.01em; margin: 0; }
.display-lg { font: 600 44px/48px var(--font-display); letter-spacing: -.01em; margin: 0; }
.display-md { font: 500 32px/38px var(--font-display); margin: 0; }
.display-sm { font: 500 28px/34px var(--font-display); margin: 0; }
@media (min-width: 768px) { .display-xl { font-size: 96px; line-height: 92px; } .display-lg { font-size: 64px; line-height: 68px; } .display-md { font-size: 40px; line-height: 46px; } }
.lead { font-size: 18px; line-height: 30px; color: var(--ink-muted); }
@media (min-width: 768px) { .lead { font-size: 20px; line-height: 32px; } }
.caption { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.label { font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; color: var(--ink-muted); }
.worn { font: 400 18px/28px var(--font-worn); }
.pixel { font: 16px/16px var(--font-pixel); text-transform: uppercase; }
.num { font-variant-numeric: lining-nums tabular-nums; }
.muted { color: var(--ink-muted); }
.red-text { color: var(--red-text); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .info { color: var(--info); } .signal { color: var(--signal); }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }
.link:hover { text-decoration-color: var(--ink); }

/* ── header and footer ── */
.site-header { position: sticky; top: 0; z-index: 40; background: var(--bg); border-bottom: 1px solid var(--hairline); }
.site-header .inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 64px; }
@media (min-width: 768px) { .site-header .inner { padding: 0 40px; } }
.logo { height: 32px; width: auto; display: block; }
.logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; } [data-theme="light"] .logo-light { display: block; }
.nav { display: flex; gap: 24px; margin-left: auto; align-items: center; }
.nav a { font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; color: var(--ink-muted); text-decoration: none; padding: 24px 0 22px; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); border-bottom-color: var(--ink); }
.nav .count { font: 16px/16px var(--font-pixel); margin-left: 6px; color: var(--ink); }
.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--ink); color: var(--bg); }
/* mobile: bottom tab bar */
.tabbar { display: none; }
@media (max-width: 767px) {
  .nav { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 56px; box-sizing: border-box; padding: 8px 0 6px; color: var(--ink-muted); text-decoration: none; font: 400 11px/14px var(--font-text); letter-spacing: .12em; text-transform: uppercase; }
  .tabbar a i { font-size: 18px; }
  .tabbar a.on { color: var(--ink); box-shadow: inset 0 2px 0 var(--red-text); }
  .tabbar .count { font: 16px/16px var(--font-pixel); color: var(--ink); margin-left: 4px; }
  body.has-tabbar { padding-bottom: 72px; }
}
.site-footer { margin-top: 144px; padding: 0 16px 48px; text-align: center; }
.site-footer .seal { width: 120px; height: 120px; display: block; margin: 0 auto 24px; }
.site-footer .sign { height: 20px; width: auto; margin: 16px auto 0; display: block; opacity: .9; }
.seal-light, .sign-light { display: none !important; }
[data-theme="light"] .seal-dark, [data-theme="light"] .sign-dark { display: none !important; }
[data-theme="light"] .seal-light, [data-theme="light"] .sign-light { display: block !important; }

/* ── containers ── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 40px; } }
.frame { position: relative; border: 1px solid var(--line); background: var(--surface); padding: 24px; }
.frame::before { content: ""; position: absolute; inset: 6px; border: 1px solid var(--hairline); pointer-events: none; }
.frame > * { position: relative; }
@media (min-width: 768px) { .frame { padding: 40px; } }
.panel { border: 1px solid var(--hairline); background: var(--surface); padding: 16px; }
.hr { border: 0; border-top: 1px solid var(--hairline); margin: 0; }
.rule { display: flex; align-items: center; gap: 16px; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rule-mark { width: 8px; height: 8px; border: 1px solid var(--ink); transform: rotate(45deg); }

/* ── controls ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.btn:disabled { border-color: var(--hairline); color: var(--ink-muted); cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--on-red); }
.btn-primary:hover:not(:disabled) { background: var(--red-pressed); border-color: var(--red-pressed); color: var(--on-red); }
.btn-ghost { min-height: 32px; padding: 0; border-color: transparent; border-bottom-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: transparent; color: var(--ink); border-bottom-color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 14px; }
.btn-block { width: 100%; }
.input, .select { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); background: var(--surface-raised); color: var(--ink); font: 400 16px/24px var(--font-text); }
.input:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--hairline); background: var(--surface-raised); color: var(--ink);
  font: 400 14px/20px var(--font-text); cursor: pointer; white-space: nowrap; user-select: none; }
.chip:hover { border-color: var(--line); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-sm { min-height: 30px; padding: 0 9px; font-size: 13px; }
.tag { display: inline-block; padding: 0 4px; background: var(--surface-raised); color: var(--tone, var(--ink)); font: 16px/16px var(--font-pixel); text-transform: uppercase; white-space: nowrap; }
.tag::before { content: "["; } .tag::after { content: "]"; }
.tag-red { --tone: var(--red-text); } .tag-signal { --tone: var(--signal); } .tag-warn { --tone: var(--warn); } .tag-ok { --tone: var(--ok); } .tag-info { --tone: var(--info); }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); }
.stepper button { width: 40px; min-height: 40px; background: transparent; border: 0; color: var(--ink); cursor: pointer; font-size: 18px; }
.stepper button:hover { background: var(--ink); color: var(--bg); }
.stepper span { min-width: 36px; display: flex; align-items: center; justify-content: center; font: 16px/16px var(--font-pixel); border-left: 1px solid var(--hairline); border-right: 1px solid var(--hairline); }

/* ── catalogue pieces ── */
.thumb { background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.piece { display: flex; flex-direction: column; border: 1px solid var(--hairline); background: var(--surface); min-width: 0; }
.piece:hover { border-color: var(--line); }
.piece .thumb { aspect-ratio: 1 / 1; border-bottom: 1px solid var(--hairline); }
.piece-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.piece-code { font: 16px/16px var(--font-pixel); color: var(--ink-muted); }
.piece-name { font: 400 15px/22px var(--font-text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.price { font: 500 24px/28px var(--font-display); font-variant-numeric: lining-nums tabular-nums; }
.row-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hairline); align-items: center; min-width: 0; }
.row-item .thumb { width: 64px; height: 64px; flex: none; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; color: var(--ink-muted); white-space: nowrap; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-raised); }

/* ── prompt, checker, setup sheet ── */
.prompt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font: 16px/16px var(--font-pixel); text-transform: uppercase; }
.prompt-path { color: var(--signal); }
.prompt-cursor { display: inline-block; width: 8px; height: 16px; background: var(--signal); animation: l23blink 1.2s steps(1) infinite; }
@keyframes l23blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .prompt-cursor { animation: none; } }
.checker { height: 16px; background-image: repeating-conic-gradient(var(--ink) 0 25%, transparent 0 50%); background-size: 16px 16px; }
.sheet-rows { display: grid; gap: 8px; align-content: start; }
.sheet-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.sheet-label { flex: none; font: 16px/16px var(--font-pixel); text-transform: uppercase; color: var(--ink-muted); }
.sheet-leader { flex: 1; min-width: 16px; border-bottom: 1px dotted var(--line); transform: translateY(-3px); }
.sheet-value { min-width: 0; max-width: 64%; overflow-wrap: anywhere; text-align: right; }

/* ── overlays ── */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
[data-theme="light"] .overlay { background: rgba(11, 9, 9, .45); }
.dialog { background: var(--surface); border: 1px solid var(--line); width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; padding: 24px; position: relative; }
@media (max-width: 767px) {
  .overlay { align-items: flex-end; padding: 0; }
  .dialog { max-width: none; max-height: 92dvh; border-left: 0; border-right: 0; border-bottom: 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
}
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 80; background: var(--surface-raised); border: 1px solid var(--line); color: var(--ink); padding: 12px 18px; max-width: calc(100% - 32px); }
@media (max-width: 767px) { .toast { bottom: 88px; } }
.sticky-bar { position: sticky; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 767px) { .sticky-bar { bottom: 64px; } }

/* print */
@media print {
  .site-header, .tabbar, .site-footer, .no-print { display: none !important; }
  body { background: #fff; color: #000; padding: 0 !important; }
  .frame, .panel { background: #fff; border-color: #999; }
}

/* ── additions: toggles, list states, mobile bars ── */
.btn-on { background: var(--ink); color: var(--bg); }
.icon-btn.in-list { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 40px; background: transparent; border: 0; border-right: 1px solid var(--hairline); color: var(--ink-muted); cursor: pointer;
  font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; padding: 0 12px; white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--bg); }
.grid-pieces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid-pieces { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-pieces { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.bar-fixed { position: fixed; left: 0; right: 0; bottom: 0; z-index: 44; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
@media (max-width: 767px) { .bar-fixed { bottom: calc(57px + env(safe-area-inset-bottom)); padding-bottom: 10px; } body.has-bar { padding-bottom: 150px; } }
@media (min-width: 768px) { .bar-fixed.mobile-only { display: none; } }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.scroll-x::-webkit-scrollbar { display: none; }
.pick { border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; text-align: left; color: var(--ink); padding: 0; display: flex; flex-direction: column; min-width: 0; font: inherit; }
.pick:hover { border-color: var(--line); }
.pick.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pick .thumb { aspect-ratio: 4 / 3; }
.pick-body { padding: 8px 10px; display: grid; gap: 2px; }
.field-label { font: 400 12px/16px var(--font-text); letter-spacing: var(--caps); text-transform: uppercase; color: var(--ink-muted); display: block; margin-bottom: 6px; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.section-title .pixel { color: var(--ink-muted); }
