/* =========================================================
   THEME (manual)
   - JS aplica html.theme-light / html.theme-dark
   - Si no hay nada aún, dejamos claro por defecto para evitar “pantallazo”
========================================================= */

:root{
  --bg:#f6f7fb;
  --surface:#ffffff;
  --surface2:#f2f4f8;
  --card:#ffffff;
  --text:#0b1220;
  --muted:#586174;
  --border:rgba(15,23,42,.12);
  --shadow-soft: 0 8px 18px rgba(0,0,0,.08);
  --shadow-hard: 0 18px 40px rgba(0,0,0,.14);
  --accent:#6d28d9;
  --accent2:#16a34a;
  --danger:#dc2626;

  --bg-grad-1: rgba(109,40,217,.10);
  --bg-grad-2: rgba(22,163,74,.08);
}

html.theme-light{
  --bg:#f6f7fb;
  --surface:#ffffff;
  --surface2:#f2f4f8;
  --card:#ffffff;
  --text:#0b1220;
  --muted:#586174;
  --border:rgba(15,23,42,.12);
  --shadow-soft: 0 8px 18px rgba(0,0,0,.08);
  --shadow-hard: 0 18px 40px rgba(0,0,0,.14);
  --accent:#6d28d9;
  --accent2:#16a34a;
  --danger:#dc2626;

  --bg-grad-1: rgba(109,40,217,.10);
  --bg-grad-2: rgba(22,163,74,.08);
}

html.theme-dark{
  --bg:#0b1220;
  --surface:#0f172a;
  --surface2:#111c33;
  --card:#0f1a31;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --border:rgba(255,255,255,.12);
  --shadow-soft: 0 8px 18px rgba(0,0,0,.28);
  --shadow-hard: 0 18px 40px rgba(0,0,0,.42);
  --accent:#7c3aed;
  --accent2:#22c55e;
  --danger:#ef4444;

  --bg-grad-1: rgba(124,58,237,.30);
  --bg-grad-2: rgba(34,197,94,.18);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 20% -10%, var(--bg-grad-1), transparent 55%),
    radial-gradient(1200px 800px at 90% 20%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  color:var(--text);
  padding-bottom: 84px;
}

