/* ==========================================================================
   DeepVerse — The Consultation Studio
   Editorial, heritage-school aesthetic: warm paper, forest green, brass,
   serif display type. Person-first: the advisor fills the right panel and
   the conversation sits over her like call captions.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* paper & ink */
  --paper: #f3eee2;
  --paper-deep: #eae3d1;
  --card: #fffdf6;
  --ink: #211f18;
  --ink-2: #46422f;
  /* Both tokens are used as text on paper/card surfaces. Keep them at
     WCAG AA contrast for the small labels used throughout the workspace. */
  --mut: #716a58;
  --line: #ddd5bf;
  --line-2: #c9bfa3;

  /* heritage */
  --green: #1d4a38;
  --green-deep: #12392a;
  --green-wash: #e4eae3;
  --brass: #87641f;
  --brass-soft: #c9a45e;
  --wine: #7c2d2d;

  --serif: 'Fraunces', 'Noto Serif JP', 'Noto Serif TC', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', 'Noto Sans JP', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;

  --topbar-h: 66px;
  --panel-w: clamp(360px, 30vw, 440px);

  --ring: 0 0 0 3px rgba(29, 74, 56, 0.25);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 110% -20%, rgba(29, 74, 56, 0.08), transparent 60%),
    var(--paper);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}

input,
select {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

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

.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%);
  color: var(--mut);
  font-family: var(--serif);
  font-size: 18px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 118, 99, 0.4) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(125, 118, 99, 0.35);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------------------------
   3. Studio shell
   -------------------------------------------------------------------------- */
.studio {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

.studio-topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-shrink: 0;
  height: var(--topbar-h);
  padding: 0 26px;
  border-bottom: 1px solid var(--line-2);
  background: var(--paper);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wordmark-crest {
  width: 30px;
  height: 34px;
  clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 80%);
  box-shadow: inset 0 -2px 0 var(--brass-soft);
}

.wordmark strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.05;
}

.wordmark span {
  display: block;
  margin-top: 1px;
  color: var(--mut);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.studio-nav {
  display: flex;
  gap: 4px;
  margin: 0 auto;
  height: 100%;
}

/* The nav entries are anchors so every view has a followable address; the
   underline they would otherwise carry is replaced by the active rule below. */
.advisor-nav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 18px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.advisor-nav-btn b {
  font-weight: inherit;
}

.advisor-nav-btn::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--brass);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.advisor-nav-btn:hover {
  color: var(--ink);
}

.advisor-nav-btn.active {
  color: var(--green);
  font-weight: 700;
}

.advisor-nav-btn.active::after {
  transform: scaleX(1);
}

/* The assessment entry carries its own state, so a family can see at a glance
   that a completed result is still there for the rest of the consultation. */
.advisor-nav-test.has-result b::after {
  content: " ✓";
  color: var(--green);
  font-weight: 700;
}

.advisor-nav-test.in-progress b::after {
  content: " •";
  color: var(--brass);
  font-weight: 700;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

a.source-card-link {
  display: inline-block;
  text-decoration: none;
}

.source-card-meta {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

/* 測驗邀請卡：顧問覺得時機到了才出現在回覆下方 */
.exam-invite-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--brass);
  background: rgba(160, 119, 40, 0.08);
  font-size: 12.5px;
  color: var(--ink-2);
}

.exam-invite-actions {
  display: flex;
  gap: 8px;
}

.exam-invite-card button {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid var(--ink);
  cursor: pointer;
}

.exam-invite-card .exam-invite-go {
  background: var(--green);
  color: var(--paper);
}

.exam-invite-card .exam-invite-skip {
  background: transparent;
  color: var(--ink-2);
}

/* The assessment hand-off is an important state change, so keep it visually
   distinct from the bot bubble and high-contrast on small phone screens. */
.exam-invite-card.assessment-invite-card {
  border-color: var(--green-deep);
  background: var(--green-deep);
  color: var(--card);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(18, 57, 42, 0.18);
}

.exam-invite-card.assessment-invite-card .exam-invite-go {
  border-color: var(--card);
  background: var(--card);
  color: var(--green-deep);
}

.exam-invite-card.assessment-invite-card .exam-invite-skip {
  border-color: rgba(255, 253, 246, 0.78);
  color: var(--card);
}

/* Heritage dropdowns — square, ink border, brass chevron, small caps */
.advisor-select,
.dashboard-select,
.lead-gate-form select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  border: 1px solid var(--ink);
  color: var(--ink-2);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6' viewBox='0 0 9 6'%3E%3Cpath d='M1 1l3.5 4L8 1' fill='none' stroke='%23a07728' stroke-width='1.4'/%3E%3C/svg%3E")
    no-repeat right 12px center / 9px 6px,
    transparent;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
}

.advisor-select {
  height: 36px;
  padding: 0 28px 0 12px;
}

.advisor-select:focus-visible,
.dashboard-select:focus-visible,
.lead-gate-form select:focus-visible {
  border-color: var(--green);
  box-shadow: var(--ring);
}

.advisor-select:hover,
.dashboard-select:hover {
  color: var(--green);
}

.studio-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  flex: 1;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   4. Workspace & view chrome
   -------------------------------------------------------------------------- */
.studio-workspace {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line-2);
}

.advisor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.view-header {
  flex-shrink: 0;
  padding: 34px 44px 24px;
  border-bottom: 1px solid var(--line);
}

.view-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brass);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.view-kicker::before {
  content: "";
  width: 34px;
  height: 1px;
  background: var(--brass);
}

.view-header h1,
.view-header h2 {
  max-width: 900px;
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.12;
  color: var(--ink);
}

.view-header p {
  max-width: 720px;
  color: var(--mut);
  font-size: 14.5px;
  line-height: 1.65;
}

.view-body {
  flex: 1;
  min-height: 0;
  padding: 28px 44px 44px;
  overflow-y: auto;
}

/* --------------------------------------------------------------------------
   5. Overview — editorial
   -------------------------------------------------------------------------- */
.intro-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.9fr);
  gap: 44px;
  align-items: start;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}

.section-more {
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brass-soft);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.featured-card {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--line-2);
  background: var(--card);
  text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.featured-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}

