/* ==========================================================================
   Rootwork components. Every radius, border, shadow and height is a token.
   ========================================================================== */
.ico { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons: pill actions ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--h-ctl); padding: 0 var(--s-5); border-radius: var(--r-full);
  border: var(--bw-strong) solid transparent; background: var(--surface-2); color: var(--ink);
  font: 700 var(--t-15)/1 var(--font-body); text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
  position: relative; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface); border-color: var(--root); }
.btn-quiet { background: transparent; padding-inline: var(--s-3); color: var(--primary); }
.btn-quiet:hover { background: var(--primary-soft); color: var(--primary-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger); color: var(--on-primary); }
.btn-sm { min-height: var(--h-ctl-sm); padding: 0 var(--s-4); font-size: var(--t-13); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h-ctl); padding: 0; }
.btn-icon.btn-sm { width: var(--h-ctl-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-primary) transparent var(--on-primary) transparent;
  animation: spin .8s linear infinite;
}
.btn-accent.is-loading::after, .btn-ghost.is-loading::after, .btn.is-loading:not(.btn-primary)::after { border-color: var(--primary) transparent var(--primary) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.field { display: grid; gap: var(--s-2); }
.field > label, .label { font-weight: 700; font-size: var(--t-14); color: var(--ink); }
.hint { font-size: var(--t-13); color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: var(--h-ctl); padding: 0 var(--s-4);
  background: var(--surface); border: var(--bw-strong) solid var(--line-strong); border-radius: var(--r-ctl);
  font-size: var(--t-16); color: var(--ink); transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.textarea { padding: var(--s-3) var(--s-4); min-height: 104px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: var(--s-7);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 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(--root); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select { border-color: var(--danger); }
.field .err { display: none; font-size: var(--t-13); color: var(--danger-ink); font-weight: 700; }
.field.has-error .err { display: block; }
.input-affix { position: relative; }
.input-affix .ico { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.input-affix .input { padding-left: 44px; }
.input-unit { display: flex; align-items: stretch; }
.input-unit .input { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
.input-unit span { display: grid; place-items: center; padding: 0 var(--s-4); border: var(--bw-strong) solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-ctl) var(--r-ctl) 0; background: var(--surface-2); color: var(--muted); font-weight: 700; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 20px; height: 20px; margin: 0; }
.check { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--t-15); cursor: pointer; min-height: 44px; padding-top: 12px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { width: 44px; height: 26px; border-radius: var(--r-full); background: var(--surface-3); border: var(--bw) solid var(--line-strong); position: relative; transition: background-color var(--dur-2) var(--ease); flex: none; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: var(--e-1); transition: transform var(--dur-2) var(--ease-out); }
.switch input:checked + i { background: var(--primary); border-color: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Segmented */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--r-full); }
.seg button { border: 0; background: transparent; min-height: calc(var(--h-ctl) - 10px); padding: 0 var(--s-4); border-radius: var(--r-full); font-weight: 700; font-size: var(--t-14); color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--e-1); }

/* Chips: filters, tags */
.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s-3);
  border-radius: var(--r-full); border: var(--bw) solid var(--line-strong); background: var(--surface);
  font-size: var(--t-14); font-weight: 700; color: var(--ink-2); white-space: nowrap;
}
button.chip:hover { border-color: var(--root); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .ico { width: 16px; height: 16px; }

/* Upload */
.drop { display: grid; place-items: center; gap: var(--s-2); padding: var(--s-5); text-align: center; border: var(--bw-strong) dashed var(--root-soft); border-radius: var(--r-card); background: var(--surface); color: var(--muted); font-size: var(--t-14); cursor: pointer; }
.drop:hover { border-color: var(--root); background: var(--primary-soft); }

/* ---------- Faces (cards) and lists ---------- */
.face { background: var(--surface); border-radius: var(--r-card); padding: var(--pad-card); box-shadow: var(--elev-card); border: var(--bw) solid var(--line); }
.face-flush { padding: 0; overflow: hidden; }
.face-tone { background: var(--surface-2); border-color: transparent; }
.face h3 { font-size: var(--t-18); margin-bottom: var(--s-2); }
a.face, [data-href].face { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur-2) var(--ease); cursor: pointer; }
a.face:hover, [data-href].face:hover { border-color: var(--root); }
.list > * + * { border-top: var(--row-rule); }
.li { display: flex; align-items: center; gap: var(--s-3); min-height: var(--h-row); padding: var(--s-3) var(--pad-card); color: inherit; text-decoration: none; }
a.li:hover, button.li:hover { background: var(--primary-soft); }
button.li { width: 100%; border: 0; background: none; text-align: left; font: inherit; }
.li .t { font-weight: 700; }
.li .s { font-size: var(--t-13); color: var(--muted); }
.li .end { margin-left: auto; text-align: right; flex: none; }
.sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: var(--s-6) 0 var(--s-3); }
.sec-title h2 { font-size: var(--t-18); margin: 0; }
.sec-title a, .sec-title button { font-size: var(--t-14); font-weight: 700; }

