/* ═══ The control kit and the calm primitives (docs/UI_PRO.md sections 1 and 2) ══════════════════════════════════════
   Loaded after modern.css and before components.css. Tokens only (css/tokens.css): no literal colour, and no px font
   size outside the phone block's 16 px.
   A screen opts in to the calm scale with the class "calm" on its root (form#rec-form.gf.calm, div.sf.calm, div.tq.calm,
   article.rec.calm): 14 px text, 38 px controls, white cards on neutral hairlines, one accent. Everything that restyles
   something that exists (.btn, .pill, .menu, .lines, .plate, .id-no) is written under .calm, so a screen that has not
   opted in keeps the control-tower look. What is new (.cc-*, the avatar's tones, .cf-guard, the list and the menu of the
   kit) needs no scope.
   0. outside .calm the kit's wrappers vanish     1. the calm base     2. buttons, tags, avatars, menus
   3. the wrapper, prefix and suffix, the echo line     4. date     5. segmented and chips     6. the list and the combobox
   7. file     8. the lines editor: sheet and row list     9. the warning under a field     10. the language button
   11. phones     12. dark theme: the sheet's backdrop and the list's edge
   The native controls themselves (.fld input, select, textarea, the switch, the form grid, the docked bar) are dressed
   in forms.css under .calm. A native control under a face is .cc-native: it sets no border, shadow, font size or
   min-height (tests/ui_foundation.test.js reads those on the first select of a form). */

/* ─── 0. Outside .calm: a form drawn with fieldBlock() that has not opted in looks as it always did ─── */
.cc, .cc-affix, .cc-drop, .lines .ln-foot { display: contents; }
.cc > .pre, .cc > .suf, .cc > .cc-cal, .cc-echo, .cc-drop > .ico, .cc-drop > .cc-drop-t,
.lines .ln-n, .lines tfoot, .lines .ln-hint, .lines .ln-head, .lines [data-ln-edit], .lines [data-ln-done] { display: none; }
/* the smart form is not calm yet: on a phone its own card rules (smartform.css: every cell of a line is a flex row) would
   draw the row-number cell, so it is taken out there by name, with more weight than those rules */
.sf:not(.calm) .lines .ln-n { display: none; }
/* a lines table drawn as a sheet carries the class "sheet", which is also the name of the dialog of components.css
   (.sheet: fixed, centred, padded, shadowed): a lines box is never that dialog, on any screen */
