:root {
  --header-h: 76px; /* fallback; JS measures the real topbar height and overrides this */
  --navy: #1C2B3A;
  --navy-deep: #131F2B;
  --navy-mid: #2A3D50;
  --hm-blue: #3C4D6B;       /* sampled from the HM mountain mark */
  --hm-blue-light: #8A94A6; /* lighter tint, for use on navy backgrounds */
  --hm-blue-tint: #EEF1F5;  /* light tint for chip/active backgrounds */
  --hm-charcoal: #393A39;   /* sampled from the HM wordmark */
  --orange: #F39223;        /* header strip only — not used elsewhere */
  --paper: #F6F7F9;
  --paper-raised: #FFFFFF;
  --line: #E1E5EB;
  --line-strong: #C9D0DA;
  --ink: #1C2B3A;
  --ink-soft: #5A6B7B;
  --ink-faint: #8392A4;
  --no-response: #9AA7B6;
  --radius: 10px;
  --font-display: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Montserrat', system-ui, sans-serif;
  --font-mono: 'Montserrat', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--hm-blue); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--navy);
  color: #fff;
  padding: 14px 28px;
  border-bottom: 3px solid var(--orange);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow 0.25s ease;
}
.topbar.is-scrolled {
  box-shadow: 0 8px 20px rgba(8,14,20,0.3);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.hm-logo {
  height: 36px;
  width: 102px;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #fff;
  border-radius: 6px;
  padding: 4px 7px;
  box-sizing: content-box;
}

.hm-logo--fallback {
  width: 36px;
  height: 36px;
  max-width: none;
  padding: 0;
  box-sizing: border-box;
  border-radius: 6px;
  background: var(--orange);
  color: var(--navy-deep);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar__lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.topbar__firm { font-weight: 600; letter-spacing: 0.02em; }
.topbar__divider {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.3);
  display: inline-block;
}
.topbar__client { color: rgba(255,255,255,0.9); font-weight: 600; letter-spacing: 0.02em; }
.lsv-logo {
  height: 32px;
  width: 49px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.topbar__title {
  flex: 1;
  min-width: 240px;
}
.topbar__title h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}
.topbar__title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.topbar__search { flex-shrink: 0; position: relative; }
#searchInput {
  width: 260px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
}
#searchInput::placeholder { color: rgba(255,255,255,0.5); }
#searchInput:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  background: rgba(255,255,255,0.14);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(19,31,43,0.25);
  z-index: 30;
  padding: 6px;
}
.search-results__empty {
  padding: 16px;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}
.search-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 9px 10px;
  cursor: pointer;
  margin-bottom: 2px;
}
.search-result:hover { background: var(--paper); }
.search-result__row1 {
  display: flex;
  align-items: center;
  gap: 7px;
}
.search-result__logo, .search-result__logo-fallback {
  width: 40px; height: 16px; object-fit: contain; object-position: left center; flex-shrink: 0;
}
.search-result__logo-fallback {
  background: var(--navy-mid);
  color: #fff;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.search-result__type-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--hm-blue);
  background: var(--hm-blue-tint);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.search-result__loc {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-weight: 600;
}
.search-result__snippet {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
}
.search-result__snippet mark {
  background: var(--hm-blue-tint);
  color: var(--hm-blue);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* ---------- Body layout ---------- */
.body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--navy-deep);
  color: #fff;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__watermark {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 320px;
  object-fit: contain;
  opacity: 0.05;
  filter: brightness(0) invert(1);
  pointer-events: none;
  z-index: 0;
}

.sidebar__scroll { padding: 10px 0 30px; overflow-y: auto; flex: 1; position: relative; z-index: 1; }

.summary-nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 14px 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.summary-nav-item__icon { font-size: 11px; color: var(--hm-blue-light); }
.summary-nav-item:hover { background: rgba(255,255,255,0.05); }
.summary-nav-item.active {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--hm-blue-light);
  color: #fff;
}

