/* ==========================================================================
   Plumb components. Form values come from tokens.css only.
   ========================================================================== */

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  --_h: var(--h-ctl);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--_h); padding: 0 var(--s-4);
  font-size: var(--t-14); font-weight: 500; font-variation-settings: "wdth" var(--wdth-label);
  line-height: 1; white-space: nowrap; text-decoration: none;
  color: var(--ink); background: var(--bg);
  border: var(--bw-strong) solid var(--line-strong); border-radius: var(--r-ctl);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.ink { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ink:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger-ink); border-color: var(--danger); background: var(--bg); }
.btn.sm { --_h: var(--h-ctl-sm); padding: 0 var(--s-3); font-size: var(--t-13); }
.btn.touch { --_h: var(--h-touch); font-size: var(--t-16); padding: 0 var(--s-5); }
.btn.block { display: flex; width: 100%; }
.btn.icon { padding: 0; width: var(--_h); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn.is-loading { pointer-events: none; color: transparent; position: relative; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent;
  animation: spin .7s linear infinite;
}
.btn.primary.is-loading::after { border-color: var(--on-primary) transparent var(--on-primary) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Fields ------------------------------------------------------------- */
.field { display: grid; gap: var(--s-1); }
.field > label, .field > .label { font-size: var(--t-13); font-weight: 500; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: var(--h-ctl); padding: 0 var(--s-3);
  background: var(--bg); color: var(--ink);
  border: var(--bw) solid var(--line-strong); border-radius: var(--r-ctl);
  font-size: var(--t-15);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.textarea { padding: var(--s-2) var(--s-3); min-height: 88px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: var(--s-6);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.field.is-error .input, .field.is-error .select, .field.is-error .textarea { border-color: var(--danger); }
.field-msg { font-size: var(--t-12); color: var(--muted); }
.field.is-error .field-msg { color: var(--danger-ink); }
.touch-fields .input, .touch-fields .select { min-height: var(--h-touch); font-size: var(--t-16); }

.search { position: relative; }
.search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; }

/* Checkbox, radio */
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-14); min-height: 28px; }
.check input { appearance: none; width: 18px; height: 18px; margin: 0; flex: none;
  border: var(--bw-strong) solid var(--line-strong); border-radius: 3px; background: var(--bg); display: grid; place-content: center; }
.check input[type=radio] { border-radius: 50%; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ''; width: 9px; height: 5px; border: 1.5px solid var(--bg); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px,-1px); }
.check input[type=radio]:checked::after { width: 6px; height: 6px; border: 0; border-radius: 50%; background: var(--bg); transform: none; }

/* Toggle */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); font-size: var(--t-14); }
.switch input { appearance: none; margin: 0; width: 40px; height: 24px; border-radius: 12px; flex: none;
  background: var(--surface-3); position: relative; transition: background var(--dur-2) var(--ease); }
.switch input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 1px 2px oklch(0.2 0.01 358 / .25); transition: transform var(--dur-2) var(--ease-out); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(16px); }

/* Segmented */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border-radius: var(--r-card); }
.seg button { border: 0; background: transparent; min-height: calc(var(--h-ctl) - 4px); padding: 0 var(--s-3);
  border-radius: var(--r-ctl); font-size: var(--t-13); font-weight: 500; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.seg.touch button { min-height: 44px; font-size: var(--t-14); flex: 1; justify-content: center; }
.seg.touch { display: flex; }

/* ---- Surfaces ------------------------------------------------------------ */
.face { background: var(--bg); border: var(--rule); border-radius: var(--r-card); box-shadow: var(--elev-card); }
.face.pad { padding: var(--pad-card); }
.face-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--pad-card); border-bottom: var(--rule); min-height: 48px; }
.face-head h2, .face-head h3 { font-size: var(--t-15); }
.hr { height: 0; border: 0; border-top: var(--rule); margin: var(--s-4) 0; }

