/* AIvan component layer — direction 4a.
 *
 * Transcribed from designs/AIvan Components.dc.html, component by component.
 * Where the library and aivan-tokens.css disagree on a number, the library
 * wins: it is the drawing that was approved, and the token file is a summary
 * of it. Shell values (frame width, header, page padding, tab bar) come from
 * designs/AIvan Portal.dc.html, which draws the same components in situ.
 *
 * Layout is two widths and no more. Desktop is a content column plus a fixed
 * 340px rail; below 900px it is the phone layout at full width, with the rail's
 * contents moved above the content because a phone is where you act rather than
 * survey. There is deliberately no tablet breakpoint.
 */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ai-canvas);
  color: var(--ai-ink);
  font-family: var(--ai-font-sans);
  font-size: var(--ai-text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Values the library uses that the token file does not carry. */
:root {
  --ai-disabled-fill:  #EDECF2;
  --ai-disabled-ink:   #9A98A8;
  --ai-field-disabled: #F2F1F5;
  --ai-track:          #E6E4EE;
  --ai-track-strong:   #DEDCE5;
  --ai-placeholder:    #767489;   /* placeholder and secondary mono in chrome */
  --ai-focus-ring:      0 0 0 4px rgba(124, 108, 240, 0.24);
  --ai-focus-ring-soft: 0 0 0 4px rgba(124, 108, 240, 0.18);

  /* Interactive outlines come in two weights in the library: .18 on buttons,
     .16 on fields and card edges. */
  --ai-line-field:  rgba(25, 24, 38, 0.16);
  --ai-line-card:   rgba(25, 24, 38, 0.16);

  /* Semantic borders as the library draws them on alerts and amber cards. */
  --ai-warn-edge:  rgba(168, 118, 28, 0.45);
  --ai-bad-edge:   rgba(194, 80, 58, 0.45);
  --ai-good-edge:  rgba(47, 125, 116, 0.40);

  --ai-modal-shadow: 0 20px 44px rgba(25, 24, 38, 0.12);

  --ai-frame-max: 1280px;
}

/* Headlines are 500. The library sets a lighter headline against heavier mono
   figures; at 700 every screen shouts. Only the display size is 700. */
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font-size: var(--ai-text-h1); letter-spacing: -0.03em; line-height: 1.1; }
h2 { font-size: var(--ai-text-h2); letter-spacing: -0.02em; line-height: 1.2; }
h3 { font-size: var(--ai-text-h3); letter-spacing: -0.015em; line-height: 1.3; }
p { margin: 0; }

.ai-display { font-size: var(--ai-text-display); letter-spacing: -0.04em; line-height: 1; font-weight: 700; }
.ai-lead { font-family: var(--ai-font-serif); font-size: var(--ai-text-lead); line-height: 1.6; color: var(--ai-body); text-wrap: pretty; }
.ai-serif { font-family: var(--ai-font-serif); color: var(--ai-ink-serif); line-height: 1.7; }
.ai-body { color: var(--ai-body); }
.ai-muted { color: var(--ai-muted); }

/* Mono uppercase, 10px at 0.12em. This is the library's card label and it is
   used everywhere a panel names itself. */
.ai-label {
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-label);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ai-muted);
  line-height: 1.4;
}

/* The page's own eyebrow is one step up and tracked wider. */
.ai-eyebrow {
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ai-muted);
  line-height: 1.4;
}

/* Numeric figures are always mono. A metric set in sans reads as prose. */
.ai-metric {
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-metric);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ai-ink);
}
.ai-figure { font-family: var(--ai-font-mono); font-variant-numeric: tabular-nums; }

.ai-icon { flex: none; vertical-align: middle; }

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

/* ---- Shell ------------------------------------------------------------- */

/* The app is a white frame on the grey canvas, not a full-bleed page. The grey
   only ever shows as the margin around it. */
.ai-frame {
  max-width: var(--ai-frame-max);
  margin: var(--ai-space-5) auto;
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius-frame);
  min-height: calc(100vh - var(--ai-space-8));
}

/* One bar: brand, nav, search, then the account. 18/28 padding, a .12 rule
   under it, and no fill — the tint on the current page is the only colour. */
.ai-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-6);
  padding: 18px 28px;
  background: var(--ai-surface);
  border-bottom: 1px solid rgba(25, 24, 38, 0.12);
  border-radius: var(--ai-radius-frame) var(--ai-radius-frame) 0 0;
}

.ai-header-start { display: flex; align-items: center; gap: var(--ai-space-2); min-width: 0; }

.ai-brand { display: inline-flex; align-items: center; gap: var(--ai-space-2); color: var(--ai-ink); }
.ai-brand:hover { color: var(--ai-ink); }
.ai-brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.035em; }

.ai-divider { width: 1px; height: 18px; margin: 0 4px; background: var(--ai-line); flex: none; }

/* The mark: two glyphs on solid black. The A/i asymmetry is what survives
   being shrunk to a favicon, so it is never swapped for a symmetrical pair. */
.ai-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ai-ink);
  color: #FFFFFF;
  font-weight: 700;
  font-size: var(--ai-text-sm);
  letter-spacing: -0.02em;
  flex: none;
}

/* Inside an app the bar names it and carries its controls. The mark stays as
   the way home, so the app name is the only title on the row. */
.ai-app-name { font-size: var(--ai-text-sm); font-weight: 500; color: var(--ai-ink); white-space: nowrap; }
.ai-app-name:hover { color: var(--ai-ink); }
.ai-crumb { font-family: var(--ai-font-mono); font-size: var(--ai-text-eyebrow); color: var(--ai-muted); white-space: nowrap; }

.ai-nav { display: flex; align-items: center; gap: 2px; }

/* The selected item is held by the lavender tint rather than a heavy fill. */
.ai-nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--ai-space-1);
  padding: 6px 13px;
  border-radius: var(--ai-radius-pill);
  color: var(--ai-body);
  font-size: var(--ai-text-sm);
  white-space: nowrap;
}
.ai-nav a:hover { background: var(--ai-surface-sunken); color: var(--ai-ink); }
.ai-nav a[aria-current="page"] {
  background: var(--ai-accent-chip);
  color: var(--ai-accent-ink);
  font-weight: 500;
}

/* Search is the centre of the bar, not a button tucked at the end. */
.ai-search {
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-2);
  padding: 9px 16px;
  border: 1px solid var(--ai-line-field);
  border-radius: var(--ai-radius-pill);
  background: var(--ai-surface-sunken);
  color: var(--ai-placeholder);
  font-family: inherit;
  font-size: var(--ai-text-sm);
  cursor: pointer;
  text-align: left;
}
.ai-search:hover { border-color: var(--ai-line-strong); }
.ai-search-inner { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-search-placeholder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-header-end { display: flex; align-items: center; gap: var(--ai-space-1); }

.ai-page { padding: 32px 28px 40px; }

/* A supporting sentence is small grey sans. Mono uppercase is for short
   labels beside a figure — a whole sentence set that way is unreadable. */
.ai-note {
  font-size: var(--ai-text-xs);
  line-height: 1.5;
  color: var(--ai-body);
  text-wrap: pretty;
}

/* Meta that sits inline after a title: mono, sentence case, not tracked. */
.ai-inline-meta {
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-xs);
  color: var(--ai-muted);
}

