:root {
  color-scheme: dark;
  --bg: #12161c;
  --bg-2: #181e26;
  --card: #222a34;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3f8;
  --muted: #93a0ae;
  --copper: #e8a87c;
  --green: #7dcea0;
  --danger: #e07a7a;
  --input: #0f141a;
  --bubble-out: #2a3d34;
  --on-ok: #102018;
  --on-accent: #12161c;
  --on-danger: #2a1010;
  --rail: rgba(15, 18, 22, 0.72);
  --overlay: rgba(8, 10, 14, 0.72);
  --glow-a: rgba(232, 168, 124, 0.12);
  --glow-b: rgba(125, 206, 160, 0.08);
  --mark-glow: rgba(232, 168, 124, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

[data-theme="midnight"] {
  color-scheme: dark;
}

[data-theme="slate"] {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-2: #12171e;
  --card: #1a222c;
  --line: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #8b9cb0;
  --copper: #8ea2ff;
  --green: #5eead4;
  --danger: #f87171;
  --input: #080b10;
  --bubble-out: #1b2c38;
  --on-ok: #04201c;
  --on-accent: #0b1020;
  --on-danger: #2a1010;
  --rail: rgba(8, 11, 16, 0.82);
  --overlay: rgba(4, 6, 10, 0.76);
  --glow-a: rgba(142, 162, 255, 0.14);
  --glow-b: rgba(94, 234, 212, 0.08);
  --mark-glow: rgba(142, 162, 255, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

[data-theme="nord"] {
  color-scheme: dark;
  --bg: #2e3440;
  --bg-2: #3b4252;
  --card: #434c5e;
  --line: rgba(236, 239, 244, 0.1);
  --text: #eceff4;
  --muted: #d8dee9;
  --copper: #88c0d0;
  --green: #a3be8c;
  --danger: #bf616a;
  --input: #2e3440;
  --bubble-out: #4c566a;
  --on-ok: #1c2418;
  --on-accent: #1d2a30;
  --on-danger: #2a1014;
  --rail: rgba(46, 52, 64, 0.88);
  --overlay: rgba(24, 28, 36, 0.72);
  --glow-a: rgba(136, 192, 208, 0.16);
  --glow-b: rgba(163, 190, 140, 0.1);
  --mark-glow: rgba(136, 192, 208, 0.16);
  --shadow: 0 24px 60px rgba(24, 28, 36, 0.4);
}

[data-theme="ember"] {
  color-scheme: dark;
  --bg: #140e0c;
  --bg-2: #1c1410;
  --card: #2a1d16;
  --line: rgba(240, 160, 90, 0.14);
  --text: #f6efe8;
  --muted: #b9a89a;
  --copper: #f0a05a;
  --green: #d4b46a;
  --danger: #e07060;
  --input: #100b09;
  --bubble-out: #3a2618;
  --on-ok: #24180a;
  --on-accent: #1a1008;
  --on-danger: #2a1010;
  --rail: rgba(16, 10, 8, 0.86);
  --overlay: rgba(10, 6, 4, 0.76);
  --glow-a: rgba(240, 160, 90, 0.16);
  --glow-b: rgba(212, 180, 106, 0.08);
  --mark-glow: rgba(240, 160, 90, 0.16);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="matcha"] {
  color-scheme: dark;
  --bg: #0f1612;
  --bg-2: #162019;
  --card: #1e2a22;
  --line: rgba(197, 214, 122, 0.14);
  --text: #e8f0e9;
  --muted: #8fa396;
  --copper: #c5d67a;
  --green: #7dcea0;
  --danger: #e07a7a;
  --input: #0c120e;
  --bubble-out: #24352a;
  --on-ok: #102018;
  --on-accent: #14180c;
  --on-danger: #2a1010;
  --rail: rgba(10, 16, 12, 0.86);
  --overlay: rgba(6, 10, 8, 0.76);
  --glow-a: rgba(197, 214, 122, 0.14);
  --glow-b: rgba(125, 206, 160, 0.1);
  --mark-glow: rgba(197, 214, 122, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

[data-theme="daylight"] {
  color-scheme: light;
  --bg: #f3efe6;
  --bg-2: #fffdf8;
  --card: #efe6d8;
  --line: rgba(48, 40, 32, 0.1);
  --text: #1c1915;
  --muted: #6b6358;
  --copper: #c4783a;
  --green: #3d8f6a;
  --danger: #c45c5c;
  --input: #ffffff;
  --bubble-out: #d7eee3;
  --on-ok: #f4fff8;
  --on-accent: #fff8f0;
  --on-danger: #fff5f5;
  --rail: rgba(255, 253, 248, 0.88);
  --overlay: rgba(40, 32, 24, 0.46);
  --glow-a: rgba(196, 120, 58, 0.14);
  --glow-b: rgba(61, 143, 106, 0.1);
  --mark-glow: rgba(196, 120, 58, 0.16);
  --shadow: 0 24px 50px rgba(48, 40, 32, 0.12);
}

* { box-sizing: border-box; }
* {
  scrollbar-width: none;
}
*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--glow-a), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, var(--glow-b), transparent 45%),
    var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
.hidden { display: none !important; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--shadow);
}
.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--copper);
  margin: 0 0 8px;
}
h1 { font-size: 48px; margin: 0 0 12px; letter-spacing: -0.04em; }
.lede { color: var(--muted); line-height: 1.5; }
label { display: grid; gap: 8px; margin: 18px 0; color: var(--muted); font-size: 14px; }
input, select, textarea {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
button[type="submit"], .call-btn {
  background: var(--green);
  color: var(--on-ok);
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
}
.login-card button[type="submit"] { width: 100%; }
.error { color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; }
.hint a, a.field-link {
  color: var(--copper);
  text-underline-offset: 2px;
}
.field-link {
  font-size: 12px;
  color: var(--copper);
  margin-top: -4px;
}

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}
.rail {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 148px;
}
.mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 6px var(--mark-glow);
}
.rail nav { display: grid; gap: 6px; }
.nav-group { display: grid; gap: 4px; }
.nav-children {
  display: grid;
  gap: 4px;
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.nav-children button { padding: 8px 12px; font-size: 13px; }
.nav-group.current > [data-view="phone"] { color: var(--text); }
.rail nav button, .ghost, .text-btn {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
}
.rail nav button.active, .rail nav button:hover {
  background: var(--card);
  color: var(--text);
}
.rail-foot { margin-top: auto; display: grid; gap: 8px; }
.nav-icon { display: none; }
.status-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  margin-right: 8px;
}
.status-dot.ready::before { background: var(--green); }
.status-dot.busy::before { background: var(--copper); }

