:root {
  --rail: #17324A;          /* road-sign blue */
  --rail-ink: #E3EBF2;
  --rail-muted: #93A9BB;
  --rail-hover: rgba(255, 255, 255, 0.07);
  --page: #EEF1F3;
  --surface: #FFFFFF;
  --ink: #1A2128;
  --muted: #5D6A75;
  --line: #DCE2E7;
  --amber: #F2A900;         /* indicator light: unread + active + send */
  --amber-ink: #1A2128;
  --online: #2FA36B;
  --danger: #B3261E;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rail: #0D2131; --page: #0E1318; --surface: #151B21; --ink: #E4EAEF;
    --muted: #93A0AC; --line: #27313A; --danger: #F2B8B5; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --rail: #0D2131; --page: #0E1318; --surface: #151B21; --ink: #E4EAEF;
  --muted: #93A0AC; --line: #27313A; --danger: #F2B8B5; color-scheme: dark;
}
html { font-size: 16px; }
html[data-size="small"] { font-size: 14px; }
html[data-size="large"] { font-size: 18px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 1rem/1.5 var(--font); color: var(--ink); background: var(--page); }
[hidden] { display: none !important; }
@media (max-width: 900px), (pointer: coarse) { .desktop-admin-link { display: none !important; } }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.primary {
  background: var(--amber); color: var(--amber-ink); border: 0;
  border-radius: 8px; padding: 0.55rem 1.1rem; font-weight: 700;
}
.primary:hover { filter: brightness(1.05); }
.quiet { background: none; border: 0; padding: 0.35rem 0.5rem; border-radius: 6px; color: var(--muted); }
.quiet:hover { color: var(--ink); }
.error { color: var(--danger); min-height: 1.5em; margin: 0.25rem 0; font-size: 0.9rem; }

label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.85rem; }
input:not([type=checkbox]), select, textarea {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}

