/* Палитра-токены = нативное приложение apps/translator (res/values/colors.xml):
   near-black фон + лавандовый акцент, карточки с обводкой 1px (теней НЕТ). */
:root {
  --bg: #0C0E12; --panel: #1A1D23; --card2: #15181D; --stroke: #2A2E35;
  --text: #E8EAED; --muted: #9AA0A6; --faint: #5F6368;
  --accent: #C9C6FF; --accent-ink: #3B3A8F;
  --recording: #F36B5C; --amber: #E8C161; --red: #F36B5C; --accent2: #8AB4F8;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Атрибут hidden должен побеждать любые display:flex/-правила ниже (иначе скрытые
   панели/модалки остаются на весь экран и перехватывают тапы). */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; align-items: center; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Фон — на всю ширину (body), контент — центрированная колонка до ~520px (планшет/десктоп). */
.topbar, .pairbar, .result, .text-panel, .bottom { width: 100%; max-width: 520px; }
/* Фокус клавиатурой — лавандовый ring в тон акценту (вместо системного янтарного). */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* Монохромные inline-SVG иконки (порт ic_* из приложения): наследуют цвет через currentColor. */
.ic { width: 24px; height: 24px; display: block; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px; }
.brand { font-size: 20px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.brand-a { color: var(--text); }
.brand-b { color: var(--muted); font-weight: 400; }
.top-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }

.chip {
  background: var(--panel); color: var(--text); border: 1px solid var(--stroke); border-radius: 999px;
  padding: 12px 14px; font-size: 14px; cursor: pointer; max-width: 55vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  min-height: 44px; min-width: 0;  /* min-width:0 → чип сжимается с эллипсисом, не ломая топбар */
}
.chip.small { padding: 5px 10px; font-size: 12px; min-height: 0; }
.chip[data-mode="in"] { border-color: var(--accent); color: var(--accent); }
.iconbtn { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
.iconbtn:active { background: rgba(255,255,255,.06); }

/* Языковая пара: чипы r16 (bg_langbtn), card+stroke, 16px bold; «АВТО» — тихий чип r9. */
.pairbar { display: flex; align-items: center; gap: 8px; padding: 4px 16px 12px; }
.lang {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 15px 10px; font-size: 16px; font-weight: 700; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auto {
  background: transparent; color: var(--muted); border: 1px solid var(--stroke); border-radius: 9px;
  padding: 4px 9px; font-size: 10px; font-weight: 600; letter-spacing: .04em; cursor: pointer;
  position: relative; flex-shrink: 0;
}
/* Чип «АВТО» остаётся визуально компактным, но зона нажатия расширена до 44×44. */
.auto::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 44px; height: 44px; }

.result { flex: 1; padding: 8px 20px; overflow-y: auto; min-height: 40vh; }
.src-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; min-height: 16px; }
.orig-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.original { font-size: 26px; line-height: 1.3; font-weight: 500; color: var(--text); }
.draft-badge { color: var(--amber); font-size: 12px; }
/* Перевод = текст на фоне + divider (как в приложении: без карточки, лавандовый). */
.translations { margin-top: 0; display: flex; flex-direction: column; }
.translations.draft { opacity: .55; }
.translation { border-top: 1px solid var(--stroke); margin-top: 14px; padding-top: 14px; }
.tr-label { color: var(--accent); font-size: 13px; margin-bottom: 6px; }
.tr-text { color: var(--accent); font-size: 28px; line-height: 1.3; }
.tr-actions { margin-top: 6px; display: flex; gap: 4px; align-items: center; }

.text-panel { display: flex; gap: 8px; padding: 8px 16px; }
.text-panel textarea { flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--stroke); border-radius: 12px; padding: 10px; font-size: 16px; resize: none; }
.text-panel textarea:focus { outline: none; border-color: var(--accent); }

/* idle/record — взаимоисключающи, ОДИНАКОВЫЕ паддинги + содержимое 78px → низ не «прыгает». */
.bottom { padding: 0 16px 4px; }
.status { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.status[data-k="finishing"] { color: var(--recording); }
.status[data-k="listening_more"] { color: var(--amber); }

.idle-panel { display: flex; align-items: center; padding: 20px 0 24px; }
.action-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.action-circle {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--stroke); color: var(--muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.action-circle:active { background: var(--card2); }
.action-label { margin-top: 7px; font-size: 12px; color: var(--muted); }

/* Микрофон: круг 78px, ПЛОСКАЯ лавандовая заливка, глиф = accent_ink. */
.mic {
  width: 78px; height: 78px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .1s; box-shadow: 0 0 0 0 rgba(201,198,255,.5);
}
.mic .ic { width: 30px; height: 30px; }
.mic:active { transform: scale(.95); }
.mic.busy { animation: pulse 1.1s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201,198,255,.5); }
  70% { box-shadow: 0 0 0 16px rgba(201,198,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,198,255,0); }
}

/* Панель записи: карточка r24 + stroke (bg_record_panel) + кнопка стоп 78px красная. */
.record-panel { display: flex; align-items: center; gap: 14px; padding: 20px 0 24px; }
.rec-card {
  flex: 1 1 0; min-width: 0; height: 78px; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 24px; padding: 0 16px;
}
.wave { flex: 1 1 0; min-width: 0; width: 100%; height: 50px; }
.timer { flex: none; color: var(--text); font-variant-numeric: tabular-nums; font-family: monospace; font-size: 15px; }
.stop {
  flex: 0 0 auto;
  width: 78px; height: 78px; border-radius: 50%; border: none;
  background: var(--recording); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.stop .ic { width: 30px; height: 30px; }
.stop:active { transform: scale(.95); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--card2); width: 100%; max-width: 520px; max-height: 80dvh; border-radius: 20px 20px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.sheet-head-actions { display: flex; align-items: center; gap: 8px; }
.picker-list { display: flex; flex-direction: column; }
.picker-item { text-align: left; background: transparent; color: var(--text); border: none; border-bottom: 1px solid var(--stroke); padding: 14px 8px; font-size: 17px; cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.hist-card { background: var(--panel); border: 1px solid var(--stroke); border-radius: 20px; padding: 14px; }
.hist-orig { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.hist-tr { color: var(--accent); font-size: 17px; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.muted { color: var(--muted); text-align: center; }

/* Баннер установки iOS — СВЕРХУ (а не над нижним рядом История·Микрофон·Озвучка, иначе
   перекрывал их и перехватывал тапы до закрытия). Центрируем в колонку контента. */
.ios-hint { position: fixed; left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top)); z-index: 30; margin: 0 auto; max-width: 496px; }
.ios-hint-body { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; padding: 14px; font-size: 14px; line-height: 1.5; }
.ios-hint-body .chip { margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: #000c; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Ландшафт / низкие экраны: без 40vh-резерва результата и с ужатым вертикальным ритмом,
   чтобы микрофон и нижний ряд помещались на экран без скролла (напр. 740×360). idle/record
   ужимаются ОДИНАКОВО — низ по-прежнему не «прыгает» при старте записи. */
@media (max-height: 480px) {
  .result { min-height: 0; }
  .topbar { padding: 6px 12px; }
  .pairbar { padding: 2px 16px 8px; }
  .lang { padding: 10px 10px; }
  .idle-panel, .record-panel { padding: 10px 0 12px; }
}