main {
  padding: 28px 32px 24px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 28px;
  flex-shrink: 0;
}
.top h2 { margin: 0; font-size: 32px; letter-spacing: -0.03em; }
.dnd {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.dialer {
  grid-column: 2;
  width: 100%;
  max-width: 360px;
  justify-self: center;
  margin: 12px 0 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}
.dial-display {
  min-height: 48px;
  font-size: 28px;
  text-align: center;
  letter-spacing: 0.04em;
  margin: 0 0 18px;
}
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pad button {
  height: 64px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
}
.pad button small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}
.pad.compact button { height: 48px; }
.dial-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.view { flex: 1; min-height: 0; overflow: auto; }
.calls-panel { min-height: 0; }
#view-phone.view {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#panel-phone {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  column-gap: 20px;
  align-items: start;
  padding: 0 8px 12px;
}
#panel-recents, #panel-contacts {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#panel-recents .pane-head,
#panel-recents > .hint,
#panel-contacts .pane-head,
#panel-contacts .inline-form,
#panel-contacts #import-status {
  flex-shrink: 0;
}
#call-list, #contact-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#view-messages.view {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split {
  display: grid;
  grid-template-columns: 220px minmax(640px, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  min-width: 872px;
}
.shell:has(#view-messages:not(.hidden)) main {
  padding: 14px 16px 10px;
}
.shell:has(#view-messages:not(.hidden)) .top {
  margin-bottom: 10px;
  align-items: center;
}
.shell:has(#view-messages:not(.hidden)) .top h2 {
  font-size: 22px;
}
.list-pane, .detail-pane, .cards article, .list button, .settings {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.list-pane, .detail-pane {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.detail-pane { min-height: 0; }
.pane-head, .inline-form {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
}
.list-pane .pane-head {
  padding: 10px 12px 8px;
  flex-shrink: 0;
}
.list-pane .pane-head h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.list { display: grid; }
.list button, .cards article {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.list button:hover, .list button.active { background: var(--card); }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 48px 24px; text-align: center; }

.search { max-width: 240px; }
.inline-form input { flex: 1; min-width: 0; }

.list .contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.list .contact-row:hover { background: var(--card); }
.list .contact-main {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 0;
  text-align: left;
}
.list .contact-main strong { display: block; }
.list .contact-main .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list .contact-actions button {
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
}
.list .contact-actions .star {
  border-color: transparent;
  background: transparent;
  font-size: 18px;
  padding: 4px 8px;
  color: var(--muted);
}
.list .contact-actions .star.on { color: var(--copper); }
.list .contact-actions .del {
  color: var(--danger);
  border-color: rgba(224, 122, 122, 0.4);
}
.contact-main strong.missed, #call-list article strong.missed { color: var(--danger); }
#call-list article strong { cursor: pointer; }
.call-transcript-block {
  margin-top: 12px;
  background: var(--input);
  border: 1px solid var(--line);
  border-left: 3px solid var(--copper);
  border-radius: 14px;
  overflow: hidden;
}
.call-transcript-label {
  margin: 0;
  padding: 10px 14px 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper);
  font-weight: 700;
}
.call-transcript-body {
  margin: 0;
  padding: 0 14px 14px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.call-transcript-body p {
  margin: 0 0 12px;
}
.call-transcript-body p:last-child { margin-bottom: 0; }
.call-transcript-speaker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.call-transcript-speaker.out { color: var(--green); }
.call-transcript-speaker.in { color: var(--copper); }

/* Nav badges */
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--copper);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}

