/* Ma Files Engine: standing engine template. Dark by default, condensed board, all sizes in rem. */

:root {
  --font-head: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;

  /* light theme */
  --bg: #f4f2ff;
  --glow-a: rgba(99, 102, 241, 0.34);
  --glow-b: rgba(168, 85, 247, 0.30);
  --glow-c: rgba(244, 114, 182, 0.26);
  --ink: #1b1846;
  --ink-soft: #46437a;
  --panel-solid: #ffffff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-line: rgba(99, 102, 241, 0.22);
  --field: #ffffff;
  --field-line: #b9b6ea;
  --bubble-user: #e6e4ff;
  --bubble-bot: #ffffff;
  --link: #4338ca;
  --btn-a: #4f46e5;
  --btn-b: #9333ea;
  --on-btn: #ffffff;
  --grad-a: #4f46e5;
  --grad-b: #9333ea;
  --grad-c: #c0267a;
  --coral: #b4372a;
  --coral-bg: #fde9e5;
  --track: #e2e0fb;
  --focus: #4f46e5;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0a1f;
  --glow-a: rgba(99, 102, 241, 0.55);
  --glow-b: rgba(168, 85, 247, 0.48);
  --glow-c: rgba(244, 114, 182, 0.36);
  --ink: #eef0ff;
  --ink-soft: #c3c5ee;
  --panel-solid: #17153a;
  --panel: rgba(23, 21, 58, 0.62);
  --panel-line: rgba(129, 140, 248, 0.28);
  --field: #100e2b;
  --field-line: #4b4890;
  --bubble-user: #2e2a78;
  --bubble-bot: #1d1a48;
  --link: #a5b4fc;
  --btn-a: #4f46e5;
  --btn-b: #9333ea;
  --on-btn: #ffffff;
  --grad-a: #818cf8;
  --grad-b: #c084fc;
  --grad-c: #f472b6;
  --coral: #ff9e8c;
  --coral-bg: rgba(255, 120, 100, 0.14);
  --track: #2b2860;
  --focus: #a5b4fc;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
  position: relative;
}
/* Vibrant glow on a fixed layer (works on iOS, no scrim over it). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42rem 32rem at 12% -6%, var(--glow-a), transparent 70%),
    radial-gradient(38rem 30rem at 92% 8%, var(--glow-b), transparent 70%),
    radial-gradient(46rem 30rem at 50% 108%, var(--glow-c), transparent 70%);
}

h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.15; color: var(--ink); }
a { color: var(--link); text-underline-offset: 0.2em; }
p { margin: 0 0 0.75rem; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.1875rem; border-radius: 0.375rem; }
.sr-only { position: absolute; width: 0.0625rem; height: 0.0625rem; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.skip { position: absolute; left: 1rem; top: -10rem; z-index: 50; padding: 0.75rem 1rem; background: var(--btn-a); color: var(--on-btn); border-radius: 0.5rem; }
.skip:focus { top: calc(0.5rem + env(safe-area-inset-top, 0px)); }

/* Sticky full-width nav bar; content centered */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 0.0625rem solid var(--panel-line);
  background: var(--panel-solid);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .nav {
    background: var(--panel);
    -webkit-backdrop-filter: blur(1.25rem) saturate(1.3);
    backdrop-filter: blur(1.25rem) saturate(1.3);
  }
}
.nav-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  padding: 0.625rem calc(1rem + env(safe-area-inset-right, 0px)) 0.625rem calc(1rem + env(safe-area-inset-left, 0px));
}
.brand { display: inline-flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--ink); }
.brand-mark { width: 1.375rem; height: 1.375rem; border-radius: 0.4rem; background: linear-gradient(135deg, var(--indigo), var(--purple) 60%, var(--pink)); flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.125rem; }
.brand-sub { font-size: 0.8125rem; font-weight: 600; color: var(--link); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.125rem; }
.nav-links a { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 0.9375rem; padding: 0.25rem 0; }
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); }
.prefs { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; justify-content: center; }
.size-group { display: inline-flex; border: 0.0625rem solid var(--field-line); border-radius: 62rem; overflow: hidden; }
.pref-btn {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--field);
  border: 0;
  min-width: 2.125rem;
  min-height: 2.125rem;
  padding: 0 0.5rem;
  cursor: pointer;
  line-height: 1;
}
.size-group .pref-btn + .pref-btn { border-left: 0.0625rem solid var(--field-line); }
.size-group .pref-btn[data-font-size-set="sm"] { font-size: 0.75rem; }
.size-group .pref-btn[data-font-size-set="md"] { font-size: 0.875rem; }
.size-group .pref-btn[data-font-size-set="lg"] { font-size: 1rem; }
.size-group .pref-btn[data-font-size-set="xl"] { font-size: 1.125rem; }
.size-group .pref-btn[aria-pressed="true"] { background: var(--btn-a); color: var(--on-btn); }
.theme-btn { display: inline-flex; align-items: center; gap: 0.375rem; border: 0.0625rem solid var(--field-line); border-radius: 62rem; font-size: 0.8125rem; }
.theme-icon { width: 0.8125rem; height: 0.8125rem; border-radius: 50%; background: var(--ink); box-shadow: inset -0.25rem -0.125rem 0 0 var(--purple); }

