:root {
    --bg: #0f1115;
    --panel: #181c23;
    --panel-light: #222730;
    --text: #e4e6eb;
    --text-dim: #8b909a;
    --accent: #00d4ff;
    --accent-glow: rgba(0, 212, 255, 0.4);
    --danger: #ff4757;
    --border: #2a2f38;
    --green: #2ecc71;
    --yellow: #f1c40f;
    --pink: #ff4757;
    --trash: #9b59b6;
    --unavailable-text: #ff8a8a;
    --radius: 12px;
    --radius-sm: 6px;
    --space: 10px;
    --transition: 0.2s ease;
}

:root[data-theme="light"] {
    --bg: #f8f9fa;
    --panel: #ffffff;
    --panel-light: #f1f3f5;
    --text: #212529;
    --text-dim: #6c757d;
    --accent: #0096c7;
    --accent-glow: rgba(0, 150, 199, 0.2);
    --border: #dee2e6;
    --green: #27ae60;
    --yellow: #f39c12;
    --pink: #ff4757;
    --trash: #8e44ad;
    --unavailable-text: #c92a2a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-width: 300px;
    font-size: 13px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }
.logo-img {
    width: 32px; height: 32px; flex-shrink: 0;
    background-image: url('img/logo_100.png');
    background-size: contain; background-repeat: no-repeat; background-position: center;
    border-radius: 4px; cursor: pointer; user-select: none; -webkit-user-drag: none; pointer-events: auto;
    position: relative; /* Для центрирования цифр частоты */
}

.player-panel {
    display: none;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    flex: 1 1 0;
    min-width: 0;
    margin-left: 20px;
    margin-right: 10px;
    position: relative;
    overflow: hidden;
    padding: 4px 0;
}
.player-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; overflow: hidden; z-index: 3; }
.player-logo { width: 28px; height: 28px; border-radius: 4px; object-fit: contain; background: var(--panel-light); flex-shrink: 0; }
.player-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; overflow: hidden; width: 100%; }
.player-name { font-size: 12px; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }

.player-name:hover { color: var(--accent); }
.player-stream-info {
    background: none; border: none; color: var(--text-dim); font-size: 9px; cursor: default; padding: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
    display: block; width: 100%; text-decoration: none;
}
.player-stream-info.active-link {
    color: var(--accent); cursor: pointer;
}
.player-stream-info.active-link:hover { text-decoration: underline; }
.player-stream-info.active-link {
    color: var(--accent); cursor: pointer; pointer-events: auto;
}
.player-stream-info.active-link:hover { text-decoration: underline; }

.player-controls-vertical {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    gap: 2px; 
    height: 100%; 
    z-index: 3; 
    flex-shrink: 0;
}
.player-hint {
    font-size: 9px;
    color: var(--text-dim);
    height: 11px;
    line-height: 11px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.player-hint.show { opacity: 1; }
.player-controls-row {
    display: flex; gap: 4px;
}
.player-btn {
    background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
    width: 24px; height: 22px; position: relative;
}
.player-btn.loading svg { opacity: 0; }
.player-btn.loading::after {
    content: ''; position: absolute; width: 18px; height: 18px;
    top: 2px; left: 3px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
.player-btn-mini { width: 24px; height: 12px; opacity: 0.7; }
.player-btn-mini:hover { opacity: 1; }

.volume-slider {
    -webkit-appearance: none; 
    appearance: none;
    -moz-orient: vertical;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 8px; height: 32px; 
    background: var(--border); border-radius: 4px; 
    outline: none; cursor: pointer; z-index: 3; flex-shrink: 0;
    padding: 0; margin: 0;
    overflow: hidden;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 0; height: 0; 
    background: transparent; 
    cursor: pointer;
}
.volume-slider::-moz-range-thumb {
    width: 0; height: 0;
    background: transparent; cursor: pointer; border: none;
}
.volume-slider::-moz-range-track {
    width: 8px; height: 32px;
    background: transparent;
    border-radius: 4px;
}

.spectrum-canvas {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 18px; pointer-events: none; z-index: 1; opacity: 0.9;
}

.actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; z-index: 10; }
.content { flex: 1; padding: var(--space); display: flex; flex-direction: column; gap: var(--space); }

.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space); }
.control-panel { padding: 8px; background: var(--panel); }

.control-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.select-group { display: flex; gap: 6px; flex: 1 1 220px; min-width: 0; }
.input-group { display: flex; gap: 6px; flex: 1 1 180px; align-items: center; }

