/* JARVIS — dark, green, phone-first. System fonts only (no external requests). */
:root {
  --bg: #050b08;
  --bg2: #08130e;
  --panel: #0c1a14;
  --panel2: #11231b;
  --line: #1c3a2c;
  --green: #00ff88;
  --green2: #19c37d;
  --green-dim: #0c4a31;
  --text: #e8fff4;
  --muted: #93b8a6;
  --warn: #ffcc4d;
  --danger: #ff5c6c;
  --info: #5cc8ff;
  --radius: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Ethiopic", sans-serif;
  line-height: 1.5; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
  background: radial-gradient(1200px 600px at 50% -200px, #0b2a1d 0%, var(--bg) 60%) fixed;
}
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* boot / login */
.boot, .login { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: 24px; }
.reactor { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px;
  background: radial-gradient(circle, var(--green) 0 12%, transparent 13% 30%, var(--green-dim) 31% 34%, transparent 35% 52%, var(--green2) 53% 56%, transparent 57% 74%, rgba(0,255,136,.5) 75% 79%, transparent 80%);
  box-shadow: 0 0 40px rgba(0,255,136,.35); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 70px rgba(0,255,136,.6); transform: scale(1.03); } }
.login form { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: left; }
.login h1 { text-align: center; letter-spacing: .35em; margin: 0 0 4px; color: var(--green); font-weight: 800; }
.login .sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: .9rem; }

/* layout */
.shell { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; border-bottom: 1px solid var(--line); background: rgba(5,11,8,.92); backdrop-filter: blur(8px); position: relative; z-index: 5; }
.brand { font-weight: 800; letter-spacing: .3em; color: var(--green); font-size: 1.05rem; text-shadow: 0 0 12px rgba(0,255,136,.45); }
.topbar .spacer { flex: 1; }
.main { flex: 1; overflow-y: auto; padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 18px); -webkit-overflow-scrolling: touch; }
.main.chat-main { padding-bottom: 0; display: flex; flex-direction: column; overflow: hidden; }
.banner { padding: 10px 14px; font-size: .92rem; display: flex; gap: 10px; align-items: center; }
.banner.offline { background: #3b2b05; color: var(--warn); }
.banner.demo { background: #0b2333; color: var(--info); }
.banner.error { background: #3a0d14; color: #ffc2c8; }

/* bottom navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(6, 1fr); background: rgba(8,19,14,.97); border-top: 1px solid var(--line); z-index: 10; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: .68rem; min-height: 48px; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--green); }
.nav a.active::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--green); box-shadow: 0 0 10px var(--green); }
.nav .dot { position: absolute; top: 8px; right: calc(50% - 18px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--warn); color: #000; font-size: .68rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }

/* common controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); color: #002414; border-color: var(--green); box-shadow: 0 0 18px rgba(0,255,136,.25); }
.btn.danger { background: transparent; color: var(--danger); border-color: #5a1e27; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .9rem; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn[aria-pressed="true"] { color: var(--warn); border-color: #5a4a12; }
label { display: block; font-size: .9rem; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=time], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--green2); outline: none; box-shadow: 0 0 0 3px rgba(0,255,136,.15); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--text); margin: 0; }
.check input { width: 24px; height: 24px; accent-color: var(--green); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error-text { color: var(--danger); margin: 10px 0 0; min-height: 1.4em; }
h2 { font-size: 1.25rem; margin: 6px 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.glow { box-shadow: 0 0 0 1px rgba(0,255,136,.12), 0 8px 30px rgba(0,0,0,.35); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.empty { color: var(--muted); padding: 10px 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--green); border-color: var(--green-dim); background: rgba(0,255,136,.08); }
.badge.warn { color: var(--warn); border-color: #5a4a12; background: rgba(255,204,77,.08); }
.badge.err { color: var(--danger); border-color: #5a1e27; background: rgba(255,92,108,.08); }
.badge.off { color: var(--muted); }
.badge.info { color: var(--info); border-color: #164a63; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--green-dim); border-color: var(--green2); color: var(--green); }
details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); }
pre { white-space: pre-wrap; word-break: break-word; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: .88rem; }
code { background: var(--bg2); padding: 1px 5px; border-radius: 6px; font-size: .9em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--green-dim); border-top-color: var(--green); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 12px; align-items: center; color: var(--muted); padding: 16px 0; }

/* toast & modal */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 50; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--green); padding: 12px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 20px 20px 0 0; width: min(640px, 100%); max-height: 90dvh; overflow-y: auto; padding: 20px 18px calc(20px + var(--safe-b)); }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 20px; } }

