*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #080c18; --panel: rgba(255,255,255,0.04); --line: rgba(255,255,255,0.07);
  --text: #e2e8f0; --muted: #94a3b8; --dim: #64748b;
  --a1: #64c8ff; --a2: #a064ff; --warm: #f0abfc;
}
html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body { background: radial-gradient(ellipse at 50% 0%, #1a1440 0%, var(--bg) 60%); background-attachment: fixed; }

.app { max-width: 680px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column;
       padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
header { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 10px; }
.brand { display: flex; align-items: baseline; gap: 12px; }
h1 { font-size: 1.6rem; font-weight: 800;
     background: linear-gradient(135deg, var(--a1), var(--a2));
     -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.status { font-size: .78rem; color: var(--dim); font-weight: 600; letter-spacing: .02em; }
.status.listening { color: #f87171; } .status.thinking { color: #fbbf24; } .status.speaking { color: var(--a1); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--muted);
            width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; cursor: pointer; }

.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 2px 16px;
       scroll-behavior: smooth; }
.hint { margin: auto; text-align: center; color: var(--dim); font-size: .88rem; line-height: 1.6; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; font-size: .95rem;
       white-space: pre-wrap; word-wrap: break-word; user-select: text; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #1e3a6e, #2a2366); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { align-self: center; background: #3b1219; color: #fca5a5; font-size: .82rem; }
.msg.pending { color: var(--dim); font-style: italic; }

.controls { padding: 8px 0 14px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.orb-wrap { position: relative; }
.orb { position: relative; width: 132px; height: 132px; border-radius: 50%; border: none; cursor: pointer;
       background: radial-gradient(circle at 35% 30%, #3a2f7a, #151a3a 70%);
       box-shadow: 0 0 0 1px rgba(160,100,255,.25), 0 10px 40px rgba(100,80,255,.25);
       touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
       transition: transform .15s; }
.orb-core { position: absolute; inset: 22px; border-radius: 50%;
            background: radial-gradient(circle at 40% 35%, var(--a1), var(--a2) 60%, transparent 72%);
            opacity: .55; transition: opacity .2s, transform .2s; }
.orb-label { position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%); white-space: nowrap;
             font-size: .75rem; color: var(--dim); font-weight: 600; }
.orb.listening { transform: scale(1.06); }
.orb.listening .orb-core { background: radial-gradient(circle at 40% 35%, #fda4af, #ef4444 60%, transparent 72%);
                           opacity: .9; animation: pulse 1s ease-in-out infinite; }
.orb.thinking .orb-core { animation: spin 1.4s linear infinite;
                          background: conic-gradient(from 0deg, var(--a1), var(--a2), transparent, var(--a1)); opacity: .7; }
.orb.speaking .orb-core { opacity: .95; animation: breathe .6s ease-in-out infinite alternate; }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { to { transform: scale(1.1); } }

.text-form { width: 100%; display: flex; gap: 8px; margin-top: 18px; }
.text-form input, .login input, select { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text);
                    border-radius: 12px; padding: 11px 14px; font: inherit; font-size: .92rem; outline: none; }
.text-form input:focus, .login input:focus { border-color: rgba(160,100,255,.5); }
.text-form button { width: 46px; border-radius: 12px; border: none; cursor: pointer; color: white;
                    background: linear-gradient(135deg, #3b6fd6, #7c4ddb); font-size: 1rem; }

.sheet { position: fixed; inset: 0; background: rgba(2,4,12,.6); backdrop-filter: blur(6px);
         display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet.hidden { display: none; }
.sheet-card { width: 100%; max-width: 680px; background: #0f1428; border: 1px solid var(--line);
              border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
              display: flex; flex-direction: column; gap: 16px; }
.sheet-card h2 { font-size: 1.1rem; }
.sheet-card label { display: flex; flex-direction: column; gap: 8px; font-size: .82rem; color: var(--muted); font-weight: 600; }
select { width: 100%; appearance: none; }
select option { background: #0f1428; }
input[type=range] { width: 100%; accent-color: #8b5cf6; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; } .row form { display: flex; } .row form .btn { flex: 1; }
.btn { padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
       color: var(--text); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, #3b6fd6, #7c4ddb); border: none; }
.btn.danger { color: #fca5a5; } .btn.ghost { color: var(--muted); }
.meta { font-size: .72rem; color: var(--dim); }

.login { max-width: 340px; margin: 18vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login p { color: var(--dim); font-size: .88rem; margin-top: -6px; }
.login .err { color: #fca5a5; font-size: .85rem; }

/* ── Hands-free ── */
.modes { display: flex; gap: 4px; padding: 4px; margin-top: 20px; border-radius: 12px;
         background: var(--panel); border: 1px solid var(--line); }
.mode-btn { border: none; background: transparent; color: var(--dim); font: inherit; font-size: .8rem;
            font-weight: 600; padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.mode-btn.on { background: linear-gradient(135deg, #3b6fd6, #7c4ddb); color: white; }
.text-form { margin-top: 4px; }
.orb.standby .orb-core { opacity: .75; animation: breathe 2.2s ease-in-out infinite alternate;
                         background: radial-gradient(circle at 40% 35%, #86efac, var(--a1) 55%, transparent 72%); }
.orb.muted .orb-core { opacity: .25; filter: grayscale(1); }
.orb.loading .orb-core { opacity: .5; animation: spin 1.4s linear infinite;
                         background: conic-gradient(from 0deg, #86efac, var(--a1), transparent, #86efac); }
.status.standby { color: #86efac; } .status.muted { color: var(--dim); } .status.loading { color: #fbbf24; }
.check { flex-direction: row !important; align-items: center; gap: 10px !important; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: #8b5cf6; flex-shrink: 0; }
.check span { color: var(--text); font-weight: 500; }
