/* Kubinu kit base: the shell and the primitives every screen uses. Every colour, size and font comes from
   tokens.css (--k-*). No colour literals, no gradients, no decorative shadows (tests/ui enforces it).
   Shadows appear only on layers that float: menus, dialogs, toasts, glass. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--k-top-bar) + 12px); scrollbar-color: var(--k-outline) transparent; }
body { margin: 0; min-height: 100dvh; background: var(--k-bg); color: var(--k-fg); font: var(--k-body-l); overflow-wrap: break-word; }
img, svg { max-width: 100%; }
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: var(--k-link); text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--k-secondary-container); color: var(--k-on-secondary-container); }
[hidden] { display: none !important; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -80px; z-index: 100; padding: 10px 16px; border-radius: var(--k-radius-md); background: var(--k-primary); color: var(--k-on-primary); }
.skip:focus { top: 8px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 16px; height: 16px; }
.ico--fill { fill: currentColor; stroke: none; }
.mono { font-family: var(--k-font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
b, strong { font-weight: 600; }
.mono b, b.mono, .mono strong, strong.mono { font-weight: 500; }
.muted { color: var(--k-fg-muted); }
.display { font: var(--k-headline-s); letter-spacing: -0.01em; }
.k-num--xl { font: var(--k-number-xl); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.eyebrow { display: flex; align-items: center; gap: 10px; font: var(--k-label-m); text-transform: uppercase; letter-spacing: .08em; color: var(--k-secondary); }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--k-accent); rotate: 20deg; flex: none; }
.eyebrow--plain::before { content: none; }
.lead { font: var(--k-body-l); color: var(--k-fg-muted); }

/* every grid and flex child may shrink: long names and numbers wrap or ellipsise instead of pushing the page wide */
:where(.shell, .main, .topbar, .rail-in, .nav, .sheet-nav, .menu-pop, .page-head, .actions, .stack, .grid-2, .grid-3, .grid-aside, .bento, .tile,
  .card, .card-head, .banner, .banners, .field, .form-grid, .chips, .filters, .search, .pager, .kv, .tabs, .dlg, .foot, .toast, .empty, .footer,
  .legend-box, .limits, .auth, .auth-side, .auth-top, .auth-panel, .sheet-head, .switcher, .check, .brand, .who) > * { min-width: 0; }

/* logos: full colour on light, reversed on dark */
.logo-dark { display: none; }
[data-theme="kubinu-dark"] .logo-light { display: none; }
[data-theme="kubinu-dark"] .logo-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .logo-light { display: none; }
  :root:not([data-theme]) .logo-dark { display: inline-block; }
}

