/* ==========================================================================
   Soul Sounds Academy (SSA) — shell: base, nav, controls, panels, modal, toasts
   Built by ETANC for Soul Sounds Academy (SSA).
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Reserve the scrollbar column so locking body scroll for a modal never shifts the page */
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink-900);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-optical-sizing: auto;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
dl, dd { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; border-spacing: 0; }

::selection { background: rgb(var(--brass-rgb) / 0.35); color: var(--paper); }

/* Opacity hierarchy — the only three text emphasis levels */
.t-1 { color: var(--text-1); }
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100px; left: var(--s-4);
  background: var(--brass); color: var(--brass-ink);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-ctl);
  z-index: 100; font-weight: 500;
}
.skip-link:focus { top: var(--s-4); }

/* Focus — always visible, never loud: a 1px brass line, no blur */
:focus-visible {
  outline: 1px solid var(--focus-border);
  outline-offset: 2px;
  border-radius: var(--r-ctl);
}

/* ---------- Scrollbars ----------
   Two deliberately separate treatments:
   (a) The page (document) scrollbar: custom 11px bar on <html> only — gray rounded
       thumb, dark track in the surface colour, and hand-drawn chevron arrow buttons.
   (b) Internal scrollers (.scroll-slim and the components listed): 4px rounded brass
       thumb, transparent track, no buttons, via the WebKit pseudo-elements.
   scrollbar-color inherits, so (b) resets it to auto first — Chromium otherwise ignores
   ::-webkit-scrollbar styling on any element with a non-auto scrollbar-color. */
html::-webkit-scrollbar { width: 11px; height: 11px; }
html::-webkit-scrollbar-track { background: var(--ink-800); }
html::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 999px;
  border: 3px solid var(--ink-800); /* the track shows through as an inset margin, keeping the thumb slim inside its lane */
  background-clip: padding-box;
}
html::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
html::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-active); }
html::-webkit-scrollbar-corner { background: var(--ink-800); }
/* Arrow buttons, drawn by hand: a thin 1.25px chevron in the same gray, brighter on hover.
   Only the single button at each end is shown. */
html::-webkit-scrollbar-button { display: block; width: 11px; height: 14px; background-color: var(--ink-800); background-repeat: no-repeat; background-position: center; background-size: 7px 7px; }
html::-webkit-scrollbar-button:vertical:decrement { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' fill='none' stroke='%236B6B6B' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'><path d='M1.5 5.5 4 3l2.5 2.5'/></svg>"); }
html::-webkit-scrollbar-button:vertical:increment { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' fill='none' stroke='%236B6B6B' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'><path d='M1.5 2.5 4 5l2.5-2.5'/></svg>"); }
html::-webkit-scrollbar-button:vertical:decrement:hover { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' fill='none' stroke='%23A8A8A8' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'><path d='M1.5 5.5 4 3l2.5 2.5'/></svg>"); }
html::-webkit-scrollbar-button:vertical:increment:hover { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' fill='none' stroke='%23A8A8A8' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'><path d='M1.5 2.5 4 5l2.5-2.5'/></svg>"); }
html::-webkit-scrollbar-button:horizontal { display: none; width: 0; height: 0; }
/* Hide the paired ("double") buttons some platforms add at each end */
html::-webkit-scrollbar-button:vertical:start:increment, html::-webkit-scrollbar-button:vertical:end:decrement { display: none; height: 0; }

.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body {
  scrollbar-color: auto; scrollbar-width: auto;
}
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar { width: 4px; height: 4px; }
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-track { background: transparent; }
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-thumb { background: rgb(var(--brass-rgb) / 0.3); border-radius: 999px; }
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-thumb:hover,
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-thumb:active { background: rgb(var(--brass-rgb) / 0.5); }
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
:is(.scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body)::-webkit-scrollbar-corner { background: transparent; }
/* Firefox has no pseudo-elements: the page bar goes gray, the internal scrollers thin brass */
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-color: var(--scroll-thumb) var(--ink-800); }
  .scroll-slim, .checklist, .table-wrap, .matrix-wrap, .sel__list, .cmdk__list, .modal__body { scrollbar-width: thin; scrollbar-color: rgb(var(--brass-rgb) / 0.3) transparent; }
}
/* Internal scrollers keep a small gutter so the thumb never touches content */
.scroll-slim { padding-right: var(--s-3); }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Layout ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-8) var(--gutter) var(--s-16);
}

.screen[hidden] { display: none; }
/* Page transition: the leaving screen fades out briefly, the arriving one fades in.
   Opacity only, on the whole screen container; the top bar sits outside .screen. */
.screen { transition: opacity var(--dur-page-in) ease-out; }
.screen.is-leaving { opacity: 0; transition-duration: var(--dur-page-out); }
.screen.is-entering { opacity: 0; transition: none; }
@media (prefers-reduced-motion: reduce) { .screen { transition: none; } }

