/* Voiceper — calm, friendly design system for mobile and desktop. */

/* ---- design tokens ---- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --font-sans: "Inter", "Nunito Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f0;
  --surface-3: #e3ebe6;
  --border: #d9e5df;
  --text: #17211c;
  --text-dim: #66746d;
  --text-muted: #85908a;
  --accent: #065f46;
  --accent-dark: #064e3b;
  --accent-soft: #dcefe8;
  --accent-ink: #ffffff;
  --accent-on-soft: #065f46;
  --danger: #dc2626;
  --danger-dark: #991b1b;
  --danger-soft: #fee2e2;
  --danger-ink: #ffffff;
  --warn: #d97706;
  --info: #2563eb;
  --gold: #f59e0b;
  --radius: .75rem;
  --radius-s: .5rem;
  --shadow: 0 .06rem .12rem rgba(16, 24, 40, .06), 0 .5rem 1.5rem rgba(16, 24, 40, .08);
  --shadow-soft: 0 .06rem .12rem rgba(16, 24, 40, .06);
  --shadow-raised: 0 .62rem 1.9rem rgba(16, 24, 40, .12);
  --focus: color-mix(in srgb, var(--accent) 42%, transparent);
  --content-max: 65rem;
  --nav-h: clamp(4.25rem, 13svh, 4.75rem);
  --topbar-h: clamp(3.5rem, 10svh, 4rem);
  --side-nav-w: clamp(5.5rem, 8vw, 6rem);
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --tap-size: 2.75rem;
  --tap-size-sm: 2.25rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141a;
    --surface: #171f29;
    --surface-2: #202a36;
    --surface-3: #2a3644;
    --border: #334155;
    --text: #edf2f7;
    --text-dim: #a7b4c2;
    --text-muted: #8795a5;
    --accent: #34d399;
    --accent-dark: #10b981;
    --accent-soft: #103b2d;
    --accent-ink: #06231a;
    --accent-on-soft: #bbf7d0;
    --danger: #f87171;
    --danger-dark: #ef4444;
    --danger-soft: #451a1a;
    --danger-ink: #2a0b0b;
    --warn: #fbbf24;
    --info: #60a5fa;
    --gold: #facc15;
    --shadow: 0 .06rem .12rem rgba(0, 0, 0, .35), 0 .62rem 1.5rem rgba(0, 0, 0, .28);
    --shadow-soft: 0 .06rem .12rem rgba(0, 0, 0, .28);
    --shadow-raised: 0 1rem 2.25rem rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141a;
  --surface: #171f29;
  --surface-2: #202a36;
  --surface-3: #2a3644;
  --border: #334155;
  --text: #edf2f7;
  --text-dim: #a7b4c2;
  --text-muted: #8795a5;
  --accent: #34d399;
  --accent-dark: #10b981;
  --accent-soft: #103b2d;
  --accent-ink: #06231a;
  --accent-on-soft: #bbf7d0;
  --danger: #f87171;
  --danger-dark: #ef4444;
  --danger-soft: #451a1a;
  --danger-ink: #2a0b0b;
  --warn: #fbbf24;
  --info: #60a5fa;
  --gold: #facc15;
  --shadow: 0 .06rem .12rem rgba(0, 0, 0, .35), 0 .62rem 1.5rem rgba(0, 0, 0, .28);
  --shadow-soft: 0 .06rem .12rem rgba(0, 0, 0, .28);
  --shadow-raised: 0 1rem 2.25rem rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; min-width: 0; }
button { color: inherit; }
img, svg, video, canvas { max-width: 100%; }
img, video, canvas { height: auto; }
.ui-icon {
  width: 1.2em;
  height: 1.2em;
  display: inline-block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1, h2, h3 { font-weight: 750; letter-spacing: 0; line-height: 1.15; margin: 0 0 .55em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.03rem; }
@media (min-width: 45rem) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.35rem; }
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p.dim, .dim { color: var(--text-dim); }
.small { font-size: .85rem; }
:where(button, a, input, select, textarea, [role=button]):focus-visible {
  outline: .18rem solid var(--focus);
  outline-offset: .18rem;
}
::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.boot-splash {
  display: flex; align-items: center; justify-content: center;
  min-height: 100svh;
}
.boot-logo {
  display: block;
  width: min(13rem, 70vw);
  height: auto;
}

.brand-logo {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  line-height: 0;
}
.brand-logo img {
  display: block;
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
}
.brand-logo-full {
  width: 8.4rem;
}
.brand-logo-mark {
  width: 2rem;
  height: 2rem;
}
.brand-logo-mark img {
  height: 100%;
  object-fit: contain;
}
.brand-logo .brand-logo-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo-full .brand-logo-light {
    display: none;
  }
  :root:not([data-theme="light"]) .brand-logo-full .brand-logo-dark {
    display: block;
  }
}
:root[data-theme="dark"] .brand-logo-full .brand-logo-light {
  display: none;
}
:root[data-theme="dark"] .brand-logo-full .brand-logo-dark {
  display: block;
}
:root[data-theme="light"] .brand-logo-full .brand-logo-light {
  display: block;
}
:root[data-theme="light"] .brand-logo-full .brand-logo-dark {
  display: none;
}

/* ---- layout ---- */
.shell { display: flex; min-height: 100svh; }
.main {
  flex: 1;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 1.15rem) clamp(1rem, 4vw, 1.4rem)
    calc(var(--nav-h) + clamp(1.25rem, 5vw, 1.75rem));
  width: 100%;
  min-width: 0;
}
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: clamp(.5rem, 2vw, .62rem);
  min-height: var(--topbar-h);
  padding: .62rem clamp(.75rem, 4vw, 1rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: thin solid color-mix(in srgb, var(--border) 70%, transparent);
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
}
.topbar .brand,
.brand-lockup {
  display: flex; align-items: center; gap: .5rem;
  min-width: 0; white-space: nowrap;
}
.topbar .brand .brand-logo-shell {
  width: clamp(7.2rem, 18vw, 8.8rem);
}
.topbar .brand .brand-logo-shell-mark {
  display: none;
  width: 2rem;
  height: 2rem;
}
.topbar .spacer { flex: 1; }
.next-call-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: .5rem;
  max-width: min(27rem, 44vw);
  min-height: var(--tap-size);
  padding: .45rem .75rem;
  border: thin solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 999rem;
  background: color-mix(in srgb, var(--accent-soft) 48%, var(--surface));
  color: var(--accent-on-soft);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  flex: 0 1 auto;
  min-width: 0;
  transition: background-color .16s ease, border-color .16s ease,
    box-shadow .16s ease, transform .08s ease;
}
.next-call-pill[hidden] { display: none; }
.next-call-pill:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
  box-shadow: 0 0 0 .22rem color-mix(in srgb, var(--accent) 10%, transparent);
}
.next-call-pill:active { transform: scale(.97); }
.next-call-pill .ui-icon {
  width: 1.12rem;
  height: 1.12rem;
  flex: 0 0 auto;
}
.next-call-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.12;
}
.next-call-kicker {
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-call-detail {
  margin-top: .08rem;
  color: var(--text-dim);
  font-size: .68rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-call-pill.is-live {
  border-color: color-mix(in srgb, var(--accent) 78%, var(--border));
  background: var(--accent);
  color: var(--accent-ink);
}
.next-call-pill.is-live .next-call-detail {
  color: color-mix(in srgb, var(--accent-ink) 82%, transparent);
}
.iconbtn {
  position: relative;
  border: thin solid var(--border); background: var(--surface);
  width: var(--tap-size); height: var(--tap-size); border-radius: 50%;
  box-shadow: var(--shadow-soft);
  font-size: 1.1rem; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: background-color .16s ease, border-color .16s ease,
    box-shadow .16s ease, transform .08s ease;
}
.iconbtn .ui-icon { width: 1.25rem; height: 1.25rem; }
.iconbtn:hover { background: var(--surface-2); border-color: var(--surface-3); }
.iconbtn:active { transform: scale(.94); }
.chat-shortcut {
  border-color: color-mix(in srgb, var(--border) 82%, var(--accent));
}
.chat-shortcut .ui-icon {
  width: 1.38rem;
  height: 1.38rem;
  stroke-width: 2.15;
}
.chat-shortcut:hover,
.chat-shortcut.has-unread {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--accent) 12%, transparent);
}
.iconbtn .dot {
  position: absolute; top: -.06rem; right: -.06rem;
  min-width: 1.06rem; height: 1.06rem; padding: 0 .25rem;
  background: var(--danger-dark); color: #fff;
  border-radius: .56rem; font-size: .68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: .12rem solid var(--surface);
}
@media (max-width: 26.25rem) {
  .topbar { gap: .5rem; padding-inline: .75rem; }
  .topbar .brand { font-size: 0; gap: 0; }
  .topbar .brand .brand-logo-shell-full { display: none; }
  .topbar .brand .brand-logo-shell-mark { display: inline-grid; }
  .next-call-pill {
    width: var(--tap-size);
    padding: 0;
    justify-content: center;
  }
  .next-call-text { display: none; }
  .iconbtn { width: 2.38rem; height: 2.38rem; }
}
@media (max-width: 45rem) {
  .next-call-pill { max-width: 38vw; }
  .next-call-detail { display: none; }
}

