/* Kindred Cards: planner (engine) styles */
:root {
  --font-head: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --indigo: #6366f1; --purple: #a855f7; --indigo-l: #818cf8; --purple-l: #c084fc; --pink: #f472b6;
  --coral: #ff8a8f;

  --bg: #0b0b1a;
  --ink: #eef0ff;
  --ink-soft: #d4d7f2;
  --muted: #b2b6d8;
  --accent-ink: #a5b4fc;
  --panel: rgba(23, 22, 48, 0.72);
  --panel-solid: #171630;
  --panel-2: rgba(255, 255, 255, 0.06);
  --panel-2-solid: #22213f;
  --line: rgba(199, 204, 255, 0.16);
  --field: rgba(10, 10, 26, 0.6);
  --field-solid: #0f0f22;
  --chip-bg: rgba(129, 140, 248, 0.16);
  --chip-ink: #dfe3ff;
  --bubble-user-a: #4f46e5; --bubble-user-b: #7c3aed;
  --error-bg: rgba(255, 138, 143, 0.12); --error-ink: #ffb3b6; --error-line: rgba(255, 138, 143, 0.45);
  --shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
  --glow-a: rgba(99, 102, 241, 0.55); --glow-b: rgba(168, 85, 247, 0.45); --glow-c: rgba(244, 114, 182, 0.35);
  --focus: #f9a8d4;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f4ff; --ink: #17153a; --ink-soft: #2e2b55; --muted: #4f4b78; --accent-ink: #4338ca;
    --panel: rgba(255, 255, 255, 0.78); --panel-solid: #ffffff; --panel-2: rgba(99, 102, 241, 0.07); --panel-2-solid: #eeedfd;
    --line: rgba(67, 56, 202, 0.16); --field: rgba(255, 255, 255, 0.9); --field-solid: #ffffff;
    --chip-bg: rgba(99, 102, 241, 0.12); --chip-ink: #312e81;
    --error-bg: #fff1f2; --error-ink: #b42335; --error-line: rgba(225, 29, 72, 0.35);
    --shadow: 0 1rem 2.5rem rgba(67, 56, 202, 0.12);
    --glow-a: rgba(129, 140, 248, 0.45); --glow-b: rgba(192, 132, 252, 0.35); --glow-c: rgba(244, 114, 182, 0.3);
    --focus: #db2777;
  }
}
:root[data-theme="light"] {
  --bg: #f5f4ff; --ink: #17153a; --ink-soft: #2e2b55; --muted: #4f4b78; --accent-ink: #4338ca;
  --panel: rgba(255, 255, 255, 0.78); --panel-solid: #ffffff; --panel-2: rgba(99, 102, 241, 0.07); --panel-2-solid: #eeedfd;
  --line: rgba(67, 56, 202, 0.16); --field: rgba(255, 255, 255, 0.9); --field-solid: #ffffff;
  --chip-bg: rgba(99, 102, 241, 0.12); --chip-ink: #312e81;
  --error-bg: #fff1f2; --error-ink: #b42335; --error-line: rgba(225, 29, 72, 0.35);
  --shadow: 0 1rem 2.5rem rgba(67, 56, 202, 0.12);
  --glow-a: rgba(129, 140, 248, 0.45); --glow-b: rgba(192, 132, 252, 0.35); --glow-c: rgba(244, 114, 182, 0.3);
  --focus: #db2777;
}

html[data-font-size="sm"] { font-size: 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; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--bg); color: var(--ink); font-family: var(--font-body); line-height: 1.5;
  min-height: 100vh; min-height: 100svh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  position: relative;
}
a { color: var(--accent-ink); }
button, textarea { 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; }
[hidden] { display: none !important; }