/* Content column, then a rail. Never two panels of equal weight side by side —
   the eye has to know where to start. */
.ai-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--ai-space-5);
  align-items: start;
}

.ai-stack { display: flex; flex-direction: column; gap: var(--ai-space-5); }
.ai-stack-tight { display: flex; flex-direction: column; gap: var(--ai-space-2); }
.ai-row { display: flex; align-items: center; gap: var(--ai-space-2); }
.ai-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--ai-space-3); }
.ai-wrap { flex-wrap: wrap; }

/* ---- Surfaces ---------------------------------------------------------- */

.ai-panel {
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius-panel);
  padding: var(--ai-space-5) var(--ai-panel-pad-x);
}

/* The library's card is the 18px radius, not the 14px one — 14px is for the
   smaller inner tiles that sit inside a card. */
.ai-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-line-card);
  border-radius: var(--ai-radius-panel);
  padding: 20px 20px 22px;
}

/* Well: the same container on the sunken ground, for nested lists. */
.ai-well {
  background: var(--ai-surface-sunken);
  border: 1px solid var(--ai-line-card);
  border-radius: var(--ai-radius-panel);
  padding: 20px 20px 22px;
}

/* A block set into a card: sunken, hairline, 12px radius. */
.ai-inset {
  background: var(--ai-surface-sunken);
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-inner);
  padding: var(--ai-space-3);
}

/* The same container holding rows instead of prose: white, and flush, because
   the rows bring their own padding and their own separators. */
.ai-inset-list {
  background: var(--ai-surface);
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-inner);
  overflow: hidden;
}
.ai-inset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-2);
  padding: 11px 14px;
  font-size: var(--ai-text-sm);
}
.ai-inset-row + .ai-inset-row { border-top: 1px solid var(--ai-line-soft); }
/* Striping is opt-in: the library's nested list is plain white, and only a
   longer table of figures earns the zebra. */
.ai-inset-zebra .ai-inset-row:nth-child(odd) { background: var(--ai-surface-sunken); }

/* Inside a padded panel the head is a rule with space around it. */
.ai-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ai-space-3);
  padding-bottom: var(--ai-space-3);
  margin-bottom: var(--ai-space-3);
  border-bottom: 1px solid var(--ai-line-soft);
}

/* A panel that carries a flush head has no padding of its own — the head and
   the body set their own, and the head's rule runs the full width. */
.ai-panel-framed > .ai-panel-head {
  align-items: center;
  padding: 14px 20px;
  margin: 0;
  border-bottom-color: rgba(25, 24, 38, 0.12);
}

.ai-panel-framed {
  background: var(--ai-surface);
  border: 1px solid var(--ai-line-card);
  border-radius: var(--ai-radius-panel);
  overflow: hidden;
}
.ai-panel-body { padding: 6px 20px 18px; }

.ai-accent-panel { background: var(--ai-accent-wash); border-color: var(--ai-accent-line); }
.ai-warn-panel { background: var(--ai-warn-wash); border-color: var(--ai-warn-line); }
.ai-good-panel { background: var(--ai-good-wash); border-color: var(--ai-good-line); }

/* The accent stripe that names an app card. */
.ai-card-strip { height: 4px; background: var(--ai-accent); }
.ai-card-strip-warn { background: var(--ai-warn); }
.ai-card-strip-tint { background: var(--ai-accent-chip); }

.ai-raised { box-shadow: 0 24px 60px rgba(25, 24, 38, 0.14); }

/* ---- Controls ---------------------------------------------------------- */

/* Every control is a pill. This is the single most visible thing about the
   library — a rounded rectangle reads as a different product.

   One selector only: a `button.ai-button` compound here would outrank every
   variant class below it and repaint outline buttons lavender. */
