/* ── Account settings (/settings/, and the tabs of /users/<pk>/) ───────────
   A stack of panels inside one tab — «Безпека» and «Оформлення» here, the same two
   subjects on the account page — capped narrow enough that the forms inside stay
   readable on a wide screen. Both pages' *first* tab is a two-column grid instead:
   `.account-cols` (pages/accounts.css) there, `.settings-cols` below here. */
.settings-page { display: flex; flex-direction: column; gap: 16px; max-width: var(--panel-measure); }

/* The first tab of «Мій обліковий запис»: two columns of *equal* width, where
   `/users/<pk>/` gives its own left column the wider track (`.account-cols`). The
   difference is what is in them — there a form with a person picker and a multi-select,
   here a four-row readout, which beside «Стан запису» over «Входи та спроби» left the
   tab lopsided.

   `auto-fit` rather than `repeat(2, …)` so the layout follows the content: an account
   without `users.logins` renders no second panel at all (the partial emits nothing), so
   the grid has one child, the sibling track collapses, and the remaining one spans the
   width instead of leaving a hole where a panel would be. The 360px minimum is what
   decides the collapse to a single column — below two of them plus the gap there is only
   ever one track, so this needs no breakpoint of its own. `min-width: 0` on the children
   for the reason `.account-cols` spells out: a grid item's `auto` minimum is its content,
   so a long unbroken value inside one widens the page rather than the box. */
.settings-cols {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}
.settings-cols > * { min-width: 0; }
/* …and when there *is* only one column, cap it like the tabs beside it — the same
   measure, hence the same token: a six-row readout whose values start at 200px reads as
   a stretched table across a 1400px screen. `:has()` rather than a class from the view,
   because «скільки тут колонок» is a fact about this markup — the same reasoning
   `.theme-tile:has(input:checked)` below is written with. */
.settings-cols:has(> :only-child) { max-width: var(--panel-measure); }

/* The profile readout is a plain `.dl` (same one the person/movement/location
   details use) — only the nested list of access-group names is new. */
.dl-list { list-style: none; margin: 5px 0 0; padding: 0; color: var(--muted); font-size: 12.5px; }

.settings-form { max-width: 420px; }
.settings-state { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }

/* ── Theme picker (the «Оформлення» section of /settings/) ─────────────────
   Mode segmented control + palette grid + the save status line. Each .swatch resolves
   the palette's own tokens (themes.css duplicates every selector onto
   `.swatch[data-theme][data-mode]`), so the preview is pixel-accurate and
   js/settings/theme.js only flips the swatch's data-mode.

   Every control is a <label> wrapping a radio, so the picker is an ordinary form
   that submits without JS; `:has(input:checked)` is what draws the selection.

   The grid is `auto-fill` rather than a fixed three columns, and that is a consequence
   of the catalogue: the palette list grew past ten and will grow again, so «скільки в
   рядку» is a fact about the available width and the tile's own legible minimum, not a
   number to retune per palette added. The minimum is 128px because below that the
   miniature below stops being readable as a shell — and once the track is intrinsic the
   phone breakpoint the old fixed grid needed disappears with it. */
.theme-picker { display: flex; flex-direction: column; gap: 16px; }
.tile-input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.theme-tile:focus-within, .theme-mode-btn:focus-within { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.theme-mode {
  display: flex; gap: 6px; padding: 4px;
  background: var(--panel-3); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.theme-mode-btn {
  flex: 1; cursor: pointer; padding: 8px 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--muted);
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
}
.theme-mode-btn:hover { color: var(--text); }
.theme-mode-btn:has(input:checked) {
  background: var(--panel); border-color: var(--border-bright);
  color: var(--text-strong); box-shadow: var(--shadow);
}
/* The ☀/☾ glyph is a font glyph rather than an icon from the set, so it needs its own
   size — at label size it read as punctuation next to the word. */
.theme-mode-glyph { font-size: 15px; line-height: 1; }

.theme-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
}
.theme-tile {
  position: relative; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font-family: var(--font-display);
  transition: border-color .12s, transform .12s;
}
.theme-tile:hover { border-color: var(--border-bright); color: var(--text); transform: translateY(-1px); }
/* Two rings, not one: the tile is one of sixteen and the selected one has to be
   findable without reading, so the accent border is doubled by an inset ring of the
   same colour — a 2px border would shift the tile's contents by a pixel on selection. */
