:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(15, 29, 48, 0.78);
  --surface-strong: #101f33;
  --line: rgba(160, 190, 224, 0.14);
  --text: #f4f8fc;
  --muted: #91a3b8;
  --blue: #5ea7ff;
  --violet: #8f74ff;
  --mint: #40dfb1;
  --danger: #ff6f7d;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(71, 132, 226, 0.2), transparent 40%),
    linear-gradient(160deg, #081321 0%, #07111f 55%, #081624 100%);
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 38rem;
  height: 38rem;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.08;
  pointer-events: none;
}

.ambient-one { top: 15%; left: -24rem; background: #248dff; }
.ambient-two { right: -26rem; bottom: -8rem; background: #39d9b1; }

.app {
  position: relative;
  z-index: 1;
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar, .topbar-actions, .brand, .status-pill, .session-meta, .activity-line,
.card-heading, .control-dock, .controls, .audio-note { display: flex; align-items: center; }

.topbar { justify-content: space-between; }

.brand { gap: 12px; color: var(--text); text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(111, 172, 255, 0.3);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(88, 162, 255, 0.2), rgba(123, 102, 255, 0.1));
  box-shadow: inset 0 0 18px rgba(82, 153, 255, 0.08);
}

.brand-mark::before, .brand-mark::after, .brand-mark i {
  position: absolute;
  content: "";
  width: 14px;
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--blue), #b2ceff);
  transform-origin: left center;
}
.brand-mark::before { transform: translate(-5px, -7px) rotate(60deg); }
.brand-mark i { transform: translate(1px, 0) rotate(180deg); }
.brand-mark::after { transform: translate(-5px, 7px) rotate(-60deg); }

.topbar-actions { gap: 10px; }
.key-button {
  display: grid;
  width: 39px;
  height: 39px;
  padding: 10px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 29, 48, 0.55);
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}
.key-button:hover { border-color: rgba(94, 167, 255, 0.45); transform: translateY(-1px); }
.key-button svg { width: 17px; fill: var(--muted); }