.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40rem 28rem at 12% 8%, var(--glow-a), transparent 65%),
    radial-gradient(36rem 26rem at 88% 18%, var(--glow-b), transparent 65%),
    radial-gradient(44rem 30rem at 55% 100%, var(--glow-c), transparent 70%);
}

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 40; width: 100%;
  background: var(--panel-solid);
  background: var(--panel);
  -webkit-backdrop-filter: blur(1rem) saturate(1.3); backdrop-filter: blur(1rem) saturate(1.3);
  border-bottom: 1px solid var(--line);
  padding: max(0.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
}
.nav-row {
  width: min(100% - 0rem, clamp(56.25rem, 66vw, 83.75rem)); margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1rem;
}
.brand { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: 0.75rem; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--indigo), var(--purple) 55%, var(--pink));
  box-shadow: 0 0.35rem 1rem rgba(99, 102, 241, 0.4);
}
.brand-mark svg { width: 1.1rem; height: 1.1rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.brand-text strong { font-family: var(--font-head); font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.75rem; color: var(--muted); }
.links { display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: center; }
.links a {
  color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: 0.9375rem; padding: 0.5rem 0.85rem; border-radius: 99rem; min-height: 2.5rem; display: inline-flex; align-items: center;
}
.links a[aria-current="page"] { background: var(--chip-bg); color: var(--chip-ink); }
.prefs { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.sizes { display: inline-flex; align-items: flex-end; gap: 0.125rem; padding: 0.1875rem; border-radius: 99rem; border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2); }
.size-btn { min-width: 2.25rem; height: 2.25rem; border: 0; border-radius: 99rem; background: transparent; color: var(--ink); font-family: var(--font-head); font-weight: 700; line-height: 1; cursor: pointer; display: inline-grid; place-items: center; }
.size-btn[data-size="sm"] { font-size: 0.8125rem; }
.size-btn[data-size="md"] { font-size: 0.9375rem; }
.size-btn[data-size="lg"] { font-size: 1.0625rem; }
.size-btn[data-size="xl"] { font-size: 1.25rem; }
.size-btn[aria-pressed="true"] { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #ffffff; }
.icon-btn { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2); color: var(--ink); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
@media (min-width: 48rem) { .nav-row { justify-content: space-between; } }

/* ── Hero ── */
.hero {
  position: relative; z-index: 1; text-align: center;
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem)); margin: 0 auto; padding: 1.1rem 0 0.9rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.75rem; border-radius: 99rem;
  background: var(--chip-bg); color: var(--chip-ink); border: 1px solid var(--line); font-size: 0.8125rem; font-weight: 500;
}
.hero h1 {
  font-family: var(--font-head); font-weight: 700; letter-spacing: -0.025em; line-height: 1.08; margin: 0;
  font-size: clamp(1.75rem, 1.05rem + 2.3vw, 2.75rem); overflow-wrap: anywhere;
}
.grad {
  color: var(--purple-l);
  background: linear-gradient(90deg, var(--indigo-l), var(--purple-l) 50%, var(--pink));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .grad { color: #7e22ce; background-image: linear-gradient(90deg, #4f46e5, #7e22ce 50%, #be185d); }
.subline { margin: 0; font-weight: 500; color: var(--ink-soft); font-size: 1rem; line-height: 1.45; max-width: 46rem; }
.hero-links { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-top: 0.15rem; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.4rem 1rem; border-radius: 99rem;
  border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.9rem;
}
@media (min-width: 62rem) {
  .hero h1 { white-space: nowrap; }
}

/* ── Board ── */
.board {
  position: relative; z-index: 1;
  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;
}
.card {
  position: relative; min-width: 0;
  background: var(--panel-solid);
  background: var(--panel);
  -webkit-backdrop-filter: blur(1.1rem) saturate(1.3); backdrop-filter: blur(1.1rem) saturate(1.3);
  border: 1px solid var(--line); border-radius: 1.1rem; padding: 1rem; box-shadow: var(--shadow); overflow: hidden;
}
.card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 0.2rem;
  background: linear-gradient(90deg, var(--indigo), var(--purple), var(--pink));
}
.top-card::before { background: linear-gradient(90deg, var(--pink), var(--purple)); }
.short-card::before { background: linear-gradient(90deg, var(--indigo-l), var(--indigo)); }
.detail-card::before { background: linear-gradient(90deg, var(--purple-l), var(--pink)); }
.card h2 { font-family: var(--font-head); font-weight: 700; font-size: 1.125rem; margin: 0; letter-spacing: -0.01em; }
.card h3 { font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; margin: 0 0 0.25rem; }

@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-card, .chat-ph { grid-column: 1 / -1; grid-row: 1; }
  .top-card { grid-column: 1; grid-row: 2; }
  .short-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-card, .chat-ph { grid-column: 1; grid-row: 1; }
  .top-card { grid-column: 2; grid-row: 1; }
  .short-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.5rem;
  height: clamp(26rem, 72svh, 36rem);
}
@media (min-width: 700px) { .chat-card { height: clamp(24rem, 60svh, 34rem); } }
@media (min-width: 1100px) { .chat-card { height: clamp(22rem, calc(100svh - 21rem), 38rem); } }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.chat-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.chat-titles { min-width: 0; flex: 1 1 auto; }
.chat-sub { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.875rem; }
.chat-tools { display: flex; align-items: center; gap: 0.375rem; flex: none; }
.count-chip { font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 99rem; background: var(--chip-bg); color: var(--chip-ink); white-space: nowrap; }
.round-btn {
  width: 2.375rem; height: 2.375rem; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer;
}
.round-btn svg { width: 1.1rem; height: 1.1rem; }
.round-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pill-btn {
  min-height: 2.25rem; padding: 0.25rem 0.8rem; border-radius: 99rem; border: 1px solid var(--line);
  background: var(--panel-2-solid); background: var(--panel-2); color: var(--ink); font-size: 0.85rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.log {
  flex: 1 1 auto; min-height: 5rem; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 0.6rem; padding: 0.25rem 0.1rem 0.25rem 0;
}
.empty { margin: auto 0; text-align: center; color: var(--muted); padding: 0.5rem; font-size: 0.9rem; }
.empty p { margin: 0.25rem 0; }
.empty-title { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.msg { max-width: 92%; padding: 0.65rem 0.85rem; border-radius: 1rem; line-height: 1.5; font-size: 0.95rem; overflow-wrap: anywhere; }
.msg p { margin: 0 0 0.5rem; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 0.25rem 0 0.5rem; padding-left: 1.2rem; }
.msg.user { align-self: flex-end; color: #ffffff; background: #5b3fe6; background: linear-gradient(135deg, var(--bubble-user-a), var(--bubble-user-b)); border-bottom-right-radius: 0.3rem; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--panel-2-solid); background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 0.3rem; }
.msg.bot strong { font-family: var(--font-head); color: var(--accent-ink); }
.msg.bot a { color: var(--accent-ink); }
.msg.error { align-self: flex-start; background: var(--error-bg); color: var(--error-ink); border: 1px solid var(--error-line); }

/* Thinking indicator */
.thinking { display: flex; flex-direction: column; gap: 0.35rem; }
.dots { display: inline-flex; gap: 0.35rem; align-items: center; height: 1.2rem; }
.dots i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--purple-l); display: block; animation: pulse 1.2s ease-in-out infinite; }
:root[data-theme="light"] .dots i { background: #7c3aed; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.1); } }
.wait-note { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Composer */
.composer { display: flex; flex-direction: column; gap: 0.5rem; }
.composer textarea {
  width: 100%; min-width: 0; resize: none; border-radius: 0.9rem; border: 1px solid var(--line);
  background: var(--field-solid); background: var(--field); color: var(--ink);
  padding: 0.7rem 0.85rem; line-height: 1.4; font-size: 1rem; min-height: 2.9rem; max-height: 8rem; overflow-y: hidden;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer-actions { display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; }
@container chat (min-width: 18.5rem) {
  .composer { flex-direction: row; align-items: flex-end; }
  .composer textarea { flex: 1 1 auto; }
  .composer-actions { flex: none; }
}
.mic-btn {
  width: 2.9rem; height: 2.9rem; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.mic-btn svg { width: 1.2rem; height: 1.2rem; }
.mic-btn[aria-pressed="true"] { background: linear-gradient(135deg, #be185d, #7e22ce); color: #ffffff; border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(244, 114, 182, 0.28); }
.send-btn {
  min-height: 2.9rem; padding: 0 1.2rem; border-radius: 99rem; border: 0; cursor: pointer; font-weight: 500;
  color: #ffffff; background: #5b3fe6; background: linear-gradient(135deg, #4f46e5, #7c3aed); flex: none;
}
.send-btn:disabled { opacity: 0.6; cursor: progress; }
.mic-status { margin: 0; font-size: 0.8rem; color: var(--muted); }
.mic-error { margin: 0; font-size: 0.85rem; color: var(--error-ink); background: var(--error-bg); border: 1px solid var(--error-line); border-radius: 0.6rem; padding: 0.4rem 0.6rem; }
.chat-note { margin: 0; font-size: 0.75rem; color: var(--muted); }

/* Full page */
.chat-card.full {
  position: fixed; z-index: 100; inset: 0; height: auto; max-height: none; border-radius: 0;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--panel-solid);
}
.chat-ph { visibility: hidden; }
body.chat-open { overflow: hidden; }
/* .board (z-index 1) is the chat's stacking context; lift it above the sticky nav (40) and footer while full page. */
body.chat-open .board { z-index: 200; }

/* ── Side cards ── */
.side { display: flex; flex-direction: column; gap: 0.75rem; }
.pill { align-self: flex-start; font-size: 0.75rem; font-weight: 500; padding: 0.2rem 0.65rem; border-radius: 99rem; background: var(--chip-bg); color: var(--chip-ink); }
.match-tile {
  border-radius: 0.9rem; padding: 1rem; min-height: 6.5rem; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.25rem;
  background: #5b21b6; background: linear-gradient(135deg, #4338ca, #7e22ce 55%, #be185d); color: #ffffff;
}
.tile-kind { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.95; }
.tile-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; line-height: 1.2; overflow-wrap: anywhere; }
.fit { display: flex; align-items: baseline; gap: 0.4rem; }
.fit-score { font-family: var(--font-head); font-weight: 700; font-size: 1.75rem; color: var(--accent-ink); }
.fit-label { color: var(--muted); font-size: 0.85rem; }
.fit-why { margin: 0; color: var(--ink-soft); font-size: 0.9rem; overflow-wrap: anywhere; }

.gauge-row { display: flex; align-items: center; gap: 0.75rem; }
.gauge { position: relative; width: 4.25rem; height: 4.25rem; flex: none; }
.gauge svg { width: 100%; height: 100%; display: block; }
.gauge-track { stroke: var(--line); }
.gauge-fill { stroke: var(--purple-l); transition: stroke-dasharray 0.6s ease; }
:root[data-theme="light"] .gauge-fill { stroke: #7c3aed; }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 1rem; }
.rank-note { margin: 0; font-size: 0.85rem; color: var(--muted); min-width: 0; }
.short-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.short-list button {
  width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.7rem; border-radius: 0.7rem; border: 1px solid var(--line); background: var(--panel-2-solid); background: var(--panel-2); color: var(--ink); cursor: pointer; min-height: 2.75rem;
}
.short-list button[aria-pressed="true"] { border-color: var(--purple-l); box-shadow: inset 0 0 0 1px var(--purple-l); }
.short-list .s-title { min-width: 0; overflow-wrap: anywhere; font-weight: 500; font-size: 0.9rem; }
.short-list .s-score { flex: none; font-family: var(--font-head); font-weight: 700; color: var(--accent-ink); font-size: 0.9rem; }

.fields { margin: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.fields div { min-width: 0; }
.fields dt { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.fields dd { margin: 0.1rem 0 0; font-size: 0.92rem; color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; }
.field-empty { color: var(--muted); font-size: 0.9rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.text-link { font-weight: 500; font-size: 0.9rem; min-height: 2.5rem; display: inline-flex; align-items: center; }
.preview-btn {
  min-height: 2.5rem; padding: 0.4rem 0.9rem; border-radius: 99rem; border: 0; cursor: pointer; font-weight: 500; font-size: 0.88rem;
  color: #ffffff; background: #5b3fe6; background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.next-step { border-top: 1px solid var(--line); padding-top: 0.75rem; }
.next-step p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); overflow-wrap: anywhere; }

.foot { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 1rem max(1.25rem, env(safe-area-inset-bottom)); }
.foot p { margin: 0 auto 0.25rem; max-width: 46rem; }

@media (prefers-reduced-motion: reduce) {
  .dots i { animation: none; opacity: 0.85; }
  .gauge-fill { transition: none; }
}