.lines.sheet { position: static; z-index: auto; inset: auto; width: auto; max-height: none; padding: 0; border-radius: var(--r-md); box-shadow: none; transform: none; overflow: visible; overflow-x: auto; }
/* the unit of a number's label ("(km)") is hidden only where the control shows it as a suffix */
.fld label .lbl-unit { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
/* a Hindi label over its English one (docs/UI_PRO.md 3.14): two lines. The Hindi words stay inline, so the required
   star (and "auto if blank") sit on their line; the English label is the block under them. Devanagari is one pixel up */
.lbl-hi { display: inline; font-size: calc(var(--fs-body) + 1px); }
.lbl-en { display: block; color: var(--muted); font-weight: 400; font-size: var(--fs-small); line-height: var(--lh-small); }
/* the kit's icons: 24-unit strokes in the text colour */
.cc svg, .cc-pop svg, .cc-menu svg, .av svg, .lines .ln-foot svg, .lines .ln-x svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ─── 1. The calm base ─── */
.calm { font-size: var(--fs-ctl); line-height: var(--lh-ctl); }
.calm .num, .calm .money { font-variant-numeric: tabular-nums lining-nums; }
/* a record number in a sentence: mono, never caps, never a heading; a vehicle number is the UI face at 600, without its box.
   (Longhands: "inherit" inside the font shorthand is invalid, and an invalid font takes every one of them back to the parent's) */
.calm .id-no { font-family: var(--font-mono); font-weight: 500; font-size: .92em; line-height: inherit; letter-spacing: 0; text-transform: none; }
.calm .plate { display: inline; padding: 0; border: 0; border-radius: 0; background: none; font-family: var(--font-ui); font-weight: 600; font-size: 1em; line-height: inherit; letter-spacing: 0; font-variant-numeric: tabular-nums lining-nums; }

/* ─── 2. Buttons, tags, avatars, menus (2.15) ─── */
.calm .btn, .calm .btn.btn-primary, .calm .btn.btn-secondary, .calm .btn.btn-ghost, .calm .btn.btn-danger, .calm .btn.btn-ai {
  height: var(--h-ctl-sm); min-height: 0; padding: 0 12px; gap: 6px; border: 1px solid var(--edge); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font: 600 var(--fs-body)/1 var(--font-ui); box-shadow: none; transform: none;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.calm .btn:hover, .calm .btn.btn-secondary:hover { background: var(--inset); border-color: var(--edge-2); }
.calm .btn:active { background: var(--inset-2); transform: none; }
.calm .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.calm .btn.xs { height: 26px; padding: 0 8px; }
.calm .btn.lg { height: var(--h-ctl); padding: 0 16px; font-size: var(--fs-ctl); }
.calm .btn.primary, .calm .btn.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.calm .btn.primary:hover, .calm .btn.btn-primary:hover, .calm .btn.primary:active, .calm .btn.btn-primary:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.calm .btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.calm .btn.soft:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.calm .btn.ghost, .calm .btn.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.calm .btn.ghost:hover, .calm .btn.btn-ghost:hover { background: var(--inset-2); border-color: transparent; color: var(--ink); }
.calm .btn.danger, .calm .btn.btn-danger { background: var(--surface); border-color: var(--crit-line); color: var(--crit-text); }
.calm .btn.danger:hover, .calm .btn.btn-danger:hover { background: var(--crit-soft); border-color: var(--crit-line); }
.calm .btn.icon { width: var(--h-ctl-sm); padding: 0; }
.calm .btn.lg.icon { width: var(--h-ctl); }
.calm .btn svg { width: 15px; height: 15px; stroke-width: 1.75; }
/* aria-disabled still takes the click (it says what is missing): it looks enabled. disabled is only for a running request */
.calm .btn[aria-disabled="true"] { opacity: 1; cursor: pointer; }
.calm .btn:disabled { opacity: .5; cursor: not-allowed; }

/* a tag: one word of state, without the control tower's leading dot (a tag that wants one says has-dot) */
.calm .pill { height: 22px; padding: 0 8px; gap: 5px; border: 0; border-radius: var(--r-sm); font: 600 var(--fs-small)/1 var(--font-ui); letter-spacing: 0; }
.calm .pill:not(.has-dot)::before { display: none; }
.calm .pill.neutral, .calm .pill.muted { background: var(--inset-2); color: var(--ink-2); }

/* an avatar (ui.js avatar()): a person keeps a tone; the agent, a machine source, WhatsApp, nobody yet. The 24 px circle
   is the shell's .av; these are its tones and sizes */
.av.t1, .av.t2, .av.t3, .av.t4, .av.ai, .av.sys, .av.wa, .av.none {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-pill); box-shadow: none;
  font: 600 var(--fs-xs)/1 var(--font-ui); letter-spacing: 0; vertical-align: middle;
}
.av.t1 { background: var(--accent-soft); color: var(--accent-text); }
.av.t2 { background: var(--warn-soft); color: var(--warn-text); }
.av.t3 { background: var(--info-soft); color: var(--info-text); }
.av.t4 { background: var(--good-soft); color: var(--good-text); }
.av.ai { background: var(--ai-soft); color: var(--ai-text); }
.av.sys { background: var(--inset-2); color: var(--ink-2); }
.av.wa { background: var(--good-soft); color: var(--good-text); }
.av.none { background: transparent; color: var(--muted); border: 1.5px dashed var(--edge); }
.av.sm { width: 20px; height: 20px; }
.av.lg { width: 32px; height: 32px; font-size: var(--fs-small); }
.av svg { width: 13px; height: 13px; }
.av.lg svg { width: 16px; height: 16px; }

/* a menu: the record page's own, and openMenu()'s */
.calm .menu, .menu.cc-menu {
  min-width: 216px; padding: 6px; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  box-shadow: var(--e-pop); font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui);
}
.calm .menu .mi, .menu.cc-menu .mi {
  justify-content: flex-start; gap: 10px; min-height: 34px; padding: 0 10px; border-radius: var(--r-sm); color: var(--ink);
  font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui);
}
.calm .menu .mi:hover, .menu.cc-menu .mi:hover, .calm .menu .mi:focus-visible, .menu.cc-menu .mi:focus-visible { background: var(--inset-2); }
.calm .menu .mi svg, .menu.cc-menu .mi svg { width: 16px; height: 16px; color: var(--muted); }
.calm .menu .mi kbd, .menu.cc-menu .mi kbd { margin-left: auto; padding: 0; border: 0; background: none; color: var(--muted); font: 400 var(--fs-small)/1 var(--font-ui); }
.calm .menu .mi.danger, .menu.cc-menu .mi.danger { color: var(--crit-text); }
.calm .menu .mi.danger svg, .menu.cc-menu .mi.danger svg { color: currentColor; }
.calm .menu .mi[aria-disabled="true"], .menu.cc-menu .mi[aria-disabled="true"] { color: var(--muted); cursor: default; background: none; }
.calm .menu .ml, .menu.cc-menu .ml { padding: 6px 10px 2px; color: var(--muted); font: 400 var(--fs-small)/var(--lh-small) var(--font-ui); letter-spacing: 0; text-transform: none; }
.calm .menu hr, .menu.cc-menu hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--hair); }
/* in the top layer (the Popover API): the browser's own popover box off, placed by popOver() */
.menu.cc-menu[popover] { inset: auto; margin: 0; overflow: auto; }
.menu.cc-menu[hidden] { display: none; }

