/* Kizora — dashboard styling.
 *
 * No framework and no build step: this is a self-hosted tool for one family,
 * and a toolchain nobody maintains is a liability. Everything below is CSS
 * custom properties, grid and flex.
 *
 * The visual system, briefly:
 *
 * * every colour, radius, size, weight, shadow and duration is a token
 *   declared in the block below. Nothing further down the file writes a hex
 *   value -- a call site that wants "danger" asks for the *tone*, not a red;
 * * the family accent arrives at runtime as --accent / --accent-ink and is
 *   used for identity only: the logo mark, the active nav item, primary
 *   buttons and focus rings. State keeps its own tones, so a family whose
 *   accent happens to be red can still show an error;
 * * depth comes from stacked surfaces and hairline borders. Dark is a
 *   designed theme with four surface levels and a top edge highlight, not a
 *   black page with grey rectangles;
 * * numbers are tabular, because a column of figures that shifts by a pixel
 *   per row is a column nobody can scan;
 * * every interactive element has a hover, a focus ring and a disabled
 *   state, and every tap target is at least --tap-min on a touch screen.
 */

/* ======================================================================
 * 1. Design tokens — the only place in this file with literal colours.
 * ====================================================================== */

/* One theme. There used to be two, and a second full palette is a second
 * thing to keep honest on every change -- the light one had already drifted
 * (a hero heading dropped a type step only there). More to the point, a
 * product people should recognise does not get to look like two products.
 *
 * Mid graphite, not near-black: dark enough to sit beside a game at night,
 * light enough not to read as "developer tool". The brand colour is the only
 * saturated thing on screen, which is what makes it the thing you remember.
 */

:root {
  color-scheme: dark;

  /* -- absolutes, so nothing below has to write #fff ------------------ */
  --ink-black: #000000;
  --ink-white: #ffffff;

  /* -- surfaces: cosmic indigo, each step one layer up ---------------
   * Палитра бренда Kizora. Deep Indigo -- «космос», на котором всё лежит;
   * Surface Navy и выше -- слои над ним. Глубина набирается слоями и
   * волосяными границами, а не тенями: тень на почти чёрном фоне не видна,
   * и вместо неё получается грязь. */
  --bg: #0b1020;
  --bg-glow:
    radial-gradient(72rem 40rem at 78% -14%, #241a4d 0%, transparent 58%),
    radial-gradient(52rem 32rem at -4% 104%, #10265c 0%, transparent 62%);
  --surface-sunken: #070b17;
  --surface: #131a33;
  --surface-2: #1a2242;
  --surface-3: #232c52;
  --surface-4: #2e3865;
  --edge-highlight: rgb(255 255 255 / 7%);

  --border: #232c52;
  --border-strong: #3a4680;

  /* -- text levels ---------------------------------------------------- */
  --text: #f7f9ff;
  --text-dim: #b9c0e0;
  --muted: #8d95bd;
  --text-inverse: #0b1020;

  /* -- the brand ------------------------------------------------------
   * Accent Violet. Фиксированный, не пер-семейный: по нему узнают продукт,
   * поэтому он владеет тем, что нажимают -- кнопки, активная строка меню,
   * кольцо фокуса. Собственный цвет семьи -- --family ниже, он остаётся на
   * гербе, плашках рангов и графиках.
   *
   * Accent Cyan -- вторая половина брендовой пары: ссылки, значки и то, с
   * чем взаимодействуют, но не «главное действие». Два акцента, у каждого
   * своя работа; там, где они спорят, выигрывает фиолетовый. */
  --accent: #8b5cff;
  --accent-ink: #0b1020;
  --accent-hot: #a47bff;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 38%, transparent);

  --accent-2: #35d6ff;
  --accent-2-ink: #051018;
  --accent-2-soft: color-mix(in srgb, var(--accent-2) 16%, transparent);
  --accent-2-line: color-mix(in srgb, var(--accent-2) 42%, transparent);

  /* Soft Lavender -- светлая поверхность из палитры. На тёмной странице она
   * появляется редко и намеренно: там, где карточка должна читаться как
   * лист бумаги поверх космоса. */
  --surface-light: #e8e2ff;
  --surface-light-ink: #0b1020;

  /* The family's own colour. Defaults to the brand until branding loads. */
  --family: var(--accent);
  --family-ink: var(--accent-ink);

  /* -- tones: what a state means, never what colour it is -------------
   * The five names match family_core.domain.visuals.Tone one for one, so a
   * badge the API describes as "critical" cannot come out amber here.
   *
   * Deliberately desaturated. Against a violet-and-cyan brand, a status
   * palette at full chroma competes with it, and five loud colours mean none
   * of them is a signal. Critical is pulled towards rose, info towards a
   * cooler slate than the brand cyan, so neither reads as the accent -- and a
   * status always carries its word, never colour alone. */
  --tone-good: #5fbf95;
  --tone-attention: #d6a75c;
  --tone-critical: #f0788f;
  --tone-muted: #8d95bd;
  --tone-info: #7aa2d6;

  --tone-good-soft: color-mix(in srgb, var(--tone-good) 15%, transparent);
  --tone-attention-soft: color-mix(in srgb, var(--tone-attention) 16%, transparent);
  --tone-critical-soft: color-mix(in srgb, var(--tone-critical) 15%, transparent);
  --tone-muted-soft: color-mix(in srgb, var(--tone-muted) 14%, transparent);
  --tone-info-soft: color-mix(in srgb, var(--tone-info) 15%, transparent);

  --tone-good-line: color-mix(in srgb, var(--tone-good) 34%, transparent);
  --tone-attention-line: color-mix(in srgb, var(--tone-attention) 36%, transparent);
  --tone-critical-line: color-mix(in srgb, var(--tone-critical) 34%, transparent);
  --tone-muted-line: color-mix(in srgb, var(--tone-muted) 30%, transparent);
  --tone-info-line: color-mix(in srgb, var(--tone-info) 34%, transparent);

  /* Legacy aliases kept so older rules keep meaning what they meant. */
  --success: var(--tone-good);
  --warning: var(--tone-attention);
  --danger: var(--tone-critical);
  --gold: #d6a75c;

  /* -- radii ----------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* -- spacing scale --------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 22px;
  --space-6: 28px;
  --space-7: 36px;
  --space-8: 48px;

  /* -- type ------------------------------------------------------------ */
  --font: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui,
    -apple-system, "Inter", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;

  --fs-hero: 34px;      /* countdown, the one number on an operational screen */
  --fs-page: 23px;      /* page title */
  --fs-value: 27px;     /* the primary value inside a stat tile */
  --fs-section: 17px;   /* a heading that owns a group of cards */
  --fs-card: 15px;      /* card title */
  --fs-body: 14.5px;    /* running text */
  --fs-sm: 13px;        /* secondary text, table cells */
  --fs-xs: 11.5px;      /* labels, badges */
  --fs-2xs: 10.5px;     /* eyebrow / uppercase micro-label */

  --fw-normal: 450;
  --fw-medium: 550;
  --fw-semibold: 620;
  --fw-bold: 700;

  --lh-tight: 1.18;
  --lh-body: 1.55;

  /* -- elevation ------------------------------------------------------- */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 40%), 0 24px 56px -24px rgb(0 0 0 / 75%);
  --ring: 0 0 0 3px var(--accent-glow);

  /* -- motion ---------------------------------------------------------- */
  --dur-fast: 0.12s;
  --dur: 0.2s;
  --dur-slow: 0.34s;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* -- layout ---------------------------------------------------------- */
  --sidebar-width: 258px;
  --content-max: 1180px;
  --topbar-height: 60px;
  --bottom-nav-height: 62px;
  --tap-min: 44px;
}

/* ======================================================================
 * 1b. Icons.
 *
 * One drawn set, defined once as <symbol>s in index.html and referenced by
 * <use>. fill/stroke are inheritable presentation properties, so setting
 * them here reaches the symbol's content through the shadow tree and every
 * icon takes the colour of the text beside it.
 * ====================================================================== */

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* Optical: a stroked glyph next to text sits a touch high on the line. */
  vertical-align: -0.22em;
}

