:root {
  --bg: #07111f;
  --bg-soft: #0d1b2f;
  --card: rgba(15, 31, 53, 0.92);
  --line: rgba(143, 185, 230, 0.16);
  --text: #e8f1ff;
  --muted: #86a1bf;
  --primary: #35d0ba;
  --primary-dark: #1aa890;
  --danger: #ff6b6b;
  --warn: #f3b94d;
  --ok: #42d392;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(53, 208, 186, 0.16), transparent 28rem),
    radial-gradient(circle at 85% 20%, rgba(58, 123, 213, 0.2), transparent 32rem),
    var(--bg);
}

button, input, select { font: inherit; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 34px; }

.topbar, .brand, .call-top, .card-heading, .actions, .incoming, .footer {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.brand { gap: 14px; }

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #3a7bd5);
  color: #04111e;
  font-weight: 800;
  letter-spacing: 0.06em;
}

h1, h2, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: 0.02em; }
h2 { font-size: 20px; margin-top: 2px; }
.brand p, .muted, .hint, .footer { color: var(--muted); }
.brand p { margin-top: 3px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}
.pill.idle { color: var(--muted); }
.pill.warn { color: var(--warn); border-color: rgba(243, 185, 77, 0.4); }
.pill.ok { color: var(--ok); border-color: rgba(66, 211, 146, 0.4); }
.pill.bad { color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
}
.log-card { grid-column: 1 / -1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-heading { justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-heading p { margin-top: 6px; font-size: 13px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
label:first-child, label:last-child { grid-column: 1 / -1; }

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  color: var(--text);
  background: rgba(4, 13, 25, 0.72);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input:focus { border-color: rgba(53, 208, 186, 0.7); box-shadow: 0 0 0 3px rgba(53, 208, 186, 0.12); }
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  color: var(--text);
  background: rgba(4, 13, 25, 0.72);
  outline: none;
}
select:focus { border-color: rgba(53, 208, 186, 0.7); box-shadow: 0 0 0 3px rgba(53, 208, 186, 0.12); }

.api-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(4, 13, 25, 0.38);
}
.api-panel-heading, .api-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.api-panel-heading { margin-bottom: 14px; }
.api-panel-heading h3 { margin: 0; font-size: 15px; }
.api-panel-heading p { margin-top: 5px; font-size: 12px; }
.api-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.api-status.ok { color: var(--ok); }
.api-status.bad { color: var(--danger); }
.api-login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
}
.api-login-grid label, .api-task-options label { min-width: 0; grid-column: auto; }
.api-login-grid button { min-height: 42px; }
.api-task-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.api-task-options > .hint { grid-column: 1 / -1; margin-top: -4px; }
.api-session-row { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.api-message { min-height: 0; margin-top: 8px; font-size: 12px; line-height: 1.5; }
.api-message:empty { display: none; }
.api-message.error { color: var(--danger); }
.api-message.success { color: var(--ok); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}
.checkbox-label input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--primary);
}

.actions { gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.actions.compact { margin-top: 0; }

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.16s, opacity 0.16s, background 0.16s;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.42; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #03141a; font-weight: 700; }
button.secondary { border: 1px solid var(--line); }
button.danger { background: rgba(255, 107, 107, 0.15); border: 1px solid rgba(255, 107, 107, 0.4); color: #ffb3b3; }
button.small { padding: 8px 12px; font-size: 12px; }
.call-actions { margin-top: 20px; }
.call-btn { flex: 1; min-width: 180px; }

.hint { margin-top: 16px; font-size: 12px; line-height: 1.6; }
.hint a { color: var(--primary); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

.call-top { justify-content: space-between; gap: 18px; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.duration { font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 300; color: #b9d8ff; }

.incoming {
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(243, 185, 77, 0.35);
  background: rgba(243, 185, 77, 0.08);
}
.incoming span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.visualizer {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 12px 0;
}
.visualizer span {
  width: 5px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), rgba(58, 123, 213, 0.3));
  animation: pulse 1.6s ease-in-out infinite;
}
.visualizer span:nth-child(2n) { animation-delay: -0.35s; }
.visualizer span:nth-child(3n) { animation-delay: -0.7s; }
.visualizer span:nth-child(4n) { animation-delay: -1.05s; }
.visualizer span:nth-child(5n) { animation-delay: -1.4s; }
@keyframes pulse { 0%, 100% { height: 12px; opacity: 0.4; } 50% { height: 56px; opacity: 1; } }

.video-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.video-tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #020810;
}
.video-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-tile:last-child video { transform: scaleX(-1); }
.video-label {
  position: absolute;
  left: 10px;
  bottom: 9px;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(2, 8, 16, 0.72);
  color: var(--text);
  font-size: 11px;
}

.log {
  height: 210px;
  overflow: auto;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(2, 8, 16, 0.75);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}
.log-line { display: grid; grid-template-columns: 74px 1fr; gap: 10px; }
.log-time { color: #5d7896; }
.log-info { color: #b9d8ff; }
.log-ok { color: var(--ok); }
.log-warn { color: var(--warn); }
.log-bad { color: var(--danger); }

.footer { justify-content: space-between; gap: 16px; margin-top: 20px; font-size: 12px; }

audio { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .log-card { grid-column: auto; }
}
@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 16px; }
  .topbar, .call-top, .incoming, .footer { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  label:first-child, label:last-child { grid-column: auto; }
  .api-login-grid, .api-task-options { grid-template-columns: 1fr; }
  .api-session-row { grid-column: auto; }
  .duration { font-size: 24px; }
  .video-stage { grid-template-columns: 1fr; }
}