.status-pill {
  gap: 9px;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #b9c8d7;
  background: rgba(15, 29, 48, 0.55);
  font-size: 12px;
  font-weight: 650;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #6f8193; box-shadow: 0 0 0 4px rgba(111, 129, 147, 0.1); }
.app[data-activity="agent_speaking"] .status-dot,
.app[data-activity="customer_speaking"] .status-dot,
.app[data-activity="listening"] .status-dot,
.app[data-activity="processing"] .status-dot { background: var(--mint); box-shadow: 0 0 0 4px rgba(64, 223, 177, 0.1), 0 0 16px rgba(64, 223, 177, 0.55); }

.hero { padding: 54px 0 26px; text-align: center; }
.eyebrow, .section-label { color: #7f93aa; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; }
.eyebrow span { width: 18px; height: 1px; background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.hero h1 { margin: 13px 0 8px; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; letter-spacing: -0.04em; }
.hero p { max-width: 560px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.7; }

.session-card, .conversation-card, .control-dock {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(18, 34, 56, 0.88), rgba(10, 23, 39, 0.78));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(20px);
}

.session-card { overflow: hidden; border-radius: 24px; }
.session-meta { min-height: 72px; padding: 0 28px; border-bottom: 1px solid var(--line); }
.meta-item { min-width: 120px; }
.meta-item span, .meta-item strong { display: block; }
.meta-item span { color: #70849b; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.meta-item strong { max-width: 240px; margin-top: 5px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.meta-separator { width: 1px; height: 30px; margin: 0 26px; background: var(--line); }
.session-timer { margin-left: auto; color: #aab9c8; font: 500 13px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.08em; }

.voice-stage { display: grid; grid-template-columns: 1fr minmax(170px, 0.5fr) 1fr; align-items: center; min-height: 290px; padding: 42px 11%; }
.participant { display: flex; flex-direction: column; align-items: center; text-align: center; }
.orb-wrap { position: relative; display: grid; width: 112px; height: 112px; place-items: center; }
.voice-orb { position: relative; z-index: 2; display: grid; width: 82px; height: 82px; place-items: center; border: 1px solid rgba(255,255,255,0.16); border-radius: 50%; transition: transform 280ms ease, filter 280ms ease; }
.voice-orb::before { position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,0.08); border-radius: inherit; content: ""; }
.voice-orb svg { width: 28px; fill: white; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3)); }
.agent-orb { background: radial-gradient(circle at 35% 28%, #8dc7ff, #5575e8 48%, #633fd0 100%); box-shadow: 0 14px 44px rgba(91, 112, 232, 0.3), inset 0 0 24px rgba(255,255,255,0.12); }
.customer-orb { background: radial-gradient(circle at 35% 28%, #8cebd4, #25af9f 50%, #17767e 100%); box-shadow: 0 14px 44px rgba(36, 190, 158, 0.2), inset 0 0 24px rgba(255,255,255,0.1); }
.pulse { position: absolute; inset: 14px; border: 1px solid transparent; border-radius: 50%; opacity: 0; }
.agent-participant .pulse { border-color: rgba(107, 145, 255, 0.5); }
.customer-participant .pulse { border-color: rgba(64, 223, 177, 0.5); }

.participant-copy { margin-top: 13px; }
.participant-copy span, .participant-copy strong, .participant-copy small { display: block; }
.participant-role { color: #6e8299; font-size: 9px; font-weight: 750; letter-spacing: 0.15em; text-transform: uppercase; }
.participant-copy strong { margin-top: 6px; font-size: 14px; }
.participant-copy small { margin-top: 6px; color: var(--muted); font-size: 12px; }

.signal { display: flex; height: 46px; align-items: center; justify-content: center; gap: 5px; }
.signal span { width: 3px; height: 7px; border-radius: 5px; background: linear-gradient(to top, rgba(94,167,255,0.45), rgba(64,223,177,0.7)); opacity: 0.55; }
.signal::before, .signal::after { width: 36px; height: 1px; background: linear-gradient(90deg, transparent, rgba(125,160,195,0.32)); content: ""; }
.signal::after { background: linear-gradient(90deg, rgba(125,160,195,0.32), transparent); }

.activity-line { min-height: 51px; justify-content: center; gap: 10px; border-top: 1px solid var(--line); color: #94a8bc; font-size: 12px; }
.activity-icon { display: flex; height: 14px; align-items: center; gap: 2px; }
.activity-icon i { width: 2px; height: 5px; border-radius: 3px; background: currentColor; }

.app[data-activity="agent_speaking"] .agent-participant .voice-orb,
.app[data-activity="customer_speaking"] .customer-participant .voice-orb { transform: scale(1.07); filter: saturate(1.2) brightness(1.08); }
.app[data-activity="agent_speaking"] .agent-participant .pulse,
.app[data-activity="customer_speaking"] .customer-participant .pulse { animation: pulse 1.8s ease-out infinite; }
.app[data-activity="agent_speaking"] .agent-participant .pulse-two,
.app[data-activity="customer_speaking"] .customer-participant .pulse-two { animation-delay: 0.6s; }
.app[data-activity="agent_speaking"] .signal span,
.app[data-activity="customer_speaking"] .signal span,
.app[data-activity="processing"] .signal span { animation: waveform 750ms ease-in-out infinite alternate; opacity: 1; }
.signal span:nth-child(2n) { animation-delay: -200ms !important; }
.signal span:nth-child(3n) { animation-delay: -390ms !important; }
.app[data-activity="agent_speaking"] .participant-copy #agentState,
.app[data-activity="customer_speaking"] .participant-copy #customerState { color: var(--mint); }

.conversation-card { margin-top: 18px; padding: 25px 27px 18px; border-radius: 20px; }
.card-heading { justify-content: space-between; }
.card-heading h2 { margin: 5px 0 0; font-size: 18px; letter-spacing: -0.02em; }
.turn-count { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: #8195aa; font-size: 10px; }
.transcript { display: flex; min-height: 190px; max-height: 330px; margin-top: 18px; padding: 4px 4px 12px; flex-direction: column; gap: 12px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2a4058 transparent; }
.empty-state { display: flex; min-height: 156px; align-items: center; justify-content: center; flex-direction: column; color: var(--muted); text-align: center; }
.empty-state strong { margin-top: 13px; color: #b7c4d2; font-size: 13px; }
.empty-state span { max-width: 350px; margin-top: 6px; font-size: 11px; line-height: 1.5; }
.empty-wave { display: flex; height: 26px; align-items: center; gap: 4px; }
.empty-wave i { width: 2px; height: 6px; border-radius: 2px; background: #3d536b; }
.empty-wave i:nth-child(2), .empty-wave i:nth-child(4) { height: 15px; }
.empty-wave i:nth-child(3) { height: 23px; }

.turn { display: flex; gap: 10px; animation: turnIn 280ms ease both; }
.turn.customer { flex-direction: row-reverse; }
.turn-avatar { display: grid; width: 27px; height: 27px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #dceeff; background: #415bc3; font-size: 9px; font-weight: 800; }
.turn.customer .turn-avatar { color: #dffff6; background: #198a7d; }
.turn-body { max-width: min(78%, 760px); }
.turn-meta { margin: 0 4px 5px; color: #687e95; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.turn.customer .turn-meta { text-align: right; }
.turn-text { padding: 11px 14px; border: 1px solid rgba(106, 145, 207, 0.16); border-radius: 5px 14px 14px 14px; color: #d8e4ef; background: rgba(48, 70, 112, 0.32); font-size: 12px; line-height: 1.6; }
.turn.customer .turn-text { border-color: rgba(61, 198, 164, 0.16); border-radius: 14px 5px 14px 14px; background: rgba(30, 112, 102, 0.22); }

.control-dock { min-height: 76px; margin-top: 18px; padding: 13px 16px 13px 22px; justify-content: space-between; border-radius: 18px; }
.audio-note { gap: 11px; }
.audio-note > span:last-child, .audio-note strong, .audio-note small { display: block; }
.audio-note strong { font-size: 11px; }
.audio-note small { margin-top: 4px; color: #70849a; font-size: 10px; }
.device-icon { position: relative; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 9px; }
.device-icon::before { position: absolute; top: 7px; left: 11px; width: 6px; height: 10px; border: 1.5px solid #8498ac; border-radius: 5px; content: ""; }
.device-icon::after { position: absolute; top: 18px; left: 9px; width: 10px; height: 5px; border-top: 1.5px solid #8498ac; content: ""; }
.controls { gap: 9px; }
.button { display: inline-flex; min-height: 43px; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border-radius: 12px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform 150ms ease, opacity 150ms ease, border-color 150ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.38; cursor: not-allowed; }
.button-primary { min-width: 132px; border: 1px solid rgba(139, 181, 255, 0.38); background: linear-gradient(135deg, #557be5, #6a53cf); box-shadow: 0 9px 25px rgba(73, 91, 207, 0.28), inset 0 1px rgba(255,255,255,0.16); }
.button-secondary { border: 1px solid var(--line); background: rgba(12, 26, 44, 0.65); }
.start-icon { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid white; }
.stop-icon { width: 8px; height: 8px; border-radius: 2px; background: #ff8791; }

.key-dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 1px solid rgba(132, 166, 203, 0.2); border-radius: 22px; color: var(--text); background: #101f32; box-shadow: 0 35px 100px rgba(0,0,0,0.6); }
.key-dialog::backdrop { background: rgba(2, 8, 16, 0.75); backdrop-filter: blur(8px); }
.key-dialog form { position: relative; padding: 32px; }
.dialog-close { position: absolute; top: 14px; right: 16px; border: 0; color: #75899f; background: transparent; font-size: 24px; cursor: pointer; }
.dialog-icon { display: grid; width: 42px; height: 42px; margin-bottom: 18px; place-items: center; border: 1px solid rgba(94,167,255,0.25); border-radius: 13px; background: rgba(67,129,213,0.14); }
.dialog-icon svg { width: 19px; fill: var(--blue); }
.key-dialog h2 { margin: 7px 0 7px; font-size: 24px; }
.key-dialog p { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.key-dialog code { color: #c3d9ef; }
.key-dialog label { display: block; margin-bottom: 7px; color: #a9bacb; font-size: 11px; font-weight: 700; }
.key-dialog input { width: 100%; height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--text); background: #0b1828; }
.key-dialog input:focus { border-color: rgba(94,167,255,0.55); box-shadow: 0 0 0 3px rgba(94,167,255,0.08); }
.dialog-submit { width: 100%; margin-top: 13px; }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: 380px; padding: 12px 16px; border: 1px solid rgba(255,111,125,0.3); border-radius: 12px; color: #ffdce0; background: rgba(72, 23, 34, 0.95); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@keyframes pulse { 0% { opacity: 0.75; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.65); } }
@keyframes waveform { from { height: 6px; } to { height: 35px; } }
@keyframes turnIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 720px) {
  .app { width: min(100% - 24px, 1160px); padding-top: 16px; }
  .hero { padding-top: 38px; }
  .session-meta { padding: 15px 17px; flex-wrap: wrap; gap: 14px 20px; }
  .meta-separator { display: none; }
  .meta-item { min-width: calc(50% - 12px); }
  .session-timer { margin-left: 0; }
  .voice-stage { grid-template-columns: 1fr 70px 1fr; min-height: 260px; padding: 35px 10px; }
  .orb-wrap { width: 88px; height: 88px; }
  .voice-orb { width: 68px; height: 68px; }
  .signal::before, .signal::after { display: none; }
  .conversation-card { padding: 22px 16px 14px; }
  .control-dock { padding: 13px; flex-direction: column; gap: 14px; }
  .controls, .button { width: 100%; }
  .audio-note { align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
