:root {
  color-scheme: dark;
  --column: 820px;        /* conversation width cap for tablets and laptops */
  --bg: #0e1014;
  --surface: #171a20;
  --surface-2: #20242c;
  --line: #2a2f38;
  --text: #f3f5f7;
  --muted: #8d96a5;
  --accent: #ff9f43;      /* Chime orange: live, start, "for you" */
  --for-you: #ffd84d;
  --size: 26px;           /* conversation text size, user adjustable */
  --gutter: 16px;
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* Keep everything in a readable centered column on wide screens. */
.top, .cast, .views, .feed, .timeline, .dock {
  padding-left: max(var(--gutter), calc((100% - var(--column)) / 2));
  padding-right: max(var(--gutter), calc((100% - var(--column)) / 2));
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

body.live .brand-dot { background: var(--accent); animation: beat 1.6s ease-in-out infinite; }

.status { flex: 1; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.warn { color: var(--accent); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
}

/* ---------- Cast strip: who's at the table ---------- */

.cast {
  display: flex;
  gap: 14px;
  padding-top: 6px;
  padding-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}

.cast::-webkit-scrollbar { display: none; }

.cast-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: none;
  width: 58px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--muted);
}

.cast-item .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-item.unknown .label { color: var(--accent); }

/* ---------- Avatars ---------- */

.avatar {
  --c: var(--muted);
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: var(--c);
  color: #0e1014;
  font-weight: 800;
  font-size: 16px;
}

.avatar.big { width: 56px; height: 56px; font-size: 20px; }

/* Unknown voices get an outlined, numbered avatar so they read as "needs a name". */
.unknown > .avatar, .avatar.unknown {
  background: transparent;
  color: var(--c);
  box-shadow: inset 0 0 0 2.5px var(--c);
}

/* The "someone is talking right now" ring. */
.avatar.speaking::after,
.row.live .avatar::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2.5px solid var(--c);
  animation: ripple 1.2s ease-out infinite;
}

/* ---------- Conversation feed ---------- */

.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 16px;
  padding-bottom: 24px;
  scroll-behavior: smooth;
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 18px;
  animation: rise 220ms ease-out;
}

.row.cont { margin-top: 6px; }
.row.cont > .avatar { visibility: hidden; height: 0; }
.row.cont .name { display: none; }

.body { display: flex; flex-direction: column; min-width: 0; max-width: min(84%, 720px); }

.name {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 5px 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--c);
  font-size: 15px;
  font-weight: 700;
}

.who-tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 13px;
}

.bubble {
  padding: 0.45em 0.7em;
  border-radius: var(--radius);
  border-bottom-left-radius: 8px;
  background: var(--surface-2);
  font-size: var(--size);
  line-height: 1.3;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.row.cont .bubble { border-top-left-radius: 8px; }

/* The phone owner's words: right side, tinted with their color, like your own texts. */
.row.me { flex-direction: row-reverse; }
.row.me .body { align-items: flex-end; }
.row.me .name { display: none; } /* your own words don't need a label */
.row.me .bubble {
  background: color-mix(in srgb, var(--c) 30%, var(--surface-2));
  border-radius: var(--radius);
  border-bottom-right-radius: 8px;
}
.row.me.cont .bubble { border-top-right-radius: 8px; }

/* Someone said the owner's name: make sure they notice. */
.row.for-you .bubble { box-shadow: 0 0 0 3px var(--for-you); }
.row.for-you .body::after {
  content: "To you";
  align-self: flex-start;
  margin: 6px 0 0 4px;
  color: var(--for-you);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Words still being spoken: faded, with a blinking caret. */
.row.live .bubble { opacity: 0.72; }
.row.live .text::after {
  content: "";
  display: inline-block;
  width: 0.08em;
  height: 1em;
  margin-left: 0.12em;
  vertical-align: -0.12em;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}

/* ---------- Empty state ---------- */

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 4px;
  margin: 12vh auto 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 18px;
}

.empty h1 { margin: 22px 0 6px; color: var(--text); font-size: 28px; letter-spacing: -0.02em; }
.empty p { margin: 4px 0; line-height: 1.45; }
.empty b { color: var(--text); }

.empty-rings { position: relative; width: 84px; height: 84px; }
.empty-rings span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ripple 3s ease-out infinite;
}
.empty-rings span:nth-child(2) { animation-delay: 1s; }
.empty-rings span:nth-child(3) { animation-delay: 2s; }
.empty-rings::after {
  content: "";
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Jump to latest ---------- */

.jump {
  position: fixed;
  left: max(var(--gutter), calc((100% - var(--column)) / 2));
  bottom: calc(150px + env(safe-area-inset-bottom));
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.4);
}

/* ---------- View switcher ---------- */

.views { display: flex; gap: 6px; padding-top: 2px; padding-bottom: 8px; }
.views[hidden] { display: none; }
.views button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}
.views button.on { background: var(--surface-2); color: var(--text); }

