/* Components. Every colour, size, radius and shadow comes from css/tokens.css.
 * No hex colours and no px here (breakpoints are in em because media queries
 * can't read variables). */

/* (font not used in this app: left out of the build) */
@font-face { font-family: Figtree; src: url("../assets/fonts/Figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--root-size); }
@media (min-width: 120em) { html { font-size: var(--root-size-tv); } }
body { font-optical-sizing: auto; margin: 0; min-height: 100vh; background: var(--page-bg); background-attachment: fixed; color: var(--ink); font-family: var(--font-sans); font-size: var(--fs-small); line-height: var(--lh-small); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-w); }
[hidden] { display: none !important; }
.sr { position: absolute; width: var(--border-w); height: var(--border-w); overflow: hidden; clip-path: inset(50%); }

/* ---------- type ---------- */
.h2 { font-family: var(--font-display); font-size: var(--fs-sub-big); line-height: var(--lh-h2); font-weight: var(--fw-h2); letter-spacing: var(--ls-h2); }
.title { font-family: var(--font-display); font-size: var(--fs-page); line-height: var(--lh-h2); font-weight: var(--fw-h2); letter-spacing: var(--ls-h2); }
.h3 { font-family: var(--font-display); font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-h3); letter-spacing: var(--ls-h3); }
.kicker { font-size: var(--fs-kicker); line-height: var(--lh-kicker); font-weight: var(--fw-kicker); letter-spacing: var(--ls-kicker); color: var(--forest-text); }
.sub { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--ink-2); }
.fine { font-size: var(--fs-fine); line-height: var(--lh-fine); color: var(--ink-3); }
.strong { font-weight: var(--fw-kicker); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--size-control); padding: 0 var(--space-4); border: var(--border-w) solid var(--forest); border-radius: var(--radius-sm); background: var(--btn-bg); box-shadow: var(--btn-shadow); color: var(--on-primary); font-size: var(--fs-small); font-weight: var(--fw-button); line-height: var(--lh-button); white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--forest-dk); border-color: var(--forest-dk); }
.btn.ghost { box-shadow: none; background: var(--surface); color: var(--forest-text); border-color: var(--line); }
.btn.ghost:hover { background: var(--mint); border-color: var(--forest-text); }
.btn.quiet { box-shadow: none; background: transparent; color: var(--forest-text); border-color: transparent; padding: 0 var(--space-2); }
.btn.quiet:hover { background: var(--mint); }
.btn.sm { min-height: var(--size-control-sm); padding: 0 var(--space-3); font-size: var(--fs-kicker); }
.btn.wide { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ---------- fields ---------- */
.field { display: grid; gap: var(--space-1); }
.field > span, .label { font-size: var(--fs-kicker); font-weight: var(--fw-kicker); color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: var(--size-control); padding: var(--space-2) var(--space-3); border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.input:hover { border-color: var(--ink-3); }
textarea.input { resize: vertical; }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }
.form { display: grid; gap: var(--space-4); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.error { color: var(--bad); font-size: var(--fs-kicker); font-weight: var(--fw-medium); }
.choice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { background: var(--mint); border-color: var(--forest-text); }
.choice input { margin-top: var(--space-1); accent-color: var(--forest-text); }

/* combo (pick a patient from the list) */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin-top: var(--space-1); max-height: 15rem; overflow: auto; background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); padding: var(--space-1); }
.combo-opt { display: flex; justify-content: space-between; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; text-align: left; }
.combo-opt:hover, .combo-opt:focus-visible { background: var(--mint); }
.picked { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--mint); border: var(--border-w) solid var(--forest); border-radius: var(--radius-md); }

/* chips (filters) */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { min-height: var(--size-control-sm); padding: 0 var(--space-3); border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font-size: var(--fs-kicker); font-weight: var(--fw-medium); }
.chip:hover { border-color: var(--forest-text); }
.chip[aria-pressed="true"] { background: var(--forest); border-color: var(--forest-text); color: var(--on-primary); }
.chip .count { opacity: 0.75; margin-left: var(--space-1); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--size-sidebar) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-5) var(--space-4); background: var(--surface-2); border-right: var(--border-w) solid var(--line); overflow: auto; }
.side-logo { display: block; width: 100%; aspect-ratio: 600 / 153; background: var(--logo) left center / contain no-repeat; }
.nav { display: grid; gap: var(--space-1); }
.nav button { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--size-control); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); font-weight: var(--fw-medium); text-align: left; }
.nav button:hover { background: var(--band); }
.nav button[aria-current="page"] { background: var(--mint); color: var(--forest-text); font-weight: var(--fw-kicker); }
.nav .lbl { flex: 1; }
.ico { flex: none; width: var(--size-icon); height: var(--size-icon); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.badge { min-width: 1.5rem; padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--warn-bg); color: var(--warn); font-size: var(--fs-fine); font-weight: var(--fw-kicker); text-align: center; }
.side-foot { margin-top: auto; display: grid; gap: var(--space-4); }
.who { display: flex; align-items: center; gap: var(--space-3); }
.avatar { flex: none; display: grid; place-items: center; width: var(--size-avatar); height: var(--size-avatar); border-radius: var(--radius-md); background: var(--mint); color: var(--forest-text); font-weight: var(--fw-kicker); font-size: var(--fs-kicker); }
.built { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-4); border-top: var(--border-w) solid var(--line); text-decoration: none; }
.built .wm { display: block; height: 1.125rem; aspect-ratio: 312 / 78; background: var(--levoko-wordmark) left center / contain no-repeat; }

