:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #192234;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --cyan: #38bdf8;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --amber: #f59e0b;
  --red: #ef4444;
  --red-dark: #dc2626;
  --radius: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at top, #131d33 0%, var(--bg) 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  overscroll-behavior: none;
}

.app-shell {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 18px env(safe-area-inset-bottom, 20px);
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* LOGIN */
#login-screen {
  justify-content: center;
}

.login-card {
  background: rgba(18, 24, 38, 0.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.brand-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  border-radius: 18px;
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 24px;
}

.input-label {
  display: block;
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: #0d1320;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  margin-bottom: 14px;
}

.input-wrap:focus-within {
  border-color: var(--cyan);
}

.input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 0;
  outline: none;
}

.icon-btn {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan);
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  color: #061018;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error-box {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.86rem;
  margin-bottom: 14px;
  text-align: left;
}

.security-note {
  color: var(--muted);
  font-size: 0.76rem;
  margin: 18px 0 0;
  line-height: 1.4;
}

/* CALL SCREEN */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 14px;
}

.top-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
}

.dot-brand {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.ghost-btn {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.85fr;
  gap: 8px;
}

.status-card {
  background: rgba(18, 24, 38, 0.88);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 11px;
}

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

.status-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.indicator.online {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.indicator.offline {
  background: var(--red);
}

.indicator.idle {
  background: var(--muted);
}

.indicator.active {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.indicator.warn {
  background: var(--amber);
}

/* CENTER STAGE */
.center-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.orb-container {
  position: relative;
  width: 176px;
  height: 176px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  --local-scale: 1;
  --remote-scale: 1;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transition: transform 0.08s linear, opacity 0.2s ease;
}

.ring-outer {
  width: 172px;
  height: 172px;
  border: 2px solid rgba(56, 189, 248, 0.26);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.14), transparent 70%);
  transform: scale(var(--remote-scale));
}

.ring-mid {
  width: 132px;
  height: 132px;
  border: 2px solid rgba(16, 185, 129, 0.38);
  background: radial-gradient(circle, rgba(16, 185, 129, 0.16), transparent 70%);
  transform: scale(var(--local-scale));
}

.orb-core {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1b2740, #0f172a);
  border: 2px solid rgba(56, 189, 248, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.orb-container.connected .orb-core {
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 28px rgba(16, 185, 129, 0.28);
}

.orb-container.connecting .orb-core {
  border-color: var(--amber);
  color: var(--amber);
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.orb-mic-icon {
  width: 36px;
  height: 36px;
}

.call-state-label {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 22px;
}

/* METERS */
.meters-wrap {
  width: 100%;
  background: rgba(18, 24, 38, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-label {
  font-size: 0.76rem;
  color: var(--muted);
}

.meter-track {
  height: 8px;
  width: 100%;
  background: #0c1220;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.06s linear;
}

.meter-fill.local {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.meter-fill.remote {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

.info-banner {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a;
  font-size: 0.82rem;
  text-align: center;
}

/* CONTROLS */
.controls-dock {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 6px;
}

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

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.ctrl-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ctrl-btn.active {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.55);
  color: #fecaca;
}

.ctrl-icon {
  font-size: 1.35rem;
}

.ctrl-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.call-btn {
  width: 100%;
  border: none;
  border-radius: 22px;
  padding: 20px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.call-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.call-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.call-btn.start {
  background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.35);
}

.call-btn.hangup {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.35);
}

.debug-drawer {
  margin-top: 4px;
  background: rgba(18, 24, 38, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.76rem;
  color: var(--muted);
}

.debug-drawer summary {
  cursor: pointer;
  user-select: none;
}

.event-log {
  margin: 8px 0 0;
  max-height: 120px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}
