/* ===========================================================================
   ASTHERION OS: the shared interface.

   One stylesheet for every page. Before this, each page carried its own
   inline styles: three typefaces, five button styles, four card styles and
   gold on almost everything, so nothing a teammate learned on one page held
   on the next. Pages now link this file and keep only what is truly theirs.

   The rules this file encodes (docs/design/os-interface.md has the reasoning):

   1. Gold means "this needs you". Aurion (#c1b79f) marks a due follow-up, an
      item waiting on a decision, the count of things to triage. It is never
      a button colour, a border or a heading. A screen with nothing waiting
      has no gold on it at all.
   2. Aether white is for information and for the primary action. One primary
      button per view.
   3. Dark and quiet. The room is a deeper Noctis, close to Void, lit from one
      cool corner; surfaces step up from it by a shade, lines barely show,
      and the one warm thing on a screen is the gold that needs you.
   4. DM Sans for everything a person reads, the hub's name included. The
      wordmark is a supplied file and is never typed out by hand (Brand
      System v4.0); --mark (Cormorant Garamond) is left only for the house
      seal in the Studio's preview, which mirrors the blog.
   5. Straight, quiet geometry: hairlines, 6px controls, 10px panels. Status
      pills are the only round shapes.
   6. Sentence case, no tracked capitals, no dot-joined metadata.

   Contrast, measured on ground / raised / raised-2:
     ink 16.1 / 15.2 / 13.8    ink-2 7.5 / 7.1 / 6.4    ink-3 5.5 / 5.2 / 4.7
     signal 9.9 / 9.3 / 8.5    edge (controls) 3.6 / 3.4 / 3.1
   =========================================================================== */

:root {
  color-scheme: dark;

  /* ground and surfaces */
  --ground: #010c13;          /* Noctis taken down toward Void: the room */
  --raised: #05151e;          /* panels, drawers */
  --raised-2: #0a1f2b;        /* hover and selected rows */
  --sunk: #00080d;            /* fields sit slightly below the surface */
  --side: #00090f;            /* the sidebar, a shade under the room */
  --line: #12262f;            /* dividers, non-interactive edges */
  --edge: #4f6d7d;            /* anything you can click or type into */
  --glow: rgba(18, 58, 78, 0.42); /* the one cool light, top right */

  /* ink */
  --ink: #e4e9eb;             /* Aether, softened so it does not glare */
  --ink-2: #94a2aa;
  --ink-3: #788a93;
  --on-ink: #010c13;          /* text on an Aether-filled button */

  /* meaning */
  --signal: #c1b79f;          /* Aurion: needs you, the one warm point */
  --signal-wash: rgba(193, 183, 159, 0.09);
  --clear: #86c498;           /* done, positive */
  --caution: #cf8d68;         /* due, overdue, careful */
  --alert: #e39494;           /* errors and destructive actions only */

  /* type */
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --mark: 'Cormorant Garamond', Georgia, serif;
  --t-meta: 12.5px;
  --t-small: 13.5px;
  --t-body: 15px;
  --t-lead: 17px;
  --t-h3: 15px;
  --t-h2: 19px;
  --t-title: 32px;

  /* geometry */
  --r-ctl: 6px;
  --r-panel: 10px;
  --side-w: 252px;
  --bar-h: 56px;
  --gutter: 40px;

  /* the shell's names, kept so older pages and the shell itself still resolve */
  --os-ink: var(--ink);
  --os-ink-2: var(--ink-2);
  --os-ink-3: var(--ink-3);
  --os-gold: var(--signal);
  --os-edge: var(--edge);
}