/* Avatar */
.av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft-2); color: var(--primary-strong); font: 700 var(--t-12)/1 var(--font-body); overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-sm { width: 26px; height: 26px; font-size: 10px; }
.av-lg { width: 56px; height: 56px; font-size: var(--t-16); }
.av-stack { display: flex; } .av-stack .av { border: 2px solid var(--surface); margin-left: -8px; } .av-stack .av:first-child { margin-left: 0; }

/* Status pills: one vocabulary for the whole product */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-full); font-size: var(--t-12); font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--success-soft); color: var(--success-ink); }
.pill.warn { background: var(--warning-soft); color: var(--warning-ink); }
.pill.bad { background: var(--danger-soft); color: var(--danger-ink); }
.pill.info { background: var(--info-soft); color: var(--info-ink); }
.pill.brand { background: var(--primary-soft); color: var(--primary); }
.pill.live { background: var(--accent); color: var(--on-accent); }
.pill.live::before { animation: beat 1.6s var(--ease) infinite; }
@keyframes beat { 50% { opacity: .35; } }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); background: var(--primary); color: var(--on-primary); font: 700 11px/18px var(--font-body); text-align: center; }

/* Tabs (inline) */
.tabs-i { display: flex; gap: var(--s-5); border-bottom: var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs-i button, .tabs-i a { background: none; border: 0; padding: var(--s-3) 0; min-height: 44px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs-i [aria-selected="true"], .tabs-i [aria-current="page"] { color: var(--ink); border-bottom-color: var(--primary); }

/* Accordion */
details.acc { border-top: var(--rule); }
details.acc:last-child { border-bottom: var(--rule); }
details.acc summary { list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: var(--h-row); font-weight: 700; cursor: pointer; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "+"; font: 400 22px/1 var(--font-display); color: var(--primary); transition: transform var(--dur-2) var(--ease); }
details.acc[open] summary::after { transform: rotate(45deg); }
details.acc > div { padding-bottom: var(--s-4); color: var(--ink-2); }

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 0; z-index: var(--z-layer);
  padding: 6px 10px; border-radius: var(--r-ctl); background: var(--drench); color: var(--on-drench); font: 400 var(--t-12)/1.3 var(--font-body); white-space: nowrap; pointer-events: none;
}

/* Table */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: var(--rule); border-radius: var(--r-card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-14); }
.tbl th { text-align: left; font-weight: 700; font-size: var(--t-12); color: var(--muted); padding: var(--s-3) var(--s-4); background: var(--surface-2); white-space: nowrap; }
.tbl th button { background: none; border: 0; font: inherit; color: inherit; padding: 0; display: inline-flex; gap: 4px; align-items: center; }
.tbl th[aria-sort] button { color: var(--ink); }
.tbl td { padding: 0 var(--s-4); height: var(--h-row); border-top: var(--row-rule); border-right: var(--cell-rule); vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--primary-soft); }
.tbl tr.sel td { background: var(--accent-soft); }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.bulk { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); background: var(--drench); color: var(--on-drench); border-radius: var(--r-card) var(--r-card) 0 0; font-size: var(--t-14); }
.bulk .btn { min-height: var(--h-ctl-sm); background: var(--drench-2); color: var(--on-drench); font-size: var(--t-13); }
.bulk .btn:hover { background: var(--accent); color: var(--on-accent); }

