/* Online microphone — скевоморфный диктофон по флеш-макету «один в один».
   Микрофон — растровый ассет mic.png (извлечён из макета); кнопка записи — спрайт mic-btn.png
   (кружок кнопки из того же макета) поверх запечённой: в покое совпадает попиксельно, при нажатии
   вжимается, во время записи утоплена и показывает СТОП-квадрат. Прослушивание — состояние done:
   ВСЯ правая зона становится плеером; высота правой зоны стабильна (панель записи прячется
   visibility, не выпадая из потока) — микрофон не прыгает. Namespace .omic (длинный — урок
   voice_recorder). Цвета сняты пипеткой с макета (System.Drawing, усреднение ядра). */

.omic {
    /* ── палитра из макета ──────────────────────────────────────────── */
    --omic-bg-hi:      #8f1716; /* центр радиального фона (за микрофоном) */
    --omic-bg-mid:     #6a0f0a;
    --omic-bg-lo:      #420301; /* тёмные края */
    --omic-gold:       #dcb500; /* заголовок и подсказка */
    --omic-gold-lite:  #ffdf5a;
    --omic-green:      #51ff00; /* волна/спектр индикатора (жирный олдскульный зелёный) */
    --omic-green-stat: #3fcb00; /* статус «Waiting to start» */
    --omic-glow:       #49d200; /* зелёное свечение вокруг кнопки */
    --omic-red:        #bf1612; /* красная кнопка */
    --omic-panel:      #0e0e0e; /* корпус флип-панели */
    --omic-panel-ind:  #000000; /* фон индикатора */
    --omic-chrome-hi:  #f0f0f0;
    --omic-chrome-mid: #8a8c90;
    --omic-chrome-lo:  #1a1a1c;
    --omic-digit:      #ffffff;

    /* геометрия кнопки в mic.png 236x419 (замер по пикселям ассета) */
    --om-cx: 50.68%;   /* центр красной кнопки по X */
    --om-cy: 42.77%;   /* центр по Y */
    --om-btn-d: 28.81%; /* диаметр спрайта кнопки (68px от ширины 236px) */

    max-width: 760px;
    margin: 0 auto;
    font-family: 'Arial Black', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Сцена (арт-область): mic | (title / right / foot) | gain ─────────── */
.omic__stage {
    position: relative;
    display: grid;
    grid-template-columns: 33% 1fr 11%;
    grid-template-rows: auto 1fr auto;
    column-gap: clamp(8px, 2.2%, 20px);
    row-gap: clamp(6px, 1.6vw, 14px);
    padding: clamp(10px, 2.4vw, 20px);
    border-radius: 14px;
    background:
        radial-gradient(128% 110% at 31% 45%,
            #9c1a17 0%, var(--omic-bg-hi) 22%, var(--omic-bg-mid) 55%, var(--omic-bg-lo) 100%);
    box-shadow: inset 0 0 60px rgba(0,0,0,.55), 0 6px 22px rgba(0,0,0,.35);
    overflow: hidden;
}

/* ── Микрофон ─────────────────────────────────────────────────────────── */
.omic__mic {
    position: relative;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: center;
    justify-self: center;
    width: 100%;
    max-width: 240px;
}
.omic__mic-img {
    display: block;
    width: 100%;
    height: auto;
    -webkit-user-drag: none;
    user-select: none;
}

/* Кнопка записи — спрайт кружка из макета ПОВЕРХ запечённого (в покое совпадает попиксельно).
   Двухслойная механика, как у настоящей клавиши: хромовый обод-гнездо (.omic__btn) НЕПОДВИЖЕН,
   вжимается только внутренняя шляпка (.omic__cap) — лёгкий сдвиг вниз + тень от обода сверху шляпки.
   Никакого масштабирования и затемнения всего узла. Во время записи шляпка утоплена и = СТОП-квадрат. */
.omic__btn {
    position: absolute;
    left: var(--om-cx);
    top: var(--om-cy);
    width: var(--om-btn-d);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: transparent;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    cursor: pointer;
    outline: none;
    z-index: 3;
}
.omic__cap { /* внутренняя шляпка (белое кольцо + красная точка), 48px от 68px кнопки */
    position: absolute;
    left: 50%;
    top: 50%;
    width: 70.6%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    pointer-events: none;
    transition: transform .07s ease, opacity .07s ease;
}
/* Вжатая кнопка — весь узел уходит в ГЛУБОКУЮ ТЁМНУЮ ЛУНКУ (отдельный спрайт-чаша: тёмные стенки,
   тень обода сверху, отсвет дна снизу). Чаша накрывает и белое кольцо шляпки — от гнезда остаётся
   только внешняя хромовая кромка, как в референсе. На дне — красный индикатор: точка в момент
   клика, СТОП-квадрат во время записи. */
.omic__cap--pressed {
    opacity: 0;
    /* Нажатый узел воссоздан целиком по замерам референса: хром-кольцо + чаша + СТОП.
       Запечённый узел в mic.png чуть крупнее хотспота и его центр на ~1.5px выше центра
       красной точки (замер) — слой увеличен и приподнят, чтобы накрыть родную кнопку без щелей. */
    width: 110%;
    top: 47.8%;
}
/* нажато (клик) или идёт запись: выпуклая шляпка гаснет, лунка проявляется */
.omic__btn:active .omic__cap:not(.omic__cap--pressed),
.omic.is-rec .omic__cap:not(.omic__cap--pressed) { opacity: 0; }
.omic__btn:active .omic__cap--pressed,
.omic.is-rec .omic__cap--pressed { opacity: 1; }
.omic__btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(255,255,255,.55), 0 0 10px 3px var(--omic-glow);
}

/* Зелёное свечение-пульс (усиливает запечённое во время записи) */
.omic__glow {
    position: absolute;
    left: var(--om-cx);
    top: var(--om-cy);
    width: 46%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    background: radial-gradient(circle,
        rgba(73,210,0,0) 32%, rgba(73,210,0,.55) 44%, rgba(73,210,0,0) 64%);
}
.omic.is-rec .omic__glow { animation: omic-pulse 1.15s ease-in-out infinite; }
@keyframes omic-pulse {
    0%,100% { opacity: .15; transform: translate(-50%,-50%) scale(.9); }
    50%     { opacity: .9;  transform: translate(-50%,-50%) scale(1.08); }
}

/* Золотой заголовок */
.omic__title {
    grid-column: 2 / 4;
    grid-row: 1;
    align-self: center;
    white-space: nowrap;
    text-align: center;
    font-weight: 900;
    font-size: clamp(19px, 4.7vw, 43px);
    line-height: 1;
    letter-spacing: .5px;
    color: var(--omic-gold);
    background: linear-gradient(180deg, #ffe867 0%, #ffcf1f 44%, #e3a200 76%, #b87e00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.55));
}

/* ── Правая зона: стабильная высота; панель записи + подсказка в потоке,
      прослушивание — АБСОЛЮТОМ поверх (высота зоны не меняется — ничего не прыгает) ── */
.omic__right {
    position: relative;
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.6vw, 16px);
    min-width: 0;
}
.omic__panel {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.6vw, 16px);
    min-width: 0;
}
.omic[data-state="done"] .omic__panel,
.omic[data-state="done"] .omic__prompt { visibility: hidden; }

