:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d7dee8;
  --panel: #ffffff;
  --page: #eef3f6;
  --soft: #f7f9fb;
  --accent: #087f8c;
  --accent-strong: #066674;
  --success: #138a36;
  --danger: #b42318;
  --warning: #c47f00;
  --agent: #e8f6f7;
  --customer: #f3efe8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

body[data-call-status="listening"] .phone-surface,
body[data-call-status="speaking"] .phone-surface,
body[data-call-status="thinking"] .phone-surface {
  border-color: #54d2dc;
  box-shadow: inset 0 0 0 1px rgba(84, 210, 220, 0.28);
}

body[data-call-status="error"] .phone-surface {
  border-color: #ff9d92;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 15px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.workspace {
  width: min(1320px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.topbar,
.test-notice,
.agent-panel,
.conversation-panel,
.notes-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(23, 32, 51, 0.08);
}

.topbar {
  min-height: 88px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand,
.person {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark,
.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.brand-mark {
  background: var(--accent);
}

.brand-mark span {
  width: 18px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 12px;
  position: relative;
}

.brand-mark span::after,
.headset::after {
  content: "";
  position: absolute;
}

.brand-mark span::after {
  left: 50%;
  bottom: -12px;
  width: 24px;
  height: 14px;
  border-bottom: 3px solid #fff;
  border-left: 3px solid #fff;
  border-right: 3px solid #fff;
  border-radius: 0 0 14px 14px;
  transform: translateX(-50%);
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.call-state {
  min-width: 210px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
}

#statusText {
  display: block;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.test-notice {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8e6;
  border-color: #f0c96a;
  color: #5c4100;
}

.test-notice strong {
  flex: 0 0 auto;
}

.test-notice span {
  color: #6f520c;
}

.call-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(360px, 1fr) 280px;
  gap: 14px;
}

.call-layout.chat-hidden {
  grid-template-columns: minmax(360px, 1fr) 320px;
}

.conversation-panel,
.conversation-panel[hidden],
.conversation-panel.is-hidden,
.call-layout.chat-hidden .conversation-panel {
  display: none !important;
}

.agent-panel,
.conversation-panel,
.notes-panel {
  min-height: 640px;
}

.agent-panel {
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.person {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 14px;
}

.person strong {
  display: block;
  font-size: 1rem;
}

.person p {
  font-size: 0.92rem;
}

.avatar {
  position: relative;
  background: var(--customer);
  color: #6b4e22;
  font-weight: 900;
}

.avatar.headset {
  background: var(--agent);
  color: var(--accent-strong);
}

.headset::after {
  inset: 9px 7px 16px;
  border: 3px solid currentColor;
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
}

.headset::before {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 13px;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.active-person {
  border-color: rgba(8, 127, 140, 0.35);
}

.phone-surface {
  border-radius: 8px;
  border: 1px solid #263244;
  background: #1e293b;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 18px;
  color: #fff;
}

.phone-screen {
  min-height: 126px;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #3b4658;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.phone-screen .label {
  color: #b9c3d3;
}

.phone-screen strong {
  font-size: 1.25rem;
}

.phone-screen small {
  color: #dbe4f0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1rem;
}

.voice-meter {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.voice-meter span {
  width: 9px;
  height: 16px;
  border-radius: 5px;
  background: #6b788f;
  transition: background 160ms ease, height 160ms ease;
}

.voice-meter.active span {
  background: #54d2dc;
  animation: pulse 820ms ease-in-out infinite;
}

.voice-meter.active span:nth-child(2) {
  animation-delay: 90ms;
}

.voice-meter.active span:nth-child(3) {
  animation-delay: 180ms;
}

.voice-meter.active span:nth-child(4) {
  animation-delay: 270ms;
}

@keyframes pulse {
  0%, 100% { height: 16px; }
  50% { height: 54px; }
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.call-button.start {
  background: var(--success);
  color: #fff;
  white-space: nowrap;
}

.call-button.stop {
  background: #ffe6e3;
  color: var(--danger);
  white-space: nowrap;
}

.conversation-head {
  min-height: 72px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.conversation-head strong {
  font-size: 1.1rem;
}

#clearLogButton {
  background: #edf1f6;
  color: var(--ink);
}

.conversation {
  min-height: 0;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 18px;
  background:
    linear-gradient(#ffffffd9, #ffffffd9),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, #eef2f6 32px);
}

.bubble {
  width: min(78%, 620px);
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.bubble span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bubble p {
  color: var(--ink);
  margin: 0;
  line-height: 1.4;
}

.bubble.agent {
  margin-left: auto;
  background: var(--agent);
  border-color: rgba(8, 127, 140, 0.28);
}

.bubble.customer {
  background: var(--customer);
  border-color: #eadfce;
}

.bubble.system {
  width: 100%;
  background: #f4f6f8;
}

.bubble.error {
  width: 100%;
  background: #fff0ee;
  border-color: #ffc6bf;
}

.notes-panel {
  padding: 18px;
}

dl {
  margin: 0;
}

dl div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.script {
  margin-top: 22px;
  display: grid;
  gap: 9px;
}

.prompt-chip {
  min-height: 38px;
  text-align: left;
  background: #edf7f8;
  color: var(--accent-strong);
  font-size: 0.92rem;
}

@media (max-width: 1060px) {
  .call-layout {
    grid-template-columns: 300px minmax(360px, 1fr);
  }

  .call-layout.chat-hidden {
    grid-template-columns: minmax(320px, 1fr) 300px;
  }

  .notes-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .call-layout.chat-hidden .notes-panel {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .call-state {
    width: 100%;
  }

  .test-notice {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .call-layout {
    grid-template-columns: 1fr;
  }

  .call-layout.chat-hidden {
    grid-template-columns: 1fr;
  }

  .agent-panel,
  .conversation-panel {
    min-height: auto;
  }

  .conversation {
    max-height: 520px;
  }

  .bubble {
    width: 100%;
  }
}
