:root {
  --bg: #0b0d12;
  --surface: #141824;
  --surface-2: #1c2233;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --muted: #8b95ad;
  --accent: #4f8cff;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.9);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s, box-shadow 0.2s;
}
.dot.connected {
  background: var(--green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
}
.dot.busy {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

.title {
  font-size: 16px;
  font-weight: 600;
}
.subtitle {
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.orb-stage {
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.orb {
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
}

.orb-core {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7eb2ff, #3b63f6 65%, #1d2c7a);
  box-shadow: 0 0 28px rgba(79, 140, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(79, 140, 255, 0.25);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.orb.listening .orb-core {
  box-shadow: 0 0 36px rgba(34, 197, 94, 0.45);
}
.orb.speaking .orb-core {
  transform: scale(1.12);
  box-shadow: 0 0 46px rgba(79, 140, 255, 0.75);
}
.orb.speaking .orb-ring {
  animation: pulse 1.3s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.32); opacity: 0; }
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 280px;
}

.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: #233a6b;
  border-bottom-right-radius: 4px;
}

.msg.model {
  align-self: flex-start;
  background: var(--surface-2);
  border-bottom-left-radius: 4px;
}

.tool-card {
  align-self: stretch;
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
}

.tool-card.done {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.28);
}

.tool-card.error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
}

.tool-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tool-body {
  color: #cdd5e7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

.dock {
  border-top: 1px solid var(--border);
  background: rgba(15, 18, 27, 0.96);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.text-bar {
  display: flex;
  gap: 8px;
}
.text-bar input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}
.send-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
.ctrl-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}
.ctrl-btn:disabled {
  opacity: 0.4;
}

.call-btn {
  min-width: 148px;
  height: 56px;
  border-radius: 999px;
  border: none;
  background: var(--green);
  color: #06140b;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.35);
}
.call-btn.active {
  background: var(--red);
  color: white;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input, .field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}

.primary-btn {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