.featured-loc {
  color: var(--brass);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.featured-card strong {
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.featured-card:hover strong {
  text-decoration: underline;
  text-decoration-color: var(--brass-soft);
  text-underline-offset: 3px;
}

.featured-card p {
  color: var(--mut);
  font-size: 12.5px;
  line-height: 1.55;
}

.featured-card b {
  margin-top: 3px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.ask-strip {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line-2);
}

.ask-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ask-chip {
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 99px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ask-chip:hover {
  border-color: var(--green);
  background: var(--green-wash);
  color: var(--green);
}

.intro-aside {
  position: sticky;
  top: 0;
  display: grid;
  gap: 0;
  border: 1px solid var(--line-2);
  background: var(--card);
}

.intro-stat {
  display: grid;
  gap: 2px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.intro-stat:last-child {
  border-bottom: 0;
}

.intro-stat b {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  color: var(--green);
  line-height: 1.05;
}

.intro-stat span {
  color: var(--mut);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intro-aside-note {
  padding: 16px 22px;
  border-top: 2px solid var(--green);
  background: var(--green-wash);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
}

.intro-services {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 40px;
  border-top: 1px solid var(--line-2);
}

.intro-service {
  padding: 22px 26px 22px 0;
  border-right: 1px solid var(--line);
  margin-right: 26px;
  text-align: left;
  transition: background 0.15s ease;
}

.intro-service:last-child {
  border-right: 0;
  margin-right: 0;
}

.intro-service span {
  display: block;
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro-service strong {
  display: block;
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.intro-service p {
  margin-top: 7px;
  color: var(--mut);
  font-size: 13px;
  line-height: 1.6;
}

.featured-method {
  margin: -8px 0 18px;
  color: var(--mut);
  font-size: 11.5px;
  line-height: 1.55;
}

button.intro-service:hover strong {
  color: var(--green);
  text-decoration: underline;
  text-decoration-color: var(--brass-soft);
  text-underline-offset: 4px;
}

/* --------------------------------------------------------------------------
   6. Toolbar / inputs / actions
   -------------------------------------------------------------------------- */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-input {
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  flex: 1;
  min-width: 200px;
}

.dashboard-select {
  height: 42px;
  padding: 0 30px 0 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.dashboard-input:focus-visible {
  border-color: var(--green);
  box-shadow: var(--ring);
}

.dashboard-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 24px;
  border-radius: 4px;
  color: #f6f2e7;
  background: var(--green);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s ease;
}

.dashboard-action:hover {
  background: var(--green-deep);
}

.dashboard-action.secondary {
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-2);
}

.dashboard-action.secondary:hover {
  border-color: var(--ink-2);
  background: var(--card);
}

/* --------------------------------------------------------------------------
   7. League table — printed table aesthetic
   -------------------------------------------------------------------------- */
.league-table-wrap {
  max-height: calc(100% - 60px);
  overflow: auto;
  border-top: 2px solid var(--ink);
  background: transparent;
}

.league-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

.league-col-rank {
  width: 7%;
}

.league-col-metric {
  width: 15%;
}

.league-col-university {
  width: 34%;
}

/* The scope toggle sits above the toolbar rather than inside it: which table
   you are reading is a different kind of choice from how you filter it, and on
   a narrow screen the two wrapping into one row reads as four peer buttons. */
.league-scope-toggle {
  display: inline-flex;
  margin-bottom: 12px;
  border: 1px solid var(--ink);
  overflow: hidden;
}

.league-scope-toggle button {
  min-height: 40px;
  padding: 0 22px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.league-scope-toggle button + button {
  border-left: 1px solid var(--ink);
}

.league-scope-toggle button.active {
  background: var(--ink);
  color: var(--paper);
}

.league-metric-toggle {
  display: inline-flex;
  border: 1px solid var(--ink);
  overflow: hidden;
}

.league-metric-toggle button {
  min-height: 40px;
  padding: 0 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.league-metric-toggle button + button {
  border-left: 1px solid var(--ink);
}

.league-metric-toggle button.active {
  background: var(--green);
  color: var(--paper);
}

.league-source-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-3, var(--ink-2));
  letter-spacing: 0.02em;
}

.rank-heading {
  padding: 0 12px 0 2px !important;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.rank-cell {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--brass) !important;
}

.metric-cell small {
  font-size: 10px;
  color: var(--ink-2);
}

.league-col-gender,
.league-col-age {
  width: 10%;
}

.league-col-location {
  width: 18%;
}

.league-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  text-align: left;
}

.sort-header-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px 0 2px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sort-header-btn:hover,
.sort-header-btn.active {
  color: var(--green);
}

.sort-header-btn.active span {
  color: var(--brass);
}

.league-table tbody td {
  height: 46px;
  padding: 0 12px 0 2px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  font-variant-numeric: tabular-nums;
}

.league-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.league-table tbody tr:hover {
  background: rgba(29, 74, 56, 0.06);
}

.league-table tbody tr:hover .school-name-cell {
  text-decoration: underline;
  text-decoration-color: var(--brass-soft);
  text-underline-offset: 3px;
}

.school-name-cell {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink) !important;
}

.school-detail {
  margin-top: 18px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line-2);
  color: var(--mut);
  font-size: 13px;
  line-height: 1.7;
}

.school-detail strong {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

.school-detail .open-profile-link {
  margin-left: 10px;
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brass-soft);
}

/* --------------------------------------------------------------------------
   8. Map
   -------------------------------------------------------------------------- */
.map-search-row {
  position: relative;
  z-index: 500;
}

.map-search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.map-search-box .dashboard-input {
  width: 100%;
}

.map-search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 600;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--card);
  box-shadow: 0 16px 40px rgba(33, 31, 24, 0.18);
}

.map-search-suggestions button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 0.12s ease;
}

.map-search-suggestions button:last-child {
  border-bottom: 0;
}

.map-search-suggestions button:hover {
  background: var(--green-wash);
}

.map-search-suggestions span {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

.map-search-suggestions small {
  flex-shrink: 0;
  color: var(--mut);
  font-size: 12px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 300px;
  gap: 22px;
  align-items: stretch;
}

.uk-map {
  min-height: 480px;
  border: 1px solid var(--line-2);
  overflow: hidden;
  filter: sepia(0.14) saturate(0.9);
}

.map-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--mut);
  font-size: 14px;
}

.map-side {
  overflow-y: auto;
  padding: 2px 0 0;
}

.map-side h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
}

.map-side > p {
  margin-top: 9px;
  color: var(--mut);
  font-size: 13px;
  line-height: 1.65;
}

.map-side dl {
  display: grid;
  gap: 11px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}