/* Readout: a labelled instrument value */
.readout { display: grid; gap: 2px; }
.readout .v { font-family: var(--font-display); font-variation-settings: "wdth" var(--wdth-display);
  font-size: var(--t-28); font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.readout .d { font-size: var(--t-12); color: var(--muted); }
.readout .d .up { color: var(--danger-ink); } .readout .d .down { color: var(--success-ink); }

/* Tick ruler: the one ornament. --p = 0..1 filled */
.ruler { --p: .4; position: relative; height: 18px;
  background-image: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 8px);
  background-size: 100% 8px; background-repeat: no-repeat; background-position: 0 100%; }
.ruler::after { content: ''; position: absolute; left: 0; bottom: 0; height: 8px; width: calc(var(--p) * 100%);
  background-image: repeating-linear-gradient(90deg, var(--primary) 0 1px, transparent 1px 8px);
  transition: width var(--dur-3) var(--ease-out); }
.ruler.major { height: 22px; background-image: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 8px),
  repeating-linear-gradient(90deg, var(--ink-2) 0 1px, transparent 1px 40px); background-size: 100% 8px, 100% 14px; }

/* ---- Pills: status, priority, trade ------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  font-size: var(--t-12); font-weight: 500; line-height: 1; white-space: nowrap;
  border-radius: var(--r-ctl); border: var(--bw) solid var(--line); color: var(--ink-2); background: var(--bg); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.open     { color: var(--ink); border-color: var(--line-strong); }
.pill.assigned { color: var(--info-ink); background: var(--info-soft); border-color: transparent; }
.pill.fixed    { color: var(--warning-ink); background: var(--warning-soft); border-color: transparent; }
.pill.verified, .pill.released, .pill.synced { color: var(--success-ink); background: var(--success-soft); border-color: transparent; }
.pill.closed   { color: var(--muted); background: var(--surface-2); border-color: transparent; }
.pill.disputed, .pill.failed { color: var(--danger-ink); background: var(--danger-soft); border-color: transparent; }
.pill.draft    { color: var(--ink-2); background: var(--surface-2); border-color: transparent; }
.pill.review   { color: var(--info-ink); background: var(--info-soft); border-color: transparent; }
.pill.pending  { color: var(--warning-ink); background: var(--warning-soft); border-color: transparent; }

/* Priority: shape + word, ink only. Critical is the one inverted chip. */
.prio { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px 0 6px;
  font-size: var(--t-12); font-weight: 500; border-radius: var(--r-ctl); border: var(--bw) solid var(--line-strong); color: var(--ink); background: var(--bg); white-space: nowrap; }
.prio svg { width: 10px; height: 10px; }
.prio.critical { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.prio.low { color: var(--muted); border-color: var(--line); }

.trade { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; font-size: var(--t-12);
  color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-ctl); white-space: nowrap; }
.ref { font-family: var(--font-mono); font-size: var(--t-12); color: var(--muted); letter-spacing: var(--tracking-mono); font-variant-numeric: tabular-nums; }

.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: var(--t-12); font-weight: 600; background: var(--surface-3); color: var(--ink); object-fit: cover; }
.avatar.lg { width: 48px; height: 48px; font-size: var(--t-15); }

/* ---- Tables --------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; }
.tbl { font-size: var(--t-14); }
.tbl th { text-align: left; font-size: var(--t-12); font-weight: 500; color: var(--muted);
  height: 34px; padding: 0 var(--s-3); border-bottom: var(--rule); white-space: nowrap; font-variation-settings: "wdth" var(--wdth-label); }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.tbl th[aria-sort] { color: var(--ink); }
.tbl td { height: var(--h-row); padding: 6px var(--s-3); border-bottom: var(--row-rule); vertical-align: middle; }
.tbl tbody tr { transition: background var(--dur-1) var(--ease); }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr[aria-selected="true"] { background: var(--primary-soft); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr[data-href] { cursor: pointer; }
.bulkbar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  background: var(--ink); color: var(--bg); border-radius: var(--r-card); font-size: var(--t-14); }
.bulkbar .btn { background: transparent; color: var(--bg); border-color: var(--ink-2); }

/* Row list (phone + panels) */
.rows > * { border-bottom: var(--rule); }
.rows > *:last-child { border-bottom: 0; }

