:root {
  --bg: #0a0b0f;
  --grid-line: rgba(255, 255, 255, 0.045);
  --panel-bg: #12141a;
  --panel-bg-2: #15171e;
  --panel-border: #23262f;
  --text: #e6e8ec;
  --muted: #838a99;
  --accent: #dc2626;
  --accent-dim: rgba(220, 38, 38, 0.14);
  --danger: #ef5b5b;
  --danger-dim: rgba(239, 91, 91, 0.14);
  --live: #37d67a;
  --bubble-agent-bg: #171a21;
  --bubble-agent-border: #2a2e38;
  --bubble-caller-bg: #1b2434;
  --bubble-caller-border: #2d3c58;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 75%);
}

.hero {
  max-width: 880px;
  margin: 4.5rem auto 2.5rem;
  padding: 0 1.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.hero .accent {
  color: var(--accent);
}

.hero p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  font-size: 0.95rem;
}

.hero code {
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.panels {
  max-width: 1100px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 820px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.panel-header .icon {
  font-size: 1.1rem;
}

.panel-header h2 {
  font-size: 1rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
}

.label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.status-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  word-break: break-word;
}

.status-box .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-box.connecting .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.status-box.active .dot {
  background: var(--live);
  box-shadow: 0 0 0 4px rgba(55, 214, 122, 0.14);
}

.status-box.error .dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-dim);
}

.sf-input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}

.sf-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sf-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.sf-debug {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg-2);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1.25rem;
}

.sf-debug[hidden] {
  display: none;
}

.sf-debug .sf-status {
  font-weight: 600;
}

.sf-debug.matched .sf-status {
  color: var(--live);
}

.sf-debug.unmatched .sf-status {
  color: var(--muted);
}

.sf-debug .sf-owner {
  color: var(--muted);
  font-size: 0.78rem;
}

.cta {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.cta:hover {
  background: rgba(220, 38, 38, 0.22);
}

.cta:active {
  transform: scale(0.99);
}

.cta:disabled {
  opacity: 0.55;
  cursor: default;
}

.cta.hangup {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
}

.cta.hangup:hover {
  background: rgba(239, 91, 91, 0.22);
}

.steps {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.steps .num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  flex-shrink: 0;
  color: var(--muted);
}

.steps li.current {
  color: var(--text);
}

.steps li.current .num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.steps li.done .num {
  border-color: var(--live);
  color: var(--live);
}

.timer {
  margin-top: 1.5rem;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.transcript-panel {
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.live-badge[hidden] {
  display: none;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--live);
  border: 1px solid rgba(55, 214, 122, 0.35);
  background: rgba(55, 214, 122, 0.08);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.live-badge .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.transcript {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 0.25rem;
}

.transcript .empty {
  color: var(--muted);
  font-size: 0.88rem;
  margin: auto 0;
  text-align: center;
}

.msg {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.msg .who {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.msg .bubble {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg.agent {
  align-self: flex-start;
}

.msg.agent .bubble {
  background: var(--bubble-agent-bg);
  border: 1px solid var(--bubble-agent-border);
}

.msg.caller {
  align-self: flex-end;
  text-align: right;
}

.msg.caller .bubble {
  background: var(--bubble-caller-bg);
  border: 1px solid var(--bubble-caller-border);
}

.avatar {
  position: fixed;
  right: 1.75rem;
  bottom: 1.75rem;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: radial-gradient(circle at 35% 30%, #3a1414, #0a0b0f 70%);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.18), 0 8px 24px rgba(0, 0, 0, 0.4);
}

@media (max-width: 560px) {
  .avatar {
    display: none;
  }
}