/* ======================================================================
 * 2. Tone carriers.
 *
 * A component asks for `class="badge tone-critical"`. The class sets three
 * local properties; the component reads them. That is the whole mapping --
 * no rule anywhere says `.badge.something { color: red }`, so adding a tone
 * is one block here and nothing else.
 * ====================================================================== */

.tone-good {
  --tone: var(--tone-good);
  --tone-soft: var(--tone-good-soft);
  --tone-line: var(--tone-good-line);
}
.tone-attention {
  --tone: var(--tone-attention);
  --tone-soft: var(--tone-attention-soft);
  --tone-line: var(--tone-attention-line);
}
.tone-critical {
  --tone: var(--tone-critical);
  --tone-soft: var(--tone-critical-soft);
  --tone-line: var(--tone-critical-line);
}
.tone-muted {
  --tone: var(--tone-muted);
  --tone-soft: var(--tone-muted-soft);
  --tone-line: var(--tone-muted-line);
}
.tone-info {
  --tone: var(--tone-info);
  --tone-soft: var(--tone-info-soft);
  --tone-line: var(--tone-info-line);
}
.tone-accent {
  --tone: var(--accent);
  --tone-soft: var(--accent-soft);
  --tone-line: var(--accent-line);
}

/* ======================================================================
 * 3. Base
 * ====================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: var(--lh-tight); }

::selection { background: var(--accent-soft); }

:where(button, a, select, input, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid transparent;   /* kept for forced-colours modes */
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* A skip link, because the sidebar is long and keyboard users should not
 * have to tab past thirteen nav items to reach the page. */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: calc(var(--space-3) * -6);
  z-index: 60;
  background: var(--surface-4);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-3); }

/* Scrollbars, so the panel does not switch fonts halfway down. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ======================================================================
 * 4. Boot / login
 * ====================================================================== */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.boot-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-7);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  position: relative;
  overflow: hidden;
}

.boot-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-hot), transparent);
}

.boot-card h1 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-page);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.boot-card p { color: var(--text-dim); margin: 0 0 var(--space-5); }
.boot-card code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  background: var(--surface-3);
  padding: 1px var(--space-2);
  border-radius: var(--radius-xs);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  background: linear-gradient(180deg, var(--accent), var(--accent-hot));
  color: var(--accent-ink);
  text-decoration: none;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  border: 0;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.button:active { transform: translateY(0); }

/* ======================================================================
 * 5. Shell — sidebar, topbar, bottom navigation
 * ====================================================================== */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  /* The sidebar is sticky and one screen tall, so on a long page its
   * column ran out of colour partway down and the page background showed
   * through under the menu. The column is painted here instead, in the
   * same mix the sidebar itself uses over --bg, so there is no seam
   * where the sticky element ends. */
  background-image: linear-gradient(
    to right,
    color-mix(in srgb, var(--surface) 88%, var(--bg)) 0 var(--sidebar-width),
    var(--border) var(--sidebar-width) calc(var(--sidebar-width) + 1px),
    transparent calc(var(--sidebar-width) + 1px)
  );
}

#app,
main,
.view,
.card,
.table-wrap { min-width: 0; }

.sidebar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-3) var(--space-4);
  gap: var(--space-5);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-1); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  flex: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-hot));
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px -8px var(--accent-glow);
  display: grid;
  place-items: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  color: var(--accent-ink);
  letter-spacing: 0.02em;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }

.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#family-picker {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--fs-sm);
  min-height: var(--tap-min);
  cursor: pointer;
}
#family-picker:hover { border-color: var(--border-strong); }

.sidebar nav { display: flex; flex-direction: column; gap: var(--space-4); overflow-y: auto; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  /* --text-dim, not --muted: at 10.5px uppercase these headings carry the
     menu's structure, and there are five of them now rather than two. */
  color: var(--text-dim);
  padding: 2px var(--space-3) var(--space-1);
  font-weight: var(--fw-semibold);
}

.sidebar nav button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-dim);
  padding: var(--space-2) var(--space-3);
  min-height: 38px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.sidebar nav button:hover { background: var(--surface-2); color: var(--text); }

.sidebar nav button[aria-current="page"] {
  background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
  color: var(--text);
  font-weight: var(--fw-medium);
}
.sidebar nav button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--space-2);
  bottom: var(--space-2);
  width: 3px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-hot));
}

.nav-icon { width: 18px; height: 18px; flex: none; opacity: 0.85; vertical-align: -0.2em; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-1) 0;
}

