/**
 * OS — base.css
 * Design system derived from the CoreX mobile UI: floating pill dock,
 * tile logo, segmented pills, grouped cards, light & dark editions.
 * Light/dark via [data-theme] on <html> + prefers-color-scheme fallback.
 * Accent via [data-accent] (blue | teal | violet | pink).
 */

/* Kill the OS-default blue tap flash (Android/WebView) on every tappable */
html { -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, label, [role="button"],
.row, .dock-btn, .chip, .icon-btn, .btn {
  -webkit-tap-highlight-color: transparent;
}

/* ============================== Tokens ============================== */
:root {
  --bg: #ECEEF2;
  --bg-2: #F3F4F7;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.6);
  --card: #FFFFFF;
  --field: #FFFFFF;
  --line: rgba(12, 14, 18, 0.09);
  --line-soft: rgba(12, 14, 18, 0.055);
  --fg: #0D0F12;
  --muted: #565C64;
  --faint: #878D96;
  --accent: #0A7CFF;
  --accent-soft: rgba(10, 124, 255, 0.12);
  --accent-fg: #FFFFFF;
  --ok: #0FA968;
  --ok-soft: rgba(15, 169, 104, 0.12);
  --bad: #E5484D;
  --bad-soft: rgba(229, 72, 77, 0.12);
  --warn: #B88409;
  --pill: rgba(12, 14, 18, 0.06);
  --pill-line: rgba(12, 14, 18, 0.08);
  --tile-bg: linear-gradient(180deg, #FFFFFF, #E0E3EA);
  --tile-line: rgba(12, 14, 18, 0.14);
  --tile-fg: #0D0F12;
  --dock-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  --dock-line: rgba(255, 255, 255, 0.48);
  --dock-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 30%);
  --dock-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.80),
                 inset 0 -1px 1px rgba(255, 255, 255, 0.25),
                 inset 0 0 24px rgba(255, 255, 255, 0.12),
                 0 2px 6px rgba(14, 18, 26, 0.05),
                 0 22px 48px -20px rgba(14, 18, 26, 0.32);
  --bg-aurora:
    radial-gradient(30vh 56vh at 3% 52%, rgba(10, 124, 255, 0.10), transparent 72%),
    radial-gradient(46vh 38vh at 14% 84%, rgba(10, 124, 255, 0.11), transparent 70%),
    radial-gradient(54vh 42vh at 88% 14%, rgba(124, 92, 255, 0.09), transparent 70%),
    radial-gradient(42vh 34vh at 64% 94%, rgba(15, 169, 104, 0.07), transparent 70%);
  --card-shadow: 0 1px 2px rgba(14, 18, 26, 0.05), 0 12px 32px -18px rgba(14, 18, 26, 0.18);
  --bubble-mine: #0A7CFF;
  --bubble-mine-fg: #FFFFFF;
  --bubble-peer: #FFFFFF;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --dock-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-accent="teal"]   { --accent: #0AA2A2; --accent-soft: rgba(17, 169, 169, 0.14); --bubble-mine: #0AA2A2; }
:root[data-accent="violet"] { --accent: #7C5CFF; --accent-soft: rgba(124, 92, 255, 0.14); --bubble-mine: #7C5CFF; }
:root[data-accent="pink"]   { --accent: #F04DA0; --accent-soft: rgba(240, 77, 160, 0.13); --bubble-mine: #F04DA0; }

:root[data-theme="dark"] {
  --bg: #060608;
  --bg-2: #0B0B0E;
  --surface: rgba(9, 9, 12, 0.62);
  --surface-2: rgba(12, 13, 16, 0.5);
  --card: #101014;
  --field: #131318;
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.055);
  --fg: #F4F6F7;
  --muted: #9BA1A6;
  --faint: #6C7278;
  --accent: #0A84FF;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --accent-fg: #FFFFFF;
  --ok: #30D158;
  --ok-soft: rgba(48, 209, 88, 0.14);
  --bad: #FF453A;
  --bad-soft: rgba(255, 69, 58, 0.14);
  --warn: #E5B34A;
  --pill: rgba(255, 255, 255, 0.09);
  --pill-line: rgba(255, 255, 255, 0.07);
  --tile-bg: linear-gradient(180deg, #232329, #0A0A0F);
  --tile-line: rgba(255, 255, 255, 0.14);
  --tile-fg: #F2F4F7;
  --dock-bg: linear-gradient(180deg, rgba(30, 31, 37, 0.22), rgba(10, 11, 14, 0.07));
  --dock-line: rgba(255, 255, 255, 0.12);
  --dock-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 30%);
  --dock-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.12),
                 inset 0 -1px 1px rgba(255, 255, 255, 0.02),
                 inset 0 0 24px rgba(255, 255, 255, 0.018),
                 0 2px 8px rgba(0, 0, 0, 0.24),
                 0 22px 48px -18px rgba(0, 0, 0, 0.60);
  --bg-aurora:
    radial-gradient(30vh 56vh at 3% 52%, rgba(10, 132, 255, 0.10), transparent 72%),
    radial-gradient(46vh 38vh at 14% 84%, rgba(10, 132, 255, 0.11), transparent 70%),
    radial-gradient(54vh 42vh at 88% 14%, rgba(124, 92, 255, 0.09), transparent 70%),
    radial-gradient(42vh 34vh at 64% 94%, rgba(48, 209, 88, 0.05), transparent 70%);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  --bubble-mine: #0A84FF;
  --bubble-peer: #15151A;
}

/* v2.6.5 fix — accent in the explicit dark theme.
   :root[data-theme="dark"] and :root[data-accent="…"] have EQUAL specificity
   (0,2,0); the dark block comes later in this file, so it used to win the
   cascade and every accent re-locked to blue once the theme was dark.
   These rules have higher specificity (0,3,0) and run after it. */
:root[data-theme="dark"][data-accent="teal"] {
  --accent: #0AA2A2; --accent-soft: rgba(17, 169, 169, 0.20); --bubble-mine: #0AA2A2;
}
:root[data-theme="dark"][data-accent="violet"] {
  --accent: #7C5CFF; --accent-soft: rgba(124, 92, 255, 0.20); --bubble-mine: #7C5CFF;
}
:root[data-theme="dark"][data-accent="pink"] {
  --accent: #F04DA0; --accent-soft: rgba(240, 77, 160, 0.19); --bubble-mine: #F04DA0;
}

@media (prefers-color-scheme: dark) {
  /* OS-follow default (no data-theme set) — handled below + boot script */
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #060608;
    --bg-2: #0B0B0E;
    --surface: rgba(9, 9, 12, 0.62);
    --surface-2: rgba(12, 13, 16, 0.5);
    --card: #101014;
    --field: #131318;
    --line: rgba(255, 255, 255, 0.09);
    --line-soft: rgba(255, 255, 255, 0.055);
    --fg: #F4F6F7;
    --muted: #9BA1A6;
    --faint: #6C7278;
    --accent: #0A84FF;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --ok: #30D158;
    --ok-soft: rgba(48, 209, 88, 0.14);
    --bad: #FF453A;
    --bad-soft: rgba(255, 69, 58, 0.14);
    --warn: #E5B34A;
    --pill: rgba(255, 255, 255, 0.09);
    --pill-line: rgba(255, 255, 255, 0.07);
    --tile-bg: linear-gradient(180deg, #232329, #0A0A0F);
    --tile-line: rgba(255, 255, 255, 0.14);
    --tile-fg: #F2F4F7;
    --dock-bg: linear-gradient(180deg, rgba(30, 31, 37, 0.22), rgba(10, 11, 14, 0.07));
    --dock-line: rgba(255, 255, 255, 0.12);
    --dock-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 30%);
    --dock-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.12),
                   inset 0 -1px 1px rgba(255, 255, 255, 0.02),
                   inset 0 0 24px rgba(255, 255, 255, 0.018),
                   0 2px 8px rgba(0, 0, 0, 0.24),
                   0 22px 48px -18px rgba(0, 0, 0, 0.60);
    --bg-aurora:
      radial-gradient(30vh 56vh at 3% 52%, rgba(10, 132, 255, 0.10), transparent 72%),
    radial-gradient(46vh 38vh at 14% 84%, rgba(10, 132, 255, 0.11), transparent 70%),
      radial-gradient(54vh 42vh at 88% 14%, rgba(124, 92, 255, 0.09), transparent 70%),
      radial-gradient(42vh 34vh at 64% 94%, rgba(48, 209, 88, 0.05), transparent 70%);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
    --bubble-mine: #0A84FF;
    --bubble-peer: #15151A;
  }
  :root:not([data-theme="light"]):not([data-theme="dark"])[data-accent="teal"]   { --accent: #0AA2A2; --accent-soft: rgba(17, 169, 169, 0.14); --bubble-mine: #0AA2A2; }
  :root:not([data-theme="light"]):not([data-theme="dark"])[data-accent="violet"] { --accent: #7C5CFF; --accent-soft: rgba(124, 92, 255, 0.14); --bubble-mine: #7C5CFF; }
  :root:not([data-theme="light"]):not([data-theme="dark"])[data-accent="pink"]   { --accent: #F04DA0; --accent-soft: rgba(240, 77, 160, 0.13); --bubble-mine: #F04DA0; }
}

/* ============================== Reset ============================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: none;
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
/* Ambient color field behind the app — gives the liquid-glass dock and
   desktop rail something real to refract (pure flat bg kills the effect). */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg-aurora);
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
img, svg, video { display: block; }
::selection { background: var(--accent-soft); }

/* ============================== Topbar ============================== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.topbar .spacer { flex: 1; }
.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

/* Tile logo (CoreX-style rounded-square brand tile) */
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tile-bg);
  border: 1px solid var(--tile-line);
  color: var(--tile-fg, #F2F4F7);
  flex: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.tile svg { width: 20px; height: 20px; }
.tile-lg { width: 56px; height: 56px; border-radius: 16px; }
.tile-lg svg { width: 32px; height: 32px; }
/* v2.8.14 — brand spots carry the self-contained logo tile (black rounded
 * tile baked into the SVG), so the generic chip background is switched off.
 * v2.8.15 — each theme gets its own presentation: light floats the black
 * tile on a soft shadow; dark lifts the tile and adds a hairline ring so
 * it never melts into the dark chrome. */
.tile-brand {
  background: transparent;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(8, 10, 16, 0.22), 0 4px 14px rgba(8, 10, 16, 0.10);
}
html[data-theme='dark'] .tile-brand {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 2px 10px rgba(0, 0, 0, 0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .tile-brand {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 2px 10px rgba(0, 0, 0, 0.5);
  }
}
.tile-brand svg { width: 100%; height: 100%; }

/* v2.8.15 — white bubble / black Os mark. The SVG paths carry these classes
 * (inline marks only); the fill attributes in the markup are fallbacks.
 * Dark theme lifts the tile one step so it reads against near-black chrome;
 * the bubble stays white and the calligraphy stays black in both themes. */
.osb-tile { fill: #050507; }
.osb-bubble { fill: #ffffff; }
.osb-ink { fill: #0b0b0e; }
html[data-theme='dark'] .osb-tile { fill: #0e0e15; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .osb-tile { fill: #0e0e15; }
}

/* ============================== Buttons ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 650;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-ghost { background: var(--pill); color: var(--fg); border-color: var(--pill-line); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-lg { width: 100%; padding: 15px 20px; font-size: 15.5px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--fg);
  flex: none;
  transition: background 0.12s ease, transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.92); background: var(--pill); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.chip { width: auto; height: 34px; padding: 0 13px; gap: 6px; background: var(--pill); border: 1px solid var(--pill-line); font-size: 13px; font-weight: 650; border-radius: 999px; }

/* Theme toggle shows sun in dark / moon in light */
[data-theme-toggle] .icon-sun { display: none; }
[data-theme-toggle] .icon-moon { display: block; }
[data-theme="dark"] [data-theme-toggle] .icon-sun { display: block; }
[data-theme="dark"] [data-theme-toggle] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) [data-theme-toggle] .icon-sun { display: block; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) [data-theme-toggle] .icon-moon { display: none; }
}

/* ============================== Fields ============================== */
.field {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  font-size: 16px; /* 16px prevents iOS zoom */
  outline: none;
  transition: border 0.12s ease, box-shadow 0.12s ease;
  appearance: none;
  -webkit-appearance: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--faint); }
label.lbl {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 7px 2px;
}
.search-row { position: relative; }
.search-row svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--faint); pointer-events: none;
}
.search-row .field { padding-left: 38px; border-radius: 10px; background: var(--field); }

