/* Event Agent engine: dark glass template, indigo/purple/pink accents */

:root,
html[data-theme="dark"] {
  --bg: #0b0b1a;
  --bg-2: #13122b;
  --text: #eef0ff;
  --muted: #b9bce0;
  --faint: #a3a6d1;
  --panel: rgba(24, 23, 52, 0.72);
  --panel-solid: #181734;
  --panel-border: rgba(165, 160, 255, 0.22);
  --field: rgba(10, 10, 28, 0.78);
  --field-solid: #0d0d22;
  --field-border: rgba(165, 160, 255, 0.34);
  --bubble-user: #4f46e5;
  --bubble-user-text: #ffffff;
  --bubble-bot: rgba(40, 38, 82, 0.9);
  --bubble-bot-solid: #28264f;
  --chip-bg: rgba(129, 140, 248, 0.16);
  --chip-text: #d4d7ff;
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;
  --accent-text: #c7cbff;
  --link: #c4b5fd;
  --coral: #ff8a7a;
  --nav-bg: rgba(11, 11, 26, 0.72);
  --nav-solid: #0e0e22;
  --shadow: 0 1.25rem 3rem rgba(3, 3, 15, 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;
  --gauge-track: rgba(165, 160, 255, 0.2);
  --focus: #f9a8d4;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f3ff;
  --bg-2: #ebe8ff;
  --text: #17153a;
  --muted: #3b3970;
  --faint: #4d4b85;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --panel-border: rgba(99, 102, 241, 0.22);
  --field: rgba(255, 255, 255, 0.95);
  --field-solid: #ffffff;
  --field-border: rgba(79, 70, 229, 0.38);
  --bubble-user: #4f46e5;
  --bubble-user-text: #ffffff;
  --bubble-bot: rgba(238, 236, 255, 0.95);
  --bubble-bot-solid: #eeecff;
  --chip-bg: rgba(99, 102, 241, 0.12);
  --chip-text: #3730a3;
  --accent-text: #4338ca;
  --link: #5b21b6;
  --coral: #b4321f;
  --nav-bg: rgba(255, 255, 255, 0.72);
  --nav-solid: #ffffff;
  --shadow: 0 1.25rem 3rem rgba(49, 46, 129, 0.14);
  --glow-a: rgba(99, 102, 241, 0.3);
  --glow-b: rgba(168, 85, 247, 0.24);
  --glow-c: rgba(244, 114, 182, 0.2);
  --gauge-track: rgba(99, 102, 241, 0.16);
  --focus: #be185d;
  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: 140%; }

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

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

h1, h2, h3 {
  font-family: "Space Grotesk", "Manrope", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0; }
a { color: var(--link); }
button, textarea { font: inherit; color: inherit; }
svg { display: block; }

:focus-visible { outline: 0.18rem solid var(--focus); outline-offset: 0.18rem; border-radius: 0.4rem; }

.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: 50;
  background: var(--panel-solid); color: var(--text); padding: 0.6rem 1rem; border-radius: 0.6rem;
}
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 0.75rem); }