/* ---------- login ---------- */
.login {
  --surface: #fff; --ink: #2e2a3c; --muted: #737373; --line: #b3b3b3;
  --amber: #1783cf; --danger: #b3261e;
  color-scheme: light; color: var(--ink);
  font-family: Roboto, Arial, sans-serif;
  min-height: 100dvh; display: grid; grid-template-columns: minmax(220px, 320px) 1fr;
  background: #f5f5f6;
}
.login-brand-panel { background: #2e2a3c; color: #fff; padding: 34px 30px; }
.login-logos { display: flex; align-items: center; gap: 18px; }
.ams-logo { color: #f2b705; font-size: 30px; font-weight: 700; line-height: 1; }
.login-logo-divider { width: 1px; height: 38px; background: #ffffff40; flex: none; }
.login-logo { display: block; width: 110px; height: auto; max-width: 44%; }
.login-product { margin: 24px 0 8px; font-size: 18px; font-weight: 700; }
.login-brand-sub { margin: 0; font-size: 13px; line-height: 1.65; color: #e6e6e6; }
.login-form-panel { display: grid; place-items: center; padding: 28px; }
.login-card {
  width: min(100%, 420px); display: grid; gap: 6px;
}
.login-card .brand { margin: 0; font-size: 25px; color: var(--ink); line-height: 1.2; }
.login-card .sub { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.login-card label { margin: 0; font-size: 12px; font-weight: 700; color: var(--ink); }
.login-card input:not([type=checkbox]) { margin: 0 0 7px; padding: 11px 12px; border-radius: 6px; font-size: 16px; }
.login-card .primary { width: 100%; padding: 11px 14px; border-radius: 6px; background: #2e2a3c; color: #fff; }
.login-card .primary:hover { background: #3a3549; filter: none; }
.login-card input:focus { outline: 2px solid #3badf7; outline-offset: 1px; }
.login-password-wrap { position: relative; }
.login-password-wrap input:not([type=checkbox]) { padding-right: 74px; margin-bottom: 0; }
.login-reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #156ca7; font-size: 12px; padding: 6px 8px; }
.login-help { font-size: 12px; color: #666; margin: 12px 0 0; line-height: 1.5; }
.login-password-guide { margin-top: 4px; padding: 10px 12px; background: #ececef; border-radius: 6px; font-size: 12px; color: #666; }
.login-password-guide p { margin: 0 0 5px; font-weight: 700; color: #2e2a3c; }
.login-password-guide ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.people-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.people-summary p, .people-empty { color: var(--muted); font-size: .9rem; }
.people-list { margin: 12px 0 0; padding: 0; list-style: none; }
.people-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.people-details { display: grid; gap: 3px; min-width: 0; }
.people-email { overflow-wrap: anywhere; font-size: .9rem; }
.people-meta { color: var(--muted); font-size: .8rem; }
@media (max-width: 680px) {
  .login { display: block; }
  .login-brand-panel { padding: 20px 24px; }
  .login-product { margin-top: 14px; }
  .login-form-panel { align-items: start; padding: 44px 24px; }
}

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }
.scrim { display: none; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; min-height: 0; }
.rail-head { padding: 1.1rem 1.25rem 0.5rem; }
.rail .brand { font-weight: 700; font-size: 1.2rem; letter-spacing: 0.01em; }
.nav { flex: 1; overflow-y: auto; padding: 0.5rem 0.6rem 1rem; }
.rail-foot { display: flex; align-items: center; gap: 0.25rem; padding: 0.75rem 0.9rem; border-top: 1px solid rgba(255,255,255,0.08); }
.rail-foot { flex-wrap: wrap; }
.rail-foot .me { flex: 1 1 100%; display: flex; align-items: center; gap: 0.5rem; background: none; border: 0; color: var(--rail-ink);
  font-weight: 700; text-align: left; padding: 0.3rem 0.4rem; border-radius: 6px; min-width: 0; }
.rail-foot .me:hover { background: var(--rail-hover); }
#me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .quiet { color: var(--rail-muted); }
.rail .quiet:hover { color: var(--rail-ink); background: var(--rail-hover); }

.group { margin-top: 1rem; }
.group-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0.6rem 0.2rem; color: var(--rail-muted); font-size: 0.85rem; }
.group-head .add { background: none; border: 0; color: var(--rail-muted); font-size: 1.15rem; line-height: 1; padding: 0.1rem 0.4rem; border-radius: 6px; }
.group-head .add:hover { color: var(--rail-ink); background: var(--rail-hover); }
.group ul { list-style: none; margin: 0; padding: 0; }
.vehicle-group-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: .35rem .6rem; border: 0; border-radius: 6px; background: none; color: var(--rail-muted); font-size: .85rem; text-align: left; }
.vehicle-group-toggle:hover { color: var(--rail-ink); background: var(--rail-hover); }
.vehicle-group-toggle:focus-visible { outline: 2px solid var(--rail-ink); outline-offset: 2px; }
.hint { color: var(--rail-muted); font-size: 0.9rem; padding: 0.5rem 0.6rem; }

.item {
  position: relative; width: 100%; display: flex; align-items: center; gap: 0.5rem;
  background: none; border: 0; color: var(--rail-muted); text-align: left;
  padding: 0.4rem 0.6rem; border-radius: 6px;
}
.item:hover { background: var(--rail-hover); color: var(--rail-ink); }
.item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .hash { width: 0.75rem; text-align: center; opacity: 0.7; }
.item.unread { color: var(--rail-ink); font-weight: 700; }
.item.active { background: var(--rail-hover); color: var(--rail-ink); }
.item.active::before {
  content: ""; position: absolute; left: -0.6rem; top: 0.35rem; bottom: 0.35rem;
  width: 4px; border-radius: 0 3px 3px 0; background: var(--amber);
}
.badge { background: var(--amber); color: var(--amber-ink); font-weight: 700; font-size: 0.75rem; border-radius: 999px; padding: 0 0.45rem; line-height: 1.4rem; min-width: 1.4rem; text-align: center; }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; border: 2px solid var(--rail-muted); flex: none; margin: 0 0.075rem; }
.dot.on { background: var(--online); border-color: var(--online); }

/* ---------- conversation pane ---------- */
.pane { position: relative; display: grid; grid-template-rows: auto auto 1fr auto auto; min-height: 0; background: var(--surface); }
.pane-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0; font-size: 1.1rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { color: var(--muted); font-size: 0.85rem; }
.menu { display: none; background: none; border: 0; font-size: 1.3rem; padding: 0.1rem 0.4rem; color: var(--ink); }

.messages { overflow-y: auto; padding: 0.5rem 1.5rem 1rem; }
.empty { color: var(--muted); margin-top: 2rem; text-align: center; }
.older { display: block; margin: 0.75rem auto; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.9rem; color: var(--muted); font-size: 0.9rem; }
.day { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; margin: 1.25rem 0 0.25rem; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { margin-top: 0.85rem; max-width: 72ch; }
.msg.cont { margin-top: 0.15rem; }
.msg header { display: flex; align-items: baseline; gap: 0.5rem; }
.msg time { color: var(--muted); font-size: 0.8rem; }
.msg p { margin: 0; overflow-wrap: anywhere; }
.msg a { color: inherit; text-decoration-color: var(--amber); text-underline-offset: 2px; }
.msg.mine strong { color: var(--muted); }

.typing { min-height: 1.5rem; padding: 0 1.5rem; color: var(--muted); font-size: 0.85rem; }
.composer { display: flex; gap: 0.6rem; align-items: flex-end; padding: 0 1.5rem 1.1rem; }
.composer textarea { margin: 0; resize: none; max-height: 160px; line-height: 1.45; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 12px; padding: 1.4rem 1.5rem 1.2rem; width: min(440px, 92vw); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(8, 18, 28, 0.55); }
dialog h3 { margin: 0 0 1rem; font-size: 1.15rem; }
dialog menu { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 0.5rem 0 0; padding: 0; }
.checks { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.6rem; margin-bottom: 0.85rem; }
.checks label, label.inline { display: flex; gap: 0.5rem; align-items: center; color: var(--ink); margin: 0.3rem 0; font-size: 1rem; }
.choices { display: grid; gap: 0.5rem; }
.choices button { text-align: left; background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem; }
.choices button:hover { border-color: var(--amber); }
.choices small { display: block; color: var(--muted); }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 84vw); z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  .rail.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8, 18, 28, 0.45); z-index: 10; }
  .rail.open + .scrim { display: block; }
  .menu { display: inline-block; }
  .pane-head, .messages, .composer, .typing { padding-left: 1rem; padding-right: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

/* ---------- presence statuses ---------- */
.dot.s-available { background: var(--online); border-color: var(--online); }
.dot.s-busy { background: #E0663A; border-color: #E0663A; }
.dot.s-away { background: #E3B341; border-color: #E3B341; }
.dot.s-dnd { background: #D93A3A; border-color: #D93A3A; }
.item .live svg { width: 1rem; height: 1rem; fill: none; stroke: var(--amber); stroke-width: 2; vertical-align: -0.15rem; }

/* ---------- icons ---------- */
.ctl svg, .call-btn svg, .ctl-mini svg, .tag svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- header call button + call bar ---------- */
.call-btn { display: inline-flex; align-items: center; gap: 0.45rem; background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 0.35rem 0.85rem; color: var(--ink); font-weight: 700; }
.call-btn:hover { border-color: var(--amber); }
.call-btn.live { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.callbar { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 1.5rem; background: var(--page);
  border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.callbar .cb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--amber); flex: none;
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--amber) 30%, transparent); }
.primary.small { padding: 0.3rem 0.8rem; font-size: 0.9rem; }

/* ---------- call stage ---------- */
.stage { position: absolute; inset: 0; z-index: 5; display: grid; grid-template-rows: auto 1fr auto;
  background: #0B1620; color: #E8EEF3; }
.stage-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 1.25rem; }
.stage-head h3 { margin: 0; font-size: 1.05rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-time { color: #9FB2C2; font-variant-numeric: tabular-nums; }
.ctl-mini { display: inline-flex; align-items: center; gap: 0.4rem; background: rgba(255,255,255,0.08); border: 0;
  color: #E8EEF3; border-radius: 8px; padding: 0.35rem 0.7rem; }
.ctl-mini:hover { background: rgba(255,255,255,0.15); }

.tiles { display: grid; gap: 0.6rem; padding: 0 1rem; min-height: 0; overflow: auto; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.tiles[data-count="1"] { grid-template-columns: minmax(0, 960px); justify-content: center; }
.tiles[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles[data-state="connecting"]::before { content: "Getting your camera and microphone ready…"; color: #9FB2C2; text-align: center; }
.tile { position: relative; aspect-ratio: 16 / 9; background: #162736; border-radius: 10px; overflow: hidden;
  outline: 3px solid transparent; outline-offset: -3px; transition: outline-color 0.15s; }
.tile.speaking { outline-color: var(--amber); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tile.has-video video { display: block; }
.tile.screen video { object-fit: contain; }
.stage.call-focused { position: fixed; inset: 0; z-index: 20; }
.tiles[data-layout="focused"] {
  display: block; position: relative; padding: 0; margin: 0 1rem;
  overflow: hidden; min-width: 0;
}
.tiles[data-layout="focused"] .tile:not([data-id="local"]) {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto;
}
.tiles[data-layout="focused"] .tile:not([data-id="local"]) video { object-fit: contain; }
.tiles[data-layout="focused"] .tile[data-id="local"] {
  position: absolute; right: 1rem; bottom: 1rem; z-index: 2;
  width: clamp(120px, 22vw, 280px); max-width: 38%;
  border: 2px solid rgba(255,255,255,.45); box-shadow: 0 6px 24px #0008;
}
.tiles[data-layout="focused"] .tile[data-id="local"] .avatar {
  width: clamp(2rem, 6vw, 4rem); height: clamp(2rem, 6vw, 4rem); font-size: 1.2rem;
}
.tiles[data-layout="focused"] .tile[data-id="local"] .tag { font-size: .75rem; }
.tile.mirror video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; margin: auto; width: 5rem; height: 5rem; border-radius: 50%;
  display: grid; place-items: center; background: #24435C; color: #E8EEF3; font-weight: 700; font-size: 1.6rem; }
.tile.has-video .avatar { display: none; }
.tag { position: absolute; left: 0.5rem; bottom: 0.5rem; display: flex; align-items: center; gap: 0.35rem; max-width: calc(100% - 1rem);
  background: rgba(8, 16, 24, 0.7); color: #fff; border-radius: 6px; padding: 0.15rem 0.5rem; font-size: 0.85rem; }
.tag .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag .st { color: #F2C14E; }
.tag .st:empty { display: none; }
.tag svg { width: 1rem; height: 1rem; stroke: #FF8A80; }

.controls { display: flex; justify-content: center; gap: 0.6rem; padding: 0.9rem 1rem 1.1rem; flex-wrap: wrap; }
.ctl { display: inline-flex; flex-direction: column; align-items: center; gap: 0.25rem; min-width: 5.5rem;
  background: rgba(255,255,255,0.08); border: 0; color: #E8EEF3; border-radius: 12px; padding: 0.6rem 0.75rem; font-size: 0.8rem; }
.ctl:hover { background: rgba(255,255,255,0.16); }
.ctl.off { background: #E8EEF3; color: #0B1620; }
.ctl.active { background: var(--amber); color: var(--amber-ink); }
.ctl.leave { background: #C62828; color: #fff; }
.ctl.leave:hover { background: #B71C1C; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: grid; gap: 0.5rem; width: min(360px, calc(100vw - 2rem)); }
.toast { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--amber);
  border-radius: 10px; padding: 0.8rem 0.9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.toast p { margin: 0; }
.toast-actions { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: 0.6rem; }

/* ---------- settings ---------- */
.settings-dlg { width: min(760px, 96vw); padding: 0; }
.settings-wrap { display: grid; grid-template-columns: 200px 1fr; min-height: min(560px, 80vh); }
.settings-tabs { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 0.6rem; background: var(--page); border-right: 1px solid var(--line); }
.settings-tabs button { text-align: left; background: none; border: 0; border-radius: 8px; padding: 0.5rem 0.75rem; color: var(--muted); }
.settings-tabs button:hover { color: var(--ink); }
.settings-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--amber); }
.settings-body { padding: 1.25rem 1.5rem; overflow-y: auto; max-height: 80vh; }
.settings-body h3 { margin: 0 0 1rem; }
.settings-body h4 { margin: 1.4rem 0 0.5rem; font-size: 1rem; }
.settings-foot { display: flex; justify-content: flex-end; padding: 0.75rem 1rem; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 0.6rem; align-items: flex-end; }
.inline-form label { flex: 1; margin: 0; }
.muted-line, .help { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0; }
.note { min-height: 1.5em; color: var(--online); }
.note.bad { color: var(--danger); }
.warn { background: color-mix(in srgb, var(--amber) 18%, var(--surface)); border-left: 4px solid var(--amber);
  padding: 0.6rem 0.8rem; border-radius: 6px; margin: 0 0 1rem; }
.check { display: flex !important; gap: 0.6rem; align-items: flex-start; color: var(--ink) !important; margin: 0.55rem 0 !important; font-size: 1rem !important; }
.check input { margin-top: 0.3rem; accent-color: var(--amber); }
.check small { display: block; color: var(--muted); font-size: 0.85rem; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 0.2rem; gap: 0.2rem; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0.35rem 0.8rem; border-radius: 7px; color: var(--ink); cursor: pointer; }
.seg input:checked + span { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; }
.av-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.meter { height: 0.5rem; background: var(--page); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: -0.4rem 0 0.9rem; }
.meter span { display: block; height: 100%; width: 0; background: var(--online); transition: width 0.08s linear; }
.preview-box { position: relative; aspect-ratio: 16 / 9; background: #162736; border-radius: 8px; overflow: hidden; margin-bottom: 0.85rem; }
.preview { width: 100%; height: 100%; object-fit: cover; display: none; }
.preview.mirror { transform: scaleX(-1); }
.preview-box.has-video .preview { display: block; }
.preview-box.has-video .preview-empty { display: none; }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #9FB2C2; font-size: 0.9rem; }
.range input { padding: 0; accent-color: var(--amber); }
.range output { color: var(--ink); font-weight: 700; margin-left: 0.25rem; }
.secondary { background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.9rem; color: var(--ink); margin-bottom: 0.9rem; }
.secondary:hover { border-color: var(--amber); }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-decoration-color: var(--amber); }

@media (max-width: 760px) {
  .settings-wrap { grid-template-columns: 1fr; }
  .settings-tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-tabs button { white-space: nowrap; }
  .av-grid { grid-template-columns: 1fr; }
  .tiles[data-count="2"] { grid-template-columns: 1fr; }
  .tiles[data-layout="focused"] { margin: 0 .5rem; }
  .tiles[data-layout="focused"] .tile[data-id="local"] { right: .5rem; bottom: .5rem; max-width: 36%; }
  .ctl { min-width: 4.2rem; }
  .ctl span { font-size: 0.72rem; }
  .callbar { padding: 0.5rem 1rem; }
  .call-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tile, .meter span { transition: none; } }


/* Home-only date calendar; conversation layouts remain unchanged. */
.home-link { background: none; border: 0; padding: 0; color: inherit; text-align: left; }
.home-calendar { max-width: 520px; margin: 1.5rem auto; padding: 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.calendar-heading, .calendar-navigation { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; }
.calendar-heading h3, .calendar-month { margin: 0; font-size: 1rem; font-weight: 700; }
.home-calendar button { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.home-calendar button:hover { background: var(--page); }
.calendar-today { padding: 0 0.75rem; font-size: 0.9rem; }
.calendar-prev, .calendar-next { font-size: 1.5rem; }
.home-calendar table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: center; }
.home-calendar th { color: var(--muted); font-size: 0.8rem; font-weight: 400; padding-bottom: 0.5rem; }
.home-calendar td { height: 44px; padding: 4px 0; }
.home-calendar td span { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; margin: auto; }
.home-calendar td:nth-child(n+6) { color: var(--muted); }
.home-calendar [aria-current="date"] { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.calendar-note { color: var(--muted); font-size: 0.8rem; margin: 0.75rem 0 0; }
.calendar-caption { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 380px) { .home-calendar { padding: 0.75rem; } }


.home-calendar .calendar-day { min-width: 0; min-height: 40px; width: 100%; max-width: 40px; padding: 0; border: 0; border-radius: 50%; position: relative; }
.home-calendar .calendar-day[aria-pressed="true"] { outline: 2px solid var(--amber); outline-offset: 1px; }
.calendar-day.has-bookings::after { content: ''; position: absolute; bottom: 3px; left: calc(50% - 2px); width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.booking-form { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; }
.booking-form h4, .booking-date { margin: 0.75rem 0; }
.booking-form .calendar-note { margin-bottom: 1rem; }
.booking-times { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0.75rem; }
.booking-times input { min-width: 0; }
.booking-item { border-bottom: 1px solid var(--line); padding: 0.75rem 0; overflow-wrap: anywhere; }
.booking-item p { margin: 0.25rem 0; white-space: pre-wrap; }
.booking-item button { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
.calendar-status { color: var(--muted); font-size: 0.85rem; }


/* Present selected tabs/windows at a readable size, with participants beneath. */
.present-hint { flex-basis: 100%; text-align: center; margin: 0 0 0.25rem; color: #C2CDD6; font-size: 0.85rem; }
.tiles[data-layout="presentation"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); align-content: start; padding-bottom: 0.5rem; }
.tiles[data-layout="presentation"] .tile.presenting { grid-column: 1 / -1; order: -1; width: 100%; height: min(62vh, 900px); aspect-ratio: auto; }
.tiles[data-layout="presentation"] .tile.presenting video { object-fit: contain; }
.tiles[data-layout="presentation"] .tile:not(.presenting) { max-width: 200px; }
.ctl:disabled { opacity: 0.65; cursor: wait; }


.storage-link { margin: 0 0.75rem 0.5rem; padding: 0.7rem; border: 1px solid var(--rail-muted); border-radius: 8px; background: transparent; color: var(--rail-ink); text-align: left; }
.storage-link.active, .storage-link:hover { background: var(--rail-hover); }
.recording-notice { flex-basis: 100%; text-align: center; margin: 0; font-size: 0.85rem; color: #f5d37e; }
.recording-notice.recording-warning { color: #ffb4ab; }
.recording-storage { max-width: 900px; margin: 1rem auto; }
.recording-row { padding: 1rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.recording-row h4 { margin: 0 0 0.3rem; }
.recording-row p { margin: 0.3rem 0; }
.recording-row video { display: block; width: 100%; max-height: 65vh; margin-top: 0.75rem; background: #000; }
.recordings-status { color: var(--muted); }


/* ---------- incoming call card ---------- */
.ringcard { border-left-color: var(--online); padding: 0.9rem 1rem; animation: ring-in 0.25s ease-out; }
.ring-top { display: flex; align-items: center; gap: 0.75rem; }
.ring-top strong { display: block; font-size: 1.05rem; }
.ring-top small { color: var(--muted); }
.ring-avatar { width: 2.75rem; height: 2.75rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #24435C; color: #fff; font-weight: 700; animation: ring-pulse 1.4s ease-out infinite; }
.ring-hint { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }
.ringcard .toast-actions { margin-top: 0.8rem; }
.ringcard .toast-actions button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 0; border-radius: 8px; padding: 0.55rem; font-weight: 700; }
.ringcard .decline { background: #C62828; color: #fff; }
.ringcard .accept { background: var(--online); color: #fff; }
.ringcard .accept svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 163, 107, 0.6); } 100% { box-shadow: 0 0 0 0.9rem rgba(47, 163, 107, 0); } }
@keyframes ring-in { from { transform: translateY(0.75rem); opacity: 0; } }

/* ---------- caller waiting banner ---------- */

.stage-wait { position: absolute; top: 3.75rem; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 0.75rem; background: rgba(255, 255, 255, 0.1); color: #E8EEF3;
  padding: 0.5rem 0.6rem 0.5rem 1rem; border-radius: 999px; white-space: nowrap; max-width: calc(100% - 2rem); }
.stage-wait span:not(.pulse) { overflow: hidden; text-overflow: ellipsis; }
.stage-wait .pulse { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--online); flex: none;
  animation: ring-pulse 1.4s ease-out infinite; }
.stage-wait:has(.pulse) { padding-right: 1rem; }
@media (prefers-reduced-motion: reduce) { .ring-avatar, .stage-wait .pulse, .ringcard { animation: none; } }

/* ---------- message send states ---------- */
.msg.pending p { opacity: 0.6; }
.msg.failed p { color: var(--danger); }
.send-state { display: block; font-size: 0.8rem; color: var(--muted); }
.msg.failed .send-state { color: var(--danger); }

/* ---------- connection stats ---------- */
.stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; margin: 1rem 0 1.25rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; display: flex; align-items: center; gap: 0.4rem; }
.stats .dot { border-color: var(--muted); }
.rtt.good { color: var(--online); } .rtt.fair { color: #B7791F; } .rtt.slow { color: var(--danger); }

/* Keep answered calls and their controls within the phone viewport. */
.stage.call-focused, .stage:fullscreen {
  position: fixed; inset: 0; width: 100%; height: 100dvh; box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.stage:fullscreen { background: #0B1620; }
@media (max-width: 760px) {
  .stage-head { flex-wrap: wrap; padding: .5rem; gap: .5rem; }
  .stage-head h3 { min-width: 0; }
  .stage .controls { gap: .35rem; padding: .5rem; }
  .stage .ctl { min-width: 0; flex: 1; padding: .5rem .25rem; }
  .stage .present-hint { font-size: .75rem; }
}