/* Stat: figure + label, no hero-metric template */
.stat { display: grid; gap: 2px; }
.stat b { font: 600 var(--t-28)/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: var(--t-13); color: var(--muted); }
.stat em { font-style: normal; font-size: var(--t-12); font-weight: 700; color: var(--success-ink); }
.stat em.down { color: var(--danger-ink); }
.bar-track { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width var(--dur-3) var(--ease-out); }

/* ---------- Layers ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.2 0.06 355 / .45); display: none; place-items: center; padding: var(--s-4); }
.modal-scrim.open { display: grid; animation: fade var(--dur-2) var(--ease); }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--elev-modal); padding: var(--s-5); animation: rise var(--dur-3) var(--ease-out); }
.drawer-scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.2 0.06 355 / .35); opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-layer) + 1); width: min(460px, 100%); background: var(--surface); box-shadow: var(--elev-modal); transform: translateX(100%); transition: transform var(--dur-3) var(--ease-out); display: flex; flex-direction: column; }
.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer-open .drawer { transform: none; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) var(--s-5); border-bottom: var(--rule); }
.drawer .body { padding: var(--s-5); overflow-y: auto; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- Feedback ---------- */
.banner { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-card); font-size: var(--t-14); background: var(--info-soft); color: var(--info-ink); }
.banner .ico { margin-top: 1px; }
.banner b { display: block; }
.banner.warn { background: var(--warning-soft); color: var(--warning-ink); }
.banner.bad { background: var(--danger-soft); color: var(--danger-ink); }
.banner.ok { background: var(--success-soft); color: var(--success-ink); }
.banner.offline { background: var(--drench); color: var(--on-drench); }
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-7) var(--s-5); color: var(--muted); }
.empty h3 { color: var(--ink); font-size: var(--t-18); margin: var(--s-2) 0 0; }
.empty p { max-width: 34ch; margin: 0 0 var(--s-3); font-size: var(--t-15); }
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-ctl); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   DOMAIN — the components that only this product has
   ========================================================================== */

/* Seed loader: replaces every spinner that is not inside a button. */
.seed { width: 56px; height: 56px; }
.seed path { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: grow-line 1.8s var(--ease-out) infinite; }
.seed path:nth-child(2) { animation-delay: .3s; } .seed path:nth-child(3) { animation-delay: .5s; }
.seed ellipse { fill: var(--root-soft); }
@keyframes grow-line { 0% { stroke-dashoffset: 60; } 55%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0; } }

/* Roots: an SVG layer drawn between [data-root] nodes by Components.roots(). */
.rooted { position: relative; }
.roots { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }
.roots path { fill: none; stroke: var(--root); stroke-width: 1.25; stroke-linecap: round; stroke-dasharray: var(--len, 400); stroke-dashoffset: var(--len, 400); }
.roots.on path { animation: draw var(--dur-grow) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 110ms); }
.roots path.hot { stroke: var(--accent-strong); stroke-width: 2; }
.rooted > :not(.roots) { position: relative; z-index: 1; min-width: 0; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Node: the root's end point, on every crop, request and person. */
.node { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--primary); background: var(--surface); flex: none; }
.node.fill { background: var(--primary); }
.node.want { border-style: dashed; border-color: var(--root); }
.node.live { border-color: var(--on-accent); background: var(--accent); }
.hit .node, .node.hit { animation: pulse .7s var(--ease-out); }
@keyframes pulse { from { box-shadow: 0 0 0 0 oklch(0.42 0.15 355 / .5); } to { box-shadow: 0 0 0 14px oklch(0.42 0.15 355 / 0); } }

