/* Spectre — glass dashboard. Mobile-first, tuned for iPhone home-screen use. */
:root {
  --bg: #06050f;
  --text: #f1f1ff;
  --muted: rgba(226, 228, 255, 0.62);
  --faint: rgba(226, 228, 255, 0.38);
  --stroke: rgba(255, 255, 255, 0.14);
  --stroke-strong: rgba(255, 255, 255, 0.24);
  --glass-a: rgba(255, 255, 255, 0.10);
  --glass-b: rgba(255, 255, 255, 0.035);
  --accent: #8f7dff;
  --accent-2: #35e1ff;
  --ok: #3ee0a0;
  --warn: #ffbf5a;
  --bad: #ff5d7d;
  --radius: 26px;
  --radius-sm: 16px;
  --blur: saturate(180%) blur(24px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; flex: none; }
.sprite { position: absolute; }

/* Moving aurora behind the glass */
.aurora { position: fixed; inset: -20vmax; z-index: -1; filter: blur(70px) saturate(140%); opacity: .85; }
.aurora span {
  position: absolute; border-radius: 50%;
  width: 60vmax; height: 60vmax; mix-blend-mode: screen;
  animation: drift 26s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: radial-gradient(circle, #5b3cff 0%, transparent 62%); top: 0; left: 5%; }
.aurora span:nth-child(2) { background: radial-gradient(circle, #00c2ff 0%, transparent 60%); top: 35%; right: -5%; animation-duration: 32s; }
.aurora span:nth-child(3) { background: radial-gradient(circle, #c13cff 0%, transparent 60%); bottom: -10%; left: 20%; animation-duration: 38s; }
.aurora span:nth-child(4) { background: radial-gradient(circle, #1fffb4 0%, transparent 65%); top: 10%; right: 25%; width: 35vmax; height: 35vmax; opacity: .35; animation-duration: 44s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vmax, -4vmax, 0) scale(1.12); }
  100% { transform: translate3d(-5vmax, 5vmax, 0) scale(.95); }
}
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }

/* Glass surface */
.glass {
  background: linear-gradient(145deg, var(--glass-a), var(--glass-b));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .16);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.wordmark { letter-spacing: .32em; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--stroke-strong); background: rgba(255, 255, 255, .08);
  font-weight: 600; cursor: pointer; transition: transform .12s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #5f8cff 55%, var(--accent-2));
  color: #fff; box-shadow: 0 10px 30px rgba(110, 100, 255, .45);
}
.btn.ghost { background: transparent; }
.btn.danger { color: #ffd0da; border-color: rgba(255, 93, 125, .45); background: rgba(255, 93, 125, .12); }
.btn.armed { background: linear-gradient(135deg, #ff9f43, #ff5d7d); box-shadow: 0 10px 30px rgba(255, 93, 125, .45); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 1px solid var(--stroke); background: rgba(255, 255, 255, .06); cursor: pointer;
}
.icon-btn.send { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; }
.icon-btn.listening { background: var(--bad); border-color: transparent; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 93, 125, .15); } }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom)); }
.login-card { width: min(100%, 380px); padding: 34px 26px 26px; text-align: center; display: grid; gap: 14px; }
.login-card h1 { margin: 4px 0 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; }
.logo-orb {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.35), rgba(143,125,255,.25) 45%, rgba(53,225,255,.12));
  border: 1px solid var(--stroke-strong); box-shadow: 0 0 60px rgba(143, 125, 255, .45);
}
.logo-orb svg { width: 46px; height: 46px; color: #fff; }
.field { display: grid; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
.field input {
  height: 52px; padding: 0 16px; border-radius: var(--radius-sm); font-size: 17px; color: var(--text);
  background: rgba(0, 0, 0, .25); border: 1px solid var(--stroke); outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(143, 125, 255, .2); }
#login-code { letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.error { color: #ffb3c2; min-height: 1.2em; margin: 0; font-size: 14px; }

/* App shell */
.app {
  max-width: 760px; margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 16px calc(var(--tabbar-h) + 96px + var(--safe-bottom));
}
.topbar {
  position: sticky; top: calc(8px + var(--safe-top)); z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 16px; border-radius: 999px; margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.brand svg { color: #fff; filter: drop-shadow(0 0 10px rgba(143, 125, 255, .8)); }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--stroke); background: rgba(0, 0, 0, .2);
  font-size: 13px; cursor: pointer;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px currentColor; color: var(--warn); }
.dot.ok { background: var(--ok); color: var(--ok); }
.dot.bad { background: var(--bad); color: var(--bad); }

.tab { display: grid; gap: 14px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.hero { padding: 22px 22px 20px; position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(53, 225, 255, .35), transparent 65%);
}
.hero h2 { margin: 2px 0 4px; font-size: 28px; letter-spacing: -.01em; }
.hero p { margin: 0; }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.quick-btn {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
  padding: 16px; min-height: 96px; border-radius: 22px; cursor: pointer; text-align: left; font-weight: 600;
}
.quick-btn svg { width: 26px; height: 26px; color: var(--accent-2); }
.quick-btn:active { transform: scale(.98); }
@media (min-width: 620px) { .quick { grid-template-columns: repeat(4, 1fr); } }

.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px; line-height: 20px;
  text-align: center; background: var(--bad); color: #fff; font-weight: 700;
}
.badge:empty { display: none; }
.quick-btn .badge { position: absolute; top: 12px; right: 12px; }

/* Brain switch: Spectre (email, Telegram, approvals) vs Hermes (research, memory) */
:root { --hermes: #ffcf6b; }
.brain-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 14px;
  border-radius: 18px; background: rgba(0, 0, 0, .22); border: 1px solid var(--stroke);
}
.brain-switch button {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; text-align: left;
}
.brain-switch button span { display: grid; line-height: 1.2; }
.brain-switch button b { font-size: 15px; }
.brain-switch button small { font-size: 11.5px; color: var(--faint); }
.brain-switch button.active { color: #fff; background: rgba(143, 125, 255, .22); border-color: rgba(143, 125, 255, .45); }
.brain-switch button[data-brain="hermes"].active { background: rgba(255, 207, 107, .16); border-color: rgba(255, 207, 107, .45); }
.brain-switch button[data-brain="hermes"].active svg { color: var(--hermes); }
.msg .who { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.msg.bot.hermes { border-color: rgba(255, 207, 107, .35); background: rgba(255, 207, 107, .08); }
.msg.bot.hermes .who { color: var(--hermes); }
.msg.me.hermes { background: linear-gradient(135deg, #c98a1f, #e7b14a); }

/* Chat */
.chat { padding: 14px; min-height: 160px; }
.messages { display: flex; flex-direction: column; gap: 10px; }
.msg {
  max-width: 86%; padding: 11px 15px; border-radius: 20px; white-space: pre-wrap; word-wrap: break-word;
  font-size: 15.5px; animation: rise .25s ease both;
}
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), #5f8cff); border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: rgba(255, 255, 255, .09); border: 1px solid var(--stroke); border-bottom-left-radius: 6px; }
.msg.note { align-self: center; max-width: 100%; font-size: 13px; color: var(--muted); background: none; padding: 2px 8px; text-align: center; }
.msg.typing { display: inline-flex; gap: 5px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; transform: translateY(-2px); } }
.empty { color: var(--faint); text-align: center; padding: 28px 10px; font-size: 14px; }

.composer {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px + var(--safe-bottom));
  width: min(728px, calc(100% - 32px));
  display: flex; align-items: center; gap: 8px; padding: 7px; border-radius: 999px;
}
.composer input {
  flex: 1; min-width: 0; height: 44px; padding: 0 8px 0 12px; border: 0; outline: none;
  background: transparent; font-size: 16px;
}
.composer input::placeholder { color: var(--faint); }

/* Floating bars: denser glass so scrolling content never fights with the labels */
.topbar, .composer, .tabbar {
  background: linear-gradient(145deg, rgba(34, 29, 70, .80), rgba(12, 10, 30, .78));
  border-color: rgba(255, 255, 255, .18);
}

/* Tab bar */
.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-bottom)); width: min(728px, calc(100% - 32px));
  height: var(--tabbar-h); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px; border-radius: 999px;
}
.tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; border-radius: 999px; color: var(--muted); font-size: 11px; cursor: pointer;
}
.tabbar button.active { color: #fff; background: rgba(255, 255, 255, .12); }
.tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); }