.screen__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s-6);
  padding-bottom: var(--s-6);
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--line);
}
.screen__title { font-size: var(--fs-2xl); }
.screen__lede { margin-top: var(--s-2); max-width: 60ch; font-size: var(--fs-base); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-6);
  min-height: 64px;
}
.topbar__meta { font-size: var(--fs-sm); white-space: nowrap; }

.wordmark {
  display: inline-flex; align-items: center; gap: var(--s-3);
  text-decoration: none; padding: var(--s-2) 0;
}
/* The mark: five cells of a cadence strip, one lit */
.wordmark__mark {
  display: inline-grid; grid-auto-flow: column; gap: 3px;
  align-items: end; height: 22px;
}
.wordmark__mark i {
  display: block; width: 5px; border-radius: var(--r-cell);
  background: rgb(var(--paper-rgb) / var(--o-3));
}
.wordmark__mark i:nth-child(1) { height: 10px; }
.wordmark__mark i:nth-child(2) { height: 16px; }
.wordmark__mark i:nth-child(3) { height: 22px; background: var(--brass); }
.wordmark__mark i:nth-child(4) { height: 14px; }
.wordmark__mark i:nth-child(5) { height: 8px; }

.wordmark__text { display: flex; flex-direction: column; line-height: 1.1; }
.wordmark__name {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--fs-md); letter-spacing: -0.01em;
}
.wordmark__sub { font-size: var(--fs-xs); margin-top: 2px; }

.tabs { min-width: 0; justify-self: center; }
.tabs__list {
  display: flex; gap: var(--s-1);
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs__list::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: inline-block;
  padding: var(--s-5) var(--s-3) calc(var(--s-5) - 2px);
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--text-2);
  text-decoration: none; white-space: nowrap;
  border-radius: var(--r-ctl);
  transition: color var(--dur-fast) var(--ease-out);
  /* Cell run under the label. --tab-cells is the number of whole cells that
     fit this tab; app.js measures each tab and sets it, because a fixed
     repeating pattern leaves a part-cut cell on every width that is not an
     exact multiple of the period. */
  --tab-cell: 5px;
  --tab-gap: 3px;
  --tab-cells: 7;
}
.tab:hover { color: var(--text-1); }
/* Active indicator: a short run of cells, the same motif as the hero */
.tab::after {
  content: "";
  position: absolute; left: var(--s-3); right: var(--s-3); bottom: 0;
  height: 3px;
  /* One cell per tile, tiled --tab-cells times across the run. The tile is
     (width + gap) / n, so the trailing gap of the last tile falls outside the
     element: the run always begins and ends on a whole cell. */
  background-image: linear-gradient(
    to right,
    var(--brass) 0 calc(100% - var(--tab-gap)),
    transparent calc(100% - var(--tab-gap)) 100%
  );
  background-size: calc((100% + var(--tab-gap)) / var(--tab-cells)) 100%;
  background-repeat: repeat-x;
  border-radius: var(--r-cell);
  /* Inactive: the same dots at reduced opacity, hidden by a clip that sweeps open on hover */
  opacity: 0.45;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 260ms var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.tab:hover::after { clip-path: inset(0 0 0 0); }
.tab[aria-current="page"] { color: var(--text-1); }
.tab[aria-current="page"]::after { opacity: 1; clip-path: inset(0 0 0 0); transition: opacity var(--dur-base) var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .tab::after { transition: none; } }

/* ---------- Palette picker ----------
   Three swatches and the current palette's name, sitting at the top right
   beside the period readout. Each swatch is a miniature of the palette it
   selects: that palette's ground, with its accent as a bar inside. Selection
   is carried by the brass ring and full opacity, and by the name, so the
   control never depends on colour alone. */
.topbar__end {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  justify-self: end;
  min-width: 0;
}

.palette {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: rgb(var(--paper-rgb) / 0.03);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.palette:hover { border-color: var(--line-strong); background: rgb(var(--paper-rgb) / 0.05); }

.palette__sw {
  position: relative;
  width: 17px; height: 24px;
  flex: none;
  padding: 0;
  border: 1px solid rgb(var(--paper-rgb) / 0.22);
  border-radius: 4px;
  background: var(--sw-bg, var(--ink-800));
  cursor: pointer;
  opacity: 0.55;
  overflow: hidden;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-btn-release) var(--ease-btn);
}
/* The accent bar: the same cell motif, at the smallest size it appears */
.palette__sw::after {
  content: "";
  position: absolute; left: 3px; right: 3px; bottom: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--sw-fg, var(--brass));
}
.palette__sw[data-palette="paper"] { --sw-bg: var(--sw-paper-bg); --sw-fg: var(--sw-paper-fg); }
.palette__sw[data-palette="brass"] { --sw-bg: var(--sw-brass-bg); --sw-fg: var(--sw-brass-fg); }
.palette__sw[data-palette="ink"]   { --sw-bg: var(--sw-ink-bg);   --sw-fg: var(--sw-ink-fg); }