.ai-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-accent);
  color: #FFFFFF;
  font-family: inherit;
  font-size: var(--ai-text-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.ai-button:hover { background: var(--ai-accent-hover); color: #FFFFFF; }
.ai-button:focus-visible { outline: none; box-shadow: var(--ai-focus-ring); }

.ai-button-primary { background: var(--ai-accent); color: #FFFFFF; }
.ai-button-primary:hover { background: var(--ai-accent-hover); }

/* Ink: the commit action on a page that already carries lavender elsewhere. */
.ai-button-ink { background: var(--ai-ink); color: #FFFFFF; }
.ai-button-ink:hover { background: #000000; color: #FFFFFF; }

/* Outline: the neutral secondary. White, not tinted. */
.ai-button-outline {
  background: var(--ai-surface);
  border-color: var(--ai-line-strong);
  color: var(--ai-ink);
}
.ai-button-outline:hover { background: var(--ai-surface-sunken); color: var(--ai-ink); }

/* Tint: an accented action that is not the primary one on the page. */
.ai-button-secondary { background: var(--ai-accent-chip); color: var(--ai-accent-ink); }
.ai-button-secondary:hover { background: var(--ai-accent-line); color: var(--ai-accent-ink); }

/* Quiet: dismissals and "not now". No fill, no border. */
.ai-button-quiet { background: transparent; color: var(--ai-accent-ink); }
.ai-button-quiet:hover { background: var(--ai-accent-wash); color: var(--ai-accent-ink); }

.ai-button-danger {
  background: var(--ai-surface);
  border-color: var(--ai-bad-edge);
  color: var(--ai-bad-strong);
}
.ai-button-danger:hover { background: #FBF0EC; color: var(--ai-bad-strong); }

/* Header chrome: a small outlined pill, quieter type than a page action. */
.ai-button-nav {
  padding: 8px 14px;
  gap: 7px;
  background: var(--ai-surface);
  border-color: var(--ai-line-strong);
  color: var(--ai-body);
  font-size: 12.5px;
  font-weight: 400;
}
.ai-button-nav:hover { background: var(--ai-surface-sunken); color: var(--ai-ink); }

.ai-button-sm { padding: 7px 14px; font-size: var(--ai-text-xs); }

/* The shortcut, worn as a control. Inside an app it stands in for the whole
   search field, which the app's own controls have taken the room for. */
.ai-button-kbd { font-family: var(--ai-font-mono); font-size: 11.5px; color: var(--ai-muted); }
.ai-button-lg { padding: 15px 28px; font-size: 15px; }

/* The card action row: 9/16 at 12px, one step in from a page action. */
.ai-button-card { padding: 9px 16px; font-size: var(--ai-text-xs); }

/* The banner's pair of answers, one step down again. */
.ai-button-xs { padding: 8px 15px; font-size: var(--ai-text-xs); }

/* A timeline entry's action: fixed height so a column of them lines up. */
.ai-button-tl { min-height: 34px; padding: 0 15px; font-size: 12.5px; }

/* A round icon button. 40px on desktop; the phone rule below takes it to 44. */
.ai-button-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--ai-surface);
  border-color: var(--ai-line-strong);
  color: var(--ai-ink);
  font-size: 15px;
}
.ai-button-icon:hover { background: var(--ai-surface-sunken); color: var(--ai-ink); }

.ai-button:disabled,
.ai-button[aria-disabled="true"] {
  background: var(--ai-disabled-fill);
  border-color: transparent;
  color: var(--ai-disabled-ink);
  cursor: not-allowed;
}

/* Segmented group: one pill, hard-divided, the selection filled ink. */
.ai-segmented {
  display: inline-flex;
  border: 1px solid var(--ai-line-field);
  border-radius: var(--ai-radius-pill);
  overflow: hidden;
  background: var(--ai-surface);
}
.ai-segmented > * {
  padding: 9px 18px;
  font-size: var(--ai-text-sm);
  font-weight: 500;
  color: var(--ai-ink);
  background: transparent;
  border: none;
  border-left: 1px solid rgba(25, 24, 38, 0.12);
  font-family: inherit;
  cursor: pointer;
}
.ai-segmented > *:first-child { border-left: none; }
.ai-segmented > [aria-pressed="true"],
.ai-segmented > [aria-current="true"] { background: var(--ai-ink); color: #FFFFFF; }

/* Filter pills: the timeline's own control, smaller than a button. */
.ai-filters { display: flex; gap: 6px; }
.ai-filter {
  padding: 5px 12px;
  border: 1px solid var(--ai-line-strong);
  border-radius: var(--ai-radius-pill);
  background: transparent;
  color: var(--ai-body);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.ai-filter[aria-pressed="true"] { background: var(--ai-ink); border-color: var(--ai-ink); color: #FFFFFF; }

/* A toolbar of pills wrapped in a track. */
.ai-pillbar {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius-pill);
  background: var(--ai-surface-sunken);
}
.ai-pillbar > * {
  padding: 8px 16px;
  border-radius: var(--ai-radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ai-muted);
  font-family: inherit;
  font-size: var(--ai-text-sm);
  cursor: pointer;
}
.ai-pillbar > [aria-current="page"],
.ai-pillbar > [aria-pressed="true"] {
  background: var(--ai-surface);
  border-color: rgba(25, 24, 38, 0.12);
  color: var(--ai-ink);
  font-weight: 500;
}

/* Underline tabs, for switching view inside one app. */
.ai-tabs { display: flex; gap: 22px; align-items: center; }
.ai-tabs > * {
  padding-bottom: var(--ai-space-1);
  border-bottom: 2px solid transparent;
  color: var(--ai-muted);
  font-size: var(--ai-text-body);
}
.ai-tabs > [aria-current="page"] { border-bottom-color: var(--ai-accent); color: var(--ai-ink); font-weight: 500; }

.ai-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--ai-space-1);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-xs);
  color: var(--ai-muted);
}
.ai-breadcrumb > [aria-current="page"] { color: var(--ai-ink); }

.ai-pagination { display: flex; align-items: center; gap: 6px; }
.ai-pagination > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--ai-radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ai-ink);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-xs);
}
.ai-pagination > .ai-pagination-step { border-color: var(--ai-line-field); font-family: inherit; font-size: var(--ai-text-body); color: var(--ai-muted); }
.ai-pagination > [aria-current="page"] { background: var(--ai-ink); color: #FFFFFF; }

/* Sidebar rail of app links. */
.ai-sidebar {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 18px 16px;
  background: var(--ai-surface-sunken);
  border-right: 1px solid rgba(25, 24, 38, 0.12);
}
.ai-sidebar > .ai-label { padding: 6px 12px 10px; }
.ai-sidebar a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ai-ink);
  font-size: var(--ai-text-body);
}
.ai-sidebar a:hover { background: var(--ai-surface); color: var(--ai-ink); }
.ai-sidebar a[aria-current="page"] { background: var(--ai-accent-chip); color: var(--ai-accent-ink); font-weight: 500; }

.ai-spinner {
  width: 12px;
  height: 12px;
  border-radius: var(--ai-radius-pill);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
  animation: ai-spin 0.8s linear infinite;
  flex: none;
}
/* On white, the same spinner is tint-on-accent rather than white-on-accent. */
.ai-spinner-accent {
  width: 16px;
  height: 16px;
  border-color: var(--ai-accent-chip);
  border-top-color: var(--ai-accent);
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-shimmer { 0% { opacity: 0.45; } 50% { opacity: 1; } 100% { opacity: 0.45; } }
@keyframes ai-pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* ---- Chips, badges, status ---------------------------------------------- */

/* Chips are accent-outlined by default, not grey, and set in tracked mono. */
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--ai-radius-pill);
  background: transparent;
  border: 1px solid var(--ai-accent-line);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-label);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ai-accent-ink);
  white-space: nowrap;
}
.ai-chip-new { background: var(--ai-accent-chip); border-color: transparent; color: var(--ai-accent-ink); }
/* The one chip that reports a live count rather than a category. */
.ai-chip-live { padding: 4px 11px; gap: 7px; background: var(--ai-accent-wash); letter-spacing: 0.1em; color: var(--ai-ink); }
.ai-chip-neutral { border-color: var(--ai-line-field); color: var(--ai-muted); }
.ai-chip-good { background: var(--ai-good-wash); border-color: var(--ai-good-line); color: var(--ai-good); }
/* Amber text is #8A6420. The lighter #A8761C is for dots, bars and borders. */
.ai-chip-warn { background: var(--ai-warn-wash); border-color: var(--ai-warn-line); color: var(--ai-warn-ink); }
.ai-chip-bad { background: #FBF0EC; border-color: rgba(180, 83, 42, 0.3); color: var(--ai-bad); }
/* Tag chip: sentence-case sans with a remove affordance, not a mono label. */
.ai-chip-tag {
  padding: 5px 10px 5px 12px;
  background: var(--ai-accent-chip);
  border-color: transparent;
  font-family: inherit;
  font-size: var(--ai-text-xs);
  letter-spacing: normal;
  text-transform: none;
}
.ai-chip-tag button {
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  opacity: 0.7;
  font-size: var(--ai-text-sm);
  cursor: pointer;
}

/* A figure badge is a rounded rectangle, not a pill — it reads as data. */
.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--ai-accent-chip);
  color: var(--ai-accent-ink);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-label);
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.ai-badge-ink { background: var(--ai-ink); color: #FFFFFF; }
.ai-badge-up { background: transparent; border: 1px solid var(--ai-good-edge); color: var(--ai-good); }
.ai-badge-down { background: transparent; border: 1px solid rgba(194, 80, 58, 0.4); color: var(--ai-bad-strong); }
/* The timeline's "new" marker: smaller again, and 5px-cornered. */
.ai-badge-sm { padding: 2px 7px; border-radius: 5px; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }

.ai-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-accent);
  color: #FFFFFF;
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-eyebrow);
}

