/* =============================== Components =============================== */

/* Buttons */
.btn {
  --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-5);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  user-select: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn.is-loading { opacity: 0.55; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn-primary { --btn-bg: var(--ember); --btn-fg: #fff; --btn-bd: transparent; box-shadow: var(--glow-ember); }
.btn-primary:hover { background: var(--ember-2); }
.btn-brand { --btn-bg: var(--gradient-brand); --btn-fg: #fff; --btn-bd: transparent; background: var(--gradient-brand); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { background: var(--surface); }
.btn-outline { --btn-bg: transparent; --btn-bd: var(--line-strong); }
.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-onair { --btn-bg: var(--onair); --btn-fg: #fff; --btn-bd: transparent; box-shadow: 0 8px 26px rgba(255, 45, 85, 0.4); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-lg { height: 50px; padding: 0 var(--s-8); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--text-2); transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  position: relative;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-active { color: var(--ember); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--ember); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field .error-text { font-size: var(--fs-xs); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2385849a' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); background: var(--surface-2); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); }
.form-actions { display: flex; gap: var(--s-3); justify-content: flex-end; margin-top: var(--s-4); flex-wrap: wrap; }
.checkbox { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--ember); margin-top: 2px; flex: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background var(--t-fast); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--t-med) var(--ease); }
.switch input:checked + .track { background: var(--ember); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }

/* Cards & surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-6); }
.card-tight { padding: var(--s-4); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: var(--fs-lg); }
.panel-glass { background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: var(--r-lg); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s-4); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); position: relative; overflow: hidden; }
.stat .stat-label svg { width: 15px; height: 15px; color: var(--ember); }
.stat .stat-label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .stat-value { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.stat.accent::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gradient-brand); }

/* Badges & chips */
.badge svg { width: 12px; height: 12px; }
.chip svg { width: 15px; height: 15px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: var(--r-pill); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-live, .badge-onair { background: var(--onair); color: #fff; }
.badge-live::before, .badge-onair::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; }
.badge-radio { background: var(--violet-soft); color: var(--violet); }
.badge-premium { background: var(--amber-soft); color: var(--amber); }
.badge-success { background: var(--mint-soft); color: var(--mint); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-ember { background: var(--ember-soft); color: var(--ember); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--text-inverse); border-color: transparent; }
.chip-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Avatars & artwork */
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); flex: none; overflow: hidden; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--text-2); }
.avatar img { width: 100%; height: 100%; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.art {
  position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-2); flex: none;
}
.art img { width: 100%; height: 100%; }
.art-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 2rem; color: rgba(255,255,255,0.92); }

/* Section headers & rows */
.section { margin-top: var(--s-10); }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.section-head h2 { font-size: var(--fs-xl); }
.section-head p { color: var(--text-3); font-size: var(--fs-sm); margin-top: 4px; }
.section-head a { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.section-head a:hover { color: var(--text); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-8); flex-wrap: wrap; }
.page-head p { color: var(--text-3); margin-top: 6px; }
.row-scroll {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(176px, 1fr); gap: var(--s-4);
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: var(--s-2); margin: 0 calc(-1 * var(--s-2)); padding-inline: var(--s-2);
}
.row-scroll > * { scroll-snap-align: start; }
@media (min-width: 1200px) { .row-scroll { grid-auto-columns: calc((100% - 5 * var(--s-4)) / 6); } }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--s-5); }