.main { display: flex; flex-direction: column; min-width: 0; }
.page { flex: 1; width: 100%; max-width: var(--size-content); margin: 0 auto; padding: var(--space-7) var(--space-7) var(--space-8); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-content: start; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.page-head > div { display: grid; gap: var(--space-2); max-width: 44rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.toolbar .grow { flex: 1; min-width: 12rem; }
.toolbar select.input, .toolbar .input { width: auto; }
.toolbar .grow .input { width: 100%; }

.demo-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-6); background: var(--band); border-top: var(--border-w) solid var(--line); font-size: var(--fs-fine); color: var(--ink-2); }
.demo-bar .spacer { flex: 1; }
.demo-bar .input { width: auto; min-height: var(--size-control-sm); padding: 0 var(--space-2); }
.demo-bar .set { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- surfaces ---------- */
.card { background: var(--card-bg); border: var(--border-w) solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); }
.card.pad { padding: var(--space-5); }
.stack { display: grid; gap: var(--space-4); align-content: start; }
.stack.tight { gap: var(--space-2); }
.stack.loose { gap: var(--space-6); }
.split { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.empty { padding: var(--space-7) var(--space-5); text-align: center; color: var(--ink-3); }

/* ---------- checklist card (a status row that opens into a checklist) ---------- */
.pcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.pcard { overflow: hidden; }
.pcard-head { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-4) var(--space-5); border: 0; background: none; text-align: left; }
.pcard-head:focus-visible, .todo:focus-visible { outline-offset: calc(var(--focus-w) * -1); }
.pcard-head:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.pcard-head .chev { flex: none; color: var(--ink-3); transition: transform 0.2s ease; }
.pcard[data-open="true"] .chev { transform: rotate(90deg); }
.pcard-head .ttl { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.pcard-head .grow { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.pcard-head .left { color: var(--ink-3); font-size: var(--fs-fine); white-space: nowrap; }
.stack-av { display: flex; }
.stack-av .avatar { width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); font-size: var(--fs-fine); margin-left: var(--space-1); }
.stack-av .avatar:first-child { margin-left: 0; }
.ring { flex: none; width: var(--size-ring); height: var(--size-ring); transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; stroke: var(--line); }
.ring .arc { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset 0.35s ease; }
.ring.amber .arc { stroke: var(--warn); }
.pcard-body { border-top: var(--border-w) solid var(--line); padding: var(--space-2) var(--space-3) var(--space-3); display: grid; }
.todo { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; text-align: left; }
button.todo:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.todo .box { flex: none; display: grid; place-items: center; width: var(--size-check); height: var(--size-check); border-radius: var(--radius-pill); border: var(--border-w) solid var(--ink-3); color: transparent; transition: background 0.15s ease, border-color 0.15s ease; }
.todo .box .ico { width: 0.875rem; height: 0.875rem; stroke-width: 3; }
.todo[aria-checked="true"] .box { background: var(--ok); border-color: var(--ok); color: var(--paper); }
.todo .txt { flex: 1; }
.todo[aria-checked="true"] .txt { color: var(--ink-3); text-decoration: line-through; }
.todo .meta { color: var(--ink-3); font-size: var(--fs-fine); white-space: nowrap; }
.todo .dot { flex: none; width: 0.625rem; height: 0.625rem; margin: 0 0.5rem; border-radius: var(--radius-pill); background: var(--warn); box-shadow: 0 0 0 var(--focus-w) var(--warn-bg); }
.todo .dot.bad { background: var(--bad); box-shadow: 0 0 0 var(--focus-w) var(--bad-bg); }
.glance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.glance button { display: grid; gap: var(--space-1); padding: var(--space-4) var(--space-5); text-align: left; color: inherit; }
.glance button:hover { border-color: var(--forest-text); }
.glance b { font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-stat); font-weight: var(--fw-stat); letter-spacing: var(--ls-stat); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: var(--space-3) var(--space-4); text-align: left; font-size: var(--fs-fine); font-weight: var(--fw-kicker); color: var(--ink-3); border-bottom: var(--border-w) solid var(--line); white-space: nowrap; }
td { padding: var(--space-3) var(--space-4); border-bottom: var(--border-w) solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.right, td.right { text-align: right; }
td .fine { display: block; }
td .fine.inline { display: inline; }
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

.tag { display: inline-block; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); font-size: var(--fs-fine); font-weight: var(--fw-kicker); white-space: nowrap; background: var(--band); color: var(--ink-2); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag[style] { background: color-mix(in srgb, var(--c) 24%, transparent); color: var(--ink); }
.tag.info { background: var(--mint); color: var(--forest-text); }
.up { color: var(--bad); } .down { color: var(--ok); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }
.tile { padding: var(--space-4); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.tile b { display: block; font-family: var(--font-display); font-size: var(--fs-sub-big); line-height: var(--lh-stat); letter-spacing: var(--ls-stat); }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: var(--space-7) var(--space-4); }
.signin-box { min-width: 0; width: 100%; max-width: 46rem; display: grid; gap: var(--space-6); }
.signin-logo { width: min(20rem, 80%); aspect-ratio: 600 / 153; background: var(--logo) left center / contain no-repeat; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.person { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-lg); text-align: left; }
.person:hover { border-color: var(--forest-text); background: var(--mint); }
.person .go { margin-left: auto; color: var(--forest-text); font-weight: var(--fw-kicker); }
.signin .built { border-top: 0; padding-top: 0; }

/* ---------- treatment plans ---------- */
.tabs { display: flex; gap: var(--space-5); border-bottom: var(--border-w) solid var(--line); }
.tabs button { padding: var(--space-3) 0; border: 0; border-bottom: var(--focus-w) solid transparent; background: none; color: var(--ink-3); font-weight: var(--fw-kicker); }
.tabs button[aria-selected="true"] { color: var(--forest-text); border-bottom-color: var(--forest-text); }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--space-6); align-items: start; }
.step { display: flex; align-items: baseline; gap: var(--space-3); }
.step i { flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); background: var(--forest); color: var(--on-primary); font-style: normal; font-weight: var(--fw-kicker); font-size: var(--fs-fine); }
.shop { position: relative; }
.shop .ico { position: absolute; left: var(--space-4); top: 50%; transform: translateY(-50%); width: 1.25rem; height: 1.25rem; color: var(--ink-3); pointer-events: none; }
.input.shop-q { height: 3.5rem; padding-left: calc(var(--space-4) * 2 + 1.25rem); font-size: var(--fs-sub); }
.codes { max-height: 26rem; overflow: auto; }
.code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-4); width: 100%; padding: var(--space-3) var(--space-4); border: 0; border-bottom: var(--border-w) solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.code-row:last-child { border-bottom: 0; }
.code-row:hover, .code-row:focus-visible, .code-row.top { background: var(--mint); }
.code-row .what { display: grid; gap: 0.125rem; min-width: 0; }
.code-row .in { color: var(--forest-text); font-weight: var(--fw-kicker); }
.code-row .price { font-variant-numeric: tabular-nums; font-weight: var(--fw-kicker); font-size: var(--fs-body); }
.code-row .add { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--radius-pill); background: var(--btn-bg); color: var(--on-primary); font-size: 1.25rem; line-height: 1; }
.adjs { display: grid; gap: var(--space-2); }
.adj { display: grid; grid-template-columns: minmax(0, 1fr) 9.5rem; align-items: center; gap: var(--space-3); }
.adj-l { display: grid; gap: 0.0625rem; }
.adj .input { text-align: right; }
.adj-why .input { width: 100%; }
.plan { position: sticky; top: var(--space-5); }
.plan-item { display: grid; grid-template-columns: 5rem auto minmax(0, 1fr) auto; grid-template-areas: "what what price x" "tooth step . ."; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; border-bottom: var(--border-w) solid var(--line); }
.plan-item .what { grid-area: what; display: grid; gap: 0.0625rem; min-width: 0; }
.plan-item .num { grid-area: price; text-align: right; }
.plan-item .x { grid-area: x; }
.plan-item .stepper { grid-area: step; }
.plan-item .tooth { grid-area: tooth; min-width: 0; height: var(--size-control-sm); text-align: center; padding-left: var(--space-2); padding-right: var(--space-2); }
details.fold > summary { cursor: pointer; padding: var(--space-2) 0; }
details.fold > summary::marker { color: var(--forest-text); }
details.fold[open] > .card, details.fold[open] > .fine { margin-top: var(--space-2); }
details.dates summary { cursor: pointer; color: var(--forest-text); font-size: var(--fs-small); padding: var(--space-1) 0; }
details.dates .schedule { margin-top: var(--space-2); }
.stepper { display: inline-flex; align-items: center; border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.stepper button { width: var(--size-control-sm); height: var(--size-control-sm); border: 0; background: none; color: var(--forest-text); font-weight: var(--fw-kicker); }
.stepper button:hover { background: var(--mint); }
.stepper span { min-width: 2rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.x { width: var(--size-control-sm); height: var(--size-control-sm); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-3); }
.x:hover { background: var(--bad-bg); color: var(--bad); }
.sum { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-2) 0; }
.sum.big { font-family: var(--font-display); font-size: var(--fs-sub-big); line-height: var(--lh-stat); letter-spacing: var(--ls-stat); padding: var(--space-3) 0; }
.sum.total { border-top: var(--border-w) solid var(--ink); font-weight: var(--fw-kicker); }
.rule { border: 0; border-top: var(--border-w) solid var(--line); margin: 0; }
.schedule { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); max-height: 15rem; overflow: auto; }
.schedule div { display: flex; justify-content: space-between; padding: var(--space-2) var(--space-4); border-bottom: var(--border-w) solid var(--line); }
.schedule div:last-child { border-bottom: 0; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: var(--size-chat); overflow: hidden; }
.channels { padding: var(--space-3); border-right: var(--border-w) solid var(--line); display: grid; gap: var(--space-1); align-content: start; }
.channels button.ch { display: grid; width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; text-align: left; }
.channels button.ch:hover { background: var(--band); }
.channels button.ch[aria-current="true"] { background: var(--mint); }
.channels button.ch b { color: var(--ink); }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { padding: var(--space-4) var(--space-5); border-bottom: var(--border-w) solid var(--line); }
.msgs { flex: 1; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); max-height: 60vh; overflow: auto; }
.msgs > :first-child { margin-top: auto; }
.day { text-align: center; font-size: var(--fs-fine); font-weight: var(--fw-kicker); color: var(--ink-3); }
/* messages: yours on the right, everyone else's on the left */
.msg { display: flex; align-items: flex-end; gap: var(--space-2); }
.msg .mb { display: grid; gap: 0.1875rem; justify-items: start; max-width: min(34rem, 78%); }
.msg .who { padding: 0 var(--space-3); }
.msg .bubble { padding: var(--space-2) var(--space-4); border-radius: var(--radius-xl); border-bottom-left-radius: var(--radius-sm); background: var(--bubble); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .avatar { width: 2rem; height: 2rem; border-radius: var(--radius-pill); font-size: var(--fs-fine); }
.msg.cont { margin-top: calc(var(--space-3) * -1); }
.msg.cont .avatar { visibility: hidden; }
.msg.me { flex-direction: row-reverse; }
.msg.me .mb { justify-items: end; }
.msg.me .bubble { background: var(--btn-bg); color: var(--on-primary); border-radius: var(--radius-xl); border-bottom-right-radius: var(--radius-sm); }
.compose { display: flex; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-top: var(--border-w) solid var(--line); }

/* tags inside messages, and the list you pick them from */
.mention { display: inline-flex; align-items: center; gap: 0.25rem; margin: 0 0.0625rem; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--forest-text) 22%, transparent); color: var(--forest-text); font-weight: var(--fw-medium); vertical-align: baseline; text-align: left; }
.mention:hover { background: color-mix(in srgb, var(--forest-text) 34%, transparent); }
.mention .ico { width: 0.875rem; height: 0.875rem; }
.mention.you { background: var(--warn-bg); color: var(--warn); }
.msg.me .mention { background: color-mix(in srgb, white 24%, transparent); color: var(--on-primary); }
.compose { position: relative; align-items: center; }
.compose .input { flex: 1; }
.compose .round { flex: none; font-weight: var(--fw-kicker); color: var(--forest-text); }
.tag-pop { position: absolute; z-index: 6; left: var(--space-5); right: var(--space-5); bottom: 100%; margin-bottom: var(--space-2); max-height: 20rem; overflow: auto; padding: var(--space-2); display: grid; gap: 0.125rem; }
.tag-head { padding: var(--space-1) var(--space-3); }
.tag-opt { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); text-align: left; }
.tag-opt .grow { display: grid; }
.tag-opt .ico { color: var(--ink-3); }
.tag-opt:hover, .tag-opt[aria-selected="true"] { background: var(--mint); }
.channels .badge { margin-left: var(--space-1); }