.theme-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
  text-align: left;
}
.theme-group__header:hover { background: rgba(255,255,255,0.05); }
.theme-group__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-weight: 500;
}
.theme-group__caret {
  transition: transform 0.15s ease;
  color: rgba(255,255,255,0.4);
  margin-left: 8px;
}
.theme-group.open .theme-group__caret { transform: rotate(90deg); }

.theme-group__questions {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  display: none;
}
.theme-group.open .theme-group__questions { display: block; }

.q-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: rgba(255,255,255,0.65);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 18px 8px 22px;
  cursor: pointer;
  line-height: 1.35;
}
.q-nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.q-nav-item .q-nav-item__no {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--hm-blue-light);
  margin-right: 6px;
}
.q-nav-item {
  position: relative;
}
.q-nav-item.active {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--hm-blue-light);
  color: #fff;
}
.lsv-dot {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hm-blue-light);
}

.mobile-nav { display: none; }

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 32px 40px 60px;
  min-width: 0;
  max-width: 1280px;
}
@keyframes contentEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main.content-enter {
  animation: contentEnter 0.28s ease;
}

.question-header__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.qno-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--navy);
  color: #fff;
  border-radius: 5px;
  padding: 3px 8px;
}
.lsv-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--hm-blue);
  background: var(--hm-blue-tint);
  border-radius: 20px;
  padding: 3px 10px;
}
.copy-link-btn {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 3px 11px;
  cursor: pointer;
}
.copy-link-btn:hover { border-color: var(--hm-blue); color: var(--hm-blue); }
.copy-link-btn.copied { border-color: var(--hm-blue); color: var(--hm-blue); background: var(--hm-blue-tint); }

.question-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.6;
  letter-spacing: 0;
  margin: 0 0 22px;
  max-width: 900px;
  color: var(--hm-blue);
}

/* Admin toggle chips */
.admin-toggles-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.admin-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.reset-shortlist-btn {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--hm-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: underline;
  text-decoration-color: transparent;
}
.reset-shortlist-btn:hover { text-decoration-color: var(--hm-blue); }
.shortlist-hint {
  font-size: 11px;
  color: var(--ink-faint);
  margin: 0 0 20px;
}
.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
}
.admin-toggle img {
  height: 24px; width: 74px; object-fit: contain; object-position: center; border-radius: 0;
}
.admin-toggle .badge-fallback {
  width: 24px; height: 24px; border-radius: 4px; object-fit: contain;
  font-size: 10px;
}
.admin-toggle .badge-fallback {
  background: var(--navy-mid);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.admin-toggle.off { opacity: 0.4; }
.admin-toggle.off .badge-fallback { background: var(--no-response); }
.admin-toggle .no-data-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--no-response);
  margin-left: 2px;
}
.admin-toggle.active {
  border-color: var(--hm-blue);
  background: var(--hm-blue-tint);
  color: var(--navy);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.toolbar__count {
  font-size: 12px;
  color: var(--ink-faint);
}
.toolbar__btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hm-blue);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
}
.toolbar__btn:hover { border-color: var(--hm-blue); }

/* Response grid */
.response-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.response-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}
.response-card.flash {
  border-color: var(--hm-blue);
  box-shadow: 0 0 0 3px var(--hm-blue-tint);
}
.response-card.no-response {
  background: #FBFBFC;
  border-style: dashed;
}

.response-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.response-card__logo {
  height: 24px; width: 88px; object-fit: contain; object-position: left center; flex-shrink: 0;
}
.response-card__logo-fallback {
  width: 26px; height: 26px; border-radius: 5px; flex-shrink: 0;
  background: var(--navy-mid);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.response-card__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
}
.response-card__body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  max-height: 220px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black calc(100% - 28px), transparent 100%);
}
.response-card.expanded .response-card__body {
  max-height: none;
  mask-image: none;
}
.response-card__body mark {
  background: var(--hm-blue-tint);
  color: var(--hm-blue);
  border-radius: 2px;
  font-weight: 600;
}
.response-card__body.no-response-text {
  color: var(--no-response);
  font-style: italic;
}
.response-card__toggle {
  align-self: flex-start;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--hm-blue);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* Verdict / Independent view panel — signature element */