/* ---------- the product tile ---------- */
.tile-icon { width: 32px; height: 32px; flex: none; color: var(--k-fg); overflow: visible; }
.tile-icon--sm { width: 20px; height: 20px; }
.tile-icon--lg { width: 40px; height: 40px; }
.tile-icon--xl { width: 72px; height: 72px; }
.tile-icon .ti-on { fill: currentColor; }
.tile-icon .ti-off { fill: currentColor; opacity: .16; }
.tile-icon .ti-lift { fill: var(--k-accent); transform-box: fill-box; transform-origin: center; transform: translate(1.5px, .5px) rotate(20deg); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
.rail { display: none; }
.main { display: flex; flex-direction: column; min-height: 100dvh; }
.page { width: 100%; max-width: 1440px; margin: 0 auto; padding: 16px 16px 32px; flex: 1; }
.page--center { display: grid; place-content: center; justify-items: center; }
.page--narrow { max-width: 46rem; }
.grow { flex: 1; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; min-height: var(--k-top-bar); padding: 8px 16px;
  background: var(--k-bg); border-bottom: 1px solid var(--k-outline-variant); }
.topbar > * { flex: none; }
.topbar > .grow { flex: 1; }
.brand { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 44px; min-height: 44px; color: var(--k-fg); text-decoration: none; border-radius: var(--k-radius-md); }
.brand img { height: 32px; width: auto; }
.product-name { font: var(--k-title-l); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.topbar > .product-name { margin-right: 4px; }
.topbar > .menu--start { flex: 0 1 auto; }
.switcher { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; max-width: 100%; padding: 0 8px 0 14px; border-radius: var(--k-radius-full);
  background: var(--k-surface); border: 1px solid var(--k-outline-variant); text-decoration: none; color: var(--k-fg); font: var(--k-label-l); }
.switcher > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.switcher .ico { width: 20px; height: 20px; color: var(--k-fg-muted); transition: rotate var(--k-dur-effects) var(--k-ease-effects); }
.menu[open] > .switcher .ico { rotate: 180deg; }
.switcher:hover { border-color: var(--k-outline); }
.sample-chip { min-height: 28px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 240px; max-width: min(360px, calc(100vw - 32px)); padding: 8px; background: var(--k-surface);
  border: 1px solid var(--k-outline-variant); border-radius: var(--k-radius-lg); box-shadow: var(--k-shadow-2); }
.menu--start .menu-pop { left: 0; right: auto; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; background: none;
  border-radius: var(--k-radius-md); text-decoration: none; color: var(--k-fg); text-align: left; cursor: pointer; font: var(--k-label-l); }
.menu-pop a:hover, .menu-pop button:hover { background: var(--k-surface-high); }
.menu-pop a[aria-current="true"] { background: var(--k-surface-high); font-weight: 600; }
.menu-pop a > .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop form { margin: 0; }
.menu-pop hr, .sheet-nav hr { border: 0; border-top: 1px solid var(--k-outline-variant); margin: 8px 4px; }
.menu-pop .ico { width: 20px; height: 20px; }
.menu-label { padding: 6px 12px 4px; font: var(--k-label-s); text-transform: uppercase; letter-spacing: .08em; color: var(--k-fg-muted); }
.who { display: grid; gap: 2px; padding: 8px 12px 10px; font: var(--k-body-s); color: var(--k-fg-muted); overflow-wrap: anywhere; }
.who b { font: var(--k-title-s); color: var(--k-fg); }

.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border-radius: var(--k-radius-full); border: 0; background: transparent;
  color: var(--k-fg); cursor: pointer; transition: background var(--k-dur-effects) var(--k-ease-effects), border-radius var(--k-dur-spatial) var(--k-ease-spatial); }
.icon-btn:hover { background: var(--k-surface-high); }
.icon-btn:active { border-radius: var(--k-radius-md); background: var(--k-surface-highest); }
.icon-btn--outlined { border: 1px solid var(--k-outline); }
.theme-toggle .sun { display: none; }
[data-theme="kubinu-dark"] .theme-toggle .sun { display: block; }
[data-theme="kubinu-dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .sun { display: block; }
  :root:not([data-theme]) .theme-toggle .moon { display: none; }
}

/* navigation: the rail from 600 px, the sheet on phones.
   The rail fits its items to the window. A slot is the room under the brand shared between the items (:has() counts them, up to
   sixteen): never under 3.125rem, which keeps a 44 px target and its label, never over 4.125rem. What still does not fit scrolls
   inside the list, and a button at the edge says there is more (ui.js); without the script the list shows its scrollbar. */
.nav { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden auto; overscroll-behavior: contain;
  scroll-padding-block: 2.5rem 3.25rem; scrollbar-width: thin; scrollbar-color: var(--k-outline) transparent;
  --nav-n: 8; --nav-slot: clamp(3.125rem, calc((100dvh - var(--k-top-bar) - 2.75rem) / var(--nav-n)), 4.125rem);
  --nav-pill: clamp(1.75rem, calc(var(--nav-slot) - 1.375rem), 2rem); }
.nav:has(> a:nth-of-type(9)) { --nav-n: 9; } .nav:has(> a:nth-of-type(10)) { --nav-n: 10; } .nav:has(> a:nth-of-type(11)) { --nav-n: 11; }
.nav:has(> a:nth-of-type(12)) { --nav-n: 12; } .nav:has(> a:nth-of-type(13)) { --nav-n: 13; } .nav:has(> a:nth-of-type(14)) { --nav-n: 14; }
.nav:has(> a:nth-of-type(15)) { --nav-n: 15; } .nav:has(> a:nth-of-type(16)) { --nav-n: 16; }
.nav a { display: grid; flex: none; justify-items: center; align-content: center; gap: 2px; min-height: var(--nav-slot); padding: 2px 0; border-radius: var(--k-radius-lg);
  text-decoration: none; color: var(--k-fg-muted); font: var(--k-label-l); font-size: .6875rem; line-height: 1rem; letter-spacing: -.01em; }
.nav a:focus-visible { outline-offset: -2px; }
/* a two-word label ("Django admin", "Audit log") wraps to a second line instead of being cut */
.nav-label { max-width: 100%; padding-inline: 2px; text-align: center; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.nav a .pill { display: grid; place-items: center; width: 56px; height: var(--nav-pill); border-radius: var(--k-radius-full);
  transition: background var(--k-dur-spatial) var(--k-ease-spatial); }
.nav a:hover .pill { background: var(--k-surface-high); }
.nav a[aria-current="page"] { color: var(--k-fg); font-weight: 600; }
.nav a[aria-current="page"] .pill { background: var(--k-primary-container); color: var(--k-on-primary-container); }
.nav .sep { flex: none; height: 1px; margin: 6px 12px; background: var(--k-outline-variant); }
.rail-more { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: grid; justify-items: center; align-content: center; min-height: var(--k-touch); padding: 2px 0;
  border: 0; border-top: 1px solid var(--k-outline-variant); background: var(--k-bg); color: var(--k-fg); font: var(--k-label-l); font-size: .6875rem; line-height: 1rem; cursor: pointer; }
.rail-more--up { top: var(--k-top-bar); bottom: auto; min-height: 2rem; border-top: 0; border-bottom: 1px solid var(--k-outline-variant); }
.rail-more--up .ico { rotate: 180deg; }
.rail-more .ico { width: 20px; height: 20px; }
.rail-more:hover { background: var(--k-surface-high); }
/* data-theme is set by the script in the page head, so it means scripts run: the buttons are the cue, and the scrollbar gives its room back */
:root[data-theme] .nav { padding-inline: 4px; scrollbar-width: none; }
:root[data-theme] .nav::-webkit-scrollbar { display: none; }
.sheet-nav { display: grid; gap: 2px; }
.sheet-nav a, .sheet-nav button { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 52px; padding: 0 16px; border: 0; background: none; border-radius: var(--k-radius-full);
  text-decoration: none; color: var(--k-fg); font: var(--k-label-l); text-align: left; cursor: pointer; }
.sheet-nav a > span, .sheet-nav button > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-nav a:hover, .sheet-nav button:hover { background: var(--k-surface-high); }
.sheet-nav a[aria-current="page"] { background: var(--k-primary-container); color: var(--k-on-primary-container); font-weight: 600; }
.sheet-nav form { margin: 0; }
.sheet-nav .who { padding-inline: 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.only-wide { display: none; }

.banners { display: grid; }
.footer { padding: 16px; border-top: 1px solid var(--k-outline-variant); color: var(--k-fg-muted); font: var(--k-body-s); display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; align-items: center; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--k-fg-muted); }
.shell--map .footer { display: none; }

@media (max-width: 599px) {
  .topbar { gap: 6px; }
  .topbar:has(.switcher) > .product-name { display: none; }
  .switcher > span { max-width: 9rem; }
  .sample-chip .ico { display: none; }
  .footer { flex-direction: column; align-items: flex-start; }
}
@media (min-width: 600px) {
  .shell { grid-template-columns: var(--k-rail) minmax(0, 1fr); }
  .shell--norail, .shell--bare { grid-template-columns: minmax(0, 1fr); }
  .rail { display: block; background: var(--k-bg); border-right: 1px solid var(--k-outline-variant); z-index: 31; }
  .rail-in { display: flex; flex-direction: column; align-items: stretch; position: sticky; top: 0; height: 100dvh; padding: 0 0 8px; }
  .rail-in .brand { min-height: var(--k-top-bar); flex: none; }
  .rail-in .tile-icon { width: 36px; height: 36px; }
  .only-compact { display: none !important; }
  .only-wide { display: revert; }
  .page { padding: 24px 24px 40px; }
  .topbar { padding-inline: 24px; gap: 12px; }
  .footer { padding-inline: 24px; }
}
@media (min-width: 1200px) {
  .page { padding: 24px 32px 48px; }
  .topbar, .footer { padding-inline: 32px; }
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; min-height: 44px; max-width: 100%; padding: 0 20px; border: 1px solid transparent;
  border-radius: var(--k-radius-full); background: var(--k-primary); color: var(--k-on-primary); font: var(--k-label-l); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: border-radius var(--k-dur-spatial) var(--k-ease-spatial), background var(--k-dur-effects) var(--k-ease-effects); }
.btn:hover { background: color-mix(in srgb, var(--k-primary) 86%, var(--k-bg)); }
.btn:active { border-radius: var(--k-radius-md); }
.btn--accent { background: var(--k-secondary); color: var(--k-on-secondary); }   /* the one commit on a page; white text sits on laterite deep only */
.btn--accent:hover { background: color-mix(in srgb, var(--k-secondary) 88%, var(--k-fg)); }
.btn--tonal { background: var(--k-primary-container); color: var(--k-on-primary-container); }
.btn--tonal:hover { background: color-mix(in srgb, var(--k-primary-container) 86%, var(--k-fg)); }
.btn--outline { background: transparent; color: var(--k-fg); border-color: var(--k-outline); }
.btn--outline:hover { background: var(--k-surface-high); }
.btn--text { background: transparent; color: var(--k-link); padding-inline: 12px; }
.btn--text:hover { background: var(--k-surface-high); }
.btn--danger { background: var(--k-error); color: var(--k-on-error); }
.btn--danger:hover { background: color-mix(in srgb, var(--k-error) 88%, var(--k-fg)); }
.btn--sm { padding-inline: 14px; }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--k-surface-high); color: var(--k-fg-disabled); border-color: transparent; cursor: not-allowed; }
.btn .ico { width: 20px; height: 20px; }
.btn.is-busy { position: relative; color: transparent; pointer-events: none; }
/* the busy mark is the brand's lifted tile; on a coloured button it takes that button's text colour so it stays visible */
.btn { --busy: var(--k-accent); }
.btn--accent { --busy: var(--k-on-secondary); }
.btn--danger { --busy: var(--k-on-error); }
.btn--tonal { --busy: var(--k-on-primary-container); }
.btn[disabled], .btn[aria-disabled="true"] { --busy: var(--k-accent); }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: var(--k-radius-xs); background: var(--busy); animation: lift 900ms var(--k-ease-spatial) infinite alternate; }
@keyframes lift { from { transform: rotate(0); } to { transform: rotate(20deg); } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions--center { justify-content: center; }
.actions--end { justify-content: flex-end; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field label, .field .lbl { font: var(--k-label-l); }
.field .req { margin-left: 2px; color: var(--k-secondary); }
.field .help, .help { font: var(--k-body-s); color: var(--k-fg-subtle); }
.field .err, .err { display: flex; gap: 6px; align-items: flex-start; font: var(--k-body-s); color: var(--k-error); }
.input, :where(.field) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="hidden"]), select, textarea) {
  width: 100%; min-height: var(--k-field-h); padding: 0 14px; background: var(--k-surface-lowest); color: var(--k-fg);
  border: 1px solid var(--k-outline); border-radius: var(--k-radius-sm); }