/* ---- Tabs, accordion ------------------------------------------------------ */
.tabs { display: flex; gap: var(--s-5); border-bottom: var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { all: unset; cursor: pointer; padding: var(--s-3) 0; font-size: var(--t-14); font-weight: 500;
  color: var(--muted); position: relative; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); }
.tabs [aria-selected="true"]::after, .tabs [aria-current="page"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.acc { border-top: var(--rule); }
.acc summary { list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 48px; font-weight: 500; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary .ico { transition: transform var(--dur-2) var(--ease-out); }
.acc[open] summary .ico { transform: rotate(180deg); }
.acc > div { padding-bottom: var(--s-4); color: var(--ink-2); font-size: var(--t-14); }

/* ---- Layers: modal, drawer, tooltip, popover ----------------------------- */
.layer-scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.2 0.01 358 / .38);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease); }
.modal { position: fixed; z-index: calc(var(--z-layer) + 1); left: 50%; top: 50%; width: min(92vw, 520px);
  max-height: 86vh; overflow: auto; background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--elev-modal);
  transform: translate(-50%, -46%); opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--ease-out); }
.drawer { position: fixed; z-index: calc(var(--z-layer) + 1); top: 0; right: 0; bottom: 0; width: min(94vw, 460px);
  background: var(--bg); box-shadow: var(--elev-modal); overflow: auto;
  transform: translateX(102%); transition: transform var(--dur-3) var(--ease-out); }
.is-open > .layer-scrim, .layer-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal.is-open { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.drawer.is-open { transform: none; }
.layer-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: var(--rule); }
.layer-head h2 { font-size: var(--t-18); }
.layer-body { padding: var(--s-5); }
.layer-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: var(--rule); }

.tip { position: relative; }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translate(-50%, 4px);
  padding: 5px 8px; border-radius: var(--r-ctl); background: var(--ink); color: var(--bg); font-size: var(--t-12);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-1), transform var(--dur-2) var(--ease-out); z-index: var(--z-sticky); }
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.popover { position: absolute; z-index: var(--z-layer); min-width: 200px; padding: var(--s-2);
  background: var(--bg); border-radius: var(--r-card); box-shadow: var(--elev-pop); }
.popover button, .popover a { display: flex; width: 100%; align-items: center; gap: var(--s-2); min-height: 36px; padding: 0 var(--s-2);
  border: 0; background: none; border-radius: var(--r-ctl); font-size: var(--t-14); text-align: left; text-decoration: none; }
.popover button:hover, .popover a:hover { background: var(--surface-2); }

/* ---- Feedback ---------------------------------------------------------- */
.banner { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-card); font-size: var(--t-14); background: var(--surface-2); color: var(--ink); }
.banner.info { background: var(--info-soft); color: var(--info-ink); }
.banner.warn { background: var(--warning-soft); color: var(--warning-ink); }
.banner.err { background: var(--danger-soft); color: var(--danger-ink); }
.banner.ok { background: var(--success-soft); color: var(--success-ink); }
.banner strong { display: block; color: inherit; }

.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-7) var(--s-5); }
.empty .mark { width: 56px; height: 56px; display: grid; place-items: center; color: var(--primary); position: relative; }
.empty .mark::before, .empty .mark::after { content: ''; position: absolute; inset: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  clip-path: polygon(0 0, 30% 0, 30% 30%, 0 30%, 0 70%, 30% 70%, 30% 100%, 0 100%, 0 0, 100% 0, 100% 30%, 70% 30%, 70% 0, 100% 0, 100% 100%, 70% 100%, 70% 70%, 100% 70%); }
.empty h3 { font-size: var(--t-18); }
.empty p { color: var(--muted); font-size: var(--t-14); max-width: 36ch; }

.skel { background: var(--surface-2); border-radius: var(--r-ctl); position: relative; overflow: hidden; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, oklch(1 0 0 / .6), transparent); animation: skel 1.3s var(--ease) infinite; }
@keyframes skel { to { transform: translateX(100%); } }

/* ---- Domain: spirit-level sync indicator ---------------------------------- */
.level { display: inline-flex; align-items: center; gap: var(--s-2); height: 28px; padding: 0 10px 0 6px;
  border-radius: var(--r-full); background: var(--surface-2); font-size: var(--t-12); font-weight: 500; color: var(--ink-2); }