/* bottom navigation (mobile-first) */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: thin solid var(--border);
  box-shadow: 0 -.5rem 1.5rem rgba(16,24,40,.08);
  padding: .44rem .38rem calc(.44rem + env(safe-area-inset-bottom));
  height: auto;
}
.nav button {
  border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .12rem;
  color: var(--text-dim); font-size: .68rem; font-weight: 700;
  min-height: 3.12rem;
  min-width: min(3.12rem, 18vw);
  padding: .31rem clamp(.28rem, 2vw, .5rem);
  border-radius: .75rem;
  transition: background-color .16s ease, color .16s ease, transform .08s ease;
}
.nav button .ico {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  color: currentColor;
  line-height: 1;
}
.nav button .ico .ui-icon { width: 1.38rem; height: 1.38rem; stroke-width: 1.85; }
.nav button span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav button:hover { background: var(--surface-2); }
.nav button.active {
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
.nav button.active .ico { transform: scale(1.08); }

@media (min-width: 56.25rem) {
  .shell { padding-left: var(--side-nav-w); }
  .nav {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--side-nav-w);
    flex-direction: column; justify-content: flex-start; align-items: center;
    gap: .5rem; padding: 5.38rem .62rem .88rem;
    border-top: 0; border-right: thin solid var(--border);
    box-shadow: .5rem 0 1.5rem rgba(16,24,40,.06);
  }
  .nav button {
    width: min(calc(100% - .5rem), 5.25rem);
    min-height: 3.62rem;
    padding: .5rem .25rem;
    justify-content: center;
    overflow: hidden;
    text-align: center;
    margin-inline: auto;
  }
  .nav button .ico {
    margin-inline: auto;
  }
  .nav button span:last-child {
    width: 100%;
    text-align: center;
  }
  .main { padding: 1.75rem clamp(1.5rem, 3vw, 1.75rem) 3.25rem; }
  .topbar {
    padding-left: calc(var(--side-nav-w) + clamp(1.5rem, 3vw, 1.75rem));
    padding-right: clamp(1.5rem, 3vw, 1.75rem);
  }
}

/* server uptime badge (VOICEPER_SHOW_UPTIME) */
.uptime-badge {
  position: fixed; z-index: 35; left: .38rem;
  bottom: calc(var(--nav-h) + .38rem);
  background: var(--surface); color: var(--text-dim);
  font-size: .68rem; font-weight: 600;
  padding: .18rem .56rem; border-radius: .62rem; box-shadow: var(--shadow);
  opacity: .85; pointer-events: none;
}
@media (min-width: 56.25rem) {
  .uptime-badge { left: calc(var(--side-nav-w) + .25rem); bottom: .5rem; }
}