.ai-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-accent-chip);
  color: var(--ai-accent-ink);
  font-family: inherit;
  font-size: var(--ai-text-sm);
  font-weight: 500;
  cursor: pointer;
}
/* In the bar the account is ink, and one step smaller. */
.ai-avatar-ink {
  width: 32px;
  height: 32px;
  background: var(--ai-ink);
  color: #FFFFFF;
  font-size: var(--ai-text-xs);
}

/* Status: a dot and a sentence. The dot carries the colour so the text can
   stay ink and remain readable. */
.ai-status { display: inline-flex; align-items: center; gap: var(--ai-space-1); font-size: var(--ai-text-sm); color: var(--ai-ink); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ai-dot-sm { width: 7px; height: 7px; }
.ai-dot-xs { width: 6px; height: 6px; }
.ai-dot-accent { background: var(--ai-accent); }
.ai-dot-warn { background: var(--ai-warn); }
.ai-dot-good { background: var(--ai-good); }
.ai-dot-bad { background: var(--ai-bad-strong); }
.ai-dot-idle { background: var(--ai-track-strong); }
/* Absent is an outline, never a filled shape. */
.ai-dot-absent { background: transparent; border: 1px dashed var(--ai-accent); }
.ai-dot-pending { border: 1.5px solid var(--ai-accent); background: var(--ai-surface); }
.ai-pulse { animation: ai-pulse 1.6s ease-in-out infinite; }
.ai-shimmer { animation: ai-shimmer 1.4s ease-in-out infinite; }

/* ---- Fields -------------------------------------------------------------- */

/* Fields are 12px-radius rectangles — only the search field is a pill. */
.ai-field {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--ai-line-field);
  border-radius: var(--ai-radius-inner);
  background: var(--ai-surface);
  color: var(--ai-ink);
  font-family: inherit;
  font-size: var(--ai-text-body);
}
.ai-field::placeholder { color: var(--ai-disabled-ink); }
.ai-field:focus {
  outline: none;
  border-color: var(--ai-accent);
  box-shadow: var(--ai-focus-ring-soft);
}
.ai-field[aria-invalid="true"] { border-color: var(--ai-bad-strong); }
.ai-field:disabled {
  background: var(--ai-field-disabled);
  border-color: var(--ai-line-soft);
  color: var(--ai-disabled-ink);
}
.ai-field-search { border-radius: var(--ai-radius-pill); }
.ai-field-error { margin-top: var(--ai-space-1); font-size: var(--ai-text-xs); color: var(--ai-bad-strong); }
/* Notes are prose, so a textarea is serif. */
textarea.ai-field {
  min-height: 76px;
  font-family: var(--ai-font-serif);
  line-height: 1.6;
  color: var(--ai-body);
  resize: vertical;
}
select.ai-field { appearance: none; background-image: none; }

/* A field label is the card label, given room to breathe. */
.ai-field-label { display: block; margin-bottom: var(--ai-space-1); }
.ai-field-label-focus { color: var(--ai-accent-ink); }
.ai-field-label-error { color: var(--ai-bad-strong); }

/* Checkbox and radio: 20px, drawn rather than native. */
.ai-check,
.ai-radio {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
  border: 1px solid rgba(25, 24, 38, 0.24);
  background: var(--ai-surface);
  cursor: pointer;
}
.ai-check { border-radius: 6px; }
.ai-radio { border-radius: var(--ai-radius-pill); }
.ai-check:checked {
  background: var(--ai-accent);
  border-color: var(--ai-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}
.ai-radio:checked { border: 5px solid var(--ai-accent); }
.ai-check:focus-visible,
.ai-radio:focus-visible { outline: none; box-shadow: var(--ai-focus-ring); }

/* Switch: 44×26 with a 20px knob. */
.ai-switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  flex: none;
  border: none;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-track-strong);
  cursor: pointer;
}
.ai-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: var(--ai-radius-pill);
  background: #FFFFFF;
  transition: transform 0.14s ease;
}
.ai-switch:checked { background: var(--ai-accent); }
.ai-switch:checked::after { transform: translateX(18px); }
.ai-switch:focus-visible { outline: none; box-shadow: var(--ai-focus-ring); }

/* Range: a 6px track with a bordered white thumb. */
.ai-range { appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
.ai-range {
  --ai-range-fill: 50%;
}
.ai-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--ai-radius-pill);
  /* WebKit has no ::-moz-range-progress, so the filled part of the track is a
     hard-stop gradient the caller positions with --ai-range-fill. */
  background: linear-gradient(
    to right,
    var(--ai-accent) 0 var(--ai-range-fill),
    var(--ai-track) var(--ai-range-fill) 100%
  );
}
.ai-range::-moz-range-track { height: 6px; border-radius: var(--ai-radius-pill); background: var(--ai-track); }
.ai-range::-moz-range-progress { height: 6px; border-radius: var(--ai-radius-pill); background: var(--ai-accent); }
.ai-range::-webkit-slider-thumb {
  appearance: none;
  margin-top: -7px;
  width: 20px;
  height: 20px;
  border-radius: var(--ai-radius-pill);
  background: #FFFFFF;
  border: 1px solid var(--ai-line-strong);
  box-shadow: 0 1px 3px rgba(25, 24, 38, 0.16);
}
.ai-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--ai-radius-pill);
  background: #FFFFFF;
  border: 1px solid var(--ai-line-strong);
  box-shadow: 0 1px 3px rgba(25, 24, 38, 0.16);
}

.ai-meter {
  height: 8px;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-disabled-fill);
  overflow: hidden;
}
.ai-meter-sm { height: 6px; }
.ai-meter > span { display: block; height: 100%; border-radius: var(--ai-radius-pill); background: var(--ai-accent); }
.ai-meter-mid > span { background: #A79BF5; }
.ai-meter-over > span { background: var(--ai-bad-strong); }

.ai-kbd {
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-label);
  color: var(--ai-placeholder);
}

/* ---- Lists and data ------------------------------------------------------ */

.ai-list { display: flex; flex-direction: column; }
.ai-list > * + * { border-top: 1px solid var(--ai-line-hair); }
.ai-list-row { display: flex; gap: var(--ai-space-3); padding: var(--ai-space-3) 0; }