.verdict {
  display: flex;
  gap: 18px;
  background: var(--navy);
  border-radius: 14px;
  padding: 24px 26px;
  position: relative;
  overflow: hidden;
}
.verdict::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 220px; height: 220px;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.06), transparent 70%);
  pointer-events: none;
}
.verdict__mark {
  flex-shrink: 0;
  width: 92px; height: 40px;
  background: #fff;
  border-radius: 8px;
  padding: 4px 7px;
  display: flex; align-items: center; justify-content: center;
}
.verdict__mark img {
  width: 100%; height: 100%; object-fit: contain; object-position: center;
}
.verdict__body { color: #fff; min-width: 0; flex: 1; }
.verdict__body h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin: 2px 0 14px;
  color: #fff;
}
.verdict__block {
  font-size: 13.5px;
  line-height: 1.65;
  color: rgba(255,255,255,0.85);
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.verdict__block:last-child { margin-bottom: 0; }
.verdict__block .verdict__label {
  display: block;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--hm-blue-light);
  margin-bottom: 5px;
}
.verdict__block.empty { display: none; }

/* ---------- Summary view ---------- */
.summary-header { max-width: 760px; margin-bottom: 28px; }
#summaryTitle {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 8px 0 10px;
}
.summary-intro {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.summary-caveat {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #8A5A1C;
  background: #FBF0E0;
  border: 1px solid #EBD4AC;
  border-radius: 7px;
  padding: 7px 12px;
  margin: 0 0 14px;
}
.summary-stats {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.fact-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.fact-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.fact-card__logo {
  height: 26px; width: 100px; object-fit: contain; object-position: left center; flex-shrink: 0;
}
.fact-card__logo-fallback {
  width: 26px; height: 26px; border-radius: 5px; flex-shrink: 0;
  background: var(--navy-mid);
  color: #fff;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.fact-card__name { font-weight: 700; font-size: 14px; color: var(--navy); }

.fact-row { margin-bottom: 13px; }
.fact-row:last-child { margin-bottom: 0; }
.fact-row--missing .fact-value { color: var(--no-response); font-style: italic; }
.fact-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.fact-value { font-size: 13px; line-height: 1.5; color: var(--ink); }
.fact-note { font-style: italic; color: var(--ink-faint); font-weight: 500; }
.fact-footnote {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 3px;
  line-height: 1.4;
}
.fact-source {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  color: var(--hm-blue);
  background: var(--hm-blue-tint);
  border: none;
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.fact-source:hover { background: var(--hm-blue); color: #fff; }
.fact-no-response { color: var(--no-response); font-style: italic; font-size: 13px; margin: 0; }

/* Footer */
.app-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--paper-raised);
}

/* Focus visibility */
button:focus-visible, [tabindex]:focus-visible, input:focus-visible {
  outline: 2px solid var(--hm-blue);
  outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    background: var(--navy-deep);
    position: sticky;
    top: var(--header-h);
    z-index: 40;
  }
  .mobile-nav select {
    flex: 1;
    padding: 9px 10px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.2);
    background: var(--navy-mid);
    color: #fff;
    font-size: 13px;
    font-family: var(--font-body);
  }
  .mobile-summary-btn {
    flex-shrink: 0;
    padding: 9px 12px;
    border-radius: 7px;
    border: 1px solid var(--hm-blue-light);
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
  }
  .main { padding: 24px 18px 48px; }
  .topbar { padding: 12px 16px; gap: 12px; }
  #searchInput { width: 100%; }
  .search-results { width: 100%; left: 0; right: 0; }
  .topbar__title { order: 3; width: 100%; }
  .question-header h2 { font-size: 21px; }
  .admin-toggles-row { flex-direction: column; align-items: stretch; gap: 4px; }
}

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