/* ---- cards & buttons ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: thin solid var(--border);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.12rem);
  margin-bottom: 1rem;
}
.card.flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card[style*="cursor:pointer"], .action-card {
  transition: border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}
.card[style*="cursor:pointer"]:hover, .action-card:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  box-shadow: var(--shadow-raised);
  transform: translateY(-.06rem);
}
.row { display: flex; gap: .75rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.select-inline {
  width: auto;
  min-width: clamp(8.25rem, 18vw, 10.75rem);
  flex: 0 0 auto;
}
@media (max-width: 40rem) {
  .select-inline {
    width: 100%;
    min-width: 0;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(.75rem, 3vw, 1rem);
  margin-bottom: clamp(.88rem, 3vw, 1.12rem);
}
.page-head h1 { margin-bottom: .25rem; }
.page-head p { margin: 0; max-width: 42rem; }
.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.section {
  margin-top: clamp(1.25rem, 4vw, 1.5rem);
}
.section:first-child { margin-top: 0; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .62rem;
}
.section-head h2 { margin: 0; }
.section-head .dim { margin: .12rem 0 0; }
.focus-card {
  background: linear-gradient(135deg, var(--surface), var(--accent-soft));
  border: thin solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.12rem);
}
.focus-card h2,
.focus-card h3,
.focus-card p { margin-top: 0; }
.focus-card p:last-child { margin-bottom: 0; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.75rem), 1fr));
  gap: .75rem;
}
.action-card {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  padding: clamp(.88rem, 3vw, 1rem);
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.action-card:hover { text-decoration: none; }
.action-card .item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.62rem;
  height: 2.62rem;
  border-radius: .75rem;
  background: var(--surface-2);
  color: var(--accent);
}
.action-card .item-icon .ui-icon { width: 1.31rem; height: 1.31rem; }
.action-card .item-title { display: block; margin-bottom: .12rem; }
.action-card .item-meta { display: block; color: var(--text-dim); font-size: .85rem; }
.training-card {
  margin-bottom: .75rem;
}
.training-card .ring {
  flex: 0 0 auto;
}
.list-card {
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list-card .list-item {
  padding: clamp(.8rem, 2.5vw, .88rem) clamp(.88rem, 3vw, 1rem);
}
.list-card .list-item[style*="cursor:pointer"]:hover,
.list-item [role=button]:hover {
  color: var(--accent);
}
.list-primary { font-weight: 700; }
.list-meta {
  color: var(--text-dim);
  font-size: .85rem;
  margin-top: .12rem;
}
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.list-card .inline-actions .iconbtn {
  width: var(--tap-size);
  height: var(--tap-size);
  border-radius: .88rem;
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  box-shadow: none;
}
.list-card .inline-actions .iconbtn .ui-icon {
  width: 1.38rem;
  height: 1.38rem;
}
.list-card .inline-actions .iconbtn:hover {
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface-3));
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  border-radius: 999rem;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: .78rem;
  font-weight: 750;
  line-height: 1;
  padding: .38rem .56rem;
}
.pill.good {
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
.pill.warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: color-mix(in srgb, var(--warn) 72%, var(--text));
}
.pill.danger-soft {
  background: var(--danger-soft);
  color: color-mix(in srgb, var(--danger) 78%, var(--text));
}
@media (max-width: 38.75rem) {
  .page-head {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: .88rem;
  }
  .page-actions .btn,
  .page-actions .btn.sm {
    width: 100%;
  }
  .section { margin-top: 1.25rem; }
  .focus-card { padding: 1rem; }
  .action-card { padding: .88rem; }
  .list-card .list-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .list-card .inline-actions {
    flex-basis: 100%;
    justify-content: flex-start;
    padding-left: clamp(2.75rem, 12vw, 3rem);
  }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: thin solid transparent; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 1rem;
  line-height: 1.15;
  min-height: var(--tap-size);
  padding: .68rem clamp(.9rem, 4vw, 1.25rem);
  border-radius: .75rem;
  box-shadow: 0 .18rem 0 var(--accent-dark);
  text-align: center;
  max-width: 100%;
  min-width: 0;
  transition: background-color .16s ease, border-color .16s ease,
    box-shadow .08s ease, transform .08s ease;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 92%, #000); text-decoration: none; }
.btn:active { transform: translateY(.12rem); box-shadow: 0 .06rem 0 var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 .18rem 0 color-mix(in srgb, var(--border) 75%, #000);
}
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger {
  background: var(--danger);
  box-shadow: 0 .18rem 0 var(--danger-dark);
  color: var(--danger-ink);
}
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 92%, #000); }
.btn.ghost {
  background: transparent; border-color: transparent; box-shadow: none;
  color: var(--accent); padding: .5rem .75rem;
}
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-on-soft); }
.btn.sm {
  min-height: var(--tap-size-sm);
  padding: .5rem clamp(.7rem, 3vw, .88rem);
  font-size: .88rem;
  border-radius: .62rem;
}
.btn.block { width: 100%; }
/* ---- forms ---- */
label.field { display: block; margin-bottom: .88rem; min-width: 0; }
label.field span { display: block; font-size: .85rem; font-weight: 600; color: var(--text-dim); margin-bottom: .31rem; }
input[type=text], input[type=email], input[type=password], input[type=time],
input[type=number], select, textarea {
  width: 100%;
  border: thin solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-s);
  min-height: var(--tap-size);
  padding: .62rem .75rem;
  font-size: 1rem;
  font-family: inherit;
  box-shadow: var(--shadow-soft);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 .18rem var(--focus);
}
textarea { line-height: 1.4; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
.seg {
  display: flex; background: var(--surface-2); border-radius: .75rem; padding: .25rem;
  border: thin solid color-mix(in srgb, var(--border) 72%, transparent);
  min-width: 0;
}
.seg button {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: .56rem; border-radius: .56rem; font-weight: 700; color: var(--text-dim);
  font-size: .92rem;
  min-height: var(--tap-size-sm);
  min-width: 0;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.switch { position: relative; display: inline-block; width: 3rem; height: 1.75rem; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--surface-2);
  border: thin solid var(--border);
  border-radius: .88rem; transition: .18s; cursor: pointer;
}
.switch .track::before {
  content: ""; position: absolute; width: 1.38rem; height: 1.38rem;
  left: .18rem; top: .18rem; background: #fff; border-radius: 50%;
  box-shadow: 0 .06rem .18rem rgba(0,0,0,.3); transition: .18s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(1.25rem); }

/* ---- gamification ---- */
.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.25rem), 1fr));
  gap: .75rem;
}
.stat {
  background: var(--surface); border-radius: var(--radius);
  border: thin solid var(--border);
  box-shadow: var(--shadow); padding: .94rem .75rem; text-align: center;
}
.stat .val { font-size: 1.55rem; font-weight: 850; line-height: 1.15; }
.stat .lbl { font-size: .78rem; color: var(--text-dim); font-weight: 600; }
.progress-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(min(100%, 22rem), .95fr);
  gap: .75rem;
  align-items: stretch;
}
.progress-summary,
.progress-trend-card {
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(.94rem, 3vw, 1.12rem);
}
.progress-summary {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.progress-streak {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  width: fit-content;
  max-width: 100%;
  border-radius: 999rem;
  padding: .38rem .62rem;
  background: color-mix(in srgb, var(--accent-soft) 74%, var(--surface));
  color: var(--accent-on-soft);
  font-size: .84rem;
  font-weight: 800;
  line-height: 1;
}
.progress-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: .62rem;
}
.progress-metric {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .62rem;
  align-items: center;
  min-width: 0;
  padding: .75rem;
  border: thin solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 84%, var(--surface-2));
}
.progress-metric-icon {
  display: inline-grid;
  place-items: center;
  width: 2.12rem;
  height: 2.12rem;
  border-radius: .62rem;
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
.progress-metric-icon .ui-icon {
  width: 1.12rem;
  height: 1.12rem;
}
.progress-metric-value {
  font-size: clamp(1.28rem, 5vw, 1.7rem);
  font-weight: 850;
  line-height: 1.05;
}
.progress-metric-label {
  margin-top: .18rem;
  color: var(--text-dim);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
}
.progress-trend-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.progress-trends {
  display: grid;
  gap: .75rem;
}
.progress-trend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}
.progress-trend-head h3 {
  margin-bottom: .18rem;
  font-size: 1rem;
}
.progress-sparkline {
  width: 100%;
  min-height: 4.5rem;
  padding: .5rem;
  border-radius: var(--radius-s);
  color: var(--accent);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--surface-2) 48%, transparent),
      transparent);
}
.progress-sparkline svg {
  display: block;
  width: 100%;
  height: auto;
}
.progress-sparkline-base,
.progress-sparkline-line {
  fill: none;
  stroke-linecap: round;
}
.progress-sparkline-base {
  stroke: color-mix(in srgb, var(--border) 72%, transparent);
  stroke-width: .35;
}
.progress-sparkline-line {
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linejoin: round;
}
.progress-sparkline-dot {
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: .65;
}
.progress-sparkline-dot.is-last {
  fill: currentColor;
}
.progress-trend-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .62rem;
  font-size: .86rem;
}
.progress-trend-meta span {
  color: var(--text-dim);
  font-size: .74rem;
  font-weight: 700;
}
.badges { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: .62rem; }
.badge {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  min-height: 6.5rem; padding: .75rem .5rem; border-radius: var(--radius-s);
  background: var(--surface-2); text-align: center;
  border: thin solid color-mix(in srgb, var(--border) 42%, transparent);
}
.badge .em {
  display: grid;
  place-items: center;
  width: 2.12rem;
  height: 2.12rem;
  color: var(--text-dim);
  opacity: .42;
}
.badge .em .ui-icon { width: 1.38rem; height: 1.38rem; }
.badge.earned {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}
.badge.earned .em { color: var(--accent-on-soft); opacity: 1; }
.badge .nm { font-size: .68rem; font-weight: 600; color: var(--text-dim); }
.achievement-progress {
  margin-top: auto;
  min-width: 3.25rem;
  border-radius: 999rem;
  padding: .22rem .48rem;
  background: var(--surface);
  color: var(--text-dim);
  font-size: .68rem;
  font-weight: 800;
}
.badge.earned .achievement-progress {
  color: var(--accent-on-soft);
}
@media (max-width: 38.75rem) {
  .progress-panel {
    grid-template-columns: minmax(0, 1fr);
  }
  .progress-trend-head,
  .progress-trend-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

.ring { position: relative; width: 4.75rem; height: 4.75rem; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring .num {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: .95rem;
}

.done-hero {
  text-align: center; padding: clamp(1.25rem, 5vw, 1.75rem) 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--accent-ink); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.done-hero .big {
  display: grid;
  place-items: center;
  width: 3.62rem;
  height: 3.62rem;
  margin: 0 auto .62rem;
  border-radius: 1.12rem;
  background: rgba(255,255,255,.16);
}
.done-hero .big .ui-icon { width: 2rem; height: 2rem; stroke-width: 2.6; }
.timer-finished {
  display: grid;
  place-items: center;
  color: var(--accent);
}
.timer-finished .ui-icon { width: 2.62rem; height: 2.62rem; stroke-width: 2.5; }

/* exercise status list */
.exlist { display: flex; flex-direction: column; gap: .62rem; }
.exitem {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); padding: .88rem; border-radius: var(--radius-s);
  box-shadow: var(--shadow); cursor: pointer; border: thin solid var(--border);
  transition: border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}
.exitem:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow-raised);
  transform: translateY(-.06rem);
}
.exitem .status { font-size: 1.5rem; width: 2.12rem; text-align: center; flex: 0 0 auto; }
.exitem.done { opacity: .75; }
.exitem .tool-tag {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-on-soft);
  padding: .18rem .5rem; border-radius: .38rem;
}

/* ---- lists ---- */
.list-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem .25rem; border-bottom: thin solid var(--surface-2);
}
.list-item > * { min-width: 0; }
.list-item:last-child { border-bottom: none; }
@media (max-width: 32.5rem) {
  .list-item { gap: .62rem; }
  .list-item .btn.sm { padding-inline: .62rem; }
}