/* Table: mono label head on the sunken ground, zebra body, figures right. */
.ai-table { width: 100%; border-collapse: collapse; }
.ai-table thead th {
  padding: 12px 18px;
  background: var(--ai-surface-sunken);
  border-bottom: 1px solid rgba(25, 24, 38, 0.12);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-label);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ai-muted);
  text-align: left;
}
.ai-table tbody td { padding: 13px 18px; font-size: var(--ai-text-sm); vertical-align: baseline; }
.ai-table tbody tr + tr td { border-top: 1px solid var(--ai-line-soft); }
.ai-table tbody tr:nth-child(even) td { background: var(--ai-surface-sunken); }
.ai-table .ai-num { font-family: var(--ai-font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.ai-up { color: var(--ai-good); }
.ai-down { color: var(--ai-bad-strong); }

/* Bar chart: tint bars, the one being pointed at in full accent. */
.ai-bars { display: flex; align-items: flex-end; gap: 7px; height: 84px; }
.ai-bars > * { flex: 1; border-radius: 5px; background: var(--ai-accent-chip); }
.ai-bars > .ai-bar-on { background: var(--ai-accent); }

/* A row of segments: the briefing's arrived/expected strip and the tutor's
   queue are the same shape at different heights. */
.ai-segments { display: flex; gap: 4px; }
.ai-segments > * { flex: 1; height: 26px; border-radius: 5px; background: var(--ai-track-strong); }
.ai-segments > .ai-seg-on { background: var(--ai-accent); }
.ai-segments > .ai-seg-due { background: transparent; border: 1px dashed rgba(124, 108, 240, 0.5); }
.ai-segments > .ai-seg-warn { background: var(--ai-warn); }
.ai-segments > .ai-seg-bad { background: var(--ai-bad-strong); }

/* Step ticks: the same idea at 6px, for progress through a known count. */
.ai-steps { display: flex; gap: 5px; }
.ai-steps > * { flex: 1; height: 6px; border-radius: var(--ai-radius-pill); background: var(--ai-disabled-fill); }
.ai-steps > .ai-step-on { background: var(--ai-accent); }

/* A stacked proportion bar. */
.ai-stackbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; }

/* Absent is not zero: a day with no data is a dashed outline, never a filled
   shape at the baseline. */
.ai-absent {
  border: 1px dashed rgba(25, 24, 38, 0.2);
  background: transparent;
  border-radius: var(--ai-radius-inner);
  color: var(--ai-muted);
}
.ai-daygrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ai-daygrid > * { height: 20px; border-radius: 5px; }

/* ---- Feedback ------------------------------------------------------------ */

/* Alert: a dot, a title and a line of detail, on white with a coloured edge.
   The wash is reserved for panels; an alert stays white so a stack of them
   does not turn the page into stripes. */
.ai-alert {
  display: flex;
  gap: var(--ai-space-2);
  padding: 14px 16px;
  border: 1px solid var(--ai-accent-line);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface);
}
.ai-alert > .ai-dot { margin-top: 6px; }
.ai-alert-title { font-size: var(--ai-text-body); font-weight: 500; }
.ai-alert-body { margin-top: 3px; font-size: var(--ai-text-sm); color: var(--ai-body); }
.ai-alert-good { border-color: var(--ai-good-edge); }
.ai-alert-warn { border-color: var(--ai-warn-edge); }
.ai-alert-bad { border-color: var(--ai-bad-edge); }

/* The one banner across the top of Today: an alert laid out as a row. */
.ai-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-5);
  padding: 15px 20px;
  border: 1px solid var(--ai-accent-line);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface);
  flex-wrap: wrap;
}
.ai-banner-warn { border-color: var(--ai-warn-edge); }
.ai-banner-bad { border-color: var(--ai-bad-edge); }

.ai-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-3);
  padding: 14px 18px;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-ink);
  color: #FFFFFF;
  font-size: var(--ai-text-sm);
}
.ai-toast a, .ai-toast button { color: var(--ai-accent-line); background: none; border: none; font: inherit; cursor: pointer; }

.ai-tip {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--ai-ink);
  color: #FFFFFF;
  font-size: var(--ai-text-xs);
}

/* Empty state: dashed, sunken, centred, with one way out. */
.ai-empty {
  padding: 34px 24px;
  text-align: center;
  border: 1px dashed rgba(25, 24, 38, 0.24);
  border-radius: var(--ai-radius-panel);
  background: var(--ai-surface-sunken);
  color: var(--ai-muted);
}
.ai-empty-mark { width: 44px; height: 44px; margin: 0 auto; border-radius: var(--ai-radius-pill); background: var(--ai-accent-chip); }
.ai-empty-title { margin-top: var(--ai-space-3); font-size: 18px; font-weight: 500; letter-spacing: -0.015em; color: var(--ai-ink); }
.ai-empty-body {
  margin: var(--ai-space-1) auto 18px;
  max-width: 320px;
  font-family: var(--ai-font-serif);
  font-size: var(--ai-text-body);
  line-height: 1.6;
  color: var(--ai-body);
}

.ai-skeleton {
  height: 14px;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-disabled-fill);
  animation: ai-shimmer 1.4s ease-in-out infinite;
}

/* Legacy content fills the bottom of the frame, so it has to round with it. */
.legacy-app { border-radius: 0 0 var(--ai-radius-frame) var(--ai-radius-frame); }

/* A task reads as one line: what it is, its figures, and what to do — not a
   stack. The whole point of the rail is that it can be scanned. */
.ai-task {
  display: flex;
  align-items: center;
  gap: var(--ai-space-3);
  flex-wrap: wrap;
}
.ai-task-body { flex: 1; min-width: 200px; }
.ai-task-actions { display: flex; align-items: center; gap: var(--ai-space-1); }

/* ---- Timeline ------------------------------------------------------------ */

/* Time, a dot on its rail, then the entry. The dot column is 5px wide so the
   rail lines up down the page regardless of how tall an entry runs. */
.ai-timeline { display: flex; flex-direction: column; }
.ai-tl-row {
  display: flex;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--ai-line-hair);
}
.ai-tl-row:last-child { border-bottom: none; }
.ai-tl-time {
  width: 46px;
  flex: none;
  padding-top: 2px;
  font-family: var(--ai-font-mono);
  font-size: 11.5px;
  color: var(--ai-body);
}
.ai-tl-rail { width: 5px; flex: none; display: flex; justify-content: center; padding-top: 6px; }
.ai-tl-body { flex: 1; min-width: 0; }
.ai-tl-app { font-family: var(--ai-font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ai-muted); }
.ai-tl-title { margin-top: 6px; font-size: 15.5px; font-weight: 500; letter-spacing: -0.015em; }
.ai-tl-text { margin-top: 5px; font-size: var(--ai-text-sm); line-height: 1.5; color: var(--ai-body); text-wrap: pretty; }
.ai-tl-action { flex: none; align-self: center; }
/* The trailing note: what has not happened yet, on the same rail. */
.ai-tl-foot { display: flex; gap: 18px; padding: 16px 0 4px; font-size: var(--ai-text-sm); color: var(--ai-muted); }

/* ---- Command palette --------------------------------------------------- */

.ai-palette {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 12vh var(--ai-space-3) var(--ai-space-3);
  background: rgba(25, 24, 38, 0.34);
}
.ai-palette[hidden] { display: none; }

.ai-palette-sheet {
  width: min(760px, 100%);
  max-height: 76vh;
  overflow-y: auto;
  background: var(--ai-surface);
  border: 1px solid var(--ai-line-card);
  border-radius: 20px;
}