@media (max-width: 720px) {
  :root { --t-title: 26px; --gutter: 16px; }
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: transparent; color: var(--ink);
  font-family: var(--sans); font-size: var(--t-body); line-height: 1.55;
  font-optical-sizing: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
/* One low cool light from the top right corner, and the far corner left in
   the dark. Fixed, so it stays put while the page scrolls under it. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 760px at 88% -14%, var(--glow), transparent 62%),
    radial-gradient(900px 700px at -8% 112%, rgba(0, 0, 0, 0.55), transparent 60%);
}
::selection { background: rgba(228, 233, 235, 0.2); }
a { color: var(--ink); text-decoration-color: rgba(242, 245, 246, 0.35); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; color: var(--ink); }
p { margin: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Headings take focus after a view changes so a screen reader starts there;
   a ring around a heading nobody tabbed to reads as a selection. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 14px; height: 14px; }
.ic.xs { width: 12px; height: 12px; }

/* ---------------------------------------------------------------------------
   Page frame. The shell draws the sidebar (desktop) or the bars (phone); a
   page supplies <main class="page"> and its header.
   --------------------------------------------------------------------------- */
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 36px var(--gutter) 96px; }
.page.wide { max-width: 1480px; }
.page.narrow { max-width: 780px; }
@media (max-width: 720px) { .page { padding-top: 18px; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head-text { min-width: 0; flex: 1 1 420px; }
.page-title { font-size: var(--t-title); font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; }
.page-purpose { margin-top: 8px; max-width: 62ch; color: var(--ink-2); font-size: var(--t-body); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 720px) {
  .page-head { margin-bottom: 16px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}

/* The readout: one sentence under the title saying what needs you here.
   It is the only place a page header uses gold, and only when something is
   actually waiting. */
.readout { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; font-size: var(--t-body); color: var(--ink-2); max-width: 70ch; }
.readout::before { content: ''; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--ink-3); }
.readout.needs { color: var(--ink); }
.readout.needs::before { background: var(--signal); box-shadow: 0 0 0 4px var(--signal-wash); }
.readout b, .readout strong { font-weight: 600; color: var(--ink); }
.readout.needs b, .readout.needs strong { color: var(--signal); }
.readout a, .readout button.link { color: inherit; }

/* ---------------------------------------------------------------------------
   Tabs: a quiet underline row. Sticky under the phone bar.
   --------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 24px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; margin-bottom: -1px;
  font: 500 var(--t-body)/1 var(--sans); color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"], .tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.tab .count { font-size: var(--t-meta); color: var(--ink-3); font-weight: 500; }
.tab .count.needs { color: var(--signal); font-weight: 600; }
.tab:focus-visible { outline-offset: -3px; }
@media (max-width: 1023px) {
  .tabs.sticky { position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 30; background: var(--ground); margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
}

/* ---------------------------------------------------------------------------
   Sections, panels, lists
   --------------------------------------------------------------------------- */
.section { margin-top: 36px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title { font-size: var(--t-h2); font-weight: 600; }
.section-note { color: var(--ink-3); font-size: var(--t-small); }
.h3 { font-size: var(--t-h3); font-weight: 600; }

.panel { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px; box-shadow: inset 0 1px 0 rgba(228, 233, 235, 0.03); }
.panel.tight { padding: 14px 16px; }
.panel + .panel { margin-top: 12px; }

/* Rows with hairlines: the default way to show a set of things. */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list > li, .list > .row { border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; min-height: 56px; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.row-meta { color: var(--ink-2); font-size: var(--t-small); margin-top: 2px; overflow-wrap: anywhere; }
.row-side { display: flex; align-items: center; gap: 8px; flex: none; color: var(--ink-3); font-size: var(--t-small); }
a.row, button.row { width: 100%; text-align: left; color: inherit; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
a.row:hover, button.row:hover, .row.link:hover { background: var(--raised); }
.row.needs .row-title::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); margin-left: 8px; vertical-align: 2px; }

/* Key-value pairs */
.kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: var(--t-small); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }

/* Stats: a number and what it counts. Only a number that needs you is gold. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.stat { background: var(--ground); padding: 16px 18px; }
.stat-n { font-size: 28px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; }
.stat-l { color: var(--ink-2); font-size: var(--t-small); margin-top: 4px; }
.stat.needs .stat-n { color: var(--signal); }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-ctl); border: 1px solid var(--edge);
  background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 600 14px/1 var(--sans); letter-spacing: -0.005em;
}
.btn:hover { background: var(--raised-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: transparent; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: #f2f5f6; }
.btn-primary:disabled:hover { background: var(--ink); }
.btn-quiet { border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { color: var(--ink); background: var(--raised); }
.btn-danger { border-color: rgba(232, 154, 154, 0.55); color: var(--alert); }
.btn-danger:hover { background: rgba(232, 154, 154, 0.08); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn .ic { width: 15px; height: 15px; }
.icon-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--edge); background: var(--raised); }
.icon-btn.sm { width: 30px; height: 30px; }
.link { appearance: none; background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: rgba(242, 245, 246, 0.35); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
@media (max-width: 720px) {
  .btn, .btn-sm { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; } .icon-btn.sm { width: 44px; height: 44px; }
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; min-width: 0; }
.label { display: block; margin-bottom: 6px; font-size: var(--t-small); font-weight: 600; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--ink-3); }
.hint { margin-top: 6px; font-size: var(--t-small); color: var(--ink-3); line-height: 1.5; }
.error-text { margin-top: 6px; font-size: var(--t-small); color: var(--alert); }
.input, .select, .textarea {
  display: block; width: 100%; margin: 0; padding: 10px 12px; border-radius: var(--r-ctl);
  border: 1px solid var(--edge); background: var(--sunk); color: var(--ink);
  font: 400 var(--t-body)/1.4 var(--sans);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a9b6bd' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 245, 246, 0.14); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--alert); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
/* 16px stops iOS zooming the page when a field takes focus. */
@media (max-width: 1023px) { .input, .select, .textarea { font-size: 16px; } }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--t-body); }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }

