/* Colors: light, then dark (follows the phone unless chosen in Settings) */
:root{--bg:#F3EEE2;--card:#FFFCF5;--card2:#EDE6D6;--ink:#1B2826;--muted:#5F6B66;--line:#D8CFBA;--accent:#1F7A72;--soft:#DAEBE5;--streak:linear-gradient(135deg,#1F7A72,#134F4A);--red:#B8372E;--warm:#F6E2DE;--hint:#2A7A4F;--on:#fff;--hero-fig:#fff;color-scheme:light}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--bg:#121315;--card:#1A1B1E;--card2:#232427;--ink:#ECEDEA;--muted:#92979A;--line:#2D2F33;--accent:#5CC0B1;--soft:#16211F;--streak:linear-gradient(135deg,#15302E,#1B4642 50%,#173C39);--red:#E5584C;--warm:#2A1817;--hint:#5FB07A;--on:#0B1514;--hero-fig:#ECEDEA;color-scheme:dark}}
:root[data-theme=dark]{--bg:#121315;--card:#1A1B1E;--card2:#232427;--ink:#ECEDEA;--muted:#92979A;--line:#2D2F33;--accent:#5CC0B1;--soft:#16211F;--streak:linear-gradient(135deg,#15302E,#1B4642 50%,#173C39);--red:#E5584C;--warm:#2A1817;--hint:#5FB07A;--on:#0B1514;--hero-fig:#ECEDEA;color-scheme:dark}
*{box-sizing:border-box}[hidden]{display:none!important}
body{margin:0;min-height:100dvh;background:var(--bg);color:var(--ink);font:16px/1.5 -apple-system,BlinkMacSystemFont,"Apple SD Gothic Neo","Noto Sans KR",sans-serif;-webkit-tap-highlight-color:transparent}
main{max-width:480px;margin:0 auto;padding:calc(env(safe-area-inset-top) + 16px) 18px calc(env(safe-area-inset-bottom) + 24px)}
section{display:flex;flex-direction:column;gap:14px}
h1{font-size:34px;margin:8px 0 0;letter-spacing:-.5px}h2{margin:0}h3{margin:8px 0 0;font-size:17px}
header{text-align:center}header p{margin:0;color:var(--muted);letter-spacing:.08em;text-transform:uppercase;font-size:12px}
header::after{content:"";display:block;width:56px;height:3px;margin:12px auto 0;border-radius:3px;background:var(--accent)}
button,input,select,textarea{font:inherit;color:inherit}
button{min-height:50px;padding:10px 16px;border:1px solid var(--line);border-radius:14px;background:var(--card);font-weight:600;cursor:pointer}
button:disabled{opacity:.4}button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.primary{background:var(--accent);border-color:var(--accent);color:var(--on)}.danger{background:var(--warm);border-color:var(--red);color:var(--red)}
.back{align-self:flex-start;border:0;background:none;padding:0;color:var(--accent)}
.row{display:flex;gap:10px}.row>*{flex:1}
label{display:flex;flex-direction:column;gap:4px;font-weight:600}
input:not([type=radio]):not([type=checkbox]),select,textarea{width:100%;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--card);font-weight:400;font-size:16px}
::placeholder{color:var(--muted);opacity:.75}
fieldset{border:0;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}legend{font-weight:600;margin-bottom:4px}
.choice{flex-direction:row;align-items:center;gap:12px;padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--card)}
.choice:has(:checked){border-color:var(--accent);background:var(--soft)}
.choice span{display:flex;flex-direction:column}.choice small{font-weight:400;color:var(--muted)}.choice input{width:20px;height:20px;accent-color:var(--accent)}
.note{color:var(--muted);font-size:14px;margin:0}