/* ─── 3. The wrapper of a control, its prefix and suffix, the echo line ─── */
.calm .cc { display: block; position: relative; min-width: 0; }
.calm .cc-echo { display: block; color: var(--muted); font: 400 var(--fs-small)/var(--lh-small) var(--font-ui); font-variant-numeric: tabular-nums lining-nums; }
.calm .cc-echo:empty { display: none; }
.calm .cc-echo.ok { color: var(--good-text); }
.calm .fld label .lbl-unit { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* a native select that stays (a phone, a cell of a lines table, a value the system fills): the chevron is the wrapper's,
   drawn from the same 16 px outline path as the list's and the combobox's (a mask, so it takes the token's colour).
   forms.css takes the select's own gradient chevron away where this one is drawn */
.calm .cc:has(> select:not([multiple]):not(.cc-native))::after {
  content: ""; position: absolute; right: 12px; bottom: calc((var(--h-ctl) - 16px) / 2); width: 16px; height: 16px; background: var(--muted); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}
/* a native control under a face: the truth of the field, out of sight (2.2) */
.cc-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.calm .cc-affix {
  display: flex; align-items: center; gap: 8px; height: var(--h-ctl); padding: 0 12px; border: 1px solid var(--edge); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.calm .cc-affix:hover { border-color: var(--edge-2); }
.calm .cc-affix:focus-within { border-color: var(--accent); box-shadow: var(--ring-ctl); }
.calm .fld.invalid .cc-affix { border-color: var(--crit); box-shadow: var(--ring-crit); }
.calm .cc-affix > .pre, .calm .cc-affix > .suf { display: inline-flex; align-items: center; flex: none; color: var(--muted); white-space: nowrap; }
.calm .cc-affix > .pre svg { width: 16px; height: 16px; }
/* the control inside: no box of its own. The field's focus rule still lands on it and is clipped away; the ring is the wrapper's */
.calm .cc-affix > input:not([type=checkbox]):not([type=file]):not([type=radio]) {
  flex: 1; min-width: 0; width: auto; height: 100%; min-height: 0; padding: 0; border-width: 0; border-radius: 0; background: transparent; clip-path: inset(0);
}
/* a number: no spin buttons (a wheel over it changes nothing: controls.js) */
.calm .cc input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.calm .cc input[type=number]::-webkit-inner-spin-button, .calm .cc input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.calm .cc-json textarea { font-family: var(--font-mono); }

/* ─── 4. Date, date and time: the browser's own field and picker, quick picks, a calendar glyph (2.9) ─── */
.calm .cc-date { padding: 0; }
.calm .cc-date > input:not([type=checkbox]):not([type=file]):not([type=radio]) { align-self: stretch; height: auto; padding: 0 10px 0 12px; border-radius: var(--r-md); }
.calm .cc-date > .tail { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 2px; }
.calm .cc-date > .tail .btn { position: relative; height: 26px; padding: 0 8px; }
/* 26 px to look at, 32 px to press (7.1 rule 5) */
.calm .cc-date > .tail .btn::after { content: ""; position: absolute; inset: -4px -1px; }
.calm .cc-date > .cc-cal { display: block; position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }
/* the browser's indicator is stretched over the glyph, unseen: a click on the glyph opens the browser's picker */
.calm .cc-date > input::-webkit-calendar-picker-indicator { width: 20px; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
@supports not selector(::-webkit-calendar-picker-indicator) { .calm .cc-date > .cc-cal { display: none; } }

/* ─── 5. Segmented (real radios) and chips (real checkboxes) (2.11) ─── */
.calm .cc-seg[data-cc-on="seg"] {
  display: inline-flex; align-self: flex-start; gap: 2px; height: var(--h-ctl); max-width: 100%; padding: 3px; border-radius: var(--r-md);
  background: var(--inset-2); overflow: hidden; vertical-align: top;
}
.calm .cc-seg[data-cc-on="seg"]:focus-within { box-shadow: var(--ring-ctl); }
.calm .fld.invalid .cc-seg[data-cc-on="seg"] { box-shadow: 0 0 0 1px var(--crit), var(--ring-crit); }
.calm .cc-seg-o { position: relative; display: inline-flex; flex: none; }
.calm .cc-seg-o > input, .calm .cc-chip > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.calm .cc-seg-o > span {
  display: inline-grid; align-content: center; justify-items: center; height: 100%; padding: 0 14px; border-radius: var(--r-sm);
  color: var(--ink-2); font: 500 var(--fs-body)/1 var(--font-ui); white-space: nowrap;
}
/* the bold copy holds the width, so picking an option moves nothing */
.calm .cc-seg-o > span::after { content: attr(data-t); height: 0; overflow: hidden; visibility: hidden; font-weight: 600; }
/* the picked one: a white pill with the control's own 3:1 edge (its fill alone is 1.1:1 on the trough) */
.calm .cc-seg-o > input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--e-card), 0 0 0 1px var(--edge); }
.calm .cc-seg-o > input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--accent); }
.calm .cc-seg-o > input:disabled + span { color: var(--muted); }
.calm .cc-chips[data-cc-on="chips"] { display: flex; flex-wrap: wrap; gap: 8px; border-radius: var(--r-md); }
.calm .cc-chip { position: relative; display: inline-flex; }
.calm .cc-chip > span {
  display: inline-flex; align-items: center; gap: 6px; height: var(--h-ctl-sm); padding: 0 12px; border: 1px solid var(--edge); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-2); font: 500 var(--fs-body)/1 var(--font-ui); white-space: nowrap;
}
.calm .cc-chip > span svg { display: none; width: 14px; height: 14px; stroke-width: 2.2; }
.calm .cc-chip:hover > span { border-color: var(--edge-2); color: var(--ink); }
.calm .cc-chip > input:checked + span { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); font-weight: 600; }
.calm .cc-chip > input:checked + span svg { display: block; }
.calm .cc-chip > input:focus-visible + span { box-shadow: var(--focus-ring); }
.calm .fld.invalid .cc-chip > span { border-color: var(--crit); }