/* ---------- procedures: folders ---------- */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--size-folder), 1fr)); gap: var(--space-3); }
.folder-card { display: grid; gap: var(--space-1); justify-items: center; padding: var(--space-4) var(--space-4) var(--space-5); border: var(--border-w) solid transparent; border-radius: var(--radius-xl); background: none; text-align: center; }
.folder-card:hover { background: var(--surface); }
.folder-card[aria-pressed="true"] { background: var(--surface); border-color: var(--line); }
.folder-card .nm { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); }
.folder { --c: var(--folder-a); display: block; position: relative; width: 100%; max-width: 12rem; aspect-ratio: 4 / 3; margin-bottom: var(--space-3); }
.folder .back { position: absolute; inset: 12% 0 0 0; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--c) 62%, black); }
.folder .back::before { content: ""; position: absolute; left: 0; bottom: 100%; width: 42%; height: 16%; margin-bottom: -1%; border-radius: var(--radius-md) var(--radius-md) 0 0; background: inherit; }
.folder .pg { position: absolute; left: 14%; top: 4%; width: 44%; height: 60%; border-radius: var(--radius-sm); background: var(--paper-sheet); transform: rotate(-7deg); box-shadow: var(--shadow-note); }
.folder .pg + .pg { left: 44%; top: 8%; transform: rotate(6deg); opacity: 0.92; }
.folder .pg::before { content: ""; position: absolute; left: 14%; right: 30%; top: 16%; height: 22%; border-top: var(--focus-w) solid color-mix(in srgb, var(--paper-sheet) 80%, black); border-bottom: var(--focus-w) solid color-mix(in srgb, var(--paper-sheet) 80%, black); }
.folder .front { position: absolute; inset: 34% 0 0 0; border-radius: var(--radius-md) var(--radius-md) var(--radius-lg) var(--radius-lg); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 78%, white), var(--c) 55%, color-mix(in srgb, var(--c) 86%, black)); box-shadow: inset 0 var(--border-w) 0 color-mix(in srgb, var(--c) 45%, white); display: flex; align-items: flex-end; justify-content: space-between; padding: var(--space-2) var(--space-3); }
.folder.glass .front { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 38%, transparent), color-mix(in srgb, var(--c) 70%, transparent)); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); }
.folder .pg, .folder .front { transition: transform 0.25s ease; }
.folder .front { transform-origin: 50% 100%; overflow: hidden; }
.folder .front::after { content: ""; position: absolute; inset: 0 0 52% 0; background: linear-gradient(180deg, color-mix(in srgb, white 32%, transparent), transparent); pointer-events: none; }
.folder-card:hover .folder .front, .folder.open .front { transform: perspective(40rem) rotateX(-16deg); }
.folder-card:hover .folder .pg, .folder.open .pg { transform: translateY(-14%) rotate(-9deg); }
.folder-card:hover .folder .pg + .pg, .folder.open .pg + .pg { transform: translateY(-10%) rotate(8deg); }
.folder .fico { position: absolute; left: 50%; top: 46%; width: 30%; height: auto; transform: translate(-50%, -50%); fill: none; stroke: color-mix(in srgb, white 88%, transparent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.folder.dark-ink .fico { stroke: color-mix(in srgb, var(--note-ink) 62%, transparent); }
.folder.ghost .back, .folder.ghost .front { background: none; box-shadow: inset 0 0 0 var(--border-w) var(--ink-3); }
.folder.ghost .front::after, .folder.ghost .pg { display: none; }
.folder.ghost .fico { stroke: var(--ink-3); }
.folder.big { max-width: var(--size-folder-big); margin: 0 auto var(--space-2); }
.folder-stage { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6) var(--space-4) var(--space-5); border-radius: var(--radius-lg); background: var(--paper); }
.folder-name { width: 100%; max-width: 20rem; padding: var(--space-2); border: 0; border-bottom: var(--border-w) dashed var(--ink-3); background: none; color: var(--ink); text-align: center; font-family: var(--font-display); font-size: var(--fs-sub-big); font-weight: var(--fw-h2); letter-spacing: var(--ls-h2); }
.folder-name:focus { outline: 0; border-bottom: var(--border-w) solid var(--forest-text); }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.swatch { width: var(--size-swatch); height: var(--size-swatch); padding: 0; border: 0; border-radius: var(--radius-pill); background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 68%, white), var(--c) 72%); box-shadow: inset 0 var(--border-w) 0 color-mix(in srgb, white 40%, transparent); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 var(--focus-w) var(--surface), 0 0 0 calc(var(--focus-w) * 2) var(--c); }
.stamp { display: grid; place-items: center; width: var(--size-swatch); height: var(--size-swatch); padding: 0; border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink-2); }
.stamp.fine { width: auto; padding: 0 var(--space-3); }
.stamp[aria-pressed="true"] { border-color: var(--forest-text); color: var(--forest-text); background: var(--mint); }
.folder .pill { padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: color-mix(in srgb, white 24%, transparent); color: var(--paper-sheet); font-size: var(--fs-fine); font-weight: var(--fw-medium); }
.folder.dark-ink .pill { background: color-mix(in srgb, black 14%, transparent); color: var(--note-ink); }
.file-name { display: flex; align-items: center; gap: var(--space-3); }
.file-name .ico { color: var(--ink-3); }
.by { display: flex; align-items: center; gap: var(--space-2); }
.by .avatar { width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); font-size: var(--fs-fine); }

