:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --ru: #2f6fed;
  --zh: #e0413a;
  --ok: #3ccf7e;
  --warn: #f5b942;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 8px) 16px 8px;
}
.top h1 { font-size: 18px; font-weight: 600; margin: 0; color: var(--muted); }
.icon-btn {
  background: var(--panel); color: var(--text); border: 0; border-radius: 12px;
  width: 40px; height: 40px; font-size: 20px;
}

.log {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 16px 12px; display: flex; flex-direction: column; gap: 12px;
}
.empty { margin: auto 0; text-align: center; color: var(--muted); }
.empty .zh { font-size: 16px; }

.card {
  background: var(--panel); border-radius: var(--radius); padding: 12px 14px;
  border-left: 4px solid var(--ru); -webkit-user-select: text; user-select: text;
}
.card.from-zh { border-left-color: var(--zh); }
.card .src { color: var(--muted); font-size: 15px; }
.card .dst { font-size: 22px; font-weight: 600; margin-top: 4px; word-break: break-word; }
.card.from-ru .dst { font-size: 26px; }
.card .py { color: var(--muted); font-size: 15px; margin-top: 2px; }
.card .row-actions { display: flex; gap: 8px; margin-top: 8px; }
.card .act {
  background: var(--panel-2); color: var(--text); border: 0; border-radius: 10px;
  padding: 8px 12px; font-size: 15px;
}
.card .act.playing { background: var(--ok); color: #05130b; }
.card.pending .dst { color: var(--muted); font-weight: 400; font-size: 17px; }
.card.error { border-left-color: var(--warn); }

.status {
  min-height: 22px; text-align: center; color: var(--muted); font-size: 15px; padding: 0 16px;
}
.status.err { color: var(--warn); }

.text-form { display: flex; gap: 8px; padding: 6px 16px; }
.text-form[hidden] { display: none; }
.text-form input {
  flex: 1; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 0;
  background: var(--panel); color: var(--text); -webkit-user-select: text; user-select: text;
}
.send-btn { width: 52px; border: 0; border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 20px; }

.controls { padding: 6px 16px calc(var(--safe-b) + 12px); }
.aux { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-height: 40px; }
.aux-btn {
  background: var(--panel); color: var(--text); border: 0; border-radius: 12px;
  padding: 0 16px; height: 40px; font-size: 16px;
}
.aux-btn[hidden] { display: none; }
#btnStopAudio { background: var(--warn); color: #1d1300; font-weight: 600; }
#btnKeyboard { margin-left: auto; }

.mic-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mic-btn {
  position: relative; overflow: hidden;
  height: 34vh; min-height: 150px; max-height: 260px;
  border: 0; border-radius: 26px; color: #fff;
  font-size: 22px; font-weight: 700; letter-spacing: .2px;
  touch-action: manipulation;
  transition: transform .08s ease, filter .15s ease;
}
.mic-btn.zh .mic-label { font-size: 30px; }
.mic-btn.ru { background: var(--ru); }
.mic-btn.zh { background: var(--zh); }
.mic-btn:active { transform: scale(.98); }
.mic-btn[disabled] { filter: grayscale(.6) brightness(.6); }
.mic-label { position: relative; z-index: 1; }
.mic-level {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: rgba(255, 255, 255, .22); transition: height .08s linear;
}
.mic-btn.recording { animation: pulse 1.2s ease-in-out infinite; }
.mic-btn.recording .mic-label::after { content: "\A● запись\Aнажмите, чтобы закончить"; white-space: pre-wrap; display: block; font-size: 13px; font-weight: 500; padding: 0 8px; }
.mic-btn.zh.recording .mic-label::after { content: "\A● 录音中\A说完请按"; }
.mic-btn.busy .mic-label { opacity: .5; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 50% { box-shadow: 0 0 0 10px rgba(255,255,255,0); } }

/* Partner (face-to-face) mode: top part, upside-down. */
.partner {
  flex: 0 0 30vh; background: #fff; color: #111;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 18px calc(var(--safe-t) + 10px); transform: rotate(180deg);
}
.partner[hidden] { display: none; }
.partner-inner { text-align: center; max-height: 100%; overflow: auto; }
.partner-text { font-size: 32px; font-weight: 700; line-height: 1.3; }
.partner-pinyin { font-size: 17px; color: #555; margin-top: 6px; }
body.partner-on .top { padding-top: 8px; }
body.partner-on .mic-btn { height: 22vh; min-height: 110px; }

.login {
  position: fixed; inset: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login[hidden] { display: none; }
.login-box { width: min(100%, 360px); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.login-box img { align-self: center; border-radius: 16px; }
.login-box h2 { margin: 0 0 8px; font-size: 22px; }
.login-box input {
  font-size: 18px; padding: 14px; border-radius: 12px; border: 0;
  background: var(--panel); color: var(--text); -webkit-user-select: text; user-select: text;
}
.login-box button { height: 52px; border: 0; border-radius: 12px; font-size: 18px; font-weight: 600; background: var(--ru); color: #fff; }
.login-err { color: var(--warn); min-height: 20px; margin: 0; font-size: 15px; }

.settings {
  background: var(--panel); color: var(--text); border: 0; border-radius: 20px;
  width: min(92vw, 420px); padding: 18px;
}
.settings::backdrop { background: rgba(0,0,0,.6); }
.settings h2 { margin: 0 0 12px; font-size: 20px; }
.settings .row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--panel-2); }
.settings input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.settings .note { color: var(--muted); font-size: 13px; }
.settings button { width: 100%; height: 46px; border: 0; border-radius: 12px; font-size: 17px; margin-top: 10px; }
.settings .primary { background: var(--ru); color: #fff; }
.settings .danger { background: var(--panel-2); color: var(--warn); }