/* Segmented choice: pick one of a few. Uses aria-pressed on buttons. */
.seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: calc(var(--r-ctl) + 2px); background: var(--sunk); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button {
  appearance: none; background: none; border: none; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--r-ctl);
  font: 500 13.5px/1 var(--sans); color: var(--ink-2);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--raised-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.seg .n { color: var(--ink-3); font-size: 12px; }
.seg.block { display: flex; }
.seg.block button { flex: 1 1 auto; justify-content: center; }
@media (max-width: 720px) { .seg button { min-height: 40px; } }

/* Chips: toggles and filters. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: transparent; color: var(--ink-2);
  font: 500 13px/1 var(--sans); cursor: pointer; text-decoration: none;
}
.chip:hover { color: var(--ink); border-color: var(--edge); }
.chip[aria-pressed="true"], .chip.on { color: var(--ink); border-color: var(--ink); background: var(--raised-2); }
@media (max-width: 720px) { .chip { min-height: 40px; } }

/* ---------------------------------------------------------------------------
   Status pills: words first, colour second.
   --------------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.4; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill-needs { color: var(--signal); border-color: rgba(193, 183, 159, 0.45); background: var(--signal-wash); }
.pill-clear { color: var(--clear); border-color: rgba(143, 209, 158, 0.4); }
.pill-caution { color: var(--caution); border-color: rgba(211, 144, 105, 0.45); }
.pill-alert { color: var(--alert); border-color: rgba(232, 154, 154, 0.45); }
.pill-quiet { color: var(--ink-3); }
a.pill { text-decoration: none; }
a.pill:hover { border-color: currentColor; }
.row-go { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: var(--t-small); font-weight: 600; white-space: nowrap; }
a.row:hover .row-go { color: var(--ink); }
@media (max-width: 560px) { .row-go .row-go-text { display: none; } }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; background: var(--raised-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500; }

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-panel); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--raised-2); }
.table td.strong, .table .strong { color: var(--ink); font-weight: 600; }
.table .right { text-align: right; }

/* ---------------------------------------------------------------------------
   Empty and error states: a direction, never a mood.
   --------------------------------------------------------------------------- */