/* ---- training traffic light (navigation.md: therapist progress at a glance) ---- */
.traffic-dot {
  display: inline-block; width: .75rem; height: .75rem; border-radius: 50%;
  flex-shrink: 0;
}
.traffic-dot.green { background: var(--accent); }
.traffic-dot.yellow { background: var(--warn); }
.traffic-dot.red { background: var(--danger); }
.training-plan-card {
  padding: clamp(1rem, 3vw, 1.12rem);
}
.training-plan-main {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.training-plan-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.training-plan-chips,
.traffic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.training-plan-actions {
  display: flex;
  align-items: center;
  gap: .62rem;
  margin-left: auto;
}
.patient-training-group {
  margin-top: 1.12rem;
}
.patient-training-name {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: .62rem;
}
.patient-training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.25rem), 1fr));
  gap: .75rem;
}
.patient-training-card {
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  padding: .88rem .94rem;
}
.patient-training-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .62rem;
  margin-bottom: .62rem;
}
.patient-streak {
  display: inline-flex;
  align-items: center;
  gap: .31rem;
  flex: 0 0 auto;
  font-size: .92rem;
  font-weight: 800;
  color: var(--text-dim);
}
.patient-streak .ui-icon { width: 1rem; height: 1rem; color: var(--accent); }
.patient-training-empty {
  color: var(--text-dim);
  padding: .38rem 0 .12rem;
}
@media (max-width: 38.75rem) {
  .training-plan-head {
    flex-direction: column;
  }
  .training-plan-actions {
    margin-left: 0;
    width: 100%;
  }
  .training-plan-actions .btn.sm.secondary {
    flex: 1;
  }
  .patient-training-card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ---- tool canvases ---- */
.bio-mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin-bottom: .75rem;
}
.bio-mode-btn {
  min-width: 0;
  min-height: 4.25rem;
  padding: .62rem .75rem;
  text-align: left;
  color: var(--text-dim);
  background: var(--surface-2);
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  box-shadow: none;
  cursor: pointer;
}
.bio-mode-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
}
.bio-mode-btn.active {
  color: var(--accent-on-soft);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
  box-shadow: inset 0 0 0 .06rem color-mix(in srgb, var(--accent) 22%, transparent);
}
.bio-mode-title {
  display: block;
  font-size: .9rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.bio-mode-desc {
  display: block;
  margin-top: .18rem;
  font-size: .76rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.viz-wrap { position: relative; }
canvas.viz {
  width: 100%; height: clamp(13rem, 46svh, 16.25rem); border-radius: var(--radius-s);
  background: #0b1016; display: block;
  border: thin solid color-mix(in srgb, var(--border) 22%, #0b1016);
}
.viz-readout {
  display: flex; gap: clamp(.75rem, 4vw, 1.12rem); justify-content: center; flex-wrap: wrap;
  margin-top: .62rem;
}
.viz-readout .vr { text-align: center; }
.viz-readout .vr .v { font-size: 1.5rem; font-weight: 800; }
.viz-readout .vr .k { font-size: .72rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; }
/* min/max target labels on the live view (training-plans.md) */
.viz-mark {
  position: absolute; left: .38rem; transform: translateY(-50%);
  font-size: .66rem; font-weight: 700; color: rgba(255,255,255,.75);
  background: rgba(0,0,0,.35); padding: .06rem .31rem; border-radius: .38rem;
  pointer-events: none;
}
.rec-pulse {
  display: inline-block; width: .75rem; height: .75rem; border-radius: 50%;
  background: var(--danger); animation: pulse 1s infinite;
  margin-right: .38rem;
}
@media (max-width: 35rem) {
  .bio-mode-picker {
    gap: .38rem;
  }
  .bio-mode-btn {
    min-height: 3rem;
    padding: .5rem;
    text-align: center;
  }
  .bio-mode-desc {
    display: none;
  }
}

/* ---- overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 20, .58);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s;
}
@media (min-width: 40rem) { .overlay { align-items: center; } }
@keyframes fadein { from { opacity: 0; } }
.sheet {
  background: var(--surface); border-radius: 1.25rem 1.25rem 0 0;
  width: 100%; max-width: min(35rem, calc(100vw - 1rem)); max-height: 88svh; overflow-y: auto;
  padding: clamp(1rem, 4vw, 1.38rem);
  border: thin solid var(--border);
  box-shadow: var(--shadow-raised);
  overscroll-behavior: contain;
  animation: slideup .2s ease-out;
}
@media (min-width: 40rem) {
  .sheet { width: calc(100% - 2rem); border-radius: 1.25rem; }
}
@keyframes slideup { from { transform: translateY(2.5rem); opacity: 0; } }
.sheet .sheet-head { display: flex; align-items: center; gap: .62rem; margin-bottom: .75rem; }
.sheet .sheet-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.sheet :where(input, select, textarea, .row, .list-item) { min-width: 0; }
.editor-section {
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
  margin-bottom: .75rem;
  overflow: hidden;
}
.editor-section summary {
  display: flex;
  align-items: center;
  gap: .62rem;
  min-height: 3.25rem;
  padding: .62rem .75rem;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}
.editor-section summary::-webkit-details-marker {
  display: none;
}
.editor-section summary::after {
  content: "›";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1.35rem;
  transform: rotate(90deg);
  transition: transform .16s ease;
}
.editor-section:not([open]) summary::after {
  transform: rotate(0);
}
.editor-section-body {
  padding: 0 .75rem .75rem;
}
.editor-section-body > :last-child {
  margin-bottom: 0;
}
.editor-savebar {
  margin-top: .88rem;
}
@media (min-width: 40rem) {
  .editor-savebar {
    position: sticky;
    bottom: -1.38rem;
    background: linear-gradient(
      to bottom,
      color-mix(in srgb, var(--surface) 72%, transparent),
      var(--surface) 24%
    );
    padding-top: .75rem;
  }
}

.toast-wrap {
  position: fixed; bottom: calc(var(--nav-h) + 1rem); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  z-index: 200; pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: .68rem clamp(1rem, 5vw, 1.25rem); border-radius: 1.5rem; font-weight: 600;
  box-shadow: var(--shadow); max-width: 88%;
  overflow-wrap: anywhere;
  text-align: center;
  animation: slideup .2s ease-out;
}
.toast.error { background: var(--danger-dark); color: #fff; }
.toast.success { background: var(--accent); color: var(--accent-ink); }
@media (min-width: 56.25rem) {
  .toast-wrap { bottom: 1.5rem; left: var(--side-nav-w); }
}

/* notifications panel */
.notif-item { display: flex; gap: .62rem; padding: .75rem .12rem; border-bottom: thin solid var(--surface-2); }
.notif-item.unread { font-weight: 600; }
.notif-item .em {
  display: grid;
  place-items: center;
  width: 2.12rem;
  height: 2.12rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: .62rem;
}
.notif-item .em .ui-icon { width: 1.12rem; height: 1.12rem; }
.notif-item .when { font-size: .75rem; color: var(--text-dim); }

/* confetti */
.confetti {
  position: fixed; width: .62rem; height: .88rem; z-index: 500; top: -1.25rem;
  pointer-events: none; border-radius: .12rem;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110svh) rotate(720deg); opacity: .7; }
}

/* auth screens */
.auth-wrap {
  max-width: min(27.5rem, 100%);
  margin: 0 auto;
  min-height: 100svh;
  padding: clamp(2rem, 9svh, 3rem) clamp(1rem, 5vw, 1.25rem);
}
.auth-logo {
  display: grid;
  place-items: center;
  width: min(12rem, 72vw);
  margin-bottom: .25rem;
  margin-inline: auto;
}
.auth-tag { text-align: center; color: var(--text-dim); margin-bottom: 1.75rem; }
.oauth-row { display: flex; flex-direction: column; gap: .62rem; margin: 1.12rem 0; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: .62rem;
  border: thin solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: .95rem;
  padding: .68rem; border-radius: .75rem; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.oauth-btn:hover { background: var(--surface-2); }
.hr-label {
  display: flex; align-items: center; gap: .75rem; color: var(--text-dim);
  font-size: .8rem; margin: 1.12rem 0;
}
.hr-label::before, .hr-label::after {
  content: ""; flex: 1; height: .0625rem; background: var(--surface-2);
}
.warn-box {
  background: var(--danger-soft); border-radius: var(--radius-s);
  padding: .75rem .88rem; font-size: .88rem; margin: .62rem 0;
  border: thin solid color-mix(in srgb, var(--danger) 22%, transparent);
}
.info-box {
  background: var(--accent-soft); border-radius: var(--radius-s);
  padding: .75rem .88rem; font-size: .88rem; margin: .62rem 0;
  border: thin solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.daychips { display: flex; gap: .38rem; flex-wrap: wrap; }
.daychips button {
  border: thin solid var(--border); background: var(--surface);
  color: var(--text-dim); font-weight: 700; font-size: .8rem;
  width: var(--tap-size); height: var(--tap-size); border-radius: 50%; cursor: pointer;
}
.daychips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.timechips { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.timechip {
  background: var(--accent-soft); color: var(--accent-on-soft);
  font-weight: 700; padding: .44rem .75rem; border-radius: 1.25rem; font-size: .9rem;
  display: inline-flex; gap: .44rem; align-items: center;
}
.timechip button { border: none; background: none; cursor: pointer; color: inherit; font-weight: 800; }

.empty {
  text-align: center; color: var(--text-dim); padding: clamp(1.5rem, 8vw, 2.12rem) .75rem;
}
.empty .em {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto .62rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 1rem;
  font-size: 2rem;
}
.empty .em .ui-icon { width: 1.75rem; height: 1.75rem; }
.craft-empty {
  max-width: min(32.5rem, 100%);
  margin: 1.12rem auto;
  border: thin solid color-mix(in srgb, var(--border) 74%, transparent);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--surface) 94%, var(--accent) 6%),
      var(--surface));
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.empty-title {
  color: var(--text);
  font-weight: 800;
  font-size: 1.03rem;
}
.empty-copy {
  max-width: 38rem;
  margin: .44rem auto 0;
  color: var(--text-dim);
  line-height: 1.55;
}

table.metrics { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.metrics td { padding: .31rem .5rem; border-bottom: thin solid var(--surface-2); }
table.metrics td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- chat (requirements/chat.md) ---- */
.chat-sheet {
  display: flex;
  flex-direction: column;
  width: min(100%, calc(100vw - 1rem));
  max-width: min(42rem, calc(100vw - 1rem));
  max-height: calc(100svh - 1rem);
  overflow: hidden;
}
.chat-sheet .sheet-head {
  flex: 0 0 auto;
  margin-bottom: clamp(.75rem, 2svh, 1rem);
}
.chat-sheet .chat-root {
  flex: 1 1 auto;
  min-height: 0;
  gap: clamp(.62rem, 1.5svh, .9rem);
}
.chat-sheet .chat-picker {
  flex: 0 0 auto;
  margin-bottom: 0;
}
.chat-sheet .chat-scroll {
  flex: 1 1 auto;
  max-height: none;
  min-height: clamp(12rem, 34svh, 18rem);
  padding: clamp(.62rem, 2vw, .9rem);
  gap: .62rem;
}
.chat-sheet .chat-composer { margin-top: 0; }
.chat-sheet .chat-composer > .row {
  align-items: stretch;
  row-gap: clamp(.7rem, 2vw, .9rem) !important;
  column-gap: clamp(.5rem, 2vw, .75rem) !important;
}
.chat-sheet .chat-composer > .row > .grow {
  align-self: stretch;
  display: flex;
}
.chat-sheet .chat-input {
  min-height: var(--tap-size);
  height: 100%;
  padding-block: .62rem;
}
.chat-sheet .chat-composer .btn.sm {
  min-height: var(--tap-size);
}
.chat-root { display: flex; flex-direction: column; min-height: min(50svh, 32rem); }
.chat-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}
.chat-picker select {
  flex: 1 1 11.25rem;
  min-width: 0;
}
.chat-scroll {
  flex: 1; overflow-y: auto;
  max-height: min(52svh, 36rem);
  min-height: clamp(12rem, 38svh, 13.75rem);
  display: flex; flex-direction: column; gap: .5rem;
  padding: .62rem; background: var(--surface-2); border-radius: var(--radius-s);
  border: thin solid color-mix(in srgb, var(--border) 72%, transparent);
  overscroll-behavior: contain;
}
.chat-msg {
  align-self: flex-start; max-width: min(82%, 36rem);
  background: var(--surface); padding: .5rem .68rem; border-radius: .88rem;
  border-top-left-radius: .25rem; box-shadow: var(--shadow);
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.chat-msg.mine {
  align-self: flex-end; background: var(--accent-soft);
  border-top-left-radius: .88rem; border-top-right-radius: .25rem;
  color: var(--accent-on-soft);
}
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-meta {
  margin-top: .25rem; font-size: .68rem; color: var(--text-dim);
  display: flex; gap: .18rem .5rem; align-items: center; flex-wrap: wrap;
}
.chat-system {
  align-self: center; font-size: .74rem; color: var(--text-dim);
  background: var(--surface); padding: .18rem .62rem; border-radius: .75rem;
}
.chat-file { color: var(--accent-on-soft); font-weight: 600; text-decoration: none; }
.chat-composer { margin-top: .62rem; }
.chat-composer > .row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}
.chat-composer > .row > .grow {
  grid-column: 1 / -2;
  min-width: 0;
}
.chat-composer .ctrl-lbl {
  min-width: 0;
  width: 100%;
}
.chat-composer .ctrl-lbl .lbl {
  max-width: 100%;
}
.chat-composer .ctrl-lbl .iconbtn {
  margin-inline: auto;
}
.chat-input {
  width: 100%; resize: none; min-height: 2.38rem; max-height: 7.5rem;
  border: thin solid var(--border); border-radius: var(--radius-s);
  padding: .5rem .62rem; background: var(--surface); color: var(--text);
  font: inherit;
}
.chat-composer .btn.sm {
  grid-column: -2 / -1;
  align-self: stretch;
  min-height: var(--tap-size);
  width: 100%;
  padding-inline: .75rem;
}
.chat-danger { margin-top: .5rem; text-align: right; }
.linkbtn {
  border: none; background: none; color: var(--text-dim); cursor: pointer;
  font-size: .72rem; padding: 0; text-decoration: underline;
}
.linkbtn.danger { color: var(--danger); }
.iconbtn.recording { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.emoji-pop {
  position: fixed; z-index: 120;
  display: grid; grid-template-columns: repeat(4, minmax(3rem, 1fr)); gap: .5rem;
  background: var(--surface); padding: .62rem; border-radius: 1.12rem;
  border: thin solid var(--border);
  box-shadow: var(--shadow-raised);
  max-height: min(26.25rem, calc(100svh - 1.5rem));
  overflow-y: auto;
}
.emoji-pop .iconbtn {
  width: 3.25rem;
  height: 3.25rem;
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--border) 76%, transparent);
  box-shadow: none;
  font-size: 1.55rem;
}
.emoji-pop .iconbtn:hover {
  background: var(--surface-3);
  border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
}
@media (max-width: 35rem) {
  .chat-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 100svh;
    border-radius: 1.25rem 1.25rem 0 0;
  }
  .chat-sheet .chat-scroll {
    min-height: clamp(14rem, 42svh, 19rem);
  }
  .chat-msg { max-width: 90%; }
  .chat-composer > .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-composer > .row > .grow {
    grid-column: 1 / -1;
  }
  .chat-composer > .row > .btn.sm {
    grid-column: 1 / -1;
  }
  .chat-danger { text-align: left; }
  .emoji-pop {
    grid-template-columns: repeat(4, minmax(2.62rem, 1fr));
    gap: .38rem;
    padding: .5rem;
  }
  .emoji-pop .iconbtn {
    width: 2.88rem;
    height: 2.88rem;
    font-size: 1.38rem;
  }
}