.theme-tile:has(input:checked) {
  border-color: var(--accent); color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.theme-tile-name { font-size: 12px; font-weight: 600; text-align: center; }
.theme-tile-check {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
  border: 1px solid var(--panel-2);
  opacity: 0; transform: scale(.6); transition: opacity .12s, transform .12s;
}
.theme-tile-check .icon { width: 12px; height: 12px; }
.theme-tile:has(input:checked) .theme-tile-check { opacity: 1; transform: none; }

/* ── The swatch: the app's own shell, in miniature ─────────────────────────
   Sidebar strip + topbar + a card with two lines of ink and the primary action, all
   reading the very tokens the real surfaces read. It replaced an abstract «panel with a
   dot», which could not show the one thing that most distinguishes two palettes — how
   the page, the chrome and a card sit against each other. khaki is the case that
   proves it: its whole character is a dark drab sidebar inside a light theme, and the
   previous swatch had no sidebar to show it in (themes.css names `.swatch-nav` in that
   palette's chrome block for exactly this).

   Everything inside is sized in px rather than in %, because the tile's width follows
   the grid track: the miniature must read the same at 128px and at 200px, so only the
   sheet grows.

   What the miniature deliberately leaves out is the paper: flat `--bg` / `--panel`
   fills, no `var(--paper)` / `var(--surface)` layers. Two reasons, and either alone
   would do. The speckle is a 140px tile and the wash a two-stop gradient over a whole
   card — at 40px of preview neither is a texture, it is a single flat tint shift. And
   `--paper` is *composed* on `:root` (base/tokens.css), so a custom property that
   already substituted `--grain` there is what a descendant inherits: a swatch
   previewing a light palette from inside a dark page would carry the page's speckle
   flavour, not its own. The tokens that matter at this size — the surfaces, the ink and
   the accent — are all read live. */
.swatch {
  display: flex; aspect-ratio: 8 / 5; overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.swatch-nav {
  flex: none; width: 26px; padding: 5px 4px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--bg-2); border-right: 1px solid var(--border);
}
.swatch-brand { height: 4px; border-radius: 2px; background: var(--signal); margin-bottom: 2px; }
.swatch-navline { height: 2px; border-radius: 2px; background: var(--muted-2); }
.swatch-navline.short { width: 60%; }
.swatch-main { flex: 1; min-width: 0; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.swatch-topbar { height: 5px; border-radius: 2px; background: var(--panel-2); border: 1px solid var(--border); }
.swatch-panel {
  flex: 1; padding: 5px; border-radius: 3px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  background: var(--panel); border: 1px solid var(--border);
}
.swatch-line { height: 3px; width: 82%; border-radius: 3px; background: var(--text); opacity: .75; }
.swatch-line.short { width: 52%; background: var(--muted); opacity: 1; }
.swatch-btn { height: 6px; width: 34%; border-radius: 2px; background: var(--accent); margin-top: 1px; }

/* ── The save status line ──────────────────────────────────────────────────
   The only feedback there is: the picker has no «Зберегти» (see `_theme_picker.html`),
   and on somebody else's account page nothing repaints either. `data-state` is set by
   js/settings/theme.js; the tone is chosen here so that the semantic tokens are read in
   one place. Its `min-height` reserves the line, or the grid above would jump by a row
   height every time the sentence changes length. */
.theme-status {
  margin: 0; min-height: 18px;
  font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.theme-status[data-state="saved"] { color: var(--ok); }
.theme-status[data-state="failed"] { color: var(--danger); }

/* Transient confirmation after a successful modal save. */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border-bright);
  border-left: 3px solid var(--ok); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 13px;
}
