/* UI polish layer (2026-10-10). Loaded LAST so it only refines app.css: tokens, type scale, buttons, cards,
   status pills, focus, folds, Home truth lines. Remove this file and the app falls back to app.css unchanged.
   Rules: body text >= 14px on phones, captions >= 12px, tap targets >= 44px, text contrast >= 4.5:1. */

:root {
  /* type scale */
  --fs-caption: 12px;   /* captions, pills, timestamps: never smaller */
  --fs-small: 14px;     /* secondary body */
  --fs-body: 15px;      /* body */
  --fs-title: 16px;     /* card titles */
  --fs-section: 18px;   /* section headings */
  --fs-page: 28px;      /* page titles */
  /* spacing scale (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 28px;
  --tap: 44px;
  /* readable text on the dark surfaces (all >= 4.5:1 on --surface-1 / --bg) */
  --text-2: #b4bdcb;
  --text-3: #a0abbd;
  --nav-idle: #a3aebd;
  /* accessible status text colours (>= 4.5:1 on the dark card) */
  --ok-text: #4fe3b8; --warn-text: #f7c565; --bad-text: #ff8a97; --info-text: #7db7ff; --violet-text: #cf92ff; --neutral-text: #a9b4c4;
  /* solid buttons: white text must reach 4.5:1 */
  --btn-primary-1: #2b6fe3; --btn-primary-2: #1c5ac9;
  --focus: #8cc2ff;
}

