*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --border: #2a2a2a;
  --border-focus: #4a4a4a;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-dim: rgba(34, 197, 94, 0.1);
  --error: #ef4444;
  --error-dim: rgba(239, 68, 68, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 640px;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

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

.status-dot.online { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-dot.offline { background: var(--error); }
.status-dot.loading { background: #f59e0b; animation: pulse 1.5s infinite; }

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

/* Input section */
.input-section {
  margin-bottom: 1rem;
}

.input-section label,
.control-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.6;
  padding: 0.75rem;
  resize: vertical;
  transition: border-color 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

textarea::placeholder { color: var(--text-muted); }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.control-group.wide { grid-column: 1 / -1; }

select, input[type="text"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.625rem;
  transition: border-color 0.15s;
}

select:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
}

input[type="text"]::placeholder { color: var(--text-muted); }

input[type="range"] {
  width: 100%;
  margin-top: 0.25rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #000;
  padding: 0.625rem 1rem;
  justify-content: center;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.625rem 0.875rem;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Output section */
.output-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.output-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
}

#outputInfo {
  font-size: 0.75rem;
  color: var(--text-muted);
}

audio {
  width: 100%;
  margin-bottom: 0.75rem;
  border-radius: var(--radius);
}

.output-actions {
  display: flex;
  justify-content: flex-end;
}

/* Error section */
.error-section {
  background: var(--error-dim);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.error-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--error);
  font-size: 0.875rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.tab:hover { color: var(--text-secondary); background: var(--surface); }
.tab.active { color: var(--accent); background: var(--accent-dim); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Stream status */
.stream-status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.stream-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}

.stream-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
}

.stream-wave .bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}

.stream-wave .bar:nth-child(1) { height: 20%; animation-delay: 0s; }
.stream-wave .bar:nth-child(2) { height: 40%; animation-delay: 0.1s; }
.stream-wave .bar:nth-child(3) { height: 60%; animation-delay: 0.2s; }
.stream-wave .bar:nth-child(4) { height: 80%; animation-delay: 0.3s; }
.stream-wave .bar:nth-child(5) { height: 100%; animation-delay: 0.4s; }
.stream-wave .bar:nth-child(6) { height: 80%; animation-delay: 0.5s; }
.stream-wave .bar:nth-child(7) { height: 60%; animation-delay: 0.6s; }
.stream-wave .bar:nth-child(8) { height: 40%; animation-delay: 0.7s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* Footer */
footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2rem;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

footer a:hover { color: var(--text); }

footer code {
  background: var(--surface);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.6875rem;
}

/* Loading spinner on button */
.btn-primary.loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn-primary.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
