/* ==========================================================================
   RX-WEBSDR ua6eh — мобильный клиент (m.html)
   Отдельный файл: ПК-стили (rx-websdr-redesign.css) не используются и не
   переопределяются. Палитра станции: тёмный #0a0d14, neon-blue / neon-green.
   ========================================================================== */

:root {
    --m-bg: #0a0d14;
    --m-bg-2: #0e131d;
    --m-panel: #121926;
    --m-panel-2: #0d1420;
    --m-border: #253247;
    --m-border-soft: #1a2434;
    --m-text: #c8d3e6;
    --m-dim: #74839a;
    --m-blue: #3ea6ff;
    --m-green: #39ff14;
    --m-amber: #ffb020;
    --m-red: #ff4444;
    --m-mono: "Share Tech Mono", "Courier New", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    background: var(--m-bg);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 50% -160px, rgba(62,166,255,0.10), transparent 70%),
        var(--m-bg);
    color: var(--m-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.35;
    -webkit-tap-highlight-color: transparent;
}

button, input, select { font-family: inherit; }
button { -webkit-appearance: none; appearance: none; }

.m-hidden-system { display: none !important; }

.m-app {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
}

/* ------------------------------ Шапка ---------------------------------- */
.m-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: linear-gradient(180deg, #1b2434 0%, #0e1521 100%);
    border: 1px solid var(--m-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 6px 18px rgba(0,0,0,0.35);
}

.m-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.m-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 7px;
    border: 1px solid rgba(62,166,255,0.55);
    background: rgba(62,166,255,0.08);
    color: var(--m-blue);
    font-family: var(--m-mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(62,166,255,0.7);
}

.m-brand-text { min-width: 0; }
.m-brand-text b {
    display: block;
    color: #fff;
    font-size: 14px;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.m-brand-text b span { color: var(--m-blue); }
.m-brand-text small {
    display: block;
    color: var(--m-dim);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-brand-text small a { color: var(--m-green); text-decoration: none; }

.m-pc-link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid rgba(62,166,255,0.35);
    border-radius: 5px;
    background: rgba(62,166,255,0.06);
    color: var(--m-blue);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ----------------------------- Панели ---------------------------------- */
.m-form { margin: 0; }

.m-panel {
    margin-bottom: 8px;
    padding: 9px;
    background: linear-gradient(180deg, #151d2b 0%, #0e1521 100%);
    border: 1px solid var(--m-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 3px 8px rgba(0,0,0,0.35);
}

.m-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    color: var(--m-dim);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* --------------------------- Диапазоны --------------------------------- */
#bandbuttons,
.m-bands {
    display: flex !important;
    flex-wrap: wrap;
    gap: 5px;
    text-align: left;
}
#bandbuttons br { display: none !important; }

#bandbuttons .btnBand,
#bandbuttons button {
    flex: 1 1 calc(33.333% - 5px);
    min-width: 62px;
    min-height: 38px;
    margin: 0;
    padding: 7px 4px;
    border: 1px solid #31405a;
    border-top-color: #435778;
    border-radius: 5px;
    background: linear-gradient(180deg, #29354a 0%, #182131 100%);
    color: var(--m-text);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}
#bandbuttons .btnBand:active,
#bandbuttons button:active,
#bandbuttons .btn-selected {
    background: #08111b;
    border-color: var(--m-blue);
    color: var(--m-blue);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8), 0 0 8px rgba(62,166,255,0.25);
}

/* ------------------------ Водопад и ось частот ------------------------- */
.m-wfwrap {
    position: relative;
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: #000;
    border: 1px solid #1d2a3c;
    border-radius: 5px;
}

#wfccontainer,
#wfccontainer_inner,
#wfcontainer,
#waterfalls {
    width: 1024px;
}

#wfccontainer {
    transform-origin: 0 0;
    will-change: transform;
}

#wfcontainer {
    position: relative;
    overflow: hidden;
}

#wfdiv0 {
    width: 1024px;
    overflow: hidden;
}

#waterfalls canvas.html5waterfall {
    display: block;
    width: 1024px;
    max-width: none;
}

/* Шкалы-картинки, чёрная полоса и DX-метки ядра на телефоне не нужны. */
#waterfalls .scale,
#waterfalls [id^="blackbar"],
#waterfalls .hideblind {
    display: none !important;
}

