/* ==========
   == BASE ==
   ========== */
/* --accent se registra como color para poder animar su cambio (los derivados con color-mix lo siguen) */
@property --accent { syntax: '<color>'; inherits: true; initial-value: #58dfa3; }

/* --accent: color de énfasis (verde por defecto; se cambia con "accent" en los ajustes). Los demás derivan de él. */
:root {
  color-scheme: dark; font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  --accent: #58dfa3;
  transition: --accent .6s ease;
  --on-accent: color-mix(in srgb, var(--accent) 9%, #000);          /* texto sobre fondo de énfasis */
  --accent-bg: color-mix(in srgb, var(--accent) 12%, #1b1f1f);      /* fondo de la cadena activa */
  --accent-soft: color-mix(in srgb, var(--accent) 55%, transparent); /* icono de noticias en directo */
}

/* ======================================================
   == PÁGINA: COLUMNA PEGADA ARRIBA CON EL MISMO FONDO ==
   ====================================================== */
/* Sin altura mínima en body: el fondo de toda la pantalla lo pone html, y una altura mínima en vh/dvh dejaba scroll vacío en el móvil
   cuando la barra del navegador cambiaba de tamaño */
html { background: #1a2029; }
body { margin: 0; display: grid; place-items: start center; background: #1a2029; color: #edf2f7; }
main { width: min(520px, 100%); box-sizing: border-box; padding: 22px 20px 28px; }
/* Con altura suficiente la página no hace scroll: lo hace por dentro la parte de abajo (boletines y emisoras), sin barra visible.
   Con poca altura (móvil apaisado, ventanas bajas) se queda como una página normal */
@media (min-height: 600px) {
  html { overflow: hidden; }
  main { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 0; }
  main > :not(.scroller) { flex: none; }
  .scroller { flex: 1 1 auto; min-height: 0; margin: 0 -6px; padding: 0 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 28px; }
  .scroller::-webkit-scrollbar { display: none; }
  /* lo que sube por debajo del espectro se va desvaneciendo en vez de cortarse (--fade lo pone ui.js según el scroll) */
  .scroller { -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent calc(var(--fade, 0px) * .3), #000 var(--fade, 0px)); mask-image: linear-gradient(to bottom, transparent 0, transparent calc(var(--fade, 0px) * .3), #000 var(--fade, 0px)); }
}

/* ==========================================
   == CABECERA, ESTADO DE CONEXIÓN Y RELOJ ==
   ========================================== */
header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
h1 { font-size: 1.35rem; margin: 0; }
p { color: #aeb9c8; line-height: 1.45; }
/* Subtítulo bajo el título, escrito directamente en el HTML: 1rem, color #aeb9c8 y .6em de margen superior */
.subtitle { margin: .6em 0 0; }
.status { display: flex; align-items: center; flex: 0 0 auto; gap: 9px; min-width: 0; padding: 5px 13px; border-radius: 999px; background: #11161d; color: #cbd5e1; font-size: .78rem; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.status:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #778394; flex: 0 0 auto; }
.dot.on { background: #48d597; box-shadow: 0 0 12px #48d59766; }
.dot.err { background: #ff7070; }
/* Hueco entre el subtítulo y los botones que usa personalizar.js (algo mayor que el título): oculto mientras está vacío, y se muestra solo en cuanto el script le pone texto */
#especial { margin: 6px 0 0; font-size: calc(1.6rem + 2pt); text-align: center; }
#especial:empty { display: none; }
/* La hora (corregida con la hora real, de Madrid) va dentro de la píldora de la cabecera, junto al punto de estado */
#clock { color: #cbd5e1; font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* =========================
   == BOTONES Y VOLÚMENES ==
   ========================= */
.buttons { display: flex; gap: 10px; margin-top: 17px; }
button { border: 0; border-radius: 10px; padding: 11px 17px; font: inherit; font-weight: 650; cursor: pointer;  flex: 1; }
#toggle { color: var(--on-accent); background: var(--accent); }
#stop { color: #e8edf5; background: #394454; }
button:disabled { opacity: .45; cursor: default; }
.volume { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.volume + .volume { margin-top: 10px; }
.panel.vols { display: block; margin-top: 22px; padding: 17px 15px; }
.vols .volume { margin-top: 0; }
.vols .volume + .volume { margin-top: 12px; }
.volume label { flex: 0 0 4.6em; }
.volume span { flex: 0 0 3ch; text-align: right; font-variant-numeric: tabular-nums; }
input { width: 100%; accent-color: var(--accent); }
input[type="range"]:disabled { opacity: .4; }

/* ===================================
   == EMISORA ACTUAL Y VISUALIZADOR ==
   =================================== */
.now { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 10px; padding: 21px 18px 16px; min-height: 86px; box-sizing: border-box; border-radius: 12px; background: #11161d; }
.viz { position: relative; user-select: none; -webkit-tap-highlight-color: transparent; margin-top: 10px; padding: 28px 18px 14px; height: 86px; box-sizing: border-box; border-radius: 12px; background: #11161d; }
.viz canvas { display: block; width: 100%; height: 100%; }
.viz.eq-on { cursor: pointer; }
.viz.off canvas, .viz.off .eq-label { opacity: .45; filter: grayscale(1); }
.viz.noeq .eq-label { color: #8c98a8; }   /* emisora en modo degradado: sin ecualizador (barras sintéticas) */
.viz:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eq-label { position: absolute; top: 10px; right: 18px; max-width: calc(100% - 100px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .68rem; line-height: 14px; font-weight: 700; letter-spacing: .05em; color: var(--accent); pointer-events: none; }
.now .ps.idle { color: #8c98a8; }
.now .ps { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 2.1rem; font-weight: 700; letter-spacing: .06em; color: #edf2f7; }
/* Cambio de emisora pedido y aún sin confirmar: el nombre actual parpadea suave hasta que suena la nueva */
.ps.pending, .pres-ps.pending { animation: ps-blink 1.1s ease-in-out infinite; }
@keyframes ps-blink { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .ps.pending, .pres-ps.pending { animation: none; opacity: .6; } }

/* Botón del modo presentación, en la esquina de las barras */
/* Alineado con el margen de las barras (a su izquierda; la etiqueta del ecualizador va a su derecha), en la franja de arriba; el área de toque se extiende con ::after */
.pres-open { position: absolute; top: 10px; left: 18px; flex: none; display: grid; place-items: center; width: 14px; height: 14px; padding: 0; border-radius: 3px; background: none; color: #fff; opacity: 1; }
.pres-expand { left: 48px; }
.pres-open::after { content: ''; position: absolute; inset: -9px -8px; }
.pres-open svg { display: block; }
.viz.off .pres-open { display: none; }

/* ===============================
   == PANEL DEL MODO BOLETINES ==
   =============================== */
/* Paneles: misma estética, sin brillo */
.panel { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 15px; border-radius: 12px; background: #11161d; }
.panel .badge { display: grid; place-items: center; flex: 0 0 auto; min-width: 38px; height: 38px; box-sizing: border-box; padding: 0 6px; border-radius: 10px; background: #1a2029; font-size: 1.2rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.panel .info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.panel .info b { font-size: .88rem; font-weight: 650; color: #e2e8f0; }
.panel .info span { font-size: .78rem; color: #9fabb9; }
.panel .switch { margin-left: auto; }
.panel.news { margin-inline: 2px; background: #2a3441; }
.panel.news { margin-top: 14px; }
/* Buscador de emisoras (importador de TDTChannels): otro panel de gris claro, con el campo de texto y la lupa; justo encima, el de boletines baja a la separación normal */
.panel.search { margin: 22px 2px 0; background: #2a3441; }   /* mismo padding (15 px), hueco (12 px) y alto (68 px) que el de boletines: la lupa es un cuadrado de 38 px como su icono */
.panel.search + .panel.news { margin-top: 14px; }   /* el buscador a 22 px de las barras y boletines a 14 px del buscador */
.panel.search input { flex: 1 1 auto; min-width: 0; height: 38px; padding: 0 2px; border: 0; outline: 0; background: none; color: #edf2f7; font: inherit; font-size: .92rem; -webkit-appearance: none; appearance: none; }
.panel.search input::placeholder { color: #8c98a8; }
.panel.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.panel.search:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent); }
.panel.search .badge { flex: none; width: 38px; padding: 0; color: #cbd5e1; cursor: pointer; order: 2; }   /* min-width 38 y alto 38 vienen de .panel .badge */
.panel.search .badge:hover { color: var(--accent); }
body.no-config .panel > * { visibility: hidden; }
body.no-config .panel.vols > * { visibility: visible; }
/* Modo activado con una emisora no musical: las noticias no saltarían (naranja, el color de los avisos) */
.panel.news.wont .switch input:checked + .track { background: #f2b84b; }
.panel.news.wont .switch input:checked + .track::after { background: #2b2108; }
.panel.news .badge { transition: background .4s; }
.panel.news.live .badge { background: var(--accent-soft); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .track { background: #2a3039; }
.switch { position: relative; flex: 0 0 auto; width: 46px; height: 26px; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: #394454; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #e8edf5; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =============================================
   == EMISORAS (GRUPOS: GENERALISTAS Y MUSICALES) ==
   ============================================= */
.presets { margin: 4px 2px 0; }
.pgroup { margin-top: 18px; }
.ptitle { margin: 0 0 8px 2px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8c98a8; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.pgrid .preset { border-radius: 12px; }
/* Pulsación larga en el móvil (abre el menú de la cadena): sin selección de texto ni el menú de copiar y pegar del navegador */
.preset, .preset * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.preset { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: calc(1.8rem + 32px); padding: 10px 8px; color: #e8edf5; background: #2a3441; border: 1px solid transparent; }
.preset .pn { display: flex; align-items: center; text-align: center; font-size: .95rem; font-weight: 700; line-height: 1.15; letter-spacing: .01em; overflow-wrap: anywhere; color: #f1f5f9; }
.preset .pf { text-align: center; font-size: .74rem; line-height: 1.1; font-weight: 500; color: #9fabb9; }
.preset .pf:empty { display: none; }
.preset[hidden] { display: none; }
.preset.more { justify-content: center; font-size: 1.8rem; font-weight: 600; line-height: 1; color: var(--accent); background: #1a2029; border: 1px dashed #303a47; }
.preset.active { border-color: var(--accent); background: var(--accent-bg); }
.preset:disabled { opacity: .4; }

/* ========================
   == REGISTRO (VENTANA) ==
   ======================== */
#log { display: block; width: 100%; margin: 0; flex: 1 0 auto; height: 0; min-height: 120px; resize: vertical; box-sizing: border-box; padding: 12px; border: 0; overflow-wrap: anywhere; background: #11161d; border-radius: 10px; color: #9fabb9; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
audio { display: none; }

/* ========================
   == VENTANA DE AJUSTES ==
   ======================== */
/* La ventana (ajustes, configuración y registro) mide lo mismo en todas las pestañas y va pegada arriba; el área central ocupa el resto y, en el texto de configuración y el registro, se puede estirar desde la esquina (la ventana crece con ella) */
dialog.settings { width: min(560px, 94vw); min-height: min(584px, calc(100vh - 44px)); min-height: min(584px, calc(100dvh - 44px)); max-height: calc(100vh - 44px); max-height: calc(100dvh - 44px); overflow: auto; margin: 22px auto auto; padding: 0; border: 1px solid #303a47; border-radius: 16px; background: #1a2029; color: #edf2f7; box-shadow: 0 18px 55px #000a; }
dialog.settings[open] { display: flex; flex-direction: column; }
dialog.settings::backdrop { background: rgba(0, 0, 0, .65); }
.dlg { flex: 1 0 auto; display: flex; flex-direction: column; gap: 12px; padding: 18px; box-sizing: border-box; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; font-size: 1.05rem; }
.dlg .x { flex: none; padding: 4px 10px; background: #2a3441; color: #cbd5e1; border-radius: 8px; }
.clockrow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: .88rem; color: #cbd5e1; }
.clockrow select { padding: 6px 8px; border-radius: 8px; border: 1px solid #303a47; background: #11161d; color: #edf2f7; font: inherit; }
.clockrow input[type="text"] { width: 56px; padding: 6px 4px; box-sizing: border-box; text-align: center; border-radius: 8px; border: 1px solid #303a47; background: #11161d; color: #edf2f7; font: inherit; }
.clockrow input[type="text"]:disabled { opacity: .6; }
#cfgText { width: 100%; flex: 1 0 auto; height: 0; min-height: 120px; resize: vertical; box-sizing: border-box; padding: 10px; border-radius: 10px; border: 1px solid #303a47; background: #11161d; color: #cbd5e1; font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
/* Pestañas: texto con línea inferior (la activa lleva el color de énfasis); los botones de acción siguen siendo botones rellenos */
.tabs { display: flex; border-bottom: 1px solid #303a47; }
.tabs button { flex: 1; padding: 8px 6px 10px; margin-bottom: -1px; border-radius: 0; border-bottom: 2px solid transparent; background: none; color: #8c98a8; font-size: .92rem; }
.tabs button:hover { color: #cbd5e1; }
.tabs button.active { color: #edf2f7; border-bottom-color: var(--accent); }
.tab { flex: 1 0 auto; display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.tab[hidden] { display: none; }
/* Apartados de los ajustes generales, separados por una línea suave */
.group { display: flex; flex-direction: column; gap: 12px; }
.clockrow button { flex: none; padding: 6px 12px; font-size: .85rem; color: #e8edf5; background: #394454; }
.clockrow button.danger { color: #fff; background: #b8414d; }
.group + .group { padding-top: 14px; border-top: 1px solid #252e3a; }
/* Hueco reservado para los mensajes de la configuración (guardado, errores...), con su propio fondo */
.cfgmsg { min-height: calc(2.8em + 18px); box-sizing: border-box; padding: 8px 10px; border: 1px solid #252e3a; border-radius: 10px; background: #11161d; white-space: pre-wrap; font-size: .8rem; line-height: 1.4; }
.cfgmsg.ok { color: #58dfa3; }
.cfgmsg.err { color: #ff8a8a; }
.dlg-actions { display: flex; gap: 10px; }
.dlg-actions .primary { color: var(--on-accent); background: var(--accent); }
.dlg-actions button:not(.primary) { color: #e8edf5; background: #394454; }
.dlg-links { display: flex; justify-content: space-between; gap: 10px; }
.dlg-links[hidden] { display: none; }
.dlg-links.ghost { visibility: hidden; }   /* en Registro ocupa el sitio de los enlaces de Configuración, para que "Copiar" quede a la altura de Cargar y Guardar */
.dlg-links .link { flex: none; padding: 2px 0; background: none; color: #8c98a8; font-size: .78rem; font-weight: 500; text-decoration: underline; }

/* =======================
   == MODO PRESENTACIÓN ==
   ======================= */
/* Capa a pantalla completa con las barras como protagonistas; se dibuja en un canvas (presentation.js) y los textos son HTML encima */
.pres { position: fixed; inset: 0; z-index: 20; overflow: hidden; background: #0a0d12; touch-action: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.pres[hidden] { display: none; }
.pres.idle:not(.show-top):not(.show-bottom) { cursor: none; }
.pres canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.pres-info { position: absolute; left: 0; right: 0; top: 7vh; display: flex; flex-direction: column; align-items: center; gap: .8vh; text-align: center; pointer-events: none; }
.pres-ps > span { display: inline-block; white-space: nowrap; }
/* Nombre que no cabe: se desplaza de un lado a otro (presentation.js calcula --dx y --dur) */
.pres-ps.marquee { text-overflow: clip; }
.pres-ps.marquee > span { animation: pres-marquee var(--dur, 10s) ease-in-out infinite; }
@keyframes pres-marquee { 0%, 15% { transform: translateX(0); } 45%, 60% { transform: translateX(var(--dx)); } 90%, 100% { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .pres-ps.marquee > span { animation: none; } }
.pres-ps { max-width: 94vw; padding: .5em; margin: -.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: min(15vw, 11vh); font-weight: 750; letter-spacing: .06em; line-height: 1.1; color: #f1f5f9; text-shadow: 0 0 .45em color-mix(in srgb, var(--accent) 55%, transparent); }
.pres-qual { display: flex; justify-content: center; gap: .5em; max-width: 94vw; font-size: min(2.8vw, 1.9vh); font-weight: 600; letter-spacing: .05em; color: #8c98a8; }
.pres-qual span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pres-qual span:empty { display: none; }
@media (max-width: 599.98px) { .pres[data-mode="0"] .pres-info { top: 14vh; } }
.pres[data-mode="1"] .pres-info { top: 50%; transform: translateY(-50%); gap: .6vmin; }
.pres[data-mode="1"] .pres-ps { max-width: 34vmin; font-size: 5.6vmin; }
.pres[data-mode="1"] .pres[data-mode="1"] .pres-clock { margin-top: .4vmin; font-size: 2.6vmin; }
.pres[data-mode="1"] .pres-qual { flex-direction: column; align-items: center; gap: .15em; max-width: 34vmin; font-size: 1.5vmin; }
.pres[data-mode="2"] .pres-ps, .pres[data-mode="2"] .pres-qual, .pres[data-mode="2"] .pres-clock { text-shadow: 0 0 .35em #000, 0 0 .1em #000; }
.pres-mode { position: absolute; left: 0; right: 0; bottom: 4vh; text-align: center; font-size: .85rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #8c98a8; opacity: 0; transition: opacity .4s; pointer-events: none; }
.pres-mode.show { opacity: 1; }
.pres-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #cbd5e1; font-size: 1.1rem; transition: opacity .4s; }
.pres.idle .pres-close { opacity: 0; pointer-events: none; }
.pres-clock { margin-top: .5vh; font-size: min(4.6vw, 3.4vh); font-weight: 600; letter-spacing: .06em; font-variant-numeric: tabular-nums; color: #cbd5e1; }

/* Paneles que aparecen al llevar el ratón arriba a la izquierda (control) y abajo (emisoras); en pantallas táctiles, al tocar */
.pres-panel { position: absolute; z-index: 2; box-sizing: border-box; background: rgba(17, 22, 29, .9); border: 1px solid #252e3a; border-radius: 14px; backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.pres-ctl { top: 12px; left: 12px; width: min(300px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 12px; padding: 12px 14px; transform: translateY(-8px); }
.pres-strip { left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; padding: 8px; overflow-x: auto; overscroll-behavior: contain; touch-action: pan-x; scrollbar-width: none; -ms-overflow-style: none; transform: translateY(8px); }
.pres-strip::-webkit-scrollbar { display: none; }
.pres-strip.dragging { cursor: grabbing; user-select: none; }
.pres-strip.dragging .preset { pointer-events: none; }
@media (pointer: coarse), (max-width: 600px) { .pres-ctl { top: max(34px, calc(env(safe-area-inset-top) + 22px)); left: 0; right: 0; margin: 0 auto; } }
.pres.show-top .pres-ctl, .pres.show-bottom .pres-strip { opacity: 1; pointer-events: auto; transform: none; }
.pres.show-bottom .pres-mode { bottom: 112px; }
.pc-row { display: flex; align-items: center; gap: 12px; font-size: .88rem; color: #cbd5e1; }
.pc-row label:not(.switch) { flex: 0 0 4.6em; }
.pc-row input[type="range"] { min-width: 0; }
.pc-row span:last-child { flex: 0 0 3.4ch; text-align: right; font-variant-numeric: tabular-nums; }
.pc-news { margin-left: auto; }
.pc-play { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%; color: var(--on-accent); background: var(--accent); }
.pc-play svg { display: block; }
.pres .switch.wont input:checked + .track { background: #f2b84b; }
.pres .switch.wont input:checked + .track::after { background: #2b2108; }
.pres-strip .preset { flex: 0 0 112px; min-height: 64px; }

/* ===================================
   == EMISORAS: LISTA, ALTA Y EDICIÓN ==
   =================================== */
#tabStations { padding-top: 14px; }   /* el mensaje, el botón y la fila fantasma van abajo, como en Configuración y Registro, para que los botones queden a la misma altura */
#tabStations .cfgmsg { margin-top: auto; }
.stform { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; }
.stform .sttitle { grid-column: 1 / -1; font-size: .95rem; color: #edf2f7; }
.stform label { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-size: .76rem; color: #8c98a8; }
.stform .wide { grid-column: 1 / -1; }
.stform input[type="text"], .stform input[type="url"], .stform select { width: 100%; box-sizing: border-box; padding: 11px 12px; border-radius: 10px; border: 1px solid #303a47; background: #11161d; color: #edf2f7; font: inherit; font-size: .9rem; }
.stform input::placeholder { color: #5c6877; }
.stform .stcolor { display: flex; gap: 8px; }
.stform .stcolor input[type="text"] { flex: 1 1 auto; min-width: 0; }
.stform .stcolor input[type="color"] { flex: none; width: 44px; height: 42px; padding: 3px; box-sizing: border-box; border: 1px solid #303a47; border-radius: 10px; background: #11161d; }
/* Arrastrar para reordenar y menú del clic derecho */
.preset.dragging { background: transparent; border-color: transparent; box-shadow: none; }   /* al arrastrar, el botón se va con el cursor y en su sitio queda solo el hueco, sin borde */
.preset.dragging > * { visibility: hidden; }
.preset.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.dnd-card { position: fixed; z-index: 60; left: 0; top: 0; margin: 0; border-radius: 12px; pointer-events: none; opacity: .92; border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 12px 28px rgba(0, 0, 0, .55); }   /* copia que sigue al dedo al arrastrar en el móvil */
.ctxmenu { display: flex; flex-direction: column; max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); overflow: hidden; position: fixed; z-index: 60; min-width: 190px; padding: 5px; border: 1px solid #303a47; border-radius: 10px; background: #1a2029; box-shadow: 0 10px 30px #000a; }
.ctxmenu, .ctxmenu * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }   /* el menú no deja seleccionar texto: con la pulsación larga del móvil saltaba la selección de Android */
.ctxmenu input { -webkit-user-select: text; user-select: text; }   /* salvo los campos de texto, que se siguen pudiendo editar */
.ctxmenu button { display: block; width: 100%; padding: 8px 12px; text-align: left; font-size: .88rem; color: #e8edf5; background: none; border-radius: 7px; }
.ctxmenu button:hover:not(:disabled) { background: #2a3441; }
.ctxmenu button.danger:hover { background: #c4525e; }
.ctxmenu button:disabled { color: #8c98a8; }
.ctxmenu .ctxtitle { padding: 6px 12px 7px; margin-bottom: 3px; border-bottom: 1px solid #303a47; font-size: .8rem; color: #8c98a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 12px; border: 1px solid #303a47; background: #1a2029; color: #edf2f7; font-size: .88rem; box-shadow: 0 10px 30px #000a; pointer-events: none; }
.toast[hidden] { display: none; }

.ctxform { display: flex; flex-direction: column; gap: 6px; padding: 4px 6px 6px; width: 250px; max-width: 100%; box-sizing: border-box; }
.ctxform input { width: 100%; box-sizing: border-box; padding: 7px 9px; border-radius: 8px; border: 1px solid #303a47; background: #11161d; color: #edf2f7; font: inherit; font-size: .86rem; }
.ctxform input::placeholder { color: #5c6877; }
.ctxform .ctxerr { font-size: .78rem; line-height: 1.3; color: #ff7a85; }
.ctxform button { width: auto; align-self: flex-end; padding: 6px 14px; text-align: center; color: var(--on-accent); background: var(--accent); font-weight: 600; }
.ctxform button:disabled { opacity: .55; }
.ctxmenu .ctxform button:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
/* Con muchas emisoras en una cadena: el nombre arriba y "Añadir emisora…" / "Cambiar nombre…" (o "Guardar") abajo no se mueven; entre medias, la lista se desplaza */
.ctxmenu > * { flex: none; }
.ctxmenu > .ctxlist, .ctxmenu > .ctxform { flex: 0 1 auto; min-height: 0; }
.ctxlist { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a4656 transparent; }
.ctxform { overflow: hidden; }
.ctxfields { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a4656 transparent; padding: 2px; margin: -2px; }
.ctxrow { display: flex; align-items: center; gap: 4px; }
.ctxmenu .ctxrow .ctxgo { flex: 1 1 auto; min-width: 0; width: auto; }
.ctxmenu .ctxrow .ctxgo.on { color: var(--accent); font-weight: 600; }
.ctxmenu .ctxrow .ctxdel { flex: none; width: auto; padding: 8px 10px; font-size: .8rem; color: #ff7a85; }
.ctxmenu .ctxrow .ctxdel:hover { background: #3a2227; }
.ctxmenu .ctxrow .ctxdel.danger { color: #fff; background: #b8414d; }
.ctxmenu .ctxrow .ctxdel.danger:hover { background: #c4525e; }
.ctxmenu .ctxadd { margin-top: 3px; border-top: 1px solid #303a47; border-radius: 0 0 7px 7px; color: #cbd5e1; }
#stMsg:empty { border-color: transparent; background: none; }
.ctxform label { display: flex; flex-direction: column; gap: 4px; font-size: .74rem; color: #8c98a8; }
.ctxmenu .ctxren { margin-top: 0; border-top: 0; border-radius: 7px; }

/* ===========================================================
   == IMPORTADOR DE TDTCHANNELS: VENTANA DE RESULTADOS ==
   =========================================================== */
dialog.tdt { overflow: hidden; min-height: min(760px, calc(100vh - 44px)); min-height: min(760px, calc(100dvh - 44px)); }
.tdt .dlg { flex: 1 1 auto; min-height: 0; }
.tdtq { width: 100%; box-sizing: border-box; padding: 11px 12px; border-radius: 10px; border: 1px solid #303a47; background: #11161d; color: #edf2f7; font: inherit; font-size: .9rem; }
.tdtq::placeholder { color: #5c6877; }
.tdtstatus { font-size: .78rem; color: #8c98a8; line-height: 1.4; }
.tdtstatus.err { color: #ff8a8a; }
.tdtlist { flex: 1 1 0; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.tdtinfo { font-size: .72rem; color: #6f7b8b; line-height: 1.35; }
.tdtinfo:empty { display: none; }
.tdtsec { display: flex; align-items: center; gap: 12px; margin: 16px 2px 8px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8c98a8; }
.tdtsec::after { content: ''; flex: 1; height: 1px; background: #252e3a; }
.tdtsec:first-child { margin-top: 2px; }
/* Una sola tarjeta por canal, sin tarjetas dentro: las opciones son filas con una línea de separación y un punto (relleno = elegida) */
.tdtch { margin-bottom: 8px; padding: 12px 14px 2px; border-radius: 12px; background: #2a3441; }
.tdthead { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 8px; }
.tdthead b { font-size: .92rem; font-weight: 650; }
.tdthead .tag { padding: 1px 6px; border: 1px solid #3d4959; border-radius: 6px; font-size: .66rem; color: #9fabb9; }
.tdthead .geo { color: #f2b84b; border-color: #5a4720; }
.tdthead .amb { font-size: .74rem; color: #9fabb9; }
.tdtopt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid #364254; border-radius: 0; background: none; color: #cbd5e1; font-size: .82rem; font-weight: 500; text-align: left; }
.tdtopt::before { content: ''; flex: none; width: 9px; height: 9px; box-sizing: border-box; border: 1.5px solid #6f7b8b; border-radius: 50%; }
.tdtopt .fmt { flex: 1; min-width: 0; font-weight: 650; }
.tdtopt:hover { color: #fff; }
.tdtopt:hover::before { border-color: #cbd5e1; }
.tdtopt.sel { color: var(--accent); }
.tdtopt.sel::before { border-color: var(--accent); background: var(--accent); }
.tdtact { display: flex; flex-direction: column; gap: 12px; flex: none; padding-top: 12px; border-top: 1px solid #303a47; }
.tdtact[hidden] { display: none; }
.tdtsel { font-size: .85rem; font-weight: 650; color: #edf2f7; }
.seg { display: flex; gap: 6px; }
.seg button { padding: 8px 6px; font-size: .8rem; font-weight: 600; background: #2a3441; color: #aeb9c8; border-radius: 8px; }
.seg button.on { background: var(--accent-bg); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tdtform { gap: 12px 14px; }
.tdtnew { grid-column: 1 / -1; gap: 12px 14px; }
.tdtnew[hidden], #tdtOldRow[hidden] { display: none; }
.tdtform.isnew #tdtLabelRow { grid-column: 1 / -1; }
#tdtMsg { min-height: 0; }
#tdtMsg:empty { display: none; }