.ai-palette-input {
  display: flex;
  align-items: center;
  gap: var(--ai-space-2);
  padding: 16px 20px;
  border-bottom: 1px solid rgba(25, 24, 38, 0.12);
  color: var(--ai-muted);
}
.ai-palette-input .ai-field { border: none; padding: 0; font-size: 15px; }
.ai-palette-input .ai-field:focus { outline: none; box-shadow: none; }

.ai-palette-body { padding: 10px; }
.ai-palette-body > .ai-label { padding: 8px 12px 10px; }
.ai-palette-rule { height: 1px; margin: 10px 12px; background: var(--ai-line-soft); }

.ai-palette-actions, .ai-palette-results { display: flex; flex-direction: column; }

/* An action carries its app as a tile; a destination is just a line. */
.ai-palette-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-3);
  padding: 12px;
  border-radius: var(--ai-radius-inner);
  color: var(--ai-ink);
}
.ai-palette-action:hover,
.ai-palette-action[aria-selected="true"] { background: var(--ai-accent-chip); color: var(--ai-ink); }
.ai-palette-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--ai-line);
  background: var(--ai-surface-sunken);
  color: var(--ai-muted);
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-eyebrow);
}
.ai-palette-action[aria-selected="true"] .ai-palette-sub { color: var(--ai-accent-ink); }
.ai-palette-action[aria-selected="true"] .ai-palette-tile {
  background: var(--ai-accent);
  border-color: var(--ai-accent);
  color: #FFFFFF;
}
.ai-palette-name { display: block; font-size: var(--ai-text-body); font-weight: 500; }
.ai-palette-sub { display: block; margin-top: 2px; font-size: var(--ai-text-xs); color: var(--ai-muted); }
.ai-palette-meta { font-family: var(--ai-font-mono); font-size: var(--ai-text-eyebrow); color: var(--ai-muted); flex: none; }

.ai-palette-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-3);
  padding: 11px 12px;
  border-radius: var(--ai-radius-inner);
  color: var(--ai-ink);
  font-size: var(--ai-text-body);
}
.ai-palette-result:hover { background: var(--ai-surface-sunken); color: var(--ai-ink); }
.ai-palette-result .ai-palette-meta { color: var(--ai-placeholder); }

/* ---- Dialog -------------------------------------------------------------- */

.ai-dialog {
  border: 1px solid var(--ai-line-card);
  border-radius: var(--ai-radius-panel);
  background: var(--ai-surface);
  padding: 22px;
  box-shadow: var(--ai-modal-shadow);
}
.ai-dialog-title { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.ai-dialog-body { margin: var(--ai-space-1) 0 18px; font-family: var(--ai-font-serif); font-size: var(--ai-text-body); line-height: 1.6; color: var(--ai-body); }
.ai-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.ai-dialog-actions .ai-button { padding: 10px 18px; }

/* ---- Disclosure ---------------------------------------------------------- */

.ai-accordion { border: 1px solid var(--ai-line); border-radius: var(--ai-radius-panel); background: var(--ai-surface); overflow: hidden; }
.ai-accordion > details + details,
.ai-accordion > details:not(:first-child) { border-top: 1px solid var(--ai-line-soft); }
.ai-accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-2);
  padding: 16px 20px;
  font-size: 15px;
  cursor: pointer;
  list-style: none;
}
.ai-accordion summary::-webkit-details-marker { display: none; }
.ai-accordion summary::after { content: "▸"; color: var(--ai-muted); }
/* An open row keeps the tinted header, which is how you find your place in a
   long stack of sections. */
.ai-accordion details[open] > summary { background: var(--ai-surface-sunken); border-bottom: 1px solid var(--ai-line-soft); font-weight: 500; }
.ai-accordion details[open] > summary::after { content: "▾"; }
.ai-accordion-body { padding: 18px 20px; font-family: var(--ai-font-serif); font-size: var(--ai-text-body); line-height: 1.65; color: var(--ai-body); }

/* ---- App pieces ---------------------------------------------------------- */

.ai-audio { display: flex; align-items: center; gap: 14px; }
.ai-audio-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex: none;
  border: none;
  border-radius: var(--ai-radius-pill);
  background: var(--ai-accent);
  color: #FFFFFF;
  font-size: 15px;
  cursor: pointer;
}
.ai-audio-track { flex: 1; }
.ai-audio-times {
  margin-top: var(--ai-space-1);
  display: flex;
  justify-content: space-between;
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-eyebrow);
  color: var(--ai-muted);
}
.ai-audio-rate {
  padding: 6px 12px;
  flex: none;
  border: 1px solid var(--ai-line-field);
  border-radius: var(--ai-radius-pill);
  background: transparent;
  font-family: var(--ai-font-mono);
  font-size: var(--ai-text-eyebrow);
  color: var(--ai-muted);
  cursor: pointer;
}

/* ---- Sign in ----------------------------------------------------------- */

/* The one screen with no frame around it: the card is the whole app. */
.ai-login-card h1 { font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.ai-login-card .ai-mark { width: 36px; height: 36px; border-radius: 11px; font-size: var(--ai-text-body); }
.ai-login-card .ai-field { padding: 14px 16px; font-size: 15px; }
.ai-login-card .ai-button { padding: 15px 20px; font-size: 15px; }
.ai-login-foot { text-align: center; letter-spacing: 0.08em; }

.ai-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--ai-space-5);
}
.ai-login-card { width: min(420px, 100%); }

/* ---- Today ---------------------------------------------------------------

   Two questions, in this order: what happened, and what is waiting. The head
   gives the headline the full width and puts the day-step and the single
   primary action on the baseline beside it.
*/

.ai-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ai-space-8); flex-wrap: wrap; }
.ai-page-head h1, .ai-page-head .ai-display { margin-top: var(--ai-space-2); }
.ai-page-head .ai-lead { margin-top: var(--ai-space-2); }
.ai-page-actions { display: flex; align-items: center; gap: 10px; }

/* Waiting-on-you: white cards on the accent wash, so the rail reads as one
   thing rather than a stack of separate panels. */
.ai-waiting { display: flex; flex-direction: column; gap: var(--ai-space-1); margin-top: 14px; }
.ai-waiting-item { display: block; padding: 14px 15px 15px; border-radius: var(--ai-radius-inner); background: var(--ai-surface); color: var(--ai-ink); }
.ai-waiting-item:hover { color: var(--ai-ink); box-shadow: 0 1px 3px rgba(25, 24, 38, 0.10); }
.ai-waiting-head { display: flex; align-items: baseline; gap: 10px; }
.ai-waiting-title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; }
.ai-waiting-meta { flex: none; font-family: var(--ai-font-mono); font-size: 10.5px; color: var(--ai-muted); }
.ai-waiting-meta-warn { color: var(--ai-warn-ink); }
.ai-waiting-body { margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: var(--ai-body); text-wrap: pretty; }

/* Where the data came from: a dot, a name, and who wrote it. No chips — the
   point is which apps are now written by hand, not a status board. */