.palette__sw:hover { opacity: 0.85; transform: translateY(-1px); }
.palette__sw:active { transform: translateY(0) scale(var(--btn-press-scale)); transition-duration: var(--dur-btn-press); }
.palette__sw[aria-checked="true"] {
  opacity: 1;
  border-color: var(--brass);
  box-shadow: 0 0 0 1px var(--brass);
  transform: none;
}
.palette__sw:focus-visible { outline: 1px solid var(--focus-border); outline-offset: 2px; }

.palette__name {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 0 var(--s-2) 0 var(--s-1);
  min-width: 50px; /* fits the widest name (Paper, 45.6px) so the strip never shifts */
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .palette__sw:hover, .palette__sw:active { transform: none; }
}

/* ---------- Buttons ----------
   One tactile system for every clickable control: hover lifts (solid) or fills in
   (outline), press scales to 0.975 and flattens the shadow quickly, release eases
   back a little slower. Same easing everywhere; nothing bounces. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-5);
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  font-size: var(--fs-sm); font-weight: 500;
  white-space: nowrap;
  position: relative;
  transform: translateZ(0);
  transition:
    background var(--dur-btn-hover) var(--ease-btn),
    border-color var(--dur-btn-hover) var(--ease-btn),
    color var(--dur-btn-hover) var(--ease-btn),
    box-shadow var(--dur-btn-release) var(--ease-btn),
    transform var(--dur-btn-release) var(--ease-btn);
}
.btn:active:not(:disabled) {
  transform: scale(var(--btn-press-scale));
  transition-duration: var(--dur-btn-hover), var(--dur-btn-hover), var(--dur-btn-hover), var(--dur-btn-press), var(--dur-btn-press);
}
.btn:disabled { opacity: var(--o-3); cursor: not-allowed; transform: none; box-shadow: none; }

/* Solid: lifts on hover with a faint top highlight, presses flat */
.btn--primary {
  background: var(--brass); color: var(--brass-ink);
  border-color: var(--brass);
  box-shadow: var(--shadow-btn-rest);
}
.btn--primary:hover:not(:disabled) { background: var(--brass-hover); border-color: var(--brass-hover); box-shadow: var(--shadow-btn-hover), var(--highlight-btn); }
.btn--primary:active:not(:disabled) { background: var(--brass); box-shadow: var(--shadow-btn-press); }

/* Outline: fills in on hover instead of lifting, presses slightly darker */
.btn--ghost {
  background: transparent; color: var(--text-1);
  border-color: var(--line-strong);
}
.btn--ghost:hover:not(:disabled) { border-color: rgb(var(--paper-rgb) / 0.45); background: rgb(var(--paper-rgb) / 0.06); }
.btn--ghost:active:not(:disabled) { background: rgb(var(--paper-rgb) / 0.09); }

.btn--danger {
  background: transparent; color: var(--ember);
  border-color: rgb(var(--ember-rgb) / 0.45);
}
.btn--danger:hover:not(:disabled) { background: rgb(var(--ember-rgb) / 0.1); border-color: var(--ember); }
.btn--danger:active:not(:disabled) { background: rgb(var(--ember-rgb) / 0.16); }

.btn--sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); }

/* Loading: a thin 1.5px ring in the button's own text colour, text stays put */
.btn.is-loading { pointer-events: none; }
.btn.is-loading:disabled { opacity: 0.85; cursor: progress; }
.btn.is-loading::before {
  content: ""; width: 12px; height: 12px; flex: none;
  border-radius: 50%;
  border: 1.5px solid currentColor; border-right-color: transparent;
  opacity: 0.8;
  animation: btn-spin 800ms linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::before { animation: none; border-right-color: currentColor; opacity: 0.4; }
}

/* Quiet text-style action used inside table rows */
.link-btn {
  background: none; border: 0; padding: var(--s-1) var(--s-2);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  border-radius: var(--r-ctl);
  transition: color var(--dur-btn-hover) var(--ease-btn), background var(--dur-btn-hover) var(--ease-btn), transform var(--dur-btn-release) var(--ease-btn);
}
.link-btn:hover:not(:disabled) { color: var(--text-1); background: rgb(var(--paper-rgb) / 0.06); }
.link-btn:active:not(:disabled) { transform: scale(var(--btn-press-scale)); background: rgb(var(--paper-rgb) / 0.09); transition-duration: var(--dur-btn-hover), var(--dur-btn-hover), var(--dur-btn-press); }
.link-btn--danger:hover:not(:disabled) { color: var(--ember); background: rgb(var(--ember-rgb) / 0.1); }
.link-btn:disabled { opacity: var(--o-3); cursor: not-allowed; }