.map-side dt {
  color: var(--brass);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.map-side dd {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
}

.map-side .dashboard-action {
  margin-top: 16px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   9. Placement test
   -------------------------------------------------------------------------- */
.exam-intro {
  display: grid;
  gap: 18px;
  max-width: 780px;
}

.exam-intro > p {
  color: var(--mut);
  font-size: 13.5px;
  line-height: 1.7;
}

.exam-age-band-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 210px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid var(--line-2);
  background: var(--card);
}

.exam-age-band-row label {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.exam-age-band-row p {
  color: var(--mut);
  font-size: 12.5px;
  line-height: 1.55;
}

.exam-intro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
}

.exam-stat {
  display: grid;
  gap: 3px;
  padding: 18px 4px;
  border-right: 1px solid var(--line);
}

.exam-stat:last-child {
  border-right: 0;
}

.exam-stat span {
  color: var(--mut);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.exam-stat strong {
  font-family: var(--serif);
  color: var(--green);
  font-size: 30px;
  font-weight: 600;
}

.exam-start-btn {
  justify-self: start;
  min-height: 48px;
  padding: 0 34px;
}

.test-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 26px;
  align-items: start;
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-item {
  display: grid;
  gap: 11px;
  padding: 18px 20px;
  border: 1px solid var(--line-2);
  background: var(--card);
}

.question-subject {
  justify-self: start;
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.question-item > strong {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.5;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.answer-grid button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
  line-height: 1.4;
  transition: border-color 0.13s ease, background 0.13s ease;
}

.answer-grid button:hover {
  border-color: var(--green);
  background: var(--green-wash);
}

.answer-grid button.selected {
  border-color: var(--green);
  background: var(--green-wash);
  color: var(--green);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--green);
}

.answer-grid button.correct {
  border-color: #2c6e49;
  background: #e6f0e6;
  color: #1e5631;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px #2c6e49;
}

.answer-grid button.wrong {
  border-color: var(--wine);
  background: #f6e8e8;
  color: var(--wine);
  box-shadow: inset 0 0 0 1px var(--wine);
}

.test-summary {
  position: sticky;
  top: 0;
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--line-2);
  border-top: 2px solid var(--green);
  background: var(--card);
}

.test-summary > span {
  color: var(--mut);
  font-size: 12.5px;
}

.test-summary > strong {
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  color: var(--green);
}

.test-summary > p {
  color: var(--mut);
  font-size: 12.5px;
  line-height: 1.6;
}

.exam-toolbar {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.exam-clock {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.exam-clock span {
  color: var(--mut);
  font-size: 12px;
}

.exam-clock strong {
  font-variant-numeric: tabular-nums;
  font-family: var(--serif);
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
}

.exam-clock strong.warning {
  color: var(--wine);
  animation: examBlink 1s steps(2) infinite;
}

@keyframes examBlink {
  50% { opacity: 0.55; }
}

.exam-result {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
  max-width: 840px;
}

.exam-result-score {
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 30px;
  text-align: center;
  border: 1px solid var(--line-2);
  border-top: 2px solid var(--green);
  background: var(--card);
}

.exam-result-score span {
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.exam-result-score strong {
  font-family: var(--serif);
  font-size: 58px;
  font-weight: 600;
  color: var(--green);
  line-height: 1.05;
}

.exam-result-score p {
  color: var(--mut);
  font-size: 13px;
}

.exam-result .school-detail {
  margin-top: 0;
  border-top: 0;
  padding-top: 4px;
}

.exam-next-step .dashboard-action {
  margin: 10px 8px 0 0;
}

/* --------------------------------------------------------------------------
   10. Consult panel — the person
   -------------------------------------------------------------------------- */
.consult-panel {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--green-deep);
}

.avatar-bubble-toggle {
  display: none;
}

.consult-card {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.consult-stage {
  position: absolute;
  inset: 0;
}

.consult-wide-photo {
  display: none;
}

/* the scene drifts (not the img) so stacked motion frames stay aligned */
.consult-scene {
  position: absolute;
  inset: 0;
  transform-origin: 50% 26%;
  animation: kenBurns 26s ease-in-out infinite alternate;
  /* --speak is driven by the live TTS audio analyser */
  filter: brightness(calc(0.98 + var(--speak, 0) * 0.10));
}

.consult-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

/* motion layers from images/advisor/ (video loops or aligned still frames),
   toggled by avatarMotion.js */
.consult-photo-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  opacity: 0;
  transition: opacity 70ms linear;
  pointer-events: none;
}

/* Generated still frames are full photos, but only the edited facial region
   is composited. This hides harmless background/skin drift from img2img and
   makes the swap read as motion instead of a second photograph flashing. */
.consult-blink-frame {
  clip-path: inset(24% 29% 65% 29% round 18px);
}

.consult-talk-frame {
  clip-path: inset(34% 35% 56% 35% round 24px);
  transition-duration: 45ms;
}

@keyframes kenBurns {
  from { transform: scale(1.02); }
  to { transform: scale(1.09) translateY(-1.5%); }
}

.consult-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(9, 24, 18, 0.42) 0%, rgba(9, 24, 18, 0.05) 22%, transparent 42%, rgba(7, 20, 15, 0.62) 78%, rgba(7, 20, 15, 0.82) 100%);
}

.consult-identity {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 3;
  display: grid;
  gap: 3px;
  max-width: 72%;
}

.avatar-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-self: start;
  margin-bottom: 4px;
  padding: 4px 11px 4px 8px;
  border-radius: 99px;
  border: 1px solid rgba(246, 242, 231, 0.28);
  background: rgba(7, 20, 15, 0.42);
  backdrop-filter: blur(8px);
  color: #ece5d1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.avatar-status em {
  display: none;
  font-style: normal;
}

.consult-panel:not(.is-thinking):not(.is-speaking) .avatar-status .status-idle,
.consult-panel.is-thinking .avatar-status .status-thinking,
.consult-panel.is-speaking .avatar-status .status-speaking {
  display: inline;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9a45e;
  box-shadow: 0 0 0 0 rgba(201, 164, 94, 0.5);
  animation: statusPing 2.6s ease-out infinite;
}

.consult-panel.is-thinking .status-dot {
  animation-duration: 1s;
}

@keyframes statusPing {
  0% { box-shadow: 0 0 0 0 rgba(201, 164, 94, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(201, 164, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 164, 94, 0); }
}

.consult-identity strong {
  color: #f6f2e7;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 10px rgba(7, 20, 15, 0.6);
}

.consult-identity > span:last-child {
  color: rgba(236, 229, 209, 0.82);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(7, 20, 15, 0.6);
}

/* EQ bars — scaled by the real audio level (--speak) while she talks */
.avatar-eq {
  position: absolute;
  top: 24px;
  right: 62px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.consult-panel.is-speaking .avatar-eq {
  opacity: 1;
}

.avatar-eq span {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--brass-soft);
  transform: scaleY(calc(0.18 + var(--speak, 0) * 0.82));
  transition: transform 0.08s linear;
}

.avatar-eq span:nth-child(1) { transform: scaleY(calc(0.15 + var(--speak, 0) * 0.5)); }
.avatar-eq span:nth-child(2) { transform: scaleY(calc(0.2 + var(--speak, 0) * 0.75)); }
.avatar-eq span:nth-child(4) { transform: scaleY(calc(0.2 + var(--speak, 0) * 0.65)); }
.avatar-eq span:nth-child(5) { transform: scaleY(calc(0.12 + var(--speak, 0) * 0.45)); }

/* lives on .consult-card so it survives concise mode (stage hidden) */
.consult-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  gap: 8px;
}

.consult-action-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(246, 242, 231, 0.3);
  border-radius: 4px;
  background: rgba(7, 20, 15, 0.42);
  backdrop-filter: blur(8px);
  color: #ece5d1;
  font-size: 19px;
  line-height: 1;
  transition: background 0.15s ease;
}

.consult-action-btn:hover {
  background: rgba(7, 20, 15, 0.7);
}

.consult-action-btn .icon {
  width: 16px;
  height: 16px;
}

#avatarCloseBtn {
  display: none;
}

/* action buttons over the light compact header in concise mode */
body[data-chat-mode="concise"] .consult-action-btn {
  border-color: var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
  backdrop-filter: none;
}

body[data-chat-mode="concise"] .consult-actions {
  top: 12px;
  right: 12px;
}

/* --------------------------------------------------------------------------
   11. Chat over the person — call captions
   -------------------------------------------------------------------------- */
.chat-container {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-height: 0;
  pointer-events: none;
}

