:root {
  color-scheme: dark;
  --background: #0d1325;
  --cyan: #63e2cb;
  --lavender: #ada8ff;
  --line: rgba(255,255,255,.14);
  --sidepad: clamp(20px, 6.2vw, 40px);
}
* { box-sizing: border-box; }
[hidden] { display:none!important; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100%; min-height: 100%; background: var(--background);
  color: #f4f8ff; font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
button, select, input, textarea { font: inherit; }
button { cursor:pointer; -webkit-touch-callout:none; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
button:disabled { cursor: default; }
.screen {
  width: 100%; height: 100vh; height: 100dvh;
  min-height: 560px; max-width: 780px; margin: 0 auto;
  position: relative; display: grid; grid-template-rows: minmax(0,1fr) minmax(0,1fr);
  isolation:isolate; overflow:hidden; background: #121a30;
}
.half { position: relative; min-height:0; overflow:hidden; }
.audience {
  background: radial-gradient(ellipse at 50% 95%, rgba(109,100,222,.23), transparent 70%), #1c1739;
}
.speaker {
  background: radial-gradient(ellipse at 45% 5%, rgba(31,184,174,.15), transparent 70%), #0f2131;
}
.upside-down, .speaker-inner {
  height:100%; display:flex; flex-direction:column; min-height:0;
  padding-inline:var(--sidepad);
}
.upside-down {
  transform: rotate(180deg);
  padding-top:calc(17px + env(safe-area-inset-bottom, 0px));
  padding-bottom:56px;
}
.speaker-inner {
  padding-top:58px;
  padding-bottom:calc(12px + env(safe-area-inset-bottom, 0px));
}
.panel-head, .panel-foot { display:flex; align-items:center; justify-content:space-between; gap:14px; min-height:34px; }
.panel-head { flex:0 0 auto; }
.language-tag {
  display:inline-flex; align-items:center; gap:9px; border:1px solid rgba(255,255,255,.13);
  border-radius:30px; padding:8px 13px; letter-spacing:.13em; font-size:10px;
  font-weight:780; background:rgba(255,255,255,.045); white-space:nowrap;
}
.audience-tag { color:#d5d1ff; }
.speaker-tag { color:#bdfaf0; }
.language-dot { width:7px; height:7px; border-radius:50%; background:currentColor; box-shadow:0 0 12px currentColor; }
.icon-button {
  display:grid; place-items:center; border:1px solid var(--line); width:36px; height:36px;
  background: rgba(255,255,255,.045); color: #d7dbee; border-radius:11px; padding:8px;
}
.icon-button:active:not(:disabled) { background:rgba(255,255,255,.14); }
.icon-button:disabled { opacity:.35; }
svg { width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.translation-content { flex:1 1 auto; min-height:0; overflow:auto; scrollbar-width:none; display:flex; flex-direction:column; align-items:flex-start; justify-content:center; padding:12px 0 0; }
.translation-content::-webkit-scrollbar { display:none; }
.eyebrow { font-size:10px; letter-spacing:.21em; color:#a9aac8; font-weight:800; margin:0 0 12px; }
.translated {
  white-space:pre-wrap; overflow-wrap:anywhere; font-size:clamp(22px,6.7vw,39px); font-weight:730; line-height:1.17;
  letter-spacing:-.03em; color:#f8f7ff; text-wrap:pretty;
}
.translated.empty { color:#d3cdef; opacity:.53; font-size:clamp(21px,6vw,32px); font-weight:500; }
.translation-status { min-height:18px; margin-top:11px; font-size:12px; color:#c0bde7; }
.panel-foot { color:#9291b4; font-size:11px; flex:0 0 auto; margin-top:7px; }
.brandmark { display:inline-flex; gap:7px; align-items:center; font-weight:700; }
.brand-icon { background:#6763bf; color:white; width:22px; height:22px; border-radius:7px; display:grid; place-items:center; font-size:16px; }
.subtle { opacity:.7; }
.midline { height:1px; width:100%; position:absolute; top:50%; background:rgba(188,204,239,.25); z-index:3; }
.switch-button {
  position:absolute; z-index:4; top:50%; left:50%; transform:translate(-50%,-50%);
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  height:43px; min-width:118px; padding:0 16px; border:1px solid #829eaf;
  background:#eef6ff; color:#16273a; border-radius:100px;
  font-size:12px; font-weight:790; box-shadow:0 6px 20px rgba(3,11,22,.35);
}
.switch-button svg { width:19px; height:19px; stroke-width:2.5; }
.switch-button:active { transform:translate(-50%,-50%) scale(.96); }
.input-content { display:flex; flex-direction:column; flex:1 1 auto; min-height:0; margin-top:10px; }
.input-headline { display:flex; justify-content:space-between; align-items:flex-start; gap:7px; flex:0 0 auto; }
.input-headline .eyebrow { margin:10px 0 6px; color:#87b6bc; }
.online-indicator { display:flex; align-items:center; gap:6px; font-size:11px; color:#9cb6c4; white-space:nowrap; margin-top:9px; }
.online-dot { width:6px;height:6px;border-radius:50%;background:#6de0ba; box-shadow:0 0 9px rgba(109,224,186,.4); }
.online-indicator.busy .online-dot { background:#ffd67b; box-shadow:0 0 9px #ffd67b; animation:blink 1s infinite; }
.online-indicator.error .online-dot { background:#ff7d8a; }
#source-text {
  width:100%; min-height:85px; flex:1 1 auto; padding:5px 0 5px; margin:0; background:transparent;
  resize:none; border:0; color:#f5fcff; line-height:1.25;
  font-size:clamp(21px,6.1vw,34px); font-weight:630; letter-spacing:-.024em;
  overflow:auto; -webkit-appearance:none;
}
#source-text:focus { outline:none; }
#source-text[readonly] { cursor:default; }
#source-text::placeholder { color:#74909c; opacity:.75; font-weight:480; }
.input-footer { flex:0 0 auto; }
.conversation-mode { display:flex; width:max-content; padding:3px; gap:3px; border:1px solid #456274; border-radius:100px; margin:6px 0 10px; }
.conversation-mode button { border:0; border-radius:100px; padding:6px 15px; background:transparent; color:#b4cbd3; font-size:12px; font-weight:750; }
.conversation-mode button[aria-pressed="true"] { background:#d0f7ee; color:#102f35; }
.conversation-mode button:disabled { opacity:.6; }
.live-controls { display:flex; gap:8px; }
.live-button { flex:1; display:flex; align-items:center; justify-content:center; gap:9px; min-height:52px; border:0; border-radius:17px; background:#8befdd; color:#092c2e; padding:10px 12px; font-size:15px; font-weight:800; }
.live-button.active { background:#ffbdd0; color:#522033; }
.live-button:disabled { background:#284b51; color:#bad1d2; cursor:default; }
.live-dot { width:8px; height:8px; border-radius:50%; background:currentColor; flex:0 0 auto; }
.live-button.active .live-dot { animation:blink 1s infinite; }
.live-audio { border:1px solid #52727e; border-radius:17px; padding:8px 12px; background:#1a3647; color:#d2e5ed; font-size:12px; font-weight:700; min-width:99px; }
.live-audio[aria-pressed="true"] { border-color:#78dfcb; background:#275c59; color:#d7fff4; }
.live-note { font-size:11px; line-height:1.4; margin:9px 0 0; color:#a0bfca; }
.live-mode .translation-content { justify-content:flex-start; padding-top:22px; }
.live-mode .online-indicator.busy .online-dot { background:#6de0ba; box-shadow:0 0 9px rgba(109,224,186,.4); }
.recorder-hint { color:#8da8b8; font-size:11px; line-height:16px; min-height:18px; padding-top:2px; }
.controls { display:flex; gap:10px; align-items:stretch; margin-top:8px; }
.mic-button {
  background:rgba(102,231,210,.10); flex:0 0 58px; width:58px; height:57px; border:1px solid rgba(115,241,213,.35);
  border-radius:18px; color:#7cf0da; display:grid; place-items:center; padding:17px;
}
.mic-button:active { background:rgba(102,231,210,.22); }
.mic-button.recording { background:#ec5e7e; color:white; border-color:#fa90a4; animation:recordingPulse 1.6s infinite; }
.mic-button.recording svg { fill:currentColor; stroke:none; width:17px; height:17px; }
.mic-button:disabled { opacity:.45; }
.translate-button {
  flex:1; min-height:57px; border:0; border-radius:18px; display:flex; align-items:center; justify-content:center; gap:13px;
  background:#8befdd; color:#092c2e; padding:0 20px; font-size:16px; font-weight:800;
  box-shadow:0 5px 24px rgba(46,227,184,.13);
}
.translate-button:disabled { background:#284b51; color:#bad1d2; box-shadow:none; }
.translate-button svg { width:19px; height:19px; stroke-width:2.5; }
.translate-button:active:not(:disabled) { background:#c3fff0; }
.bottom-note { color:#6f8c99; text-align:center; font-size:10px; margin-top:9px; font-weight:500; letter-spacing:.01em; }
.toast {
  position:fixed; z-index:30; bottom:calc(24px + env(safe-area-inset-bottom, 0px));
  left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100% - 36px);
  padding:12px 17px; background:#f9fcff; color:#162438; border-radius:14px; box-shadow:0 8px 28px #0008; font-size:13px; font-weight:600;
}
.toast[hidden], .dialog-backdrop[hidden] { display:none!important; }
.dialog-backdrop { position:fixed; inset:0; z-index:25; background:rgba(3,9,20,.78); display:flex; align-items:end; justify-content:center; }
.settings-dialog {
  background:#f2f6fc; color:#1b2a3a; border-radius:25px 25px 0 0; width:min(100%,560px); max-height:94dvh;
  overflow-y:auto; padding:24px 24px calc(22px + env(safe-area-inset-bottom, 0px));
  box-shadow:0 -14px 70px #0008;
}
.settings-header { display:flex; align-items:start; justify-content:space-between; gap:16px; margin-bottom:18px; }
.settings-header h1 { font-size:26px; letter-spacing:-.035em; margin:0; }
.settings-header .eyebrow { color:#63768d; margin:0 0 4px; }
.icon-button.dark { border-color:#d5dde5; color:#3b5363; background:white; }
.setting-field { margin-top:15px; }
.setting-field label { display:block; font-size:12px; font-weight:760; color:#465d6e; margin-bottom:7px; }
.setting-field select, .setting-field input { width:100%; background:white; border:1px solid #cfdde4; border-radius:13px; height:46px; padding:0 13px; color:#122735; font-size:14px; }
.setting-field small { display:block; font-size:11px; line-height:1.4; color:#6b7a89; margin-top:6px; }
.settings-actions { display:flex; gap:9px; margin-top:22px; }
.settings-actions button { flex:1; height:46px; border-radius:13px; font-weight:760; font-size:13px; border:0; }
.soft-button { background:#e3ebf4; color:#2b475a; }
.save-button { background:#173845; color:white; }
.settings-privacy { font-size:11px; color:#728292; line-height:1.5; margin:17px 0 0; }
.visually-hidden { position:absolute; width:1px;height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@keyframes blink { 50% {opacity:.45;} }
@keyframes recordingPulse { 50% {box-shadow:0 0 0 8px rgba(236,94,126,.16);} }
@media (min-width:781px) { body { background:#060b18; } .screen { box-shadow:0 0 100px #0006; } }
@media (max-height:670px) {
  .upside-down { padding-top:12px; padding-bottom:37px; }
  .speaker-inner { padding-top:39px; padding-bottom:6px; }
  .translation-content { padding-top:3px; }
  .panel-foot { font-size:9px; }
  .input-content { margin-top:0; }
  .input-headline .eyebrow { margin-top:4px; }
  .recorder-hint { display:none; }
  .bottom-note { display:block; margin-top:6px; }
  .controls { margin-top:5px; }
  .mic-button,.translate-button { min-height:45px; height:45px; }
  .mic-button { width:50px; flex-basis:50px; padding:13px; }
  #source-text { min-height:60px; }
  .conversation-mode { margin:3px 0 6px; }
  .conversation-mode button { padding:4px 13px; }
  .live-button { min-height:45px; font-size:13px; }
  .live-note { display:none; }
  .live-mode .translation-content { padding-top:5px; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; scroll-behavior:auto!important; } }

/* Audio controls in both language panels */
.speaker-actions {display:flex;gap:7px;align-items:center}
.study-link {background:transparent;border:none;color:#a2f5e5;font-size:11px;font-weight:700;padding:0;text-decoration:underline;text-underline-offset:3px}
.study-link:disabled {color:#6a8991;text-decoration:none}
.study-view[hidden] {display:none!important}
.study-view {position:fixed;inset:0;z-index:20;background:#101a2d;color:#f7faff;overflow:hidden;display:flex;flex-direction:column;}
.study-header {padding:calc(14px + env(safe-area-inset-top,0px)) 18px 14px;display:flex;justify-content:space-between;gap:15px;align-items:center;border-bottom:1px solid #324258}
.study-title{font-size:11px;font-weight:800;letter-spacing:.18em;color:#99e7d8}
.back-button {border:1px solid #496479;background:#203349;color:#ecfff9;border-radius:24px;padding:9px 16px;font-size:13px;font-weight:700}
.study-scroll {overflow-y:auto;flex:1;padding:19px 16px calc(36px + env(safe-area-inset-bottom,0px));width:min(100%,780px);margin:auto}
.study-scroll h1{font-size:29px;letter-spacing:-.04em;line-height:1.15;margin:4px 0 9px}
.study-intro{font-size:13px;color:#a9c2cf;margin:0 0 21px}
.study-columns{display:flex;flex-direction:column;gap:10px}
.study-col {background:#1c3041;border:1px solid #3b5366;border-radius:19px;padding:16px;min-width:0}
.study-col:nth-child(2){background:#282345;border-color:#534e79}
.study-col-head{display:flex;flex-wrap:wrap;gap:7px;align-items:center;justify-content:space-between;font-size:10px;letter-spacing:.07em;font-weight:800;color:#bcf3eb}
.study-col:nth-child(2) .study-col-head{color:#e0d9ff}
.tiny-play{border:1px solid #517286;border-radius:20px;background:#26465b;color:white;padding:5px 9px;font-size:11px;white-space:nowrap;letter-spacing:0}
.study-phrase{font-weight:650;font-size:clamp(21px,4.6vw,29px);line-height:1.35;white-space:pre-wrap;overflow-wrap:anywhere;margin:12px 0 3px}
.study-card{background:#1b2a3b;border:1px solid #394a5f;border-radius:18px;padding:17px;margin-top:14px}
.study-card h2{font-size:17px;letter-spacing:-.02em;margin:0 0 10px}
.study-pronunciation{font-size:19px;font-weight:650;color:#c5f8ed;line-height:1.5;overflow-wrap:anywhere}
.study-fetch{background:#91eadb;color:#0d2b32;font-weight:790;border:0;border-radius:12px;padding:12px 18px}
.study-fetch:disabled{opacity:.5}
.study-disclaimer{color:#9cb3c0;font-size:11px;line-height:1.4;margin-bottom:0}
.alphabet-intro{color:#b4cbd6;font-size:12px;margin:0 0 16px;line-height:1.5}
.study-letters{display:grid;grid-template-columns:repeat(auto-fill,minmax(62px,1fr));gap:8px;font-size:13px;color:#a9c1cd}
.letter-row{display:flex;flex-direction:column;align-items:center;gap:8px;border:1px solid #425c72;border-radius:14px;background:#142337;padding:12px 5px;min-width:0}
.letter-glyph{font-size:30px;font-weight:760;color:#e8dfff;line-height:1.2}
.letter-latin{color:#a5f5df;font-size:19px;font-weight:700;line-height:1.2;white-space:nowrap}
@media(max-height:670px){.study-link{font-size:10px}.speaker-inner{padding-top:38px}.input-content{margin-top:0}}