/* Topbar */
.topbar{
  position: sticky;
  top:0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 12px 10px;
}
.topbar-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}
.logo{
  width:40px;
  height:40px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--shadow-soft);
  border:1px solid var(--border);
  background: var(--surface);
}
.brand-text{
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ver{
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  margin-left: 6px;
}

.topbar-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

/* Toggles */
.country-toggle,
.theme-toggle{
  display:flex;
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  overflow:hidden;
  box-shadow: var(--shadow-soft);
}
.seg{
  border:0;
  background: transparent;
  color: var(--text);
  padding: 10px 10px;
  font-size: 15px;
  cursor:pointer;
}
.seg.active{
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Install button */
.install-btn{
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}
.install-btn:active{ transform: scale(.98); }

/* Searchbar */
.searchbar{
  margin-top: 10px;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}
.search-icon{ opacity:.9; }
#search{
  flex:1;
  background: transparent;
  border:0;
  outline: none;
  color: var(--text);
  font-size: 15px;
}
#search::placeholder{ color: color-mix(in srgb, var(--muted) 70%, transparent); }
.clear{
  border:0;
  width:34px;
  height:34px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
  cursor:pointer;
}

/* Chips */
.chips-row{ margin-top: 10px; }
.chips{
  display:flex;
  gap:10px;
  overflow:auto;
  padding-bottom: 2px;
}
.chip{
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active{
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

/* Status row */
.status-row{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.section-title{
  font-weight: 900;
  font-size: 15px;
}
.section-sub{
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.loading{ opacity:.9; }

.error{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: color-mix(in srgb, var(--danger) 25%, var(--text));
  font-weight: 700;
}

/* Content & list */
.content{
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}
.station-list{
  list-style: none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.row{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border:1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}
.row:active{ transform: scale(.995); }
.row-logo{
  width:52px;
  height:52px;
  border-radius: 16px;
  object-fit: cover;
  border:1px solid var(--border);
  background: var(--surface2);
  flex: 0 0 auto;
}
.row-logo.ph{
  display:grid;
  place-items:center;
  font-size: 22px;
}
.row-meta{
  min-width: 0;
  flex:1;
}
.row-title{
  font-weight: 900;
  font-size: 15px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.row-sub{
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.row-tags{
  display:flex;
  gap:8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.tag{
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: color-mix(in srgb, var(--text) 92%, transparent);
}
.row-actions{
  display:flex;
  align-items:center;
  gap:10px;
}
.fav-mini,.edit-mini,.add-mini{
  width:40px;
  height:40px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  display:grid;
  place-items:center;
  font-size: 16px;
  cursor:pointer;
}
.add-mini{ font-size: 18px; }
.fav-mini:active,.edit-mini:active,.add-mini:active{ transform: scale(.98); }

/* Bottom nav */
.bottom-nav{
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 30;
  display:flex;
  gap: 8px;
  padding: 10px;
  border-radius: 20px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-hard);
  overflow:auto;
}
.tab{
  border:1px solid transparent;
  background: transparent;
  color: color-mix(in srgb, var(--text) 82%, transparent);
  padding: 10px 12px;
  border-radius: 16px;
  cursor:pointer;
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  min-width: 86px;
  gap: 4px;
}
.tab.active{
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
}
.tab-ico{ font-size: 18px; }
.tab-txt{ font-size: 12px; font-weight: 800; }

/* Mini player */
.mini-player{
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 86px;
  z-index: 25;
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 10px;
  border-radius: 20px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-hard);
  cursor:pointer;
}
.mini-player[hidden]{ display:none !important; }
.mini-cover{
  width:44px;
  height:44px;
  border-radius: 16px;
  border:1px solid var(--border);
  object-fit: cover;
}
.mini-meta{ min-width:0; flex:1; }
.mini-title{
  font-weight: 900;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.mini-sub{
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.mini-actions{ display:flex; gap:10px; }
.icon-btn{
  width:40px;
  height:40px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  display:grid;
  place-items:center;
  cursor:pointer;
}
.icon-btn.primary{
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
}
.icon-btn:active{ transform: scale(.98); }

/* Sheet */
.sheet-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 40;
}
.sheet{
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 45;
  border-radius: 24px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-hard);
  transform: translateY(12px);
  opacity: 0;
  transition: .22s ease;
  overflow:hidden;
}
.sheet.open{
  transform: translateY(0);
  opacity: 1;
}
.sheet-handle{
  width: 52px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  margin: 10px auto 0;
}
.sheet-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-title{ font-weight: 900; }
.sheet-header-actions{ display:flex; gap:10px; align-items:center; }
.sheet-body{
  padding: 12px;
}
.cover{
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 18px;
  border:1px solid var(--border);
  background: var(--surface2);
}
.yt-slot{
  width: 100%;
  height: 220px;
  border-radius: 18px;
  border:1px solid var(--border);
  overflow:hidden;
  background: #000;
}
#yt-player{ width:100%; height:100%; }

.now{ margin-top: 12px; }
.now-title{ font-weight: 950; font-size: 18px; }
.now-sub{ color: var(--muted); margin-top: 4px; }
.now-status{ margin-top: 8px; font-weight: 800; color: color-mix(in srgb, var(--text) 92%, transparent); }

.sheet-controls{
  margin-top: 12px;
  display:flex;
  justify-content: center;
  gap: 12px;
}
.ctl{
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  display:grid;
  place-items:center;
  cursor:pointer;
  font-size: 18px;
}
.ctl.big{
  width: 76px;
  height: 56px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
}
.ctl:disabled{ opacity:.45; cursor:not-allowed; }

/* Dialogs */
.dlg{ border:0; padding:0; background: transparent; }
.dlg::backdrop{ background: rgba(0,0,0,.55); }
.dlg-card{
  width: min(520px, calc(100vw - 24px));
  border-radius: 22px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-hard);
  padding: 14px;
}
.dlg-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.dlg-title{ font-weight: 950; }
.dlg-sub{ margin-top: 8px; color: var(--muted); font-weight: 800; }
.dlg-label{
  display:block;
  margin-top: 12px;
  font-size: 12px;
  color: color-mix(in srgb, var(--muted) 90%, transparent);
  font-weight: 800;
}
.dlg-input{
  margin-top: 6px;
  width: 100%;
  border-radius: 16px;
  border:1px solid var(--border);
  padding: 12px 12px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  outline: none;
}
.dlg-input::placeholder{ color: color-mix(in srgb, var(--muted) 70%, transparent); }
.dlg-hint{ margin-top: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dlg-error{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: color-mix(in srgb, var(--danger) 25%, var(--text));
  font-weight: 800;
}
.dlg-suggest{ margin-top: 10px; display:flex; flex-wrap: wrap; gap: 10px; }
.sug{
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 800;
  cursor:pointer;
}
.sug.on{
  background: color-mix(in srgb, var(--accent2) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent2) 45%, transparent);
}
.dlg-actions{ margin-top: 14px; display:flex; justify-content:flex-end; gap: 10px; }
.dlg-actions.split{ justify-content: space-between; }
.btn{
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 16px;
  font-weight: 900;
  cursor:pointer;
}
.btn.primary{
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
}
.btn.soft{ background: color-mix(in srgb, var(--text) 4%, transparent); }
.btn.danger{
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: color-mix(in srgb, var(--danger) 35%, var(--text));
}
.btn:active{ transform: scale(.99); }

@media (max-width: 520px){
  .tab{ min-width: 76px; padding: 10px 10px; }
  .install-btn{ padding: 10px 10px; font-size: 13px; }
  .cover,.yt-slot{ height: 200px; }
}