/* Prose: answers, company facts, program text. Rendered by md.js. */
.prose { max-width: 70ch; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.prose > * + * { margin-top: 12px; }
.prose h2, .prose h3, .prose h4, .prose h5 { font-size: var(--t-body); font-weight: 600; margin-top: 22px; line-height: 1.4; }
.prose h2 { font-size: var(--t-h3); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 5px; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--raised-2); border-radius: 4px; padding: 1px 5px; }
.prose pre { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 12px 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 2px solid var(--edge); padding-left: 14px; color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.prose .scroller { overflow-x: auto; }
.prose table { border-collapse: collapse; font-size: var(--t-small); }
.prose th, .prose td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink-2); font-weight: 600; }
.prose .ev { display: inline-block; padding: 0 5px; margin: 0 2px; border: 1px solid var(--line); border-radius: 4px; font-size: 11.5px; color: var(--ink-2); vertical-align: 1px; }
.empty { padding: 40px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r-panel); }
.empty-title { font-size: var(--t-lead); font-weight: 600; }
.empty-text { color: var(--ink-2); margin: 8px auto 0; max-width: 52ch; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.empty.small { padding: 20px 16px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-panel); border: 1px solid var(--line); background: var(--raised); font-size: var(--t-small); color: var(--ink-2); }
.notice.error { border-color: rgba(232, 154, 154, 0.5); color: var(--ink); }
.notice.error::before { content: ''; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--alert); }
.status { min-height: 20px; margin-top: 8px; font-size: var(--t-small); color: var(--ink-2); }
.status.ok { color: var(--clear); }
.status.err { color: var(--alert); }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 56px 0; color: var(--ink-2); font-size: var(--t-small); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: os-spin 0.9s linear infinite; }
@keyframes os-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   Drawer (side panel), dialog and toast
   --------------------------------------------------------------------------- */
body.os-locked { overflow: hidden; }
.drawer-bg { position: fixed; inset: 0; z-index: 90; background: rgba(0, 5, 9, 0.72); display: flex; justify-content: flex-end; }
.drawer { width: min(560px, 100vw); height: 100%; display: flex; flex-direction: column; background: var(--raised); border-left: 1px solid var(--line); box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45); animation: os-slide 0.22s cubic-bezier(0.22, 0.61, 0.36, 1); }
.drawer.wide { width: min(780px, 100vw); }
@keyframes os-slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: calc(18px + env(safe-area-inset-top)) 22px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.drawer-sub { color: var(--ink-2); font-size: var(--t-small); margin-top: 4px; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 22px 28px; }
.drawer-foot { flex: none; display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--raised); }
.drawer-sec { padding: 18px 0; border-top: 1px solid var(--line); }
.drawer-sec:first-child { border-top: none; }
@media (max-width: 560px) { .drawer-foot .btn { flex: 1 1 auto; } }

.dialog-bg { position: fixed; inset: 0; z-index: 110; background: rgba(0, 5, 9, 0.78); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: min(460px, 100%); max-height: 90vh; overflow-y: auto; background: var(--raised); border: 1px solid var(--edge); border-radius: var(--r-panel); padding: 22px; box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6); animation: os-rise 0.16s ease-out; }
.dialog-title { font-size: 18px; font-weight: 600; }
.dialog-text { margin-top: 8px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
@media (max-width: 480px) { .dialog-actions .btn { flex: 1 1 auto; } }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(18px + var(--os-tabbar-h, 0px)); z-index: 120; max-width: 480px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-radius: var(--r-panel); background: var(--raised-2); border: 1px solid var(--edge); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); color: var(--ink); font-size: 14px; animation: os-rise 0.18s ease-out; }
.toast.err { border-color: rgba(232, 154, 154, 0.6); }
.toast-act { appearance: none; background: none; border: none; cursor: pointer; flex: none; padding: 6px 8px; border-radius: var(--r-ctl); font: 600 14px/1 var(--sans); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
@keyframes os-rise { from { transform: translateY(8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .drawer, .toast { animation: none; }
  .spinner { animation: none; }
}
@media (forced-colors: active) {
  .btn, .chip, .seg, .input, .select, .textarea, .panel, .pill { border: 1px solid CanvasText; }
  .tab[aria-selected="true"] { border-bottom-color: Highlight; }
  .readout.needs::before, .row.needs .row-title::after { background: Highlight; }
}

/* Phone touch targets, last so they win over the base sizes above. */
@media (max-width: 720px) {
  .chip, .seg button { min-height: 44px; }
  .toast-act { min-height: 44px; min-width: 44px; }
}