/* ---------- procedures ---------- */
.steps { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.viewer { width: 100%; height: var(--size-viewer); max-height: 70vh; border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--paper); display: block; }
img.viewer, video.viewer { height: auto; object-fit: contain; }
.drop { display: grid; gap: var(--space-2); justify-items: center; padding: var(--space-5); border: var(--border-w) dashed var(--ink-3); border-radius: var(--radius-md); background: var(--paper); text-align: center; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--forest-text); background: var(--mint); }

/* ---------- stock room touchscreen ---------- */
.kiosk { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.kiosk-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-6); padding: var(--space-4) var(--space-6); background: var(--surface); border-bottom: var(--border-w) solid var(--line); }
.kiosk-head .side-logo { width: 11rem; flex: none; }
.kiosk-head .grow { flex: 1; min-width: 16rem; }
.kiosk-body { display: grid; grid-template-columns: minmax(0, 1fr) var(--size-kiosk-panel); gap: var(--space-6); padding: var(--space-6); align-items: start; }
.kiosk .chip { min-height: var(--size-control); padding: 0 var(--space-4); font-size: var(--fs-small); }
.tiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--size-tile), 1fr)); gap: var(--space-3); }
.tile-btn { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-2); min-height: var(--size-tile-h); padding: var(--space-4); border: var(--border-w) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: left; }
.tile-btn:hover { border-color: var(--forest-text); }
.tile-btn:active { background: var(--mint); }
.tile-btn .name { font-size: var(--fs-body); font-weight: var(--fw-kicker); line-height: var(--lh-h3); padding-right: var(--space-6); }
.tile-btn.on { background: var(--mint); border-color: var(--forest-text); box-shadow: inset 0 0 0 var(--border-w) var(--forest); }
.tile-btn.out { background: var(--band); color: var(--ink-3); }
.tile-btn .qty { position: absolute; top: var(--space-3); right: var(--space-3); min-width: 2rem; height: 2rem; padding: 0 var(--space-2); display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--forest); color: var(--on-primary); font-weight: var(--fw-kicker); }
.basket { position: sticky; top: var(--space-5); }
.basket-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: var(--border-w) solid var(--line); }
.basket .stepper button { width: var(--size-control); height: var(--size-control); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.name-btn { min-height: var(--size-control-lg); padding: var(--space-2) var(--space-3); border: var(--border-w) solid var(--forest); border-radius: var(--radius-sm); background: var(--forest); color: var(--on-primary); font-weight: var(--fw-button); text-align: center; }
.name-btn:hover { background: var(--forest-dk); }
.name-btn.idle { background: var(--surface); color: var(--ink-3); border-color: var(--line); }
.thanks { text-align: center; display: grid; gap: var(--space-4); justify-items: center; padding: var(--space-5) 0; }
.thanks .big { font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-h2); letter-spacing: var(--ls-h2); color: var(--forest-text); }