/* per-mode transcript containers — [hidden] must beat display:flex */
.chat-messages[hidden] {
  display: none;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50%;
  padding: 14px 16px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
  mask-image: linear-gradient(180deg, transparent 0%, #000 9%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 9%);
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
  animation: messageIn 0.28s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  flex-direction: row-reverse;
}

/* captions over the photo: avatars are noise, hide in interactive mode */
.message-avatar {
  display: none;
  flex-shrink: 0;
  place-items: center;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.message-bubble {
  position: relative;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: var(--chat-message-font-size, 13.5px);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.message.bot .message-bubble {
  color: #f2eede;
  background: rgba(10, 26, 20, 0.66);
  border: 1px solid rgba(246, 242, 231, 0.14);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
  color: #241f12;
  background: rgba(240, 231, 208, 0.94);
  border: 1px solid rgba(201, 164, 94, 0.5);
  backdrop-filter: blur(10px);
  border-bottom-right-radius: 4px;
}

.message.proactive-message .message-bubble {
  border-left: 2px solid var(--brass-soft);
}

.bot-answer.streaming {
  white-space: pre-wrap;
}

.bot-answer p {
  margin: 0 0 8px;
}

.bot-answer p:last-child {
  margin-bottom: 0;
}

.bot-answer ul,
.bot-answer ol {
  margin: 6px 0 8px;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

.bot-answer li::marker {
  color: var(--brass-soft);
  font-weight: 700;
}

.bot-answer .md-h {
  display: block;
  margin: 10px 0 5px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
}

.bot-answer .md-h:first-child {
  margin-top: 0;
}

.bot-answer code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 2px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass-soft);
  animation: typing 1.3s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* sources pill under a bot reply — same family as the status pill */
.source-tooltip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 12px;
  border: 1px solid rgba(246, 242, 231, 0.25);
  border-radius: 99px;
  background: rgba(246, 242, 231, 0.08);
  color: #ece5d1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.source-tooltip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brass-soft);
}

.source-tooltip:hover {
  border-color: var(--brass-soft);
  background: rgba(201, 164, 94, 0.18);
}

/* source quotation cards inside the drawer */
.source-cards {
  display: grid;
  gap: 14px;
  padding-top: 18px;
}

.source-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass-soft);
  background: var(--paper);
}

.source-card-kicker {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--brass);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.source-card-kicker em {
  color: var(--mut);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}

.source-card h4 {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.source-card blockquote {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-style: italic;
  line-height: 1.7;
}

mark.source-keyword,
mark.keyword-mark {
  background: rgba(245, 140, 54, 0.34);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
  box-shadow: inset 0 -1px 0 rgba(176, 77, 18, 0.42);
}

.source-card-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brass-soft);
}

/* cited chunk highlight inside the school profile drawer */
mark.chunk-mark {
  background: rgba(201, 164, 94, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 1px 2px;
  box-shadow: 0 0 0 1px rgba(168, 121, 44, 0.25);
}

.drawer-cited-chunk {
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-2);
  background: var(--green-wash);
}

.drawer-cited-chunk span {
  color: var(--green);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.drawer-cited-chunk p {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.65;
}

.drawer-section.section-cited {
  border-left: 3px solid var(--brass-soft);
  padding-left: 12px;
  margin-left: -15px;
  background: rgba(201, 164, 94, 0.07);
}

/* original-page PDF viewer (e-guide sources) */
.pdf-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.pdf-back {
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brass-soft);
}

.pdf-pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pdf-nav {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s ease;
}

.pdf-nav:hover {
  background: var(--green-wash);
  color: var(--green);
}

.pdf-page-label {
  color: var(--mut);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.pdf-stage {
  position: relative;
  margin: 16px 20px 28px;
  border: 1px solid var(--line-2);
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(33, 31, 24, 0.12);
}

.pdf-stage canvas {
  display: block;
}

.pdf-loading {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--mut);
  font-size: 13px;
}

.pdf-highlight {
  position: absolute;
  background: rgba(201, 164, 94, 0.38);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(168, 121, 44, 0.3);
  pointer-events: none;
}

/* dock: mode switch + report + input pinned at the bottom of the photo */
.chat-dock {
  flex-shrink: 0;
  display: grid;
  gap: 8px;
  padding: 8px 16px 16px;
  pointer-events: auto;
}

.chat-mode-bar {
  display: flex;
  gap: 0;
  justify-self: start;
  border: 1px solid rgba(246, 242, 231, 0.28);
  border-radius: 99px;
  overflow: hidden;
  background: rgba(7, 20, 15, 0.45);
  backdrop-filter: blur(8px);
}

.chat-mode-btn {
  min-height: 30px;
  padding: 0 16px;
  color: rgba(236, 229, 209, 0.75);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-mode-btn.active {
  background: #ece5d1;
  color: var(--green-deep);
}

.chat-utility-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
}

.chat-tool-btn {
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid rgba(246, 242, 231, 0.24);
  border-radius: 99px;
  color: rgba(236, 229, 209, 0.9);
  background: rgba(7, 20, 15, 0.4);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.chat-tool-btn:hover:not(:disabled) {
  background: rgba(246, 242, 231, 0.12);
}

.chat-tool-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.chat-text-size-btn {
  min-width: 36px;
  padding: 0 8px;
}

/* "A+"/"A−" read as an A-Level grade to Chinese users. The accessibility
   convention — a small A and a large A of the same letter — needs no reading
   and no translation; the localized title still explains it on hover. */
.text-size-glyph {
  font-weight: 700;
  line-height: 1;
  color: var(--parchment, #f6f2e7);
}

.text-size-small {
  font-size: 12px;
}

.text-size-large {
  font-size: 19px;
}

.generate-report-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  justify-self: start;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 99px;
  color: #241f12;
  background: var(--brass-soft);
  font-size: 12.5px;
  font-weight: 700;
  transition: background 0.15s ease;
}

.generate-report-btn:hover {
  background: #d9b876;
}

.generate-report-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.generate-report-btn .icon {
  width: 15px;
  height: 15px;
}

.generate-report-btn .spinning {
  animation: spin 1s linear infinite;
}

.message-bubble > .generate-report-btn {
  margin-top: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(246, 242, 231, 0.25);
  border-radius: 12px;
  background: rgba(7, 20, 15, 0.55);
  backdrop-filter: blur(12px);
  transition: border-color 0.15s ease;
}

.chat-input:focus-within {
  border-color: var(--brass-soft);
}

.chat-input textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: #f6f2e7;
  font-family: inherit;
  font-size: 14px;
  line-height: 18px;
  outline: none;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
}

.chat-input textarea::placeholder {
  color: rgba(236, 229, 209, 0.55);
  font-size: 14px;
}

.chat-input .icon {
  width: 17px;
  height: 17px;
}

.mic-btn,
.live-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(246, 242, 231, 0.22);
  border-radius: 9px;
  background: transparent;
  color: rgba(236, 229, 209, 0.85);
  transition: background 0.15s ease, color 0.15s ease;
}

.mic-btn:hover,
.live-btn:hover {
  background: rgba(246, 242, 231, 0.12);
  color: #ffffff;
}

.mic-btn.recording,
.live-btn.active {
  border-color: #e07a5f;
  background: rgba(224, 122, 95, 0.25);
  color: #ffb4a2;
  animation: recPulse 1.3s ease-in-out infinite;
}

/* 準備中：麥克風權限、VAD 模型或 WebRTC 交握還沒完成，此時還不能講話，
   所以刻意跟紅色的錄音狀態分開，用比較安靜的琥珀色慢速呼吸 */
.mic-btn.preparing,
.live-btn.preparing,
.live-btn.active.preparing {
  border-color: var(--brass-soft);
  background: rgba(201, 164, 94, 0.18);
  color: var(--brass-soft);
  animation: prepPulse 1.8s ease-in-out infinite;
}

@keyframes prepPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.voice-preparing-hint {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
  font-size: 12.5px;
  line-height: 36px;
  color: var(--brass);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mic-btn.processing {
  border-color: var(--brass-soft);
  background: rgba(201, 164, 94, 0.22);
  color: var(--brass-soft);
  animation: recPulse 1.3s ease-in-out infinite;
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0.35); }
  55% { box-shadow: 0 0 0 6px rgba(224, 122, 95, 0); }
}