/* Crop row: the unit of the garden. */
.crop { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); background: var(--surface); border: var(--rule); border-radius: var(--r-card); color: inherit; text-decoration: none; width: 100%; text-align: left; font: inherit; transition: border-color var(--dur-2) var(--ease); }
.crop:hover { border-color: var(--root); color: inherit; }
.crop .ph { width: 48px; height: 48px; border-radius: var(--r-ctl); object-fit: cover; flex: none; background: var(--surface-2); }
.crop .grow { min-width: 0; }
.crop .t { display: block; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crop .s { display: block; font-size: var(--t-13); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crop .end { margin-left: auto; text-align: right; flex: none; }
.crop .end b { display: block; font: 600 var(--t-16)/1.1 var(--font-display); color: var(--primary); font-variant-numeric: tabular-nums; }
.crop .end small { font-size: var(--t-12); color: var(--muted); }
.crops { display: grid; gap: var(--s-2); grid-template-columns: minmax(0, 1fr); }
.crop { position: relative; }
/* In a rooted list the node sits in a gutter so the roots stay visible. */
.rooted .crops { padding-left: 26px; }
.rooted .crop > .node { position: absolute; left: -26px; top: 50%; margin-top: -7px; }

/* Stage track: sown → sprouted → flowering → fruiting → harvest */
.stages { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.stages::before { content: ""; position: absolute; left: 10%; right: 10%; top: 9px; height: 2px; background: var(--line-strong); }
.stages .fillbar { position: absolute; left: 10%; top: 9px; height: 2px; background: var(--primary); width: var(--p, 0%); transition: width var(--dur-grow) var(--ease-out); }
.stages .st { display: grid; justify-items: center; gap: 6px; font-size: var(--t-11); line-height: 1.3; color: var(--muted); text-align: center; position: relative; min-width: 0; }
.stages .st .node { background: var(--surface); }
.stages .st.done .node { background: var(--primary); }
.stages .st.now .node { background: var(--accent); border-color: var(--on-accent); animation: pulse 1.8s var(--ease-out) infinite; }
.stages .st.done, .stages .st.now { color: var(--ink); font-weight: 700; }

/* Forecast: the "ours" bet — surplus predicted before it's picked */
.forecast { display: grid; grid-template-columns: auto 1fr; gap: var(--s-3) var(--s-4); align-items: center; padding: var(--s-4); border-radius: var(--r-card); background: var(--primary-soft); }
.forecast .fig { font-size: var(--t-28); color: var(--primary); line-height: 1; }
.forecast p { margin: 0; font-size: var(--t-14); color: var(--ink-2); }

/* Listing: surplus on the market */
.listing { display: grid; grid-template-columns: 88px 1fr; gap: var(--s-3); padding: var(--s-3); background: var(--surface); border: var(--rule); border-radius: var(--r-card); color: inherit; text-decoration: none; }
.listing:hover { border-color: var(--root); color: inherit; }
.listing img { width: 88px; height: 88px; object-fit: cover; border-radius: var(--r-ctl); background: var(--surface-2); }
.listing .t { font-weight: 700; }
.listing .meta { font-size: var(--t-13); color: var(--muted); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.listing .price { font: 600 var(--t-16)/1 var(--font-display); color: var(--primary); font-variant-numeric: tabular-nums; }
.mode { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: var(--r-full); font-size: var(--t-11); font-weight: 700; border: var(--bw) solid currentColor; }
.mode.gift { color: var(--success-ink); } .mode.swap { color: var(--info-ink); } .mode.sell { color: var(--primary); }

/* Want: a request, drawn as a dashed root end */
.want { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3); border: var(--bw) dashed var(--root); border-radius: var(--r-card); background: var(--surface); }
.want .t { font-weight: 700; }
.want .s { font-size: var(--t-13); color: var(--muted); }

/* Signal: how many neighbours want a crop vs how many grow it */
.signal { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s-3); align-items: center; }
.signal .name { font-weight: 700; }
.signal .n { font-size: var(--t-13); color: var(--muted); font-variant-numeric: tabular-nums; }
.signal .track { grid-column: 1 / -1; height: 10px; border-radius: var(--r-full); background: var(--surface-3); position: relative; overflow: hidden; }
.signal .track .d { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: inherit; width: var(--d); }
.signal .track .s { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--accent); border-radius: inherit; width: var(--s); }
.signal.gap .n { color: var(--primary); font-weight: 700; }

/* Match web: radial supply ↔ demand graph */
.matchweb { width: 100%; aspect-ratio: 1; max-width: 340px; margin: 0 auto; display: block; overflow: visible; }
.matchweb .edge { fill: none; stroke: var(--root); stroke-width: 1.4; stroke-dasharray: var(--len, 300); stroke-dashoffset: var(--len, 300); }
.matchweb.on .edge { animation: draw 1.2s var(--ease-out) forwards; animation-delay: calc(var(--i) * 160ms); }
.matchweb .edge.hot { stroke: var(--accent-strong); stroke-width: 2.4; }
.matchweb .hub { fill: var(--accent); }
.matchweb .peer { fill: var(--surface); stroke: var(--primary); stroke-width: 2; cursor: pointer; transition: fill var(--dur-2) var(--ease); }
.matchweb .peer.want { stroke-dasharray: 3 3; }
.matchweb .peer.picked { fill: var(--accent); stroke: var(--on-accent); }
.matchweb text { font: 700 13px var(--font-body); fill: var(--ink); }
.matchweb text.sub { font-weight: 400; fill: var(--muted); font-size: 11px; }
.matchweb .hub-t { font: 700 13px var(--font-display); fill: var(--on-accent); }

/* Sound toggle */
.snd-toggle[aria-pressed="false"] .on, .snd-toggle[aria-pressed="true"] .off { display: none; }

/* ==========================================================================
   Prototype chrome — device frames, prototype bar, toaster, tour.
   Structural, brand-neutral. Copy into <POC>/assets/css/components.css and
   re-skin with the project's tokens. Requires the token contract.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Phone. A fixed 390x844 canvas scaled to always fit the viewport, so the
   whole device is visible without scrolling the browser. On a real handset
   the frame disappears and the app fills the screen.
   -------------------------------------------------------------------------- */
.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(--surface-3);
}
.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: 10px solid oklch(0.18 0.04 355); border-radius: 46px;
  box-shadow: 0 40px 80px -20px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(0 0 0 / 0.08);
  overflow: hidden;
}
.phone::before {                      /* notch */
  content: ''; position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  width: 120px; height: 34px; background: oklch(0.18 0.04 355); border-radius: 20px; z-index: 5;
}
.phone-status {
  display: flex; align-items: center; justify-content: space-between;
  height: 54px; padding: 12px 28px 0; font-size: var(--t-14); font-weight: 600; flex: none;
}
.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; }   /* or horizontal card rows collapse */
.phone-tabbar {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: 84px; padding: 8px 8px 24px; flex: none;
  border-top: 1px solid var(--line); background: var(--surface);
}
.phone-tabbar a {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  border-radius: var(--r-ctl); min-height: 44px; text-decoration: none;
}
.phone-tabbar a .ico { width: 24px; height: 24px; }
.phone-tabbar a[aria-current="page"] { color: var(--primary); }
.phone-home {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 3px; background: var(--ink); opacity: .9; z-index: 4;
}
.phone { --app-gutter: var(--s-4); }