/* ---- video calls (requirements/videocall.md) ---- */
.call-wrap { display: flex; flex-direction: column; }
/* the video/whiteboard pane and the tool live-view are two separate
 * windows placed beside each other, stacking on narrow screens
 * (requirements/videocall.md) */
.call-stage {
  position: relative; margin-top: .5rem;
  display: flex; flex-direction: column; gap: .75rem;
}
@media (min-width: 47.5rem) {
  .call-stage { flex-direction: row; align-items: stretch; }
}
.call-mainpane { position: relative; flex: 1 1 auto; min-width: 0; }
.call-remote {
  position: relative; width: 100%;
  min-height: clamp(13rem, 48svh, 15rem);
  aspect-ratio: 4 / 3;
  background: #000; border-radius: var(--radius); overflow: hidden;
  border: thin solid var(--border);
  box-shadow: var(--shadow);
}
@media (min-width: 47.5rem) {
  .call-remote { aspect-ratio: 16 / 9; min-height: clamp(22rem, 54svh, 28rem); }
}
.call-remote video { width: 100%; height: 100%; object-fit: cover; }
/* mesh grid: 1 tile fills, 2+ tiles split (group calls) */
.call-grid { display: grid; width: 100%; height: 100%; gap: .12rem; }
.call-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.call-grid[data-count="3"], .call-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
}
.call-tile { position: relative; overflow: hidden; background: #000; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; }
.call-name {
  position: absolute; left: .5rem; bottom: .38rem;
  color: #fff; font-size: .75rem; font-weight: 600;
  background: rgba(0,0,0,.55); padding: .12rem .5rem; border-radius: .62rem;
  max-width: calc(100% - 1rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.call-local {
  position: absolute; right: clamp(.5rem, 2.5vw, .75rem); bottom: clamp(.5rem, 2.5vw, .75rem);
  width: clamp(6rem, 30%, 11.25rem); min-width: 0; aspect-ratio: 4 / 3;
  border-radius: var(--radius-s); overflow: hidden;
  box-shadow: 0 .12rem .62rem rgba(0,0,0,.4); border: .12rem solid var(--surface);
}
.call-local video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.call-status {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; text-align: center;
  color: #fff; background: rgba(0,0,0,.45); padding: clamp(1rem, 5vw, 1.25rem); font-weight: 600;
}
.call-controls {
  display: flex; align-items: center; gap: clamp(.75rem, 3vw, 1.12rem); margin-top: .75rem;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .75rem .88rem;
}
.call-controls-main {
  flex: 1 1 26.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: .75rem 1rem;
}
.call-controls-exit {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  margin-left: auto;
}
.call-controls-exit .btn.danger {
  min-height: var(--tap-size);
  border: thin solid color-mix(in srgb, var(--danger) 34%, var(--border));
  border-radius: var(--radius-s);
  background: var(--danger-soft);
  box-shadow: none;
  color: color-mix(in srgb, var(--danger) 72%, var(--text));
  padding: 0 1.12rem;
}
.call-controls-exit .btn.danger:hover {
  background: color-mix(in srgb, var(--danger-soft) 82%, var(--danger));
}
.call-controls-exit .btn.danger .ui-icon {
  width: 1.25rem;
  height: 1.25rem;
}
.call-controls .iconbtn {
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
  width: var(--tap-size);
  height: var(--tap-size);
}
.call-controls .iconbtn:hover {
  background: var(--surface-3);
}
.iconbtn.off { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }
.iconbtn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.iconbtn:disabled { opacity: .4; cursor: not-allowed; }
/* mic/camera device picker: a small caret pinned to the corner of the
 * mic/camera button, shown only when there's more than one device to
 * switch to (requirements/videocall.md) */
.ctrl-stack { position: relative; display: inline-flex; }
.ctrl-stack .devsel {
  position: absolute; right: -6px; bottom: -6px;
  width: 20px; height: 20px; min-width: 0; padding: 0;
}
.ctrl-stack .devsel .ui-icon { width: 12px; height: 12px; }
.ctrl-stack .devsel:disabled { display: none; }
/* icon button with a small explaining caption (chat.md, videocall.md) */
.ctrl-lbl {
  display: flex; flex-direction: column; align-items: center; gap: .31rem;
  min-width: 4rem;
}
.ctrl-lbl .lbl {
  font-size: .68rem; color: var(--text-dim); text-align: center;
  max-width: 5.12rem; line-height: 1.15;
  overflow-wrap: anywhere;
}
.call-controls .ctrl-lbl {
  flex: 0 1 4.75rem;
  min-width: 4.25rem;
}
.call-controls .ctrl-lbl .lbl {
  max-width: 4.75rem;
}
.call-chat .chat-scroll { max-height: min(34svh, 24rem); min-height: 8.75rem; }
.chat-sender { font-size: .72rem; font-weight: 700; color: var(--accent-dark); }

/* in-call tool live-view (requirements/videocall.md): at most one of the 5
 * tools selected, opened via a single "Tool" icon in .call-controls. Its
 * own window beside the video/whiteboard pane, not on top of it. */
.call-tools {
  background: var(--surface); border-radius: var(--radius);
  border: thin solid var(--border);
  box-shadow: var(--shadow); padding: .5rem;
  flex: 1 1 22rem; min-width: min(100%, 16rem);
}
.call-tools .bio-mode-picker {
  gap: .38rem;
  margin-bottom: .5rem;
}
.call-tools .bio-mode-btn {
  min-height: 2.75rem;
  padding: .44rem .5rem;
  text-align: center;
}
.call-tools .bio-mode-desc {
  display: none;
}
@media (max-width: 35rem) {
  .call-local {
    right: .5rem; bottom: .5rem; width: clamp(6rem, 34%, 8.62rem);
    border-width: thin;
  }
  .call-controls {
    align-items: stretch;
    gap: .75rem;
    padding: .75rem .62rem;
  }
  .call-controls-main {
    flex-basis: 100%;
    justify-content: center;
    gap: .62rem .5rem;
  }
  .call-controls .ctrl-lbl {
    flex-basis: calc(33.333% - .5rem);
    min-width: 3.62rem;
  }
  .call-controls-exit {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: center;
  }
  .call-controls-exit .btn.danger {
    justify-content: center;
    width: min(100%, 15rem);
  }
}
@media (max-width: 26.25rem) {
  .call-controls-main {
    justify-content: center;
  }
}
@media (max-width: 22.5rem) {
  .call-controls .ctrl-lbl {
    flex-basis: calc(50% - .5rem);
  }
}

/* Almost-fullscreen desktop layout (requirements/videocall.md): chat sits
 * in its own column beside the stage, and everything is sized to the
 * viewport so the page itself never needs to scroll — panels that could
 * overflow (chat, whiteboard, tool) scroll internally instead. Scoped to
 * body.call-active, toggled only while the live call view is mounted, so
 * the rest of the app shell is untouched. */
@media (min-width: 56.25rem) {
  body.call-active .shell { min-height: calc(100svh - var(--topbar-h)); }
  body.call-active .main {
    max-width: none;
    padding: .75rem clamp(1rem, 2vw, 1.25rem);
    overflow: hidden;
  }
  body.call-active .call-wrap {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr clamp(18rem, 26vw, 24rem);
    grid-template-rows: auto 1fr auto;
    gap: .5rem 1rem;
    overflow: hidden;
  }
  body.call-active .call-wrap > .btn.ghost { grid-column: 1 / -1; grid-row: 1; }
  body.call-active .call-stage {
    grid-column: 1; grid-row: 2;
    margin-top: 0; min-height: 0; height: 100%;
  }
  body.call-active .call-controls { grid-column: 1; grid-row: 3; }
  body.call-active .call-chatside {
    grid-column: 2; grid-row: 2 / span 2;
    display: flex; flex-direction: column; min-height: 0;
  }
  body.call-active .call-chatside h3 { flex: 0 0 auto; }
  body.call-active .call-chat { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
  body.call-active .call-chat .chat-scroll { flex: 1 1 auto; max-height: none; min-height: 0; }
  body.call-active .call-mainpane,
  body.call-active .call-remote,
  body.call-active .call-whiteboard,
  body.call-active .call-tools {
    height: 100%;
  }
  body.call-active .call-remote { min-height: 0; aspect-ratio: auto; }
  body.call-active .call-whiteboard,
  body.call-active .call-tools { overflow: auto; }
}

/* ---- whiteboard (requirements/videocall.md) ---- */
.call-whiteboard {
  background: var(--surface); border-radius: var(--radius);
  border: thin solid var(--border);
  box-shadow: var(--shadow); padding: .5rem;
}
.wb-toolbar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: .62rem;
  padding: .5rem;
  border: thin solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-2));
  scrollbar-gutter: stable;
}
.wb-control-group {
  display: flex;
  align-items: center;
  gap: .38rem;
  min-width: 0;
  padding: .25rem;
  border: thin solid color-mix(in srgb, var(--border) 58%, transparent);
  border-radius: var(--radius-s);
  background: var(--surface);
}
.wb-tool-group {
  flex-wrap: wrap;
}
.wb-toolbar .iconbtn.sm {
  width: 2.38rem;
  height: 2.38rem;
  border-radius: var(--radius-s);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
  color: var(--text-dim);
}
.wb-toolbar .iconbtn.sm:hover {
  background: var(--surface-2);
  color: var(--text);
}
.wb-toolbar .iconbtn.sm.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  color: var(--accent-on-soft);
}
.wb-toolbar .iconbtn.sm .ui-icon {
  width: 1.18rem;
  height: 1.18rem;
}
.wb-color-control {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.38rem;
  height: 2.38rem;
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
}
.wb-color-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.wb-color-swatch {
  width: 1.25rem;
  height: 1.25rem;
  border: .12rem solid color-mix(in srgb, var(--surface) 80%, #000);
  border-radius: .38rem;
  box-shadow: inset 0 0 0 .06rem color-mix(in srgb, #000 16%, transparent);
}
.wb-size-control {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 9.25rem;
  height: 2.38rem;
  padding: 0 .56rem;
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text-dim);
}
.wb-size-control .ui-icon {
  width: .94rem;
  height: .94rem;
}
.wb-toolbar .wb-size {
  width: clamp(4.5rem, 18vw, 5.12rem);
  accent-color: var(--accent);
}
@media (max-width: 38.75rem) {
  .wb-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: .38rem;
    padding: .38rem;
    scroll-padding-inline: .38rem;
  }
  .wb-control-group {
    flex: 0 0 auto;
  }
  .wb-toolbar .iconbtn.sm,
  .wb-color-control {
    width: 2.25rem;
    height: 2.25rem;
  }
  .wb-size-control {
    min-width: 8.25rem;
    height: 2.25rem;
  }
}
.wb-wrap { position: relative; }
.wb-canvas {
  display: block; width: 100%; border-radius: var(--radius-s);
  background: #fff; touch-action: none; cursor: crosshair;
  border: thin solid var(--border);
}
.wb-textinput {
  position: absolute; z-index: 20; width: min(12.5rem, calc(100% - 1rem));
  font: .88rem sans-serif; padding: .38rem;
  border: .12rem solid var(--accent); border-radius: .5rem;
}