.sidebar-foot img { border-radius: 50%; border: 1px solid var(--border); }
.sidebar-foot > span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.link:hover { color: var(--text); background: var(--surface-2); }
.link.danger:hover { color: var(--tone-critical); background: var(--tone-critical-soft); }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
.topbar h1 {
  margin: 0;
  font-size: var(--fs-page);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title .family-label { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.topbar-title .family-label:not(:empty)::before { content: "·"; margin-right: var(--space-2); opacity: 0.5; }

.topbar-actions { display: flex; gap: var(--space-1); margin-left: auto; align-items: center; }
.icon-button {
  width: var(--tap-min);
  height: var(--tap-min);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-body);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.icon-button .icon { width: 18px; height: 18px; vertical-align: 0; }
.icon-button:hover { border-color: var(--border-strong); color: var(--text); }
/* The logout control sits beside a 28px avatar in the sidebar foot, so it is
   smaller than a topbar action. */
.icon-button.small { width: 30px; height: 30px; min-height: 0; }
.icon-button.small .icon { width: 16px; height: 16px; }

.view {
  padding: var(--space-5) var(--space-6) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: var(--content-max);
  animation: rise var(--dur-slow) var(--ease-out) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* -- bottom navigation (narrow screens only) ------------------------- */

.bottom-nav {
  display: none;
  position: fixed;
  inset: auto 0 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner { display: grid; grid-template-columns: repeat(5, 1fr); }

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--bottom-nav-height);
  padding: var(--space-2) var(--space-1);
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  position: relative;
}
.bottom-nav button .nav-icon { width: 21px; height: 21px; }
.bottom-nav button[aria-current="page"] { color: var(--accent); }
.bottom-nav button[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
  background: var(--accent);
}


@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(14%); } to { transform: none; } }

/* ======================================================================
 * 6. Global search
 * ====================================================================== */

/* -- the search trigger and the palette -------------------------------
 *
 * The field used to be 420px of permanent topbar. It is now a button that
 * opens a palette, which is also where the section list lives: twenty-two
 * sections never fit a sidebar (the list stood 1015px tall in a 719px
 * column), so the menu had become a thing you scroll to find a page.
 */

.search-trigger {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-2) 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-dim); }
.search-trigger .icon { width: 15px; height: 15px; vertical-align: 0; }

.palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  /* Not centred vertically: a box that opens under the cursor's resting
   * height is quicker to read than one that opens in the middle. */
  padding: 10vh var(--space-4) var(--space-4);
}
.palette-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ink-black) 55%, transparent);
  animation: fade var(--dur) var(--ease) both;
}
.palette-box {
  position: relative;
  width: min(600px, 100%);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: palette-in var(--dur) var(--ease-out) both;
}
@keyframes palette-in { from { opacity: 0; transform: translateY(-8px); } }

.palette-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.palette-field .icon { width: 17px; height: 17px; flex: none; vertical-align: 0; }
.palette-field .search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  color: var(--text);
  font-size: var(--fs-body);
  padding: 0;
  min-height: 0;
}
.palette-field .search-input:focus { outline: none; box-shadow: none; }
.palette-field .search-input::placeholder { color: var(--muted); }

.palette-sections {
  overflow-y: auto;
  padding: var(--space-3) var(--space-2) var(--space-4);
}
.palette-group + .palette-group { margin-top: var(--space-3); }
.palette-list { display: flex; flex-direction: column; gap: 1px; }
.palette-list button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-dim);
  padding: var(--space-2) var(--space-3);
  min-height: 34px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.palette-list button:hover { background: var(--surface-2); color: var(--text); }
.palette-list button[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* One row under the daily four: the way to everything else. */
.nav-all {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-2);
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: var(--space-3);
  min-height: 38px;
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.nav-all:hover { color: var(--text); }
.nav-all .search-kbd { margin-left: auto; position: static; transform: none; }

.search-kbd {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .search-trigger-text { display: none; }
  .search-trigger .search-kbd { display: none; }
  .palette { padding: var(--space-4) var(--space-3); }
}

.search-results {
  position: relative;
  max-height: min(52vh, 420px);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  background: none;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  margin: 0;
  list-style: none;
}

.search-group-label {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: var(--fw-semibold);
  padding: var(--space-3) var(--space-2) var(--space-1);
}

.search-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-option[aria-selected="true"] { background: var(--accent-soft); }
.search-option:hover { background: var(--surface-2); }
.search-option .search-icon-cell {
  width: 26px;
  flex: none;
  text-align: center;
  font-size: var(--fs-card);
}
.search-option-text { min-width: 0; flex: 1; }
.search-option-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-option-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-hint {
  padding: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: center;
}

/* ======================================================================
 * 7. Toasts
 *
 * Bottom-right on a desktop, and above the bottom navigation on a phone --
 * a toast that covers the primary action is a toast that costs a tap.
 * ====================================================================== */

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(380px, calc(100vw - var(--space-8)));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface-4);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--tone, var(--border-strong));
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: toast-in var(--dur-slow) var(--ease-out) both;
}
.toast.leaving { animation: toast-out var(--dur) var(--ease) both; }
.toast-icon { color: var(--tone, var(--text-dim)); flex: none; display: inline-flex; align-items: center; height: var(--lh-body); }
.toast-icon .icon { width: 17px; height: 17px; vertical-align: 0; }
.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-title { font-weight: var(--fw-semibold); }
.toast-close {
  flex: none;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0 var(--space-1);
  min-width: 24px;
  min-height: 24px;
  border-radius: var(--radius-xs);
}
.toast-close .icon { width: 15px; height: 15px; vertical-align: 0; }
.toast-close:hover { color: var(--text); background: var(--surface-3); }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ======================================================================
 * 8. Components
 * ====================================================================== */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(198px, 1fr));
  gap: var(--space-3);
}
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  position: relative;
}

/* The section heading of a card. h2 in the document, small on screen: it
 * labels the card, the content is what people read. */