.ai-sources { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.ai-source-row { display: flex; align-items: center; gap: 11px; }
.ai-source-name { flex: 1; min-width: 0; font-size: var(--ai-text-sm); color: var(--ai-ink); }
.ai-source-by { flex: none; font-family: var(--ai-font-mono); font-size: 10.5px; color: var(--ai-muted); }
.ai-source-by-warn { color: var(--ai-warn-ink); }
.ai-card-foot { margin-top: var(--ai-space-3); padding-top: 14px; border-top: 1px solid var(--ai-line-soft); }

/* ---- Apps ----------------------------------------------------------------

   Three columns, and every tile carries the figure its app was redesigned
   around. A tile with no data says so; it never shows a number computed from
   nulls.
*/

.ai-app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.ai-app-tile {
  display: block;
  border: 1px solid var(--ai-line-card);
  border-radius: var(--ai-radius-panel);
  background: var(--ai-surface);
  overflow: hidden;
  color: var(--ai-ink);
}
.ai-app-tile:hover { color: var(--ai-ink); border-color: var(--ai-line-strong); }
.ai-app-tile-warn { border-color: var(--ai-warn-edge); }
.ai-app-body { padding: 20px 20px 22px; }
.ai-app-status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--ai-font-mono); font-size: var(--ai-text-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ai-muted); }
.ai-app-status-warn { color: var(--ai-warn-ink); }
.ai-app-status-good { color: var(--ai-good); }
.ai-app-status-accent { color: var(--ai-accent-ink); }
.ai-app-headline { margin-top: var(--ai-space-3); font-size: var(--ai-text-h2); font-weight: 500; letter-spacing: -0.02em; }
.ai-app-detail { margin-top: 6px; font-size: var(--ai-text-sm); color: var(--ai-body); }
.ai-app-note { margin-top: 13px; font-family: var(--ai-font-serif); font-size: var(--ai-text-body); line-height: 1.6; color: var(--ai-body); }
.ai-app-actions { margin-top: var(--ai-space-3); display: flex; gap: var(--ai-space-1); flex-wrap: wrap; }

/* ---- Morning Briefing ----------------------------------------------------

   The rolling model made visible. A day accrues rather than freezing at 08:30,
   so the page is a strip of arrival times, one card for what just landed, and
   a quieter list of what came earlier.
*/

/* Weather sits beside the headline, not in the body: it is the one section you
   read at a glance rather than listen to. */
.ai-weather {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 22px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface-sunken);
}
.ai-weather-temp { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.ai-weather-rule { width: 1px; height: 44px; background: var(--ai-line-soft); flex: none; }
.ai-weather-grid { display: grid; grid-template-columns: auto auto; gap: 4px 18px; font-size: 12.5px; }
.ai-weather-grid dt { color: var(--ai-muted); }
.ai-weather-grid dd { margin: 0; font-family: var(--ai-font-mono); }

.ai-arrivals {
  padding: 22px 24px 26px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface-sunken);
}

/* 06:00 on the left, 18:00 on the right, now somewhere between. */
.ai-strip { position: relative; height: 58px; margin-top: 22px; }
.ai-strip::before {
  content: "";
  position: absolute;
  top: 5px; left: 0; right: 0;
  height: 1px;
  background: rgba(25, 24, 38, 0.16);
}
/* The elapsed part of the day is drawn in ink over the hairline. */
.ai-strip-elapsed { position: absolute; top: 5px; left: 0; height: 1px; background: var(--ai-ink-serif); }
.ai-strip-now {
  position: absolute;
  top: -6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
}
.ai-strip-now::before { content: ""; width: 2px; height: 22px; background: var(--ai-ink-serif); }
.ai-strip-now span {
  font-family: var(--ai-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
}

.ai-strip-mark {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%);
  color: var(--ai-muted);
}
/* A source that lands at either end would hang off the card, so the marks at
   the edges align to their own side instead of centring on the tick. */
.ai-strip-mark[data-edge="start"],
.ai-strip-now[data-edge="start"] { transform: none; align-items: flex-start; }
.ai-strip-mark[data-edge="end"],
.ai-strip-now[data-edge="end"] { transform: translateX(-100%); align-items: flex-end; }
.ai-strip-dot {
  width: 11px;
  height: 11px;
  border-radius: var(--ai-radius-pill);
  box-sizing: border-box;
  background: var(--ai-track-strong);
  border: 1.5px solid var(--ai-track-strong);
}
.ai-strip-at { font-family: var(--ai-font-mono); font-size: 10px; white-space: nowrap; }
.ai-strip-label { font-size: 11.5px; white-space: nowrap; }
.ai-strip-new .ai-strip-dot { background: var(--ai-accent); border-color: var(--ai-accent); }
.ai-strip-new .ai-strip-at, .ai-strip-new .ai-strip-label { color: var(--ai-ink); }
.ai-strip-done .ai-strip-at, .ai-strip-done .ai-strip-label { color: var(--ai-body); }
/* Not arrived yet, so an outline rather than a fill. */
.ai-strip-pending .ai-strip-dot { background: var(--ai-surface); border-color: var(--ai-line-strong); }
.ai-strip-overdue .ai-strip-dot { background: var(--ai-warn-wash); border-color: var(--ai-warn); }
.ai-strip-overdue .ai-strip-at, .ai-strip-overdue .ai-strip-label { color: var(--ai-warn-ink); }

/* The section that just landed gets the accent frame; everything else is a
   row. Only one card can be new at a time, which is what makes it readable. */
.ai-section {
  border: 1px solid var(--ai-accent-line);
  border-radius: 16px;
  background: var(--ai-surface);
  overflow: hidden;
  scroll-margin-top: 88px;
}
.ai-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-4);
  padding: 18px 22px;
  background: var(--ai-accent-wash);
  border-bottom: 1px solid var(--ai-accent-line);
}
.ai-section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.025em; }
.ai-section-stamp { font-family: var(--ai-font-mono); font-size: 10.5px; color: var(--ai-muted); white-space: nowrap; }
.ai-section-progress { height: 3px; background: rgba(124, 108, 240, 0.2); }
.ai-section-progress > span { display: block; height: 100%; width: 0; background: var(--ai-accent); }
.ai-section-body { padding: 20px 22px 22px; }
.ai-section-summary { font-family: var(--ai-font-serif); font-size: 17px; line-height: 1.65; color: var(--ai-ink-serif); text-wrap: pretty; }
.ai-section-stories { margin-top: 20px; display: flex; flex-direction: column; gap: 2px; }

/* A story is clickable because the voice can be sent to it. The marker bar is
   how you see which one is being read. */