/* Background glow: never covered by a scrim */
.glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(45rem 30rem at 12% -6%, var(--glow-a), transparent 65%),
    radial-gradient(40rem 28rem at 88% 4%, var(--glow-b), transparent 62%),
    radial-gradient(38rem 26rem at 55% 105%, var(--glow-c), transparent 65%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20; width: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--nav-solid);
  border-bottom: 1px solid var(--panel-border);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .nav {
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
  }
}
.nav-row {
  width: min(100% - 1.5rem, 83.75rem);
  margin: 0 auto;
  padding: 0.6rem 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.5rem 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 0.7rem;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 55%, #be185d);
  color: #ffffff; font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; font-weight: 700; font-size: 0.9rem;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.brand-name strong { font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; font-size: 1rem; }
.brand-name span { font-size: 0.78rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 0.4rem 0.75rem; border-radius: 999px;
}
.nav-links a[aria-current="page"] { color: var(--text); background: var(--chip-bg); }
.nav-links a:hover { color: var(--text); }
.prefs { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.size-picker { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 999px; padding: 0.15rem; }
.size-btn {
  background: transparent; border: 0; border-radius: 999px; cursor: pointer; color: var(--muted);
  min-width: 2rem; height: 2rem; padding: 0 0.35rem; font-weight: 700; line-height: 1;
  font-family: "Space Grotesk", "Manrope", system-ui, sans-serif;
}
.size-btn[data-size="sm"] { font-size: 0.75rem; }
.size-btn[data-size="md"] { font-size: 0.9rem; }
.size-btn[data-size="lg"] { font-size: 1.05rem; }
.size-btn[data-size="xl"] { font-size: 1.2rem; }
.size-btn[aria-pressed="true"] { background: #4f46e5; color: #ffffff; }
.theme-btn {
  width: 2.35rem; height: 2.35rem; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; background: var(--chip-bg); color: var(--text);
  border: 1px solid var(--panel-border);
}
.theme-btn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-btn .icon-moon { fill: currentColor; stroke: none; }
html[data-theme="dark"] .theme-btn .icon-moon { display: none; }
html[data-theme="light"] .theme-btn .icon-sun { display: none; }

/* ---------- Hero ---------- */
main { display: block; }
.hero {
  width: min(100% - 2rem, 83.75rem);
  margin: 0 auto;
  padding: 1.5rem 0 1.1rem;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
}
.chip {
  display: inline-block; font-size: 0.8rem; font-weight: 600; color: var(--chip-text);
  background: var(--chip-bg); border: 1px solid var(--panel-border);
  padding: 0.25rem 0.75rem; border-radius: 999px;
}
.hero h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem); font-weight: 700; letter-spacing: -0.02em; max-width: 100%; }
.grad {
  color: var(--purple-soft);
  background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft) 50%, var(--pink));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .grad {
  color: #6d28d9;
  background: linear-gradient(90deg, #4338ca, #7e22ce 50%, #be185d);
  -webkit-background-clip: text; background-clip: text;
}
.subline { font-weight: 700; color: var(--muted); font-size: 1rem; max-width: 46rem; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 0.2rem; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 2.25rem;
  padding: 0.3rem 0.9rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.9rem;
  color: var(--text); background: var(--chip-bg); border: 1px solid var(--panel-border);
}
.chip-link:hover { border-color: var(--indigo-soft); }

/* ---------- Board ---------- */
.board {
  width: min(100% - 3rem, 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;
}
.board > * { min-width: 0; }

.card {
  position: relative;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 1.1rem;
  padding: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card {
    background: var(--panel);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    backdrop-filter: blur(18px) saturate(130%);
  }
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.2rem;
  background: linear-gradient(90deg, var(--indigo), var(--purple));
}
.match-card::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.list-card::before { background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft)); }
.detail-card::before { background: linear-gradient(90deg, var(--pink), var(--indigo-soft)); }

.card h2 { font-size: 1.1rem; font-weight: 600; }
.card-sub { color: var(--muted); font-size: 0.88rem; }

@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-slot { grid-column: 1 / -1; grid-row: 1; }
  .match-card { grid-column: 1; grid-row: 2; }
  .list-card { grid-column: 2; grid-row: 2; }
  .detail-card { grid-column: 3; grid-row: 2; }
}
@media (min-width: 1100px) {
  .board { grid-template-columns: minmax(0, 1.36fr) minmax(0, 1.06fr) minmax(0, 0.98fr) minmax(0, 0.98fr); }
  .chat-slot { grid-column: 1; grid-row: 1; }
  .match-card { grid-column: 2; grid-row: 1; }
  .list-card { grid-column: 3; grid-row: 1; }
  .detail-card { grid-column: 4; grid-row: 1; }
}

/* ---------- Chat card ---------- */
.chat-card {
  container-type: inline-size;
  container-name: chat;
  display: flex; flex-direction: column; gap: 0.6rem;
  height: clamp(26rem, 78svh, 40rem);
}
@media (min-width: 700px) { .chat-card { height: clamp(24rem, 62svh, 38rem); } }
@media (min-width: 1100px) { .chat-card { height: clamp(22rem, 100svh - 21rem, 38rem); } }