.card > h2,
.card > h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.card h4 { margin: 0; font-size: var(--fs-card); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
/* Same treatment as `.card > h2` above: these are the same thing -- a card's
 * own label -- and differed only because one of them sits beside a badge,
 * which put a page-weight heading and an eyebrow on screen for one role. */
.card-head > h2,
.card-head > h3 {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.section-title {
  margin: var(--space-3) 0 0;
  font-size: var(--fs-section);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

/* Stat tiles: the number is the content, everything else is a label. */
.stat {
  padding: var(--space-4);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat .value {
  font-size: var(--fs-value);
  font-weight: var(--fw-bold);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-tight);
}
.stat .label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  margin-bottom: var(--space-1);
}
.stat .delta {
  font-size: var(--fs-xs);
  margin-top: var(--space-1);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--tone, var(--muted));
}
.delta.up { --tone: var(--tone-good); }
.delta.up::before { content: "▲"; font-size: 8px; }
.delta.down { --tone: var(--tone-critical); }
.delta.down::before { content: "▼"; font-size: 8px; }
.delta.flat { --tone: var(--muted); }

/* -- badge: a word first, a colour second ----------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--tone-soft, var(--surface-3));
  color: var(--tone, var(--text-dim));
  border: 1px solid var(--tone-line, var(--border));
  white-space: nowrap;
  line-height: 1.5;
}
.badge-icon { font-size: 0.92em; }

/* Legacy tone names still used by a couple of setup screens. */
.badge.ok { --tone: var(--tone-good); --tone-soft: var(--tone-good-soft); --tone-line: var(--tone-good-line); }
.badge.warn { --tone: var(--tone-attention); --tone-soft: var(--tone-attention-soft); --tone-line: var(--tone-attention-line); }
.badge.bad { --tone: var(--tone-critical); --tone-soft: var(--tone-critical-soft); --tone-line: var(--tone-critical-line); }

/* A rank pill wears the family's rank colour, passed in as --rank. */
.rank-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--rank, var(--text-dim));
  background: color-mix(in srgb, var(--rank, var(--muted)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--rank, var(--muted)) 34%, transparent);
  white-space: nowrap;
}

/* -- progress --------------------------------------------------------- */

.progress { display: flex; flex-direction: column; gap: var(--space-1); }
.progress-label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress-label strong { color: var(--text-dim); font-weight: var(--fw-medium); }

.bar {
  height: 7px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.bar > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--tone, linear-gradient(90deg, var(--accent), var(--accent-hot)));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform var(--dur-slow) var(--ease-out);
}
.bar.thick { height: 10px; }

/* -- avatar: initials underneath, image on top, lazy ------------------ */

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--avatar-size, 40px);
  height: var(--avatar-size, 40px);
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(150deg, var(--surface-4), var(--surface-3));
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: calc(var(--avatar-size, 40px) * 0.36);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar::before { content: attr(data-initials); }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* No background: the initials underneath are the placeholder, so a slow
   * or broken image shows a name rather than a grey disc. */
}
.avatar-lg { --avatar-size: 76px; }
.avatar-sm { --avatar-size: 28px; }

/* -- empty state: says what will appear, and why ---------------------- */

/* Left-aligned and unframed. The dashed rectangle around centred text drew
 * a second border inside a card that already had one, and announced the
 * absence of data as if it were an event. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-5) 0;
  max-width: 52ch;
}
.empty-state h3,
.empty-state h4 {
  margin: 0;
  font-size: var(--fs-card);
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.empty-state p {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.empty-state .action { margin-top: var(--space-2); }

/* The line under a truncated list: it is information, not a caption, so it
 * sits apart from the table rather than inside it. */
/* -- section tabs ------------------------------------------------------
 *
 * Used by «Мой кабинет», where the sections are one person's own eight
 * areas rather than eight pages. A tab carries its own count, because the
 * whole reason to open the portal is to see which of them wants something.
 * On a phone the row scrolls sideways inside itself -- the page never does.
 */

.tabs {
  display: flex;
  gap: var(--space-1);
  /* Wraps where there is room and scrolls where there is not. A row that
   * scrolls on a 1440px screen looks like a bug rather than a choice, and
   * one that wraps on a phone eats half the screen before the content. */
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  padding-bottom: 1px;
}
@media (max-width: 860px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
}

.tabs button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* The count next to a tab. Tone-coloured when something wants doing and
 * quiet otherwise, so a glance along the row finds the one that matters. */
.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--tone-attention-soft);
  color: var(--tone-attention);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
}

/* -- the recruitment board ---------------------------------------------
 *
 * Columns, because "where is everyone stuck" is a question a shape answers
 * faster than a table does. It scrolls sideways inside itself on a narrow
 * screen -- the page never does.
 */

.board {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  align-items: flex-start;
}

.board-column {
  flex: 0 0 240px;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.board-head h3 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-dim);
}

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  /* The tone shows on the left edge: a card waiting too long is visible
   * before anything on it is read. */
  border-left: 3px solid var(--tone, var(--border));
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.board-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.board-card:last-child { margin-bottom: 0; }
.board-card p { margin: var(--space-1) 0 var(--space-2); font-size: var(--fs-xs); }
.board-card select { width: 100%; font-size: var(--fs-xs); }

@media (max-width: 860px) {
  /* One column at a time on a phone: a 240px column inside a 375px screen
   * is a peek at the next one, which reads as a broken layout. */
  .board-column { flex: 0 0 min(280px, 82vw); }
}

.list-note {
  margin: var(--space-4) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}

/* Legacy one-liner; kept because a few setup screens still use it. */
.empty {
  color: var(--muted);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  font-size: var(--fs-sm);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

/* -- error state ------------------------------------------------------ */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  background: var(--tone-critical-soft);
  border: 1px solid var(--tone-critical-line);
  border-left: 3px solid var(--tone-critical);
}
.error-state h4 { color: var(--text); font-size: var(--fs-card); }
.error-state p { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); overflow-wrap: anywhere; }

.muted { color: var(--muted); }
.error { color: var(--tone-critical); }
.ok-text { color: var(--tone-good); font-size: var(--fs-sm); }

/* -- alerts ----------------------------------------------------------- */

.alerts { display: flex; flex-direction: column; gap: var(--space-2); }
.alert {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tone, var(--muted));
  font-size: var(--fs-sm);
}
.alert.warning { --tone: var(--tone-attention); }
.alert.info { --tone: var(--tone-info); }
.alert.critical { --tone: var(--tone-critical); }

/* -- skeletons -------------------------------------------------------- */

.skeleton {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface-3) 70%, transparent), transparent)
      0 0 / 200% 100%,
    var(--surface);
  animation: sweep 1.4s ease-in-out infinite;
}
.skeleton-stat { height: 96px; }
.skeleton-card { height: 96px; }
.skeleton-card.tall,
.skeleton-block { height: 260px; }
.skeleton-row { height: 46px; border-radius: var(--radius-sm); }
.skeleton-list { display: flex; flex-direction: column; gap: var(--space-2); }

@keyframes sweep {
  from { background-position: -120% 0, 0 0; }
  to { background-position: 220% 0, 0 0; }
}