.iconbtn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-ctl);
  background: transparent; color: var(--text-2);
  font-size: 22px; line-height: 1;
  transition: color var(--dur-btn-hover) var(--ease-btn), background var(--dur-btn-hover) var(--ease-btn), transform var(--dur-btn-release) var(--ease-btn);
}
.iconbtn:hover:not(:disabled) { color: var(--text-1); background: rgb(var(--paper-rgb) / 0.06); }
.iconbtn:active:not(:disabled) { transform: scale(0.94); background: rgb(var(--paper-rgb) / 0.09); transition-duration: var(--dur-btn-hover), var(--dur-btn-hover), var(--dur-btn-press); }
.iconbtn:disabled { opacity: var(--o-3); cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .btn, .link-btn, .iconbtn { transition-duration: 0ms; }
  .btn:active:not(:disabled), .link-btn:active:not(:disabled), .iconbtn:active:not(:disabled) { transform: none; }
}

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field__label { font-size: var(--fs-xs); }
.field input, .field select, .field textarea,
.form input, .form select, .form textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--s-2) var(--s-3);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text-1);
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out), background 150ms var(--ease-out);
}
.field input:hover, .field select:hover, .form input:hover, .form select:hover, .form textarea:hover {
  border-color: var(--line-strong);
  background: var(--input-bg-hover);
}
.field input:focus-visible, .field select:focus-visible,
.form input:focus-visible, .form select:focus-visible, .form textarea:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: var(--focus-inset);
}
input::placeholder, textarea::placeholder { color: var(--input-placeholder); opacity: 1; font-weight: 400; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
/* Number fields: no native spinner chrome (arrow keys still step) */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* Date and month fields: the picker indicator becomes a thin-line calendar in the same
   weight as the select chevron; the popup itself follows color-scheme: dark. */
input[type="date"], input[type="month"] { position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="month"]::-webkit-calendar-picker-indicator {
  width: 14px; height: 14px; padding: 0; margin-left: var(--s-2);
  cursor: pointer; opacity: 0.62;
  background: var(--icon-calendar) center / 14px 14px no-repeat;
  transition: opacity 150ms var(--ease-out);
}
input[type="date"]::-webkit-calendar-picker-indicator:hover, input[type="month"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
input[type="date"]::-webkit-datetime-edit, input[type="month"]::-webkit-datetime-edit { padding: 0; }
input[type="date"]::-webkit-datetime-edit-fields-wrapper, input[type="month"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type="date"]::-webkit-datetime-edit-text { color: var(--text-3); padding: 0 1px; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: var(--s-8) !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select option { background: var(--ink-800); color: var(--paper); }

/* ---------- Custom Date & Month Picker (shared) ----------
   Wraps native <input type="date"> and <input type="month"> with a themed,
   accessible, portalled calendar widget that harmonizes with Brass, Paper,
   and Ink palettes. */
.dp { position: relative; min-width: 0; }
.dp__native { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: -1px; opacity: 0; pointer-events: none; overflow: hidden; }

.dp__btn {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3);
  background: var(--input-bg);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  color: var(--text-1); font-size: var(--fs-base); text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.dp__btn:hover { border-color: var(--line-strong); background: var(--input-bg-hover); }
.dp__btn:focus-visible, .dp__btn[aria-expanded="true"] { outline: none; border-color: var(--focus-border); box-shadow: var(--focus-inset); }
.dp__btn:disabled { opacity: var(--o-3); cursor: not-allowed; }
.dp__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp__text.is-empty { color: var(--input-placeholder); }
.dp__icon { flex: none; width: 15px; height: 15px; color: var(--brass); opacity: 0.85; transition: opacity var(--dur-fast) var(--ease-out); }
.dp__btn:hover .dp__icon, .dp__btn[aria-expanded="true"] .dp__icon { opacity: 1; }

.dp__popup {
  position: fixed; z-index: 100;
  width: 290px;
  background: var(--ink-800);
  border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  box-shadow: var(--shadow-modal);
  padding: var(--s-3);
  font-family: var(--font-ui);
  opacity: 0; transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
  user-select: none;
}
.dp__popup.is-open { opacity: 1; transform: none; pointer-events: auto; }

.dp__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  margin-bottom: var(--s-2); padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line-soft);
}
.dp__title {
  display: flex; align-items: center; gap: var(--s-1);
  font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600;
  color: var(--paper); letter-spacing: -0.01em;
}
.dp__nav {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-ctl);
  background: transparent; border: 1px solid transparent;
  color: var(--text-2); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.dp__nav:hover { background: var(--input-bg-hover); color: var(--text-1); border-color: var(--line); }
.dp__nav svg { width: 12px; height: 12px; }

.dp__dows {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px; text-align: center;
}
.dp__dow {
  font-size: var(--fs-xs); font-weight: 500; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 0;
}

.dp__grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dp__cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; min-height: 32px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-ctl);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-1);
  cursor: pointer; padding: 0;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.dp__cell:hover { background: rgb(var(--brass-rgb) / 0.14); color: var(--paper); }