/* ─── 6. The list and the combobox (2.12), and their layer (2.14) ─── */
.calm .cc-face {
  display: flex; align-items: center; gap: 8px; width: 100%; height: var(--h-ctl); padding: 0 12px; border: 1px solid var(--edge); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui); text-align: left; cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.calm .cc-face:hover { border-color: var(--edge-2); }
.calm .cc-face:focus-visible, .calm .cc.is-open > .cc-face, .calm .cc:has(> .cc-native:focus) > .cc-face { outline: none; border-color: var(--accent); box-shadow: var(--ring-ctl); }
.calm .fld.invalid .cc-face { border-color: var(--crit); box-shadow: var(--ring-crit); }
.calm .cc-face:disabled { background: var(--inset); color: var(--ink-2); cursor: not-allowed; }
.calm .cc-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calm .cc-val.is-empty { color: var(--muted); }
.calm .cc-chev { width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.calm .cc-combo[data-cc-on="combo"] { display: block; }
.calm .cc-combo[data-cc-on="combo"] > .cc-affix { cursor: text; }
/* the picker's own search box stays for the lookup: out of sight, its hidden attribute still wireRefPickers()'s */
.calm .cc-combo[data-cc-on="combo"] > .ref-q { position: absolute; opacity: 0; pointer-events: none; }
.calm .cc-ico { width: 16px; height: 16px; color: var(--muted); }
/* a picker that cannot be used (the linked module is closed to this role, or the field is switched off) */
.calm .cc-combo[data-cc-on="combo"] > .cc-affix:has(> .cc-in:disabled) { border-color: var(--hair); background: var(--inset); cursor: not-allowed; }
.calm .cc-combo[data-cc-on="combo"] > .cc-affix > .cc-in:disabled { background: transparent; cursor: not-allowed; }
.calm .cc-clear { position: relative; display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
/* 22 px to look at, 32 px to press */
.calm .cc-clear::after { content: ""; position: absolute; inset: -5px; }
.calm .cc-clear[hidden] { display: none; }
.calm .cc-clear:hover { background: var(--inset-2); color: var(--ink); }
.calm .cc-clear svg { width: 14px; height: 14px; }
/* tokens: a multi-choice of more than 8 */
.calm .cc-combo:has(.cc-tok) > .cc-affix { flex-wrap: wrap; gap: 4px 6px; height: auto; min-height: var(--h-ctl); padding: 4px 12px; }
.calm .cc-combo:has(.cc-tok) > .cc-affix > input:not([type=checkbox]):not([type=file]):not([type=radio]) { flex: 1 1 80px; height: 28px; }
.calm .cc-tok { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 2px 0 8px; border-radius: var(--r-sm); background: var(--inset-2); color: var(--ink); font: 500 var(--fs-body)/1 var(--font-ui); white-space: nowrap; }
.calm .cc-tok button { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--r-xs); background: none; color: var(--muted); cursor: pointer; }
.calm .cc-tok button::after { content: ""; position: absolute; inset: -6px -4px; }
.calm .cc-tok button:hover { color: var(--ink); background: var(--inset); }
.calm .cc-tok svg { width: 12px; height: 12px; }

/* the list itself: one element for a select's list, a combobox's and a phone's bottom sheet */
.cc-pop {
  box-sizing: border-box; z-index: 60; min-width: 240px; max-height: 320px; margin: 0; padding: 6px; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--e-pop); font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui);
  list-style: none; text-align: left; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.cc-pop[hidden] { display: none; }
.cc-pop[popover] { position: fixed; inset: auto; margin: 0; width: max-content; height: auto; }
.cc-pop.cc-abs { position: absolute; top: calc(100% + 6px); left: 0; width: max-content; }
.cc-pop > [role=option] { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 4px 10px; border-radius: var(--r-sm); cursor: pointer; }
.cc-pop > [role=option]:hover, .cc-pop > [role=option].is-active { background: var(--inset-2); }
.cc-pop > [role=option][aria-disabled="true"] { color: var(--muted); cursor: not-allowed; background: none; }
.cc-pop .cc-opt-t { flex: 1; min-width: 0; }
.cc-pop .cc-opt-t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-pop .cc-opt-t small { display: block; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-pop .cc-opt-t b:not(:only-child) { font-weight: 600; }
.cc-pop > [role=option][aria-selected="true"] .cc-opt-t b { color: var(--accent-text); font-weight: 600; }
.cc-pop .cc-tick { width: 16px; height: 16px; color: var(--accent-text); stroke-width: 2.2; }
.cc-pop .pill { flex: none; height: 22px; padding: 0 8px; border-radius: var(--r-sm); background: var(--inset-2); color: var(--ink-2); font: 600 var(--fs-small)/1 var(--font-ui); letter-spacing: 0; }
.cc-pop > .cc-pop-blank { color: var(--muted); }
.cc-pop > .cc-pop-h { padding: 6px 10px 2px; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.cc-pop > .cc-pop-sep { height: 1px; margin: 5px 4px; background: var(--hair); }
.cc-pop > .cc-pop-none { padding: 8px 10px; color: var(--muted); }
/* the answer is on its way: the rows of the page before stay, quieter */
.cc-pop[aria-busy="true"] > [role=option] .cc-opt-t b { color: var(--ink-2); }
.cc-pop > .cc-pop-add { margin-top: 4px; color: var(--accent-text); font-weight: 600; }
.cc-pop > .cc-pop-add svg { width: 16px; height: 16px; }
/* a phone: the combobox's list is a bottom sheet with its own search box */
.cc-pop.cc-sheet {
  position: fixed; inset: auto 0 0 0; width: auto; min-width: 0; max-width: none; max-height: 70vh; padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
/* the scrim is the app's: dark in both themes (the ink is near white in the dark one), stronger there (section 12) */
.cc-pop.cc-sheet::backdrop { background: color-mix(in srgb, var(--map-bg) 38%, transparent); }
.cc-pop > .cc-pop-q { position: sticky; top: 0; z-index: 1; padding: 12px 0 8px; background: var(--surface); }
.cc-pop .cc-sheet-q {
  box-sizing: border-box; width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--edge); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink); font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui);
}
.cc-pop .cc-sheet-q:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring-ctl); }
.cc-pop.cc-sheet > [role=option] { min-height: 44px; }