/* ---------- time off and shared calendar (glass controls) ---------- */
.glass { background: var(--glass-bg); border: var(--border-w) solid var(--glass-border); box-shadow: var(--glass-shadow); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); }
.glass-btn { display: inline-flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-5) var(--space-2) var(--space-3); border-radius: var(--radius-pill); color: var(--ink); text-align: left; }
.glass-btn:hover { filter: brightness(1.08); }
.glass-btn small { display: block; font-size: var(--fs-fine); color: var(--ink-3); line-height: var(--lh-button); }
.glass-btn b { display: block; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: var(--lh-h3); }
.cal-ico { position: relative; flex: none; width: var(--size-well); height: var(--size-well); border-radius: var(--radius-md); background: linear-gradient(180deg, color-mix(in srgb, var(--paper-sheet) 92%, transparent), color-mix(in srgb, var(--paper-sheet) 70%, transparent)); box-shadow: var(--well-shadow); overflow: hidden; }
.cal-ico::before { content: ""; position: absolute; inset: 0 0 68% 0; background: linear-gradient(90deg, var(--folder-e), var(--folder-a)); }
.team-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-4); align-items: stretch; }
.week { display: flex; justify-content: space-between; gap: var(--space-2); }
.daypill { flex: 1; max-width: var(--size-daypill); display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-1) var(--space-3); border-radius: var(--radius-pill); color: var(--ink-3); }
.daypill .dow { font-size: var(--fs-fine); font-weight: var(--fw-medium); }
.daypill .well { display: grid; place-items: center; width: var(--size-well); height: var(--size-well); border-radius: var(--radius-pill); background: var(--well-bg); box-shadow: var(--well-shadow); font-size: var(--fs-body); font-weight: var(--fw-medium); }
.daypill.today { color: var(--ink); transform: translateY(calc(var(--space-1) * -1)); }
.daypill.today .well { background: var(--btn-bg); color: var(--on-primary); box-shadow: var(--glow); }
.daypill .away { display: flex; gap: 0.1875rem; min-height: 0.5rem; }
.daypill .away i { width: 0.5rem; height: 0.5rem; border-radius: var(--radius-pill); background: var(--c); }
.bal { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.bal div { display: grid; gap: var(--space-1); align-content: center; }
.bal b { font-family: var(--font-display); font-size: var(--fs-sub-big); line-height: var(--lh-stat); font-weight: var(--fw-stat); letter-spacing: var(--ls-stat); }
.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
.cal-head .grow { flex: 1; }
.round { display: grid; place-items: center; width: var(--size-control-sm); height: var(--size-control-sm); padding: 0; border-radius: var(--radius-pill); color: var(--ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: var(--border-w) solid var(--line); }
.cal-dow { padding: var(--space-2) var(--space-3); font-size: var(--fs-fine); font-weight: var(--fw-medium); color: var(--ink-3); border-bottom: var(--border-w) solid var(--line); }
.cal-cell { min-height: var(--size-cell); padding: var(--space-2); border: 0; border-right: var(--border-w) solid var(--line); border-bottom: var(--border-w) solid var(--line); background: none; text-align: left; display: flex; flex-direction: column; gap: 0.1875rem; color: inherit; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.cal-cell.out { opacity: 0.35; }
.cal-cell.wkend { background: color-mix(in srgb, var(--ink) 2.5%, transparent); }
.cal-num { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); font-size: var(--fs-kicker); font-weight: var(--fw-medium); color: var(--ink-2); }
.cal-cell.today .cal-num { background: var(--btn-bg); color: var(--on-primary); box-shadow: var(--glow); }
.ev { --c: var(--ink-3); display: flex; align-items: center; gap: var(--space-1); padding: 0.125rem var(--space-2); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 24%, transparent); font-size: var(--fs-fine); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev::before { content: ""; flex: none; width: 0.4375rem; height: 0.4375rem; border-radius: var(--radius-pill); background: var(--c); }
.ev.pending { background: none; box-shadow: inset 0 0 0 var(--border-w) color-mix(in srgb, var(--c) 70%, transparent); color: var(--ink-2); }
.ev.office { background: none; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-5); }
.legend .ev { background: none; padding: 0; }
.req { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); padding: var(--space-4) var(--space-5); border-bottom: var(--border-w) solid var(--line); }
.req:last-child { border-bottom: 0; }
.req .grow { flex: 1; min-width: 14rem; }
.decide { display: inline-flex; gap: var(--space-2); padding: var(--space-1); border-radius: var(--radius-pill); }
.decide button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--size-control-sm); padding: 0 var(--space-3) 0 var(--space-1); border: 0; border-radius: var(--radius-pill); background: none; color: var(--ink); font-size: var(--fs-kicker); font-weight: var(--fw-medium); }
.decide button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.decide .orb { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 70%, white), var(--c) 70%); box-shadow: inset 0 var(--border-w) 0 color-mix(in srgb, white 45%, transparent), 0 0.375rem 0.75rem -0.25rem var(--c); color: var(--paper-sheet); }
.decide .orb .ico { width: 0.875rem; height: 0.875rem; stroke-width: 3; }
/* date range picker */
.drp-fields { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-3); }
.drp-field { display: grid; gap: 0.125rem; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); }
.drp-field.on { box-shadow: var(--glass-shadow), 0 0 0 var(--focus-w) color-mix(in srgb, var(--forest-text) 55%, transparent); }
.drp-field b { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.drp-month { display: flex; align-items: center; justify-content: space-between; }
.drp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: var(--space-1); }
.drp-grid span { text-align: center; font-size: var(--fs-fine); color: var(--ink-3); padding-bottom: var(--space-1); }
.drp-day { height: var(--size-control); border: 0; background: none; color: var(--ink); font-variant-numeric: tabular-nums; border-radius: var(--radius-pill); }
.drp-day:hover:not(:disabled):not(.a):not(.b) { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.drp-day:disabled { color: var(--ink-3); opacity: 0.4; cursor: default; }
.drp-day.mid { border-radius: 0; background: color-mix(in srgb, var(--folder-a) 26%, transparent); }
.drp-day.a, .drp-day.b { background: var(--btn-bg); color: var(--on-primary); box-shadow: var(--glow); font-weight: var(--fw-kicker); }
.drp-day.a.ranged { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
.drp-day.b.ranged { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.drp-count { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* ---------- dialogs and toast ---------- */
dialog { width: calc(100% - var(--space-6)); max-width: var(--size-dialog); max-height: calc(100vh - var(--space-6)); padding: 0; border: var(--border-w) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); overflow: auto; }
dialog.wide { max-width: var(--size-dialog-wide); }
dialog::backdrop { background: var(--scrim); }
.dlg { display: grid; gap: var(--space-5); padding: var(--space-5); }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3); }
.phone { font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-stat); letter-spacing: var(--ls-stat); color: var(--forest-text); text-decoration: none; }
.history { display: grid; gap: var(--space-3); }
.history li { list-style: none; display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-3); }
.history { padding: 0; margin: 0; }
.scroll { max-height: 16rem; overflow: auto; border: var(--border-w) solid var(--line); border-radius: var(--radius-md); }
.plain { margin: 0; padding: var(--space-4); background: var(--paper); border-radius: var(--radius-md); font: inherit; white-space: pre-wrap; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: var(--space-8); transform: translateX(-50%); display: flex; align-items: center; gap: var(--space-4); max-width: calc(100% - var(--space-6)); padding: var(--space-3) var(--space-4); background: var(--ink); color: var(--surface); border-radius: var(--radius-sm); font-weight: var(--fw-medium); }
.toast button { border: 0; background: none; color: var(--toast-link); font-weight: var(--fw-kicker); text-decoration: underline; }