.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; }
.chat-head h2 { min-width: 0; text-align: left; font-size: 1.05rem; }
.chat-card { padding: 0.9rem; }
.chat-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.35rem 0.6rem; margin-top: -0.3rem; }
.chat-meta .card-sub { text-align: left; min-width: 0; }
.icon-btn .icon-collapse { display: none; }
.icon-btn[aria-pressed="true"] .icon-expand { display: none; }
.icon-btn[aria-pressed="true"] .icon-collapse { display: block; }
.icon-btn[aria-pressed="true"] { background: #4f46e5; color: #ffffff; border-color: #4f46e5; }
.chat-tools { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.icon-btn {
  width: 2rem; height: 2rem; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; background: var(--chip-bg); color: var(--text);
  border: 1px solid var(--panel-border);
}
.icon-btn svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.text-btn {
  min-height: 2.25rem; padding: 0 0.8rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--panel-border); white-space: nowrap;
}
.text-btn[aria-pressed="true"] { background: var(--indigo); color: #ffffff; border-color: var(--indigo); }

.count-chip {
  flex-shrink: 0; font-size: 0.78rem; font-weight: 600; color: var(--chip-text);
  background: var(--chip-bg); padding: 0.15rem 0.6rem; border-radius: 999px;
}

.log {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.25rem 0.15rem 0.25rem 0;
}
.log-empty { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0; text-align: center; padding: 0 0.5rem; }
.msg {
  max-width: 92%; padding: 0.65rem 0.85rem; border-radius: 1rem; font-size: 0.95rem; text-align: left;
  overflow-wrap: anywhere;
}
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 0.5rem; }
.msg ul { margin: 0.35rem 0 0; padding-left: 1.15rem; }
.msg li + li { margin-top: 0.2rem; }
.msg.user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-text); border-bottom-right-radius: 0.3rem; }
.msg.user a { color: #ffffff; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot-solid); color: var(--text); border: 1px solid var(--panel-border); border-bottom-left-radius: 0.3rem; }
.msg.error { align-self: flex-start; background: transparent; border: 1px solid var(--coral); color: var(--coral); }

/* Thinking indicator */
.thinking { display: flex; flex-direction: column; gap: 0.35rem; }
.dots { display: inline-flex; gap: 0.3rem; padding: 0.2rem 0; }
.dots span { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--indigo-soft); animation: pulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { background: var(--purple-soft); animation-delay: 0.2s; }
.dots span:nth-child(3) { background: var(--pink); animation-delay: 0.4s; }
.wait-note { font-size: 0.85rem; color: var(--muted); }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.35; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .dots span { animation: none; opacity: 1; transform: none; }
}