/* Флип-часы + статус в одной чёрной панели */
.omic__clock {
    background: linear-gradient(180deg, #1b1b1b 0%, var(--omic-panel) 55%, #050505 100%);
    border: 1px solid #000;
    border-radius: 12px;
    padding: clamp(8px, 1.6vw, 16px) clamp(6px, 1.4vw, 14px) clamp(6px, 1.2vw, 12px);
    box-shadow: inset 0 2px 10px rgba(0,0,0,.8), 0 1px 0 rgba(255,255,255,.06);
}
.omic__flip {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(2px, .6vw, 5px);
    font-size: clamp(26px, 6.9vw, 64px);
}
.omic__digit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: .96em;
    height: 1.16em;
    border-radius: .15em;
    font-weight: 900;
    color: var(--omic-digit);
    background: linear-gradient(180deg, #6d6d6d 0%, #333 46%, #3d3d3d 54%, #0d0d0d 100%);
    box-shadow: inset 0 1px 1px rgba(255,255,255,.35), inset 0 -2px 5px rgba(0,0,0,.7),
                0 1px 2px rgba(0,0,0,.6);
    text-shadow: 0 -1px 0 rgba(0,0,0,.55), 0 2px 2px rgba(0,0,0,.55);
}
.omic__digit::after { /* шов перекидного механизма */
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-1px);
    background: rgba(0,0,0,.72);
    box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.omic__colon {
    font-weight: 900;
    color: var(--omic-digit);
    padding: 0 .06em;
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.omic__status {
    margin-top: clamp(4px, 1vw, 10px);
    text-align: center;
    font-weight: 800;
    font-size: clamp(13px, 2.5vw, 22px);
    letter-spacing: .3px;
    color: var(--omic-green-stat);
    text-shadow: 0 0 8px rgba(63,203,0,.5);
}
.omic.is-rec .omic__status::before {
    content: '';
    display: inline-block;
    width: .6em; height: .6em;
    margin-right: .45em;
    border-radius: 50%;
    background: #ff2b21;
    box-shadow: 0 0 6px #ff2b21;
    vertical-align: baseline;
    animation: omic-blink 1s steps(1) infinite;
}
@keyframes omic-blink { 50% { opacity: .15; } }

/* Индикатор звука (запись/покой) */
.omic__ind {
    position: relative;
    background: var(--omic-panel-ind);
    border: 1px solid #000;
    border-radius: 12px;
    box-shadow: inset 0 2px 12px rgba(0,0,0,.9);
    height: clamp(56px, 12vw, 96px);
    overflow: hidden;
}
.omic__ind-canvas { display: block; width: 100%; height: 100%; }
.omic__ind-label {
    position: absolute;
    right: 8px;
    bottom: 4px;
    font-size: clamp(9px, 1.5vw, 13px);
    font-weight: 700;
    color: #d7d7d7;
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
}

/* ── Нижняя подсказка (idle/recording) ────────────────────────────────── */
.omic__prompt {
    text-align: center;
    padding-top: clamp(4px, 1.2vw, 12px);
}
.omic__prompt-main {
    display: block;
    font-weight: 900;
    font-size: clamp(14px, 2.9vw, 25px);
    line-height: 1.18;
    color: var(--omic-gold);
    text-shadow: 0 2px 3px rgba(0,0,0,.5);
}
.omic__prompt-key {
    display: block;
    margin-top: .2em;
    font-weight: 700;
    font-size: clamp(11px, 1.9vw, 16px);
    color: var(--omic-gold-lite);
    opacity: .92;
}

/* ── Прослушивание (done): вся правая зона ────────────────────────────── */
.omic__review {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    gap: clamp(6px, 1.2vw, 12px);
    min-width: 0;
}
.omic[data-state="done"] .omic__review { display: flex; }
.omic__review-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.omic__review-title {
    font-weight: 900;
    font-size: clamp(15px, 2.6vw, 22px);
    color: var(--omic-gold);
    text-shadow: 0 2px 3px rgba(0,0,0,.5);
    white-space: nowrap;
}
.omic__review-time {
    font-weight: 800;
    font-size: clamp(13px, 2.2vw, 18px);
    color: #eee;
    text-shadow: 0 1px 2px #000;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
/* Большая волна записи: перемотка кликом/драгом; при play — живой спектр */
.omic__rwave {
    position: relative;
    flex: 1;
    min-height: 70px;
    background: var(--omic-panel-ind);
    border: 1px solid #000;
    border-radius: 12px;
    box-shadow: inset 0 2px 12px rgba(0,0,0,.9);
    overflow: hidden;
    cursor: pointer;
    touch-action: none; /* драг-перемотка на таче */
}
.omic__rwave-canvas { display: block; width: 100%; height: 100%; }
.omic__rprogress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: var(--omic-green);
    box-shadow: 0 0 6px var(--omic-green);
    pointer-events: none;
}
.omic__playbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
.omic__play {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    padding: .45em 1.2em;
    border: 0;
    border-radius: 999px;
    font-weight: 800;
    font-size: clamp(13px, 2vw, 17px);
    font-family: inherit;
    color: #fff;
    background: linear-gradient(180deg, #e2413f 0%, var(--omic-red) 100%);
    box-shadow: 0 3px 10px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.3);
    cursor: pointer;
    outline: none;
}
.omic__play:hover { filter: brightness(1.08); }
.omic__play:active { transform: translateY(1px); filter: brightness(.92); }
.omic__play:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.5); }
.omic__play .bi { font-size: 1.15em; }
.omic__act {
    display: inline-flex;
    align-items: center;
    gap: .45em;
    font-weight: 700;
    font-size: clamp(12px, 1.8vw, 14px);
    font-family: inherit;
    border-radius: 8px;
    padding: .45em .8em;
}
.omic__act-dl {
    color: #fff;
    background: linear-gradient(180deg, #3a3c44 0%, #23242a 100%);
    border: 1px solid #000;
}
.omic__act-dl:hover { background: linear-gradient(180deg, #45474f 0%, #2b2c33 100%); color:#fff; }
.omic__act-again {
    color: #17181c;
    background: linear-gradient(180deg, #f0f0f0 0%, #c9cacd 100%);
    border: 1px solid #000;
}
.omic__act-again:hover { color:#17181c; background: linear-gradient(180deg, #fff 0%, #d5d6d9 100%); }
.omic__act:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.45); }
.omic__act[disabled] { opacity: .55; cursor: default; }

/* Прелоадер кодирования: высота зарезервирована всегда — интерфейс не прыгает */
.omic__encoding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5em;
    height: 1.5em;
    margin: 0;
    color: #ffd9d9;
    font-size: 13px;
    font-weight: 700;
    visibility: hidden;
}
.omic__encoding.is-on { visibility: visible; }
.omic__spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: omic-spin .8s linear infinite;
}
@keyframes omic-spin { to { transform: rotate(360deg); } }

/* ── Ползунок усиления входа (gain) ───────────────────────────────────── */
.omic__gain {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    height: 100%;
    justify-self: center;
}
.omic__gain-ic {
    font-size: clamp(14px, 2.4vw, 20px);
    color: #b8b9bd;
    text-shadow: 0 1px 2px #000;
}
.omic__gain-range {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl; /* низ = минимум */
    width: 10px;
    flex: 1;
    min-height: 90px;
    background: transparent;
    outline: none;
    cursor: pointer;
}
.omic__gain-range::-webkit-slider-runnable-track {
    width: 8px;
    border-radius: 6px;
    background: linear-gradient(90deg, #050505, #3a3b3e 50%, #050505);
    box-shadow: inset 0 0 3px rgba(0,0,0,.9);
}
.omic__gain-range::-moz-range-track {
    width: 8px;
    border-radius: 6px;
    background: linear-gradient(90deg, #050505, #3a3b3e 50%, #050505);
    box-shadow: inset 0 0 3px rgba(0,0,0,.9);
}
.omic__gain-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 19px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--omic-chrome-hi) 0%, var(--omic-chrome-mid) 48%, #55565a 52%, #d9dadd 100%);
    border: 1px solid #2a2a2c;
    box-shadow: 0 1px 3px rgba(0,0,0,.6);
    margin-left: -12px;
}
.omic__gain-range::-moz-range-thumb {
    width: 32px;
    height: 19px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--omic-chrome-hi) 0%, var(--omic-chrome-mid) 48%, #55565a 52%, #d9dadd 100%);
    border: 1px solid #2a2a2c;
    box-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.omic__gain-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(255,255,255,.5); }