/* ======================================================================
 * 9. Tables — one responsive pattern for every table in the app
 *
 * `table()` in app.js stamps `data-label` onto every cell. Below a phone
 * breakpoint each row turns into a card and the label reappears in front of
 * its value. One rule, every table, no per-table markup.
 * ====================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-clickable] { cursor: pointer; }
tbody tr[data-clickable]:hover { background: var(--surface-3); }
tbody tr[data-clickable]:focus-visible { background: var(--surface-3); box-shadow: var(--ring); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.toolbar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-3);
}
.toolbar.tight { margin-bottom: 0; }

/* ======================================================================
 * 10. Forms and buttons
 * ====================================================================== */

input[type="search"],
input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--fs-sm);
  min-height: var(--tap-min);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
textarea { min-height: 90px; }

input:hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }
input:focus,
select:focus,
textarea:focus { border-color: var(--accent-line); }

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

/* A checkbox cannot be 44px without looking like a button, so the label
 * around it carries the tap target instead -- the whole row is clickable
 * because the control lives inside the <label>. */
.field-inline {
  min-height: var(--tap-min);
  cursor: pointer;
}

input[type="color"] {
  width: 56px;
  height: var(--tap-min);
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

button.action {
  background: linear-gradient(180deg, var(--accent), var(--accent-hot));
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  min-height: var(--tap-min);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}
button.action:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
button.action:active:not(:disabled) { transform: translateY(0); }
button.action:disabled { opacity: 0.45; cursor: default; }

/* A quieter button, for actions that sit next to a primary one. */
button.action.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.action.ghost:hover:not(:disabled) { border-color: var(--border-strong); filter: none; }

/* A destructive action keeps its own tone whatever the family accent is. */
button.action.danger {
  background: var(--tone-critical-soft);
  color: var(--tone-critical);
  border: 1px solid var(--tone-critical-line);
}
button.action.danger:hover:not(:disabled) { filter: none; background: var(--tone-critical-soft); border-color: var(--tone-critical); }

button.action.small { min-height: 34px; padding: var(--space-1) var(--space-3); font-size: var(--fs-xs); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.field { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--fs-sm); }
.field > span { color: var(--text-dim); font-weight: var(--fw-medium); }
.field select,
.field input[type="number"],
.field input[type="url"],
.field input[type="text"] { width: 100%; }
.field-note { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--tone-critical); }

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  padding: var(--space-1) 0;
  min-height: var(--tap-min);
}
.field-inline > span { color: var(--text); font-weight: var(--fw-normal); }

/* ======================================================================
 * 11. Today
 * ====================================================================== */

.greeting {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 58%),
    var(--surface);
  border-color: var(--border-strong);
  padding: var(--space-5);
}
.greeting h2 {
  margin: 0;
  font-size: var(--fs-page);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}
.greeting p { margin: var(--space-1) 0 0; color: var(--text-dim); font-size: var(--fs-sm); }
.greeting-text { min-width: 0; flex: 1; }

.next-event {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}
.next-event-main { min-width: 0; flex: 1 1 260px; display: flex; flex-direction: column; gap: var(--space-2); }
.next-event-title { font-size: var(--fs-section); font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.next-event-meta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.countdown {
  font-size: var(--fs-hero);
  font-weight: var(--fw-bold);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--tone, var(--text));
}
.countdown-caption { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--space-1); }
.countdown-block { flex: none; text-align: right; }

.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: 0; }
.todo-mark {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  background: var(--tone-soft, var(--surface-3));
  color: var(--tone, var(--muted));
  border: 1px solid var(--tone-line, var(--border));
}
.todo-body { flex: 1; min-width: 0; }
.todo-body h4 { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.todo-body p { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.todo-action { flex: none; align-self: center; }

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--fs-sm);
}
.metric-row .metric-value { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }
.metric-stack { display: flex; flex-direction: column; gap: var(--space-4); }

/* ======================================================================
 * 12. Member profile
 * ====================================================================== */