/* chat */
.messages { flex: 1; overflow-y: auto; padding: 6px 2px 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 12px 14px; border-radius: 18px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--green-dim); border: 1px solid #13704a; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.assistant.error { border-color: #5a1e27; }
.msg .md p { margin: 0 0 .6em; } .msg .md p:last-child { margin-bottom: 0; }
.msg .md ul, .msg .md ol { margin: .3em 0 .6em; padding-left: 1.3em; }
.msg .md h1, .msg .md h2, .msg .md h3 { font-size: 1.05rem; margin: .5em 0 .3em; }
.cite { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--green); background: rgba(0,255,136,.1); border: 1px solid var(--green-dim); border-radius: 6px; padding: 0 5px; margin: 0 1px; vertical-align: super; line-height: 1.5; text-decoration: none; }
.sources { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.source { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); min-height: 44px; }
.source b { color: var(--green); flex: none; }
.msg-tools { display: flex; gap: 6px; margin-top: 8px; }
.msg-tools button { min-height: 36px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: .82rem; cursor: pointer; }
.tool-status { font-size: .82rem; color: var(--muted); display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.welcome { text-align: center; color: var(--muted); padding: 24px 12px; margin: auto 0; }
.welcome .reactor { width: 72px; height: 72px; }
.suggestions { display: grid; gap: 8px; margin-top: 16px; text-align: left; }
.suggestions button { min-height: 52px; text-align: left; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--text); }
.composer { border-top: 1px solid var(--line); background: rgba(5,11,8,.96); padding: 10px 12px calc(var(--nav-h) + var(--safe-b) + 10px); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 56px; max-height: 160px; resize: none; border-radius: 18px; padding: 15px 16px; }
.send-btn { width: 56px; height: 56px; border-radius: 18px; flex: none; }
.mic-wrap { display: flex; justify-content: center; align-items: center; gap: 14px; margin-bottom: 10px; }
.mic { width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--green2); background: radial-gradient(circle, #0f3a28, #08130e); color: var(--green); display: grid; place-items: center; cursor: pointer; box-shadow: 0 0 24px rgba(0,255,136,.25); touch-action: manipulation; }
.mic svg { width: 36px; height: 36px; }
.mic.listening { background: radial-gradient(circle, var(--green), #0a8c51); color: #002414; animation: pulse 1.2s ease-in-out infinite; }
.mic:disabled { opacity: .45; }
.voice-status { min-height: 1.5em; text-align: center; font-size: .92rem; color: var(--muted); margin-bottom: 6px; }
.voice-status.live { color: var(--green); }

/* approvals */
.approval { border: 1px solid #5a4a12; background: linear-gradient(180deg, rgba(255,204,77,.06), transparent); }
.approval .payload { margin: 10px 0; }
.approval .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* briefing */
.briefing-text { white-space: normal; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; text-decoration: none; color: var(--text); }
.stat b { display: block; font-size: 1.6rem; color: var(--green); line-height: 1.2; }
.stat span { font-size: .78rem; color: var(--muted); }

/* tasks */
.task { display: flex; gap: 12px; align-items: flex-start; }
.task input[type=checkbox] { width: 28px; height: 28px; margin-top: 2px; accent-color: var(--green); flex: none; }
.task .body { flex: 1; min-width: 0; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .meta { font-size: .84rem; color: var(--muted); }
.task .meta .overdue { color: var(--danger); font-weight: 700; }

/* integrations */
.integration .scopes { font-size: .82rem; color: var(--muted); word-break: break-all; }
.activity li { font-size: .85rem; padding: 6px 0; }

@media (min-width: 900px) {
  .main { max-width: 860px; margin: 0 auto; width: 100%; }
  .composer { padding-left: calc(50% - 420px); padding-right: calc(50% - 420px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