/* Composer */
.composer {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem;
}
.composer textarea {
  width: 100%; min-height: 2.75rem; max-height: 8rem; resize: none; overflow-y: hidden;
  padding: 0.65rem 0.85rem; border-radius: 1.4rem; line-height: 1.4;
  background: var(--field-solid); border: 1px solid var(--field-border); color: var(--text);
}
.composer textarea::placeholder { color: var(--faint); opacity: 1; }
.composer textarea.scrolls { overflow-y: auto; }
.composer-actions { display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; }
.mic-btn {
  width: 2.75rem; height: 2.75rem; border-radius: 50%; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center; background: var(--chip-bg); color: var(--text); border: 1px solid var(--field-border);
}
.mic-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic-btn[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: #1a0a14; }
.mic-btn[hidden] { display: none; }
.send-btn {
  min-height: 2.75rem; padding: 0 1.2rem; border-radius: 999px; cursor: pointer; font-weight: 700;
  background: var(--indigo); color: #ffffff; border: 1px solid var(--indigo); flex-shrink: 0;
  background-image: linear-gradient(135deg, #4f46e5, #7e22ce);
}
.send-btn[aria-busy="true"] { cursor: progress; opacity: 0.75; }
@container chat (min-width: 18.5rem) {
  .composer { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
}
.mic-status { font-size: 0.82rem; color: var(--muted); text-align: left; }
.error-line { font-size: 0.85rem; color: var(--coral); font-weight: 600; text-align: left; }
.chat-note { font-size: 0.78rem; color: var(--muted); text-align: left; }

/* Full page */
.chat-card.is-full {
  position: fixed; z-index: 40;
  inset: 0;
  height: auto;
  border-radius: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) calc(env(safe-area-inset-right, 0px) + 1rem) calc(env(safe-area-inset-bottom, 0px) + 1rem) calc(env(safe-area-inset-left, 0px) + 1rem);
  background: var(--panel-solid);
}
@media (min-width: 900px) {
  .chat-card.is-full { padding-left: max(1rem, calc((100vw - 60rem) / 2)); padding-right: max(1rem, calc((100vw - 60rem) / 2)); }
}
body.has-full { overflow: hidden; }

/* ---------- Side cards ---------- */
.side-head { display: flex; }
.pill {
  display: inline-block; align-self: flex-start;
  font-size: 0.82rem !important; font-weight: 700; color: var(--chip-text);
  background: var(--chip-bg); border: 1px solid var(--panel-border);
  padding: 0.2rem 0.7rem; border-radius: 999px;
}
.match-card, .list-card, .detail-card { display: flex; flex-direction: column; gap: 0.7rem; text-align: left; }
.match-tile {
  border-radius: 0.9rem; padding: 0.9rem;
  background: linear-gradient(135deg, #4338ca, #7e22ce 60%, #be185d);
  color: var(--tile-text);
}
.tile-kind { font-size: 0.78rem; font-weight: 600; color: #e9e7ff; }
.tile-title, .detail-name, .match-tile, .detail-list dd { overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.match-card { container-type: inline-size; }
.tile-title { font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; font-size: 1.15rem; font-size: clamp(0.85rem, 8cqi, 1.15rem); font-weight: 600; line-height: 1.25; color: #ffffff; }
.fit { display: flex; align-items: baseline; gap: 0.5rem; }
.fit-label { font-size: 0.85rem; color: var(--muted); }
.fit-value { font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--accent-text); }
.why { font-size: 0.9rem; color: var(--muted); }

.gauge-row { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); column-gap: 0.75rem; row-gap: 0.45rem; align-items: center; }
.gauge { width: 3.5rem; height: 3.5rem; transform: rotate(-90deg); }
.rank-note { grid-column: 1 / -1; }
.gauge circle { fill: none; stroke-width: 5; }
.gauge-track { stroke: var(--gauge-track); }
.gauge-fill { stroke: var(--purple-soft); stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.gauge-value { font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; font-size: 1.35rem; font-weight: 700; color: var(--text); }
.rank-note { font-size: 0.82rem; color: var(--muted); }
.match-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.match-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; text-align: left;
  padding: 0.55rem 0.7rem; border-radius: 0.7rem; cursor: pointer;
  background: var(--chip-bg); border: 1px solid var(--panel-border); color: var(--text); font-size: 0.88rem; font-weight: 600;
}
.match-btn { flex-wrap: wrap; }
.match-btn .match-title { flex: 1 1 7rem; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.match-btn .score { margin-left: auto; }
.match-btn .score { color: var(--accent-text); font-family: "Space Grotesk", "Manrope", system-ui, sans-serif; flex-shrink: 0; }
.match-btn[aria-pressed="true"] { border-color: var(--purple-soft); box-shadow: inset 0 0 0 1px var(--purple-soft); }
.list-empty { font-size: 0.88rem; color: var(--muted); }

.detail-name { font-weight: 700; font-size: 0.98rem; }
.detail-list { margin: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.detail-list div { display: flex; flex-direction: column; gap: 0.05rem; }
.detail-list dt { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; font-size: 0.9rem; }
.guide-link { font-weight: 700; font-size: 0.9rem; }
.next-step { border-top: 1px solid var(--panel-border); padding-top: 0.7rem; }
.next-step h3 { font-size: 0.95rem; margin-bottom: 0.25rem; color: var(--accent-text); }
.next-step p { font-size: 0.9rem; }

/* ---------- Footer ---------- */
.foot {
  width: min(100% - 2rem, 60rem); margin: 0 auto;
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 0.5rem 0 calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  text-align: center; color: var(--muted); font-size: 0.82rem;
}

@media (min-width: 700px) {
  .nav-row { justify-content: space-between; }
}
