:root {
  --bg: #f4f6fa; --card: #fff; --soft: #f0f3f9; --ink: #1b2333; --muted: #6b7385; --line: #e8ecf3;
  --blue: #2f6bff; --green: #16a34a; --orange: #ea8a00; --red: #dc2626; --warn: #b45309;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12141a; --card: #1b1e26; --soft: #242836; --ink: #e8eaf0; --muted: #a0a6b6; --line: #2a2e3a;
          --blue: #5b8cff; --warn: #f2b45a; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { max-width: 900px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; background: var(--bg); }

.top { display: flex; align-items: center; padding: 10px 16px; background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { display: block; font-size: 1.2rem; font-weight: 800; }
.brand small { display: block; font-size: .72rem; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 4px; }
.icon { background: none; border: 0; font-size: 1.3rem; padding: 6px 10px; border-radius: 10px; }
.icon:hover { background: var(--soft); }

.unsupported { margin: 12px 16px; padding: 14px; border-radius: 14px; background: #fff7e6; color: #7a4a00; }
.unsupported p { margin: 6px 0 0; font-size: .92rem; line-height: 1.5; }

.langbar { display: flex; align-items: center; gap: 8px; padding: 4px 16px 12px; background: var(--card); }
.chip { flex: 1; min-width: 0; text-align: left; background: var(--soft); border: 0; border-radius: 14px; padding: 9px 14px; position: relative; }
.chip small { display: block; font-size: .75rem; color: var(--muted); }
.chip b { display: block; font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .reset { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--muted); padding: 4px; }
.swap { color: var(--muted); font-size: 1.2rem; }

.status { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 16px 10px; }
.status-row { display: flex; align-items: center; gap: 8px; }
.dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.06); transition: transform .12s; font-size: 1rem; }
.status b { font-size: 1rem; }
.spacer { flex: 1; }
.dl { font-size: .82rem; color: var(--muted); }
.partial { margin-top: 6px; font-size: 1.1rem; font-style: italic; }
.notice { margin-top: 6px; font-size: .9rem; color: var(--warn); }
.st-listening b { color: var(--green); } .st-listening .dot { background: rgba(22,163,74,.15); }
.st-translating b { color: var(--orange); } .st-translating .dot { background: rgba(234,138,0,.15); }
.st-speaking b { color: var(--blue); } .st-speaking .dot { background: rgba(47,107,255,.15); }

.picker { background: #eff4ff; padding: 10px 0 10px 16px; }
@media (prefers-color-scheme: dark) { .picker { background: #1f2a44; } }
.picker b { font-size: .9rem; }
.picker-list { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 2px 0; }
.picker-list button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 1rem; }

.chat { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.empty { text-align: center; padding: 48px 24px; }
.empty-icon { font-size: 3.4rem; }
.empty h2 { font-size: 1.25rem; margin: 12px 0 6px; }
.empty p { color: var(--muted); line-height: 1.6; margin: 0; }
.bubble { max-width: 82%; margin: 6px 0; padding: 12px 10px 12px 16px; border-radius: 18px; background: var(--card);
  box-shadow: 0 2px 6px rgba(0,0,0,.08); border-bottom-left-radius: 4px; }
.bubble.mine { margin-left: auto; background: var(--blue); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 4px; }
.bubble .meta { font-size: .75rem; opacity: .7; }
.bubble .orig { font-size: .95rem; opacity: .85; margin-top: 4px; }
.bubble .tr { display: flex; align-items: flex-end; gap: 4px; margin-top: 6px; }
.bubble .tr b { font-size: 1.45rem; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.bubble .tr button { background: none; border: 0; font-size: 1.15rem; opacity: .8; padding: 2px 6px; }

.controls { background: var(--card); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; }
.auto { width: 100%; height: 58px; border: 0; border-radius: 18px; background: var(--blue); color: #fff; font-size: 1.2rem; font-weight: 800; }
.auto.on { background: var(--red); }
.auto:disabled { opacity: .5; }
.talk { display: flex; gap: 10px; margin-top: 10px; }
.talkbtn { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px; background: var(--soft); padding: 12px; text-align: left; user-select: none; -webkit-user-select: none; }
.talkbtn b { display: block; font-size: 1rem; }
.talkbtn small { display: block; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talkbtn.active { background: #dcfce7; }
@media (prefers-color-scheme: dark) { .talkbtn.active { background: #14532d; } }
.hint { text-align: center; font-size: .76rem; color: var(--muted); margin: 8px 0 0; }
.hint a { color: var(--muted); }

dialog { border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: 88vh; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.sheet { padding: 8px 20px 24px; }
.sheet-head { display: flex; align-items: center; }
.sheet-head h2 { flex: 1; font-size: 1.3rem; }
.h { display: block; font-weight: 700; margin: 18px 0 8px; }
.muted { color: var(--muted); font-size: .88rem; line-height: 1.5; margin: 4px 0 8px; }
select { width: 100%; font: inherit; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; }
.seg button.on { background: #e1e8ff; font-weight: 700; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #2b3a63; } }
.cands { display: flex; flex-wrap: wrap; gap: 8px; }
.cands button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 10px; }
.cands button.on { background: #e1e8ff; border-color: #b9c8ff; }
@media (prefers-color-scheme: dark) { .cands button.on { background: #2b3a63; border-color: #3e5490; } }
input[type=range] { width: 100%; }
.picklist button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 6px; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