/* Lists & cards */
.section-head h2 { margin: 6px 4px 2px; font-size: 26px; }
.section-head p { margin: 0 4px; }
.list { display: grid; gap: 12px; }
.card { padding: 18px; }
.item { padding: 16px 18px; display: grid; gap: 8px; }
.item header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item h3 { margin: 0; font-size: 16px; font-weight: 600; }
.tag, .status {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .06); white-space: nowrap;
}
.status.pending { color: var(--warn); border-color: rgba(255, 191, 90, .4); }
.status.done { color: var(--ok); border-color: rgba(62, 224, 160, .4); }
.status.failed, .status.rejected { color: var(--bad); border-color: rgba(255, 93, 125, .4); }
.status.expired { color: var(--faint); }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; word-break: break-word; }
.body {
  margin: 0; padding: 12px 14px; border-radius: 14px; background: rgba(0, 0, 0, .28); border: 1px solid var(--stroke);
  white-space: pre-wrap; word-wrap: break-word; font: 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace; max-height: 260px; overflow: auto;
}
.body:empty { display: none; }
.meta { margin: 0; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.event { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 12px 14px; align-items: start; }
.event .ico {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .07);
  border: 1px solid var(--stroke);
}
.event .ico svg { width: 18px; height: 18px; }
.event.security .ico { color: var(--warn); }
.event.error .ico { color: var(--bad); }
.event.action .ico, .event.approval .ico { color: var(--ok); }
.event p { margin: 0; word-break: break-word; font-size: 14.5px; }
.event small { color: var(--faint); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.checks li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.checks li svg { width: 22px; height: 22px; color: var(--ok); }
.checks li.off svg { color: var(--warn); }
.checks b { display: block; font-weight: 600; }
.checks span { color: var(--muted); font-size: 14px; }
.actions-card { display: grid; gap: 10px; }
@media (min-width: 620px) { .actions-card { grid-template-columns: 1fr 1fr; } }

.toast {
  position: fixed; z-index: 50; left: 50%; top: calc(16px + var(--safe-top)); transform: translateX(-50%);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px);
  animation: rise .25s ease both;
}