/* ---------- printable plan ---------- */
#print-root { display: none; }
.sheet { background: var(--surface); color: var(--ink); padding: var(--space-6); display: grid; gap: var(--space-5); font-size: var(--fs-fine); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-5); padding-bottom: var(--space-4); border-bottom: var(--focus-w) solid var(--forest); }
.sheet-head img { height: 4rem; width: auto; }
.sheet-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.sheet th, .sheet td { padding: var(--space-2) var(--space-3); }
.sheet .sum { padding: var(--space-1) var(--space-3); }
.sign { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-6); margin-top: var(--space-6); }
.sign span { display: block; border-top: var(--border-w) solid var(--ink); padding-top: var(--space-1); }
dialog .sheet { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); }

/* Printing: while a patient sheet's preview is open, print only the sheet (on white).
   Any other time, Ctrl+P prints the screen as it is. */
@media print {
  body.printing { background: var(--paper-sheet); }
  body.printing #app, body.printing dialog, body.printing .toast { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing .sheet { padding: 0; }
  .demo-bar, .tabbar, .toast { display: none !important; }
  @page { margin: 1.5cm; }
}

@keyframes tab-pop { from { transform: scale(0.82); } to { transform: scale(1); } }
@keyframes tab-lbl { from { opacity: 0; max-width: 0; } to { opacity: 1; max-width: 8rem; } }
@media (prefers-reduced-motion: reduce) { .tabbar button.pop, .tabbar button.pop .lbl { animation: none; } }

