/* Banking Agent — engine (home page). Dark by default; indigo / purple / pink accents. */

:root {
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;

  --bg: #0b0b1a;
  --bg-2: #12122a;
  --text: #eef0ff;
  --muted: #b6b9d9;
  --faint: #9a9ec6;
  --panel: rgba(22, 22, 48, 0.86);
  --panel-solid: #17172f;
  --panel-border: rgba(165, 160, 255, 0.22);
  --field: #0f0f24;
  --field-border: rgba(165, 160, 255, 0.32);
  --chip-bg: rgba(129, 140, 248, 0.16);
  --chip-text: #d7d9ff;
  --bubble-user: linear-gradient(135deg, #5155e6, #8b3fe0);
  --bubble-user-text: #ffffff;
  --bubble-bot: #1e1e3c;
  --bubble-bot-text: #eef0ff;
  --link: #a5b4fc;
  --warn: #ff8a7a;
  --shadow: 0 1.25rem 3rem rgba(3, 3, 20, 0.55);
  --glow-a: rgba(99, 102, 241, 0.55);
  --glow-b: rgba(168, 85, 247, 0.45);
  --glow-c: rgba(244, 114, 182, 0.32);
  --tile-text: #ffffff;
  --focus: #f0abfc;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f3ff;
  --bg-2: #ebe9ff;
  --text: #17153b;
  --muted: #45437a;
  --faint: #5a5890;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --panel-border: rgba(99, 102, 241, 0.22);
  --field: #ffffff;
  --field-border: rgba(79, 70, 229, 0.35);
  --chip-bg: rgba(99, 102, 241, 0.12);
  --chip-text: #3730a3;
  --bubble-user: linear-gradient(135deg, #4f46e5, #7e22ce);
  --bubble-user-text: #ffffff;
  --bubble-bot: #efeefe;
  --bubble-bot-text: #17153b;
  --link: #4338ca;
  --warn: #b42318;
  --shadow: 0 1.25rem 3rem rgba(55, 48, 163, 0.14);
  --glow-a: rgba(99, 102, 241, 0.35);
  --glow-b: rgba(168, 85, 247, 0.28);
  --glow-c: rgba(244, 114, 182, 0.24);
  --focus: #7e22ce;
  color-scheme: light;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-font-size="md"] { font-size: 112.5%; }
html[data-font-size="lg"] { font-size: 125%; }
html[data-font-size="xl"] { font-size: 137.5%; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  position: relative;
}

h1, h2, h3, .brand-name strong, .tile-title {
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: -0.01em;
}

a { color: var(--link); }
button, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; border-radius: 0.5rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--panel-solid); color: var(--text); padding: 0.5rem 0.875rem; border-radius: 0.5rem;
}
.skip:focus { top: 1rem; }

