:root {
  --bg: #0a0e14; --panel: #121822; --panel2: #18202c; --line: #232e3d; --text: #e6edf5; --dim: #8a99ad;
  --accent: #4fd8ff; --accent2: #1a8fb8; --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "Segoe UI", system-ui, sans-serif; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

#app { display: flex; flex-direction: column-reverse; height: 100dvh; }
#nav { display: flex; background: rgba(18, 24, 34, .92); backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding-bottom: var(--sab); flex: none; z-index: 5; }
#nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 7px; color: var(--dim); font-size: 11px; position: relative; }
#nav button.on { color: var(--accent); }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: #fff; font: 600 11px/17px system-ui; font-style: normal; text-align: center; padding: 0 4px; }
#view { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--sat) + 14px) 16px 24px; }
#view.chat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

@media (min-width: 900px) {
  #app { flex-direction: row; }
  #nav { flex-direction: column; width: 92px; border-top: 0; border-right: 1px solid var(--line); padding: 18px 0; gap: 6px; }
  #nav button { flex: none; padding: 12px 0; }
  #view { padding: 28px max(28px, calc(50% - 480px)); }
  #view.chat { padding: 0 max(0px, calc(50% - 480px)); }
}

h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); margin: 26px 2px 10px; font-weight: 600; }
.sub { color: var(--dim); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.card.tap:active { background: var(--panel2); }
.title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: 13px; color: var(--dim); }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.dot.live { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.busy { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #04222d; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); color: var(--dim); margin: 3px 4px 0 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }

input[type=text], input[type=password], input[type=time], input[type=tel], input[type=url], textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none; }
input:focus, textarea:focus { border-color: var(--accent2); }
label.f { display: block; font-size: 13px; color: var(--dim); margin: 12px 0 5px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; transition: .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked { background: var(--accent2); }
.switch input:checked::after { left: 23px; }

/* home */
.hero { display: flex; align-items: center; gap: 16px; margin: 6px 0 4px; }
.talk { width: 76px; height: 76px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 50%, #c9f4ff 0, var(--accent) 18%, #0b4a63 55%, #071a24 75%); box-shadow: 0 0 28px rgba(79, 216, 255, .45), inset 0 0 14px rgba(255, 255, 255, .25); animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 44px rgba(79, 216, 255, .7), inset 0 0 14px rgba(255, 255, 255, .25); } }
.approval { border-color: var(--warn); }
.approval pre { max-height: 180px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 11px; }
.stat b { font-size: 21px; display: block; }
.bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar i.hot { background: var(--warn); }
.feed .item { display: flex; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.feed .item:last-child { border: 0; }
.feed .k { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--dim); }
.k.approval, .k.security { background: var(--warn); } .k.jarvis, .k.schedule { background: var(--accent); } .k.activity { background: var(--good); } .k.call { background: #c084fc; }

/* chat */
.chat-head { display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 10px) 12px 10px; border-bottom: 1px solid var(--line); flex: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--dim); flex: none; }
.icon-btn:active { background: var(--panel2); }
.icon-btn.accent { color: var(--accent); }
#msgs { flex: 1; overflow-y: auto; padding: 14px 14px 6px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 88%; margin-bottom: 12px; padding: 10px 14px; border-radius: 18px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { margin-left: auto; background: var(--accent2); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg h4 { margin: 8px 0 4px; font-size: 15px; }
.msg .err { color: var(--bad); font-size: 14px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; font: 12.5px/1.45 ui-monospace, Consolas, monospace; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
code { font: 13px ui-monospace, Consolas, monospace; background: rgba(255, 255, 255, .07); padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: pulse 1s infinite; } .typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--sab)); border-top: 1px solid var(--line); flex: none; background: var(--bg); }
@media (max-width: 899px) { #view.chat .composer { padding-bottom: 8px; } }
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #04222d; display: grid; place-items: center; flex: none; }
.send.stop { background: var(--bad); color: #fff; }
.mic.rec { color: var(--bad); animation: pulse 1s infinite; }
.empty { text-align: center; color: var(--dim); padding: 60px 20px; }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.sheet-body { position: relative; width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 22px 22px 0 0; padding: 18px 16px calc(22px + var(--sab)); border: 1px solid var(--line); border-bottom: 0; animation: up .22s ease-out; }
@media (min-width: 900px) { #sheet { align-items: center; } .sheet-body { border-radius: 22px; border-bottom: 1px solid var(--line); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-body h3 { margin: 0 0 12px; font-size: 19px; }
.list .li { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.list .li:last-child { border: 0; }
.shot { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; background: #000; min-height: 120px; }

/* voice */
#voice { position: fixed; inset: 0; z-index: 30; background: radial-gradient(circle at 50% 40%, #0d2430, #05080c 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 30px; }
.voice-close { position: absolute; top: calc(var(--sat) + 14px); right: 18px; width: 44px; height: 44px; font-size: 20px; color: var(--dim); }
#orb { width: 190px; height: 190px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, rgba(79, 216, 255, .16), transparent 70%); border: 2px solid rgba(79, 216, 255, .5); transition: transform .08s linear; }
#orb span { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, #d9f8ff 0, var(--accent) 25%, #0b4a63 70%); box-shadow: 0 0 60px rgba(79, 216, 255, .7); }
#voice.thinking #orb { animation: spin 1.4s linear infinite; border-style: dashed; }
#voice.speaking #orb span { animation: breathe 1s ease-in-out infinite; }
#voice.paused #orb { opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }
#voice-state { font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
#voice-text { max-width: 520px; text-align: center; color: var(--text); min-height: 4.5em; max-height: 34dvh; overflow: auto; font-size: 17px; }

#gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
#gate .box { width: 100%; max-width: 360px; text-align: center; }
#gate .talk { margin: 0 auto 22px; }
#offline { position: fixed; top: calc(var(--sat) + 8px); left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 7px 16px; border-radius: 20px; font-size: 13px; z-index: 40; white-space: nowrap; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--sab) + 84px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: #223044; border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: 86%; animation: up .2s; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