/* ============================== Cards & lists ============================== */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}
.card-pad { padding: 16px; }
.sect {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 4px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sect .aux { font-size: 11px; letter-spacing: 0.04em; color: var(--faint); font-weight: 700; text-transform: none; }

.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-md);
  transition: background 0.12s ease;
  width: 100%;
  text-align: left;
}
.row:active { background: var(--pill); }
.row + .row { margin-top: 2px; }

/* Avatar tiles */
.ava {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  flex: none;
  letter-spacing: 0.02em;
}
.ava::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.ava-sm { width: 34px; height: 34px; border-radius: 11px; font-size: 12px; }
.ava-lg { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; }
.ava img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.ava.ava-photo { overflow: hidden; }
.ava .dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 13px; height: 13px; border-radius: 999px;
  background: var(--ok); border: 2.5px solid var(--bg);
}

/* Chat row */
.chat-row .meta { flex: 1; min-width: 0; }
.chat-row .name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.chat-row .prev {
  color: var(--muted); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
.chat-row .side { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chat-row .time { font-size: 11.5px; color: var(--faint); font-weight: 600; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 11.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.badge.muted-b { background: var(--pill); color: var(--muted); }
.check { color: var(--accent); display: inline-flex; }
.check svg { width: 14px; height: 14px; }

/* ============================== Dock ============================== */
.dock {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--dock-bg);
  border: 1px solid var(--dock-line);
  box-shadow: var(--dock-shadow);
  backdrop-filter: blur(38px) saturate(200%);
  -webkit-backdrop-filter: blur(38px) saturate(200%);
}
/* liquid-glass top sheen */
.dock::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: var(--dock-sheen);
}
.dock-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 4px 6px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  position: relative;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.dock-btn:active { transform: scale(0.94); }
.dock-btn svg { width: 19px; height: 19px; }
.dock-btn .n {
  position: absolute; top: 3px; right: calc(50% - 20px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 9.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.dock-btn[aria-current="page"] {
  background: var(--pill);
  color: var(--fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 0 12px rgba(255, 255, 255, 0.20),
              0 1px 2px rgba(14, 18, 26, 0.10);
}
:root[data-theme="dark"] .dock-btn[aria-current="page"] {
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 12px rgba(255, 255, 255, 0.045);
}

/* ============================== Sheets / modal ============================== */
.sheet-layer { position: fixed; inset: 0; z-index: 80; display: none; }
.sheet-layer.open { display: block; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 5, 8, 0.45);
  opacity: 0; transition: opacity 0.22s ease;
}
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.25, 1);
  max-height: 84vh;
  max-height: 84dvh;
  overflow-y: auto;
}
.sheet-layer.open .sheet { transform: translateY(0); }
.grabber { width: 38px; height: 5px; border-radius: 999px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ============================== Toast ============================== */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--dock-h) + 30px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 90;
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  font-weight: 650;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================== Misc ============================== */
.hr { height: 1px; background: var(--line-soft); border: 0; margin: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 750; letter-spacing: 0.03em;
  padding: 4px 9px; border-radius: 999px;
  background: var(--pill); color: var(--muted);
  border: 1px solid var(--pill-line);
}
.chip .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ok); }
.chip.lock svg { width: 11px; height: 11px; }
.empty { text-align: center; color: var(--faint); font-size: 13.5px; padding: 34px 20px; }
.empty svg { width: 34px; height: 34px; margin: 0 auto 10px; opacity: 0.5; }
.fade-in { animation: fadeIn 0.25s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Scrollbars hidden on mobile surfaces */
.no-bar::-webkit-scrollbar { display: none; }
.no-bar { scrollbar-width: none; }

/* ============================== Premium detailing (v2.8.5) ==============================
 * Small, zero-layout-cost touches that make the app feel native:
 * brand-colored text selection, keyboard focus rings, slim desktop
 * scrollbars, no accidental text selection on chrome, gentle press
 * feedback on every interactive surface, soft landing on tab switches. */

::selection { background: rgba(10, 124, 255, 0.28); }
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  ::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
}

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