/* Hero: compact so the board sits above the fold */
.hero {
  text-align: center;
  padding: clamp(1rem, 2.5vw, 1.5rem) calc(1.5rem + env(safe-area-inset-right, 0px)) clamp(1rem, 2.5vw, 1.5rem) calc(1.5rem + env(safe-area-inset-left, 0px));
  max-width: 72rem;
  margin: 0 auto;
}
.chip {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.3125rem 0.875rem;
  border-radius: 62rem;
  border: 0.0625rem solid var(--panel-line);
  background: var(--panel-solid);
  color: var(--ink);
  margin: 0 0 0.75rem;
}
.hero h1 { font-size: clamp(1.75rem, 1.1rem + 2.4vw, 2.75rem); font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.grad { color: var(--grad-b); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .grad {
    background: linear-gradient(90deg, var(--grad-a), var(--grad-b) 55%, var(--grad-c));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}
.sub { color: var(--ink); font-size: 1.0625rem; font-weight: 600; margin: 0.625rem auto 0.875rem; max-width: 40rem; text-wrap: balance; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.chip-link { text-decoration: none; margin: 0; font-size: 0.9375rem; }
.chip-link:hover { border-color: var(--purple); }

/* Board: cards size to their own content (staggered heights) */
.board {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.card {
  position: relative;
  min-width: 0;
  border-radius: 1.125rem;
  border: 0.0625rem solid var(--panel-line);
  background: var(--panel-solid);
  padding: 1.125rem 1.125rem 1.125rem;
  overflow: hidden;
  box-shadow: 0 1.25rem 3rem rgba(15, 10, 60, 0.18);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card {
    background: var(--panel);
    -webkit-backdrop-filter: blur(1.125rem) saturate(1.25);
    backdrop-filter: blur(1.125rem) saturate(1.25);
  }
}
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.1875rem; }
.card-chat::before { background: linear-gradient(90deg, var(--indigo), var(--purple)); }
.card-top::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.card-short::before { background: linear-gradient(90deg, var(--pink), var(--indigo-soft)); }
.card-details::before { background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft)); }
.card h2 { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.75rem; }
.empty { color: var(--ink-soft); font-size: 0.9375rem; margin: 0; }
.center { text-align: center; }

/* Chat card */
.card-chat { display: flex; flex-direction: column; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.625rem; }
.card-title { min-width: 0; }
.card-title h2 { margin: 0; }
.card-sub { margin: 0.125rem 0 0; font-size: 0.875rem; color: var(--ink-soft); }
.head-actions { display: flex; align-items: center; gap: 0.375rem; flex: 0 0 auto; }
.icon-btn {
  width: 2.375rem;
  height: 2.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0.0625rem solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { border-color: var(--field-line); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
.ghost-btn {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--field);
  border: 0.0625rem solid var(--field-line);
  border-radius: 0.75rem;
  min-height: 2.375rem;
  padding: 0 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  white-space: nowrap;
}
.ghost-btn svg { width: 1.125rem; height: 1.125rem; fill: currentColor; }
.ghost-btn:hover { border-color: var(--purple); }
.msg-count {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0 0 0.625rem;
  padding: 0.25rem 0.75rem;
  border-radius: 62rem;
  background: var(--track);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink);
}
.msg-count .dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--ink-soft); }
.msg-count.active .dot { background: var(--pink); }

