/*
 * Joy Phone — design tokens.
 * Brand: Joy Travel teal #1B95B6 → coral #CC5D3F (from the logo). The accent is the teal, darkened in light
 * mode and lightened in dark mode so text and buttons stay readable.
 */
:root {
  --canvas: #f7f7fa;
  --sidebar: #fbfbfd;
  --surface: #ffffff;
  --raised: #ffffff;
  --ink: #1a1b25;
  --ink-2: #44475a;
  --muted: #6b6e80;
  --line: #e7e7ef;
  --line-strong: #d9d9e4;
  --accent: #11738f;
  --accent-ink: #ffffff;
  --accent-soft: #e4f3f7;
  --brand-teal: #1b95b6;
  --brand-coral: #cc5d3f;
  --brand-gradient: linear-gradient(45deg, #1b95b6 12%, #6f7e85 50%, #cc5d3f 90%);
  --live: #1f9d6b;
  --live-soft: #e5f6ee;
  --danger: #d6455a;
  --danger-soft: #fcebee;
  --warn: #b97c0c;
  --note-bg: #fff7e0;
  --note-line: #f1e1b0;
  --note-ink: #8a5a00;
  --shadow: 0 1px 2px rgba(26, 27, 37, 0.05), 0 4px 16px rgba(26, 27, 37, 0.05);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Dark: follows the phone unless the user picked a theme in Settings. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #121319;
    --sidebar: #15161d;
    --surface: #1a1b23;
    --raised: #20212b;
    --ink: #ececf3;
    --ink-2: #c4c6d4;
    --muted: #9497a8;
    --line: #2a2b36;
    --line-strong: #363846;
    --accent: #4fc0dc;
    --accent-ink: #0f1a1f;
    --accent-soft: #10313a;
    --live: #3fc48c;
    --live-soft: #173326;
    --danger: #f0707f;
    --danger-soft: #3a1d23;
    --warn: #e5b04d;
    --note-bg: #2e2818;
    --note-line: #463b1f;
    --note-ink: #e9c46a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #121319;
  --sidebar: #15161d;
  --surface: #1a1b23;
  --raised: #20212b;
  --ink: #ececf3;
  --ink-2: #c4c6d4;
  --muted: #9497a8;
  --line: #2a2b36;
  --line-strong: #363846;
  --accent: #4fc0dc;
  --accent-ink: #0f1a1f;
  --accent-soft: #10313a;
  --live: #3fc48c;
  --live-soft: #173326;
  --danger: #f0707f;
  --danger-soft: #3a1d23;
  --warn: #e5b04d;
  --note-bg: #2e2818;
  --note-line: #463b1f;
  --note-ink: #e9c46a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* Inter (SIL Open Font License), self-hosted so the app works offline-first and loads fast. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter Tight (SIL Open Font License), medium: the "Joy Phone" name. */
@font-face {
  font-family: "Inter Tight"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/inter-tight-500.woff2") format("woff2");
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none; font-variant-numeric: tabular-nums;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 24px; height: 24px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- shell */
#app { height: 100%; display: flex; flex-direction: column; }
.shell { flex: 1; display: flex; min-height: 0; }
.pane-list {
  width: 100%; display: flex; flex-direction: column; min-height: 0;
  background: var(--sidebar); padding-top: env(safe-area-inset-top);
}
.pane-main { flex: 1; display: none; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.shell.show-main .pane-list { display: none; }
.shell.show-main .pane-main { display: flex; padding-top: env(safe-area-inset-top); }
@media (min-width: 920px) {
  .pane-list { width: 360px; flex: none; border-right: 1px solid var(--line); }
  .pane-main { display: flex; }
  .shell.show-main .pane-list { display: flex; }
  .shell.show-main .pane-main, .pane-main { padding-top: 0; }
  .only-mobile { display: none !important; }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; letter-spacing: 0;
  background: var(--accent); color: var(--accent-ink); transition: filter 120ms, transform 120ms;
}
.btn:active { transform: scale(0.98); filter: brightness(0.95); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.quiet { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.live { background: var(--live); color: #fff; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.text-btn { color: var(--accent); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; padding: 6px 4px; }

/* ---------------------------------------------------------------- list pane */
.list-head { display: flex; align-items: center; gap: 6px; padding: 14px 16px 6px 20px; }
.brand { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; display: block; }

.brand-name { font-family: "Inter Tight", var(--font); font-size: 20px; font-weight: 500; letter-spacing: -0.4px; }
.line-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.line-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.line-state.ready .dot { background: var(--live); box-shadow: 0 0 0 3px var(--live-soft); }

.search {
  margin: 8px 16px 6px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border-radius: var(--r-sm); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted);
}
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--ink); min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 6px 16px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  height: 30px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted);
  white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px;
}
.tab .count { font-size: 12px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; }
.tab[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.notice {
  margin: 4px 16px 10px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  display: flex; align-items: center; gap: 12px; font-size: 14px;
}
.notice .grow { flex: 1; min-width: 0; }
.notice strong { display: block; font-size: 14px; }
.notice .sub { color: var(--muted); }
.notice.ringing { box-shadow: inset 0 0 0 1.5px var(--live); background: var(--live-soft); }
.notice.ringing .pulse {
  width: 36px; height: 36px; border-radius: 50%; background: var(--live); color: #fff; display: grid; place-items: center; flex: none;
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 45%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }

.list { flex: 1; overflow-y: auto; padding: 2px 8px 8px; -webkit-overflow-scrolling: touch; }
.conv {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); text-align: left;
}
.conv:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.conv[aria-current="true"] { background: var(--accent-soft); }
.conv .body { flex: 1; min-width: 0; }
.conv .top { display: flex; align-items: baseline; gap: 8px; }
.conv .name { flex: 1; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: 12px; color: var(--muted); }
.conv .last { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; }
.conv .last.bad { color: var(--danger); }
.conv .last.live { color: var(--live); font-weight: 600; }
.conv .ellipsis { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.conv.is-unread .name, .conv .name.unread { font-weight: 700; }
.conv.is-unread .last { color: var(--ink); }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.unread-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.assignee { font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--line); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.avatar.chat-av { background: var(--brand-gradient) !important; color: #fff !important; }
.list-divider { height: 1px; background: var(--line); margin: 6px 12px; }
.live-dot { background: var(--live-soft); color: var(--live); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.conv .preview { display: block; font-size: 13px; color: var(--ink-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--line); color: var(--ink-2); }
.empty { text-align: center; color: var(--muted); padding: 56px 24px; font-size: 14px; }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.list-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* avatars: soft color picked from the number */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 14px; letter-spacing: 0.2px;
  background: var(--av-bg, var(--accent-soft)); color: var(--av-ink, var(--accent));
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.xl { width: 88px; height: 88px; font-size: 26px; }
.av-0 { --av-bg: #e6edfb; --av-ink: #3b5bb5; }
.av-1 { --av-bg: #e4f4ee; --av-ink: #1e7f5a; }
.av-2 { --av-bg: #fbeae4; --av-ink: #b0502c; }
.av-3 { --av-bg: #f1e8fb; --av-ink: #7a45b8; }
.av-4 { --av-bg: #fbf2dc; --av-ink: #96690a; }
.av-5 { --av-bg: #e3f2f6; --av-ink: #1f7389; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar { background: color-mix(in srgb, var(--av-ink) 26%, var(--surface)); color: color-mix(in srgb, var(--av-ink) 40%, #fff); }
}
:root[data-theme="dark"] .avatar { background: color-mix(in srgb, var(--av-ink) 26%, var(--surface)); color: color-mix(in srgb, var(--av-ink) 40%, #fff); }

/* ---------------------------------------------------------------- thread */
.thread-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 68px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.thread-head .who { flex: 1; min-width: 0; }
.thread-head .title { font-weight: 700; font-size: 16px; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .number { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
.thread-head .number button { color: var(--accent); font-weight: 600; font-size: 13px; white-space: nowrap; }
@media (max-width: 919px) {
  .thread-head { gap: 8px; padding: 10px 12px 10px 4px; }
  .thread-head .avatar.lg { width: 40px; height: 40px; font-size: 14px; }
}
.head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn.on { color: var(--live); background: var(--live-soft); }
.icon-btn.sm { width: 30px; height: 30px; }
.assigned-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--line); padding: 1px 8px 1px 6px; border-radius: 999px; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; padding: 6px;
  background: var(--raised); border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, 0.18);
}
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--accent-soft); }
.menu button svg:last-child:not(:first-child) { margin-left: auto; color: var(--accent); }
.menu-label { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px 4px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.done-bar { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 8px 12px; font-size: 13px; color: var(--live); background: var(--live-soft); }
@media (max-width: 919px) { .hide-narrow { display: none; } .thread-head .btn.live.sm { width: 34px; padding: 0; } }
.name-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.name-edit input { height: 34px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--canvas); padding: 0 10px; font-size: 16px; flex: 1 1 140px; min-width: 0; }

.timeline { flex: 1; overflow-y: auto; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.timeline-inner { width: 100%; max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.day { align-self: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

/* The call stub: a ticket with a perforated edge (Joy Phone's signature element). */
.ticket { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.ticket-main { display: flex; align-items: stretch; }
.ticket-info { flex: 1; padding: 14px 16px; display: flex; gap: 12px; align-items: center; min-width: 0; }
.ticket-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.ticket-icon.missed { background: var(--danger-soft); color: var(--danger); }
.ticket-icon.live { background: var(--live-soft); color: var(--live); }
.ticket-title { font-weight: 600; font-size: 14px; }
.ticket-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.ticket-stub {
  position: relative; width: 92px; flex: none; padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  border-left: 2px dashed var(--line-strong);
}
.ticket-stub::before, .ticket-stub::after {
  content: ""; position: absolute; left: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--canvas);
}
.ticket-stub::before { top: -8px; }
.ticket-stub::after { bottom: -8px; }
.ticket-stub .big { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.ticket-stub .small { font-size: 12px; color: var(--muted); }
.ticket-body { border-top: 1px solid var(--line); padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; }

.summary { border-radius: var(--r-md); background: var(--accent-soft); padding: 12px 14px; }
.summary-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.summary ul { margin: 0; padding-left: 18px; }
.summary li { margin: 2px 0; line-height: 1.45; font-size: 14px; }
.summary .next { margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); font-size: 14px; color: var(--ink); }
.summary .next-label { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.pending { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.player { display: flex; align-items: center; gap: 12px; }
.play {
  width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--surface);
  display: grid; place-items: center; flex: none;
}
.play svg { fill: currentColor; stroke: none; }
.track { flex: 1; height: 6px; border-radius: 999px; background: var(--line); position: relative; overflow: hidden; cursor: pointer; }
.track > span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: inherit; }
.player .clock { font-size: 13px; color: var(--muted); min-width: 76px; text-align: right; }
details.transcript summary { list-style: none; cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
details.transcript summary::-webkit-details-marker { display: none; }
details.transcript[open] summary svg { transform: rotate(90deg); }
details.transcript p { margin: 8px 0 0; color: var(--ink-2); line-height: 1.55; font-size: 14px; white-space: pre-wrap; max-width: 64ch; }

/* notes: chat bubbles */
.bubble-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.bubble-row.mine { align-items: flex-end; }
.bubble-meta { font-size: 12px; color: var(--muted); padding: 0 6px; }
.bubble {
  max-width: min(85%, 520px); padding: 10px 14px; border-radius: 18px; border-bottom-left-radius: 6px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); white-space: pre-wrap; line-height: 1.45; font-size: 14px;
}
.mine .bubble { background: var(--accent); color: var(--accent-ink); box-shadow: none; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.mention { font-weight: 600; }
.bubble-meta.bad { color: var(--danger); }
.bubble-meta.time { font-size: 11px; }
.bubble .mms { display: block; max-width: 220px; border-radius: 12px; margin-top: 6px; }
.bubble-line { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.mine .bubble-line { flex-direction: row-reverse; }
.bubble-line .bubble { max-width: min(80vw, 520px); }
.chat-row .reply-btn { opacity: 0; transition: opacity 120ms; }
.chat-row:hover .reply-btn, .chat-row:focus-within .reply-btn { opacity: 1; }
@media (hover: none) { .chat-row .reply-btn { opacity: 0.7; } .chat-row .reply-btn span { display: none; } }

/* internal comments: sticky-note style, so they never look like a text to the customer */
.note-row { display: flex; gap: 10px; align-items: flex-start; }
.note { flex: 1; min-width: 0; max-width: 560px; background: var(--note-bg); box-shadow: inset 0 0 0 1px var(--note-line); border-radius: 14px; padding: 10px 14px 12px; }
.note-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--note-ink); }
.note-meta strong { color: var(--ink); font-size: 13px; }
.note-meta .reply-btn { margin-left: auto; }
.note-body { margin-top: 4px; white-space: pre-wrap; line-height: 1.45; font-size: 14px; }
.reply-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 4px 6px; border-radius: 8px; }
.reply-btn:hover { color: var(--accent); background: var(--accent-soft); }
.quote {
  display: block; width: 100%; text-align: left; margin: 6px 0 2px; padding: 6px 10px; border-radius: 10px;
  border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--ink) 6%, transparent); font-size: 13px;
}
.mine .bubble .quote { border-left-color: var(--accent-ink); background: color-mix(in srgb, var(--accent-ink) 16%, transparent); }
.quote-name { display: block; font-weight: 700; font-size: 12px; }
.quote-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; opacity: 0.85; }
.flash .bubble, .flash .note { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: none; } }

.composer {
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer-inner { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; position: relative; }
.composer-box { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.composer.is-note textarea { background: var(--note-bg); box-shadow: inset 0 0 0 1px var(--note-line); }
.compose-tabs { display: flex; gap: 4px; }
.compose-tabs button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.compose-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.compose-tabs button.is-note[aria-selected="true"] { background: var(--note-bg); color: var(--note-ink); box-shadow: inset 0 0 0 1px var(--note-line); }
.replying { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--muted); }
.replying .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.replying strong { color: var(--ink); font-size: 12.5px; }
.replying-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.mention-suggest:empty { display: none; }
.mention-suggest button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 13px; font-weight: 600; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; max-height: 140px; min-height: 40px;
  padding: 10px 14px; border-radius: 20px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line); font-size: 15px; line-height: 1.35;
}
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send:disabled { opacity: 0.4; }
.send.note-send { background: var(--note-ink); color: var(--surface); }

.placeholder-main { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.placeholder-main .brand-mark { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; }

/* ---------------------------------------------------------------- dialer & call */
.sheet { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 16px 24px calc(24px + env(safe-area-inset-bottom)); }
.sheet-top { width: 100%; max-width: 420px; display: flex; align-items: center; }
.display {
  width: 100%; max-width: 420px; text-align: center; border: 0; background: none; outline: none;
  font-size: 28px; font-weight: 400; letter-spacing: 0.5px; padding: 28px 8px 4px;
}
.display::placeholder { font-size: 22px; color: var(--muted); letter-spacing: 0; }
.hint { font-size: 13px; color: var(--muted); text-align: center; max-width: 320px; margin: 4px 0 18px; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; justify-content: center; }
.key {
  width: 76px; height: 76px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 26px; font-weight: 400;
}
.key small { font-size: 9.5px; letter-spacing: 1.6px; color: var(--muted); font-weight: 600; margin-top: -2px; }
.key:active { background: var(--accent-soft); }
.dial-actions { display: flex; align-items: center; gap: 26px; margin-top: 22px; }
.call-fab { width: 72px; height: 72px; border-radius: 50%; background: var(--live); color: #fff; display: grid; place-items: center; }
.call-fab.end { background: var(--danger); }
.call-fab svg { width: 30px; height: 30px; }

.call-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(48px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 60% at 50% 0%, var(--accent-soft), var(--canvas) 70%);
}
.call-screen .who { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-top: 16px; }
.call-screen .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.call-screen .state { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.call-screen .state.live { color: var(--live); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.controls { display: grid; grid-template-columns: repeat(3, 84px); gap: 18px 22px; margin-top: auto; margin-bottom: 32px; justify-content: center; }
.transfer-sheet { margin-top: auto; margin-bottom: 24px; width: 100%; max-width: 360px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.sheet-title { font-weight: 700; padding: 6px 8px 8px; }
.transfer-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-md); font-weight: 600; }
.transfer-row:hover { background: var(--accent-soft); }
.transfer-row .grow { flex: 1; }
.ctrl { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.ctrl .disc { width: 60px; height: 60px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; color: var(--ink); }
.ctrl[aria-pressed="true"] .disc { background: var(--ink); color: var(--surface); box-shadow: none; }
.ctrl:disabled { opacity: 0.4; }
.call-actions { display: flex; gap: 40px; justify-content: center; }
.callbar {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--live); color: #fff; font-weight: 600; font-size: 14px;
}

/* ---------------------------------------------------------------- settings & login */
.page { flex: 1; overflow-y: auto; padding: 8px 16px 32px; }
.page-inner { max-width: 560px; margin: 0 auto; }
.group-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 6px 8px; }
.group { background: var(--surface); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.item { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
.item + .item { border-top: 1px solid var(--line); }
.item .grow { flex: 1 1 200px; min-width: 0; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item.link { width: 100%; text-align: left; flex-wrap: nowrap; }
.item.link:hover { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.item-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.item.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.item.stack .segmented { align-self: flex-start; }
.muted { color: var(--muted); font-weight: 400; }
.role-badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink-2); }
.role-badge.admin { background: var(--accent-soft); color: var(--accent); }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.text-btn.danger { color: var(--danger); }
.group.form { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1.4fr 120px; gap: 8px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.group.form .btn { align-self: flex-start; }
.group.form p { margin: 0; }
.invite-ready { margin-top: 12px; box-shadow: inset 0 0 0 1.5px var(--accent); }
.field.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; margin-top: 8px; height: 40px; }
select.field { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; height: 44px; }
.field.area { height: auto; padding: 10px 14px; line-height: 1.45; resize: vertical; min-height: 64px; }
.mini-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.track-sw { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 150ms; }
.track-sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 150ms; }
.switch input:checked + .track-sw { background: var(--live); }
.switch input:checked + .track-sw::after { transform: translateX(18px); }
.switch input:focus-visible + .track-sw { box-shadow: var(--focus); }
.menu-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-top: 1px solid var(--line); }
.opt-key { display: flex; flex-direction: column; gap: 6px; flex: none; }
.key-select { width: 70px; font-weight: 700; font-size: 17px; }
.opt-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.audio-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.audio-row audio { height: 36px; max-width: 100%; }
.file-btn { cursor: pointer; position: relative; }
.hear { margin-top: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--accent-soft); }
.hear-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.hear-text { font-size: 14px; line-height: 1.5; }
.save-bar { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.save-bar .btn { max-width: 560px; margin: 0 auto; display: flex; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line); }
.segmented button { height: 30px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.login { flex: 1; display: grid; place-items: center; padding: 24px; background: radial-gradient(70% 45% at 15% 0%, color-mix(in srgb, var(--brand-teal) 16%, transparent), transparent 70%), radial-gradient(70% 45% at 90% 5%, color-mix(in srgb, var(--brand-coral) 13%, transparent), transparent 70%), var(--canvas); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 24px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card .login-logo { display: block; width: 88px; height: 88px; margin: 0 auto 18px; box-shadow: 0 6px 18px rgba(17, 115, 143, 0.25); border-radius: 20px; }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -0.5px; }
.login-card h1.center { text-align: center; margin-bottom: 12px; font-family: "Inter Tight", var(--font); font-weight: 500; font-size: 30px; letter-spacing: -0.6px; }
.login-card p { margin: 4px 0 22px; color: var(--muted); }
.login-card .logo { max-height: 40px; max-width: 160px; margin-bottom: 16px; display: block; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin: 12px 2px 6px; }
.field {
  width: 100%; height: 48px; border-radius: var(--r-sm); border: 0; padding: 0 14px; font-size: 15px;
  background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line-strong); outline: none;
}
.field:focus { box-shadow: inset 0 0 0 1.5px var(--accent), var(--focus); }
.error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 1em; }
.login-card .btn { margin-top: 18px; height: 48px; }
.login-card .forgot { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--canvas); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; max-width: 90vw; z-index: 20; box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- incoming call: frosted glass popup */
.glass-overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--canvas) 30%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
  animation: fade-in 180ms ease-out;
}
.glass-card {
  position: relative; width: min(360px, 100%); padding: 22px 22px 26px; border-radius: 30px; text-align: center; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand-teal) 22%, transparent), color-mix(in srgb, var(--brand-coral) 16%, transparent)),
              color-mix(in srgb, var(--surface) 62%, transparent);
  -webkit-backdrop-filter: blur(28px) saturate(170%); backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid color-mix(in srgb, #fff 45%, transparent);
  box-shadow: 0 24px 60px rgba(10, 20, 30, 0.28), inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent);
  animation: pop-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
:root[data-theme="dark"] .glass-card { border-color: rgba(255, 255, 255, 0.14); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .glass-card { border-color: rgba(255, 255, 255, 0.14); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12); } }
.glass-top { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.glass-top .brand-mark { width: 22px; height: 22px; border-radius: 6px; }
.glass-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.glass-avatar { position: relative; width: 104px; height: 104px; margin: 22px auto 14px; display: grid; place-items: center; }
.glass-avatar .avatar.xl { width: 96px; height: 96px; font-size: 30px; box-shadow: 0 0 0 4px color-mix(in srgb, #fff 55%, transparent); }
.glass-avatar.ringing::before, .glass-avatar.ringing::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--live) 70%, transparent);
  animation: ring-out 2s ease-out infinite;
}
.glass-avatar.ringing::after { animation-delay: 1s; }
.glass-name { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.glass-sub { font-size: 14px; color: var(--ink-2); margin-top: 2px; min-height: 1.2em; }
.glass-context {
  margin: 14px auto 0; max-width: 300px; padding: 10px 12px; border-radius: 14px; font-size: 13px; line-height: 1.4; color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 55%, transparent); border: 1px solid color-mix(in srgb, #fff 30%, transparent);
  display: flex; flex-direction: column; gap: 4px; text-align: left;
}
.glass-context div { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.glass-actions { display: flex; justify-content: center; gap: 56px; margin-top: 24px; }
.glass-actions .ctrl { color: var(--ink); font-weight: 600; }
.call-fab.answer { animation: answer-bounce 1.6s ease-in-out infinite; box-shadow: 0 8px 24px color-mix(in srgb, var(--live) 45%, transparent); }
.call-fab.end { box-shadow: 0 8px 24px color-mix(in srgb, var(--danger) 35%, transparent); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(16px) scale(0.94); } }
@keyframes ring-out { 0% { transform: scale(0.95); opacity: 0.9; } 100% { transform: scale(1.45); opacity: 0; } }
@keyframes answer-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* team: manage panel */
.member-block + .member-block, .member-block + .item, .item + .member-block { border-top: 1px solid var(--line); }
.manage-panel { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.inline-form { display: flex; gap: 8px; }
.inline-form .field { flex: 1; min-width: 0; height: 40px; }
.inline-form .btn { height: 40px; }
.danger-text { color: var(--danger); }

/* version + beta label */
.beta {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; margin-left: 2px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.version { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 12px; color: var(--muted); }