/* Messaging: threads, compose, bubbles */
.thread-search {
  max-width: none;
  margin: 0 12px 10px;
  flex-shrink: 0;
  padding: 9px 12px;
  font-size: 13px;
}
.compose-row { display: flex; gap: 8px; padding: 0 12px 10px; flex-shrink: 0; }
.compose-row input { flex: 1; min-width: 0; }
.thread-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.thread-actions button { white-space: nowrap; }
.composer-meta { padding: 2px 12px 6px; margin: 0; font-size: 11px; }

#thread-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px 12px;
}
#thread-list .empty { padding: 32px 12px; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 84px;
  height: auto;
  flex: 0 0 auto;
  text-align: left;
  position: relative;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  color: inherit;
  overflow: hidden;
  line-height: 1.25;
  appearance: none;
}
.thread-item:hover {
  background: var(--card);
  border-color: var(--line);
}
.thread-item.active {
  background: var(--card);
  border-color: color-mix(in srgb, var(--copper) 40%, var(--line));
  box-shadow: inset 3px 0 0 var(--copper);
}
.thread-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--copper) 16%, var(--card));
  color: var(--copper);
  font-size: 13px;
  font-weight: 700;
}
.thread-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 20px 16px 18px;
  gap: 2px;
  align-content: center;
}
.thread-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-time {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}
.thread-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 18px;
  min-width: 0;
}
.thread-unread {
  flex-shrink: 0;
  width: 18px;
  background: var(--green);
  color: var(--on-ok);
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 0 5px;
}
.thread-unread.is-empty {
  visibility: hidden;
}
.bubble-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble.out .bubble-meta { text-align: right; }
.reactions { margin-top: 4px; font-size: 14px; }

.pane-actions { display: flex; gap: 6px; }
.group-row { flex-wrap: wrap; }
.group-row input { flex: 1 1 140px; }
.notify-pref { width: min(640px, 100%); margin-bottom: 12px; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 16px;
  line-height: 1;
}

/* Message rows with a reaction affordance */
.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  position: relative;
  width: 100%;
}
.bubble-row.out { justify-content: flex-end; }
.bubble-row .bubble { max-width: 75%; }
.react-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  opacity: 0.35;
  transition: opacity 0.1s ease;
  padding: 0 4px;
  flex-shrink: 0;
  align-self: center;
}
.bubble-row:hover .react-btn,
.bubble-row:focus-within .react-btn { opacity: 1; }
.reaction-menu {
  position: fixed;
  z-index: 40;
  display: flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.reaction-menu button {
  border: 0;
  background: transparent;
  font-size: 18px;
  padding: 2px 4px;
}

/* Emoji picker + scheduling */
.emoji-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
}
.emoji-palette button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  font-size: 18px;
  padding: 4px 8px;
}
.schedule-row { display: flex; gap: 8px; padding: 0 12px 8px; align-items: center; }
.schedule-row input { flex: 1; min-width: 0; }
.schedule-row button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}
.scheduled-list { display: grid; gap: 6px; padding: 0 12px; }
.scheduled-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
}
.scheduled-item button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--danger);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.favorites {
  grid-column: 1;
  justify-self: end;
  width: min(220px, 100%);
  max-height: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  margin-top: 12px;
  padding: 0;
}
.favorites .fav-label {
  width: 100%;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 4px 8px;
}
.favorites button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
}
.favorites button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.favorites button .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.favorites button:hover { background: var(--card); }