.dp__cell.is-other { color: var(--text-3); opacity: 0.4; }
.dp__cell.is-today::after {
  content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--brass);
}
.dp__cell.is-selected {
  background: var(--brass) !important; color: var(--brass-ink) !important;
  font-weight: 700; border-color: var(--brass);
  box-shadow: 0 2px 6px -1px rgb(var(--brass-rgb) / 0.4);
}
.dp__cell.is-selected::after { background: var(--brass-ink); }
.dp__cell:focus-visible { outline: none; border-color: var(--focus-border); box-shadow: var(--focus-inset); }

.dp__mgrid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2); padding: var(--s-2) 0;
}
.dp__mcell {
  display: flex; align-items: center; justify-content: center;
  height: 42px; border-radius: var(--r-ctl);
  background: var(--input-bg); border: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-1);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.dp__mcell:hover { background: rgb(var(--brass-rgb) / 0.14); border-color: var(--line-strong); color: var(--paper); }
.dp__mcell.is-selected {
  background: var(--brass) !important; color: var(--brass-ink) !important;
  font-weight: 700; border-color: var(--brass);
}
.dp__mcell.is-current { border-color: var(--brass); }

.dp__foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--s-2); padding-top: var(--s-2);
  border-top: 1px solid var(--line-soft);
}
.dp__quick {
  background: transparent; border: none; padding: 4px 6px;
  font-size: var(--fs-xs); font-weight: 500; color: var(--brass);
  cursor: pointer; border-radius: var(--r-ctl);
  transition: background var(--dur-fast) var(--ease-out);
}
.dp__quick:hover { background: rgb(var(--brass-rgb) / 0.12); }

/* ---------- Custom select (shared) ----------
   The native <select> stays in the DOM (hidden) as the value holder; .sel__btn is
   what people see, and .sel__list is a listbox portalled to <body>. */
.sel { position: relative; min-width: 0; }
.sel__native { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: -1px; opacity: 0; pointer-events: none; overflow: hidden; }
.sel__btn {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3);
  background: var(--input-bg);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  color: var(--text-1); font-size: var(--fs-base); text-align: left;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.sel__btn:hover { border-color: var(--line-strong); background: var(--input-bg-hover); }
.sel__btn:focus-visible, .sel__btn[aria-expanded="true"] { outline: none; border-color: var(--focus-border); box-shadow: var(--focus-inset); }
.sel__btn:disabled { opacity: var(--o-3); cursor: not-allowed; }
.sel__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel__chev { flex: none; width: 12px; height: 12px; color: var(--text-2); transition: transform var(--dur-base) var(--ease-out); }
.sel__btn[aria-expanded="true"] .sel__chev { transform: rotate(180deg); }

.sel__list {
  position: fixed; z-index: 80;
  min-width: 160px; max-height: 280px; overflow-y: auto;
  margin: 0; padding: var(--s-1) var(--s-3) var(--s-1) var(--s-1);
  background: var(--ink-800);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  box-shadow: var(--shadow-toast);
  opacity: 0; transform: translateY(-3px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.sel__list.is-open { opacity: 1; transform: none; }
.sel__opt {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4);
  border-radius: var(--r-cell);
  font-size: var(--fs-sm); color: var(--text-1);
  cursor: pointer; white-space: nowrap;
}
.sel__opt.is-active { background: rgb(var(--brass-rgb) / 0.1); }
/* Selected: a single cell-shaped mark at the left edge, the same shape as every other status mark */
.sel__opt[aria-selected="true"]::before {
  content: ""; position: absolute; left: 5px; top: 50%; width: 3px; height: 12px;
  transform: translateY(-50%); border-radius: var(--r-cell); background: var(--brass);
}
.sel__opt[aria-selected="true"] { color: var(--text-1); }
.sel__opt .t-2 { font-size: var(--fs-xs); }
@media (prefers-reduced-motion: reduce) { .sel__list, .sel__chev { transition: none; } }

.field--search { flex: 1 1 260px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4);
  margin-bottom: var(--s-5);
}
.toolbar .field:not(.field--search) { flex: 1 1 160px; max-width: 260px; }
.toolbar__meta { margin-left: auto; font-size: var(--fs-sm); white-space: nowrap; align-self: center; padding-top: var(--s-4); }

/* ---------- Panels ---------- */
.panel { border-radius: var(--r-panel); min-width: 0; }
.panel--raised {
  background: var(--ink-800);
  border: 1px solid var(--line);
  padding: var(--s-6);
}
.panel--flat { background: transparent; }
.panel__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4);
  padding-bottom: var(--s-3); border-bottom: 1px solid var(--line);
}
.panel__title { font-size: var(--fs-lg); }
.panel__meta { font-size: var(--fs-sm); white-space: nowrap; }

/* ---------- Stat row (flat, hairline-separated, not cards) ---------- */
.statrow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: var(--s-8) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.statrow--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-5) var(--s-5) var(--s-5) 0;
  min-width: 0;
}
.stat + .stat { padding-left: var(--s-5); border-left: 1px solid var(--line); }
.stat__label { font-size: var(--fs-sm); }
.stat__value {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--fs-xl); line-height: 1.1; letter-spacing: -0.015em;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.stat__value--money { font-size: clamp(1.25rem, 0.6rem + 1.4vw, 1.75rem); }
.stat__hint { font-size: var(--fs-xs); }