.level .vial { position: relative; width: 34px; height: 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line-strong); overflow: hidden; }
.level .vial::before, .level .vial::after { content: ''; position: absolute; top: 1px; bottom: 1px; width: 1px; background: var(--line-strong); }
.level .vial::before { left: 11px; } .level .vial::after { right: 11px; }
.level .bubble { position: absolute; top: 2px; left: 12px; width: 8px; height: 6px; border-radius: 3px; background: var(--success);
  transition: transform var(--dur-4) var(--ease-out), background var(--dur-2); }
.level.off .bubble { transform: translateX(-10px); background: var(--warning); }
.level.busy .bubble { animation: bubble 1.2s var(--ease) infinite alternate; background: var(--info); }
.level.fail .bubble { transform: translateX(10px); background: var(--danger); }
@keyframes bubble { from { transform: translateX(-8px); } to { transform: translateX(8px); } }

/* ---- Domain: reticle + laser (capture signature) ------------------------ */
.reticle { position: absolute; pointer-events: none; width: 120px; height: 120px; }
.reticle i { position: absolute; width: 22px; height: 22px; border: 0 solid var(--laser); }
.reticle i:nth-child(1) { left: 0; top: 0; border-width: 2px 0 0 2px; }
.reticle i:nth-child(2) { right: 0; top: 0; border-width: 2px 2px 0 0; }
.reticle i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 2px 2px; }
.reticle i:nth-child(4) { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.reticle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--laser); }
.reticle.lock { animation: lock var(--dur-3) var(--ease-out) both; }
@keyframes lock { from { transform: scale(1.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.laser { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--laser); pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 1px oklch(0.66 0.26 358 / .25); }
.laser.go { animation: laser .9s var(--ease) both; }
@keyframes laser { 0% { transform: translateY(0); opacity: 0; } 10%, 85% { opacity: 1; } 100% { transform: translateY(var(--laser-h, 300px)); opacity: 0; } }

/* ---- Domain: plan with pins ---------------------------------------------- */
.plan { position: relative; background: var(--bg); border: var(--rule); border-radius: var(--r-card); overflow: hidden; aspect-ratio: 4 / 3; }
.plan svg.plan-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  background: var(--ink); color: var(--bg); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }
.pin.new { background: var(--primary); box-shadow: 0 0 0 1px var(--primary); animation: pin-in var(--dur-3) var(--ease-out) both; }
.pin.done { background: var(--bg); color: var(--muted); box-shadow: 0 0 0 1px var(--line-strong); }
@keyframes pin-in { from { transform: translate(-50%, -150%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.heat { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); background: var(--primary); mix-blend-mode: multiply; }

/* ---- Domain: snag row ------------------------------------------------------ */
.snag { display: grid; grid-template-columns: 64px 1fr auto; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; text-decoration: none; color: inherit; }
.snag .thumb { width: 64px; height: 64px; border-radius: var(--r-ctl); object-fit: cover; background: var(--surface-2); }
.snag h3 { font-family: var(--font-body); font-variation-settings: "wdth" var(--wdth-body); font-size: var(--t-15); font-weight: 600; letter-spacing: 0; line-height: 1.3; }
.snag .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.snag.enter { animation: snag-in var(--dur-3) var(--ease-out) both; }
@keyframes snag-in { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Domain: A4 report page ------------------------------------------------- */
.a4 { width: 794px; min-height: 1123px; background: var(--bg); color: var(--ink); padding: 56px 60px;
  box-shadow: 0 1px 0 var(--line), 0 20px 50px -30px oklch(0.2 0.01 358 / .35); margin-inline: auto; position: relative; }
.a4 .brandbar { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.a4 .ph { break-inside: avoid; }
.drop { animation: drop var(--dur-3) var(--ease-out) both; }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- FAB (camera) ---------------------------------------------------------- */
.fab { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; border: 0;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line);
  transition: transform var(--dur-1) var(--ease); }
.fab:active { transform: scale(.94); }

/* ==========================================================================
   Prototype chrome: phone, sheet, push, pocbar, toaster, tour.
   ========================================================================== */
.phone-stage {
  --phone-fit: 1;
  height: 100dvh; overflow: hidden;
  display: grid; grid-template-columns: auto; place-content: center; place-items: center;
  column-gap: var(--s-10);
  padding: var(--s-4) var(--gutter) calc(var(--pocbar-h) + var(--s-4));
  background: var(--ground);
}
.phone {
  position: relative; flex: none; width: 390px; height: 844px;
  transform: scale(var(--phone-fit)); transform-origin: center;
  display: flex; flex-direction: column; background: var(--bg); color: var(--ink);
  border: 9px solid var(--drench); border-radius: 50px;
  box-shadow: 0 0 0 1px var(--drench-line), 0 50px 90px -40px oklch(0.2 0.01 358 / .5);
  overflow: hidden; overflow: clip;
}
.phone::before { content: ''; position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  width: 118px; height: 33px; background: var(--drench); border-radius: 20px; z-index: 5; }
.phone-status { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 12px 30px 0;
  font-size: var(--t-14); font-weight: 600; flex: none; font-variant-numeric: tabular-nums; }
.phone-status .sig { display: flex; gap: 5px; align-items: center; }
.phone-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: none; position: relative; display: flex; flex-direction: column; }
.phone-scroll::-webkit-scrollbar { display: none; }
.phone-scroll > * { flex-shrink: 0; }
.phone-tabbar { display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: center;
  height: 86px; padding: 6px 8px 26px; flex: none; border-top: var(--rule); background: var(--bg); position: relative; }
.phone-tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; color: var(--muted); min-height: 44px; text-decoration: none; }
.phone-tabbar a[aria-current="page"] { color: var(--ink); }
.phone-tabbar a[aria-current="page"]::before { content: ''; position: absolute; top: -7px; width: 18px; height: 2px; background: var(--primary); }
.phone-tabbar .fab { justify-self: center; margin-top: -30px; }
.phone-tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--primary); color: var(--on-primary); font-size: 10px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.phone-home { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: 134px; height: 5px; border-radius: 3px; background: var(--ink); z-index: 4; }
.phone { --app-gutter: 20px; }
.app-pad { padding-inline: var(--app-gutter); }

.phone-caption { display: none; align-self: center; max-width: 34ch; font-size: var(--t-14); line-height: 1.55; color: var(--ink-2); }
.phone-caption strong { display: block; color: var(--ink); font-family: var(--font-display); font-variation-settings: "wdth" var(--wdth-display);
  font-size: var(--t-18); font-weight: 600; margin-bottom: var(--s-2); }
.phone-caption .ref { display: block; margin-bottom: var(--s-2); }
@media (min-width: 1100px) { .phone-stage { grid-template-columns: auto minmax(260px, 34ch); } .phone-caption { display: block; } }
@media (max-height: 940px) { .phone-stage { --phone-fit: .95; } }
@media (max-height: 880px) { .phone-stage { --phone-fit: .9; } }
@media (max-height: 820px) { .phone-stage { --phone-fit: .84; } }
@media (max-height: 770px) { .phone-stage { --phone-fit: .78; } }
@media (max-height: 700px) { .phone-stage { --phone-fit: .72; } }
@media (max-height: 640px) { .phone-stage { --phone-fit: .66; } }
@media (max-width: 600px) {
  .phone-stage { --phone-fit: 1; padding: 0; height: 100dvh; grid-template-columns: 1fr; background: var(--bg); }
  .phone { width: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; transform: none; }
  .phone::before, .phone-status, .phone-home, .phone-caption { display: none; }
  body.has-pocbar .phone-stage, body.has-pocbar .phone { height: calc(100dvh - var(--pocbar-h)); }
  .phone-tabbar { padding-bottom: 8px; height: 68px; }
}

/* Bottom sheet */
.sheet-scrim { position: absolute; inset: 0; z-index: var(--z-layer); background: oklch(0.2 0.01 358 / .42);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: calc(var(--z-layer) + 1); max-height: 88%;
  display: flex; flex-direction: column; background: var(--bg); color: var(--ink); border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(102%); transition: transform var(--dur-3) var(--ease-out); }
.sheet::before { content: ''; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 10px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; padding: var(--s-3) var(--app-gutter) var(--s-6); }
.sheet.is-open { transform: none; }
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }

