/* Home Blend Planner — engine layout (dark by default) */

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%; }

:root {
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;
  --bg: #11122b;
  --text: #eef0ff;
  --muted: #c3c6ee;
  --faint: #a9addb;
  --panel: #191a3d;
  --panel-glass: rgba(25, 26, 61, 0.74);
  --panel-line: rgba(160, 166, 255, 0.2);
  --field: #0f1030;
  --field-line: rgba(160, 166, 255, 0.34);
  --bubble-user: #3c3fa8;
  --bubble-user-text: #ffffff;
  --bubble-bot: #22244d;
  --link: #b4b8ff;
  --coral: #ff9a80;
  --coral-bg: rgba(255, 120, 90, 0.12);
  --nav-glass: rgba(17, 18, 43, 0.72);
  --glow-a: rgba(99, 102, 241, 0.55);
  --glow-b: rgba(168, 85, 247, 0.45);
  --glow-c: rgba(244, 114, 182, 0.32);
  --shadow: 0 1.25rem 3rem -1.5rem rgba(5, 5, 25, 0.8);
  --grad: linear-gradient(100deg, #818cf8 0%, #c084fc 50%, #f472b6 100%);
  --strip: linear-gradient(90deg, #6366f1, #a855f7, #f472b6);
  --btn-text: #ffffff;
  --btn-bg: #5a4ee8;
  --board-w: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f4ff;
  --text: #1a1c3d;
  --muted: #434870;
  --faint: #4f5480;
  --panel: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.82);
  --panel-line: rgba(99, 102, 241, 0.2);
  --field: #ffffff;
  --field-line: rgba(79, 70, 229, 0.38);
  --bubble-user: #4f46e5;
  --bubble-user-text: #ffffff;
  --bubble-bot: #eef0ff;
  --link: #4338ca;
  --coral: #b93a1d;
  --coral-bg: rgba(220, 80, 50, 0.08);
  --nav-glass: rgba(255, 255, 255, 0.78);
  --glow-a: rgba(99, 102, 241, 0.32);
  --glow-b: rgba(168, 85, 247, 0.26);
  --glow-c: rgba(244, 114, 182, 0.24);
  --shadow: 0 1.25rem 3rem -1.75rem rgba(40, 40, 110, 0.35);
  --grad: linear-gradient(100deg, #4f46e5 0%, #7e22ce 55%, #be185d 100%);
  --btn-bg: #4f46e5;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

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, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42rem 30rem at 12% 8%, var(--glow-a), transparent 70%),
    radial-gradient(38rem 28rem at 88% 14%, var(--glow-b), transparent 70%),
    radial-gradient(40rem 30rem at 55% 105%, var(--glow-c), transparent 70%);
}

h1, h2, h3 { font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; margin: 0; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 0.15rem solid var(--purple-soft); outline-offset: 0.15rem; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  background: var(--panel);
  color: var(--text);
}
.skip:focus { top: calc(0.75rem + env(safe-area-inset-top, 0px)); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  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(--panel);
  border-bottom: 1px solid var(--panel-line);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav {
    background: var(--nav-glass);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    backdrop-filter: blur(16px) saturate(1.3);
  }
}
.nav-row {
  width: var(--board-w);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f472b6);
  color: #ffffff;
  flex: none;
}
.brand-mark svg { width: 1.35rem; height: 1.35rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.brand-name { font-family: "Space Grotesk", "Inter", system-ui, sans-serif; font-weight: 700; font-size: 0.98rem; }
.brand-sub { font-size: 0.78rem; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.15rem 0.35rem; }
.links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.55rem;
}
.links a:hover { color: var(--text); background: var(--panel-line); }
.links a[aria-current="page"] { color: var(--text); background: var(--panel-line); }
.prefs { display: flex; align-items: center; gap: 0.5rem; }
.sizes {
  display: inline-flex;
  align-items: flex-end;
  border: 1px solid var(--panel-line);
  border-radius: 0.65rem;
  padding: 0.15rem;
}
.size-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.3rem;
}
.size-btn.s1 { font-size: 0.75rem; }
.size-btn.s2 { font-size: 0.9rem; }
.size-btn.s3 { font-size: 1.05rem; }
.size-btn.s4 { font-size: 1.2rem; }
.size-btn[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-text); }
.theme-btn {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.65rem;
  border: 1px solid var(--panel-line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.theme-btn svg { width: 1.15rem; height: 1.15rem; }
.theme-btn .i-sun { display: none; }
html[data-theme="light"] .theme-btn .i-sun { display: block; }
html[data-theme="light"] .theme-btn .i-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  width: var(--board-w);
  margin: 0 auto;
  padding: 1.1rem 0 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.chip {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .chip { background: var(--panel-glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
}
.hero h1 {
  font-size: clamp(1.75rem, 1.1rem + 3vw, 2.75rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.grad {
  color: var(--purple-soft);
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub {
  font-weight: 650;
  font-size: 1rem;
  color: var(--muted);
  max-width: 44rem;
}
.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.35rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--field-line);
  background: var(--panel);
}
.chip-link:hover { border-color: var(--purple-soft); }

/* ---------- Board ---------- */
.board {
  width: var(--board-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.board > * { min-width: 0; }

.card {
  position: relative;
  border-radius: 1.1rem;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1.1rem 1rem 1rem;
  overflow: hidden;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card {
    background: var(--panel-glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.25);
    backdrop-filter: blur(18px) saturate(1.25);
  }
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0.2rem;
  background: var(--strip);
}
.card h2 { font-size: 1.1rem; font-weight: 700; }

/* chat */
.chat-slot { grid-column: 1; grid-row: 1; }
.chat-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  height: clamp(28rem, 78svh, 36rem);
  container-type: inline-size;
  container-name: chat;
}
.chat-head { min-width: 0; text-align: left; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.1rem; }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.chat-actions { display: flex; gap: 0.4rem; flex: none; }
.icon-btn, .ghost-btn {
  min-height: 2.25rem;
  border-radius: 0.65rem;
  border: 1px solid var(--field-line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn { width: 2.25rem; display: grid; place-items: center; }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.ghost-btn { padding: 0 0.8rem; font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.icon-btn:hover, .ghost-btn:hover { border-color: var(--purple-soft); }
.count-chip {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
}
.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;
}
.msg {
  max-width: 92%;
  padding: 0.6rem 0.8rem;
  border-radius: 0.9rem;
  font-size: 0.93rem;
  line-height: 1.5;
  text-align: left;
}
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); color: var(--text); border-top-left-radius: 0.3rem; }
.msg.user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-text); border-top-right-radius: 0.3rem; }
.msg.error { background: var(--coral-bg); color: var(--coral); border: 1px solid var(--coral); }
.msg.typing .msg-text { color: var(--muted); }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}
.composer textarea {
  width: 100%;
  min-height: 2.6rem;
  max-height: 8rem;
  resize: none;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-radius: 0.8rem;
  padding: 0.55rem 0.8rem;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--faint); opacity: 1; }
.composer-buttons { display: flex; justify-content: center; gap: 0.5rem; }
.mic-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--field-line);
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.mic-btn svg { width: 1.15rem; height: 1.15rem; }
.mic-btn[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: #2a0b1c; }
.mic-btn[hidden] { display: none; }
.send-btn {
  min-height: 2.6rem;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 0.8rem;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 700;
  cursor: pointer;
}
.send-btn:disabled { opacity: 0.6; cursor: progress; }
@container chat (min-width: 18.5rem) {
  .composer { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .composer-buttons { justify-content: flex-end; }
}
.status { min-height: 0; font-size: 0.82rem; color: var(--coral); text-align: left; }
.status:empty { display: none; }
.note { font-size: 0.74rem; color: var(--faint); text-align: left; }

/* full page */
.chat-card.is-full {
  position: fixed;
  z-index: 60;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  left: calc(0.75rem + env(safe-area-inset-left, 0px));
  right: calc(0.75rem + env(safe-area-inset-right, 0px));
  width: auto;
  height: auto;
  max-width: 60rem;
  margin: 0 auto;
  background: var(--panel);
}
.full-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(8, 8, 28, 0.6);
}
.full-backdrop[hidden] { display: none; }
body.is-full-open { overflow: hidden; }

/* side cards */
.side { display: flex; flex-direction: column; gap: 0.7rem; text-align: center; }
.pill {
  align-self: center;
  font-size: 0.78rem !important;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
}
.tile {
  border-radius: 0.9rem;
  padding: 0.9rem;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 60%, #be185d);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: left;
}
.tile-kind { font-size: 0.75rem; font-weight: 600; color: #ece9ff; }
.tile-title { font-family: "Space Grotesk", "Inter", system-ui, sans-serif; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.fit-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.fit-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.fit-value { font-family: "Space Grotesk", "Inter", system-ui, sans-serif; font-size: 1.5rem; font-weight: 700; }
.why { font-size: 0.88rem; color: var(--muted); text-align: left; }

.gauge-row { display: flex; align-items: center; gap: 0.75rem; text-align: left; }
.gauge { width: 4rem; height: 4rem; flex: none; }
.gauge-track { stroke: var(--panel-line); }
.gauge-fill { stroke: var(--purple-soft); transition: stroke-dasharray 0.4s ease; }
html[data-theme="light"] .gauge-fill { stroke: #7e22ce; }
.gauge-text { fill: var(--text); font-family: "Space Grotesk", "Inter", system-ui, sans-serif; font-weight: 700; font-size: 0.6rem; }
.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; text-align: left; }
.match-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 0.7rem;
  border: 1px solid var(--panel-line);
  background: transparent;
  cursor: pointer;
  font-size: 0.86rem;
}
.match-list button[aria-pressed="true"] { border-color: var(--purple-soft); background: var(--panel-line); }
.match-list .m-title { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.match-list .m-score { flex: none; font-weight: 700; color: var(--muted); }

.detail-name { font-weight: 700; font-family: "Space Grotesk", "Inter", system-ui, sans-serif; overflow-wrap: anywhere; }
.detail-list { margin: 0; display: grid; gap: 0.45rem; text-align: left; }
.detail-list div { display: grid; gap: 0.05rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--panel-line); min-width: 0; }
.detail-list dt { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.detail-list dd { margin: 0; font-size: 0.88rem; overflow-wrap: anywhere; }
.text-link { font-weight: 600; font-size: 0.88rem; }
.next {
  border-radius: 0.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px dashed var(--field-line);
  text-align: left;
}
.next h3 { font-size: 0.9rem; margin-bottom: 0.2rem; }
.next p { font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }

.notes {
  width: var(--board-w);
  margin: 1.5rem auto 0;
  padding: 0 0 calc(2rem + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 0.6rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Tablet ---------- */
@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-slot { 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; }
  .chat-card { height: clamp(24rem, 62svh, 34rem); }
  .nav-row { justify-content: space-between; }
  .notes { text-align: left; }
}

/* ---------- Desktop ---------- */
@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; }
  .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 { height: clamp(22rem, 100svh - 21rem, 38rem); }
}

/* Larger text on mid-size desktops: give the chat its own full-width row so the log keeps room */
@media (min-width: 1100px) and (max-width: 1599px) {
  html[data-font-size="lg"] .board,
  html[data-font-size="xl"] .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html[data-font-size="lg"] .chat-slot,
  html[data-font-size="xl"] .chat-slot { grid-column: 1 / -1; grid-row: 1; }
  html[data-font-size="lg"] .top-card,
  html[data-font-size="xl"] .top-card { grid-column: 1; grid-row: 2; }
  html[data-font-size="lg"] .short-card,
  html[data-font-size="xl"] .short-card { grid-column: 2; grid-row: 2; }
  html[data-font-size="lg"] .detail-card,
  html[data-font-size="xl"] .detail-card { grid-column: 3; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