.omic__gain-range:focus-visible::-moz-range-thumb     { box-shadow: 0 0 0 3px rgba(255,255,255,.5); }

/* ── Пикер микрофона (низ сцены; виден при >1 устройств) ──────────────── */
.omic__foot {
    grid-column: 2 / 4;
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}
.omic__foot[hidden] { display: none; }
.omic__foot-ic {
    color: #b8b9bd;
    font-size: 15px;
    text-shadow: 0 1px 2px #000;
}
.omic__mic-sel {
    max-width: 320px;
    min-width: 0;
    flex: 0 1 auto;
    padding: .3em 1.8em .3em .7em;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #e6e6e6;
    background: linear-gradient(180deg, #2b2c31 0%, #17181c 100%);
    border: 1px solid #000;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #b8b9bd 50%),
        linear-gradient(135deg, #b8b9bd 50%, transparent 50%);
    background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.omic__mic-sel:disabled { opacity: .5; cursor: default; }
.omic__mic-sel option { /* выпадающий список: тёмные пункты, не «бледное на белом» */
    color: #e6e6e6;
    background: #1c1d22;
}
.omic__foot-refresh {
    padding: .25em .45em;
    border: 1px solid #000;
    border-radius: 8px;
    background: linear-gradient(180deg, #2b2c31 0%, #17181c 100%);
    color: #b8b9bd;
    cursor: pointer;
    outline: none;
    line-height: 1;
}
.omic__foot-refresh:hover { color: #fff; }
.omic__foot-refresh:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.4); }

/* ── Ошибка ───────────────────────────────────────────────────────────── */
.omic__error {
    min-height: 1.2em;
    margin: .7rem 0 0;
    text-align: center;
    color: #ff6b6b;
    font-weight: 700;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.omic__error:empty { min-height: 0; margin: 0; }

/* ── Мобайл: правая зона (часы/индикатор/подсказка ↔ плеер) под микрофоном, gain справа ── */
@media (max-width: 560px) {
    .omic__stage {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto auto;
        column-gap: 10px;
        row-gap: 10px;
        align-items: start;
    }
    .omic__title { grid-column: 1 / 3; grid-row: 1; }
    .omic__mic   { grid-column: 1; grid-row: 2; max-width: 190px; }
    .omic__gain  { grid-column: 2; grid-row: 2; }
    .omic__right { grid-column: 1 / 3; grid-row: 3; }
    .omic__foot  { grid-column: 1 / 3; grid-row: 4; }
    .omic__act, .omic__play { flex: 1 1 auto; justify-content: center; }
}