/* In-frame push */
.push { position: absolute; left: 10px; right: 10px; top: 56px; z-index: var(--z-toast); display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--elev-modal); font-size: var(--t-14);
  transform: translateY(-160%); transition: transform var(--dur-3) var(--ease-out); }
.push .ico { color: var(--primary); margin-top: 2px; }
.push.in { transform: none; }

/* Prototype bar */
.pocbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-pocbar); height: var(--pocbar-h);
  display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); font-size: var(--t-12);
  background: var(--drench); color: var(--on-drench); }
.pocbar .tagword { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--on-drench-muted); }
.pocbar .roles { display: flex; gap: 2px; }
.pocbar .roles a { padding: 5px 10px; border-radius: var(--r-ctl); color: var(--on-drench-muted); text-decoration: none; white-space: nowrap; }
.pocbar .roles a:hover { color: var(--on-drench); background: var(--drench-2); }
.pocbar .roles a[aria-current="true"] { background: var(--primary); color: var(--on-primary); }
.pocbar .mods { display: flex; gap: 4px; }
.pocbar .tag-module { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--drench-line);
  border-radius: var(--r-ctl); color: var(--on-drench-muted); text-decoration: none; }
.pocbar .spacer { flex: 1; }
.pocbar button.link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--on-drench-muted);
  font: inherit; padding: 4px 6px; white-space: nowrap; border-radius: var(--r-ctl); min-height: 32px; }
