:root {
  --bg: #0f1420; --panel: #182033; --line: #2a3550; --text: #eef2fa; --muted: #9aa6bf;
  --accent: #7c9cff; --accent-2: #b48cff; --me: #2b3a63; --danger: #ff8a8a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 0;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; }
.top h1 { font-size: 20px; margin: 0; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 15px; }
.primary { background: var(--accent); color: #0b1020; border: 0; border-radius: 999px; padding: 13px 26px; font-weight: 700; text-decoration: none; display: inline-block; }
.primary.small { padding: 9px 16px; font-size: 15px; }
.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); border-radius: 999px; padding: 9px 16px; font-size: 15px; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 0 16px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 14px; position: sticky; top: 0; background: linear-gradient(var(--bg) 85%, transparent); z-index: 1; }

.orb { width: 132px; height: 132px; border-radius: 50%; border: 0; padding: 0; background: radial-gradient(circle at 35% 30%, #3a4a7a, #1a2340); display: grid; place-items: center; transition: transform .2s; }
.orb-core { width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); opacity: .35; transition: opacity .3s, transform .3s; }
.orb.standby .orb-core { opacity: .6; animation: breathe 3.2s ease-in-out infinite; }
.orb.listening .orb-core { opacity: 1; animation: pulse 1.1s ease-in-out infinite; }
.orb.thinking .orb-core { opacity: .8; animation: spin 1.4s linear infinite; border-radius: 38%; }
.orb.speaking .orb-core { opacity: 1; animation: talk .55s ease-in-out infinite alternate; }
@keyframes breathe { 50% { transform: scale(1.12); } }
@keyframes pulse { 50% { transform: scale(1.3); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes talk { to { transform: scale(1.22, .86); } }
@media (prefers-reduced-motion: reduce) { .orb-core { animation: none !important; } }

.status { margin: 0; font-size: 18px; font-weight: 600; text-align: center; }
.hearing { margin: 0; min-height: 1.5em; color: var(--muted); text-align: center; font-size: 16px; }
.notice { margin: 0; background: #3a2a1a; border: 1px solid #6b4d26; color: #ffd9a3; padding: 10px 14px; border-radius: 12px; font-size: 15px; }

.log { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 16px; }
.bubble { max-width: 86%; padding: 11px 15px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 6px; }
.bubble.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.error { border-color: #6b4d26; color: #ffd9a3; }

.composer { display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; }

dialog { border: 0; padding: 0; background: transparent; width: min(560px, 100vw); max-width: 100vw; max-height: 92dvh; margin: auto auto 0; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.sheet { background: var(--panel); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 92dvh; overflow-y: auto; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.sheet label.row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.sheet input[type="text"], .sheet input[type="password"], .sheet input[type="email"], .sheet select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text); width: 100%;
}
.sheet input[type="checkbox"] { width: 22px; height: 22px; }
.sheet details { background: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.sheet details ol { padding-left: 20px; margin: 8px 0; }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.small-note { color: var(--muted); font-size: 14px; margin: 0; }

.note { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.note h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.note pre { margin: 0 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 16px; }
.note-actions { display: flex; gap: 8px; align-items: center; }
.err-detail { display: block; margin-top: 6px; font-size: 13px; opacity: .8; user-select: text; -webkit-user-select: text; }