.profile-head {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: center;
}
.profile-identity { min-width: 0; flex: 1 1 240px; display: flex; flex-direction: column; gap: var(--space-2); }
.profile-head h2 {
  font-size: var(--fs-page);
  color: var(--text);
  margin: 0;
  text-transform: none;
  letter-spacing: -0.02em;
  font-weight: var(--fw-bold);
}
.profile-pills { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.profile-facts {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.profile-facts b { color: var(--text-dim); font-weight: var(--fw-medium); }

.achievements {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}
.achievement {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.achievement.earned { border-color: var(--tone-line, var(--border-strong)); background: var(--surface-3); }
.achievement.locked { opacity: 0.55; }
.achievement-icon { font-size: 22px; flex: none; line-height: 1.2; }
.achievement-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: var(--space-1); }
.achievement-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.achievement-tier { font-size: var(--fs-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.achievement-desc { font-size: var(--fs-xs); color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-3) var(--space-4);
  border-left: 1px solid var(--border);
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 20px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone, var(--border-strong));
  border: 1px solid var(--surface);
}
.timeline-body { min-width: 0; flex: 1; }
.timeline-body h4 { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.timeline-body p { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.timeline-when { flex: none; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ======================================================================
 * 13. Events
 * ====================================================================== */

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: var(--space-3);
}

.event-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.event-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.event-card.is-live { border-color: var(--tone-attention-line); }
.event-card.is-live::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--tone-attention);
}

.event-head { display: flex; align-items: flex-start; gap: var(--space-3); justify-content: space-between; }
.event-title { font-size: var(--fs-card); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.event-when {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.event-when .countdown-inline { color: var(--tone, var(--text)); font-weight: var(--fw-semibold); }
.event-foot {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* -- active event mode ------------------------------------------------ */

.event-live-head {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(120deg, var(--tone-attention-soft), transparent 60%), var(--surface);
  border-color: var(--tone-attention-line);
}
.event-live-head .countdown { font-size: 46px; }

.roster-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
}
.roster-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.roster-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.roster-row:hover { background: var(--surface-2); }
.roster-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-count {
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-semibold);
  color: var(--tone, var(--text-dim));
}

/* ======================================================================
 * 14. Branding editor
 * ====================================================================== */

.branding-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: var(--space-5);
  align-items: start;
}

.branding-preview {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
}
.preview-banner {
  height: 92px;
  background: linear-gradient(120deg, var(--preview-accent, var(--accent)), var(--surface-3));
  background-size: cover;
  background-position: center;
}
.preview-body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.preview-identity { display: flex; align-items: center; gap: var(--space-3); margin-top: -38px; }
.preview-mark {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: var(--fw-bold);
  font-size: var(--fs-card);
  background: var(--preview-accent, var(--accent));
  color: var(--preview-ink, var(--accent-ink));
  border: 2px solid var(--surface-2);
}
.preview-mark img { width: 100%; height: 100%; object-fit: cover; }
.preview-name { font-size: var(--fs-section); font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.preview-motto { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.preview-button {
  align-self: flex-start;
  background: var(--preview-accent, var(--accent));
  color: var(--preview-ink, var(--accent-ink));
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.preview-tones { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ======================================================================
 * 15. Charts
 * ====================================================================== */

.chart { width: 100%; height: 180px; display: block; overflow: visible; }
.chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .label {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.chart .bar-rect { fill: url("#bar-gradient"); }

/* The shared gradient in index.html takes its colours from the tokens, so
 * a family accent reaches the charts without a second definition. */
#bar-gradient .stop-a { stop-color: var(--accent); }
#bar-gradient .stop-b { stop-color: var(--accent-hot); }

/* ======================================================================
 * 16. Onboarding, templates, channel tree — the setup screens
 * ====================================================================== */

.ai-output {
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-size: var(--fs-sm);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 55%),
    var(--surface);
  border-color: var(--border-strong);
  padding: var(--space-5) var(--space-6);
}
.hero h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-page);
  font-weight: var(--fw-bold);
  letter-spacing: -0.03em;
}
.hero p { margin: 0; max-width: 62ch; color: var(--text-dim); font-size: var(--fs-body); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}
.step:first-child { padding-top: 2px; }
.step:last-child { border-bottom: 0; padding-bottom: 2px; }

.step-mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.step-mark .icon { width: 15px; height: 15px; vertical-align: 0; }
.todo-mark .icon { width: 14px; height: 14px; vertical-align: 0; }
.step-mark.done {
  background: var(--tone-good-soft);
  color: var(--tone-good);
  border-color: var(--tone-good-line);
}

.step-body { flex: 1; min-width: 0; }
.step-body h4 { margin: 0 0 var(--space-1); font-size: var(--fs-card); }
.step-body p { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.step-action {
  flex: none;
  align-self: center;
  /* A column, because a step that asks before it runs grows a warning line
   * and a cancel button under its button. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}
/* A finished step is one line: the title, and what it produced. It has
 * nothing left to teach, so it stops taking the space of something that
 * does. */
.step-done { padding: var(--space-2) 0; }
.step-done .step-body h4 {
  margin: 0;
  color: var(--text-dim);
  font-weight: var(--fw-medium);
}

/* -- onboarding ------------------------------------------------------- */

/* The hero carries the next step, not a score. Its heading takes the
 * Display role because it is the thing that decides what happens next on
 * this screen; the count of finished steps sits underneath, in a bar,
 * where a number nobody acts on belongs. */
.onboarding-hero {
  align-items: flex-end;
  gap: var(--space-5) var(--space-7);
}
.onboarding-next { flex: 1 1 26rem; min-width: 0; }
.onboarding-next h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-hero);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.03em;
  max-width: 18ch;
}
.onboarding-next p {
  margin: 0;
  max-width: 62ch;
  color: var(--text-dim);
  font-size: var(--fs-body);
}
.onboarding-act {
  margin-top: var(--space-4);
  /* A column for the same reason .step-action is one: this button grows a
   * warning line and a cancel button when it is about to change the server. */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.onboarding-progress { flex: 0 1 220px; min-width: 160px; }
.onboarding-progress .bar { height: 6px; }
/* Two classes, to outrank the `.hero p` body-copy rule above: the count of
 * finished steps is a caption, not prose. */
.onboarding-hero .onboarding-progress-note {
  margin: var(--space-2) 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.onboarding-done { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.onboarding-done .steps { margin-top: var(--space-2); }

/* The sentence a server-changing step shows before it runs. Written with
 * both parents in the selector because the hero and the step row each style
 * their own paragraphs, and a warning that inherits body grey is a warning
 * nobody reads as one. */
.onboarding-act .confirm-note,
.step-action .confirm-note {
  margin: 0;
  max-width: 34ch;
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
  color: var(--tone-attention);
}

@media (max-width: 860px) {
  .onboarding-hero { align-items: stretch; }
  /* Both parents named on purpose: a later `.hero h2` rule in this same
   * breakpoint drops hero headings to the section size, and the next action
   * is not a section label. */
  .onboarding-hero .onboarding-next h2 { font-size: var(--fs-page); max-width: none; }
  .onboarding-progress { flex: 1 1 auto; }
  .step-action { align-self: stretch; }
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: var(--space-3);
}

.template { display: flex; flex-direction: column; gap: var(--space-1); }
.template-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.template p { font-size: var(--fs-sm); margin: var(--space-1) 0; color: var(--text-dim); }
.template code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  background: var(--surface-3);
  padding: 1px var(--space-2);
  border-radius: var(--radius-xs);
  color: var(--text-dim);
}
.template .toolbar { margin: var(--space-3) 0 0; }
.template select { flex: 1; min-width: 0; }

.hint {
  font-size: var(--fs-xs) !important;
  color: var(--muted) !important;
  border-left: 2px solid var(--border-strong);
  padding-left: var(--space-2);
  margin: var(--space-2) 0 !important;
}
.hint.warn { border-left-color: var(--tone-attention); }

details summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--muted);
  padding: var(--space-2) 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸"; font-size: 10px; transition: transform var(--dur) var(--ease); }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { color: var(--text); }

.preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  max-height: 260px;
  overflow-y: auto;
}
.preview .preview-body { white-space: pre-wrap; margin-top: var(--space-2); line-height: 1.55; color: var(--text-dim); padding: 0; }

.publish-output { min-height: 18px; }
.publish-output p { margin: var(--space-2) 0 0; font-size: var(--fs-sm); }
.publish-output a { color: var(--accent); }

/* -- the console layout ------------------------------------------------
 *
 * Used where the page has one subject and some tools that act on it. The
 * subject fills the page; the tools are a bar above it. This replaces the
 * older shape -- one card per region, stacked -- which made every region
 * look equally important and pushed the subject below the fold. A card is
 * for a thing (a member, an application), not for a region of a page.
 */

.console {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

/* Sticky, because on a 62-channel server the tree is longer than the
 * viewport and the tools have to stay in reach without a scroll back up. */
.console-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: linear-gradient(var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
}

.console-create {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.console-create input[type="text"] { flex: 1 1 15rem; min-width: 0; }
.console-create select { flex: 0 1 auto; }
.console-create .action .icon { width: 15px; height: 15px; vertical-align: 0; }

/* The template runner is a drawer. It is used once at setup and then almost
 * never, which is not what a permanently open panel is for. */
.console-tools > summary {
  font-size: var(--fs-sm);
  color: var(--text-dim);
}
.console-tools[open] > summary { margin-bottom: var(--space-3); }
.console-tools-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.console-note {
  margin: 0;
  max-width: 62ch;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}
.console-history h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.console-body { min-width: 0; }

/* A real heading, at a real size. The page used to label this region with
 * the same 11.5px uppercase eyebrow as every other region, so nothing on
 * the page outranked anything else. */
.console-heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.console-heading h2 {
  margin: 0;
  font-size: var(--fs-section);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

/* -- the tree ---------------------------------------------------------
 *
 * An outline, not a list of boxes. No panel, no card, no rounded container
 * per category: a hairline and an indent are enough to say "these belong
 * under that", and they cost no vertical space, which is the whole point
 * when a server has sixty-two channels.
 */

.tree-group { padding-top: var(--space-4); }

.tree-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 0 0 var(--space-1);
}
.tree-head h3 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
  letter-spacing: 0;
}
.tree-count {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tree-head .tree-actions { margin-left: auto; align-self: center; }

.tree {
  list-style: none;
  margin: 0;
  /* The indent guide: one hairline running down the category's children,
   * so the nesting is visible without a box drawn around it. */
  padding: 0 0 0 var(--space-3);
  border-left: 1px solid var(--border);
  margin-left: 3px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  min-height: 30px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-xs);
}
.tree-item:hover { background: var(--surface-2); }
.tree-item:hover .tree-actions,
.tree-item:focus-within .tree-actions { opacity: 1; }

.tree-icon { color: var(--muted); width: 15px; height: 15px; flex: none; vertical-align: 0; }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty {
  padding: var(--space-1) var(--space-2);
  min-height: 30px;
  display: flex;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.tree-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  flex: none;
}

/* A row action is a glyph on the row, not a bordered control: a 62-row tree
 * with 124 outlined buttons in it is a page made of buttons. */
.icon-button.bare {
  width: 26px;
  height: 26px;
  min-height: 0;
  border: 0;
  background: none;
}
.icon-button.bare .icon { width: 15px; height: 15px; }
.icon-button.bare:hover { background: var(--surface-3); color: var(--text); }
.icon-button.bare.danger:hover { background: var(--tone-critical-soft); color: var(--tone-critical); }

@media (hover: none) {
  .tree-actions { opacity: 1; }
  /* Touch needs the full target back. */
  .tree-item { min-height: var(--tap-min); }
  .icon-button.bare { width: var(--tap-min); height: var(--tap-min); }
}

.value-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-2);
  margin: var(--space-2) 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.value-fields .field { gap: var(--space-1); font-size: var(--fs-xs); }

/* ======================================================================
 * 17. Responsive
 * ====================================================================== */

@media (max-width: 1080px) {
  .branding-layout { grid-template-columns: minmax(0, 1fr); }
  .branding-preview { position: static; }
}

/* Below this width the sidebar is replaced by the bottom bar entirely --
 * a wrapped sidebar that eats a third of a phone screen is worse than no
 * sidebar at all. */
@media (max-width: 860px) {
  /* No sidebar column here, so no stripe painted for it either. */
  #app { grid-template-columns: 1fr; background-image: none; }
  .sidebar { display: none; }
  .bottom-nav { display: block; }

  body { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)); }

  .topbar { padding: var(--space-2) var(--space-3); gap: var(--space-2); flex-wrap: wrap; }
  .topbar-title { order: 1; flex: 1 1 auto; }
  .topbar-actions { order: 2; }
  .search { order: 3; flex: 1 1 100%; max-width: none; }
  .topbar h1 { font-size: var(--fs-section); }

  .view { padding: var(--space-4) var(--space-3) var(--space-7); gap: var(--space-3); }
  .card { padding: var(--space-4); }

  .toasts {
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
    bottom: calc(var(--bottom-nav-height) + var(--space-3) + env(safe-area-inset-bottom, 0px));
  }

  .hero,
  .greeting { padding: var(--space-4); }
  .hero h2 { font-size: var(--fs-section); }
  /* The action moves to its own line rather than sitting beside the step
   * at full width, which is what pushed the page 31px past the screen. */
  .step { gap: var(--space-3); flex-wrap: wrap; }
  .step-body { flex: 1 1 160px; }
  .step-action { flex: 1 0 100%; width: 100%; align-self: flex-start; }
  .step-action button { width: 100%; }

  /* --- touch targets ----------------------------------------------
   * 34px is a comfortable button under a mouse and a miss under a
   * thumb. The compact variants exist for density on a desktop, so
   * they give the density back here rather than the size. */
  button.action.small { min-height: var(--tap-min); }
  .link,
  button.link {
    min-height: var(--tap-min);
    display: inline-flex;
    align-items: center;
  }

  .countdown-block { text-align: left; }
  .event-live-head .countdown { font-size: 38px; }

  /* --- the one responsive table pattern --------------------------- */
  .table-wrap { border: 0; background: none; overflow-x: visible; }
  table thead { display: none; }
  table,
  table tbody,
  table tr,
  table td { display: block; width: 100%; }
  table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    padding: var(--space-1) var(--space-3);
  }
  table tr:last-child { margin-bottom: 0; }
  table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  table tr td:last-child { border-bottom: 0; }
  table td::before {
    content: attr(data-label);
    flex: none;
    text-align: left;
    color: var(--muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--fw-semibold);
  }
  /* A cell with no header (an icon column, a bar) keeps the full width. */
  table td[data-label=""] { justify-content: flex-end; }
  table td[data-label=""]::before { content: none; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .grid.wide { grid-template-columns: 1fr; }
  .stat .value { font-size: 22px; }
  .template-grid,
  .event-grid { grid-template-columns: 1fr; }
  .achievements { grid-template-columns: 1fr; }
  .search-kbd { display: none; }
  .next-event { gap: var(--space-3); }
  .countdown { font-size: 28px; }
}

/* 320px is the narrowest phone still in use; nothing may overflow there. */
@media (max-width: 380px) {
  :root { --space-5: 18px; --space-6: 20px; }
  .view { padding: var(--space-3) var(--space-2) var(--space-7); }
  .card { padding: var(--space-3); }
  .profile-facts { gap: var(--space-2); font-size: var(--fs-xs); }
  .bottom-nav button { font-size: 9.5px; }
}

/* ======================================================================
 * 18. Motion preferences — last, so it wins.
 * ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Exceptions: motion here carries a state change, not decoration --
   * a toast that has no fade still needs a moment to be read before it
   * is gone, and a progress fill or an opening palette must stay legible
   * as *changing*, not just jump between two static states unseen. */
  .toast,
  .toast.leaving,
  [role="progressbar"] > span,
  .palette-backdrop,
  .palette-box {
    animation-duration: var(--dur-fast) !important;
    transition-duration: var(--dur-fast) !important;
  }
}

/* --- modules -------------------------------------------------------------
 *
 * Cards rather than a list of switches. Each one has to fit a sentence
 * about what the module does and a sentence about what turning it off
 * costs -- a row with a toggle on the right has room for neither, and a
 * switch nobody understands is a switch nobody touches.
 */

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.module-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Dimmed, not hidden: a family has to be able to find the thing it turned
 * off in order to turn it back on. */
.module-card.is-off {
  opacity: 0.72;
}

.module-card > p {
  margin: 0;
  font-size: var(--fs-sm);
}

.module-parts {
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

ul.plain {
  margin: var(--space-2) 0;
  padding-left: var(--space-4);
  font-size: var(--fs-sm);
}

ul.plain li {
  margin-bottom: var(--space-1);
}

/* --- the public page -----------------------------------------------------
 *
 * Shares the dashboard's tokens rather than defining a second palette:
 * two sets of colours drift, and the first thing somebody notices after
 * logging in should not be that the product changed colour.
 *
 * One column, generous measure, no components that need JavaScript. The
 * page has to work with the script blocked -- the only script on it is the
 * bookmark redirect, and a visitor who never had a bookmark loses nothing.
 */

.landing-body {
  background: var(--bg-glow), var(--bg);
  color: var(--text);
}

.landing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) 0;
}