.pocbar button.link:hover { color: var(--on-drench); }
.pocbar button[aria-pressed="true"] { color: var(--on-drench); background: var(--drench-2); }
@media (max-width: 720px) {
  .pocbar .hide-sm { display: none; }
  .pocbar { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .pocbar::-webkit-scrollbar { display: none; }
  .pocbar > * { flex: none; }
  .pocbar .spacer { flex: 1 0 var(--s-4); }
}
@media (max-width: 420px) { .pocbar .tagword { display: none; } }
body.has-pocbar { padding-bottom: var(--pocbar-h); }
body.has-pocbar:has(.phone-stage) { padding-bottom: 0; }

body.show-sow [data-module] { outline: 1px dashed var(--primary); outline-offset: 2px; position: relative; }
body.show-sow [data-module]::after { content: attr(data-module); position: absolute; top: -8px; right: -6px; z-index: 2;
  font-family: var(--font-mono); font-size: 9px; line-height: 1; padding: 3px 5px; border-radius: var(--r-ctl); background: var(--primary); color: var(--on-primary); }

/* Toaster */
.toaster { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--pocbar-h) + var(--s-4));
  z-index: var(--z-toast); display: flex; flex-direction: column-reverse; align-items: center; gap: var(--s-2); pointer-events: none; }
body:not(.has-pocbar) .toaster { bottom: var(--s-4); }
.toast { display: flex; gap: var(--s-2); align-items: center; max-width: 46ch; padding: 10px var(--s-4); background: var(--drench); color: var(--on-drench);
  border-radius: var(--r-card); box-shadow: var(--elev-pop); font-size: var(--t-14); animation: toast-in var(--dur-3) var(--ease-out);
  transition: opacity var(--dur-2); }