/* ---------- Tables ---------- */
.table-wrap, .matrix-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line);
}
.table { width: 100%; }
.table th {
  text-align: left; font-weight: 500; font-size: var(--fs-xs);
  color: var(--text-2);
  padding: var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.table tbody tr:hover { background: rgb(var(--paper-rgb) / 0.025); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .link-btn { margin-left: var(--s-1); }

.who { display: flex; flex-direction: column; line-height: 1.3; }
.who__name { font-weight: 500; }
.who__code { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }

/* Money in tables gets the display face only when it's the row's key figure */
.amount-key { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 500; letter-spacing: -0.01em; }
.amount-zero { color: var(--text-3); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 26px; padding: 0 var(--s-2) 0 var(--s-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  font-size: var(--fs-xs); font-weight: 500; color: var(--text-1);
  white-space: nowrap; line-height: 1;
  background: rgb(var(--paper-rgb) / 0.03);
}
.chip .t-2 { font-weight: 400; }
.chip__x {
  border: 0; background: none; padding: 0; margin-right: -2px;
  width: 18px; height: 18px; border-radius: var(--r-cell);
  color: var(--text-2); font-size: 15px; line-height: 1;
  display: inline-grid; place-items: center;
  transition: color var(--dur-btn-hover) var(--ease-btn), background var(--dur-btn-hover) var(--ease-btn), transform var(--dur-btn-release) var(--ease-btn);
}
.chip__x:hover:not(:disabled) { color: var(--ember); background: rgb(var(--ember-rgb) / 0.12); }
.chip__x:active:not(:disabled) { transform: scale(0.9); transition-duration: var(--dur-btn-hover), var(--dur-btn-hover), var(--dur-btn-press); }

/* Instrument marker: a single cell in a fixed shade, so instruments are told apart by
   position and label rather than by a rainbow */
.chip::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--r-cell);
  background: rgb(var(--paper-rgb) / var(--o-3));
}

/* ---------- Cells (the motif, at working scale) ---------- */
.cell {
  --size: 22px;
  position: relative;
  display: inline-block;
  width: var(--size); height: var(--size);
  border-radius: var(--r-cell);
  vertical-align: middle;
  flex: none;
}
.cell--paid {
  background: var(--brass);
}
.cell--paid::after {
  /* check glyph so paid never relies on colour alone */
  content: "";
  position: absolute; left: 50%; top: 46%;
  width: 26%; height: 50%;
  border: solid var(--brass-ink);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -55%) rotate(45deg);
}
.cell--unpaid {
  border: 1.5px solid var(--ember);
  background:
    repeating-linear-gradient(135deg, rgb(var(--ember-rgb) / 0.55) 0 1.5px, transparent 1.5px 5px);
}
.cell--upcoming {
  border: 1px solid rgb(var(--paper-rgb) / var(--o-3));
  background: transparent;
}
.cell--none {
  background: transparent;
}
.cell--none::after {
  content: ""; position: absolute; left: 35%; right: 35%; top: 50%;
  height: 1px; background: rgb(var(--paper-rgb) / var(--o-3));
}

.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); font-size: var(--fs-sm); color: var(--text-2); }
.legend__item { display: inline-flex; align-items: center; gap: var(--s-2); }
.legend .cell { --size: 14px; }
.legend .cell--paid::after { border-width: 0 1.5px 1.5px 0; }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--s-16) var(--s-6);
  gap: var(--s-3);
}
.empty__strip { display: inline-grid; grid-auto-flow: column; gap: 4px; margin-bottom: var(--s-3); }
.empty__strip i { width: 10px; height: 10px; border-radius: var(--r-cell); border: 1px solid rgb(var(--paper-rgb) / var(--o-3)); }
.empty__strip i:nth-child(3) { background: rgb(var(--paper-rgb) / var(--o-3)); border-color: transparent; }
.empty__title { font-size: var(--fs-lg); font-weight: 500; }
.empty__text { max-width: 42ch; color: var(--text-2); font-size: var(--fs-sm); }
.empty .btn { margin-top: var(--s-2); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); }
.footer__inner {
  max-width: var(--page-max); margin: 0 auto;
  padding: var(--s-5) var(--gutter);
  display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap;
  font-size: var(--fs-xs);
}