.landing {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

/* Named apart from the dashboard's `.hero` on purpose: that one is a
 * horizontal card with a progress ring in it, and sharing the name made
 * this column lay itself out sideways. */
.landing-hero {
  padding: var(--space-7) 0 var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.landing-hero h1 {
  /* Clamped rather than fixed: the headline is the one element that has to
   * survive a 320px phone and a 27-inch monitor without a media query. */
  font-size: clamp(26px, 4.4vw, 44px);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}

.lede {
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 62ch;
  margin: 0;
}

.landing-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.landing-note {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin: 0;
  max-width: 62ch;
}

.landing-block {
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
}

.landing-block h2 {
  font-size: clamp(19px, 2.4vw, 26px);
  margin: 0 0 var(--space-4);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.landing-grid h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-card);
}

.landing-grid p {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 58ch;
}

.landing-list {
  margin: 0;
  padding-left: var(--space-5);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-2) var(--space-5);
  line-height: 1.6;
  color: var(--text-dim);
}

.landing-foot {
  border-top: 1px solid var(--border);
  padding: var(--space-5) 0 var(--space-6);
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* The footer link is the second way into the panel, and on a phone it was
 * a 15px-tall target. Given a real one rather than shrunk to fit the line
 * it sits on. */
.landing-foot a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-2);
  margin-left: calc(var(--space-2) * -1);
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.button.ghost:hover {
  filter: none;
  border-color: var(--accent);
}