#sendBtn {
  flex-shrink: 0;
  display: none;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 9px;
  color: var(--green-deep);
  background: #ece5d1;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s ease;
}

#sendBtn:hover {
  background: #ffffff;
}

#sendBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-input.has-text .mic-btn,
.chat-input.has-text .live-btn {
  display: none;
}

.chat-input.has-text #sendBtn {
  display: block;
}

.waveform-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  background: rgba(246, 242, 231, 0.1);
}

.waveform-bar {
  width: 3px;
  min-height: 6px;
  max-height: 26px;
  border-radius: 2px;
  background: var(--brass-soft);
  transition: height 0.1s ease;
}

/* --------------------------------------------------------------------------
   12. Concise (tool) mode — plain paper document chat
   -------------------------------------------------------------------------- */
.chat-compact-header {
  display: none;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.chat-compact-header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line-2);
}

.chat-compact-header strong {
  display: block;
  font-family: var(--serif);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.chat-compact-header span {
  display: block;
  margin-top: 1px;
  color: var(--mut);
  font-size: 11.5px;
}

body[data-chat-mode="concise"] .consult-panel {
  background: var(--paper);
}

body[data-chat-mode="concise"] .consult-stage {
  display: none;
}

body[data-chat-mode="concise"] .consult-card {
  display: flex;
}

body[data-chat-mode="concise"] .chat-compact-header {
  display: flex;
}

body[data-chat-mode="concise"] .chat-container {
  background: var(--paper);
}

body[data-chat-mode="concise"] .chat-messages {
  max-height: none;
  flex: 1;
  mask-image: none;
  -webkit-mask-image: none;
}

body[data-chat-mode="concise"] .message-bubble {
  max-width: 100%;
  border-radius: 6px;
  font-size: var(--chat-message-font-size, 13.5px);
  backdrop-filter: none;
}

body[data-chat-mode="concise"] .message.bot .message-bubble {
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--line);
}

body[data-chat-mode="concise"] .message.user .message-bubble {
  color: #f6f2e7;
  background: var(--green);
  border: 0;
}

body[data-chat-mode="concise"] .bot-answer .md-h {
  color: var(--ink);
}

body[data-chat-mode="concise"] .bot-answer code {
  background: var(--paper-deep);
}

body[data-chat-mode="concise"] .source-tooltip {
  border-color: var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
}

body[data-chat-mode="concise"] .source-tooltip::before {
  background: var(--brass);
}

body[data-chat-mode="concise"] .source-tooltip:hover {
  border-color: var(--green);
  background: var(--green-wash);
  color: var(--green);
}

body[data-chat-mode="concise"] .typing-indicator span {
  background: var(--mut);
}

body[data-chat-mode="concise"] .chat-dock {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding-top: 10px;
}

body[data-chat-mode="concise"] .chat-mode-bar {
  border-color: var(--line-2);
  background: var(--paper);
}

body[data-chat-mode="concise"] .chat-mode-btn {
  color: var(--mut);
}

body[data-chat-mode="concise"] .chat-mode-btn.active {
  background: var(--green);
  color: #f6f2e7;
}

body[data-chat-mode="concise"] .chat-input {
  border-color: var(--line-2);
  background: var(--paper);
}

body[data-chat-mode="concise"] .chat-input textarea {
  color: var(--ink);
}

body[data-chat-mode="concise"] .chat-input textarea::placeholder {
  color: var(--mut);
}

body[data-chat-mode="concise"] #sendBtn {
  display: block;
  color: #f6f2e7;
  background: var(--green);
}

body[data-chat-mode="concise"] #sendBtn:hover {
  background: var(--green-deep);
}

body[data-chat-mode="concise"] .mic-btn,
body[data-chat-mode="concise"] .live-btn {
  display: none !important;
}

body[data-chat-mode="concise"] .chat-input.has-text .mic-btn,
body[data-chat-mode="concise"] .chat-input.has-text .live-btn {
  display: none;
}

body[data-chat-mode="concise"] .generate-report-btn {
  color: #f6f2e7;
  background: var(--brass);
}

/* --------------------------------------------------------------------------
   13. School profile drawer
   -------------------------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(33, 31, 24, 0.4);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 8100;
  width: min(560px, 94vw);
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--line-2);
  box-shadow: 24px 0 80px rgba(33, 31, 24, 0.3);
  animation: drawerIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes drawerIn {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 26px 28px 18px;
  border-bottom: 1px solid var(--line-2);
  background: var(--card);
}

.drawer-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.drawer-kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--brass);
}

.drawer-head h3 {
  margin: 10px 36px 4px 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
}

.drawer-sub {
  color: var(--mut);
  font-size: 13px;
  line-height: 1.5;
}

.drawer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s ease;
}

.drawer-close:hover {
  background: var(--paper);
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-2);
}

.drawer-stat {
  display: grid;
  gap: 2px;
  padding: 14px 10px 14px 28px;
  border-right: 1px solid var(--line);
}

.drawer-stat:last-child {
  border-right: 0;
}

.drawer-stat b {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--green);
  line-height: 1.2;
}

.drawer-stat span {
  color: var(--mut);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.drawer-body {
  padding: 8px 28px 34px;
}

.drawer-overview {
  padding: 16px 0;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.75;
  border-bottom: 1px solid var(--line);
}

.drawer-overview p + p {
  margin-top: 8px;
}

.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.drawer-tags-label {
  width: 100%;
  color: var(--brass);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tag {
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 99px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 12px;
}

.drawer-section {
  border-bottom: 1px solid var(--line);
}

.drawer-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  cursor: pointer;
  list-style: none;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-section summary::-webkit-details-marker {
  display: none;
}

.drawer-section summary::after {
  content: "+";
  flex-shrink: 0;
  color: var(--brass);
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 500;
}

.drawer-section[open] summary::after {
  content: "−";
}

.drawer-section-body {
  padding: 0 0 16px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
}

.drawer-cta {
  margin-top: 22px;
  display: flex;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   14. Lead gate modal
   -------------------------------------------------------------------------- */
.lead-gate-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(33, 31, 24, 0.5);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  animation: fadeIn 0.2s ease;
}

.lead-gate-modal[hidden] {
  display: none;
}

.lead-gate-dialog {
  width: min(440px, 100%);
  max-height: min(660px, calc(100svh - 32px));
  overflow: auto;
  border-top: 3px solid var(--green);
  background: var(--card);
  box-shadow: 0 24px 70px rgba(33, 31, 24, 0.35);
  animation: dialogIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.lead-gate-header {
  position: relative;
  padding: 24px 26px 14px;
}

.lead-gate-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mut);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.lead-gate-close:hover,
.lead-gate-close:focus-visible {
  background: var(--paper);
  color: var(--ink);
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.lead-gate-header span {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--brass);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead-gate-header h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
}

.lead-gate-header p {
  margin-top: 8px;
  color: var(--mut);
  font-size: 13px;
  line-height: 1.6;
}

.google-lead-button {
  padding: 8px 26px 0;
}

.google-lead-button:empty {
  display: none;
}

.lead-gate-form {
  display: grid;
  gap: 13px;
  padding: 14px 26px 26px;
}

.lead-gate-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}

.lead-gate-form input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lead-gate-form select {
  height: 42px;
  padding: 0 30px 0 12px;
}