textarea.input, :where(.field) textarea { padding-block: 12px; min-height: 120px; resize: vertical; }
select[multiple].input, :where(.field) select[multiple] { padding: 8px; min-height: 132px; }
.input::placeholder, :where(.field) :is(input, textarea)::placeholder { color: var(--k-fg-subtle); opacity: 1; }
.input:focus, :where(.field) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]), select, textarea):focus { outline: 2px solid var(--k-focus); outline-offset: 0; border-color: var(--k-focus); }
.input:disabled, :where(.field) :is(input, select, textarea):disabled { color: var(--k-fg-disabled); background: var(--k-surface-high); cursor: not-allowed; }
.input[aria-invalid="true"], :where(.field) :is(input, select, textarea)[aria-invalid="true"], .has-error :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { border-color: var(--k-error); border-width: 2px; }
.field--mono :is(input, textarea) { font-family: var(--k-font-mono); font-variant-numeric: tabular-nums; }
:where(.field) input[type="file"] { width: 100%; min-height: var(--k-field-h); padding: 6px; background: var(--k-surface-lowest); border: 1px dashed var(--k-outline); border-radius: var(--k-radius-sm); font: var(--k-body-m); }
input[type="file"]::file-selector-button { min-height: 34px; margin-right: 12px; padding: 0 14px; border: 0; border-radius: var(--k-radius-full); background: var(--k-primary-container); color: var(--k-on-primary-container); font: var(--k-label-l); cursor: pointer; }
:where(.field) :is(input[type="radio"], input[type="checkbox"]) { accent-color: var(--k-secondary); width: 20px; height: 20px; margin: 0 10px 0 0; flex: none; }
:where(.field) :is(div, ul) > :is(div, li) > label { display: flex; align-items: center; min-height: 44px; font: var(--k-body-l); cursor: pointer; }
:where(.field) ul { margin: 0; padding: 0; list-style: none; }
.pw { position: relative; }
.pw .input, .pw input { padding-right: 52px; }
.pw .icon-btn { position: absolute; right: 2px; top: 2px; }
.check { display: inline-flex; align-items: flex-start; gap: 2px; min-height: 44px; margin-left: -11px; cursor: pointer; }   /* the drawn box lines up with the fields above it */
.check-text { display: grid; gap: 2px; padding-block: 10px; font: var(--k-body-l); }
/* the input itself is the 44px hit area; the visible box is drawn inside it */
.check input[type="checkbox"] { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 44px; height: 44px; margin: 0; border: 0; background: transparent; cursor: pointer; }
.check input[type="checkbox"]::before { content: ""; position: absolute; inset: 11px; border: 2px solid var(--k-outline); border-radius: var(--k-radius-xs); background: var(--k-surface-lowest); }
.check input[type="checkbox"]:checked::before { background: var(--k-secondary); border-color: var(--k-secondary); }
.check input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 17px; top: 12px; width: 6px; height: 11px; border: solid var(--k-on-secondary); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check input[type="checkbox"]:focus-visible { outline: none; }
.check input[type="checkbox"]:focus-visible::before { outline: 2px solid var(--k-focus); outline-offset: 2px; }
.check input[type="checkbox"]:disabled::before { border-color: var(--k-fg-disabled); background: var(--k-surface-high); }
.switch { position: relative; display: inline-flex; align-items: center; min-width: 52px; min-height: 44px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch i { width: 52px; height: 32px; border-radius: var(--k-radius-full); background: var(--k-surface-highest); border: 2px solid var(--k-outline); position: relative;
  transition: background var(--k-dur-spatial) var(--k-ease-spatial); }
.switch i::after { content: ""; position: absolute; left: 4px; top: 4px; width: 16px; height: 16px; border-radius: var(--k-radius-full); background: var(--k-outline);
  transition: transform var(--k-dur-spatial) var(--k-ease-spatial), width var(--k-dur-spatial) var(--k-ease-spatial), background var(--k-dur-effects); }
.switch input:checked + i { background: var(--k-primary); border-color: var(--k-primary); }
.switch input:checked + i::after { transform: translateX(20px); width: 20px; height: 20px; top: 2px; background: var(--k-on-primary); }
.switch input:focus-visible + i { outline: 2px solid var(--k-focus); outline-offset: 2px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--k-radius-full); background: var(--k-surface-high); max-width: 100%; }
.seg :is(button, a) { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--k-radius-full); background: transparent; cursor: pointer; font: var(--k-label-l); color: var(--k-fg-muted); text-decoration: none; white-space: nowrap; }
.seg :is(button, a):is([aria-pressed="true"], [aria-selected="true"], [aria-current]) { background: var(--k-primary); color: var(--k-on-primary); }
.seg button:disabled { color: var(--k-fg-disabled); cursor: not-allowed; }

