:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #3b82f6;
  --accent-dim: #1d4ed8;
  --green: #22c55e;
  --amber: #eab308;
  --red: #ef4444;
  --gray: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 10px;
}

section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.status-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--gray);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.idle { background: var(--gray); }
.status-badge.connecting { background: var(--amber); color: #1a1a1a; animation: pulse 1.2s infinite; }
.status-badge.reconnecting { background: var(--amber); color: #1a1a1a; animation: pulse 1.2s infinite; }
.status-badge.live { background: var(--green); color: #05260f; }
.status-badge.error { background: var(--red); }

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

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.channel-btn {
  position: relative;
  padding: 18px 12px;
  min-height: 84px;
  border-radius: 14px;
  border: 3px solid var(--border);
  background: #0d1117;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.channel-btn:active {
  transform: scale(0.97);
}

.channel-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: #fff;
}

.channel-btn:disabled {
  cursor: not-allowed;
}

.channel-btn.live-elsewhere {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.card-label {
  font-size: 16px;
  font-weight: 700;
}

.card-listeners {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.35;
  word-break: break-word;
}

.channel-btn.active .card-listeners {
  color: rgba(255, 255, 255, 0.75);
}

select, input[type="range"] {
  width: 100%;
}

select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1117;
  color: var(--text);
  font-size: 15px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

input[type="range"] {
  accent-color: var(--accent);
  height: 32px;
}

.level-meter {
  margin-top: 12px;
  height: 10px;
  background: #0d1117;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  transition: width 0.05s linear;
}

.btn-transmit {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}

.btn-transmit.on {
  background: var(--red);
}

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

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  margin-bottom: 0;
  min-height: 0;
}

.error-msg:empty {
  display: none;
}

.field-row {
  margin-bottom: 16px;
}

.field-row:last-child {
  margin-bottom: 0;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.value-inline {
  color: var(--text);
  font-weight: 600;
}

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1117;
  color: var(--text);
  font-size: 15px;
}

.links-row {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.link {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.link:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
}

.modal h2 {
  margin-top: 0;
}

.confirm-text {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-secondary {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}