/* ---- calendar: monthly + weekly view (requirements/navigation.md,
 * videocall.md, calendar-view.md) ---- */
.calendar {
  --cal-gap: .5rem;
  --cal-pad-xs: .18rem;
  --cal-pad-sm: .38rem;
  --cal-pad-md: .62rem;
  --cal-gutter-size: clamp(2.45rem, 8vw, 2.9rem);
  --cal-work-gutter-size: clamp(2.15rem, 7vw, 2.55rem);
  --cal-hour-size: clamp(2.65rem, 7svh, 3rem);
  --cal-event-min-height: 1.55rem;
  margin: .38rem 0 .75rem;
}
.calendar .seg.sm {
  padding: var(--cal-pad-xs);
  border-radius: .62rem;
  box-shadow: none;
  max-width: 100%;
  overflow: hidden;
}
.calendar .seg.sm button {
  flex: none;
  padding: var(--cal-pad-sm) clamp(.45rem, 1.8vw, .62rem);
  font-size: .78rem;
  min-height: 2rem;
  white-space: nowrap;
}
.calendar > .row {
  gap: var(--cal-gap);
  align-items: center;
}
.cal-title {
  text-align: center;
  font-weight: 800;
  line-height: 1.2;
}
.therapist-next-patients {
  margin: .12rem 0 .75rem;
  padding: clamp(.55rem, 2vw, .75rem);
  border: thin solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
}
.therapist-next-patients-head {
  margin-bottom: .5rem;
  color: var(--text);
  font-size: .9rem;
}
.therapist-next-patient-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: .5rem;
}
.therapist-next-patient {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
  min-width: 0;
}
.therapist-next-dot {
  inline-size: .44rem;
  block-size: .44rem;
  border-radius: 50%;
  background: var(--accent);
}
.therapist-next-name {
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.therapist-next-time {
  margin-top: .06rem;
  color: var(--text-muted);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem;
  margin-top: .5rem;
}
.cal-dow {
  text-align: center; font-size: .7rem; font-weight: 700;
  color: var(--text-dim); padding: .12rem 0;
}
.cal-day {
  position: relative; border: none; background: var(--surface-2);
  border-radius: .62rem;
  padding: .38rem .18rem;
  cursor: pointer;
  color: var(--text); font-weight: 600; font-size: .85rem;
  display: flex; flex-direction: column; align-items: stretch; gap: .12rem;
  min-height: clamp(3.35rem, 15vw, 3.9rem); text-align: left;
  border: thin solid transparent;
}
.cal-day:hover { border-color: color-mix(in srgb, var(--accent) 36%, transparent); }
.cal-day.today { outline: .12rem solid var(--accent); outline-offset: .06rem; }
.cal-day.has-events { background: var(--accent-soft); }
.cal-dot {
  align-self: center;
  min-width: .5rem; height: .5rem; border-radius: .31rem;
  background: var(--accent); color: var(--accent-ink);
  font-size: .55rem; line-height: .5rem; padding: 0 .12rem;
}
/* schedules/timeslots visible right in the month cell, so seeing them all
 * is as easy as possible (bugs/0002) */
.cal-evt {
  font: inherit; font-size: .62rem; font-weight: 650; color: var(--text-dim);
  background: var(--surface); border: none; border-radius: .25rem;
  padding: .06rem .18rem; width: 100%; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: .12rem solid var(--cal-event-tone, var(--accent));
}
.cal-evt.is-training { --cal-event-tone: var(--info); }
.cal-evt.is-past { --cal-event-tone: var(--text-muted); opacity: .72; }
.cal-evt.is-pending { --cal-event-tone: var(--warn); }
.cal-evt.is-answered { --cal-event-tone: var(--accent); }
.cal-evt.is-rejected { --cal-event-tone: var(--danger); }
.cal-evt.is-slot {
  --cal-event-tone: var(--accent);
  background: color-mix(in srgb, var(--surface) 74%, var(--accent-soft));
}
.cal-evt.more { color: var(--accent-on-soft); text-align: center; cursor: default; }

/* work-week time grid (requirements/calendar-view.md) */
.cal-week {
  margin-top: .5rem;
  overflow-x: auto;
  padding-bottom: .12rem;
}
.cal-week.workweek {
  --cal-gutter-size: var(--cal-work-gutter-size);
  --cal-hour-size: clamp(2.8rem, 8svh, 3.2rem);
  overflow-x: hidden;
}
.cal-week-head {
  display: grid;
  grid-template-columns: var(--cal-gutter-size) repeat(7, minmax(0, 1fr));
  gap: 0;
}
.cal-week-head.workweek {
  grid-template-columns: var(--cal-gutter-size) repeat(5, minmax(0, 1fr));
  min-width: 0;
}
.cal-week-day {
  display: flex; flex-direction: column; align-items: center; gap: .06rem;
  border: none; background: none; cursor: pointer; color: var(--text-dim);
  font-size: .7rem; font-weight: 700; padding: .25rem 0 .38rem;
  border-radius: .5rem .5rem 0 0;
}
.cal-week-day .d {
  font-size: .95rem; color: var(--text); line-height: 1.2;
}
.cal-week-day.today .d {
  background: var(--accent); color: var(--accent-ink); border-radius: 50%;
  width: 1.38rem; height: 1.38rem; line-height: 1.38rem;
}
.cal-week-scroll {
  max-height: min(58svh, 32.5rem); overflow-y: auto;
  border: thin solid var(--border); border-radius: var(--radius-s);
  background: var(--surface);
  overscroll-behavior: contain;
  padding: .62rem 0 .38rem;
  box-sizing: border-box;
}
.cal-week-body {
  display: grid;
  grid-template-columns: var(--cal-gutter-size) repeat(7, minmax(0, 1fr));
  gap: 0;
}
.cal-week-body.workweek {
  grid-template-columns: var(--cal-gutter-size) repeat(5, minmax(0, 1fr));
  min-width: 0;
}
.cal-week-gutter { position: relative; }
.cal-hour {
  position: absolute; right: .31rem; transform: translateY(-50%);
  font-size: .58rem; color: var(--text-muted);
  font-weight: 700;
}
.cal-week-col {
  position: relative; border-left: thin solid color-mix(in srgb, var(--border) 56%, transparent);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--surface) 97%, var(--surface-2)),
      var(--surface));
}
.cal-hline {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: thin solid color-mix(in srgb, var(--border) 38%, transparent);
}
.cal-event {
  --cal-event-tone: var(--accent);
  position: absolute; left: .12rem; right: .12rem; z-index: 2;
  display: flex; align-items: center; gap: .31rem;
  overflow: hidden; border: none; cursor: pointer;
  background: color-mix(in srgb, var(--cal-event-tone) 10%, var(--surface));
  border: thin solid color-mix(in srgb, var(--cal-event-tone) 24%, transparent);
  border-left: .18rem solid var(--cal-event-tone);
  border-radius: .44rem; padding: .12rem .31rem; text-align: left;
  box-shadow: none;
}
.cal-event::before {
  content: "";
  flex: 0 0 auto;
  inline-size: .38rem;
  block-size: .38rem;
  border-radius: 50%;
  background: var(--cal-event-tone);
}
.cal-event.is-slot {
  --cal-event-tone: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 34%, var(--surface));
  border-style: dashed;
}
.cal-event.is-training {
  --cal-event-tone: var(--info);
}
.cal-event.is-past {
  --cal-event-tone: var(--text-muted);
  opacity: .72;
}
.cal-event.is-pending {
  --cal-event-tone: var(--warn);
}
.cal-event.is-answered {
  --cal-event-tone: var(--accent);
}
.cal-event.is-rejected {
  --cal-event-tone: var(--danger);
}
.cal-event .tm {
  flex: none;
  font-size: .62rem; font-weight: 800; color: var(--text);
}
.cal-event .lb {
  min-width: 0;
  font-size: .62rem; color: var(--text-dim);
  white-space: nowrap; text-overflow: ellipsis; max-width: 100%;
  overflow: hidden;
}
@media (max-width: 38.75rem) {
  .calendar > .row { flex-wrap: wrap; }
  .calendar > .row .grow {
    flex-basis: 100%;
    order: -1;
    text-align: center;
  }
  .calendar > .row .iconbtn {
    width: 2.25rem;
    height: 2.25rem;
  }
  .calendar .seg.sm {
    flex: 1 1 auto;
    min-width: 0;
  }
  .calendar .seg.sm button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: clamp(.25rem, 1.8vw, .38rem);
    font-size: .68rem;
  }
  .cal-grid { gap: .18rem; }
  .therapist-next-patients {
    padding: .55rem;
  }
  .therapist-next-patient-list {
    grid-template-columns: 1fr;
  }
  .therapist-next-patient {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .therapist-next-patient .pill {
    grid-column: 2;
    justify-self: start;
  }
  .cal-day {
    min-height: clamp(3.1rem, 18vw, 3.45rem);
    padding-inline: .12rem;
    font-size: .8rem;
  }
  .cal-evt { font-size: .58rem; }
  .cal-week-head,
  .cal-week-body {
    min-width: max(100%, 38rem);
  }
  .cal-week.workweek {
    --cal-hour-size: clamp(2.55rem, 7.5svh, 3rem);
    margin-inline: -.12rem;
  }
  .cal-week-head.workweek,
  .cal-week-body.workweek {
    min-width: 0;
    grid-template-columns: var(--cal-gutter-size) repeat(5, minmax(0, 1fr));
  }
  .cal-week-scroll {
    max-height: min(60svh, 31.25rem);
    padding-top: .5rem;
  }
  .cal-week-day {
    padding: .18rem 0 .31rem;
    font-size: .62rem;
  }
  .cal-week-day .d {
    font-size: .86rem;
  }
  .cal-hour {
    right: .18rem;
    font-size: .52rem;
  }
  .cal-event {
    left: .06rem;
    right: .06rem;
    padding: .12rem .18rem;
    border-radius: .38rem;
  }
  .cal-event .tm,
  .cal-event .lb {
    font-size: .56rem;
  }
}