.thread {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  min-width: 640px;
}
.thread header {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.thread header > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.thread header strong {
  display: block;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#thread-phone {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scheduled-list {
  flex-shrink: 0;
}
.thread-log {
  flex: 1 1 0;
  min-height: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.thread-log,
#thread-list,
#call-list,
#contact-list,
.rail,
.view {
  scrollbar-width: none;
}
.thread-log::-webkit-scrollbar,
#thread-list::-webkit-scrollbar,
#call-list::-webkit-scrollbar,
#contact-list::-webkit-scrollbar,
.rail::-webkit-scrollbar,
.view::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.bubble {
  max-width: 75%;
  min-width: 0;
  overflow: hidden;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--card);
  border-bottom-left-radius: 6px;
}
.bubble.out {
  background: var(--bubble-out);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}
.composer {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  height: 108px;
  min-height: 88px;
  margin: 8px 10px 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--input);
  overflow: hidden;
}
.composer-resize {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  z-index: 5;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
}
.composer-resize::after {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin: 5px auto 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 42%, var(--muted));
}
.composer-resize:hover::after,
.composer-resize:focus-visible::after,
.composer.is-resizing .composer-resize::after {
  background: var(--copper);
}
body.is-resizing-composer {
  cursor: ns-resize;
  user-select: none;
}
.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  max-height: none;
  resize: none;
  border: 0;
  border-radius: 16px;
  background: transparent;
  font-size: 15px;
  line-height: 1.4;
  padding: 16px 14px 40px;
}
.composer-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 6px;
  background: linear-gradient(transparent, var(--input) 28%);
}
.composer-bar .icon-btn {
  border: 0;
  background: transparent;
  padding: 6px 8px;
  opacity: 0.72;
}
.composer-bar .icon-btn:hover,
.composer-bar .icon-btn:focus-visible {
  opacity: 1;
  background: color-mix(in srgb, var(--card) 65%, transparent);
}
.composer-bar .composer-meta {
  margin: 0 8px 0 auto;
  padding: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.composer-bar button[type="submit"] {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 13px;
}
.composer-chip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 44px;
  margin: 0;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.composer .emoji-palette,
.composer .schedule-row {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 44px;
  z-index: 4;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.composer .schedule-row {
  padding: 8px;
}

.cards { display: grid; gap: 12px; }
.cards article { padding: 16px; border-radius: 18px; }
.cards audio { width: 100%; margin-top: 10px; }

.settings { padding: 20px; display: grid; gap: 4px; width: min(640px, 100%); }
.settings fieldset {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 8px 0;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; }

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin: 4px 0 8px;
}
.theme-swatch {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  text-align: left;
  color: inherit;
}
.theme-swatch:hover { border-color: color-mix(in srgb, var(--copper) 50%, var(--line)); }
.theme-swatch.active {
  border-color: var(--copper);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--copper) 30%, transparent);
}
.theme-chip {
  height: 34px;
  border-radius: 10px;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.theme-chip i { flex: 1; display: block; }
.theme-swatch strong { font-size: 13px; }
.theme-swatch .muted { font-size: 12px; line-height: 1.3; }

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  padding: 20px;
}
.call-card {
  width: min(420px, 100%);
  background: var(--bg-2);
  border-radius: 28px;
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.call-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.call-actions button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--card);
}
.danger {
  background: var(--danger);
  color: var(--on-danger);
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
}

