:root {
  --frame: #cfccbf;
  --bg: #efede4;
  --card: #ffffff;
  --ink: #0b0b0b;
  --muted: #a3a196;
  --accent: #ec3b26;
  --ok: #36b37e;
  --line: #d4d1c4;
  --orig-text: #6b6a61;
  --trans-bg: #787878;
  --trans-ink: #ffffff;
  --trans-label: #000000;
  --mic-bg: #cecece;
  --mic-ring: #8a8a8a;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}
[data-theme="dark"] {
  --frame: #0c0c0e;
  --bg: #161719;
  --card: #232427;
  --ink: #f2f1ec;
  --muted: #87867f;
  --accent: #ec3b26;
  --ok: #36b37e;
  --line: #3a3b40;
  --orig-text: #c7c6c0;
  --trans-bg: #2b2c31;
  --trans-ink: #ffffff;
  --trans-label: #c7c6c0;
  --mic-bg: #2a2b30;
  --mic-ring: #4a4b52;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--frame);
  color: var(--ink);
}
::-webkit-scrollbar { display: none; }

.frame {
  min-height: 100%;
  display: flex;
  justify-content: center;
  background: var(--frame);
}

.app {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- header ---------- */
.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(48px, env(safe-area-inset-top)) 24px 0;
  flex-shrink: 0;
}
.title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1.7px;
  line-height: .9;
  color: var(--ink);
}
.title-sub { color: var(--muted); }

.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.head-btns { display: flex; gap: 8px; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 99px;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.iconbtn:active { background: var(--ink); color: var(--bg); }
.ic-moon { display: none; }
[data-theme="dark"] .ic-sun { display: none; }
[data-theme="dark"] .ic-moon { display: block; }

.status {
  display: flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 7px 12px;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); flex-shrink: 0; }
#statusText {
  font-size: 11px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--ink);
}
.status.live { border-color: var(--accent); }
.status.live .status-dot { background: var(--accent); animation: blink 1.1s ease-in-out infinite; }
.status.live #statusText { color: var(--accent); }
.status.warn .status-dot { background: #e6a700; }

/* ---------- language card ---------- */
.langcard {
  margin: 24px 24px 0;
  background: var(--card);
  border: none;
  border-radius: 22px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.lc-col { flex: 1; min-width: 0; }
.lc-right { text-align: right; }
.lc-label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.lc-val { font-size: 18px; font-weight: 600; letter-spacing: -.4px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-arrow {
  width: 34px; height: 34px; border-radius: 99px; background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------- mic ---------- */
.micwrap { display: flex; align-items: center; justify-content: center; padding: 28px 24px 22px; flex-shrink: 0; }
.mic {
  position: relative; width: 142px; height: 142px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  background: var(--mic-bg); border: 5px solid var(--mic-ring);
  transition: border-color .2s ease, transform .05s ease;
  padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.mic:active { transform: scale(.97); }
.mic:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.mic-dot {
  width: 63px; height: 63px; border-radius: 99px; background: var(--accent);
  transform: scale(var(--level, 1));
  transition: transform .08s linear, border-radius .2s ease;
}
.mic.live { border-color: var(--accent); }
.mic.live::before {
  content: ""; position: absolute; inset: -5px; border-radius: 99px;
  border: 3px solid var(--accent); animation: ring 1.4s ease-out infinite; pointer-events: none;
}
.mic.live .mic-dot { border-radius: 18px; }

@keyframes ring { 0% { transform: scale(.85); opacity: .55; } 100% { transform: scale(1.45); opacity: 0; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- panels ---------- */
.panels { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 0 24px; min-height: 0; }
.panel { border-radius: 20px; padding: 16px 18px; }
.panel-orig { background: var(--card); box-shadow: var(--shadow); flex-shrink: 0; max-height: 30vh; overflow-y: auto; }
.panel-trans { flex: 1; background: var(--trans-bg); display: flex; flex-direction: column; min-height: 120px; overflow: hidden; }
.p-label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.panel-trans .p-label { color: var(--trans-label); }
.p-text { font-size: 16px; font-weight: 500; line-height: 1.4; color: var(--orig-text); white-space: pre-wrap; }
.panel-trans .p-text { font-size: 22px; font-weight: 600; line-height: 1.25; letter-spacing: -.4px; color: var(--trans-ink); flex: 1; overflow-y: auto; }
.p-text:empty::before { content: attr(data-placeholder); opacity: .85; }
.panel-trans .p-text:empty::before { opacity: .55; }

/* ---------- error ---------- */
.error {
  margin: 12px 24px 0; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1.5px solid var(--accent); color: var(--ink); font-size: 13px; line-height: 1.4;
}

/* ---------- actions ---------- */
.actions { padding: 16px 24px calc(16px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.cta {
  width: 100%; height: 64px; border: none; border-radius: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--accent); color: #fff;
  font-size: 18px; font-weight: 600; letter-spacing: -.3px;
  transition: background .15s ease, transform .05s ease;
}
.cta:active { transform: scale(.99); }
.cta-dot { width: 12px; height: 12px; border-radius: 99px; background: #0b0b0b; transition: border-radius .2s ease; }
.cta.active { background: #0b0b0b; }
.cta.active .cta-dot { background: var(--accent); border-radius: 3px; }
[data-theme="dark"] .cta.active { background: #000; }

.action-row { display: flex; gap: 10px; margin-top: 10px; }
.ghost {
  flex: 1; height: 52px; background: transparent; border: 1.5px solid var(--line);
  border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; color: var(--ink); font-size: 15px; font-weight: 600;
}
.ghost:disabled { opacity: .45; cursor: default; }
.ghost.muted { color: var(--muted); border-style: dashed; }
.ghost.wide { width: 100%; flex: none; margin-top: 4px; }

/* ---------- settings sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; animation: fadeIn .2s ease; }
.overlay[hidden] { display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  margin: 0 auto; max-width: 460px;
  background: var(--bg); color: var(--ink);
  border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  animation: sheetUp .28s cubic-bezier(.22,1,.36,1);
  max-height: 88vh; overflow-y: auto;
}
.sheet[hidden] { display: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 14px; }
.sheet-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.6px; }
.sheet-body { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.field input[type="text"], .field input[type="password"], .field select {
  width: 100%; background: var(--card); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 13px 14px; font-size: 16px; font-family: inherit;
}
.field small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field-check span { font-size: 14px; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
.adv[open] summary { margin-bottom: 12px; }
.cta-sheet { height: 56px; font-size: 16px; }
.cta-sheet .cta-dot { display: none; }