/* Background glow — vivid, never dimmed by a scrim. */
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -10%, var(--glow-a), transparent 60%),
    radial-gradient(50rem 36rem at 92% 4%, var(--glow-b), transparent 62%),
    radial-gradient(44rem 30rem at 60% 110%, var(--glow-c), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.nav, main, .foot { position: relative; z-index: 1; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  width: 100%;
  padding: calc(0.625rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.625rem calc(1rem + env(safe-area-inset-left));
  background: var(--panel-solid);
  border-bottom: 1px solid var(--panel-border);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .nav {
    background: var(--panel);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
  }
}
.nav-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.5rem 1.25rem;
  max-width: min(100%, 83.75rem);
  margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 2.25rem; height: 2.25rem; border-radius: 0.75rem;
  background: #5b3fd6;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 55%, #be185d);
  color: #fff; font: 700 0.875rem/1 "Space Grotesk", system-ui, sans-serif;
  box-shadow: 0 0.375rem 1rem rgba(99, 102, 241, 0.45);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name strong { font-size: 1rem; }
.brand-name small { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.nav-links a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.875rem;
  padding: 0.375rem 0.75rem; border-radius: 999px;
}
.nav-links a:hover { color: var(--text); background: var(--chip-bg); }
.nav-links a[aria-current="page"] { color: var(--chip-text); background: var(--chip-bg); }
.prefs { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.sizes { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 999px; padding: 0.125rem; background: var(--chip-bg); }
.size {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  min-width: 2rem; height: 2rem; border-radius: 999px; font-weight: 700; line-height: 1;
  font-family: "Space Grotesk", system-ui, sans-serif;
}
.size[data-size="sm"] { font-size: 0.75rem; }
.size[data-size="md"] { font-size: 0.875rem; }
.size[data-size="lg"] { font-size: 1rem; }
.size[data-size="xl"] { font-size: 1.125rem; }
.size[aria-pressed="true"] { background: #4f46e5; background: linear-gradient(135deg, #4f46e5, #7e22ce); color: #fff; }
.theme-toggle {
  width: 2.25rem; height: 2.25rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--panel-border); background: var(--chip-bg); color: var(--text);
  display: grid; place-items: center;
}
.theme-toggle svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }

/* ---------- HERO (compact) ---------- */
.hero {
  text-align: center;
  padding: 1.25rem 1rem 0.875rem;
  max-width: min(100% - 2rem, 83.75rem);
  margin: 0 auto;
}
.chip {
  display: inline-block; margin: 0 0 0.5rem;
  padding: 0.25rem 0.75rem; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-text);
  border: 1px solid var(--panel-border);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.hero h1 {
  margin: 0 0 0.375rem;
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  line-height: 1.12;
}
.grad {
  background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft) 50%, var(--pink));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
:root[data-theme="light"] .grad { background: linear-gradient(90deg, #4f46e5, #9333ea 55%, #c026d3); -webkit-background-clip: text; background-clip: text; }
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .grad { color: var(--purple-soft); background: none; }
}
.sub { margin: 0 auto 0.625rem; max-width: 62rem; font-weight: 600; color: var(--muted); font-size: 0.9375rem; }
.br-wide { display: none; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 2.25rem;
  padding: 0.375rem 0.875rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.875rem;
  color: var(--chip-text); background: var(--chip-bg); border: 1px solid var(--panel-border);
}
.chip-link:hover { border-color: var(--indigo-soft); }

/* ---------- BOARD ---------- */
.board {
  width: min(100% - 2rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.cell { min-width: 0; }
.card {
  position: relative; min-width: 0;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 1.125rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow: hidden;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card { background: var(--panel); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3); }
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.1875rem;
  background: linear-gradient(90deg, var(--indigo), var(--purple), var(--pink));
}
.card.top::before { background: linear-gradient(90deg, var(--pink), var(--purple)); }
.card.shortlist::before { background: linear-gradient(90deg, var(--indigo-soft), var(--indigo)); }
.card.details::before { background: linear-gradient(90deg, var(--purple-soft), var(--pink)); }
.card h2 { margin: 0; font-size: 1.125rem; }
.card-sub { margin: 0.125rem 0 0; color: var(--muted); font-size: 0.8125rem; }

/* Chat card */
.chat {
  display: flex; flex-direction: column; gap: 0.625rem;
  container-type: inline-size; container-name: chat;
}
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.chat-titles { min-width: 0; flex: 1 1 auto; }
.chat-foot { display: flex; align-items: flex-start; gap: 0.5rem; }
.chat-foot .count-chip { flex: none; }
.chat-tools { display: flex; align-items: center; gap: 0.375rem; flex: none; }
.pill-btn { min-width: 2.25rem; justify-content: center; }
@container chat (max-width: 21.99rem) {
  .pill-btn { padding: 0; width: 2.25rem; }
  .pill-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.count-chip {
  font-size: 0.75rem; font-weight: 600; color: var(--chip-text);
  background: var(--chip-bg); border: 1px solid var(--panel-border);
  padding: 0.1875rem 0.625rem; border-radius: 999px; white-space: nowrap;
}
.icon-btn, .pill-btn {
  display: inline-flex; align-items: center; gap: 0.375rem; cursor: pointer;
  border: 1px solid var(--panel-border); background: var(--chip-bg); color: var(--text);
  height: 2.25rem; border-radius: 999px;
}
.icon-btn { width: 2.25rem; justify-content: center; }
.pill-btn { padding: 0 0.75rem; font-size: 0.8125rem; font-weight: 600; }
.icon-btn svg, .pill-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.log {
  flex: 1 1 auto; min-height: 16rem; max-height: 30rem;
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 0.625rem;
  padding: 0.25rem 0.125rem;
}
.empty { margin: auto 0; text-align: center; color: var(--muted); font-size: 0.875rem; padding: 0.5rem; }
.empty-title { color: var(--text); font-weight: 700; margin: 0 0 0.25rem; }
.empty p { margin: 0; }
.msg {
  max-width: 88%; padding: 0.625rem 0.875rem; border-radius: 1rem;
  white-space: pre-wrap; font-size: 0.9375rem; line-height: 1.5; min-width: 0;
}
.msg.user { align-self: flex-end; background: #5b4ae6; background: var(--bubble-user); color: var(--bubble-user-text); border-bottom-right-radius: 0.375rem; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); color: var(--bubble-bot-text); border-bottom-left-radius: 0.375rem; border: 1px solid var(--panel-border); }
.msg.bot a { color: var(--link); }
.msg.err { align-self: flex-start; background: transparent; color: var(--warn); border: 1px solid var(--warn); }
.typing { display: inline-flex; gap: 0.25rem; align-items: center; }
.typing i { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--field); border: 1px solid var(--field-border);
  border-radius: 1.125rem; padding: 0.375rem;
}
.composer:focus-within { border-color: var(--indigo-soft); }
.composer textarea {
  width: 100%; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
  padding: 0.5rem 0.625rem; line-height: 1.5; max-height: 9rem; font-size: 1rem;
}
.composer textarea::placeholder { color: var(--faint); opacity: 1; }
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.375rem; }
.mic, .send { cursor: pointer; border: 0; height: 2.5rem; flex: none; }
.mic {
  width: 2.5rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--panel-border);
}
.mic[hidden] { display: none; }
.mic svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic[aria-pressed="true"] { background: var(--pink); color: #2a0718; border-color: var(--pink); }
.send {
  padding: 0 1.125rem; border-radius: 999px; font-weight: 700; color: #fff;
  background: #4f46e5;
  background: linear-gradient(135deg, #4f46e5, #7e22ce);
}
.send:disabled { opacity: 0.6; cursor: wait; }
@container chat (min-width: 18.5rem) {
  .composer { flex-direction: row; align-items: flex-end; border-radius: 1.375rem; padding: 0.3125rem 0.3125rem 0.3125rem 0.5rem; }
  .composer textarea { flex: 1 1 auto; padding: 0.5rem 0.375rem; }
  .composer-actions { flex: none; }
}
.voice-msg { margin: 0; color: var(--warn); font-size: 0.8125rem; font-weight: 600; }
.note { margin: 0; color: var(--faint); font-size: 0.75rem; }

/* Full-page chat overlay */
.chat.is-full {
  position: fixed; z-index: 50;
  inset: 0;
  border-radius: 0;
  padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
  background: var(--panel-solid);
}
.chat.is-full .log { max-height: none; }
body.chat-full { overflow: hidden; }
body.chat-full main { z-index: 60; }
.i-collapse, .chat.is-full .i-expand { display: none; }
.chat.is-full .i-collapse { display: block; }

/* Side cards */
.side { display: flex; flex-direction: column; gap: 0.625rem; }
.pill {
  align-self: flex-start; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.25rem 0.625rem; border-radius: 999px; color: var(--chip-text); background: var(--chip-bg); border: 1px solid var(--panel-border);
}
.tile {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.875rem; border-radius: 0.875rem; color: var(--tile-text);
  background: #5b3fd6;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 60%, #be185d);
  min-height: 5.5rem; justify-content: flex-end;
}
.tile-kind { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #f5ecff; }
.tile-title { font-size: 1.125rem; font-weight: 700; line-height: 1.25; }
.fit { margin: 0; display: flex; align-items: baseline; gap: 0.5rem; }
.fit-label { color: var(--muted); font-size: 0.8125rem; }
.fit strong { font-family: "Space Grotesk", system-ui, sans-serif; font-size: 1.25rem; }
.why { margin: 0; color: var(--muted); font-size: 0.875rem; }

.short-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.gauge { position: relative; width: 3.25rem; height: 3.25rem; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.g-track { fill: none; stroke: var(--chip-bg); stroke-width: 5; }
.g-val { fill: none; stroke: var(--purple-soft); stroke-width: 5; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
:root[data-theme="light"] .g-val { stroke: #7e22ce; }
.gauge span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 0.875rem/1 "Space Grotesk", system-ui, sans-serif; }
.matches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.matches .placeholder { color: var(--faint); font-size: 0.875rem; }
.match-btn {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 0.5rem; justify-content: space-between;
  padding: 0.5rem 0.625rem; border-radius: 0.75rem;
  background: var(--chip-bg); border: 1px solid transparent; color: var(--text); font-size: 0.875rem;
}
.match-btn[aria-pressed="true"] { border-color: var(--indigo-soft); }
.match-btn .m-title { min-width: 0; font-weight: 600; }
.match-btn .m-score { flex: none; font: 700 0.8125rem/1 "Space Grotesk", system-ui, sans-serif; color: var(--chip-text); }

.det-name { margin: 0; font-weight: 700; }
.det-list { margin: 0; display: grid; gap: 0.375rem; }
.det-list div { display: flex; flex-direction: column; gap: 0; padding-bottom: 0.375rem; border-bottom: 1px solid var(--panel-border); }
.det-list dt { color: var(--muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.det-list dd { margin: 0; font-size: 0.875rem; }
.det-link { font-weight: 600; font-size: 0.875rem; }
.det-link[hidden] { display: none; }
.next { margin-top: 0.25rem; padding: 0.75rem; border-radius: 0.75rem; background: var(--chip-bg); border: 1px solid var(--panel-border); }
.next h3 { margin: 0 0 0.25rem; font-size: 0.875rem; }
.next p { margin: 0; font-size: 0.875rem; }

.foot { text-align: center; color: var(--faint); font-size: 0.75rem; padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom)); max-width: 60rem; margin: 0 auto; }

/* Phones: centered text, lists stay left. */
@media (max-width: 699.98px) {
  .card { text-align: center; }
  .pill { align-self: center; }
  .chat-head { flex-direction: column; align-items: center; }
  .chat-foot { flex-direction: column; align-items: center; }
  .short-head { flex-direction: column; }
  .matches, .det-list, .msg { text-align: left; }
  .fit { justify-content: center; }
  .log { min-height: 18rem; max-height: 60svh; }
}

/* Tablet: 3 columns, chat spans the top row. */
@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cell-chat { grid-column: 1 / -1; grid-row: 1; }
  .top { grid-column: 1; grid-row: 2; }
  .shortlist { grid-column: 2; grid-row: 2; }
  .details { grid-column: 3; grid-row: 2; }
  .br-wide { display: inline; }
}

/* Desktop: 4 columns, chat has a fixed window-fitting height. */
@media (min-width: 1100px) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .cell-chat { grid-column: 1; grid-row: 1; }
  .top { grid-column: 2; grid-row: 1; }
  .shortlist { grid-column: 3; grid-row: 1; }
  .details { grid-column: 4; grid-row: 1; }
  .chat:not(.is-full) { height: clamp(22rem, 100vh - 21rem, 38rem); height: clamp(22rem, 100svh - 21rem, 38rem); }
  .chat .log { min-height: 0; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