/* ---------- Modal shell ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--s-4); }
.modal[hidden] { display: none; }
.modal__overlay {
  position: absolute; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in var(--dur-base) var(--ease-out) both;
}
.modal__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - var(--s-8));
  display: flex; flex-direction: column;
  background: var(--float-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-hero);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: panel-in var(--dur-slow) var(--ease-out) both;
}
.modal__panel:focus { outline: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
/* The rhyme: a twelve-cell strip runs along the top of every dialog */
.modal__cadence {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px;
  padding: var(--s-3) var(--s-6) 0;
}
.modal__cadence i { height: 3px; border-radius: var(--r-cell); background: rgb(var(--paper-rgb) / 0.12); }
.modal__cadence i:nth-child(-n+9) { background: rgb(var(--brass-rgb) / 0.55); }
.modal__cadence i:nth-child(9) { background: var(--brass); }

.modal__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-5) var(--s-6) var(--s-4);
}
.modal__title { font-size: var(--fs-xl); }
.modal__sub { margin-top: var(--s-1); font-size: var(--fs-sm); }
.modal__body {
  padding: 0 var(--s-6) var(--s-4);
  overflow-y: auto;
  min-height: 0; /* lets the body shrink and scroll inside the capped panel */
  display: grid; gap: var(--s-4);
}
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-6) var(--s-6);
  border-top: 1px solid var(--line);
}
.modal__foot .btn--danger { margin-right: auto; }

.form { display: grid; gap: var(--s-4); }
.form__row { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form__field { display: flex; flex-direction: column; gap: var(--s-1); }
.form__label { font-size: var(--fs-sm); color: var(--text-2); }
.form__hint { font-size: var(--fs-xs); color: var(--text-3); }
.form__error { font-size: var(--fs-xs); color: var(--ember); min-height: 1em; }
.form__field.is-invalid input, .form__field.is-invalid select { border-color: var(--ember); }
.form__text { font-size: var(--fs-base); color: var(--text-2); }
.form__text strong { color: var(--text-1); font-weight: 500; }

/* Check list used for class multi-select in the student form */
.checklist { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-ctl); padding: var(--s-1) var(--s-3) var(--s-1) var(--s-1); max-height: 240px; overflow-y: auto; background: var(--input-bg); }
.check {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-cell);
  cursor: pointer; transition: background var(--dur-fast);
}
.check:hover { background: rgb(var(--paper-rgb) / 0.04); }
.check input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; margin: 0; min-height: 0; }
.check__box {
  width: 16px; height: 16px; flex: none;
  border: 1px solid var(--line-strong); border-radius: var(--r-cell);
  position: relative; transition: background var(--dur-fast), border-color var(--dur-fast);
}
.check input:checked + .check__box { background: var(--brass); border-color: var(--brass); }
.check input:checked + .check__box::after {
  content: ""; position: absolute; left: 50%; top: 46%;
  width: 4px; height: 8px; border: solid var(--brass-ink); border-width: 0 2px 2px 0;
  transform: translate(-50%, -55%) rotate(45deg);
}
.check input:focus-visible + .check__box { outline: 1px solid var(--focus-border); outline-offset: 2px; }
.check input:disabled ~ * { opacity: var(--o-3); }
.check__text { display: flex; justify-content: space-between; gap: var(--s-3); flex: 1; font-size: var(--fs-sm); }
.check__text .t-2 { white-space: nowrap; }

/* ---------- Shared hover panel ----------
   One floating panel for every hover/focus reveal (chart bars, hero figure, payment
   strips). Positioned by JS, fixed, above or below its anchor; 150ms fade + 5px slide. */
.hpanel {
  position: fixed; z-index: 75; pointer-events: none;
  min-width: 176px; max-width: 300px;
  padding: var(--s-3) var(--s-4);
  background: var(--ink-800);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-toast);
  opacity: 0; transform: translateY(5px); visibility: hidden;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), visibility 0s linear 150ms;
}
.hpanel.is-above { transform: translateY(-5px); }
.hpanel.is-open { opacity: 1; transform: none; visibility: visible; transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), visibility 0s; }
.hpanel__title { font-size: var(--fs-xs); color: var(--text-2); margin-bottom: var(--s-1); }
.hpanel__rows { display: grid; gap: var(--s-1); }
.hpanel__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); font-size: var(--fs-xs); }
.hpanel__row .t-2 { font-size: var(--fs-xs); }
/* Supporting figures: serif to match, but small — these never compete with the KPI numerals */
.hpanel__num { font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.005em; }
.hpanel__line { font-size: var(--fs-sm); line-height: 1.45; }
.hpanel__line strong { font-family: var(--font-display); font-size: var(--fs-base); font-weight: 500; letter-spacing: -0.01em; }
/* Month list for the payment-strip tooltip: two columns, marks reuse the matrix cells */
.hpanel__months { display: grid; grid-template-columns: 1fr 1fr; gap: 2px var(--s-5); }
.hpanel__month { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); padding: 2px var(--s-1); margin: 0 calc(-1 * var(--s-1)); border-radius: var(--r-cell); color: var(--text-2); }
.hpanel__month .cell { --size: 12px; }
.hpanel__month .cell--paid::after { border-width: 0 1.5px 1.5px 0; }
.hpanel__month.is-hot { background: rgb(var(--brass-rgb) / 0.1); color: var(--text-1); }
.hpanel__month.is-none { opacity: var(--o-3); }
@media (prefers-reduced-motion: reduce) { .hpanel, .hpanel.is-open { transition: none; transform: none; } }