.ai-story { display: flex; gap: 14px; padding: 14px 14px 15px; border-radius: var(--ai-radius-inner); cursor: pointer; }
.ai-story:hover { background: var(--ai-surface-sunken); }
.ai-story::before {
  content: "";
  width: 3px;
  flex: none;
  border-radius: 2px;
  background: var(--ai-accent);
  opacity: 0.25;
}
.ai-story.is-reading { background: var(--ai-surface-sunken); }
.ai-story.is-reading::before { opacity: 1; }
.ai-story-head { display: flex; align-items: baseline; gap: 10px; }
.ai-story-headline { font-size: 15.5px; font-weight: 500; letter-spacing: -0.01em; }
.ai-story-summary { margin-top: 8px; font-family: var(--ai-font-serif); font-size: 15px; line-height: 1.65; color: var(--ai-body); text-wrap: pretty; }
.ai-story-why { margin-top: 9px; display: flex; gap: 9px; }
.ai-story-why > .ai-label { color: var(--ai-accent); padding-top: 3px; flex: none; font-size: 9.5px; }
.ai-story-why > p { font-size: var(--ai-text-sm); line-height: 1.55; color: var(--ai-muted); }

/* A rule with a label on it, for "Earlier today". */
.ai-rule { display: flex; align-items: center; gap: 14px; }
.ai-rule::after { content: ""; flex: 1; height: 1px; background: var(--ai-line-soft); }
.ai-rule > .ai-label { white-space: nowrap; }

.ai-earlier {
  display: flex;
  align-items: center;
  gap: var(--ai-space-3);
  padding: 16px 20px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface);
  color: var(--ai-ink);
}
.ai-earlier:hover { border-color: rgba(25, 24, 38, 0.28); color: var(--ai-ink); }
.ai-earlier-dot {
  width: 9px; height: 9px;
  flex: none;
  border-radius: var(--ai-radius-pill);
  box-sizing: border-box;
  border: 1.5px solid rgba(25, 24, 38, 0.28);
  background: rgba(25, 24, 38, 0.22);
}
/* Nothing arrived, so nothing is filled in. */
.ai-earlier-waiting { border-style: dashed; }
.ai-earlier-waiting .ai-earlier-dot { background: transparent; }
.ai-earlier-late { border-color: var(--ai-warn-line); background: var(--ai-warn-wash); }
.ai-earlier-late .ai-earlier-dot { background: var(--ai-warn); border-color: var(--ai-warn); }
.ai-earlier-body { flex: 1; min-width: 0; }
.ai-earlier-title { font-size: 15px; font-weight: 500; }
.ai-earlier-note { margin-top: 4px; font-size: var(--ai-text-sm); line-height: 1.5; color: var(--ai-muted); text-wrap: pretty; }
.ai-earlier-when { text-align: right; flex: none; font-family: var(--ai-font-mono); font-size: 11px; color: var(--ai-body); }
.ai-earlier-trail { margin-top: 3px; font-family: var(--ai-font-mono); font-size: 10.5px; color: var(--ai-placeholder); }

/* The rail's cards are one step tighter than a page card. */
.ai-side-card {
  padding: 18px 20px 20px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-radius-card);
  background: var(--ai-surface);
}
.ai-side-card .ai-label { letter-spacing: 0.14em; }
.ai-side-accent { border-color: var(--ai-accent-line); background: var(--ai-accent-wash); }
.ai-side-note { margin-top: 16px; font-size: 12.5px; line-height: 1.55; color: var(--ai-body); text-wrap: pretty; }
.ai-side-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-side-row { display: flex; align-items: center; justify-content: space-between; gap: var(--ai-space-2); font-size: var(--ai-text-sm); }
.ai-side-row .ai-figure { font-size: var(--ai-text-eyebrow); color: var(--ai-muted); }
.ai-side-row-late, .ai-side-row-late .ai-figure { color: var(--ai-warn-ink); }

/* A setting reads as a row you flip, not as three buttons where one is on. */
.ai-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ai-space-2);
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--ai-surface-sunken);
  color: var(--ai-ink);
  font-family: inherit;
  font-size: var(--ai-text-sm);
  text-align: left;
  cursor: pointer;
}
.ai-option[aria-pressed="true"] { background: var(--ai-accent-wash); }
.ai-switch-sm { width: 34px; height: 20px; }
.ai-switch-sm::after { width: 16px; height: 16px; }
.ai-switch-sm:checked::after { transform: translateX(14px); }
/* Inside a row the switch is a picture of the state, not a second control. */
.ai-option .ai-switch { pointer-events: none; background: rgba(25, 24, 38, 0.16); }
.ai-option[aria-pressed="true"] .ai-switch { background: var(--ai-accent); }
.ai-option[aria-pressed="true"] .ai-switch::after { transform: translateX(14px); }

/* ---- Utilities ----------------------------------------------------------- */

.ai-phone-only { display: none; }

/* ---- Tab bar (phone only) ---------------------------------------------- */

.ai-tabbar { display: none; }

/* ---- Phone ------------------------------------------------------------- */

@media (max-width: 900px) {
  /* The frame becomes the page on a phone — no margin, no rounding. */
  .ai-frame { margin: 0; border: none; border-radius: 0; min-height: 100vh; }

  .ai-header { padding: 14px 18px; gap: var(--ai-space-2); border-radius: 0; }
  .ai-header .ai-nav { display: none; }
  .ai-search { display: none; }
  .ai-mark { width: 26px; height: 26px; border-radius: 8px; font-size: var(--ai-text-eyebrow); }
  .ai-brand-name { font-size: 16px; letter-spacing: -0.03em; }
  .ai-divider { display: none; }

  .ai-page { padding: 20px 18px 96px; }

  /* The rail's contents move to the top. */
  .ai-split { grid-template-columns: minmax(0, 1fr); }
  .ai-split > .ai-rail { order: -1; }

  .ai-display { font-size: 26px; line-height: 1.08; letter-spacing: -0.035em; }

  .ai-phone-only { display: inline-flex; }
  .ai-desktop-only { display: none; }

  .ai-page-head { gap: var(--ai-space-3); }
  .ai-app-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-timeline .ai-tl-action { align-self: flex-start; }
  .ai-weather { width: 100%; }
  .ai-arrivals { overflow-x: auto; }
  .ai-strip { min-width: 520px; }

  /* Every tappable thing clears 44px, using min-height on a flex box rather
     than padding on a span. */
  .ai-button { min-height: var(--ai-touch-min); }
  .ai-button-icon { width: var(--ai-touch-min); height: var(--ai-touch-min); }

  /* Nothing may push the page sideways; wide data scrolls inside its own box. */
  .ai-page, .ai-split, .ai-panel, .ai-card, .ai-panel-framed { min-width: 0; }

  .ai-tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: flex;
    gap: 4px;
    padding: 8px 8px 12px;
    background: var(--ai-surface);
    border-top: 1px solid rgba(25, 24, 38, 0.12);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .ai-tabbar a {
    flex: 1;
    min-height: 52px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--ai-radius-inner);
    color: var(--ai-muted);
    font-size: 10.5px;
    font-weight: 500;
  }
  .ai-tabbar a[aria-current="page"] { background: var(--ai-accent-chip); color: var(--ai-accent-ink); }

  /* Legacy app content sits outside .ai-page, so it needs its own clearance
     for the tab bar. */
  .legacy-app { padding-bottom: 96px; }
}