.security-note, .security-banner {
  padding: 8px 16px;
  margin: 0;
  font-size: 12px;
}
.thread .security-note {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--line);
}
.security-banner {
  width: min(640px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.call-transcript {
  text-align: left;
  max-height: 160px;
  overflow: auto;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  white-space: pre-wrap;
}
.bubble-media {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.bubble-media img, .bubble-media video {
  max-width: 100%;
  max-height: 220px;
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  background: #000;
}
.bubble-media audio {
  display: block;
  width: 100%;
  min-width: 0;
  height: 54px;
}
.bubble:has(.bubble-media) {
  width: min(360px, 100%);
  max-width: 75%;
}
.import-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.user-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.user-row-copy { min-width: 0; }
.user-row-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-row-copy .muted {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.user-row-actions button {
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
}
.user-row-actions .user-remove {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.secret-wrap, .copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.secret-toggle {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
  white-space: nowrap;
}
.secret-toggle[aria-pressed="true"] { color: var(--text); }
.oidc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--copper) 45%, var(--line));
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  text-align: center;
}
.oidc-btn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 4px var(--mark-glow);
}
.oidc-btn:hover {
  background: var(--card);
  border-color: var(--copper);
  color: var(--text);
}
.avatar, .favicon-preview {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--card);
  border: 1px solid var(--line);
}
.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}

@media (max-width: 1200px) {
  .shell { grid-template-columns: 72px 1fr; }
  .rail {
    padding: 16px 8px;
    align-items: center;
    gap: 12px;
  }
  .brand {
    justify-content: center;
    width: 44px;
  }
  .brand strong,
  .nav-label { display: none; }
  .nav-icon {
    display: block;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .rail nav { justify-items: center; }
  .nav-children {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    justify-items: center;
  }
  .nav-children button { padding: 0; font-size: inherit; }
  .rail nav button,
  .rail .text-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    text-align: center;
    position: relative;
  }
  .rail-foot { justify-items: center; }
  .status-dot {
    width: 44px;
    overflow: hidden;
    color: transparent;
    font-size: 0;
    line-height: 0;
    display: grid;
    place-items: center;
  }
  .status-dot::before { margin-right: 0; }
  .rail .badge {
    position: absolute;
    top: 4px;
    right: 2px;
    margin: 0;
    min-width: 16px;
    padding: 0 4px;
    line-height: 16px;
    font-size: 10px;
  }
  .rail nav button::after,
  .rail .text-btn::after {
    content: attr(aria-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    box-shadow: var(--shadow);
  }
  .rail nav button:hover::after,
  .rail nav button:focus-visible::after,
  .rail .text-btn:hover::after,
  .rail .text-btn:focus-visible::after {
    opacity: 1;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .rail {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 6px;
    gap: 4px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail nav { display: flex; gap: 2px; }
  .nav-group { display: flex; align-items: center; gap: 2px; }
  .nav-children {
    display: flex;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
  .rail nav button,
  .rail .text-btn {
    width: 36px;
    height: 36px;
  }
  .nav-icon { width: 18px; height: 18px; }
  .brand { width: 36px; }
  .status-dot { width: 28px; }
  .rail-foot { margin: 0 0 0 auto; gap: 2px; }
  .rail nav button::after,
  .rail .text-btn::after {
    left: 50%;
    top: calc(100% + 6px);
    transform: translateX(-50%);
  }
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    gap: 8px;
  }
  .list-pane {
    flex: 0 0 auto;
  }
  #thread-list {
    max-height: calc(2 * 84px + 6px);
    flex: 0 0 auto;
  }
  .thread,
  .detail-pane {
    min-width: 0;
    height: auto;
  }
  .thread header {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    padding: 6px 10px;
  }
  .thread-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .thread-actions button {
    padding: 6px 8px;
    font-size: 13px;
  }
  .composer {
    flex: 0 0 auto;
    margin: 6px 8px 8px;
  }
  .composer textarea {
    min-width: 0;
  }
  .row { grid-template-columns: 1fr; }
  main { padding: 8px 10px; }
  .shell:has(#view-messages:not(.hidden)) main { padding: 8px 10px; }
  .shell:has(#view-messages:not(.hidden)) .top {
    margin-bottom: 6px;
  }
  .shell:has(#view-messages:not(.hidden)) .top h2 {
    font-size: 18px;
  }
  .top { margin-bottom: 4px; }
  .top h2 { font-size: 18px; }
  .top .eyebrow { display: none; }
  #panel-phone {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .dialer {
    grid-column: auto;
    width: min(360px, 100%);
  }
  .favorites {
    grid-column: auto;
    justify-self: stretch;
    width: min(360px, 100%);
    max-height: 180px;
    border-bottom: 1px solid var(--line);
    padding: 0 0 12px;
  }
}