.m-passband {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.m-filter {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    background: rgba(255, 176, 32, 0.14);
    border-left: 1px solid rgba(255, 176, 32, 0.55);
    border-right: 1px solid rgba(255, 176, 32, 0.55);
}

.m-carrier-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(255, 176, 32, 0.85);
    box-shadow: 0 0 6px rgba(255, 176, 32, 0.45);
}

.m-axis {
    display: block;
    width: 100%;
    height: 24px;
    margin-top: 2px;
    border-radius: 3px;
}

.m-wf-touch {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: crosshair;
    touch-action: none;
}

.m-wf-tools {
    display: flex;
    gap: 5px;
    margin-top: 7px;
}
.m-wf-btn {
    flex: 1 1 0;
    min-height: 34px;
    padding: 6px 4px;
    border: 1px solid #2d3b52;
    border-radius: 4px;
    background: #121a27;
    color: var(--m-text);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    cursor: pointer;
}
.m-wf-btn:active {
    background: #05080d;
    border-color: var(--m-blue);
    color: var(--m-blue);
}

/* ------------------------- Частота и модуляция -------------------------- */
.m-freqrow {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    background: #05080d;
    border: 1px solid var(--m-border);
    border-radius: 6px;
    box-shadow: inset 0 3px 9px rgba(0,0,0,0.85);
}

#freq-digits,
.m-freq {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--m-blue);
    font-family: var(--m-mono);
    font-size: 31px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-align: center;
    text-shadow: 0 0 9px rgba(62,166,255,0.45);
    font-variant-numeric: tabular-nums;
}
#freq-digits:focus { color: #fff; text-shadow: 0 0 9px rgba(255,255,255,0.65); }

.m-freq-unit {
    flex: 0 0 auto;
    color: var(--m-dim);
    font-family: var(--m-mono);
    font-size: 11px;
    letter-spacing: 0.4px;
}

