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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-2: #1a1a26;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --accent: #e1306c;
  --accent-2: #833ab4;
  --rtmp: #00d4aa;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.status-pills {
  display: flex;
  gap: 10px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.pill.active .dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.pill.error .dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-highlight {
  border-color: rgba(0, 212, 170, 0.3);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(0, 212, 170, 0.05) 100%);
}

.card-info {
  background: var(--surface-2);
}

.card-preview {
  border-color: rgba(131, 58, 180, 0.3);
}

.card-preview.is-live {
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.08);
}

.card-preview .card-header {
  align-items: center;
  margin-bottom: 16px;
}

.preview-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.preview-badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.card-preview.is-live .preview-badge {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.1);
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#preview-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  background: linear-gradient(135deg, #0d0d14 0%, #14141f 100%);
  text-align: center;
  padding: 20px;
}

.preview-placeholder.hidden {
  display: none;
}

.preview-placeholder p {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.preview-placeholder .hint {
  font-size: 0.78rem;
  max-width: 280px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rtmp-icon {
  background: rgba(0, 212, 170, 0.15);
  color: var(--rtmp);
}

.output-icon {
  background: rgba(131, 58, 180, 0.15);
  color: var(--accent-2);
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.card-header p {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* URL boxes */
.url-box {
  margin-bottom: 14px;
}

.url-box label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.url-row {
  display: flex;
  gap: 8px;
}

.url-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--rtmp);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
  outline: none;
}

.url-parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .url-parts { grid-template-columns: 1fr; }
}

/* Form */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.hint code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
}

.key-toggle-row {
  margin-top: 4px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
}

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

/* Buttons */
.btn-copy {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-copy:hover {
  color: var(--text);
  border-color: var(--rtmp);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn-primary, .btn-secondary, .btn-danger {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--rtmp); color: var(--rtmp); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

/* Steps */
.steps {
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.steps li {
  margin-bottom: 12px;
}

.steps strong { color: var(--text); }

.steps a {
  color: var(--accent);
  text-decoration: none;
}

.steps a:hover { text-decoration: underline; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