/* ---------- Keyboard hints ---------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-family: var(--font-ui); font-size: 10.5px; font-weight: 500; line-height: 1;
  color: var(--text-2);
  border: 1px solid rgb(var(--paper-rgb) / 0.18); border-bottom-width: 2px;
  border-radius: 3px; background: rgb(var(--paper-rgb) / 0.03);
  white-space: nowrap;
}
.field--search { position: relative; }
.field--search input { padding-right: 64px; }
.kbd--cmdk { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; pointer-events: auto; }
.kbd--cmdk:hover { color: var(--text-1); }
.field--compact .sel__btn { min-height: 32px; padding: 0 var(--s-2) 0 var(--s-3); font-size: var(--fs-sm); }
.panel__tools { display: flex; align-items: center; gap: var(--s-4); }

/* ---------- Command palette (inside the modal shell) ---------- */
.modal__foot:empty { display: none; }
.modal__panel.is-cmdk .modal__head { padding-bottom: var(--s-2); }
.cmdk__input { margin-bottom: var(--s-2); }
.cmdk__list { list-style: none; margin: 0 calc(-1 * var(--s-2)); padding: 0; max-height: 360px; overflow-y: auto; }
.cmdk__group { font-size: var(--fs-xs); color: var(--text-3); padding: var(--s-3) var(--s-3) var(--s-1); }
.cmdk__item {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4);
  border-radius: var(--r-cell); font-size: var(--fs-sm); cursor: pointer;
}
.cmdk__item .t-2 { font-size: var(--fs-xs); white-space: nowrap; }
.cmdk__item.is-active { background: rgb(var(--brass-rgb) / 0.1); }
.cmdk__item.is-active::before { content: ""; position: absolute; left: 5px; top: 50%; width: 3px; height: 12px; transform: translateY(-50%); border-radius: var(--r-cell); background: var(--brass); }
.cmdk__empty { padding: var(--s-6) var(--s-3); text-align: center; font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 70;
  display: flex; flex-direction: column; gap: var(--s-2);
  width: min(380px, calc(100vw - var(--s-8)));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--float-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-toast);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: var(--fs-sm);
  animation: toast-in var(--dur-slow) var(--ease-out) both;
}
.toast.is-leaving { animation: toast-out var(--dur-base) var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
/* Toast marker: one cell, in its state treatment */
.toast .cell { --size: 12px; }
.toast .cell--paid::after { border-width: 0 1.5px 1.5px 0; }
/* A check that draws itself: the CSS tick is replaced by an SVG stroke reveal */
.cell--draw::after { content: none; }
.cell--draw svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cell--draw path { fill: none; stroke: var(--brass-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 16; stroke-dashoffset: 16; animation: draw-check 450ms var(--ease-out) forwards; }
.toast .cell--draw path { stroke-width: 2.4; }
@keyframes draw-check { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .cell--draw path { animation: none; stroke-dashoffset: 0; } }
.toast__text strong { font-weight: 500; }
.toast .iconbtn { width: 28px; height: 28px; font-size: 18px; }

/* ---------- Responsive shell ---------- */
/* The top bar carries the wordmark, six tabs, the period and the palette
   picker, so it runs out of width before the content does and gets its own
   breakpoint: below this the tabs drop to their own row. */
@media (max-width: 1100px) {
  .topbar__inner {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand meta" "tabs tabs";
    gap: 0 var(--s-4);
    padding-bottom: 0;
  }
  .wordmark { grid-area: brand; }
  .topbar__end { grid-area: meta; }
  .tabs {
    grid-area: tabs; justify-self: stretch;
    margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
    /* fade the strip's right edge so it reads as scrollable */
    mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  }
  .tab { padding-top: var(--s-3); padding-bottom: calc(var(--s-3) + 2px); }
}
@media (max-width: 960px) {
  .statrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .statrow--3 .stat:nth-child(3) { grid-column: 1 / -1; padding-left: 0; border-left: 0; }
}
@media (max-width: 640px) {
  .main { padding-top: var(--s-6); }
  .screen__head { flex-direction: column; align-items: stretch; gap: var(--s-4); }
  .screen__head .btn { align-self: flex-start; }
  .toolbar__meta { margin-left: 0; width: 100%; padding-top: 0; }
  .topbar__meta { display: none; }
  .topbar__end { gap: var(--s-3); }
  .palette__name { display: none; }
  .wordmark__sub { display: none; }
  .modal { padding: 0; align-items: flex-end; }
  .modal__panel { width: 100%; max-height: 92dvh; border-radius: var(--r-hero) var(--r-hero) 0 0; }
  .toasts { right: var(--s-3); left: var(--s-3); bottom: var(--s-3); width: auto; }
}
