:root {
  --bg: #05080d; --panel: #0b121b; --panel2: #101a26; --line: #1b2a3b;
  --cyan: #4fd8ff; --cyan-dim: #1f6f8a; --text: #d7e6f2; --muted: #7d93a8;
  --red: #ff5c6c; --amber: #ffb547; --green: #47e0a0;
  --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
body { background: radial-gradient(ellipse at 50% -10%, #0c2233 0%, var(--bg) 60%) fixed; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
button:active { transform: scale(.98); }
button.primary { background: linear-gradient(180deg, #23a7d6, #157a9f); border-color: #3cc8f5; color: #021018; font-weight: 600; }
button.danger { background: #3a1117; border-color: var(--red); color: #ffd6da; }
button.wide { width: 100%; margin: 6px 0; }
button.icon { background: none; border: 0; padding: 6px 8px; font-size: 20px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; }
input:focus, textarea:focus { border-color: var(--cyan-dim); }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--red); min-height: 1.4em; }
h3 { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; }

.screen { height: 100%; display: flex; flex-direction: column; }
#lock { align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
#lock input { width: 260px; text-align: center; margin-bottom: 10px; display: block; }
.brand { font-weight: 300; letter-spacing: .35em; color: var(--cyan); text-shadow: 0 0 12px rgba(79,216,255,.5); }
h1.brand { font-size: 26px; margin: 8px 0 0; }

/* arc reactor */
.reactor { position: relative; border-radius: 50%; display: grid; place-items: center; }
.reactor i { position: absolute; border-radius: 50%; border: 2px solid var(--cyan); box-shadow: 0 0 18px rgba(79,216,255,.6), inset 0 0 12px rgba(79,216,255,.4); }
.reactor.big { width: 150px; height: 150px; }
.reactor.big i:nth-child(1) { inset: 0; border-style: dashed; animation: spin 14s linear infinite; }
.reactor.big i:nth-child(2) { inset: 22px; border-width: 4px; opacity: .8; animation: spin 8s linear infinite reverse; border-right-color: transparent; }
.reactor.big i:nth-child(3) { inset: 52px; background: radial-gradient(circle, #e8fbff 0%, var(--cyan) 45%, transparent 75%); border: 0; animation: pulse 2.4s ease-in-out infinite; }
.reactor.small { width: 26px; height: 26px; }
.reactor.small i:nth-child(1) { inset: 0; border-width: 1px; border-style: dashed; animation: spin 10s linear infinite; }
.reactor.small i:nth-child(2) { inset: 5px; border-width: 1px; border-right-color: transparent; animation: spin 5s linear infinite reverse; }
.reactor.small i:nth-child(3) { inset: 9px; background: var(--cyan); border: 0; animation: pulse 2.4s infinite; }
.thinking .reactor i:nth-child(2) { animation-duration: .9s; }
.thinking .reactor i:nth-child(3) { animation-duration: .7s; }
.listening .reactor i { border-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; transform: scale(.85); } }

header { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 8px) 14px 8px; border-bottom: 1px solid var(--line); }
header .brand { flex: 1; font-size: 15px; }
main { flex: 1; overflow: hidden; position: relative; }
.tab { position: absolute; inset: 0; overflow-y: auto; padding: 12px 12px 24px; display: none; -webkit-overflow-scrolling: touch; }
.tab.active { display: block; }
nav { display: flex; border-top: 1px solid var(--line); background: rgba(5,8,13,.92); padding-bottom: var(--safe-b); }
nav button { flex: 1; background: none; border: 0; border-radius: 0; font-size: 11px; color: var(--muted); padding: 8px 0 6px; position: relative; }
nav button span { display: block; font-size: 20px; }
nav button.active { color: var(--cyan); }
nav b { position: absolute; top: 4px; right: 24%; background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; }

/* chat */
#tab-chat { display: none; flex-direction: column; padding: 0; }
#tab-chat.active { display: flex; }
#log { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #12384a; border: 1px solid #1d5770; 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 .via { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg code { background: #0f1d29; padding: 1px 5px; border-radius: 5px; }
#composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px; border-top: 1px solid var(--line); }
#composer textarea { flex: 1; resize: none; max-height: 140px; border-radius: 20px; }
.mic.on { color: var(--green); text-shadow: 0 0 10px var(--green); }

/* mail */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.card b { display: block; font-size: 22px; color: var(--cyan); font-weight: 500; }
.card.red b { color: var(--red); }
.card span { font-size: 12px; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.panel.danger { border-color: #6b2630; background: #170b0f; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: var(--cyan); transition: width .4s; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; }
.chip { white-space: nowrap; font-size: 13px; padding: 6px 11px; border-radius: 20px; }
.chip.on { border-color: var(--cyan); color: var(--cyan); }
#senderSearch { width: 100%; margin-bottom: 8px; }
.sender { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.sender.risky { border-color: #6b2630; }
.sender .top { display: flex; justify-content: space-between; gap: 8px; }
.sender .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender .addr { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender .meta { font-size: 12px; color: var(--muted); margin: 4px 0; }
.sender .reason { font-size: 13px; }
.sender .flags { font-size: 12px; color: var(--red); }
.sender select { width: 100%; margin-top: 6px; padding: 7px 10px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); margin-right: 4px; }
.tag.phishing, .tag.spam { color: var(--red); border-color: #6b2630; }
.tag.done { color: var(--green); }
.sticky-apply { position: sticky; bottom: -24px; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; }
.sticky-apply label { display: block; font-size: 13px; margin-bottom: 4px; }
.sticky-apply select { padding: 4px 8px; }

/* projects / approvals */
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.item .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.item .row button { font-size: 14px; padding: 7px 11px; }
.item pre, dialog pre { white-space: pre-wrap; font-size: 12px; color: var(--muted); margin: 6px 0 0; max-height: 220px; overflow: auto; }
.status-done { color: var(--green); } .status-failed { color: var(--red); } .status-running { color: var(--amber); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; width: min(92vw, 420px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
dialog .row { display: flex; gap: 8px; margin-top: 14px; } dialog .row button { flex: 1; }