@media (hover: hover) and (pointer: fine) {
  * { scrollbar-width: thin; scrollbar-color: var(--pill-line) transparent; }
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-thumb { background: var(--pill-line); border-radius: 99px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--faint); }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
}

/* app chrome is chrome — no accidental selection or long-press callout */
.topbar, .dock, .sheet, .call-layer, .ctm, .conv-head, .call-chip, .call-top,
.dock-btn, .icon-btn, .btn, .send-btn, .join-btn, .ctm-item {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

/* gentle press feedback where it was missing */
.row, .icon-btn, .send-btn { transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease, box-shadow 0.2s ease; }
.row:active, .icon-btn:active:not(:disabled), .send-btn:active:not(:disabled) { transform: scale(0.98); }

/* soft landing for tab switches (opacity/transform only) */
.view.active > * { animation: fadeIn 0.22s ease both; }
@media (prefers-reduced-motion: reduce) {
  .view.active > * { animation: none; }
  .row:active, .icon-btn:active, .send-btn:active { transform: none; }
}

/* ================= v2.8.13 ================= */

/* boot splash — paints the instant HTML lands, fades out when app.js mounts */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    radial-gradient(1000px 500px at 20% -10%, rgba(10, 124, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(124, 92, 255, 0.07), transparent 60%),
    var(--bg);
  transition: opacity 0.32s ease, visibility 0.32s ease;
}
.boot-splash .bs-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bs-float 2.4s ease-in-out infinite;
}
.boot-splash .bs-mark svg { width: 100%; height: 100%; }
.boot-splash .bs-word {
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--faint);
}
.boot-splash .bs-bar {
  width: 124px;
  height: 3px;
  border-radius: 99px;
  background: var(--pill-line);
  overflow: hidden;
}
.boot-splash .bs-bar i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 99px;
  background: var(--accent);
  animation: bs-slide 1.15s ease-in-out infinite;
}
.boot-splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes bs-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes bs-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(340%); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-splash .bs-mark, .boot-splash .bs-bar i { animation: none; }
}