/* ---- small utilities for gradually replacing inline styles in JS views ---- */
.stack { display: flex; flex-direction: column; gap: .75rem; }
.cluster { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}
.hub-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: .88rem;
  align-items: start;
}
.profile-account-grid,
.profile-security-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21.25rem), 1fr));
}
.settings-section-head {
  margin-bottom: .62rem;
}
.settings-section-head h2 {
  margin: 0;
}
.hub-panel {
  background: var(--surface);
  border: thin solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(.94rem, 3vw, 1rem);
}
.full-span { grid-column: 1 / -1; }
.panel-title,
.card-title,
.subsection-head {
  display: flex;
  align-items: flex-start;
  gap: .62rem;
}
.panel-title,
.card-title {
  margin-bottom: .75rem;
}
.panel-title h3,
.card-title h2 {
  margin: 0;
}
.panel-title p {
  margin: .12rem 0 0;
}
.panel-title-icon,
.card-title-icon {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.12rem;
  height: 2.12rem;
  border-radius: .62rem;
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
.panel-title-icon .ui-icon,
.card-title-icon .ui-icon {
  width: 1.12rem;
  height: 1.12rem;
}
.compact-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.compact-row {
  display: flex;
  align-items: center;
  gap: .62rem;
  min-width: 0;
  padding: .62rem;
  border: thin solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 84%, var(--surface-2));
}
.compact-row .grow {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.compact-row .grow > strong,
.compact-row .grow > .dim,
.entity-card .grow > strong,
.entity-card .grow > .dim {
  overflow-wrap: anywhere;
}
.request-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .62rem;
  padding: .75rem;
  border: thin solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 84%, var(--surface-2));
}
.request-main {
  min-width: 0;
  display: grid;
  gap: .18rem;
}
.request-main strong,
.request-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.request-meta {
  color: var(--text-dim);
  font-size: .86rem;
}
.request-card .request-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14.38rem), 1fr));
  gap: .62rem;
}
.entity-card {
  display: flex;
  align-items: center;
  gap: .68rem;
  width: 100%;
  min-height: 4.25rem;
  border: thin solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  padding: .75rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}
