/* Вид повторяет прежнее приложение на Expo: те же цвета, отступы и карточки —
   человек не должен заметить, что внутри теперь страница. */

:root {
    --bg: #F4F6FA;
    --card: #FFFFFF;
    --line: #DCE1EA;
    --text: #3C4658;
    --muted: #7A8494;
    --blue: #2D6CDF;
    --red: #D93A3A;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overscroll-behavior: none;
}

body {
    display: flex;
    flex-direction: column;
    /* Убранная панель свисает ниже экрана — страница от этого прокручиваться
       не должна, для прокрутки есть лента. */
    overflow: hidden;
    /* Вырезы и полоса жестов: содержимое не должно под них уезжать. */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }

/* ── Верхняя строка ────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 2px;
}

.topbar-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--muted);
    font: 600 13px/1.2 inherit;
    font-family: inherit;
}

.topbar-link:active { opacity: 0.6; }

/* Настройки всегда справа — даже когда «Очистить» ещё не появилось. */
.topbar-link.settings { margin-left: auto; }

/* ── Лента ─────────────────────────────────────────────────────────────── */

.feed {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 16px;
}

.notice {
    border-radius: 14px;
    border: 1px solid #F3B5B5;
    background: #FDECEC;
    color: #A32020;
    font-size: 13px;
    line-height: 19px;
    padding: 14px;
}

/* Промолчал в микрофон — это не ошибка, а обычное дело, поэтому спокойный вид. */
.notice.hint {
    background: var(--card);
    border-color: var(--line);
    color: #4A5568;
    font-size: 14px;
    line-height: 20px;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border-radius: 14px;
    padding: 14px;
    color: var(--blue);
    font-size: 14px;
    font-weight: 600;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #C7D7F5;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    text-align: center;
}

.empty-emoji { font-size: 44px; }
.empty p { margin: 0; font-size: 14px; line-height: 21px; }

#turns { display: flex; flex-direction: column; gap: 12px; }

.turn {
    background: var(--card);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(11, 18, 32, 0.06);
}

.turn-row { display: flex; gap: 10px; }
.turn-flag { font-size: 20px; line-height: 26px; }
.turn-source { flex: 1; font-size: 16px; line-height: 24px; color: var(--text); }
.turn-translation { flex: 1; font-size: 16px; line-height: 24px; font-weight: 600; }
.divider { height: 1px; background: #EDF0F5; margin: 12px 0; }

/* Копирование: значок бледный, чтобы не спорить с самим текстом. */
.copy {
    flex: none;
    width: 30px;
    height: 30px;
    margin: -3px -6px 0 0;
    padding: 0;
    border: 0;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #A8B1BF;
}

.copy:active { opacity: 0.5; }
.copy.done { color: #2FA36B; }

.turn-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.replay {
    padding: 0;
    border: 0;
    background: none;
    color: var(--blue);
    font: 600 14px/1.4 inherit;
    font-family: inherit;
    text-align: left;
}

/* «Оригинал» — приглушённо: это справка, а не то, ради чего смотрят карточку. */
.source-toggle {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: #8A93A3;
    font: 600 13px/1.4 inherit;
    font-family: inherit;
}

.source-toggle:active { opacity: 0.6; }
.source-toggle svg { transition: transform 0.2s; }
.source-toggle.open svg { transform: rotate(180deg); }

/* ── Нижние кнопки ─────────────────────────────────────────────────────── */

/*
 * После перевода панель уезжает вниз, а внизу остаётся язычок.
 *
 * Уезжает она отрицательным отступом: тогда освободившееся место сразу
 * занимает лента разговора. Сдвиг через transform выглядел бы так же, но
 * оставил бы под лентой пустую полосу.
 */
.dock {
    --hide: 110px;
    transition: margin-bottom 0.3s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.dock.down {
    margin-bottom: calc(-1 * var(--hide));
}

.dock-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 78px;
    height: 27px;
    margin: 0 auto 3px;
    padding: 0;
    border: 1px solid #E2E7EF;
    border-radius: 14px;
    background: var(--card);
    color: #98A2B3;
}

.dock-handle:active { opacity: 0.7; }
.dock-handle svg { transition: transform 0.3s; }

/* Убрана — стрелка показывает вверх: нажатие вернёт панель. */
.dock.down .dock-handle svg { transform: rotate(180deg); }

.controls {
    display: flex;
    gap: 10px;
    padding: 4px 16px 8px;
}

.mic {
    flex: 1;
    min-height: 84px;
    border: 0;
    border-radius: 16px;
    padding: 12px 8px;
    color: #FFFFFF;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: opacity 0.15s;
}

/* Цвет закреплён за стороной, а не за языком: левый собеседник синий,
   правый красный — какие бы языки ни выбрали. */
.mic[data-slot="a"] { background: var(--blue); }
.mic[data-slot="b"] { background: var(--red); }
.mic:disabled { opacity: 0.45; }
.mic:active { opacity: 0.8; }

.mic-flag { font-size: 24px; }
.mic-label { font-size: 15px; font-weight: 700; }
.mic-hint { font-size: 11px; text-align: center; color: rgba(255, 255, 255, 0.8); }

/* «Дыхание» значка — единственный признак того, что идёт запись. */
.mic-recording { animation: breathe 1.7s ease-in-out infinite; }
.recording-hint { margin-top: 10px; font-size: 14px; font-weight: 600; }

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.22); opacity: 0.55; }
}