/* ================= v2.8.17 — boot-fail surface + deploy-check =================
 * .os-bootfail: painted by theme.js OSBootFail() when the entry module cannot
 * start (dead API / partial deployment / terminal watchdog state). Replaces
 * the "eternal splash" that read as a dead app. Uses the same theme vars as
 * the rest of the shell, so it is correct in light and dark. */
.os-bootfail {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg, #ECEEF2);
}
.os-bootfail-card {
  max-width: 420px;
  width: 100%;
  padding: 28px 24px 24px;
  border-radius: 20px;
  background: var(--card, #fff);
  box-shadow: 0 18px 50px rgba(8, 10, 18, 0.18);
  text-align: center;
}
.os-bootfail-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text, #101014);
  margin-bottom: 10px;
}
.os-bootfail-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-soft, #5a5f6b);
  white-space: pre-line;
  margin-bottom: 18px;
}
.os-bootfail-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 11px 26px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #2563eb);
}
.os-bootfail-btn:active { transform: scale(0.97); }

/* deploy-check page (self-contained, reuses theme vars) */
.dc-wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.dc-title { font-size: 22px; font-weight: 800; color: var(--text, #101014); margin: 6px 0 4px; }
.dc-sub { font-size: 13.5px; line-height: 1.5; color: var(--text-soft, #5a5f6b); margin: 0 0 22px; }
.dc-rows { display: flex; flex-direction: column; gap: 8px; }
.dc-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--card, #fff);
  box-shadow: 0 1px 2px rgba(8, 10, 18, 0.06);
}
.dc-mark { font-weight: 800; font-size: 15px; line-height: 1.45; width: 18px; text-align: center; }
.dc-row.ok .dc-mark { color: #0d9f6e; }
.dc-row.bad .dc-mark { color: #e0364c; }
.dc-txt { flex: 1; min-width: 0; }
.dc-name { font-size: 14px; font-weight: 600; color: var(--text, #101014); }
.dc-note { font-size: 12.5px; line-height: 1.5; color: var(--text-soft, #5a5f6b); margin-top: 3px; overflow-wrap: anywhere; }
.dc-row.bad { box-shadow: inset 0 0 0 1.5px rgba(224, 54, 76, 0.35), 0 1px 2px rgba(8, 10, 18, 0.06); }
.dc-verdict {
  margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  font-size: 14px; font-weight: 700; line-height: 1.5;
}
.dc-verdict.ok { background: rgba(13, 159, 110, 0.12); color: #0b7c58; }
.dc-verdict.bad { background: rgba(224, 54, 76, 0.12); color: #b02a3c; }
.dc-note-note, .dc-note { font-size: 12.5px; }
p.dc-note { margin-top: 26px; font-size: 12.5px; line-height: 1.6; color: var(--text-soft, #5a5f6b); }
