:root {
  --bg: #0b0f17;
  --surface: #131926;
  --surface-2: #1a2234;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
}

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

html, body {
  min-height: 100%;
  background: radial-gradient(circle at top, #172033 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand h1 {
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand p {
  font-size: 0.78rem;
  color: var(--muted);
}

.cast-launcher-wrap {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px;
}

google-cast-launcher {
  width: 22px;
  height: 22px;
  cursor: pointer;
  --connected-color: #3b82f6;
  --disconnected-color: #cbd5e1;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.dot.ready {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}

.dot.live {
  background: var(--success);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.8);
}

.dot.error {
  background: var(--danger);
}

#statusText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

#statsText {
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  color: #fff;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), #4338ca);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.86rem;
  padding: 11px 14px;
}

.btn-secondary:hover:not(:disabled) {
  background: #222c42;
}

.hidden {
  display: none !important;
}

.source-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.source-btn {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.source-btn:hover:not(:disabled) {
  background: #222c42;
}

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

.source-btn.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35) inset;
}

.source-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.source-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.source-name {
  font-size: 0.76rem;
  font-weight: 600;
}

.source-sub {
  font-size: 0.66rem;
  color: var(--muted);
}

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

.preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

.notice {
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.notice.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.settings {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

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

.field label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.field select,
.field input[type="text"] {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  outline: none;
}

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

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

.row-inline input {
  flex: 1;
}

.row-inline .btn-small {
  padding: 0 14px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 0.86rem;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.footer-hint {
  font-size: 0.74rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.footer-hint code {
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 5px;
  color: #cbd5e1;
}
