:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --text: #1d2228;
  --muted: #6b7280;
  --line: #e3dfd6;
  --accent: #0a8fc4;      /* небесно-голубой */
  --accent-ink: #ffffff;
  --accent-soft: #e2f3fa;
  --gold: #d9a300;        /* золото */
  --gold-soft: #fbf2d6;
  --danger: #d6455d;
  --shadow: 0 1px 2px rgba(20, 23, 28, .06), 0 6px 20px rgba(20, 23, 28, .06);
  --radius: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1d2128;
  --surface-2: #262b33;
  --text: #e9ebee;
  --muted: #9aa3ad;
  --line: #2f353e;
  --accent: #3bb4e6;
  --accent-ink: #0c1116;
  --accent-soft: #17313d;
  --gold: #f0c03a;
  --gold-soft: #3a3220;
  --danger: #f07386;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1d2128; --surface-2: #262b33; --text: #e9ebee; --muted: #9aa3ad;
    --line: #2f353e; --accent: #3bb4e6; --accent-ink: #0c1116; --accent-soft: #17313d;
    --gold: #f0c03a; --gold-soft: #3a3220; --danger: #f07386;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Arabic", "PingFang SC", sans-serif;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin-inline: auto;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }

/* --- шапка --- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="false"] .wave { opacity: 0; }
.icon-btn[aria-pressed="false"] { opacity: .6; }
#themeBtn .sun { display: none; }
:root[data-theme="dark"] #themeBtn .sun { display: block; }
:root[data-theme="dark"] #themeBtn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .sun { display: block; }
  :root:not([data-theme="light"]) #themeBtn .moon { display: none; }
}

/* --- выбор пары --- */
.pair {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  margin: 4px 16px 8px; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.lang {
  min-height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 600; text-align: center; position: relative; padding: 0 8px;
}
.lang.fixed { background: var(--accent-soft); color: var(--text); }
.lang.select { background: var(--gold-soft); }
.lang select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 48px; border: 0; background: transparent;
  font: inherit; font-weight: 600; color: var(--text); text-align: center; text-align-last: center; padding: 0 22px; cursor: pointer;
}
.lang.select::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}
.lang select option { color: #1d2228; background: #fff; }
.swap {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--muted); transition: transform .25s;
}
.swap:hover { color: var(--text); }
.swap.spin { transform: rotate(180deg); }

/* --- лента диалога --- */
.chat { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; padding: 24px 0; }
.empty-title { font-size: 18px; color: var(--text); font-weight: 600; margin: 0 0 6px; }
.empty-sub { margin: 0; font-size: 14px; }

.turn {
  max-width: 88%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); animation: pop .2s ease-out;
}
.turn.left  { align-self: flex-start; border-top-left-radius: 6px; border-left: 4px solid var(--accent); }
.turn.right { align-self: flex-end;   border-top-right-radius: 6px; border-right: 4px solid var(--gold); }
.turn .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.turn .src { color: var(--muted); font-size: 15px; margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn .dst { font-size: 20px; font-weight: 500; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn .row { display: flex; justify-content: flex-end; gap: 4px; margin-top: 6px; }
.turn .row button { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.turn .row button:hover { color: var(--text); }
.turn .row button svg { width: 18px; height: 18px; }
.turn.error { border-color: var(--danger); }
.turn.error .dst { color: var(--danger); font-size: 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* --- нижняя панель --- */
.dock {
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.text-row { display: flex; gap: 8px; margin-bottom: 12px; }
.text-row input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
}
.text-row input:focus { border-color: var(--accent); }
.send { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.mics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mic {
  position: relative; height: 84px; border-radius: 22px; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow); transition: transform .1s, filter .2s; overflow: hidden;
}
.mic svg { width: 28px; height: 28px; position: relative; }
.mic-label { position: relative; max-width: 100%; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#micLeft { background: var(--accent); color: var(--accent-ink); }
#micRight { background: var(--gold); color: #1d2228; }
.mic:active { transform: scale(.97); }
.mic:disabled { filter: grayscale(.7) opacity(.55); cursor: default; }
.mic-ring { position: absolute; inset: 0; background: rgba(255,255,255,.25); transform: scaleX(0); transform-origin: left; }
.mic.recording { background: var(--danger) !important; color: #fff !important; }
.mic.recording .mic-ring { animation: rec 1.4s ease-in-out infinite; }
@keyframes rec { 0% { transform: scaleX(0); opacity: .8 } 100% { transform: scaleX(1); opacity: 0 } }
.status { min-height: 20px; margin-top: 8px; text-align: center; font-size: 13px; color: var(--muted); }
.status.err { color: var(--danger); }

@media (min-width: 600px) { .mic { height: 96px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