.stage{display:flex;justify-content:center;align-items:center}
.stage svg{width:100%;max-width:320px;height:300px}
/* Korea: taegeuk red and blue */
.stage .top{fill:#cd2e3a}.stage .yin{fill:#0047a0}
.stage .halo{fill:#cd2e3a;opacity:.13}.stage .wave{fill:#0047a0;opacity:.2}
/* Japan: red sun, white rings */
:lang(ja) .stage .top{fill:#bc002d}:lang(ja) .stage .yin{display:none}
:lang(ja) .stage .halo,:lang(ja) .stage .wave{fill:#fff;stroke:#8884;stroke-width:1}
:lang(ja) .stage .halo{opacity:.55}:lang(ja) .stage .wave{opacity:.95}
#home .stage{background:var(--card2);border:1px solid var(--line);border-radius:24px;padding:10px}#home .stage svg{height:260px}

/* full-screen call */
#call{position:fixed;inset:0;max-width:480px;margin:0 auto;padding:calc(env(safe-area-inset-top) + 12px) 18px calc(env(safe-area-inset-bottom) + 18px);gap:10px;align-items:stretch}
.topbar{display:flex;justify-content:space-between;align-items:center}.topbar button{min-height:44px;border-radius:99px}
#timer{margin:0;color:var(--muted);font-variant-numeric:tabular-nums}
.bubble{flex:0 1 auto;display:flex;flex-direction:column;min-height:0;max-height:24dvh;padding:10px 14px;border:1px solid var(--line);border-radius:18px;background:var(--card)}
.bubble small{font-size:11px;color:var(--accent);font-weight:700}.bubble p{margin:0;overflow-y:auto;font-size:18px}
.bubble.me{background:var(--card2)}.bubble.me small{color:var(--red)}
#call .stage{flex:1 1 0;min-height:110px}#call .stage svg{height:100%;max-width:100%}
#status{margin:0;text-align:center;color:var(--muted);font-size:14px}
.controls{flex:none;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;column-gap:22px}
#talk{grid-column:2;width:84px;height:84px;padding:0;border-radius:50%;border:3px solid var(--accent);background:var(--card);display:grid;place-items:center}
#cancel{grid-column:1;grid-row:1;justify-self:end;width:52px;height:52px;min-height:0;padding:0;border-radius:50%;border:1px solid var(--line);color:var(--muted);font-size:20px}
#talk{grid-row:1}
#talk span{width:62px;height:62px;border-radius:50%;background:var(--accent);transition:.18s}
#talk.on{border-color:var(--red);box-shadow:0 0 0 9px var(--warm)}#talk.on span{width:30px;height:30px;border-radius:8px;background:var(--red)}

.card{background:var(--card);border-radius:14px;padding:12px;border:1px solid var(--line)}.card p{margin:2px 0}
.said{color:var(--red)}.better{color:var(--hint);font-weight:700}
.item{display:flex;gap:8px}#contactList{display:flex;flex-direction:column;gap:10px}
.item .contact-call{display:flex;align-items:center;gap:12px;min-width:0}.who{flex:1;display:flex;flex-direction:column;min-width:0;overflow-wrap:anywhere}.who small{color:var(--muted);font-weight:400}
.avatar{flex:none;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:var(--streak);color:var(--hero-fig);font-size:20px}.item button:first-child{flex:1;text-align:left}
details p{margin:6px 0}
label.volume{flex-direction:row;align-items:center;gap:10px;align-self:center;width:100%;max-width:260px}
.volume input:not([type=radio]):not([type=checkbox]){padding:0;border:0;background:none;height:32px;accent-color:var(--accent)}
.loading{display:flex;flex-direction:column;align-items:center;gap:6px;padding:56px 0}.loading b{font-size:18px}
.dots{position:relative;width:76px;height:76px;margin-bottom:18px}
.dots i{position:absolute;left:32px;top:32px;width:12px;height:12px;border-radius:50%;background:var(--accent);transform:rotate(calc(var(--i)*45deg)) translateY(-32px);animation:dot 1s linear infinite;animation-delay:calc(var(--i)*.125s - 1s)}
@keyframes dot{0%{opacity:1}100%{opacity:.15}}
.langs{display:flex;gap:6px;padding:5px;border:1px solid var(--line);border-radius:18px;background:var(--card)}
.langs button{flex:1;min-height:44px;border:0;background:none;color:var(--muted)}
.langs button[aria-pressed=true]{background:var(--accent);color:var(--on)}
:lang(ja) body,body :lang(ja){font-family:-apple-system,"Hiragino Sans","Noto Sans JP",sans-serif}
.bubble .lines{min-height:0;overflow-y:auto}.bubble .lines p{overflow:visible}
.bubble .romaji{color:var(--ink)}.bubble .english{color:var(--muted);font-size:15px;border-top:1px solid var(--line);margin-top:6px;padding-top:6px}
#call.ja .bubble #aiMsg,#call.ja .bubble #meMsg{font-size:15px;color:var(--muted)}#call.ja .bubble .romaji{font-size:19px;color:var(--ink)}
#call.ja .bubble.ai{max-height:36dvh}#call.ja .stage{min-height:60px}
.actions{flex:none;display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.actions button{min-height:36px;padding:4px 12px;font-size:13px;border-radius:99px}.actions button{background:var(--card2)}.actions button[aria-pressed=true]{border-color:var(--accent);background:var(--soft)}
.card .sub{font-weight:400;font-size:14px}
@media (prefers-reduced-motion:reduce){.dots i{animation-duration:3s}}

/* Classic printed Korean and brush Japanese lettering (open-license fonts, only the characters we use) */
@font-face{font-family:SoriKo;src:url(fonts/song-myung.woff2) format("woff2");font-display:swap}
@font-face{font-family:SoriJa;src:url(fonts/yuji-syuku.woff2) format("woff2");font-display:swap}
#home #appName{font-family:SoriKo,serif;font-weight:400;font-size:58px;letter-spacing:0;line-height:1.15}
:lang(ja) #home #appName{font-family:SoriJa,serif;font-size:52px;letter-spacing:-.05em}
/* Buttons use the lettering for Korean and Japanese characters only; English stays in the normal font */
@font-face{font-family:SoriKoText;src:url(fonts/song-myung.woff2) format("woff2");unicode-range:U+3000-FFFF;font-display:swap}
@font-face{font-family:SoriJaText;src:url(fonts/yuji-syuku.woff2) format("woff2");unicode-range:U+3000-FFFF;font-display:swap}
.langs button[data-lang=ko]{font-family:SoriKoText,-apple-system,Inter,sans-serif;font-weight:400;font-size:19px}
.langs button[data-lang=ja]{font-family:SoriJaText,-apple-system,Inter,sans-serif;font-weight:400;font-size:19px}