/* ─── 7. File: a drop zone when empty, a tile when a file is in (2.13) ─── */
.calm .cc-file { display: grid; gap: 8px; }
.calm .cc-drop {
  display: flex; align-items: center; gap: 14px; position: relative; padding: 14px 16px; border: 1.5px dashed var(--edge-2); border-radius: var(--r-lg);
  background: var(--inset); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
.calm .cc-drop:hover { border-color: var(--ink-2); }
.calm .cc-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.calm .cc-drop:focus-within { border-color: var(--accent); box-shadow: var(--ring-ctl); }
.calm .fld.invalid .cc-drop { border-color: var(--crit); }
.calm .cc-drop > .ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--hair); color: var(--accent-text); }
.calm .cc-drop > .ico svg { width: 18px; height: 18px; }
.calm .cc-drop > .cc-drop-t { display: block; flex: 1; min-width: 0; }
.calm .cc-drop b { display: block; font-weight: 600; color: var(--ink); }
.calm .cc-drop small { display: block; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.calm .cc-drop small:empty { display: none; }
/* the input lies over the zone, unseen: it keeps the click, a native drop and the keyboard's focus */
.calm .cc-drop > input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.calm .cc-drop .cc-drop-or { position: relative; z-index: 1; display: inline-block; padding: 10px 0; color: var(--accent-text); font-weight: 600; }
.calm .cc-file.has-file > .cc-drop, .calm .cc-file.is-busy > .cc-drop, .calm .cc-file.is-empty > .file-cur { display: none; }
.calm .cc-file.has-file, .calm .cc-file.is-busy {
  grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 12px; padding: 10px 12px 10px 10px; border: 1px solid var(--hair);
  border-radius: var(--r-lg); background: var(--surface);
}
.calm .cc-file .cc-thumb { display: grid; place-items: center; grid-row: span 2; width: 40px; height: 48px; border-radius: var(--r-sm); background: var(--inset-2); box-shadow: 0 0 0 1px var(--hair); color: var(--muted); overflow: hidden; }
.calm .cc-file .cc-thumb[hidden], .calm .cc-file .cc-busy[hidden] { display: none; }
.calm .cc-file .cc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.calm .cc-file .cc-thumb svg { width: 18px; height: 18px; }
.calm .cc-file .file-cur { font-size: var(--fs-ctl); gap: 4px 10px; }
.calm .cc-file .file-cur .file-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.calm .cc-file .file-cur .file-link:hover { color: var(--accent-text); text-decoration: underline; }
.calm .cc-file .file-cur [data-file-clear] { margin-left: auto; border-color: transparent; background: transparent; color: var(--ink-2); }
.calm .cc-file .file-cur [data-file-clear]:hover { background: var(--inset-2); color: var(--crit-text); }
.calm .cc-file .cc-busy { grid-column: 2; height: 3px; border-radius: var(--r-xs); background: var(--inset-2); }
.calm .cc-file .cc-another { display: none; justify-self: start; grid-column: 1 / -1; cursor: pointer; }
.calm .fld.invalid .cc-file .cc-another { display: inline-flex; }

/* ─── 8. The lines editor: a sheet or a row list (2.13) ─── */
.calm .lines, .calm .lines.sheet { border: 1px solid var(--hair); border-radius: var(--r-lg); background: var(--surface); }
.calm .lines table { font-size: var(--fs-ctl); }
.calm .lines .ln-head { display: flex; justify-content: flex-end; padding: 6px 8px 0; }
.calm .lines .ln-foot { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-top: 1px solid var(--hair); }
.calm .lines .ln-hint { display: inline; margin-left: auto; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); text-align: right; }
.calm .lines [data-add-row] { margin: 0; color: var(--accent-text); }
.calm .lines [data-del-row] { color: var(--muted); }
.calm .lines [data-del-row]:hover { color: var(--crit-text); border-color: transparent; background: var(--crit-soft); }
.calm .lines thead th {
  padding: 9px 8px; border-bottom: 1px solid var(--hair); background: transparent; color: var(--muted);
  font: 600 var(--fs-small)/var(--lh-small) var(--font-ui); letter-spacing: 0; text-transform: none;
}
.calm .lines th.r, .calm .lines td.r, .calm .lines td.r input { text-align: right; }
.calm .lines tbody td { padding: 3px 4px; border-bottom: 1px solid var(--hair); background: transparent; font-size: var(--fs-ctl); vertical-align: middle; }
.calm .lines tbody tr:hover td { background: transparent; }
.calm .lines tbody tr:last-child td { border-bottom: 1px solid var(--hair); }
.calm .lines .ln-n { display: table-cell; width: 28px; padding-left: 16px; color: var(--muted); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.calm .lines .ln-line { display: none; }
.calm .lines td.ln-x { width: 40px; padding-right: 10px; text-align: right; white-space: nowrap; }
.calm .lines .col-x { display: none; }
.calm .lines.show-x .col-x { display: table-cell; }
.calm .lines tfoot { display: table-footer-group; }
.calm .lines tfoot td { padding: 3px 4px; }
.calm .lines .ln-sum td { padding: 9px 8px; border-top: 1px solid var(--hair); color: var(--muted); font-size: var(--fs-body); }
.calm .lines .ln-sum .ln-sum-l { position: relative; }
.calm .lines .ln-sum .ln-sum-l .ln-sum-w { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); white-space: nowrap; }
.calm .lines .ln-sum b { padding-right: 5px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
/* a switch in a cell: the toggle alone */
.calm .cc-switch > input[type=checkbox] {
  position: relative; flex: none; width: 36px; height: 20px; min-height: 0; margin: 0; border: 0; border-radius: var(--r-pill); background: var(--edge);
  appearance: none; cursor: pointer; transition: background var(--t-fast); vertical-align: middle;
}
.calm .cc-switch > input[type=checkbox]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--e-card); transition: transform var(--t-fast); }
.calm .cc-switch > input[type=checkbox]:checked { background: var(--accent); }
.calm .cc-switch > input[type=checkbox]:checked::before { transform: translateX(16px); }
.calm .cc-switch > input[type=checkbox]:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (min-width: 768px) {
  /* a sheet: one row a line; a cell's control has no box at rest, only a hairline under it (forms.css sets that edge);
     the full box and the ring come with the focus */
  .calm .lines.sheet [data-ln-edit], .calm .lines.sheet [data-ln-done] { display: none; }
  /* the width goes to the columns a person reads: a number and a date keep a width that shows them whole, a select is as
     wide as its longest choice, text and linked records share the rest. A sheet too wide for its box is shown as the row
     list (controls.js wireLines() measures it); should it ever scroll, Remove stays in view */
  .calm .lines.sheet th.r, .calm .lines.sheet td.r { width: 104px; }
  .calm .lines.sheet td:has(> .cc-when) { width: 140px; }
  .calm .lines.sheet td:has(> .cc-switch) { width: 56px; }
  .calm .lines.sheet td.ln-x { position: sticky; right: 0; background: var(--surface); }
  .calm .lines.sheet .cc.compact:has(> select:not([multiple]))::after { right: 8px; bottom: calc((var(--h-ctl-sm) - 16px) / 2); }
  .calm .lines.sheet .cc.compact:has(> select:disabled)::after { display: none; }
  .calm .lines.sheet .cc-combo.compact > .cc-affix {
    height: var(--h-ctl-sm); min-width: 140px; padding: 0 8px; border-color: transparent; border-bottom-color: var(--hair); border-radius: var(--r-sm); background: transparent;
  }
  .calm .lines.sheet .cc-combo.compact > .cc-affix:hover { border-bottom-color: var(--edge-2); }
  .calm .lines.sheet .cc-combo.compact > .cc-affix:focus-within { border-color: var(--accent); background: var(--surface); }
  .calm .lines.sheet .cc-combo.compact .cc-ico { display: none; }
  /* a row list (a table of more than 6 columns without a money column): each row a block, closed to one line */
  .calm .lines.rows { overflow: hidden; }
  .calm .lines.rows table, .calm .lines.rows tbody, .calm .lines.rows tfoot { display: block; }
  .calm .lines.rows thead { display: none; }
  .calm .lines.rows tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; padding: 12px 16px; border-bottom: 1px solid var(--hair); }
  .calm .lines.rows tbody td { display: none; padding: 0; border: 0; }
  .calm .lines.rows tbody tr:last-child td { border: 0; }
  .calm .lines.rows tbody td.ln-n { display: flex; align-items: center; gap: 12px; width: auto; min-width: 0; padding: 0; color: var(--ink); font-size: var(--fs-ctl); cursor: pointer; }
  .calm .lines.rows tbody td.ln-x { display: flex; align-items: center; gap: 4px; width: auto; padding: 0; }
  .calm .lines.rows .ln-no { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: var(--r-pill); background: var(--inset-2); color: var(--ink-2); font: 600 var(--fs-xs)/1 var(--font-ui); }
  .calm .lines.rows .ln-line { display: block; min-width: 0; }
  .calm .lines.rows .ln-line b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calm .lines.rows .ln-line b.is-empty { color: var(--muted); font-weight: 400; }
  .calm .lines.rows .ln-line small { display: block; color: var(--muted); font-size: var(--fs-body); line-height: var(--lh-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calm .lines.rows tbody [data-ln-edit] { display: inline-flex; }
  .calm .lines.rows [data-ln-done] { display: none; }
  .calm .lines.rows tbody tr.is-open { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--sp-4) var(--sp-5); padding: 16px 16px 14px; background: var(--inset); }
  .calm .lines.rows tbody tr.is-open td { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .calm .lines.rows tbody tr.is-open td[data-label]::before { content: attr(data-label); color: var(--ink); font: 600 var(--fs-body)/var(--lh-body) var(--font-ui); }
  .calm .lines.rows tbody tr.is-open td[data-label][data-req]::before { content: attr(data-label) " *"; }
  .calm .lines.rows tbody tr.is-open td.ln-n { grid-column: 1 / -1; flex-direction: row; align-items: center; cursor: default; }
  .calm .lines.rows tbody tr.is-open td.ln-x { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; gap: 8px; }
  .calm .lines.rows tbody tr.is-open [data-ln-edit] { display: none; }
  .calm .lines.rows tbody tr.is-open [data-ln-done] { display: inline-flex; }
  .calm .lines.rows tbody tr.is-open td.r, .calm .lines.rows tbody tr.is-open td.r input { text-align: left; }
  /* a sheet shown as the row list (it did not fit): a closed row hides the extra columns too, an open one shows every
     column, and the columns button stays only while it is what made the sheet too wide */
  .calm .lines.rows.show-x tbody tr:not(.is-open) td.col-x { display: none; }
  .calm .lines.rows:not(.show-x) .ln-head { display: none; }
  /* a new row opens as its own editor: the ghost row is a sheet's. The foot keeps the sum: its words and the figure on one line */
  .calm .lines.rows tfoot tr.ln-ghost, .calm .lines.rows .ln-hint { display: none; }
  .calm .lines.rows .ln-sum:not([hidden]) { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 16px; }
  .calm .lines.rows .ln-sum td { display: none; padding: 0; border: 0; }
  .calm .lines.rows .ln-sum td.ln-sum-l, .calm .lines.rows .ln-sum td.ln-sum-v { display: block; }
  .calm .lines.rows .ln-sum .ln-sum-l .ln-sum-w { position: static; transform: none; }
}

/* ─── 9. A warning under a field, and the block of a refused save (2.15, 3.10) ─── */
.cf-guard {
  display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--warn-line); border-radius: var(--r-lg); background: var(--warn-soft);
  color: var(--ink); font: 400 var(--fs-ctl)/var(--lh-ctl) var(--font-ui);
}
.cf-guard h3, .cf-guard h4 { margin: 0; color: var(--ink); font: 600 var(--fs-ctl)/var(--lh-ctl) var(--font-ui); }
.cf-guard p { margin: 0; color: var(--ink-2); }
.cf-guard .rule { margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.cf-guard .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.cf-guard.block { border: 1px solid var(--hair); border-left: 3px solid var(--crit); background: var(--surface); color: var(--ink); box-shadow: var(--e-card); }
.cf-guard.block:focus { outline: none; box-shadow: var(--e-card), var(--focus-ring); }

/* the docked action bar (3.9): core/controls.js dockBar() marks a sticky bar is-docked and measures the pane round it
   into --dock-l, --dock-r and --dock-b; the bar then lies on the pane's bottom edge, as wide as the pane, its content in
   line with the column it sits in. (The generic form's bar repeats this in forms.css, over its older rule.) */
.calm .is-docked {
  position: sticky; bottom: calc(-1 * var(--dock-b, 0px)); z-index: 20; box-sizing: border-box; min-height: 64px;
  margin-right: calc(-1 * var(--dock-r, 0px)); margin-bottom: calc(-1 * var(--dock-b, 0px)); margin-left: calc(-1 * var(--dock-l, 0px));
  padding-right: var(--dock-r, var(--sp-4)); padding-left: var(--dock-l, var(--sp-4)); border: 0; border-top: 1px solid var(--hair); border-radius: 0;
  background: var(--surface); box-shadow: var(--e-bar); backdrop-filter: none;
}

/* ─── 10. The language button of the top bar (2.16): the shell's one new control ─── */
.btn.lang-btn { flex: none; font-family: var(--font-ui); }
.app.shell.desk .btn.lang-btn { height: var(--control-h); padding: 0 9px; color: var(--ink-2); font-size: var(--fs-small); }
.app.shell.desk .btn.lang-btn:hover { color: var(--ink); }
.app.shell.desk .btn.lang-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ─── 11. Phones: 44 px controls and 16 px text come from the tokens; every lines table is a list of cards ─── */
@media (max-width: 767px) {
  .btn.lang-btn { display: none; }
  /* touch targets: 44 px controls and 38 px buttons come from the tokens; nothing a finger presses is under 36 px */
  .calm .btn.xs { height: 36px; padding: 0 12px; }
  .calm .cc-clear { width: 36px; height: 36px; margin-right: -6px; }
  .calm .cc-clear::after, .calm .cc-tok button::after, .calm .cc-date > .tail .btn::after { content: none; }
  .calm .cc-tok { height: 38px; }
  .calm .cc-tok button { width: 36px; height: 36px; }
  /* a segmented option is 44 px to press: the trough's 3 px are the option's own padding here, the pill inside is as before */
  .calm .cc-seg[data-cc-on="seg"] { display: flex; flex-wrap: wrap; gap: 0; height: auto; padding: 0 2px; }
  .calm .cc-seg-o { flex: 1 1 auto; min-height: 44px; padding: 3px 1px; }
  .calm .cc-seg-o > span { width: 100%; }
  .calm .cc-date > .tail .btn { height: 36px; padding: 0 10px; }
  /* a row's buttons (Edit, Done, Remove) are 44 px to press */
  .calm .lines .ln-x .btn { height: 44px; min-width: 44px; }
  .calm .lines .ln-x .btn.icon { width: 44px; }
  .calm .lines { overflow: hidden; }
  .calm .lines table, .calm .lines tbody, .calm .lines tfoot { display: block; }
  .calm .lines thead { display: none; }
  .calm .lines tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; padding: 12px 14px; border-bottom: 1px solid var(--hair); }
  .calm .lines tbody td { display: none; padding: 0; border: 0; }
  .calm .lines tbody tr:last-child td { border-bottom: 0; }
  .calm .lines tbody td.ln-n { display: flex; align-items: center; gap: 12px; width: auto; min-width: 0; padding: 0; color: var(--ink); cursor: pointer; }
  .calm .lines tbody td.ln-x { display: flex; align-items: center; gap: 4px; width: auto; padding: 0; }
  .calm .lines .ln-no { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: var(--r-pill); background: var(--inset-2); color: var(--ink-2); font: 600 var(--fs-xs)/1 var(--font-ui); }
  .calm .lines .ln-line { display: block; min-width: 0; }
  .calm .lines .ln-line b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calm .lines .ln-line b.is-empty { color: var(--muted); font-weight: 400; }
  .calm .lines .ln-line small { display: block; color: var(--muted); font-size: var(--fs-body); line-height: var(--lh-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calm .lines tbody [data-ln-edit] { display: inline-flex; }
  .calm .lines [data-ln-done] { display: none; }
  .calm .lines tbody tr.is-open { grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--sp-3); padding: 14px; background: var(--inset); }
  .calm .lines tbody tr.is-open td, .calm .lines.show-x tbody tr.is-open td.col-x { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .calm .lines tbody tr.is-open td.col-x { display: flex; }
  .calm .lines tbody tr.is-open td[data-label]::before { content: attr(data-label); color: var(--ink); font: 600 var(--fs-body)/var(--lh-body) var(--font-ui); }
  .calm .lines tbody tr.is-open td[data-label][data-req]::before { content: attr(data-label) " *"; }
  .calm .lines tbody tr.is-open td.r, .calm .lines tbody tr.is-open td.r input { text-align: left; }
  .calm .lines tbody tr.is-open td.ln-n { flex-direction: row; align-items: center; cursor: default; }
  .calm .lines tbody tr.is-open td.ln-x { flex-direction: row; justify-content: flex-end; gap: 8px; }
  .calm .lines tbody tr.is-open [data-ln-edit] { display: none; }
  .calm .lines tbody tr.is-open [data-ln-done] { display: inline-flex; }
  .calm .lines tfoot tr { display: block; }
  .calm .lines tfoot tr[hidden], .calm .lines tfoot tr.ln-ghost { display: none; }
  .calm .lines tfoot td { display: block; padding: 6px 10px; }
  .calm .lines tfoot td.ln-n, .calm .lines .ln-head, .calm .lines .ln-hint { display: none; }
  /* the foot's sum: its words and the figure on one line */
  .calm .lines .ln-sum:not([hidden]) { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--hair); }
  .calm .lines .ln-sum td { display: none; padding: 0; border: 0; }
  .calm .lines .ln-sum td.ln-sum-l, .calm .lines .ln-sum td.ln-sum-v { display: block; }
  .calm .lines .ln-sum .ln-sum-l .ln-sum-w { position: static; transform: none; }
}

/* ─── 12. Dark theme: the sheet's backdrop is stronger, and a list or a menu gets an edge (its fill is the card's own) ─── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cc-pop.cc-sheet::backdrop { background: color-mix(in srgb, var(--map-bg) 62%, transparent); }
  :root:not([data-theme="light"]) .cc-pop, :root:not([data-theme="light"]) .menu.cc-menu, :root:not([data-theme="light"]) .calm .menu { box-shadow: 0 0 0 1px color-mix(in srgb, var(--edge) 55%, transparent), var(--e-pop); }
}
:root[data-theme="dark"] .cc-pop.cc-sheet::backdrop { background: color-mix(in srgb, var(--map-bg) 62%, transparent); }
:root[data-theme="dark"] .cc-pop, :root[data-theme="dark"] .menu.cc-menu, :root[data-theme="dark"] .calm .menu { box-shadow: 0 0 0 1px color-mix(in srgb, var(--edge) 55%, transparent), var(--e-pop); }