/* ---------- Spatial views ---------- */

.spatial { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.spatial[hidden] { display: none; }

/* Table (compass): you in the middle, everyone where they sit. */
.compass-ring {
  position: absolute;
  left: 50%;
  top: 56%;
  width: min(84vw, 62vh, 640px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px dashed var(--line);
}
.compass-you {
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.compass-you::before { content: ""; display: block; width: 14px; height: 14px; margin: 0 auto 4px; border-radius: 50%; background: var(--accent); }
.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(44vw, 300px);
  transform: translate(-50%, -24px);
  transition: left 500ms ease, top 500ms ease;
}
.seat.across { flex-direction: column-reverse; transform: translate(-50%, calc(-100% + 24px)); }
.seat .avatar { width: 48px; height: 48px; font-size: 17px; }
.seat .seat-name { color: var(--c); font-size: 15px; font-weight: 700; }
.seat .seat-text {
  padding: 0.4em 0.65em;
  border-radius: 16px;
  background: var(--surface-2);
  font-size: calc(var(--size) * 0.72);
  line-height: 1.3;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.seat.latest .seat-text { font-size: calc(var(--size) * 0.9); box-shadow: 0 0 0 2px var(--c); }
.seat.stale .seat-text { opacity: 0.45; }
.seat.for-you .seat-text { box-shadow: 0 0 0 3px var(--for-you); }

.reseat {
  position: absolute;
  top: 8px;
  right: max(var(--gutter), calc((100% - var(--column)) / 2));
  z-index: 2;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

/* Stage: remarks float in 3D, coming from where the speaker sits. */
.stage { position: absolute; inset: 0; max-width: var(--column); margin: 0 auto; perspective: 900px; perspective-origin: 50% 30%; }
.card {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: min(74%, 560px);
  padding: 0.55em 0.8em;
  border-radius: 20px;
  background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--c), 0 20px 50px rgb(0 0 0 / 0.5);
  font-size: var(--size);
  line-height: 1.3;
  transform-origin: 50% 100%;
  transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 600ms ease, filter 600ms ease;
}
.card .card-name { display: block; margin-bottom: 4px; color: var(--c); font-size: 15px; font-weight: 700; }
.card.live { opacity: 0.75; }
.card.for-you { box-shadow: 0 0 0 3px var(--for-you), 0 20px 50px rgb(0 0 0 / 0.5); }

/* Glasses: what a heads-up display would show. */
.hud {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(88vw, 640px);
  aspect-ratio: 4 / 3;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 28px;
  border-radius: 28px;
  background: radial-gradient(ellipse at 50% 40%, #1a1f26, #07090b);
  box-shadow: inset 0 0 0 1px #2a3038, 0 30px 80px rgb(0 0 0 / 0.6);
}
.hud-label { position: absolute; top: 14px; left: 20px; color: #4d5663; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.hud-prev { color: #8a93a0; font-size: calc(var(--size) * 0.7); opacity: 0.6; }
.hud-who { color: var(--c); font-size: calc(var(--size) * 0.8); font-weight: 800; }
.hud-now { color: #f5f7fa; font-size: calc(var(--size) * 1.15); font-weight: 600; line-height: 1.25; }
.hud-now.live { opacity: 0.8; }
.hud-now.for-you { color: var(--for-you); }
.spatial-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 18px; text-align: center; padding: 24px; }

/* ---------- Timeline: who talked when; drag to scroll back ---------- */

.timeline {
  position: relative;
  flex: none;
  height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  touch-action: none;
  cursor: ew-resize;
}
.timeline canvas { display: block; width: 100%; height: 100%; }
.timeline-tip {
  position: absolute;
  bottom: 40px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.row.scrubbed .bubble { box-shadow: 0 0 0 3px var(--c); }

/* ---------- Catch me up ---------- */

.catchup-btn {
  position: fixed;
  right: max(var(--gutter), calc((100% - var(--column)) / 2));
  bottom: calc(150px + env(safe-area-inset-bottom));
  z-index: 4;
  padding: 12px 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.4);
}

.eyebrow-small { margin: 0; color: var(--accent); font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.catchup-text { margin: 0; font-size: calc(var(--size) * 0.95); line-height: 1.4; }
.catchup-text.loading { color: var(--muted); animation: blink 1.4s ease-in-out infinite; }
.catchup-text.error { color: #ff7a7a; font-size: 18px; }

/* ---------- Dock: the big start/stop button ---------- */

.dock {
  padding-top: 12px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.start {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #1b1003;
  font-size: 20px;
  font-weight: 700;
}

.start-idle, .start-live { display: flex; align-items: center; gap: 12px; }
.start-live { display: none; width: 100%; padding: 0 10px 0 22px; }

body.live .start { background: var(--surface-2); color: var(--text); }
body.live .start-idle { display: none; }
body.live .start-live { display: flex; }

.mic-dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; }

.live-label { flex: 1; text-align: left; }

.stop-square {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ff5a5a;
}
.stop-square::after { content: ""; width: 16px; height: 16px; border-radius: 3px; background: #fff; }

/* Live mic level: five bars scaled by --level (0..1) from the audio. */
.wave { --level: 0; display: flex; align-items: center; gap: 4px; height: 28px; }
.wave i {
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleY(calc(0.18 + var(--level) * var(--k)));
  transition: transform 90ms linear;
}
.wave i:nth-child(1) { --k: 0.45; }
.wave i:nth-child(2) { --k: 0.75; }
.wave i:nth-child(3) { --k: 0.82; }
.wave i:nth-child(4) { --k: 0.6; }
.wave i:nth-child(5) { --k: 0.35; }

/* ---------- Bottom sheets ---------- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  color: var(--text);
}

.sheet[open] { animation: sheet-up 240ms cubic-bezier(0.2, 0.9, 0.3, 1); }
.sheet::backdrop { background: rgb(0 0 0 / 0.55); }

@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 26px; }
}

.sheet-inner {
  display: grid;
  gap: 16px;
  padding: 10px 20px max(20px, env(safe-area-inset-bottom));
}

.sheet h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }

.grabber { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }

.assign-head { display: flex; align-items: center; gap: 14px; }
.quote { margin: 4px 0 0; color: var(--muted); font-size: 16px; font-style: italic; }

.me-btn {
  min-height: 52px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: none;
  font-size: 18px;
  font-weight: 700;
}

.group h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  --c: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 16px 6px 6px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 18px;
  font-weight: 600;
}

.chip .avatar { width: 38px; height: 38px; font-size: 14px; }
.chip.on { border-color: var(--c); }
.chip small { color: var(--muted); font-weight: 500; font-size: 13px; }
.editing .chip { border-style: dashed; border-color: var(--line); }

.add { display: flex; flex-wrap: wrap; gap: 10px; }

input, select {
  flex: 1 1 180px;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 18px;
}

.seg { display: flex; padding: 3px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.seg button { padding: 0 14px; border: 0; border-radius: 11px; background: none; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--surface-2); color: var(--text); }

.add-btn, .done {
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 17px;
}

.sheet-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sheet-foot .done { margin-left: auto; }

.link { min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-size: 16px; }
.link.danger { color: #ff7a7a; }

.field { display: grid; gap: 8px; }
.field > span { font-weight: 700; font-size: 16px; }
.field small, .muted { color: var(--muted); font-size: 14px; margin: 0; }

.size-row { display: flex; align-items: center; gap: 14px; }
.round { width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 18px; }
.size-preview { flex: 1; text-align: center; font-size: var(--size); font-weight: 600; }

.error { margin: 0; color: #ff7a7a; }

/* ---------- Circles ---------- */

.circle-btn {
  max-width: 45%;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.onboard {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  background: var(--bg);
}

.onboard-inner {
  display: grid;
  gap: 18px;
  max-width: 440px;
  margin: 0 auto;
  padding: max(56px, env(safe-area-inset-top)) var(--gutter) 40px;
}

.onboard-inner > div, .onboard-inner > form { display: grid; gap: 14px; }
.onboard [data-step] { display: none !important; }
.onboard [data-step].on { display: grid !important; }
.onboard h1 { margin: 8px 0 0; font-size: 34px; letter-spacing: -0.02em; }
.onboard .lede { margin: 0 0 8px; color: var(--muted); font-size: 19px; line-height: 1.45; }
.onboard .eyebrow { margin: 8px 0 -8px; color: var(--accent); font-weight: 700; }
.onboard .fine { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }
.onboard .link { justify-self: center; }

.big-btn {
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 19px;
  font-weight: 700;
}
.big-btn.primary { border-color: var(--accent); background: var(--accent); color: #1b1003; }

.invite-card { display: grid; justify-items: center; gap: 10px; padding: 18px; border-radius: 20px; background: #fff; }
.invite-card .muted { color: #555; text-align: center; }
.qr { width: min(240px, 60vw); aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; }

.live-banner {
  position: fixed;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #1b1003;
  font-size: 17px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.45);
  white-space: nowrap;
}
.live-pip { width: 10px; height: 10px; border-radius: 50%; background: #1b1003; animation: beat 1.4s ease-in-out infinite; }

.guest-dock { display: flex; gap: 10px; }
.guest-mic {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: none;
  font-size: 19px;
  font-weight: 700;
}
.guest-mic .wave { display: none; }
.guest-mic.on { background: var(--surface-2); border-color: var(--surface-2); }
.guest-mic.on .wave { display: flex; }
.leave { min-height: 64px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--surface-2); font-size: 17px; font-weight: 600; }
.wave.small { height: 22px; }

body.guest .start { display: none; }

/* ---------- Motion ---------- */

@keyframes ripple {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes beat { 50% { transform: scale(1.35); opacity: 0.7; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .feed { scroll-behavior: auto; }
}