/* ── Настройки ─────────────────────────────────────────────────────────── */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.45);
    display: flex;
    align-items: flex-end;
    z-index: 10;
    animation: dim 0.22s ease-out;
}

/* Полосу состояния телефона затемняет приложение: страница меняет свою
   пометку theme-color, а оно красит по ней (см. SHEET_COLOR в app.js). */
@keyframes dim { from { background: rgba(11, 18, 32, 0); } }

.sheet {
    width: 100%;
    max-height: 82%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 22px 22px 0 0;
    padding: 18px 20px calc(28px + env(safe-area-inset-bottom));
    animation: rise 0.22s ease-out;
}

@keyframes rise { from { transform: translateY(100%); } }

.sheet-header { display: flex; align-items: center; justify-content: space-between; }
.sheet-header h2 { margin: 0; font-size: 19px; font-weight: 700; color: #131A24; }

.link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--blue);
    font: 600 14px/1 inherit;
    font-family: inherit;
}

.sheet-note { margin: 6px 0 14px; color: #5C6779; font-size: 13px; line-height: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding-top: 14px; }
.sheet-footer { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 17px; }

.sheet-section {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 15px;
    font-weight: 700;
    color: #131A24;
}

/* Первый раздел идёт сразу под заголовком — черта над ним лишняя. */
.sheet-section.first { margin-top: 0; padding-top: 0; border-top: 0; }

/* ── Выбор языков ──────────────────────────────────────────────────────── */

.langs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 4px;
}

.lang-slot {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 12px 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    font-family: inherit;
}

.lang-slot:active { opacity: 0.7; }
.lang-slot .flag { font-size: 22px; line-height: 1.1; }

.lang-slot .native {
    font-size: 14px;
    font-weight: 700;
    color: #131A24;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lang-slot .name { font-size: 11px; color: var(--muted); }

.swap {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.swap:active { opacity: 0.6; }

/* Список языков поверх настроек. */
.sheet-backdrop.picker { z-index: 20; }

.search {
    width: 100%;
    margin: 14px 0 4px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    font: 15px/1.3 inherit;
    font-family: inherit;
}

.search:focus { outline: none; border-color: var(--blue); }

.lang-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 2px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: none;
    font-family: inherit;
    text-align: left;
}

.lang-row:active { opacity: 0.6; }
.lang-row .flag { font-size: 22px; }
.lang-row .native { flex: 1; font-size: 15px; font-weight: 600; color: #131A24; }
.lang-row .name { font-size: 13px; color: var(--muted); }
.lang-row.chosen .native { color: var(--blue); }
.lang-row .mark { color: var(--blue); }
.lang-empty { padding: 20px 2px; color: var(--muted); font-size: 14px; }

/* Строка настройки: слева объяснение, справа переключатель. */
.setting {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
}

.setting + .setting { border-top: 1px solid var(--line); }
.setting-text { flex: 1; }
.setting-title { font-size: 15px; font-weight: 600; color: #131A24; }
.setting-note { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 17px; }

.switch {
    flex: none;
    width: 48px;
    height: 29px;
    margin-top: 2px;
    padding: 3px;
    border: 0;
    border-radius: 15px;
    background: #D7DCE5;
    display: flex;
    transition: background 0.2s;
}

.switch span {
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(11, 18, 32, 0.25);
    transition: transform 0.2s;
}

.switch.on { background: var(--blue); }
.switch.on span { transform: translateX(19px); }

.voice-section { margin-bottom: 18px; }
.voice-section h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.voice-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.voice {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 13px;
    font: 14px/1 inherit;
    font-family: inherit;
    color: var(--text);
}

.voice.selected { border-width: 2px; font-weight: 700; padding: 8px 12px; }
.voice .spinner { width: 13px; height: 13px; border-width: 2px; }
