:root {
    --bg: #0a0e1a;
    --surface: #111631;
    --text: #e7eaf2;
    --muted: #8a93a8;
    --accent: #22d3ee;
    --accent-warm: #f59e0b;
    --danger: #f43f5e;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

main {
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    max-width: 480px;
    margin: 0 auto;
    gap: 24px;
}

header {
    text-align: center;
    width: 100%;
}

h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    transition: color 0.2s;
    min-height: 20px;
}

.status.listening { color: var(--danger); }
.status.thinking  { color: var(--accent-warm); }
.status.speaking  { color: var(--accent); }
.status.error     { color: var(--danger); }

.orb-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

.orb {
    appearance: none;
    border: none;
    background: transparent;
    width: 220px;
    height: 220px;
    position: relative;
    cursor: pointer;
    padding: 0;
    outline: none;
}

.orb:focus-visible .orb-core {
    box-shadow: 0 0 0 3px var(--accent), 0 12px 48px rgba(34, 211, 238, 0.35);
}

.orb-core {
    position: absolute;
    inset: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #1e2447, #070a14);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(34, 211, 238, 0.08);
    transition: box-shadow 0.3s;
}

.orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    pointer-events: none;
}

@keyframes pulse-ring {
    0%   { transform: scale(0.85); opacity: 0; }
    50%  { opacity: 0.7; }
    100% { transform: scale(1.15); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .orb-ring { animation: none !important; }
}

.orb.listening .orb-core {
    box-shadow: 0 0 0 0 var(--danger), 0 12px 48px rgba(244, 63, 94, 0.4),
                inset 0 0 40px rgba(244, 63, 94, 0.18);
}
.orb.listening .orb-ring   { border-color: var(--danger); animation: pulse-ring 1.4s infinite; }
.orb.listening .orb-ring.r2 { animation-delay: 0.7s; }

.orb.thinking .orb-core {
    box-shadow: 0 0 0 0 var(--accent-warm), 0 12px 48px rgba(245, 158, 11, 0.35),
                inset 0 0 40px rgba(245, 158, 11, 0.18);
}
.orb.thinking .orb-ring   { border-color: var(--accent-warm); animation: pulse-ring 1.6s infinite; }
.orb.thinking .orb-ring.r2 { animation-delay: 0.8s; }

.orb.speaking .orb-core {
    box-shadow: 0 0 0 0 var(--accent), 0 12px 48px rgba(34, 211, 238, 0.4),
                inset 0 0 40px rgba(34, 211, 238, 0.22);
}
.orb.speaking .orb-ring   { border-color: var(--accent); animation: pulse-ring 1.2s infinite; }
.orb.speaking .orb-ring.r2 { animation-delay: 0.6s; }

.transcript {
    width: 100%;
    background: var(--surface);
    border-radius: 16px;
    padding: 14px 16px;
    min-height: 120px;
    max-height: 35vh;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.line {
    margin: 0 0 10px;
    word-wrap: break-word;
}
.line:last-child { margin-bottom: 0; }
.line:empty { display: none; }

.line.you {
    color: var(--muted);
    font-style: italic;
}
.line.you::before { content: "› "; }

.line.jarvis::before {
    content: "Jarvis: ";
    color: var(--accent);
    font-weight: 600;
    font-style: normal;
}

footer {
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 13px;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 8px;
}

.btn-text:hover, .btn-text:focus-visible {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.totp-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 22, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.totp-modal[hidden] { display: none; }
.totp-card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.totp-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--text);
}
.totp-card p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14px;
}
.totp-card input {
    width: 100%;
    padding: 14px;
    font-size: 24px;
    font-family: ui-monospace, monospace;
    text-align: center;
    letter-spacing: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: var(--text);
    box-sizing: border-box;
}
.totp-card input:focus {
    outline: none;
    border-color: rgba(120, 200, 255, 0.6);
}
.totp-error {
    color: #ff7a7a !important;
    margin: 12px 0 0 !important;
    font-size: 13px !important;
}
.totp-card button {
    margin-top: 18px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4a7eff, #7c5cff);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.totp-card button:disabled { opacity: 0.6; cursor: wait; }