/* Channel card */
.ch-card { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-lg); transition: background var(--t-med) var(--ease); position: relative; }
.ch-card:hover { background: var(--surface); }
.ch-card .art { border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.ch-card .art .play-fab { position: absolute; right: 10px; bottom: 10px; opacity: 0; transform: translateY(8px); transition: all var(--t-med) var(--ease); }
.ch-card:hover .art .play-fab, .ch-card:focus-within .art .play-fab { opacity: 1; transform: none; }
.ch-card .art .badge { position: absolute; left: 10px; top: 10px; }
.ch-card-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-card-sub { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.play-fab {
  width: 46px; height: 46px; border-radius: 50%; background: var(--ember); color: #fff; display: grid; place-items: center;
  box-shadow: var(--glow-ember); transition: transform var(--t-fast);
}
.play-fab:hover { transform: scale(1.06); }
.play-fab svg { width: 20px; height: 20px; }

/* Episode list row */
.ep-list { display: flex; flex-direction: column; }
.ep-row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: var(--s-4); align-items: center;
  padding: var(--s-3); border-radius: var(--r-md); transition: background var(--t-fast);
}
.ep-row:hover { background: var(--surface); }
.ep-row .art { width: 64px; border-radius: var(--r-sm); }
.ep-row-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.ep-row-meta { font-size: var(--fs-sm); color: var(--text-3); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-top: 2px; }
.ep-row-desc { font-size: var(--fs-sm); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; }
.ep-row-actions { display: flex; align-items: center; gap: var(--s-1); }

/* Tables (dashboards) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-elev); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: var(--fs-xs); color: var(--text-3); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--text-3); }

/* Tabs */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-6); overflow-x: auto; }
.tabs button, .tabs a { padding: 12px 16px; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs [aria-selected="true"] { color: var(--text); border-color: var(--ember); }

/* Skeleton loading */
.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--r-sm); }
.skel-text { height: 12px; margin: 8px 0; }
.skel-title { height: 22px; width: 40%; margin-bottom: 16px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Empty & error states */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3);
  padding: var(--s-12) var(--s-6); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--text-3);
}
.empty .empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); }
.empty p { max-width: 420px; font-size: var(--fs-sm); }
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-sm); }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-warn { background: var(--amber-soft); border-color: transparent; color: var(--text); }
.alert-warn svg { color: var(--amber); }
.alert-danger { background: var(--danger-soft); border-color: transparent; }
.alert-danger svg { color: var(--danger); }
.alert-info { background: var(--violet-soft); border-color: transparent; }
.alert-info svg { color: var(--violet); }
.alert-success { background: var(--mint-soft); border-color: transparent; }
.alert-success svg { color: var(--mint); }

/* Toasts */
.toast-host { position: fixed; z-index: 900; right: var(--s-6); bottom: calc(var(--player-h) + var(--s-4)); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; max-width: min(400px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; gap: var(--s-3); align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2); font-size: var(--fs-sm); animation: toastIn var(--t-med) var(--ease) both;
}
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: var(--mint); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--violet); }
.toast.leaving { animation: toastOut var(--t-med) var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 720px) { .toast-host { left: var(--s-4); right: var(--s-4); bottom: calc(var(--bottomnav-h) + 76px); max-width: none; } }

/* Dialogs */
dialog.modal {
  border: 1px solid var(--line-strong); border-radius: var(--r-xl); padding: 0; background: var(--bg-elev); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-3);
}
dialog.modal.wide { width: min(880px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: modalIn var(--t-med) var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.modal-body { padding: var(--s-6); overflow-y: auto; max-height: calc(100vh - 220px); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }

/* Dropdown menu */
.menu { position: absolute; z-index: 80; min-width: 220px; padding: 6px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-2); animation: modalIn var(--t-fast) var(--ease); }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: var(--s-3); padding: 9px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); text-align: left; }
.menu a:hover, .menu button:hover { background: var(--surface-3); color: var(--text); }
.menu svg { width: 18px; height: 18px; }
.menu hr { margin: 6px 0; }
.menu .menu-head { padding: 10px 12px; }

/* Progress */
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gradient-brand); border-radius: inherit; transition: width var(--t-med); }

/* Equalizer animation (now playing) */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; background: var(--ember); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; } .eq i:nth-child(3) { animation-delay: -0.6s; } .eq i:nth-child(4) { animation-delay: -0.15s; }
.eq.paused i { animation-play-state: paused; height: 4px; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* Utility */
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); } .gap-6 { gap: var(--s-6); }
.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .col { flex-direction: column; }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
@media (max-width: 960px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.hidden { display: none !important; }
.divider-dot::before { content: "•"; margin: 0 6px; color: var(--text-3); }
.link { color: var(--ember); font-weight: 600; }
.link:hover { text-decoration: underline; color: var(--ember-2); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-strong); }

/* In-app payments (embedded Stripe Checkout / Payment Element) */
.checkout-mount { min-height: 220px; }
.checkout-loading { display: flex; align-items: center; justify-content: center; gap: var(--s-3); min-height: 220px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--ember); animation: zz-spin 0.8s linear infinite; }
@keyframes zz-spin { to { transform: rotate(360deg); } }
.checkout-summary { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); border-radius: var(--r-md); background: var(--ember-soft); }
.checkout-summary svg { color: var(--ember); width: 20px; height: 20px; flex: none; }
.billing-card { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.billing-card .grow { min-width: 0; }
.invoice-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.invoice-table th, .invoice-table td { text-align: left; padding: var(--s-3) var(--s-2); border-bottom: 1px solid var(--line); }
.invoice-table th { font-weight: 600; color: var(--text-muted, inherit); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 640px) { .invoice-table .hide-sm { display: none; } }