.entity-card:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  box-shadow: var(--shadow);
  transform: translateY(-.06rem);
}
.entity-card .grow {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.empty-inline {
  display: flex;
  align-items: center;
  gap: .62rem;
  min-height: 3rem;
}
.subsection-head {
  justify-content: space-between;
  margin-top: 1.12rem;
  margin-bottom: .62rem;
}
.settings-card {
  margin-bottom: 0;
}
.settings-card .card-title {
  align-items: center;
}
.settings-card.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .88rem;
}
.setting-row.align-start {
  align-items: flex-start;
}
.setting-row .select-inline {
  min-width: 9.38rem;
}
.profile-page .stats-card {
  margin-top: 1.5rem;
}
.stats-card {
  margin-top: 1.12rem;
}
.iconbtn.danger-subtle {
  color: var(--text-dim);
}
.iconbtn.danger-subtle:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}
@media (max-width: 38.75rem) {
  .inline-form,
  .subsection-head {
    grid-template-columns: 1fr;
  }
  .inline-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .subsection-head {
    align-items: stretch;
    flex-direction: column;
  }
  .compact-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .request-card {
    grid-template-columns: 1fr;
  }
  .request-card .request-actions {
    grid-column: 1;
  }
  .compact-row .inline-actions {
    flex-basis: 100%;
    justify-content: flex-start;
    padding-left: clamp(2.5rem, 12vw, 2.88rem);
  }
  .setting-row {
    align-items: stretch;
    flex-direction: column;
  }
  .setting-row .btn,
  .setting-row .select-inline {
    width: 100%;
  }
  .profile-page .settings-grid,
  .therapist-page .hub-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- calm profile layout ---- */
.profile-page .page-head,
.recordings-page .page-head {
  padding-bottom: .88rem;
  border-bottom: thin solid color-mix(in srgb, var(--border) 72%, transparent);
}
.profile-page .section {
  margin-top: 1.38rem;
}
.profile-page .settings-section-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0 0 .75rem;
}
.profile-page .settings-section-head::after {
  content: "";
  flex: 1;
  height: .0625rem;
  background: color-mix(in srgb, var(--border) 68%, transparent);
}
.profile-page .settings-section-head h2 {
  color: var(--text-dim);
  font-size: .92rem;
  font-weight: 800;
}
.profile-page .settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18.75rem), 1fr));
  gap: .75rem;
  align-items: stretch;
}
.profile-page .profile-account-grid,
.profile-page .profile-security-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}
.profile-page .settings-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  height: 100%;
  margin-bottom: 0;
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}
.profile-page .settings-card .card-title {
  align-items: center;
  margin-bottom: 0;
  padding-bottom: .62rem;
  border-bottom: thin solid color-mix(in srgb, var(--border) 64%, transparent);
}
.profile-page .settings-card .card-title h2 {
  font-size: 1rem;
  line-height: 1.2;
}
.profile-page .settings-card .card-title-icon {
  width: 1.88rem;
  height: 1.88rem;
  border-radius: .5rem;
  background: var(--surface-2);
  color: var(--accent);
}
.profile-page .settings-card .card-title-icon .ui-icon {
  width: 1rem;
  height: 1rem;
}
.profile-page .settings-card label.field {
  margin-bottom: 0;
}
.profile-page .settings-card p {
  margin-top: 0;
}
.profile-page .settings-card p:last-child {
  margin-bottom: 0;
}
.profile-page .setting-row {
  min-height: var(--tap-size);
  padding-top: .12rem;
}
.profile-page .setting-row .grow {
  min-width: 0;
}
.profile-page .setting-row .select-inline {
  min-width: 8.5rem;
}
.profile-page .settings-card > .btn,
.profile-page .settings-card > .btn.sm,
.profile-page .setting-row .btn.sm {
  align-self: flex-start;
}
.profile-page .settings-card h3 {
  margin: .38rem 0 0;
  padding-top: .75rem;
  border-top: thin solid color-mix(in srgb, var(--border) 58%, transparent);
  font-size: .98rem;
}
.profile-page .stats-card {
  box-shadow: var(--shadow-soft);
}
.profile-page .stats-card .card-title {
  margin-bottom: .88rem;
  padding-bottom: .62rem;
  border-bottom: thin solid color-mix(in srgb, var(--border) 64%, transparent);
}
.profile-page .stats-card table.metrics {
  border-collapse: separate;
  border-spacing: 0;
}
.profile-page .stats-card table.metrics td {
  padding: .56rem 0;
}
.profile-page .stats-card canvas {
  margin-top: .75rem;
}

/* ---- calm recordings layout ---- */
.recordings-page .list-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.recordings-page .list-card .list-item {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .88rem;
}
.recordings-page .list-card .list-item > .item-icon {
  width: 2.38rem;
  height: 2.38rem;
  border-radius: .62rem;
  background: var(--surface-2);
}
.recordings-page .list-card .list-item > .grow {
  min-width: 0;
}
.recordings-page .list-primary {
  line-height: 1.25;
}
.recordings-page .list-meta {
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.recordings-page .inline-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: .38rem;
}
.recordings-page .list-card .inline-actions .iconbtn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .62rem;
}
.recording-metrics-sheet table.metrics {
  border-collapse: separate;
  border-spacing: 0;
}
.recording-metrics-sheet table.metrics td {
  padding-block: .5rem;
  vertical-align: top;
}
@media (max-width: 38.75rem) {
  .profile-page .page-head,
  .recordings-page .page-head {
    padding-bottom: .75rem;
  }
  .profile-page .section {
    margin-top: 1.25rem;
  }
  .profile-page .settings-grid,
  .profile-page .profile-account-grid,
  .profile-page .profile-security-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: .62rem;
  }
  .profile-page .settings-card {
    padding: .88rem;
    gap: .62rem;
  }
  .profile-page .settings-card .card-title {
    padding-bottom: .56rem;
  }
  .profile-page .setting-row {
    gap: .62rem;
  }
  .profile-page .settings-card > .btn,
  .profile-page .settings-card > .btn.sm,
  .profile-page .setting-row .btn,
  .profile-page .setting-row .btn.sm,
  .profile-page .setting-row .select-inline {
    align-self: stretch;
    width: 100%;
  }
  .profile-page .stats-card table.metrics tr,
  .recording-metrics-sheet table.metrics tr {
    display: grid;
    gap: .12rem;
    padding: .5rem 0;
    border-bottom: thin solid var(--surface-2);
  }
  .profile-page .stats-card table.metrics td,
  .recording-metrics-sheet table.metrics td {
    padding: 0;
    border-bottom: 0;
  }
  .profile-page .stats-card table.metrics td:last-child,
  .recording-metrics-sheet table.metrics td:last-child {
    text-align: left;
  }
  .recordings-page .list-card .list-item {
    grid-template-columns: 2.38rem minmax(0, 1fr);
    align-items: start;
    gap: .62rem;
    padding: .8rem .75rem;
  }
  .recordings-page .inline-actions {
    grid-column: 2;
    flex-basis: auto;
    justify-content: flex-start;
    padding-left: 0;
  }
  .recordings-page .list-card .inline-actions .iconbtn {
    width: 2.38rem;
    height: 2.38rem;
  }
}
.item-title { font-weight: 700; }
.item-icon {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--accent);
  background: var(--surface-2);
  border-radius: .62rem;
  line-height: 1;
}
.item-icon .ui-icon { width: 1.18rem; height: 1.18rem; }
.item-chevron { flex: 0 0 auto; color: var(--text-muted); font-size: 1.35rem; }
.prewrap { white-space: pre-wrap; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: .88rem; }