/* ---------- type ---------- */
.small { font-size: var(--fs-small); line-height: 1.45; }
.tiny { font-size: var(--fs-caption); line-height: 1.4; font-weight: 500; }
.eyebrow, body .ac-label { font-size: var(--fs-caption); }
.t-when, .freshness, .stat .sub, .stat .l { font-size: var(--fs-caption); }
.card-title { font-size: var(--fs-title); }
.h-sec { font-size: var(--fs-section); }
.dim { color: var(--text-3); }
.faint { color: #93a0b3; }
.wordmark.sm { font-size: 13px; }
.wordmark { font-size: 12px; }
kbd { font-size: 12px; }
.logo-subtitle { font-size: 11px; color: #94a0b3; }
.bottom-nav a { font-size: 12px; }
@media (min-width: 1024px) {
  .small { font-size: 13.5px; }
}

/* ---------- buttons: one system ---------- */
.btn {
  min-height: var(--tap); height: auto; padding: 10px 18px; line-height: 1.25;
  white-space: normal; text-align: center; overflow-wrap: anywhere; max-width: 100%;
  font-size: 14px;
}
.btn.primary, .btn.accent {
  background: linear-gradient(180deg, var(--btn-primary-1), var(--btn-primary-2));
  border-color: rgba(140, 190, 255, .55); color: #fff;
}
.btn.primary:hover, .btn.accent:hover { background: linear-gradient(180deg, #3a7cf0, #2064d6); }
.btn.danger, .btn.destructive { color: var(--bad-text); border-color: rgba(255, 110, 125, .45); background: rgba(255, 82, 99, .08); }
.btn.sm { min-height: var(--tap); padding: 8px 14px; font-size: 14px; }
.btn.ghost { color: var(--text-2); }
.btn[disabled] { opacity: .5; }
/* groups of buttons wrap cleanly and put the primary action first on a phone */
.btn-row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.btn-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-actions > .btn { flex: 1 1 160px; }
@media (max-width: 639px) {
  .btn-row .btn.primary, .btn-row .btn.accent { order: -1; }
  .btn-actions .btn.primary, .btn-actions .btn.accent { order: -1; flex-basis: 100%; }
  .ac-item .row[style*="flex-wrap"] > .btn, .card .row[style*="flex-wrap"] > .btn { flex: 1 1 150px; }
}
.icon-btn { min-width: var(--tap); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:focus-visible, .tab:focus-visible, .fold-head:focus-visible, .fold-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- tabs, chips, summaries, inputs: tap size ---------- */
.tab { min-height: var(--tap); height: auto; font-size: 14px; padding: 0 16px; }
.tab .n { font-size: var(--fs-caption); }
button.chip, a.chip, .chip[role="button"] { min-height: var(--tap); padding: 0 14px; font-size: 14px; }
.chip { min-height: 32px; height: auto; padding: 4px 10px; font-size: 13px; line-height: 1.3; white-space: normal; }
summary { min-height: var(--tap); }
details > summary { display: flex; align-items: center; }
.auth-input, input[type="text"], input[type="search"], input[type="number"], select, textarea { min-height: var(--tap); font-size: 16px; }
.search-input { min-height: var(--tap); }
.search-input input { min-height: 40px; }
.list-row { min-height: 52px; }

/* ---------- status pills: AA text, 12px, readable on every card ---------- */
.pill { font-size: var(--fs-caption); letter-spacing: .03em; min-height: 26px; height: auto; padding: 4px 10px; font-weight: 600; }
.pill.tone-good, .pill.tone-online { color: var(--ok-text); }
.pill.tone-warn, .pill.tone-warning, .pill.tone-working { color: var(--warn-text); }
.pill.tone-bad, .pill.tone-blocked { color: var(--bad-text); }
.pill.tone-info, .pill.tone-running, .pill.tone-building, .pill.tone-measuring, .pill.tone-cyan { color: var(--info-text); }
.pill.tone-violet, .pill.tone-validating, .pill.tone-idle { color: var(--violet-text); }
.pill.tone-neutral, .pill.tone-offline { color: var(--neutral-text); }
body .status-dot, body .agent-card .status-dot { font-size: var(--fs-caption); }
.notice { font-size: var(--fs-small); }
.notice.warn { color: #f6dcae; }
.notice.info { color: #d2e5ff; }

/* ---------- cards: one rhythm, three weights ---------- */
.stack-lg { gap: var(--sp-5); }
.stack { gap: var(--sp-3); }
.card { padding: var(--sp-4); }
.card.card-primary { border-color: var(--border-active); background: linear-gradient(180deg, rgba(40, 123, 255, .14), rgba(8, 16, 27, .9)); }
.card.card-quiet { background: rgba(8, 16, 27, .6); box-shadow: none; }
.card.card-status { border-left: 3px solid var(--tone, var(--st-offline)); }
body .ac-item { background: rgba(5, 10, 16, .72); }
body .ac-steps { padding-left: 22px; }
body .ac-facts { grid-template-columns: 104px minmax(0, 1fr); }
body .ac-ask-title { font-size: 20px; }
@media (max-width: 480px) {
  body .ac-ask-title { font-size: 19px; }
  body .ac-ask { padding: var(--sp-4) var(--sp-3); }
  body .ac-item { padding: var(--sp-3); }
  .page { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .h-title { font-size: 26px; line-height: 1.1; }
  .section-head .link, .section-head a { min-height: 32px; font-size: 14px; }
}
.section-head a, .link { font-size: 14px; }
.card-title, .ow-title, .ac-ask-title, .list-row .grow, .ac-facts dd, .small { overflow-wrap: anywhere; }
.pill { max-width: 100%; }
img, svg, video { max-width: 100%; }
pre, code { white-space: pre-wrap; overflow-wrap: anywhere; }
a.link, .list-row a { overflow-wrap: anywhere; }

/* ---------- folds (Access): header with count, remembered open/closed ---------- */
.fold { display: grid; gap: var(--sp-3); }
.fold-head {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left;
  background: rgba(8, 16, 27, .8); border: 1px solid var(--border-card); border-radius: var(--r-md); color: var(--text-1);
}
.fold-head:hover { border-color: var(--border-strong); }
.fold-title { font: 600 16px/1.3 var(--font-ui); flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.fold-count {
  flex: none; min-width: 28px; height: 26px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: var(--r-pill);
  font: 700 13px/1 var(--font-ui); background: rgba(255, 255, 255, .08); color: var(--text-1);
}
.fold-count.tone-warn { background: rgba(246, 185, 74, .18); color: var(--warn-text); }
.fold-count.tone-good { background: rgba(32, 217, 163, .14); color: var(--ok-text); }
.fold-hint { display: none; flex: 0 1 auto; font-size: var(--fs-caption); color: var(--text-3); }
@media (min-width: 640px) { .fold-hint { display: inline; } }
.fold-chev { transition: transform var(--fast) var(--ease); color: var(--text-2); flex: none; }
.fold.is-open > .fold-head .fold-chev { transform: rotate(90deg); }
.fold.is-open > .fold-head { border-color: var(--border-strong); }
.fold-body[hidden] { display: none; }
.fold-single .fold-body > .section > .section-head .h-sec { display: none; }
.fold-single .fold-body > .section > .section-head:not(:has(.dim)) { display: none; }
.fold { scroll-margin-top: 112px; }

.fold-nav {
  position: sticky; top: 0; z-index: 30; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--pad)); padding: 8px var(--pad);
  background: rgba(2, 5, 9, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-quiet);
}
.fold-nav::-webkit-scrollbar { display: none; }
.fold-chip {
  flex: none; min-height: var(--tap); padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--border-card); color: var(--text-1); font: 500 14px/1 var(--font-ui);
}
.fold-chip b { font-size: 12px; background: rgba(246, 185, 74, .2); color: var(--warn-text); border-radius: var(--r-pill); padding: 3px 7px; }
@media (min-width: 1024px) { .fold-nav { top: 0; position: static; margin: 0; padding: 0; background: none; border: 0; backdrop-filter: none; flex-wrap: wrap; } }

/* ---------- Home: three-line truth ---------- */
.truth { gap: var(--sp-3); }
.truth-rows { display: grid; gap: 2px; }
.truth-row { display: grid; grid-template-columns: 32px 40px minmax(0, 1fr) 16px; align-items: center; gap: 10px; min-height: 52px; padding: 4px 2px; border-radius: var(--r-sm); }
.truth-row + .truth-row { border-top: 1px solid var(--border-quiet); }
.truth-ic { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); background: rgba(42, 123, 255, .16); color: var(--info-text); }
.truth-n { font: 700 24px/1 var(--font-ui); color: var(--text-1); }
.truth-t { font-size: var(--fs-body); line-height: 1.3; overflow-wrap: anywhere; }
.truth-t b { color: var(--text-1); font-weight: 600; }
.truth-cta { margin-top: 2px; }
.truth-next { padding-top: 6px; }
@media (max-width: 720px) { .home-stats { display: none; } }

/* specificity fixes for rules that app.css/ventures.css set more narrowly */
.home-page .agent-tile .status-dot { font-size: var(--fs-caption); }
.sidebar .brand .wordmark.sm { font-size: 12px; }
.searchbar kbd { font-size: 12px; }
.search-input.v-search, .v-search { height: auto; min-height: var(--tap); }
.search-input.v-search input { min-height: 40px; }
.searchbar { height: var(--tap); }
.search-input input, .search-input.v-search input { min-height: var(--tap); }
.truth-t b, .truth-t .dim { display: block; }
.truth-t .dim { font-size: var(--fs-small); }

/* A card with backdrop-filter becomes the containing block of position:fixed children, which trapped bottom sheets
   (Create an account, Connect) inside the card: clipped, off-screen, under the sticky bar. While a sheet is open
   inside a card, drop the blur on that card so the sheet is positioned against the screen. */
.card:has(.scrim), .stat:has(.scrim), .glass:has(.scrim), .section:has(.scrim), .hero:has(.scrim), .ac-item:has(.scrim) {
  backdrop-filter: none; -webkit-backdrop-filter: none; transform: none; filter: none; animation: none;
}
.pill { overflow-wrap: normal; word-break: normal; flex: 0 0 auto; }
@media (max-width: 620px) { .pill { overflow-wrap: normal; max-width: 100%; } }
.ac-cols:has(> :only-child) { grid-template-columns: 1fr; }

/* ---------- glance audit (2026-10-10): readable + reachable on a 375px phone ---------- */
/* Tap targets: links that sit in headers/lists get a 44px hit area without changing how they look. */
.section-head a, .section-head .link, .link, .list-row.link { min-height: var(--tap); }
.mobile-only.row[href] { min-height: var(--tap); align-items: center; }
.mo-switch { position: relative; }
.mo-switch::after { content: ''; position: absolute; inset: -9px -6px; }   /* 46x28 switch, 58x46 hit area */
.home-needs a.btn, .needs-card, a.list-row { min-height: var(--tap); }
/* Names of people/roles are titles, not captions: never below 14px. */
.home-page .agent-tile .card-title { font-size: 14px; }
.chip, .fold-count, .tag-unknown { font-size: 14px; }
@media (max-width: 720px) {
  .home-page .agent-tile .card-title { font-size: 14px; }
  .section-head a { padding: 0 2px; }
}

/* ---------- every role is a character: colour chip on borrowed art, speech bubble for "what I'm doing now" ---------- */
.avatar .av-chip {
  position: absolute; right: -4px; bottom: -2px; z-index: 3; min-width: 22px; height: 22px; padding: 0 5px;
  display: inline-grid; place-items: center; border-radius: 11px; font: 700 11px/1 var(--font-ui); letter-spacing: .02em;
  color: #0b1018; background: rgb(var(--agent-rgb)); border: 2px solid var(--bg, #0b1018); box-sizing: border-box;
}
.avatar.is-alias.sz-md .av-chip { min-width: 24px; height: 24px; font-size: 12px; }
.avatar.is-alias.sz-lg .av-chip { min-width: 34px; height: 34px; font-size: 14px; border-radius: 17px; right: 4px; bottom: 6px; }
.avatar.is-alias { box-shadow: 0 0 0 2px rgb(var(--agent-rgb) / .55); border-radius: 50%; }

.says-list { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .says-list { grid-template-columns: 1fr 1fr; } }
.says { display: flex; align-items: center; gap: 12px; min-height: 64px; color: var(--text-1); text-decoration: none; }
.says-bubble {
  position: relative; display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; padding: 10px 14px; border-radius: 16px 16px 16px 4px;
  background: rgb(var(--agent-rgb, 90 140 255) / .12); border: 1px solid rgb(var(--agent-rgb, 90 140 255) / .45);
}
.says-name { font-size: 14px; font-weight: 700; color: rgb(var(--agent-rgb, 160 190 255)); filter: brightness(1.35); }
.says-text { font-size: 14px; line-height: 1.4; color: var(--text-1); overflow-wrap: anywhere; }
.says-inline { padding: 8px 12px; margin-top: 2px; }
button.chip, a.chip { min-height: var(--tap); }
.mobile-only.row[href] { padding: 0 10px; margin-left: -10px; }
body button.chip, body a.chip { min-height: var(--tap); height: auto; }
.sidebar .nav { min-height: var(--tap); }
body .ip-filters .chip { min-height: var(--tap); }