/* ---------- chips and status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 28px; max-width: 100%; padding: 0 10px; border: 1px solid transparent; border-radius: var(--k-radius-sm);
  font: var(--k-label-s); text-transform: uppercase; letter-spacing: .08em; background: var(--k-neutral-bg); color: var(--k-neutral-fg); white-space: nowrap; text-decoration: none; }
.chip .ico { width: 16px; height: 16px; }
.chip--success { background: var(--k-success-container); color: var(--k-on-success-container); }
.chip--warning { background: var(--k-warning-container); color: var(--k-on-warning-container); }
.chip--error { background: var(--k-error-container); color: var(--k-on-error-container); }
.chip--info { background: var(--k-info-container); color: var(--k-on-info-container); }
.chip--accent { background: var(--k-secondary-container); color: var(--k-on-secondary-container); }
.chip--outline { background: transparent; color: var(--k-fg); border-color: var(--k-outline); }
button.chip, a.chip.is-filter { min-height: 44px; padding-inline: 14px; border-color: var(--k-outline-variant); cursor: pointer; background: var(--k-surface); color: var(--k-fg); }
a.chip.is-filter:hover, button.chip:hover { border-color: var(--k-outline); }
/* a.chip.is-filter outweighs .chip.is-on, so the chosen filter is named in full here. */
.chip.is-on, a.chip.is-filter.is-on, a.chip.is-filter[aria-current], .chip[aria-pressed="true"] { background: var(--k-primary); color: var(--k-on-primary); border-color: transparent; }
.chip-count { font-family: var(--k-font-mono); font-size: .6875rem; font-variant-numeric: tabular-nums; opacity: .78; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- tables ---------- */
.table-wrap { background: var(--k-surface); border: 1px solid var(--k-outline-variant); border-radius: var(--k-radius-lg); overflow-x: auto; overflow-y: hidden; }
.tbl { width: 100%; border-collapse: collapse; font: var(--k-body-m); }
.tbl th { white-space: nowrap; text-align: left; padding: 12px 16px; background: var(--k-surface-high); font: var(--k-label-m); text-transform: uppercase; letter-spacing: .08em; color: var(--k-fg-muted); }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: var(--k-touch); min-width: var(--k-touch); box-sizing: border-box; }
.tbl th button:focus-visible { outline: 2px solid var(--k-focus); outline-offset: 2px; }
.tbl th[aria-sort] { color: var(--k-fg); }
.tbl td { padding: 12px 16px; border-top: 1px solid var(--k-outline-variant); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--k-surface-lowest); }
.tbl tr[data-href] { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--k-font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num button { justify-content: flex-end; }
.tbl .ac { display: block; color: var(--k-fg-muted); font: var(--k-body-s); }
.tbl a.row-link { color: var(--k-fg); font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.tbl a.row-link:hover { text-decoration: underline; }
.tbl td.wrap { overflow-wrap: anywhere; }
.tbl tfoot td, .tbl tfoot th { padding: 12px 16px; border-top: 1px solid var(--k-outline); background: var(--k-surface-high); font-weight: 600; text-align: left; }
.tbl tfoot .num { text-align: right; font-weight: 500; }
/* card rows under 840 px: a phone or a tablet in portrait cannot hold the full table without clipping it */
@media (max-width: 839px) {
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tbl, .tbl tbody, .tbl tfoot, .tbl tr, .tbl td { display: block; }
  .tbl tr { padding: 12px 16px; border-top: 1px solid var(--k-outline-variant); }
  .tbl tbody tr:first-child { border-top: 0; }
  .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; border: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  .tbl td > * { min-width: 0; }
  .tbl td .chips { justify-content: flex-end; }
  .tbl td::before { content: attr(data-label); flex: 0 0 7rem; overflow-wrap: normal; font: var(--k-label-s); text-transform: uppercase; letter-spacing: .08em; color: var(--k-fg-muted); text-align: left; }
  .tbl td.title { display: block; text-align: left; font-weight: 600; overflow-wrap: normal; word-break: normal; }
  .tbl td.title .ac { overflow-wrap: anywhere; font-weight: 400; }
  .tbl td[colspan] { display: block; text-align: center; padding: 0; }
  .tbl td[colspan]::before, .tbl td.title::before { content: none; }
  .tbl td.num { text-align: right; white-space: normal; }
  /* unlabelled action cells use the full row width instead of an empty label column */
  .tbl td[data-label=""], .tbl td:not([data-label]):not(.title) { display: block; padding-top: 8px; text-align: left; }
  .tbl td[data-label=""]::before, .tbl td:not([data-label])::before { content: none; }
  .tbl td[data-label=""] .actions { justify-content: flex-end; }
  .tbl tfoot tr { background: var(--k-surface-high); border-top-color: var(--k-outline); }
  .tbl tfoot td, .tbl tfoot th { padding: 4px 0; border: 0; background: none; }
}

/* ---------- panels, banners, the slot ---------- */
.card { background: var(--k-surface); border: 1px solid var(--k-outline-variant); border-radius: var(--k-radius-lg); padding: 16px; }
.card + .card { margin-top: 16px; }
.card > h2 { font: var(--k-title-l); margin-bottom: 8px; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack > .card + .card, .grid-2 > .card + .card, .grid-3 > .card + .card, .grid-aside > .card + .card, .bento > .card + .card { margin-top: 0; }  /* the gap already spaces them */
.grid-2, .grid-3, .grid-aside { display: grid; gap: 16px; align-items: start; }
@media (min-width: 840px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid-aside { grid-template-columns: minmax(0, 1fr) 22rem; } }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--k-radius-lg); background: var(--k-warning-container); color: var(--k-on-warning-container); font: var(--k-body-m); }
.banner > .ico { width: 20px; height: 20px; }
.banner a:not(.btn) { color: inherit; }
.banner-body { flex: 1; display: grid; gap: 2px; }
.banner > span { flex: 1; }
.banner-title { font: var(--k-title-s); }
.banner ul { margin: 0; padding-left: 1.1em; display: grid; gap: 2px; }
.banner-action { flex: none; align-self: center; margin: -4px 0; }
.banner .btn--outline { color: inherit; border-color: currentColor; }
.banner--info { background: var(--k-info-container); color: var(--k-on-info-container); }
.banner--error { background: var(--k-error-container); color: var(--k-on-error-container); }
.banner--success { background: var(--k-success-container); color: var(--k-on-success-container); }
.banner--support { background: var(--k-secondary-container); color: var(--k-on-secondary-container); }
.banner--neutral { background: var(--k-surface-high); color: var(--k-fg); }
.banner--flat { border-radius: 0; padding-inline: 16px; align-items: center; }
.banner--sticky, .banner--pinned { position: sticky; top: var(--k-top-bar); z-index: 25; }
@media (min-width: 600px) { .banner--flat { padding-inline: 24px; } }
@media (min-width: 1200px) { .banner--flat { padding-inline: 32px; } }
@media (max-width: 599px) { .banner { flex-wrap: wrap; } .banner > span, .banner-body { flex: 1 1 12rem; } .banner-action { margin: 0 0 0 32px; } }
.slot { display: grid; place-items: center; text-align: center; gap: 8px; padding: 24px 16px; min-height: 96px; color: var(--k-fg-muted); font: var(--k-body-m);
  border-radius: var(--k-radius-lg); border: 2px dashed var(--k-outline); }
.progress { height: 10px; border-radius: var(--k-radius-full); background: var(--k-surface-highest); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--k-primary); transition: width var(--k-dur-spatial) var(--k-ease-spatial); }
/* busy: the work has no known length, so the bar travels instead of filling */
.progress--busy > i { width: 35%; }
@media (prefers-reduced-motion: no-preference) { .progress--busy > i { animation: progress-busy 1.6s var(--k-ease-effects) infinite alternate; } }
@keyframes progress-busy { from { transform: translateX(-20%); } to { transform: translateX(206%); } }
.skeleton { background: var(--k-surface-high); border-radius: var(--k-radius-md); min-height: 16px; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: pulse 1.4s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- dialogs, sheets, toasts ---------- */
dialog { max-width: 560px; width: calc(100% - 32px); padding: 0; border: 1px solid var(--k-outline-variant); border-radius: var(--k-radius-xl); background: var(--k-surface); color: var(--k-fg); box-shadow: var(--k-shadow-4); }
dialog::backdrop { background: var(--k-scrim); }
dialog[open] { animation: pop var(--k-dur-spatial) var(--k-ease-spatial); }
@keyframes pop { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.dlg { padding: 24px; display: grid; gap: 16px; }
.dlg h2 { font: var(--k-title-l); }
.dlg .foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (max-width: 599px) {
  dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--k-radius-xl) var(--k-radius-xl) 0 0; border-bottom: 0; max-height: 92dvh; overflow-y: auto; }
  dialog.full { height: 100dvh; max-height: none; border-radius: 0; margin: 0; }
  .dlg { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .dlg .foot .btn { flex: 1 1 auto; }
}
.toasts { position: fixed; z-index: 90; inset: auto auto 16px 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toasts.toasts--top { inset: 16px auto auto 50%; }
.toast { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; min-height: 52px; border-radius: var(--k-radius-lg); background: var(--k-inverse-surface); color: var(--k-on-inverse-surface); font: var(--k-body-m);
  box-shadow: var(--k-shadow-3); pointer-events: auto; animation: tile-in var(--k-dur-spatial) var(--k-ease-spatial); }
.toast-text { flex: 1; padding-block: 6px; }
.toast-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; margin: -4px 0; padding: 0; border: 0; border-radius: var(--k-radius-full); background: transparent; color: inherit; cursor: pointer; }
.toast-close .ico { width: 20px; height: 20px; }
.toast-close:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.toast .btn--text { color: inherit; text-decoration: underline; }
.toast--error { background: var(--k-error-container); color: var(--k-on-error-container); border: 1px solid var(--k-error); }
.toast--warning { background: var(--k-warning-container); color: var(--k-on-warning-container); border: 1px solid var(--k-warning); }
.toast.is-leaving { animation: toast-out var(--k-dur-exit) var(--k-ease-exit) forwards; }
@keyframes tile-in { from { transform: rotate(8deg) translateY(12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog[open], .toast { animation: none; } }

/* ---------- small things ---------- */
.kv { display: grid; grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr); gap: 0 16px; margin: 0; font: var(--k-body-m); }
.kv dt, .kv dd { margin: 0; padding: 10px 0; border-top: 1px solid var(--k-outline-variant); }
.kv dt:first-of-type, .kv dd:first-of-type { border-top: 0; }
.kv dt { font: var(--k-label-s); line-height: 1.25rem; text-transform: uppercase; letter-spacing: .08em; color: var(--k-fg-muted); }
.kv dd { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--k-outline-variant); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 44px; padding: 0 16px; text-decoration: none; color: var(--k-fg-muted); font: var(--k-label-l); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--k-fg); }
.tabs a[aria-current="page"] { color: var(--k-secondary); border-color: var(--k-secondary); font-weight: 600; }
pre.log { margin: 0; padding: 12px; background: var(--k-surface-lowest); border: 1px solid var(--k-outline-variant); border-radius: var(--k-radius-md); font: var(--k-coord); max-height: 320px; overflow: auto; white-space: pre-wrap; }
code { font-family: var(--k-font-mono); font-size: .875em; }