.lead-gate-form input:focus-visible {
  border-color: var(--green);
  box-shadow: var(--ring);
}

.lead-gate-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* Declining has to look like a real choice, not a footnote: the form is an
   offer to email a copy, and the consultation continues without it. */
.lead-gate-decline {
  background: none;
  border: 1px solid var(--ink-2);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.lead-gate-decline:hover,
.lead-gate-decline:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
}

.lead-gate-error {
  min-height: 18px;
  color: var(--wine);
  font-size: 12.5px;
  line-height: 1.4;
}

.lead-gate-required-note {
  margin: -2px 0 0;
  /* No longer a warning: for the consultation gate this line now says the
     details are optional. The human-adviser request, which genuinely needs an
     address to book anything, keeps its own wording. */
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}

.lead-gate-dialog.lead-gate-success {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 34px 30px 30px;
  text-align: center;
}

.lead-gate-success-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 28px;
  font-weight: 700;
}

.lead-gate-success h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 24px;
}

.lead-gate-success p {
  max-width: 340px;
  color: var(--mut);
  font-size: 13.5px;
  line-height: 1.6;
}

.lead-gate-notification-status {
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  background: var(--paper);
}

/* --------------------------------------------------------------------------
   About us — sits in the column beside the featured schools, so it is built
   like a card in that grid rather than a banner.
   -------------------------------------------------------------------------- */
.intro-about {
  padding: 24px 26px;
  border: 1px solid var(--line-2);
  background: var(--card);
}

.intro-about .section-title {
  margin: 0 0 4px;
}

/* the brass rule that marks a section elsewhere in the workspace */
.intro-about .section-title::after {
  content: "";
  display: block;
  width: 38px;
  height: 2px;
  margin-top: 12px;
  background: var(--brass);
}

.intro-about p {
  margin: 14px 0 0;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.75;
}

.intro-about-free strong {
  color: var(--green);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Disclaimers. The short one rides above the composer, on the dark panel; the
   long one closes the home page, on paper.
   -------------------------------------------------------------------------- */
.site-disclaimer {
  max-width: 780px;
  margin: 34px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--mut);
  font-size: 12px;
  line-height: 1.7;
}

.chat-disclaimer {
  margin: 0 0 8px;
  padding: 0 4px;
  color: rgba(246, 242, 231, 0.58);
  font-size: 10.5px;
  line-height: 1.5;
  text-align: center;
}

/* Plain text mode moves the composer from the dark photograph to a paper
   card, so the pale interactive-mode caption must switch back to ink. */
body[data-chat-mode="concise"] .chat-disclaimer {
  color: var(--mut);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--brass);
}

/* --------------------------------------------------------------------------
   Legal page — numbered clauses under plain headings. Set as a document:
   generous measure, serif headings, a brass numeral beside each section so the
   structure is scannable without reading it.
   -------------------------------------------------------------------------- */
.legal-page {
  max-width: 720px;
  padding-bottom: 20px;
}

.legal-updated {
  margin: 0 0 30px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--mut);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.legal-section {
  margin-bottom: 32px;
}

.legal-section:last-child {
  margin-bottom: 0;
}

.legal-section h3 {
  margin: 0 0 14px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.legal-clauses {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: clause;
}

.legal-clauses li {
  position: relative;
  margin-bottom: 12px;
  padding-left: 30px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.8;
  counter-increment: clause;
}

.legal-clauses li::before {
  content: counter(clause);
  position: absolute;
  top: 3px;
  left: 0;
  width: 20px;
  color: var(--brass);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.legal-clauses li:last-child {
  margin-bottom: 0;
}

/* A clause naming an address or a contact is the one people come back for. */
.legal-clauses a,
.legal-contact {
  color: var(--green);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   About us — the band that opens the page. It was a narrow sidebar beside the
   school grid, which is where a page puts a footnote. Split into the statement
   and the fact that carries the offer, because "the service is completely
   free" is the line a family acts on.
   -------------------------------------------------------------------------- */
.about-band {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
  gap: 0;
  margin-bottom: 38px;
  border: 1px solid var(--line-2);
  background: var(--card);
}

.about-band-body {
  padding: 30px 34px;
}

.about-band-body .section-title {
  margin: 0;
  font-size: 21px;
}

/* the brass rule that marks a section elsewhere in the workspace */
.about-band-body .section-title::after {
  content: "";
  display: block;
  width: 42px;
  height: 2px;
  margin-top: 14px;
  background: var(--brass);
}

.about-lede {
  margin: 18px 0 0;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.75;
}

/* The offer sits on the heritage green so the eye lands on it, and so the free
   consultation reads as an invitation rather than a disclaimer. */
.about-band-offer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  padding: 30px 32px;
  background: var(--green-deep);
  color: var(--paper);
}

.about-free {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--brass-soft);
}

.about-band-offer p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  opacity: 0.88;
}

/* With the sidebar gone the school grid has the full width, so six cards sit
   in three columns rather than two. */
.featured-section .featured-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* --------------------------------------------------------------------------
   Full-window conversation. Testers asked to give the chat the whole desktop
   window. The workspace column collapses rather than the panel floating over
   it, so nothing is left half-visible behind the conversation.
   -------------------------------------------------------------------------- */
.consult-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  gap: 7px;
  padding: 0 12px;
  white-space: nowrap;
  /* the control has to be findable, so it carries a word as well as a glyph */
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.consult-action-label {
  line-height: 1;
}

/* the arrows point outward to expand, inward to restore */
.consult-expand-btn .expand-in { display: none; }
body.chat-expanded .consult-expand-btn .expand-out { display: none; }
body.chat-expanded .consult-expand-btn .expand-in { display: inline; }

/* One track, not a zero-width first one: the workspace is removed from the
   layout below, so the panel becomes the only grid item and would otherwise
   land in that empty first column and collapse to nothing. */
body.chat-expanded .studio-body {
  grid-template-columns: minmax(0, 1fr);
}

body.chat-expanded .studio-workspace {
  /* removed from the layout entirely, not merely covered */
  display: none;
}

/* A conversation across a full desktop window would otherwise run to a
   ninety-character measure, which is tiring to read. Hold the column to a
   comfortable width and centre it. */
body.chat-expanded .chat-messages,
body.chat-expanded .chat-dock {
  /* width first: auto side margins cancel a flex item's stretch, so without it
     the composer shrank to its content and sat 316px wide under a 900px
     conversation. */
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* The portrait is decoration here; at full width it would push the
   conversation itself below the fold. */
body.chat-expanded .consult-stage {
  max-height: 200px;
  overflow: hidden;
}

/* Stretching the portrait across the whole window magnified the face about
   fourfold — a testers' word for it was frightening. Keep the scene at the
   width it has in the panel so the face renders at exactly the same scale,
   centre it, and let a blurred copy fill the space either side. Holding the
   width also keeps the motion frames aligned: consult-blink-frame and
   consult-talk-frame clip to percentages of this box, so a box of a different
   shape would clip somewhere other than the face. */
body.chat-expanded .consult-scene {
  left: 50%;
  right: auto;
  width: var(--panel-w);
  margin-left: calc(var(--panel-w) / -2);
  z-index: 1;
}

body.chat-expanded .consult-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../images/advisor-consultant.png') center 18% / cover no-repeat;
  filter: blur(30px) brightness(0.62) saturate(0.85);
  /* scaled up so the blur does not bleed the edges inwards */
  transform: scale(1.12);
  z-index: 0;
}