/* ======================================================================
 * v9 — серверная область: выбор сервера, ожидание установки, формы
 * настройки. Токены те же, что выше; ни одного литерального цвета.
 * ====================================================================== */

.servers { display: flex; flex-direction: column; gap: var(--space-6); }

.server-group h2 {
  font-size: var(--fs-section);
  margin: 0 0 var(--space-2);
}

.server-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
}

/* Карточка сервера — одна большая цель нажатия, а не подпись со ссылкой
 * сбоку: на телефоне попасть в неё нужно с первого раза. */
.server-card-body {
  width: 100%;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.server-card-body:hover:not(:disabled) { border-color: var(--accent); }
.server-card-body:disabled { opacity: 0.55; cursor: not-allowed; }

.server-card-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; flex: 1; }

.server-card-name {
  font-weight: 620;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-card-marks { display: flex; flex-wrap: wrap; gap: var(--space-1); }

.server-card-cta { color: var(--muted); white-space: nowrap; }
.server-card-cta.primary { color: var(--accent); font-weight: 620; }

/* --- ожидание установки ------------------------------------------------ */

.pending { max-width: 34rem; display: flex; flex-direction: column; gap: var(--space-4); }

.pending-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pending-actions, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* --- формы настройки --------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: var(--space-5); }

.field { display: flex; flex-direction: column; gap: var(--space-1); margin: var(--space-3) 0; }
.field-label { font-weight: 620; }
.field-hint { color: var(--muted); font-size: var(--fs-sm); }

.field input, .field select, .field textarea {
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  width: 100%;
}

.field textarea { min-height: 90px; resize: vertical; }

.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  cursor: pointer;
}

.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.toggle.small { min-height: 34px; }

.row { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

.callout {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Предупреждение о хранении переписки — единственное место, где карточка
 * настройки повышает голос, и повод для этого настоящий. */
.callout.warn { border-left-color: var(--tone-attention); }

.facts { list-style: none; margin: 0; padding: 0; }
.facts li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.facts li:last-child { border-bottom: 0; }

/* --- модули сервера ---------------------------------------------------- */

.module-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.module-card.is-on { border-color: var(--accent-line); }

.module-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: var(--tap-min);
  cursor: pointer;
}

.module-head input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.module-summary { margin: var(--space-2) 0 0; }
.module-off { color: var(--muted); font-size: var(--fs-sm); }

.submodules {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* --- обращения --------------------------------------------------------- */

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }

.event {
  padding: var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

/* Внутренняя заметка выглядит иначе, чем ответ автору: одинаковые карточки
 * — это переписка, в которой однажды отправят заметку не туда. */
.event.is-internal {
  background: transparent;
  border: 1px dashed var(--border-strong);
}

.event-head { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; font-weight: 620; }

.nav-group-label {
  color: var(--muted);
  font-size: var(--fs-2xs);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0 var(--space-3);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

@media (max-width: 860px) {
  .server-list { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: 1fr; }
}
