:root {
  --brand: #0A8F9E;
  --brand-deep: #076E7B;
  --bg: #0F1214;
  --bg-elevated: #171B1F;
  --bg-chip: rgba(255, 255, 255, 0.04);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #EDEEEF;
  --text-secondary: rgba(237, 238, 239, 0.6);
  --good: #22C55E;
  --warn: #F59E0B;
  --bad: #EF4444;
  --radius: 10px;
  --radius-sm: 6px;
}

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

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

body {
  color-scheme: dark;
}

#app {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  width: 100%;
  max-width: 420px;
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  margin: 0 auto;
}

.screen.hidden {
  display: none;
}

/* Wordmark */
.brand-wordmark {
  display: flex;
  align-items: baseline;
  gap: 0;
  justify-content: flex-start;
  margin: 0;
}

.brand-name {
  font-family: -apple-system-body, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-pro {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  font-size: 10px;
  letter-spacing: 0.08em;
  border-radius: 4px;
  padding: 4px 7px;
  margin-left: 8px;
  vertical-align: baseline;
  text-transform: uppercase;
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  margin: -0.75rem 0 0.25rem;
  font-size: 0.85rem;
}

.field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  color: var(--text-secondary);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.field input,
.field .select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  background: var(--bg-chip);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field .select {
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

.field input:focus,
.field .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 143, 158, 0.18);
}

.big-button {
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg-chip);
  color: var(--text);
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
}

.big-button:active {
  transform: scale(0.98);
}

.big-button.primary {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}

.big-button.primary:hover {
  background: var(--brand-deep);
}

.big-button.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.big-button.mute {
  background: var(--brand);
  color: #fff;
  min-height: 72px;
  font-size: 1.25rem;
  font-weight: 600;
}

.big-button.mute[aria-pressed="true"] {
  background: var(--bad);
  color: #fff;
}

.text-button {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--text-secondary);
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-radius: var(--radius);
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.text-button:hover {
  background: var(--bg-chip);
  color: var(--text);
}

.status {
  color: var(--text-secondary);
  font-size: 0.8rem;
  min-height: 1.2em;
  text-align: center;
  margin: 0;
}

.status.error,
.error {
  color: var(--bad);
  font-size: 0.75rem;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Dots */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.dot.connecting {
  background: var(--warn);
  animation: soft-pulse 1.4s ease-in-out infinite;
}

.dot.connected { background: var(--brand); }
.dot.failed    { background: var(--bad); }

@keyframes soft-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* Level meter (listener) */
.level-meter {
  width: 100%;
  height: 8px;
  background: var(--bg-chip);
  border-radius: 3px;
  overflow: hidden;
}

.level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--good) 0%, var(--warn) 75%, var(--bad) 100%);
  transition: width 0.05s linear;
}

@media (max-width: 480px) {
  .screen {
    border-radius: var(--radius);
    margin: 0 20px;
    padding: 1.25rem 1rem;
  }
}