/* The narration column beside the device: what this screen proves. */
.phone-caption {
  display: none; align-self: center; max-width: 34ch; text-align: left;
  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-size: var(--t-18); font-weight: 600; margin-bottom: var(--s-2);
}
@media (min-width: 1100px) {
  .phone-stage { grid-template-columns: auto minmax(260px, 34ch); }
  .phone-caption { display: block; }
}

/* Step the scale down so the device always fits the window height. */
@media (max-height: 940px) { .phone-stage { --phone-fit: .95; } }
@media (max-height: 880px) { .phone-stage { --phone-fit: .90; } }
@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; } }

/* On an actual handset the app IS the page. The frame, notch, status bar and
   home indicator disappear; the app fills the screen minus the prototype bar. */
@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 { display: none; }
  .phone-caption { display: none; }
  /* The bar is fixed over the viewport, so the app must give up its height or
     the tab bar hides behind it. */
  body.has-pocbar .phone-stage,
  body.has-pocbar .phone { height: calc(100dvh - var(--pocbar-h)); }
  .phone-tabbar { padding-bottom: 8px; height: 64px; }
}

/* --------------------------------------------------------------------------
   Tablet — staff-facing landscape surfaces (kitchen display, POS, field app).
   -------------------------------------------------------------------------- */
.tablet-stage {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
  padding: var(--s-8) var(--gutter) calc(var(--pocbar-h) + var(--s-10));
  min-height: 100dvh; background: var(--surface-3);
}
.tablet {
  --tablet-fit: 1;
  position: relative; width: 1024px; height: 768px;
  transform: scale(var(--tablet-fit)); transform-origin: top center;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border: 12px solid oklch(0.18 0.04 355); border-radius: 28px;
  box-shadow: 0 40px 80px -24px rgb(0 0 0 / 0.35);
}
.tablet-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 1140px) { .tablet-stage { --tablet-fit: .82; } }
@media (max-width: 940px)  { .tablet-stage { --tablet-fit: .66; } }
@media (max-width: 760px)  { .tablet-stage { --tablet-fit: .50; } }