.select-wrapper { display: flex; gap: 4px; flex: 1 1 75%; min-width: 0; }
.select-wrapper select { flex: 1; }
.dropdown { position: relative; flex: 1 1 25%; min-width: 0; display: flex; }

input, select {
    background: var(--panel-light); border: 1px solid var(--border); color: var(--text);
    padding: 7px 9px; border-radius: var(--radius-sm); font-size: 13px; width: 100%; outline: none;
    transition: border-color var(--transition); -webkit-appearance: none; appearance: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; margin: 0; display: none;
}
input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
}
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

#minFreq, #maxFreq { flex: 2 1 50px; min-width: 45px; text-align: center; }
#bands, #presets { flex: 1.2 1 35px; min-width: 35px; text-align: center; padding-left: 4px; padding-right: 4px; }

.btn-icon {
    background: var(--panel-light); border: 1px solid var(--border); color: var(--text);
    height: 30px; min-width: 30px; padding: 0 4px; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover, .btn-icon:active { border-color: var(--accent); color: var(--accent); }
.btn-icon.mini { width: 30px; min-width: 30px; padding: 0; }
.btn-icon.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.btn-text {
    background: var(--panel-light); border: 1px solid var(--border); color: var(--text);
    height: 30px; width: 100%; padding: 0 6px; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 11px; display: flex; align-items: center; justify-content: center; transition: all var(--transition);
    text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px;
}
.btn-text:hover, .btn-text:active { border-color: var(--accent); color: var(--accent); }

.dropdown-menu {
    position: absolute; top: calc(100% + 4px); right: 0; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; z-index: 20;
    min-width: 100px; 
    display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.dropdown-menu.show { display: block; }
.dropdown-item { padding: 8px 10px; cursor: pointer; border-radius: var(--radius-sm); font-size: 13px; text-transform: uppercase; white-space: nowrap; }
.dropdown-item:hover { background: var(--panel-light); }

.content-wrapper { position: relative; display: flex; flex-direction: column; gap: var(--space); }

.bg-bandit {
    position: absolute; top: 0; right: 0; width: 100%; height: 100%; max-width: 460px; aspect-ratio: 3/2;
    background-image: url('img/bandit.png'); background-size: contain; background-repeat: no-repeat; background-position: top right;
    opacity: 0.01; transition: opacity 9s ease, z-index 0s linear 9s; pointer-events: none; z-index: 2;
}
#bgBandit.hovered { opacity: 1; z-index: 2000; transition: opacity 9s ease, z-index 0s linear 0s; }

.adapter-panel, .stations-panel { position: relative; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space); }

.fm-dial-wrapper {
    position: relative; height: 195px; margin: 0 4px 15px 4px; /* Увеличена высота */
    background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden; z-index: 4;
    flex-shrink: 0;
    display: flex; flex-direction: column;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.9), inset 0 -8px 20px var(--accent-glow);
    animation: tube-flicker 8s infinite steps(60);
}
.fm-dial-wrapper.controls-hidden {
    height: 120px; /* Канвас (84px) + строка дисплея (32px) */
}
/* Скрываем только панель с цифровыми кнопками, строка с дисплеем остается видимой */
.fm-dial-wrapper.controls-hidden .dial-presets {
    display: none;
}

/* Ряд дисплея, встроенный в шкалу */
.dial-display-row {
    height: 32px; display: flex; align-items: center; padding: 0 8px; gap: 8px;
    flex-shrink: 0; background: transparent;
}
.dial-display-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.dial-player-logo { 
    width: 24px; height: 24px; border-radius: 4px; 
    background: var(--bg); flex-shrink: 0; 
    display: flex; align-items: center; justify-content: center;
    font-family: 'Orbitron', monospace; font-size: 9px; font-weight: bold; color: var(--accent);
}
.dial-player-logo img { width: 100%; height: 100%; border-radius: 4px; object-fit: contain; }
.dial-marquee-container {
    position: relative; flex: 1; overflow: hidden; height: 24px; border: 1px solid var(--accent);
    border-radius: 4px; background: var(--accent); display: flex; align-items: center;
    cursor: pointer; flex-shrink: 1; min-width: 50px;
    box-shadow: 0 0 2px var(--accent), 3px 3px 6px var(--accent-glow), -1px -1px 2px var(--accent-glow);
    animation: neon-flicker 8s infinite steps(60);
}
.dial-marquee {
    white-space: nowrap; font-family: 'Orbitron', monospace; font-size: 11px; font-weight: bold;
    color: var(--bg); text-shadow: 0 0 2px rgba(0,0,0,0.5); padding-left: 8px;
    box-sizing: border-box;
    display: inline-block; /* Позволяет занимать только ширину контента */
}
.dial-marquee.scroll-active {
    padding-left: 0;
    animation: scroll-text 20s linear infinite;
}
@keyframes scroll-text {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } /* Сдвиг ровно на половину задвоенного текста */
}