.toast::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--on-drench-muted); flex: none; }
.toast.ok::before { background: var(--success); } .toast.warn::before { background: var(--warning); } .toast.err::before { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Tour */
.tour-hole { position: fixed; z-index: calc(var(--z-tour) + 1); border-radius: var(--r-card);
  box-shadow: 0 0 0 9999px oklch(0.2 0.01 358 / .6), 0 0 0 2px var(--primary); pointer-events: none;
  transition: all var(--dur-3) var(--ease-out); }
.tour-pop { position: fixed; z-index: calc(var(--z-tour) + 2); max-width: 34ch; padding: var(--s-4); background: var(--bg); color: var(--ink);
  border-radius: var(--r-lg); box-shadow: var(--elev-modal); }
.tour-pop .step { font-family: var(--font-mono); font-size: var(--t-11); color: var(--muted); }
.tour-pop h3 { font-size: var(--t-16); margin: var(--s-1) 0 var(--s-2); }
.tour-pop p { font-size: var(--t-14); line-height: 1.5; color: var(--ink-2); }
.tour-pop .row { justify-content: flex-end; margin-top: var(--s-4); gap: var(--s-2); }

.rv.pre { opacity: 0; transform: translateY(14px); }
.rv.in { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }

.skip-link { position: absolute; left: -9999px; top: 0; z-index: var(--z-tour); padding: var(--s-3) var(--s-4); background: var(--primary); color: var(--on-primary); }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
a.pin { text-decoration: none; }

/* ---- Report pages (A4) ---------------------------------------------------- */
.a4 { display: flex; flex-direction: column; gap: 20px; }
.a4 .brandbar { flex: none; }
.a4 .rb-name { font-family: var(--font-display); font-variation-settings: "wdth" 125; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.a4 .rb-name::before { content: ''; width: 10px; height: 14px; background: var(--primary); clip-path: polygon(50% 100%, 0 35%, 15% 0, 85% 0, 100% 35%); }
.a4 .rfoot { margin-top: auto; display: flex; justify-content: space-between; padding-top: 12px; border-top: var(--rule); font-size: 10px; color: var(--muted); }
.a4 .rh { font-size: 26px; }
.a4 .rlabel { font-size: 11px; font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.cover .cv-title { margin-top: 28px; }
.cover h2 { font-size: 64px; line-height: 1; letter-spacing: -0.02em; margin: 10px 0 8px; }
.cover .cv-sub { font-size: 18px; color: var(--ink-2); }
.cover .cv-img { width: 100%; height: 380px; object-fit: cover; border-radius: var(--r-ctl); }
.cover .cv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; border-top: 2px solid var(--ink); padding-top: 16px; }
.cover .cv-grid .v { font-size: 34px; }
.cover .cv-meta { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13px; }
.cover .cv-meta dt { color: var(--muted); }
.sum-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 36px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 28px; gap: 10px; align-items: center; margin-bottom: 8px; }
.bar-row .bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--ink); }
.rtbl td { height: 32px; font-size: 13px; }
.snag-cards { display: grid; gap: 18px; }
.rs { display: grid; grid-template-columns: 220px 1fr 130px; gap: 16px; padding-bottom: 18px; border-bottom: var(--rule); break-inside: avoid; }
.rs:has(.rs-ph + .rs-ph) { grid-template-columns: 170px 170px 1fr; }
.rs:has(.rs-ph + .rs-ph) .rs-pin { display: none; }
.rs-ph { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-ctl); overflow: hidden; background: var(--surface-2); }
.rs-ph img { width: 100%; height: 100%; object-fit: cover; }
.rs-ph svg.mk { position: absolute; inset: 0; width: 100%; height: 100%; }
.rs-ph .tagb { position: absolute; left: 6px; bottom: 6px; font-family: var(--font-mono); font-size: 9px; color: #fff; background: oklch(0.15 0.01 358 / .65); padding: 2px 5px; border-radius: 3px; }
.rs-body { display: grid; gap: 8px; align-content: start; min-width: 0; }
.rs-body h4 { font-family: var(--font-display); font-variation-settings: "wdth" 112; font-size: 17px; font-weight: 600; line-height: 1.2; }
.rs-body p { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.rs-pin { align-self: start; }
.rs-pin .pin { width: 12px; height: 12px; }
.sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 16px; }
.sign .sig { font-family: var(--font-display); font-variation-settings: "wdth" 125; font-size: 20px; border-bottom: 1px solid var(--ink); padding: 28px 0 6px; margin-bottom: 6px; }
.a4 .plan .pin { width: 18px; height: 18px; font-size: 9px; }

.a4 .rb-name.has-logo::before { display: none; }
.a4.nopins .rs-pin { display: none; }
.a4.nopins .rs { grid-template-columns: 220px 1fr; }
.a4.nots .ts { display: none; }

/* Key-value list */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px var(--s-3); font-size: var(--t-14); }
.kv dt { color: var(--muted); }