.log { flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.625rem; min-height: 12rem; max-height: 26rem; overflow-y: auto; padding: 0.25rem 0.125rem 0.5rem; overscroll-behavior: contain; }
.msg { max-width: 92%; padding: 0.625rem 0.875rem; border-radius: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.msg-bot { align-self: flex-start; background: var(--bubble-bot); border: 0.0625rem solid var(--panel-line); border-bottom-left-radius: 0.25rem; }
.msg-user { align-self: flex-end; background: var(--bubble-user); border-bottom-right-radius: 0.25rem; }
.msg-wait { color: var(--ink-soft); font-style: italic; }
.composer { margin-top: 0.75rem; container-type: inline-size; container-name: composer; }
.composer-row { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 0.5rem; min-width: 0; }
.composer textarea {
  display: block;
  flex: 1 1 100%;
  min-width: 0;
  width: 100%;
  min-height: 2.875rem;
  max-height: 9rem;
  resize: none;
  line-height: 1.4;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 0.0625rem solid var(--field-line);
  border-radius: 0.875rem;
  padding: 0.6875rem 0.875rem;
}
.composer textarea::placeholder { color: var(--ink-soft); opacity: 1; }
/* Inline row only when the chat card itself is wide enough; otherwise the box gets its own row. */
@container composer (min-width: 18.5rem) {
  .composer-row { flex-wrap: nowrap; }
  .composer-row textarea { flex: 1 1 auto; }
}
.mic-btn {
  width: 2.875rem;
  height: 2.875rem;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 0.0625rem solid var(--field-line);
  background: var(--field);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.mic-btn svg { width: 1.375rem; height: 1.375rem; fill: currentColor; }
.mic-btn[aria-pressed="true"] { border-color: var(--pink); box-shadow: 0 0 0 0.25rem rgba(244, 114, 182, 0.35); color: var(--pink); }
:root:not([data-theme="dark"]) .mic-btn[aria-pressed="true"] { color: var(--grad-c); }
.send-btn {
  font: inherit;
  font-weight: 700;
  min-height: 2.875rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 0.875rem;
  color: var(--on-btn);
  background: var(--btn-a);
  background: linear-gradient(90deg, var(--btn-a), var(--btn-b));
  cursor: pointer;
  flex: 0 0 auto;
}
.send-btn:disabled { opacity: 0.6; cursor: progress; }
.chat-note { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--ink-soft); }
.status { margin: 0.5rem 0 0; font-size: 0.875rem; }
.status:empty { display: none; }
.status.error { color: var(--coral); background: var(--coral-bg); padding: 0.5rem 0.75rem; border-radius: 0.625rem; }

/* Full page chat */
.card-chat.is-full {
  position: fixed;
  z-index: 40;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  right: calc(0.75rem + env(safe-area-inset-right, 0px));
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  left: calc(0.75rem + env(safe-area-inset-left, 0px));
  width: auto;
  height: auto;
  max-width: 64rem;
  margin: 0 auto;
  background: var(--panel-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: 0 0 0 100vmax rgba(8, 6, 30, 0.72), 0 1.5rem 4rem rgba(0, 0, 0, 0.4);
}
.card-chat.is-full .log { max-height: none; min-height: 0; }
/* Holds the chat's place in the grid while it is full page, so nothing behind it moves. */
.board.chat-full::before { content: ""; display: block; height: var(--chat-h, 0px); }

/* Top match */
.card .pill-label {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 62rem;
  background: var(--track);
  color: var(--link);
  margin: 0 0 0.75rem;
}
.match-tile {
  position: relative;
  overflow: hidden;
  border-radius: 0.875rem;
  padding: 0.875rem 1rem 1.125rem;
  background: #5b3fe0;
  background: linear-gradient(120deg, #4f46e5, #7e22ce 60%, #be185d);
  color: #ffffff;
}
.match-tile::after { content: ""; position: absolute; right: -2.5rem; bottom: -2.5rem; width: 7.5rem; height: 7.5rem; border-radius: 50%; border: 1rem solid rgba(255, 255, 255, 0.12); }
.tile-kind { margin: 0 0 1.25rem; font-size: 0.8125rem; font-weight: 700; color: #ffffff; position: relative; }
.tile-title { margin: 0; font-family: var(--font-head); font-size: 1.375rem; font-weight: 700; line-height: 1.15; color: #ffffff; position: relative; }
.top-match { margin-top: 0.875rem; }
.top-title { font-size: 1.375rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--ink-soft); }
.top-match.has-match .top-title { color: var(--ink); }
.score-pill { display: inline-block; font-weight: 700; font-size: 0.875rem; padding: 0.1875rem 0.625rem; border-radius: 62rem; background: var(--track); color: var(--ink); margin-bottom: 0.625rem; }
.top-why { color: var(--ink-soft); margin: 0; }

/* Shortlist with compact donut gauge */
.gauge { position: relative; width: 5.75rem; height: 5.75rem; margin: 0.25rem auto 0.75rem; }
.gauge svg { width: 100%; height: 100%; display: block; }
.gauge-track { fill: none; stroke: var(--track); stroke-width: 12; }
.gauge-fill { fill: none; stroke: url(#gauge-grad); stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.gauge-value { position: absolute; inset: 0; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#gauge-number { font-family: var(--font-head); font-size: 1.375rem; font-weight: 700; line-height: 1; }
.gauge-unit { font-size: 0.6875rem; color: var(--ink-soft); margin-top: 0.125rem; }
.short-help { text-align: center; color: var(--ink-soft); font-size: 0.9375rem; margin: 0 0 0.75rem; }
.shortlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.short-btn {
  width: 100%;
  font: inherit;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  background: var(--field);
  border: 0.0625rem solid var(--field-line);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  min-width: 0;
}
.short-btn span:first-child { min-width: 0; overflow-wrap: anywhere; font-weight: 600; font-size: 0.9375rem; }
.short-btn span:last-child { flex: 0 0 auto; font-weight: 700; font-size: 0.875rem; color: var(--ink-soft); }
.short-btn[aria-pressed="true"] { border-color: var(--purple); box-shadow: inset 0 0 0 0.0625rem var(--purple); }

/* Details */
.detail-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; }
.detail-list { margin: 0 0 0.875rem; display: grid; gap: 0.625rem; }
.detail-list div { min-width: 0; }
.detail-list dt { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-link { font-weight: 600; font-size: 0.9375rem; }
.next-step { margin-top: 1rem; padding-top: 1rem; border-top: 0.0625rem solid var(--panel-line); }
.next-step h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.375rem; }
.next-step p { margin: 0; color: var(--ink-soft); }

/* Notes */
.notes {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 1.25rem auto 0;
  padding: 0 0 calc(2.5rem + env(safe-area-inset-bottom, 0px));
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.notes strong { color: var(--ink); }

/* 3 columns from 700px, chat spans the top */
@media (min-width: 43.75rem) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-chat { grid-column: 1 / -1; grid-row: 1; }
  .board.chat-full::before { grid-column: 1 / -1; grid-row: 1; }
  .card-top, .card-short, .card-details { grid-row: 2; }
  .card-top { grid-column: 1; }
  .card-short { grid-column: 2; }
  .card-details { grid-column: 3; }
  .notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2rem; }
}

/* 4 columns from 1100px; chat card height fits the window */
@media (min-width: 68.75rem) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .card-chat { grid-column: 1; height: 34rem; }
  .board.chat-full::before { grid-column: 1; grid-row: 1; }
  .card-top, .card-short, .card-details { grid-row: 1; }
  .card-top { grid-column: 2; }
  .card-short { grid-column: 3; }
  .card-details { grid-column: 4; }
  @supports (height: 100svh) {
    .card-chat { height: clamp(22rem, 100svh - 21rem, 38rem); }
  }
  .card-chat .log { min-height: 0; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gauge-fill { transition: none; }
}