/* phone-only pieces are hidden until the phone breakpoint */
.mbar, .tabbar, .only-sm { display: none; }
.channels button.ch b::before { content: "# "; color: var(--ink-3); font-weight: var(--fw-medium); }

/* ---------- smaller screens ---------- */
@media (max-width: 68em) {
  /* iPad and smaller: the sidebar becomes a bar across the top so the work gets the full width */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); padding: var(--space-3) var(--space-5); border-right: 0; border-bottom: var(--border-w) solid var(--line); overflow: visible; }
  .side-logo { width: 9rem; flex: none; }
  .nav { display: flex; flex-wrap: wrap; order: 3; flex: 1 0 100%; gap: 0 var(--space-1); }
  .nav .ico { display: none; }
  .nav button { width: auto; gap: var(--space-2); padding: 0 var(--space-2); font-size: var(--fs-kicker); }
  .side-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: var(--space-3); }
  .side-foot .built, .who > div { display: none; }
  .page { padding: var(--space-6) var(--space-6) var(--space-7); }
  .builder { gap: var(--space-5); }
  .hide-md { display: none; }
  .cal-cell { padding: var(--space-1); }
  .ev { padding: 0.125rem var(--space-1); }
  .kiosk-body { grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--space-4); padding: var(--space-4); }
  .names { grid-template-columns: 1fr; }
}
@media (max-width: 56em) {
  .builder, .people, .form .two, .sheet-cols { grid-template-columns: minmax(0, 1fr); }
  .plan { position: static; }
  .team-top { grid-template-columns: minmax(0, 1fr); }
  .pcards, .glance { grid-template-columns: minmax(0, 1fr); }
  .kiosk-body { grid-template-columns: minmax(0, 1fr); }
  .basket { position: static; }
  .names { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  .channels { display: flex; flex-wrap: wrap; border-right: 0; border-bottom: var(--border-w) solid var(--line); }
  .channels button.ch { width: auto; }
  .channels .fine { display: none; }
  .page { padding: var(--space-5) var(--space-4) var(--space-7); }
}

/* ---------- iPhone: a top bar, bottom tabs, lists instead of tables, sheets instead of dialogs ---------- */
@media (max-width: 40em) {
  :root { --size-well: 2rem; --fs-page: 1.5rem; --fs-sub-big: 1.25rem; }
  .only-sm { display: revert; }
  .btn { white-space: normal; padding-top: var(--space-2); padding-bottom: var(--space-2); text-align: center; }   /* long labels wrap instead of pushing the page sideways */
  .stack.only-sm { display: grid; }
  .input, .compose .input { font-size: 1rem; }   /* under 16px, iPhones zoom in when a field is tapped */
  .kiosk-head { padding-top: calc(var(--space-3) + var(--safe-t)); }
  .side, .demo-bar, .hide-sm { display: none; }
  /* calmer on a phone: no intro paragraphs, no number tiles, dots instead of counts */
  .page-head .sub, .page-head .kicker { display: none; }
  .tabbar button .badge { min-width: 0.5rem; width: 0.5rem; height: 0.5rem; padding: 0; top: 0.5rem; right: 0.625rem; font-size: 0; }
  .mbar { display: flex; align-items: center; gap: var(--space-3); position: sticky; top: 0; z-index: 20; padding: calc(var(--space-2) + var(--safe-t)) var(--space-4) var(--space-2); background: color-mix(in srgb, var(--surface-2) 86%, transparent); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); border-bottom: var(--border-w) solid var(--line); }
  .mbar img { width: 1.75rem; height: 1.75rem; }
  .mbar b { flex: 1; font-size: var(--fs-body); font-weight: var(--fw-kicker); }
  .mbar button { border: 0; background: none; padding: 0; }
  /* a floating black pill: icons only, and the section you're on opens into a lit label */
  .tabbar { display: flex; align-items: center; justify-content: space-between; gap: 0.125rem; position: fixed; z-index: 20; left: var(--space-3); right: var(--space-3); bottom: calc(var(--space-2) + var(--safe-b)); max-width: 26rem; margin: 0 auto; padding: 0.375rem; border-radius: var(--radius-pill); background: var(--nav-pill); box-shadow: inset 0 0 0 var(--border-w) color-mix(in srgb, white 10%, transparent), 0 1rem 2rem -0.5rem color-mix(in srgb, black 70%, transparent); }
  .tabbar button { position: relative; flex: 1 1 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 2.75rem; min-width: 2rem; max-width: 3.5rem; padding: 0; border: 0; border-radius: var(--radius-pill); background: none; color: var(--nav-pill-ink); font-size: var(--fs-fine); font-weight: var(--fw-kicker); white-space: nowrap; }
  .tabbar .lbl { display: none; }
  .tabbar .ico { width: 1.375rem; height: 1.375rem; }
  .tabbar button[aria-current="page"] { flex: none; max-width: none; padding: 0 var(--space-4) 0 var(--space-3); background: var(--btn-bg); color: var(--on-primary); box-shadow: var(--glow); }
  .tabbar button[aria-current="page"] .lbl { display: inline; }
  .tabbar button.pop { animation: tab-pop 0.32s cubic-bezier(0.3, 1.5, 0.5, 1); }
  .tabbar button.pop .lbl { animation: tab-lbl 0.32s ease-out; }
  .tabbar .badge { position: absolute; top: 0.125rem; right: 0.125rem; min-width: 1rem; height: 1rem; padding: 0 0.25rem; display: grid; place-items: center; background: var(--bad); color: var(--nav-pill); font-size: 0.625rem; line-height: 1; }
  .tabbar button[aria-current="page"] .badge { display: none; }
  .page { padding: var(--space-4) var(--space-4) calc(var(--size-tabbar) + var(--safe-b) + var(--space-7)); gap: var(--space-5); }
  .page-head { align-items: stretch; }
  .page-head > .btn, .page-head > .btn-row, .page-head > .glass-btn { width: 100%; }
  .page-head .btn-row .btn { flex: 1; }
  .sub { font-size: var(--fs-small); }
  .card.pad { padding: var(--space-4); }
  .toast { bottom: calc(var(--size-tabbar) + var(--safe-b) + var(--space-4)); width: max-content; }
  .toolbar select.input, .toolbar .input, .toolbar label.field { width: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; max-width: 100%; min-width: 0; padding-bottom: var(--space-1); scrollbar-width: none; }
  .toolbar > *, .stack > *, .split > * { min-width: 0; }
  .toolbar { width: 100%; }
  .chips .chip, .chips .choice { flex: none; }
  dialog .chips { flex-wrap: wrap; }

  /* tables become lists */
  .card table, .card tbody { display: block; }
  .card thead { display: none; }
  .card tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: var(--border-w) solid var(--line); }
  .card tr:last-child { border-bottom: 0; }
  .card td { padding: 0; border: 0; }
  .card td:first-child { flex: 1 0 100%; }
  .card td:has(.row-actions) { flex: 1 0 100%; padding-top: var(--space-2); }
  .card td .fine { display: inline; margin-left: var(--space-2); }
  .card td:first-child .fine { margin-left: var(--space-2); }
  .row-actions { justify-content: flex-start; }
  #fee-table td:first-child { flex: 0 0 auto; }
  #fee-table td:nth-child(2) { flex: 1; }

  .split { flex-wrap: wrap; }
  .week { gap: var(--space-1); }
  .daypill { padding: var(--space-2) 0 var(--space-3); }
  div.todo { flex-wrap: wrap; }
  div.todo .txt { flex: 1 0 70%; }
  div.todo .btn { margin-left: calc(0.625rem + 1rem + var(--space-3)); }
  dialog .sheet { overflow-x: auto; }
  dialog .sheet table { min-width: 26rem; }
  .toast { left: var(--space-4); right: var(--space-4); transform: none; width: auto; max-width: none; }

  /* today */
  .glance { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .glance button { padding: var(--space-3); }
  .glance b { font-size: var(--fs-sub-big); }
  .pcard-head { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .pcard-head .stack-av { display: none; }
  .todo .meta { display: none; }

  /* chat, the way a phone chat app does it: channel list, then the conversation */
  .chat { min-height: 0; border: 0; background: none; box-shadow: none; overflow: visible; }
  .chat .channels { display: grid; gap: var(--space-1); padding: 0; border: 0; }
  .chat .channels button.ch { width: 100%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface); }
  .chat .channels .fine { display: block; }
  .chat[data-open="true"] .channels, .chat[data-open="false"] .thread { display: none; }
  .chat[data-open="true"] { position: fixed; z-index: 30; inset: 0; display: flex; background: var(--paper); }
  .thread { flex: 1; }
  .thread-head { display: flex; align-items: center; gap: var(--space-3); padding: calc(var(--space-3) + var(--safe-t)) var(--space-4) var(--space-3); background: var(--surface-2); }
  .msgs { max-height: none; padding: var(--space-4); overflow: auto; }
  .msgs > :first-child { margin-top: 0; }
  .compose { padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-b)); background: var(--surface-2); }
  .compose .input { border-radius: var(--radius-pill); }
  .tag-pop { left: var(--space-3); right: var(--space-3); }

  /* time off */
  .bal b { font-size: var(--fs-h3); }
  .cal-head { padding: var(--space-3) var(--space-4); }
  .cal-head .h2 { flex: 1 0 100%; }
  .cal-dow { padding: var(--space-1); text-align: center; font-size: 0.6875rem; }
  .cal-cell { min-height: 3.25rem; align-items: center; padding: var(--space-1) 0; }
  .cal-cell .ev { font-size: 0; padding: 0; background: none; box-shadow: none; gap: 0; }
  .cal-cell .ev.pending::before { background: none; box-shadow: inset 0 0 0 var(--border-w) var(--c); }
  .cal-cell .fine { display: none; }
  .legend { padding: var(--space-3) var(--space-4); }
  .req { padding: var(--space-3) var(--space-4); }
  .drp-day { height: var(--size-control-sm); }

  /* folders, stock room */
  .folders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kiosk-body { padding: var(--space-3); }
  .tiles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* dialogs slide up as sheets */
  dialog, dialog.wide { margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-width: var(--border-w) 0 0; }
  .dlg { padding: var(--space-4) var(--space-4) calc(var(--space-4) + var(--safe-b)); gap: var(--space-4); }
  .dlg-foot .btn { flex: 1; }
  .menu { display: grid; gap: var(--space-1); }
  .sheet { padding: var(--space-3); }
  .sheet-head { flex-direction: column; }
}
.menu button { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--size-control); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font-weight: var(--fw-medium); text-align: left; }
.menu button:hover { background: var(--band); }