body.chat-expanded .consult-scrim {
  z-index: 2;
}

/* Left-aligned to the conversation column rather than the window, so the name
   sits above the text it belongs to instead of far out in the blur. */
body.chat-expanded .consult-identity {
  left: max(20px, calc(50% - 450px));
}

/* At desktop sizes expanded means a real conversation workspace. The portrait
   keeps exactly the width it had as the side panel, while the conversation
   gets the rest of the window. This avoids both the giant-face treatment and
   the short letterboxed portrait that left most of the screen empty. */
@media (min-width: 1101px) {
  body.chat-expanded .studio {
    height: 100dvh;
  }

  body.chat-expanded .studio-topbar {
    display: none;
  }

  body.chat-expanded .consult-card {
    display: grid;
    grid-template-columns: var(--panel-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  body.chat-expanded .consult-stage {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1;
    max-height: none;
    overflow: hidden;
  }

  body.chat-expanded .consult-scene {
    inset: 0;
    width: auto;
    margin-left: 0;
  }

  body.chat-expanded .consult-stage::before {
    content: none;
  }

  body.chat-expanded .chat-container {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    height: 100%;
    background:
      radial-gradient(circle at 8% 8%, rgba(201, 164, 94, 0.12), transparent 34%),
      var(--green-deep);
  }

  /* Interactive full-window mode uses the generated wide photograph as one
     continuous canvas. The adviser sits on the left third while the office
     naturally softens behind the conversation on the right. */
  body.chat-expanded:not([data-chat-mode="concise"]) .consult-card {
    display: block;
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-stage {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-wide-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-scene {
    display: block;
    top: 0;
    bottom: 0;
    left: calc(33.333vw - 33.333vh);
    right: auto;
    width: 66.667vh;
    height: 100%;
    margin-left: 0;
    z-index: 1;
    mask-image: linear-gradient(90deg,
      transparent 0%,
      #000 9%,
      #000 91%,
      transparent 100%);
    -webkit-mask-image: linear-gradient(90deg,
      transparent 0%,
      #000 9%,
      #000 91%,
      transparent 100%);
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-scrim {
    background:
      linear-gradient(90deg,
        rgba(24, 22, 20, 0.04) 0%,
        rgba(24, 22, 20, 0.08) 38%,
        rgba(20, 19, 18, 0.34) 68%,
        rgba(18, 17, 16, 0.58) 100%),
      linear-gradient(180deg,
        rgba(18, 17, 16, 0.22) 0%,
        transparent 24%,
        transparent 58%,
        rgba(18, 17, 16, 0.42) 100%);
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .chat-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
  }

  /* Hold the reading measure to a comfortable width, but keep the transcript
     and composer as one aligned unit. The auto spacer places short
     conversations beside the input instead of marooning one line at the top. */
  body.chat-expanded .chat-messages,
  body.chat-expanded .chat-dock {
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .chat-messages,
  body.chat-expanded:not([data-chat-mode="concise"]) .chat-dock {
    width: min(700px, 62vw);
    max-width: none;
    margin-left: auto;
    margin-right: clamp(20px, 4vw, 72px);
  }

  body.chat-expanded .chat-messages {
    flex: 1;
    max-height: none;
    padding-top: 64px;
  }

  body.chat-expanded .chat-messages::before {
    content: '';
    margin-top: auto;
  }

  body.chat-expanded .consult-actions {
    right: max(16px, calc((100vw - var(--panel-w) - 900px) / 2 + 16px));
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-actions {
    right: clamp(20px, 4vw, 72px);
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .consult-identity {
    left: clamp(24px, 4vw, 58px);
  }

  body.chat-expanded:not([data-chat-mode="concise"]) .message.bot .message-bubble,
  body.chat-expanded:not([data-chat-mode="concise"]) .chat-mode-bar,
  body.chat-expanded:not([data-chat-mode="concise"]) .chat-tool-btn,
  body.chat-expanded:not([data-chat-mode="concise"]) .chat-input,
  body.chat-expanded:not([data-chat-mode="concise"]) .consult-action-btn {
    background-color: rgba(27, 25, 23, 0.68);
    border-color: rgba(246, 242, 231, 0.25);
  }

  /* Plain-text mode uses the same stable two-column skeleton. Its compact
     identity becomes the left rail, so switching modes never leaves a blank
     portrait column behind. */
  body.chat-expanded[data-chat-mode="concise"] .chat-compact-header {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 40px;
    border: 0;
    border-right: 1px solid rgba(246, 242, 231, 0.16);
    background:
      radial-gradient(circle at 50% 36%, rgba(201, 164, 94, 0.16), transparent 38%),
      linear-gradient(145deg, #48423a, #201e1b);
    text-align: center;
  }

  body.chat-expanded[data-chat-mode="concise"] .chat-compact-header img {
    width: 132px;
    height: 132px;
    border: 2px solid rgba(246, 242, 231, 0.36);
    box-shadow: 0 18px 48px rgba(18, 16, 14, 0.3);
  }

  body.chat-expanded[data-chat-mode="concise"] .chat-compact-header strong {
    color: #f6f2e7;
    font-size: 18px;
  }

  body.chat-expanded[data-chat-mode="concise"] .chat-compact-header span {
    margin-top: 5px;
    color: rgba(236, 229, 209, 0.76);
    font-size: 12.5px;
  }

  body.chat-expanded[data-chat-mode="concise"] .chat-container {
    background: var(--paper);
  }
}

/* No transition on grid-template-columns. The collapsed and expanded templates
   have different track counts, so there is nothing to interpolate between —
   and asking for one made the browser hold the old tracks indefinitely, which
   left the panel at its narrow width with the workspace already gone. */
.consult-expand-btn {
  transition: background 0.15s ease;
}

/* --------------------------------------------------------------------------
   15. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  /* Expanding is a desktop affordance: on a phone the panel already fills the
     screen, so the control would collapse the tabs for no gain. */
  .consult-expand-btn {
    display: none;
  }

  body.chat-expanded .studio-body {
    grid-template-columns: 1fr;
  }

  body.chat-expanded .studio-workspace {
    display: block;
  }

  /* The band stacks, and the offer keeps its colour so it still reads as the
     invitation rather than becoming a grey block. */
  .about-band {
    grid-template-columns: 1fr;
  }

  .about-band-body {
    padding: 24px 22px;
  }

  .about-band-offer {
    padding: 22px;
  }

  .featured-section .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-columns {
    grid-template-columns: 1fr;
  }

  .intro-aside {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Once the two columns stack, six school cards push About us more than a
     screen down. Who we are should not need scrolling to find, so on a narrow
     screen it comes first. */
  .intro-aside.intro-about {
    order: -1;
    grid-template-columns: 1fr;
  }

  .intro-aside-note {
    grid-column: 1 / -1;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .test-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .studio {
    height: auto;
    min-height: 100svh;
  }

  .studio-topbar {
    flex-wrap: wrap;
    height: auto;
    gap: 8px 16px;
    padding: 12px 16px;
  }

  .studio-nav {
    order: 3;
    width: 100%;
    height: 44px;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .studio-nav::-webkit-scrollbar {
    display: none;
  }

  .studio-nav .advisor-nav-btn::after {
    bottom: 0;
  }

  .advisor-nav-btn {
    padding: 0 14px;
    white-space: nowrap;
  }

  .topbar-tools {
    margin-left: auto;
  }

  .studio-body {
    display: block;
  }

  .studio-workspace {
    border-right: 0;
    min-height: 70svh;
  }

  .advisor-view {
    height: auto;
    overflow: visible;
  }

  .view-header {
    padding: 24px 20px 16px;
  }

  .view-body {
    padding: 18px 20px 28px;
    overflow: visible;
  }

  .intro-services {
    grid-template-columns: 1fr;
  }

  .intro-service {
    border-right: 0;
    margin-right: 0;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
  }

  .intro-aside {
    grid-template-columns: 1fr;
  }

  .exam-result,
  .test-layout,
  .exam-intro-grid {
    grid-template-columns: 1fr;
  }

  .exam-stat {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .exam-age-band-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .test-summary {
    position: static;
    order: -1;
  }

  .drawer-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawer-stat {
    padding-left: 20px;
  }

  /* consult panel = floating bubble that opens a full sheet */
  .consult-panel {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 6000;
    width: min(420px, calc(100vw - 28px));
    height: min(680px, calc(100svh - 60px));
    border: 1px solid rgba(7, 20, 15, 0.4);
    box-shadow: 0 24px 70px rgba(33, 31, 24, 0.45);
  }

  .consult-panel.collapsed {
    width: 64px;
    height: 64px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .consult-panel.collapsed .consult-card {
    display: none;
  }

  .avatar-bubble-toggle {
    display: none;
    position: absolute;
    inset: 0;
    overflow: hidden;
    border: 2px solid var(--card);
    border-radius: 50%;
    background: var(--green-deep);
    box-shadow: 0 14px 40px rgba(33, 31, 24, 0.4);
  }

  .consult-panel.collapsed .avatar-bubble-toggle {
    display: block;
  }

  .avatar-bubble-toggle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
  }

  .avatar-bubble-label {
    position: absolute;
    right: -2px;
    bottom: -2px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 2px solid var(--card);
    border-radius: 50%;
    background: var(--brass);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
  }

  #avatarCloseBtn {
    display: grid;
  }

  .chat-input {
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* On a phone the voice buttons vanished the instant the box had text, so a
     user who started typing then reached for the mic found nothing there and
     reported "no voice button". Keep the mic reachable while typing; the
     heavier realtime button can still yield the space. */
  .chat-input.has-text .mic-btn {
    display: grid;
  }

  .profile-drawer {
    width: 100vw;
  }
}

/* iOS Safari zooms the whole page when a focused form control renders below
   16px. Suggested-question chips focus the composer too, so the same mobile
   guard covers both direct typing and the preset-question path. */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .consult-scene,
  .status-dot,
  .avatar-eq span {
    animation: none !important;
    transition: none !important;
  }
}

/* Markdown tables in adviser replies. A family asking to compare schools side
   by side was being shown raw pipes — the model's Markdown was correct, the
   renderer simply had no table branch. The wrapper scrolls on its own so a wide
   comparison never pushes the chat column sideways on a phone. */
.md-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid rgba(246, 242, 231, 0.16);
  border-radius: 8px;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  /* Tracks the reader's chosen text size. Fixed at 12.5px it grew relatively
     smaller each time someone enlarged the conversation — the opposite of what
     they were asking for. */
  font-size: calc(var(--chat-message-font-size, 13.5px) - 1px);
  line-height: 1.45;
}

.md-table th,
.md-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(246, 242, 231, 0.1);
  vertical-align: top;
}

.md-table thead th {
  position: sticky;
  top: 0;
  background: rgba(246, 242, 231, 0.1);
  font-weight: 700;
  white-space: nowrap;
}

.md-table tbody tr:last-child td {
  border-bottom: 0;
}

.md-table tbody tr:nth-child(even) {
  background: rgba(246, 242, 231, 0.04);
}

/* The home-page disclaimer keeps the short form and links onward. */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.85;
}

.link-button:hover {
  opacity: 1;
}

/* About us now occupies the column the counters had, so it sits beside the
   featured schools rather than below the fold. */
.intro-aside.intro-about {
  margin-top: 0;
  align-self: start;
}

/* The tab holds the whole document; these point at the two halves as pages a
   form or a footer can link to. */
.legal-permalinks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: 13px;
}

.legal-permalinks a {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}

.legal-permalinks a:hover {
  text-decoration: underline;
}

.analytics-preferences-link,
.legal-analytics-preferences {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 600;
  padding: 0;
  text-decoration: none;
  cursor: pointer;
}

.analytics-preferences-link:hover,
.legal-analytics-preferences:hover {
  text-decoration: underline;
}

/* Optional analytics stays separate from the blocking service-terms modal.
   Its lower z-index means a first-time visitor reads those terms first. */
.analytics-consent {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 9000;
  width: min(880px, calc(100vw - 40px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(246, 242, 231, 0.3);
  border-radius: 16px;
  background: var(--green-deep);
  color: var(--card);
  box-shadow: 0 18px 50px rgba(8, 28, 24, 0.34);
}

.analytics-consent[hidden] {
  display: none;
}

.analytics-consent-copy {
  max-width: 620px;
}

.analytics-consent-copy strong {
  display: block;
  margin-bottom: 5px;
  font-size: 15px;
}

.analytics-consent-copy p {
  margin: 0 0 6px;
  color: var(--card);
  font-size: 13px;
  line-height: 1.55;
}

.analytics-consent-copy a {
  color: var(--card);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.analytics-consent-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
}

.analytics-consent-actions button {
  min-height: 42px;
  border: 1px solid var(--card);
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.analytics-consent-actions [data-analytics-choice="denied"] {
  background: transparent;
  color: var(--card);
}

.analytics-consent-actions [data-analytics-choice="granted"] {
  background: var(--card);
  color: var(--green-deep);
}

@media (max-width: 720px) {
  .analytics-consent {
    bottom: 12px;
    width: calc(100vw - 24px);
    align-items: stretch;
    flex-direction: column;
    gap: 13px;
    padding: 16px;
  }

  .analytics-consent-actions button {
    flex: 1;
  }
}

/* The report preview on the placement-check result screen. It shows the
   family's own result rather than a mock-up, so it has to read as a document
   extract rather than as another dashboard panel. */
.report-preview {
    margin: 18px 0 4px;
    padding: 16px;
    border: 1px solid var(--line, rgba(0, 0, 0, 0.12));
    border-radius: 10px;
    background: var(--paper, #faf8f3);
}

.report-preview h4 {
    margin: 0 0 4px;
    font-size: 1.02rem;
}

.report-preview-note {
    margin: 0 0 12px;
    font-size: 0.85rem;
    opacity: 0.75;
}

.report-preview-subhead {
    margin: 14px 0 4px;
    font-size: 0.88rem;
    font-weight: 600;
}

.report-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.report-preview-table th,
.report-preview-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--line, rgba(0, 0, 0, 0.08));
}

.report-preview-table th {
    font-weight: 600;
    opacity: 0.7;
}

.report-preview-table tr:last-child td {
    border-bottom: none;
}

.report-preview-provenance {
    margin: 14px 0 0;
    font-size: 0.78rem;
    line-height: 1.5;
    opacity: 0.72;
}

@media (max-width: 640px) {
    .report-preview {
        padding: 12px;
    }

    .report-preview-table {
        font-size: 0.8rem;
    }

    .report-preview-table th,
    .report-preview-table td {
        padding: 5px 6px;
    }
}