/* Меню выбора потока (поведение как у тултипа) */
.stream-menu {
    position: fixed; 
    transform: translate(-50%, -100%); /* Центрируем и поднимаем над кнопкой */
    min-width: 180px; max-height: 200px; overflow-y: auto; 
    z-index: 2000; background: var(--panel); border: 1px solid var(--border); 
    border-radius: var(--radius-sm); padding: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; gap: 2px;
    margin-bottom: 8px; /* Отступ от кнопки */
}
.stream-item { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; font-size: 13px; border-radius: 4px; cursor: pointer; }
.stream-item:hover { background: var(--panel-light); }
.stream-item.current { background: var(--accent); color: var(--bg); }
.stream-item.disabled { 
    color: var(--text-dim); 
    opacity: 0.5; 
    pointer-events: none; 
    text-decoration: line-through;
}
.stream-item .stream-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.stream-item .stream-info { font-size: 11px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Контролы в строке дисплея (повышенная специфичность для гарантии размера) */
.dial-display-row .fm-dial-controls { 
    display: flex; gap: 4px; align-items: center; flex-shrink: 0; position: static !important;
}
.dial-display-row .fm-dial-controls .chip-btn.control-chip { 
    height: 16px !important; min-width: 16px !important; width: 16px !important; padding: 0 !important;
    border-radius: 4px !important; 
}
.dial-display-row .fm-dial-controls .chip-btn.control-chip svg { width: 9px !important; height: 9px !important; }

/* Меню выбора потока */
.stream-menu { min-width: 200px; max-height: 250px; overflow-y: auto; right: auto; left: 50%; transform: translateX(-50%); top: 100%; }
.stream-item { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; border-radius: 4px; cursor: pointer; }
.stream-item:hover { background: var(--panel-light); }
.stream-item.current { background: var(--accent); color: var(--bg); }
.stream-item .stream-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-item .stream-info { font-size: 9px; opacity: 0.8; }
@keyframes tube-flicker {
    0% { opacity: 1; }
    70% { opacity: 1; }
    72% { opacity: 0.85; }
    74% { opacity: 1; }
    100% { opacity: 1; }
}
.fm-dial-controls { position: absolute; top: 6px; right: 6px; z-index: 10; display: flex; gap: 4px; }
.fm-dial-controls .chip-btn.control-chip { 
    width: 24px; height: 24px; min-width: 24px; padding: 0; 
    background: linear-gradient(180deg, var(--panel-light) 0%, var(--bg) 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}
#fmDialCanvas { width: 100%; height: 84px; display: block; cursor: pointer; }

.dial-presets {
    position: absolute; bottom: 0; left: 0; right: 0; height: 76px;
    display: flex; align-items: stretch; gap: 8px;
    padding: 4px 8px; 
    background: var(--bg); /* Фон как у шкалы */
    /* Эффект свечения вдоль периметра (только снизу и по бокам) */
    box-shadow: inset 0 0 15px var(--border), inset 0 -8px 20px var(--accent-glow);
}
.dial-knob-wrap {
    width: 70px; height: 100%; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#dialKnob { width: 64px; height: 64px; cursor: ns-resize; }
.dial-right-area {
    flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-width: 0;
}
.dial-row {
    display: flex; align-items: center; gap: 4px; height: 28px;
    overflow: hidden; scrollbar-width: none;
}
.dial-row::-webkit-scrollbar { display: none; }
.dial-row-top { flex-shrink: 0; }
.dial-row-presets {
    flex-wrap: wrap; height: 40px; align-content: flex-start;
}
.dial-spacer { flex: 1; }

.chip-btn {
    position: relative;
    height: 16px; min-width: 16px; padding: 0 2px;
    border: 1px solid transparent; /* Убрали старый контур */
    border-radius: 4px; 
    background: var(--bg); /* Фон, адаптивный под тему */
    color: var(--text-dim); 
    cursor: pointer; 
    font-family: 'Orbitron', monospace; font-size: 8px; font-weight: bold;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all 0.1s; user-select: none;
    overflow: visible;
    z-index: 1;
}
/* Эффект мерцающего неонового свечения (2 пикселя) */
.chip-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    box-shadow: 0 0 2px var(--accent);
    opacity: 0.8;
    animation: neon-flicker 8s infinite steps(60);
    pointer-events: none;
    z-index: -1;
}
@keyframes neon-flicker {
    0%, 100% { opacity: 0.7; box-shadow: 0 0 2px var(--accent); }
    50% { opacity: 1; box-shadow: 0 0 4px var(--accent); }
    52% { opacity: 0.6; box-shadow: 0 0 1px var(--accent); }
    54% { opacity: 1; box-shadow: 0 0 3px var(--accent); }
}

.chip-btn:hover { color: var(--accent); }
.chip-btn.band-chip { 
    font-size: 7px; 
    min-width: 14px; 
    padding: 0 2px;
}
.chip-btn.band-chip.active { color: var(--accent); }

.chip-btn.control-chip { 
    padding: 0;
    width: 16px; height: 16px;
}
.chip-btn.control-chip svg { width: 9px; height: 9px; }

.chip-btn.occupied {
    color: var(--accent); 
}
.chip-btn.assigned-active { 
    background: var(--accent); color: var(--bg); 
    box-shadow: 0 0 4px var(--accent);
}
.chip-btn.assigned-active::after {
    opacity: 1; animation: none; box-shadow: 0 0 4px var(--accent);
}
.chip-btn.disabled {
    color: #5a7d99;
    opacity: 0.7;
}
.chip-btn.status-chip.assigned-active { 
    background: transparent; 
    color: var(--accent); 
}
.chip-btn.status-chip { font-size: 10px; }

/* 2 ряд кнопок (пресеты) */
.dial-row-presets .chip-btn {
    height: 16px; min-width: 16px; font-size: 8px; padding: 0 2px;
}
.dial-row-presets .chip-btn.control-chip {
    height: 16px; min-width: 16px; width: 16px;
}
.dial-row-presets .chip-btn.control-chip svg { width: 9px; height: 9px; }

.dial-tooltip {
    position: fixed; transform: translate(-50%, -100%);
    background: var(--panel); 
    border: 1px solid var(--accent);
    box-shadow: 0 0 15px var(--accent), inset 0 0 10px var(--accent-glow);
    padding: 8px 12px; border-radius: 6px;
    display: flex; align-items: center; gap: 8px;
    opacity: 0; transition: opacity 0.2s; pointer-events: none;
    z-index: 1000; max-width: 220px;
}
.dial-freq {
    font-family: 'Orbitron', monospace; font-weight: bold;
    color: var(--accent); font-size: 14px;
    text-shadow: 0 0 6px var(--accent); margin-bottom: 2px;
}
.dial-tooltip img { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.dial-tooltip .dial-name { 
    font-size: 12px; font-weight: bold; color: var(--accent); 
    text-shadow: 0 0 4px var(--accent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; 
}
.dial-tooltip .dial-tags { 
    font-size: 10px; color: var(--text-dim); 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; 
}

.fm-dial-container {
    position: relative; height: 80px; margin: 0 4px 10px 4px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0 15px; overflow: hidden; z-index: 4;
}
.fm-dial-controls { position: absolute; top: 5px; right: 10px; z-index: 10; }
.fm-dial-scale { position: relative; width: 100%; height: 100%; margin-top: 20px; border-bottom: 2px solid var(--border); }
.fm-dial-tick { position: absolute; bottom: 0; width: 1px; height: 8px; background: var(--text-dim); cursor: pointer; transition: height 0.1s; }
.fm-dial-tick:hover { height: 14px; background: var(--accent); z-index: 5; }
.fm-dial-tick.fav { height: 12px; width: 2px; background: var(--pink); }
.fm-dial-tick.cand { height: 12px; width: 2px; background: var(--yellow); }
.fm-dial-label {
    position: absolute; font-size: 10px; color: var(--text-dim);
    transform: translateX(-50%); white-space: nowrap; cursor: pointer; background: var(--panel); padding: 0 2px;
}
.fm-dial-label.fav { color: var(--pink); font-weight: bold; }
.fm-dial-label.cand { color: var(--yellow); font-weight: bold; }
.fm-dial-indicator {
    position: absolute; top: 10px; bottom: 0; width: 2px; background: var(--accent);
    box-shadow: 0 0 8px var(--accent); pointer-events: none; transition: left 0.3s ease; opacity: 0; z-index: 6;
}
.adapter-panel::before, .stations-panel::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(24, 28, 35, 0.85); border-radius: var(--radius); z-index: 1; pointer-events: none; }
:root[data-theme="light"] .adapter-panel::before, :root[data-theme="light"] .stations-panel::before { background: rgba(255, 255, 255, 0.92); }
.adapter-panel > *, .stations-panel > * { position: relative; z-index: 3; }

.adapter-panel { padding: 8px 10px; }
.panel-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; display: flex; align-items: center; }

.hover-trigger { position: absolute; top: 0; right: 0; width: 80px; height: 100%; z-index: 2; cursor: help; }
.adapter-panel .hover-trigger { z-index: 1; }
.adapter-panel .chips-container { z-index: 2; pointer-events: none; }
.adapter-panel .chip { z-index: 3; pointer-events: auto; }

.chips-container { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
    padding: 4px 8px; border-radius: 12px; background: var(--panel-light); border: 1px solid var(--border); cursor: pointer;
    white-space: nowrap; font-weight: 500; font-family: inherit; font-size: 12px; color: var(--text); transition: all var(--transition);
    display: flex; align-items: center; position: relative;
}
.chip:hover { border-color: var(--accent); }
.chip.active { border-width: 2px; font-weight: bold; padding: 3px 7px; }
.chip.full { border-color: var(--text); color: var(--text); }
.chip.full.active { background: var(--text); color: var(--bg); }
.chip.none { border-color: var(--pink); color: var(--pink); opacity: 0.6; }
.chip.none.active { background: var(--pink); color: var(--bg); }
.chip.best { border-color: var(--green); color: var(--green); }
.chip.best.active { background: var(--green); color: var(--bg); box-shadow: 0 0 10px rgba(46, 204, 113, 0.4); }

.stations-header { display: flex; align-items: center; padding: 0 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 2px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
.col-freq { width: 45px; flex-shrink: 0; }
.col-status { width: 45px; text-align: center; margin-left: 4px; margin-right: 4px; position: relative; flex-shrink: 0; }
.col-name { flex: 1; margin-left: 8px; min-width: 0; }
.col-shifted { width: 45px; text-align: right; flex-shrink: 0; }

.station-item { display: flex; align-items: center; padding: 3px 4px; border-radius: var(--radius-sm); transition: background var(--transition); position: relative; }
.station-item:hover { background: var(--panel-light); }
.station-item.trash { opacity: 1; }

/* Микро-индикаторы источника данных */
.station-item::before { content: ''; position: absolute; left: 0; top: 5%; bottom: 5%; width: 2px; border-radius: 2px; opacity: 0; transition: opacity 0.5s; }
.station-item[data-source="api"]::before { background: var(--accent); animation: pulse-indicator 2s ease-out; }
.station-item[data-source="backup"]::before { background: var(--green); animation: pulse-indicator 2s ease-out; }
.station-item[data-source="cache"]::before { background: var(--text-dim); animation: pulse-indicator 2s ease-out; }
@keyframes pulse-indicator { 0% { opacity: 1; } 100% { opacity: 0; } }

.freq { font-family: 'Courier New', monospace; font-weight: 600; width: 45px; font-size: 12px; color: var(--text); flex-shrink: 0; padding-left: 4px; }

.status-cell { display: flex; flex-direction: row; align-items: center; justify-content: center; width: 45px; margin: 0 4px; gap: 2px; flex-shrink: 0; }
.status-icon { cursor: pointer; font-size: 14px; color: var(--text-dim); user-select: none; line-height: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 14px; min-height: 14px; }
.status-icon.normal { font-size: 7px; opacity: 0.6; }
.status-icon.fav { color: var(--pink); }
.status-icon.cand { color: var(--yellow); }
.status-icon.trash { color: var(--text-dim); opacity: 0.7; }

.preset-dropdown { position: relative; width: auto; }
.preset-btn { background: var(--panel-light); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; color: var(--text); padding: 1px 2px; font-size: 10px; width: auto; min-width: 16px; text-align: center; }
.preset-btn:hover { border-color: var(--accent); }
.preset-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.preset-menu { min-width: 220px; max-height: 250px; overflow-y: auto; right: auto; left: 50%; transform: translateX(-50%); top: 100%; padding: 4px; }
.preset-item { display: flex; gap: 8px; align-items: center; padding: 4px 8px; font-size: 11px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.preset-item:hover { background: var(--panel-light); }
.preset-item.occupied { color: var(--text-dim); font-style: italic; }
.preset-item.current { background: var(--accent); color: var(--bg); font-style: normal; }
.preset-num { flex-shrink: 0; font-weight: bold; }
.preset-name { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.preset-clear { color: var(--pink); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; justify-content: center; }

.station-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden; /* Обрезает картинку ровно по кругу */
    flex-shrink: 0;
    margin-left: 2px;
    margin-right: 6px;
    background: transparent;
}
.station-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Вписывает картинку без искажений */
}
.name { display: flex; align-items: center; flex: 1; margin-left: 8px; min-width: 0; gap: 8px; }
.name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text); cursor: pointer; flex: 1 1 auto; min-width: 0; }
.tags { font-size: 10px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 100px; min-width: 0; text-align: right; }

.play-btn-row {
    display: flex; opacity: 0.2; background: transparent; border: 1px solid var(--accent); border-radius: 50%;
    width: 16px; height: 16px; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
    margin-left: auto; color: var(--accent); transition: opacity 0.2s;
}
.station-item:hover .play-btn-row:not(.hidden) { opacity: 0.8; }
.play-btn-row.active { opacity: 1; border: 1px solid var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.play-btn-row.active svg { fill: var(--accent); }
.play-btn-row.hidden { visibility: hidden; pointer-events: none; }

.shifted-freq { width: 45px; text-align: right; font-family: 'Courier New', monospace; font-weight: 600; font-size: 12px; color: var(--text); flex-shrink: 0; }

.station-item.unavailable:not(.trash) .freq, 
.station-item.unavailable:not(.trash) .name-text { color: var(--unavailable-text); opacity: 0.9; }
.station-item.unavailable.trash .freq, 
.station-item.unavailable.trash .name-text { color: #a07070; opacity: 0.8; }
.station-item .shifted-freq.ok { color: var(--green); }
.station-item .shifted-freq.err { color: var(--pink); opacity: 0.8; }

.station-item.trash:not(.unavailable) .freq, 
.station-item.trash:not(.unavailable) .name-text { color: var(--text-dim); opacity: 0.7; }

body.player-mode .station-item.unavailable:not(.trash) .freq, 
body.player-mode .station-item.unavailable:not(.trash) .name-text { color: var(--text); opacity: 1; }
body.player-mode .station-item.trash .freq, 
body.player-mode .station-item.trash .name-text { color: var(--text-dim); opacity: 0.7; }

.error-msg { color: var(--danger); font-size: 14px; text-align: center; padding: 20px 0; display: none; }
.loading-msg { color: var(--text-dim); font-size: 14px; text-align: center; padding: 20px 0; }

.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 100; align-items: center; justify-content: center; padding: 10px; }
.modal.show { display: flex; }
.modal-content { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-width: 360px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h2 { font-size: 16px; }
.btn-close { background: transparent; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; line-height: 1; }
.intro { margin-bottom: 12px; font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.manual { padding-left: 20px; line-height: 1.5; font-size: 13px; }
.manual ul { padding-left: 20px; margin-top: 4px; }
.manual li { margin-bottom: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; box-sizing: border-box; }
.dot.best { background: var(--green); }
.dot.full { background: #ffffff; border: 1px solid #000000; }
.dot.partial-grad { background: linear-gradient(135deg, var(--yellow), var(--pink)); }
.dot.none { background: var(--pink); }

.repo-link { margin-top: 16px; text-align: center; font-size: 12px; }
.repo-link a, .intro a { color: var(--accent); text-decoration: none; }
.repo-link a:hover, .intro a:hover { text-decoration: underline; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 20px; font-size: 13px; z-index: 2000; opacity: 0; transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.second-row-test { display: none; }
#mobilePlayerControls { display: none; }
.mobile-volume-slider {
    -webkit-appearance: none; appearance: none;
    width: 64px; height: 16px; background: var(--border); border-radius: 8px;
    outline: none; cursor: pointer; flex-shrink: 0; padding: 0; margin-left: 12px;
}
.mobile-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 0; height: 0; background: transparent;
}
.mobile-volume-slider::-moz-range-thumb {
    width: 0; height: 0; background: transparent; border: none;
}
.mobile-volume-slider::-moz-range-track {
    width: 64px; height: 16px; background: transparent; border-radius: 8px;
}
body.player-mode .input-group { display: none !important; }
body.player-mode #downloadBtn { display: none !important; }
body.player-mode .select-group > .dropdown { display: none !important; }
body.player-mode #transferBtn { display: none !important; }
body.player-mode #adapterPanel { display: none !important; }
body.player-mode .col-shifted { display: none !important; }
body.player-mode .shifted-freq { display: none !important; }
body.player-mode .preset-dropdown { display: none !important; }

/* Custom Select */
.custom-select { position: relative; flex: 1 1 120px; min-width: 100px; }
.custom-select-trigger {
    background: var(--panel-light); border: 1px solid var(--border); color: var(--text);
    padding: 7px 9px; border-radius: var(--radius-sm); font-size: 13px; width: 100%; outline: none;
    transition: border-color var(--transition); -webkit-appearance: none; appearance: none; min-width: 0;
    cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.custom-select-trigger:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.custom-select-menu {
    position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: calc(100vw - 20px); background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; z-index: 20;
    max-height: 300px; overflow-y: auto; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.custom-select-menu.show { display: block; }
.custom-select-option {
    display: flex; justify-content: space-between; align-items: center; gap: 15px;
    padding: 3px 8px; cursor: pointer; border-radius: var(--radius-sm); font-size: 13px;
    white-space: nowrap;
}
.custom-select-option:hover { background: var(--panel-light); }
.custom-select-option.active { background: var(--accent); color: var(--bg); font-weight: bold; }
.custom-select-option .city-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.custom-select-option .city-stats { flex-shrink: 0; text-align: right; }

/* Mobile Menu & Checkboxes */
.app-header .actions .dropdown { flex: 0 0 auto; }
#menuBtnWrapper { display: none; }
/* Default UI Scale 150% for large screens */
@media (min-width: 721px) {
    .app-container, #loadingModal, #toast {
        zoom: 1.5;
    }
    .app-container .modal {
        zoom: 0.6666; 
    }
    .app-container .modal-content {
        zoom: 1.5; 
        max-width: 540px; /* 360px * 1.5 scale */
        max-height: 53vh; 
    }
}

/* Mobile UI Scale 120% */
@media (max-width: 420px) {
    .app-container, #toast { zoom: 1.2; }
    .app-container { max-width: 325px; } /* 325px * 1.2 = ~390px (fits most screens) */
    #loadingModal { zoom: 1.2; }
    .app-container .modal { zoom: 0.8333; } 
    .app-container .modal-content { 
        zoom: 1.2; 
        max-width: 430px; /* 360px * 1.2 scale */
        max-height: 66vh; 
    } 
    
    .app-header { flex-wrap: wrap; justify-content: space-between; }
    .app-header > *:not(#mobilePlayerControls) { flex-shrink: 0; }
    
    .app-header .actions { flex: 0 0 auto; }
    .app-header .actions > *:not(#menuBtnWrapper) { display: none !important; }
    #menuBtnWrapper { display: block !important; }
    .player-panel { 
        flex: 1 1 0; 
        min-width: 0; 
        overflow: hidden;
        margin: 0 8px;
        justify-content: flex-start;
    }
    .player-info { flex: 1 1 0; min-width: 0; }
    .player-text { width: auto; min-width: 0; }
    .player-logo { display: none; }
    .player-controls-vertical { display: none; }
    .volume-slider { display: none; }

    #mobilePlayerControls.show {
        display: flex;
        flex: 1 1 100%;
        justify-content: center;
        align-items: center;
        gap: 6px;
        margin-top: 8px;
    }
    #mobilePlayerControls .player-btn {
        width: 30px;
        min-width: 30px;
        height: 30px;
        background: var(--panel-light);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .stations-header { display: none; }
    .station-item {
        display: grid;
        grid-template-columns: auto auto 1fr auto auto;
        grid-template-rows: auto auto;
        column-gap: 8px;
        row-gap: 6px;
        padding: 8px 4px;
        border-bottom: 1px solid var(--border);
        align-items: center;
    }
    
        /* Logo - Col 1, Rows 1-2 */
        .station-item .station-logo { display: flex; align-items: center; justify-content: center; grid-row: 1 / 3; grid-column: 1; width: 40px; height: 40px; align-self: center; }    

    /* Row 1 */
    .station-item .freq { grid-row: 1; grid-column: 2; }
    .station-item .name { display: contents; }
    .station-item .name-text { grid-row: 1; grid-column: 3 / 6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-left: 0; }

    /* Row 2 */
    .station-item .status-cell { grid-row: 2; grid-column: 2; width: auto; margin: 0; display: flex; align-items: center; gap: 12px; }
    .station-item .tags { grid-row: 2; grid-column: 3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 5ch; margin: 0; text-align: left; }
    .station-item .shifted-freq { grid-row: 2; grid-column: 4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 5ch; text-align: right; }
    
    /* Play Btn - Col 5, Row 2 */
    .station-item .play-btn-row { grid-row: 2; grid-column: 5; margin-left: 8px; opacity: 0.8; align-self: center; }
}


.checkbox-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; user-select: none; }
.checkbox-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox-custom { width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-light); display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.checkbox-wrap input:checked + .checkbox-custom { background: var(--accent); border-color: var(--accent); }
.checkbox-wrap input:checked + .checkbox-custom::after { content: '✓'; color: var(--bg); font-size: 14px; font-weight: bold; line-height: 1; }

.export-city-item { padding: 8px; border-bottom: 1px solid var(--border); }
.export-city-item:last-child { border-bottom: none; }

/* Loading Modal */
#loadingModal { background: rgba(0,0,0,0.85); z-index: 3000; }
#loadingModal .modal-content { border: none; background: transparent; box-shadow: none; text-align: center; max-width: 200px; }
.spinner { border: 4px solid var(--panel-light); border-top: 4px solid var(--accent); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Touchscreen UI Enhancements */
@media (hover: none) and (pointer: coarse) {
    #minFreq, #maxFreq, #bands, #presets {
        touch-action: none;
    }
    .select-group, .input-group {
        min-width: 0;
    }
    .input-group {
        flex: 1 1 100%; /* Перенос на новую строку */
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .hover-trigger { display: none; }
    .col-status { width: 70px; }
    .status-cell { width: 70px; gap: 8px; }
    .status-icon { font-size: 22px; padding: 4px; min-width: 22px; min-height: 22px; }
    .status-icon.normal { font-size: 11px; }
    .preset-btn { font-size: 14px; padding: 4px 8px; min-width: 30px; }
    .preset-menu { min-width: 280px; max-height: 300px; }
    .preset-item { font-size: 14px; padding: 8px 12px; }
    .preset-num { font-size: 16px; }
    .preset-name { font-size: 14px; }
    .name-text { font-size: 14px; }
    .freq, .shifted-freq { font-size: 14px; }
    .chip { font-size: 14px; padding: 6px 12px; }
    .btn-icon { width: 40px; height: 40px; min-width: 40px; }
    .btn-icon.mini { width: 30px; min-width: 30px; height: 40px; }
    .btn-text { height: 40px; font-size: 13px; }
    input, select, .custom-select-trigger { font-size: 15px; padding: 10px 12px; height: 40px; }
    #bands, #presets { padding: 10px 4px; flex: 1 1 30px; min-width: 30px; }
    .station-item { padding: 6px 4px; }
    .play-btn-row { opacity: 0.8; }
} 

/* === ИНДИКАТОР ЗАГРУЗКИ ПОТОКА === */
.player-btn { position: relative; }

#playerPlayBtn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30px; height: 30px;
    border: 2px solid var(--text-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    pointer-events: none;
    z-index: 5;
}

.player-loading-hint {
    position: absolute;
    top: 100%; right: 10px;
    margin-top: 2px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
    pointer-events: none;
}
.player-loading-hint.show { display: block; }

/* Эффект электронной лампы для частоты в шапке */
.header-freq {
    position: absolute; top: -3px; left: 50%; transform: translateX(-50%);
    display: none; 
    font-family: 'Orbitron', monospace; font-weight: 700; font-size: 10px;
    color: var(--accent); text-shadow: 0 0 6px var(--accent), 0 0 12px var(--accent-glow);
    background: var(--panel-light); 
    opacity: 0.85;
    padding: 1px 4px; 
    border-radius: 4px;
    pointer-events: none; z-index: 10; white-space: nowrap;
}