.m-mode-row {
    display: flex;
    gap: 5px;
    margin-top: 7px;
    margin-bottom: 6px;
}
.m-mode-btn {
    flex: 1 1 0;
    min-height: 38px;
    padding: 7px 2px;
    border: 1px solid #31405a;
    border-radius: 5px;
    background: linear-gradient(180deg, #29354a 0%, #182131 100%);
    color: var(--m-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
}
.m-mode-btn:active,
.m-mode-btn.btn-selected {
    background: #071019;
    border-color: var(--m-green);
    color: var(--m-green);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8), 0 0 8px rgba(57,255,20,0.22);
}

.m-step-row { display: flex; gap: 4px; }
.m-step {
    flex: 1 1 0;
    min-height: 34px;
    padding: 5px 1px;
    border: 1px solid #2a374c;
    border-radius: 4px;
    background: #121a27;
    color: var(--m-text);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.m-step:active { background: #05080d; color: var(--m-blue); }
.m-step-zero { color: var(--m-amber); }

/* ------------------------------- S-метр --------------------------------- */
.m-smeter-panel { padding: 6px 9px; }

.m-smeter {
    display: flex;
    align-items: center;
    gap: 9px;
}

.m-smeter-s {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-start;
    min-width: 42px;
    color: var(--m-green);
    font-family: var(--m-mono);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 6px rgba(57,255,20,0.4);
}
#smeterSplus {
    margin-left: 1px;
    color: var(--m-red);
    font-size: 12px;
    white-space: nowrap;
}

.smeter-track {
    position: relative;
    flex: 1 1 auto;
    height: 9px;
    background: #05070a;
    border: 1px solid #1f2733;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.9);
}
.smeter-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #00d2ff 0%, #39ff14 55%, #ffaa00 80%, #f43f5e 100%);
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.12s linear;
}
.smeter-peak-mark {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ff003c;
    box-shadow: 0 0 6px #ff003c;
    transform: translateX(-50%);
    transition: left 0.2s linear;
}
.smeter-mute {
    position: absolute;
    top: 0;
    right: 3px;
    display: none;
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ff4444;
    text-shadow: 0 0 4px rgba(255,0,60,0.5);
}
.smeter-track.muted .smeter-mute { display: block; }
.smeter-track.muted .smeter-gradient,
.smeter-track.muted .smeter-peak-mark { opacity: 0.45; }

/* ------------------------------ Звук ----------------------------------- */
.m-audio-row { display: flex; gap: 5px; }
.m-ctrl {
    flex: 1 1 0;
    min-height: 40px;
    padding: 7px 4px;
    border: 1px solid #31405a;
    border-radius: 5px;
    background: linear-gradient(180deg, #29354a 0%, #182131 100%);
    color: var(--m-text);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}
.m-ctrl:active,
.m-ctrl.on {
    background: #071019;
    border-color: var(--m-green);
    color: var(--m-green);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}
.m-ctrl-audio { color: var(--m-blue); border-color: rgba(62,166,255,0.4); }
.m-ctrl-audio:active { color: var(--m-blue); border-color: var(--m-blue); }

.m-volrow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 7px 8px;
    background: rgba(0,0,0,0.25);
    border: 1px solid #1a2433;
    border-radius: 5px;
}
.m-vol-icon { color: var(--m-dim); font-size: 9px; font-weight: 700; letter-spacing: 0.5px; }
.m-vol {
    flex: 1 1 auto;
    width: 100%;
    height: 22px;
    margin: 0;
    accent-color: var(--m-blue);
    background: transparent;
}
.m-vol-db {
    min-width: 44px;
    color: var(--m-blue);
    font-family: var(--m-mono);
    font-size: 12px;
    text-align: right;
}

.m-sql-mask {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    color: var(--m-dim);
    font-size: 10px;
}
.m-sql-mask input { flex: 1 1 auto; accent-color: var(--m-amber); }
#m-sql-db { color: var(--m-amber); font-family: var(--m-mono); font-size: 10px; }
.hiddencontrol { display: none !important; }

/* ---------------------------- Оптимизация ------------------------------ */
.m-opt-row { display: flex; gap: 5px; }
.m-opt {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 42px;
    padding: 5px 3px;
    border: 1px solid #31405a;
    border-radius: 5px;
    background: linear-gradient(180deg, #29354a 0%, #182131 100%);
    color: var(--m-text);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer;
}
.m-opt b {
    color: var(--m-dim);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.m-opt.on {
    border-color: rgba(57,255,20,0.55);
    color: var(--m-green);
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.6), 0 0 7px rgba(57,255,20,0.15);
}
.m-opt.on b { color: var(--m-green); }

/* ------------------------------- Подвал --------------------------------- */
.m-foot {
    margin-top: 10px;
    padding: 12px 8px;
    text-align: center;
    border-top: 1px solid #1a2433;
    color: var(--m-dim);
    font-size: 10px;
}
.m-pc-link-wide { width: 100%; max-width: 280px; margin: 0 auto 9px; min-height: 38px; }
.m-foot-note { margin-top: 3px; }
.m-foot-dim { color: #4a576b; font-size: 9px; }

/* --------------------------- Оверлей звука ------------------------------ */
.m-audio-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    background: rgba(4,7,12,0.90);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.m-audio-modal {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(330px, calc(100vw - 36px));
    padding: 26px 22px;
    text-align: center;
    background: linear-gradient(180deg, #1c2637 0%, #0e1521 100%);
    border: 1px solid var(--m-border);
    border-radius: 12px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.7), 0 0 30px rgba(62,166,255,0.10);
}
.m-audio-icon {
    display: block;
    margin-bottom: 10px;
    color: var(--m-blue);
    font-family: var(--m-mono);
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 18px rgba(62,166,255,0.55);
}
.m-audio-title {
    color: #fff;
    font-family: var(--m-mono);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.6px;
}
.m-audio-sub {
    margin: 4px 0 20px;
    color: var(--m-dim);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
}
.m-audio-start {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--m-green);
    border-radius: 7px;
    background: linear-gradient(180deg, #0a5b3d 0%, #06432d 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 6px rgba(255,255,255,0.5);
    box-shadow: 0 0 16px rgba(57,255,20,0.22);
    cursor: pointer;
}
.m-audio-start:active { transform: scale(0.985); }
.m-audio-hint { margin-top: 12px; color: #5b6a80; font-size: 10px; }

/* --------------------------- Небольшие экраны --------------------------- */
@media (max-width: 360px) {
    .m-app { padding-left: 6px; padding-right: 6px; }
    #freq-digits, .m-freq { font-size: 27px; }
    #bandbuttons .btnBand, #bandbuttons button { flex-basis: calc(50% - 5px); }
    .m-mode-btn { font-size: 11px; }
}