/* --------------------------------------------------------------------------
   Bottom sheet — the mobile-native alternative to a modal.
   -------------------------------------------------------------------------- */
.sheet-scrim {
  position: absolute; inset: 0; z-index: var(--z-layer);
  background: rgb(0 0 0 / 0.4); 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: 82%; display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(100%); 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-4) var(--app-gutter) var(--s-6); }
.layer-open .sheet-scrim { opacity: 1; pointer-events: auto; }
.layer-open .sheet { transform: translateY(0); }

/* In-frame push notification — lands every time in a demo. */
.push {
  position: absolute; left: 8px; right: 8px; top: 58px; z-index: var(--z-toast);
  display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--bg); border-radius: var(--r-card); box-shadow: var(--e-3);
  transform: translateY(-140%); transition: transform var(--dur-3) var(--ease-out);
}
.push.in { transform: translateY(0); }

/* --------------------------------------------------------------------------
   Prototype bar — the client's remote control, on every page.
   -------------------------------------------------------------------------- */
.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);
  box-shadow: 0 -4px 20px rgb(0 0 0 / 0.2);
}
.pocbar .tagword {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  color: var(--accent); font-weight: 500;
}
.pocbar .roles { display: flex; gap: 2px; }
.pocbar .roles a {
  padding: 4px 10px; border-radius: var(--r-full); 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-full);
  color: var(--on-drench-muted); text-decoration: none;
}
.pocbar .spacer { flex: 1; }
.pocbar button.link {
  background: none; border: 0; color: var(--on-drench-muted);
  font: inherit; cursor: pointer; padding: 4px 6px; white-space: nowrap;
}
.pocbar button.link:hover { color: var(--on-drench); }
body.has-pocbar { padding-bottom: 0; }
@media (max-width: 720px) {
  .pocbar .hide-sm { display: none; }
  /* Never let the bar clip its own controls: let it scroll instead. */
  .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; } }

/* Module map overlay: outlines the elements proving each module. */
body.show-sow [data-module] { outline: 1px dashed var(--accent-strong); 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-full);
  background: var(--accent); color: var(--on-accent);
}

/* --------------------------------------------------------------------------
   Toaster
   -------------------------------------------------------------------------- */
.toaster {
  position: fixed; right: var(--s-4); bottom: calc(var(--pocbar-h) + var(--s-4));
  z-index: var(--z-toast); display: flex; flex-direction: column-reverse;
  gap: var(--s-2); pointer-events: none;
}
body:not(.has-pocbar) .toaster { bottom: var(--s-4); }
.toast {
  max-width: 42ch; padding: var(--s-3) var(--s-4);
  background: var(--drench); color: var(--on-drench);
  border-radius: var(--r-ctl); box-shadow: var(--e-3);
  font-size: var(--t-14); animation: toast-in var(--dur-3) var(--ease-out);
}
.toast.ok { background: var(--success); } .toast.warn { background: var(--warning); color: var(--on-accent); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Guided tour
   -------------------------------------------------------------------------- */
.tour-scrim { position: fixed; inset: 0; z-index: var(--z-tour); background: rgb(0 0 0 / 0.55); }
.tour-hole { position: fixed; z-index: calc(var(--z-tour) + 1); border-radius: var(--r-card);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.55), 0 0 0 3px var(--accent); pointer-events: none; }
.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-card); box-shadow: var(--e-3);
}
.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 { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

/* Section reveal — set by prototype.js, off under reduced motion. */
.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); }

/* Accessibility floor */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  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; }
.empty .ico { width: 32px; height: 32px; color: var(--root); }
/* charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .cv { font: 700 10px var(--font-body); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
svg.chart .cl { font: 400 10px var(--font-body); fill: var(--muted); }
svg.chart .cb rect { transform-box: fill-box; transform-origin: bottom; animation: bar-up var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i) * 40ms); }
@keyframes bar-up { from { transform: scaleY(0); } }
.meta > span, .li .s { vertical-align: middle; }
