/* themortgagellm — dark gray on warm cream, Times New Roman */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: #F7F4EB;
  color: #1a1a1a;
  font-family: 'Times New Roman', Times, serif;
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
}

body {
  padding: 48px 24px 80px;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

/* ---------- Hamburger menu (shared across all pages) ---------- */

.site-nav {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Sign in / signed-in area to the LEFT of the hamburger. Tucked into the
 * existing site-nav flex row so it lives in the same visual band. */
.auth-area {
  display: flex;
  align-items: center;
  gap: 10px;
  order: -1;
  margin-right: 4px;
}
.auth-signin {
  font-size: 13px;
  color: #1a1a1a;
  background: none;
  border: 1px solid #c8c2b0;
  border-radius: 3px;
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.auth-signin:hover {
  background: #efeadb;
}
.auth-signed-in {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The HTML `hidden` attribute is supposed to set display:none, but the
 * `.auth-signed-in { display: flex }` rule above has higher specificity and
 * wins by default — making both Sign in AND the signed-in block render at
 * the same time. Re-assert `hidden` here so they're properly mutex. */
.auth-area [hidden] { display: none !important; }
.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #d0cab8;
  display: block;
}
.user-email {
  font-size: 12px;
  opacity: 0.75;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-signout {
  font-size: 12px;
  opacity: 0.6;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  color: #1a1a1a;
}
.auth-signout:hover { opacity: 1; }

/* Sign-in picker: small popover below the "Sign in" button with one row
 * per enabled provider (Google, Microsoft). Shown only when more than one
 * provider is configured. */
.signin-picker {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #F7F4EB;
  border: 1px solid #c8c2b0;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  min-width: 260px;
  z-index: 200;
  padding: 4px;
}
.signin-picker.hidden { display: none; }

/* Value-prop header above the provider buttons inside the picker dropdown.
 * Anchors the dropdown with a clear sentence of why the user is about to
 * sign in. */
.signin-picker-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid #e3dcc6;
  margin-bottom: 4px;
}
.signin-picker-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}
.signin-picker-sub {
  font-size: 11.5px;
  color: #6b6a62;
  line-height: 1.4;
}
.signin-picker-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: #1a1a1a;
  background: none;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.01em;
}
.signin-picker-option:hover {
  background: #efeadb;
}
.signin-picker-option svg {
  flex-shrink: 0;
}
/* The auth-area needs `position: relative` so the picker positions
 * relative to it instead of jumping to the document root. */
.auth-area {
  position: relative;
}

.hamburger {
  background: transparent;
  border: none;
  width: 34px;
  height: 34px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: #1a1a1a;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.hamburger:hover span { opacity: 1; }

.hamburger-menu {
  position: absolute;
  top: 38px;
  right: 0;
  min-width: 220px;
  background: #efeadb;
  border: 1px solid #c8c2b0;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}
.hamburger-menu a {
  color: #1a1a1a;
  text-decoration: none;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 15px;
}
.hamburger-menu a:hover {
  background: #e3dcc6;
}

.brand-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.brand-link:hover {
  text-decoration: none;
}
.brand-logo {
  height: 56px;
  width: auto;
  display: block;
  flex: 0 0 auto;
}

/* ---------- About page ---------- */

.about-page {
  max-width: 680px;
  margin: 20px auto 60px;
  padding: 0 8px;
}

.about-headline {
  font-size: 28px;
  font-weight: normal;
  margin-bottom: 28px;
  border-bottom: 1px solid #b8b2a0;
  padding-bottom: 14px;
}

.about-lead {
  font-size: 22px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.about-body {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 20px;
  opacity: 0.85;
}

/* ---------- Legal pages (Terms, Privacy) ---------- */
/* Denser than .about-page since these documents are long and reference-
 * style. Same editorial cream feel as the rest of the site. */

.legal-page {
  max-width: 760px;
  margin: 20px auto 60px;
  padding: 0 8px;
}

.legal-headline {
  font-size: 28px;
  font-weight: normal;
  margin-bottom: 4px;
}

.legal-effective {
  font-size: 13px;
  font-style: italic;
  opacity: 0.6;
  margin-bottom: 28px;
  border-bottom: 1px solid #b8b2a0;
  padding-bottom: 14px;
}

.legal-h3 {
  font-size: 17px;
  font-weight: normal;
  margin-top: 32px;
  margin-bottom: 10px;
  border-bottom: 1px solid #d0cab8;
  padding-bottom: 4px;
}

.legal-h4 {
  font-size: 14px;
  font-weight: normal;
  font-style: italic;
  margin-top: 18px;
  margin-bottom: 6px;
  opacity: 0.75;
}

.legal-body {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 14px;
  opacity: 0.88;
}

.legal-list {
  font-size: 15px;
  line-height: 1.65;
  margin: 0 0 14px 22px;
  padding: 0;
  opacity: 0.88;
}
.legal-list li {
  margin-bottom: 6px;
}

.legal-footnote {
  font-size: 13px;
  font-style: italic;
  opacity: 0.6;
  margin-top: 40px;
  border-top: 1px solid #d0cab8;
  padding-top: 14px;
}

/* ---------- Insights (long-form research posts) ---------- */

.insights-hub,
.insight-post {
  max-width: 820px;
  margin: 20px auto 60px;
  padding: 0 8px;
}

.insight-card {
  background: #efeadb;
  border: 1px solid #d0cab8;
  padding: 20px 24px;
  margin-bottom: 18px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

/* Thumbnail block on the index card — fixed-width on desktop, full-width on
 * mobile (stacked layout via the @media block below). Sized to roughly the
 * chart's aspect ratio (the source PNG is ~1758×1205, so width-driven height
 * lands around 165–180px at the 240px width below). */
.insight-thumb {
  flex: 0 0 240px;
  display: block;
  border: 1px solid #d0cab8;
  background: #FBF8EE;
  overflow: hidden;
  line-height: 0;
}
.insight-thumb img {
  display: block;
  width: 100%;
  height: auto;
}
.insight-thumb:hover {
  border-color: #8c887e;
}

/* Card text column — flex:1 so it absorbs the remaining row width, plus
 * min-width:0 so long words / inline links don't push the column past the
 * thumb's flex-basis on narrow screens. */
.insight-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 640px) {
  .insight-card {
    flex-direction: column;
  }
  .insight-thumb {
    flex: 0 0 auto;
    width: 100%;
  }
}

.insight-date {
  font-size: 12px;
  font-style: italic;
  opacity: 0.6;
  letter-spacing: 0.04em;
  margin: 0 0 6px 0;
}

.insight-title {
  font-size: 18px;
  font-weight: normal;
  margin: 0 0 10px 0;
  line-height: 1.35;
}
.insight-title a {
  color: #1a1a1a;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.insight-title a:hover {
  border-bottom-color: #1a1a1a;
}

.insight-summary {
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 12px 0;
  opacity: 0.85;
}

.insight-body {
  font-size: 16px;
  line-height: 1.7;
}
.insight-body h2 {
  font-size: 20px;
  font-weight: normal;
  margin-top: 36px;
  margin-bottom: 12px;
  border-bottom: 1px solid #d0cab8;
  padding-bottom: 6px;
}
.insight-body h3 {
  font-size: 17px;
  font-weight: normal;
  font-style: italic;
  margin-top: 24px;
  margin-bottom: 8px;
}
.insight-body p {
  margin-bottom: 18px;
  opacity: 0.92;
}
.insight-body ul, .insight-body ol {
  margin: 0 0 18px 22px;
}
.insight-body li { margin: 4px 0; }
.insight-body a {
  color: #1a1a1a;
  text-decoration: underline;
  text-decoration-style: dotted;
}
.insight-body code {
  background: #ece6d3;
  border: 1px solid #d0cab8;
  padding: 1px 5px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
}
.insight-body hr {
  border: 0;
  border-top: 1px solid #d0cab8;
  margin: 36px 0;
}

/* Blockquote rendered as a "callout card" so quick-takeaways, executive
 * summaries, and editor's notes visually separate from the body prose.
 * Markdown blockquotes (lines starting with ">") in article bodies render
 * here. Distinct background + left accent rail + tighter typography so the
 * card reads as a separate object, not just an indent. Bullets inside the
 * blockquote stay normal-bulleted. */
.insight-body blockquote {
  margin: 22px 0;
  padding: 16px 20px;
  background: #f3eedf;
  border-left: 4px solid #2a8a85;
  border-radius: 6px;
  color: #1a1a1a;
}
.insight-body blockquote > p {
  margin: 0 0 12px;
  opacity: 1;
}
.insight-body blockquote > p:first-child {
  font-size: 15px;
  font-weight: 600;
}
.insight-body blockquote > p:last-child {
  margin-bottom: 0;
}
.insight-body blockquote ul,
.insight-body blockquote ol {
  margin: 8px 0 0 22px;
}
.insight-body blockquote li {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.55;
}
.insight-body blockquote a {
  color: #1a1a1a;
}

/* Methodology / footnote — last italicized paragraph of the body */
.insight-body p:last-child em,
.insight-body em:last-child {
  font-size: 13px;
  opacity: 0.7;
  line-height: 1.6;
}

/* Inline interactive chart iframe — embedded via insights.py */
.insight-chart {
  margin: 28px 0;
  padding: 0;
}
.insight-chart iframe {
  width: 100%;
  height: 860px;
  border: 1px solid #d0cab8;
  background: #FBF8EE;
  display: block;
}

@media (max-width: 900px) {
  .insight-chart iframe { height: 640px; }
}
@media (max-width: 640px) {
  .insight-chart iframe { height: 520px; }
}

/* ---------- User Guide page ---------- */

.userguide-container {
  max-width: 1080px;
}

.userguide-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 36px;
  margin-top: 16px;
  align-items: start;
}

.userguide-sidebar {
  position: sticky;
  top: 24px;
  border-right: 1px solid #c8c2b0;
  padding-right: 18px;
}

.ug-section {
  margin-bottom: 22px;
}

.ug-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
.ug-section-title::after {
  content: "\25B8";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  transition: transform 0.15s ease;
  font-size: 10px;
  opacity: 0.8;
}
.ug-section-title:hover {
  opacity: 0.85;
}
.ug-section.collapsed .ug-section-title {
  margin-bottom: 0;
}
.ug-section.collapsed .ug-section-title::after {
  transform: translateY(-50%) rotate(0deg);
}
.ug-section.collapsed .ug-list {
  display: none;
}

.ug-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ug-item {
  font-size: 14px;
  padding: 4px 0;
  line-height: 1.4;
}

.ug-item a {
  color: #1a1a1a;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.ug-item a:hover {
  border-bottom: 1px dotted #1a1a1a;
}

.ug-item.disabled {
  color: #a8a39a;
  cursor: default;
}

/* Sub-headings inside a sidebar section (e.g., "Origination" / "Performance"
 * groupings under "Scoring Models"). Not links — just visual grouping. */
.ug-subhead {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  padding: 8px 0 2px 0;
  list-style: none;
  font-style: italic;
}
.ug-subhead:first-child {
  padding-top: 0;
}

.userguide-content {
  max-width: 700px;
}

.ug-h {
  font-weight: normal;
  margin-top: 24px;
}

h2.ug-h { font-size: 26px; margin-top: 0; margin-bottom: 12px; }
h3.ug-h { font-size: 18px; margin-top: 32px; margin-bottom: 6px; opacity: 0.85; }

.ug-lead {
  font-size: 17px;
  line-height: 1.65;
  margin-bottom: 28px;
}

.ug-meta {
  font-size: 13px;
  font-style: italic;
  opacity: 0.6;
  margin-bottom: 18px;
}

.ug-card {
  background: #efeadb;
  border: 1px solid #d0cab8;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.ug-card h4 {
  font-size: 15px;
  font-weight: normal;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #d0cab8;
  padding-bottom: 8px;
}

.ug-card-date {
  font-size: 12px;
  font-style: italic;
  opacity: 0.55;
  margin: -4px 0 10px 0;
  letter-spacing: 0.04em;
}

.ug-card p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
  opacity: 0.85;
}

/* In-content lists inside article cards.
 * The .ug-list class is shared with the sidebar where `list-style: none`
 * (set in the base rule) is correct, so we re-add disc bullets and proper
 * padding only inside .ug-card. We also pin the <li> font-size and
 * line-height to match the surrounding <p> so the content reads as one
 * typographic stream rather than mixing browser-default 16px <li> text
 * with the 14px paragraph text. */
.ug-card .ug-list {
  list-style: disc;
  padding-left: 22px;
  margin: 8px 0 12px;
}
.ug-card .ug-list li {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 6px;
  opacity: 0.85;
}
.ug-card .ug-list li:last-child {
  margin-bottom: 0;
}

.ug-link {
  color: #1a1a1a;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.ug-code {
  background: #ece6d3;
  border: 1px solid #d0cab8;
  padding: 10px 12px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 8px 0;
}

/* ----- Use-case landing + prompt response pages ------------------------- */
.ug-prompt-text {
  font-style: italic;
  font-size: 14px;
  color: #2a2a2a;
  margin-bottom: 6px;
}
.ug-prompt-preview {
  font-size: 13px;
  opacity: 0.78;
  line-height: 1.55;
}
.ug-prompt-block {
  background: #efeadb;
  border-left: 3px solid #b8a86b;
  padding: 14px 18px;
  margin: 12px 0 28px 0;
}
.ug-prompt-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 6px;
}
.ug-prompt-quote {
  font-size: 16px;
  font-style: italic;
  line-height: 1.5;
  margin: 0 0 10px 0;
}
.ug-response {
  margin: 24px 0;
}
.ug-response p,
.ug-response ul,
.ug-response ol {
  font-size: 14px;
  line-height: 1.65;
}
.ug-response ul, .ug-response ol { padding-left: 22px; margin: 10px 0; }
.ug-response li { margin: 4px 0; }
.ug-response code {
  background: #ece6d3;
  border: 1px solid #d0cab8;
  padding: 1px 5px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
}
.ug-data-table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  width: 100%;
}
.ug-data-table th, .ug-data-table td {
  border: 1px solid #d0cab8;
  padding: 6px 10px;
  text-align: left;
}
.ug-data-table th {
  background: #ece6d3;
  font-weight: normal;
  letter-spacing: 0.02em;
}
.ug-followups {
  background: #f4f0e3;
  border: 1px solid #d8d2bd;
  padding: 14px 20px;
  margin-top: 28px;
}
.ug-followups h3 { margin-top: 0; }
.ug-followups .ug-list { padding-left: 18px; list-style: disc; }
.ug-followups .ug-item { font-size: 14px; padding: 5px 0; }

header h1 {
  font-size: 32px;
  font-weight: normal;
  letter-spacing: -0.01em;
}

header h1 .tm {
  font-size: 0.4em;
  vertical-align: super;
  margin-left: 3px;
  opacity: 0.7;
  letter-spacing: 0;
}

header .subtitle {
  font-style: italic;
  opacity: 0.65;
  margin-top: 4px;
}

/* ---------- Prompt input (rounded-rect notebook with send-button
 *            overlapping the right edge) ---------- */

.prompt-area {
  margin: 48px auto 8px;
  max-width: 880px;
  width: 100%;
  /* 36px side padding leaves room for the overhanging send button */
  padding: 0 36px;
  position: relative;
  box-sizing: border-box;
}

.prompt {
  position: relative;
  background: #FBF8EE;
  border: 1px solid #d0cab8;
  border-radius: 30px;
  padding: 22px 78px 22px 38px;       /* right padding leaves room for send button overlap */
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prompt:focus-within {
  border-color: #8c887e;
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.08);
}

#question {
  width: 100%;
  background: transparent;
  color: #1a1a1a;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.55;
  resize: none;
  min-height: 56px;
  max-height: 260px;
  padding: 0;
  overflow-y: auto;
  box-sizing: border-box;
  display: block;
}

#question::placeholder {
  color: #9e9a8e;
  font-style: italic;
}

/* Send button — solid dark circle overlapping the right edge of the input,
 * vertically centered. The arrow points right (chevron) per the OE pattern. */
#submit-btn {
  position: absolute;
  top: 50%;
  right: -24px;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background: #1a1a1a;
  color: #F7F4EB;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
  transition: background 0.15s ease, transform 0.05s ease;
  padding: 0;
  z-index: 2;
}

#submit-btn:hover {
  background: #2a2a2a;
}

#submit-btn:active {
  transform: translateY(-50%) translateY(1px);
}

#submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#submit-btn svg {
  display: block;
}

.hint {
  font-size: 12px;
  opacity: 0.55;
  font-style: italic;
  margin-top: 10px;
  text-align: center;
}

.hint kbd {
  border: 1px solid #8c887e;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 13px;
  font-style: normal;
}

.hint-arrow {
  font-style: normal;
  display: inline-block;
  border: 1px solid #8c887e;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  font-size: 13px;
  vertical-align: -3px;
}

.hint-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  font-style: italic;
}

.hint-link:hover {
  opacity: 0.85;
}

/* ---------- Quick-start chips (OpenEvidence-style discovery row) ---------
 * Sits below the prompt rectangle's .hint line. Each chip toggles a panel
 * of 2-3 suggested prompts; clicking a suggestion auto-fills the textarea
 * and runs it (wired in app.js). The expansion panel is a sibling sitting
 * directly below the chip row so its visual anchor reads cleanly. */

.quick-starts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #efeadb;
  border: 1px solid #d0cab8;
  border-radius: 999px;
  color: #1a1a1a;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.quick-chip:hover {
  background: #e3dcc6;
  border-color: #8c887e;
}

.quick-chip:active {
  transform: translateY(1px);
}

.quick-chip[aria-expanded="true"] {
  background: #1a1a1a;
  color: #FBF8EE;
  border-color: #1a1a1a;
}

.quick-chip .qs-icon {
  flex: 0 0 auto;
  color: currentColor;
}

.quick-start-panel {
  margin-top: 14px;
  background: #FBF8EE;
  border: 1px solid #d0cab8;
  border-radius: 14px;
  padding: 10px 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-start-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 4px;
  font-size: 13px;
  font-style: italic;
  opacity: 0.7;
}

.quick-start-panel-close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.6;
}

.quick-start-panel-close:hover {
  opacity: 1;
}

.qs-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  color: #1a1a1a;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.qs-suggestion:hover {
  background: #efeadb;
  border-color: #d0cab8;
}

.qs-suggestion-arrow {
  flex: 0 0 auto;
  opacity: 0.55;
}

.qs-suggestion:hover .qs-suggestion-arrow {
  opacity: 1;
}

@media (max-width: 640px) {
  .quick-starts {
    gap: 8px;
  }
  .quick-chip {
    font-size: 13px;
    padding: 8px 14px;
  }
}

/* ===== Explore-additional-capabilities disclosure ===========================
   A <details>/<summary> below the quick-start chips. Click the summary to
   reveal a grid of capability cards, each with 2-3 clickable query buttons.
   Uses the same palette + button styling as .qs-suggestion for consistency.
   The trigger is centered horizontally below the chips; the panel below
   resets to left-aligned text so card contents read normally.
   ============================================================================ */

/* ============================================================================
   Rate-limit modal — shown to anonymous users when they exhaust their daily
   cap on /api/query. Replaces the older always-visible "Why sign in?"
   callout so the value-prop messaging only appears when actually relevant.
   app.js triggers it via showRateLimitModal({title, body}) on a 429
   response from an anonymous user.
   ============================================================================ */
.rate-limit-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.rate-limit-modal[hidden],
.rate-limit-modal.hidden { display: none; }

.rate-limit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 12, 0.55);
}

.rate-limit-modal-card {
  position: relative;
  background: #FBF8EE;
  border: 1px solid #d0cab8;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 460px;
  padding: 28px 28px 22px;
  text-align: center;
}

.rate-limit-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #6b6a62;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.rate-limit-modal-close:hover {
  background: #efeadb;
  color: #1a1a1a;
}

.rate-limit-modal-icon {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 12px;
}

.rate-limit-modal-title {
  font-size: 19px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 12px;
  line-height: 1.3;
}

.rate-limit-modal-body {
  font-size: 14px;
  line-height: 1.55;
  color: #2a2a2a;
  margin: 0 0 20px;
}
.rate-limit-modal-body strong {
  color: #1a1a1a;
  font-weight: 600;
}

.rate-limit-modal-cta {
  display: block;
  width: 100%;
  background: #1a1a1a;
  color: #FBF8EE;
  border: none;
  border-radius: 6px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
  margin-bottom: 8px;
}
.rate-limit-modal-cta:hover { background: #2a2a2a; }

.rate-limit-modal-secondary {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #6b6a62;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 120ms ease, color 120ms ease;
}
.rate-limit-modal-secondary:hover { background: #efeadb; color: #1a1a1a; }

.explore-more {
  margin-top: 18px;
  text-align: center;
}

.explore-more-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: inherit;
  color: #4a4538;
  background: transparent;
  border-radius: 8px;
  user-select: none;
  list-style: none;        /* hide the native triangle marker (Chrome / Safari) */
  transition: background 0.12s ease, color 0.12s ease;
}
.explore-more-trigger::-webkit-details-marker { display: none; }
.explore-more-trigger::marker                  { display: none; }

.explore-more-trigger:hover {
  background: #efeadb;
  color: #1a1a1a;
}

.explore-more-label {
  font-weight: 500;
}

.explore-more-chevron {
  flex: 0 0 auto;
  transition: transform 0.18s ease;
}

.explore-more[open] .explore-more-chevron {
  transform: rotate(180deg);
}

.explore-more-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Parent <details>.explore-more is text-align: center to center the
     trigger; reset to left here so card contents read normally. */
  text-align: left;
}

.explore-more-card {
  background: #FBF8EE;
  border: 1px solid #d0cab8;
  border-radius: 14px;
  padding: 12px 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.explore-more-card-title {
  margin: 0 0 6px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

.explore-more-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  color: #1a1a1a;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease, border-color 0.12s ease;
}

/* Force the label span to take the remaining space and wrap cleanly on
   narrow viewports. Without `min-width: 0`, long single-word lines (or
   non-breaking strings) can blow out the flex layout and push the arrow
   off-screen on mobile. */
.explore-more-suggestion > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.explore-more-suggestion:hover {
  background: #efeadb;
  border-color: #d0cab8;
}

.explore-more-suggestion .qs-suggestion-arrow {
  flex: 0 0 auto;
  opacity: 0.55;
}

.explore-more-suggestion:hover .qs-suggestion-arrow {
  opacity: 1;
}

/* Mobile tier 1 (phones in landscape, small tablets) — tighten typography
   and padding to reclaim horizontal space for the long query text. */
@media (max-width: 640px) {
  .explore-more-card-title { font-size: 13px; padding: 0 12px; }
  .explore-more-suggestion { font-size: 13px; padding: 10px 12px; gap: 8px; }
  .explore-more-trigger    { font-size: 13px; padding: 6px 8px; }
}

/* Mobile tier 2 (narrow phones, <=380px) — reduce card padding further so
   the cards don't feel cramped, and let the trigger label wrap if needed. */
@media (max-width: 380px) {
  .explore-more-card       { padding: 10px 4px; border-radius: 12px; }
  .explore-more-card-title { font-size: 12.5px; padding: 0 10px; }
  .explore-more-suggestion { padding: 9px 10px; }
  .explore-more-trigger    {
    /* Allow the chevron to drop below the label if a very narrow viewport
       can't fit both on one line. Avoids horizontal scroll. */
    flex-wrap: wrap;
    justify-content: center;
  }
}

.conv-indicator {
  font-style: normal;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid #8c887e;
  border-radius: 10px;
  font-size: 11px;
  opacity: 0.75;
}

/* When the indicator carries an actual context state, give it more weight
 * so users can see at a glance "I am in a conversation" rather than "fresh
 * start". The base style (above) handles the empty / hidden state. */
.conv-indicator.has-context {
  border-color: #4a6b7a;
  background: #e8eff2;
  color: #1f3a44;
  opacity: 1;
  font-weight: 500;
}

/* "Click again to confirm" inline confirmation state on the new-conversation
 * link. The link text gets swapped from "new conversation" to a confirm
 * prompt for ~3s, with a distinct color so the change is obvious. */
.hint-link.confirm-pending {
  color: #a14b1c;
  font-weight: 600;
}

/* ---------- Conversation thread — prior turns ---------- */

/* Container for the stack of collapsed prior-turn cards. Sits between the
 * question input and the active results section. */
.prior-turns {
  margin: 14px 0 16px;
  padding: 12px 14px;
  background: #F7F4EB;
  border: 1px solid #d0cab8;
  border-radius: 8px;
}
.prior-turns.hidden { display: none; }

.prior-turns-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b6a62;
  margin-bottom: 8px;
  font-weight: 600;
}

/* One card per prior turn. Click to expand the summary. */
.prior-turn {
  background: #FBF8EE;
  border: 1px solid #e3dcc6;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.prior-turn:last-child { margin-bottom: 0; }
.prior-turn:hover {
  border-color: #b8b09a;
  background: #fdfaf2;
}

/* The prior turn's question text — always visible, never clipped. */
.prior-turn-question {
  font-size: 13.5px;
  line-height: 1.4;
  color: #1a1a1a;
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.prior-turn-question::before {
  content: "↳";
  color: #8c887e;
  font-weight: 400;
  flex-shrink: 0;
}

/* The summary excerpt — clipped to a couple of lines by default, expands
 * to the full summary text when the card is in .expanded state. */
.prior-turn-summary {
  font-size: 13px;
  line-height: 1.5;
  color: #4a4a4a;
  margin-left: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prior-turn.expanded .prior-turn-summary {
  -webkit-line-clamp: unset;
  overflow: visible;
}

/* Subtle "click to expand / collapse" affordance in the corner. */
.prior-turn-toggle {
  font-size: 10px;
  color: #8c887e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
  margin-left: 18px;
  font-weight: 600;
}

/* ---------- Repurchase-risk scoring panel ---------- */

.scoring-panel { margin-top: 18px; }

.meta-tag {
  font-size: 12px;
  opacity: 0.55;
  font-style: italic;
  margin-left: 8px;
}

.scoring-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #c8c2b0;
}

.scoring-blurb {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 10px;
  line-height: 1.5;
}

#scoring-input {
  width: 100%;
  background: #ece6d3;
  color: #1a1a1a;
  border: 1px solid #b8b2a0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  padding: 8px;
  resize: vertical;
}

.scoring-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px 0;
  font-size: 14px;
}

.scoring-model-row select {
  background: #ece6d3;
  color: #1a1a1a;
  border: 1px solid #8c887e;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 14px;
}

.scoring-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#scoring-submit {
  background: #1a1a1a;
  color: #F7F4EB;
  border: none;
  padding: 6px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
}

#scoring-submit:hover { opacity: 0.85; }
#scoring-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.scoring-status {
  font-style: italic;
  opacity: 0.7;
  font-size: 13px;
}

.scoring-result {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #b8b2a0;
  background: #efeadb;
}

.score-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.score-headline-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-value {
  font-size: 28px;
  font-weight: bold;
}

.score-headline-label {
  font-size: 12px;
  opacity: 0.65;
  font-style: italic;
}

.score-band {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid;
}

/* Risk-band colors darkened for readability on the cream background. */
.band-p99  { color: #b03a3a; border-color: #b03a3a; background: rgba(176, 58, 58, 0.10); }
.band-p95  { color: #b06820; border-color: #b06820; background: rgba(176, 104, 32, 0.10); }
.band-p90  { color: #8a6a10; border-color: #8a6a10; background: rgba(138, 106, 16, 0.10); }
.band-base { color: #2f7a3a; border-color: #2f7a3a; background: rgba(47, 122, 58, 0.10); }

.score-recommendation {
  font-size: 14px;
  margin-bottom: 8px;
}

.score-meta {
  font-size: 12px;
  opacity: 0.6;
  line-height: 1.5;
}

/* ---------- Reliability diagram ---------- */

.reliability-block {
  margin-top: 18px;
  border-top: 1px solid #c8c2b0;
  padding-top: 10px;
}

.reliability-canvas-wrap {
  position: relative;
  height: 400px;
  margin: 10px 0 16px;
  background: #ffffff;
  border: 1px solid #d0cab8;
  padding: 8px;
}

.reliability-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}

.reliability-table th, .reliability-table td {
  border-bottom: 1px solid #d0cab8;
  padding: 6px 10px;
  text-align: right;
}

.reliability-table th:first-child, .reliability-table td:first-child {
  text-align: left;
}

.reliability-table thead th {
  background: #efeadb;
  font-weight: normal;
  font-style: italic;
  opacity: 0.85;
}

.status {
  font-style: italic;
  opacity: 0.7;
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #1a1a1a;
  border-radius: 50%;
  animation: status-pulse 1.4s ease-in-out infinite;
  opacity: 0.6;
}
@keyframes status-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.9); }
  50%      { opacity: 1.0;  transform: scale(1.1); }
}

/* ---------- Tabbed result panel ---------- */

.tab-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid #b8b2a0;
  margin-top: 10px;
}

.tab-strip {
  display: flex;
  gap: 0;
}

.tab {
  background: transparent;
  color: #6e6a62;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #1a1a1a; }
.tab.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

.tab-meta {
  opacity: 0.55;
  font-size: 12px;
  font-style: italic;
  margin-left: 4px;
}

.tab-actions {
  padding-bottom: 6px;
}

.csv-btn {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #8c887e;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.csv-btn:hover {
  border-color: #1a1a1a;
  background: #e3dcc6;
}

.tab-panel {
  padding-top: 14px;
}

/* ---------- Copy-summary button ---------- */

#panel-summary {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 14px;
  right: 0;
  background: transparent;
  color: #6e6a62;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.copy-btn:hover {
  color: #1a1a1a;
  border-color: #8c887e;
  background: #e3dcc6;
}

.copy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.copy-btn.copied {
  color: #2f7a3a;
  border-color: transparent;
}

.copy-btn svg { display: block; }

/* Push the summary text away from the button so they don't overlap. */
#panel-summary .explanation {
  padding-right: 40px;
}

.table-meta {
  font-size: 13px;
  font-style: italic;
  opacity: 0.6;
  margin-bottom: 10px;
}

.status::after {
  content: '';
  display: inline-block;
  width: 6px;
  margin-left: 4px;
  animation: dots 1.4s infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

.error {
  color: #b03a3a;
  border: 1px solid #b03a3a;
  padding: 12px 16px;
  font-style: italic;
  background: rgba(176, 58, 58, 0.06);
}

.hidden { display: none !important; }

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.55;
}

.result-block {
  border-top: 1px solid #d0cab8;
  padding-top: 18px;
}

.result-block .section-label { margin-bottom: 10px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.explanation {
  font-size: 17px;
  line-height: 1.6;
}
.explanation p {
  margin: 0 0 12px 0;
}
.explanation p:last-child {
  margin-bottom: 0;
}
.explanation ul {
  margin: 4px 0 12px 0;
  padding-left: 24px;
}
.explanation li {
  margin: 2px 0;
}
.explanation strong {
  font-weight: 600;
}
.explanation em {
  font-style: italic;
}
.explanation hr {
  border: 0;
  border-top: 1px solid #d0cab8;
  margin: 16px 0;
}

/* Markdown pipe-tables rendered inline in the summary explanation
 * (e.g., the Fannie-vs-Freddie channel-choice comparison). */
.explanation-table {
  border-collapse: collapse;
  margin: 8px 0 14px 0;
  font-size: 14px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}
.explanation-table th,
.explanation-table td {
  border: 1px solid #d0cab8;
  padding: 7px 11px;
  text-align: left;
  white-space: nowrap;
}
.explanation-table th {
  background: #ece6d3;
  font-weight: 600;
}
.explanation-table tbody tr:nth-child(even) td {
  background: #fbf8ee;
}

.validation-badge {
  margin-top: 12px;
  font-size: 13px;
  font-style: italic;
}

.validation-badge .badge-ok {
  color: #2f7a3a;
  opacity: 0.95;
}

.validation-badge .badge-warn {
  color: #b06820;
  opacity: 0.95;
}

.validation-issues {
  list-style: disc;
  padding-left: 20px;
  margin: 6px 0 0 0;
  font-size: 12px;
  font-style: normal;
  opacity: 0.75;
  color: #1a1a1a;
}

.validation-issues li {
  margin-bottom: 4px;
  line-height: 1.45;
}

#sql {
  background: #ece6d3;
  border: 1px solid #d0cab8;
  padding: 12px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-x: auto;
  line-height: 1.45;
}

.result-actions { display: flex; gap: 6px; }

.result-actions button,
.link-btn {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #8c887e;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.result-actions button:hover,
.link-btn:hover { background: #e3dcc6; }

.result-actions button.active {
  background: #1a1a1a;
  color: #F7F4EB;
  border-color: #1a1a1a;
}

.link-btn {
  border: none;
  font-style: italic;
  opacity: 0.55;
  font-size: 13px;
  padding: 0;
}

.link-btn:hover { background: transparent; opacity: 0.9; }

#table-container { overflow-x: auto; max-width: 100%; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  border: 1px solid #d0cab8;
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #efeadb;
  font-weight: bold;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: #efeadb; }

td .null { opacity: 0.4; font-style: italic; }

#chart-wrap {
  background: #ffffff;
  padding: 16px;
  margin-top: 8px;
}

#chart-wrap canvas {
  max-height: 480px;
}

#follow-ups {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
}

.follow-up-chip {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #8c887e;
  padding: 8px 16px;
  margin: 0;
  font-family: inherit;
  font-size: 15px;
  font-style: italic;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  opacity: 0.85;
  transition: background 0.1s, color 0.1s, opacity 0.1s, border-color 0.1s;
}

.follow-up-chip:hover {
  background: #1a1a1a;
  color: #F7F4EB;
  border-color: #1a1a1a;
  opacity: 1;
}

.history-panel {
  border-top: 1px solid #d0cab8;
  padding-top: 18px;
  margin-top: 8px;
}

#history-list { list-style: none; margin-top: 8px; }

#history-list li {
  padding: 6px 0;
  border-bottom: 1px solid #e3dcc6;
  cursor: pointer;
  opacity: 0.75;
  font-size: 15px;
}

#history-list li:hover { opacity: 1; }

#history-list li.empty {
  cursor: default;
  opacity: 0.4;
  font-style: italic;
}

#history-list li.history-toggle {
  cursor: pointer;
  font-style: italic;
  opacity: 0.55;
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 10px 0 4px;
  border-bottom: none;
  border-top: 1px solid #d8d3c4;
  margin-top: 4px;
}

#history-list li.history-toggle:hover {
  opacity: 0.9;
}

.site-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid #d0cab8;
  text-align: center;
  font-size: 12px;
  opacity: 0.5;
  font-style: italic;
}

.site-footer p {
  margin: 0;
}

/* Legacy footer styles below (kept in case any other page references them). */
footer {
  margin-top: 32px;
  font-size: 12px;
  opacity: 0.5;
  font-style: italic;
}

footer p {
  margin-top: 4px;
}

footer a {
  color: inherit;
  text-decoration: underline;
}

footer a:hover {
  opacity: 0.8;
}

.brand {
  text-align: left;
  margin-top: 24px;
  font-style: normal;
}

.brand-line {
  font-size: 13px;
  opacity: 0.85;
}

.brand-copyright {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

@media (max-width: 600px) {
  body { padding: 24px 16px 60px; }
  header h1 { font-size: 26px; }
  #question { font-size: 17px; }
}


/* =========================================================================
   Mobile responsiveness — applies to ALL pages, not just the home page.
   Layered into three breakpoints:
     - 900px : User Guide sidebar+content collapses to single column. The
               240px sticky sidebar otherwise squeezes the content area too
               narrow on tablets / landscape phones.
     - 640px : Data tables in Use Guide prompt responses, scoring panel
               form, and tab-strip get scroll/wrap treatment so wide content
               doesn't overflow the viewport.
     - 480px : Phone-portrait sizing — tighter page padding, smaller brand
               logo and headlines, narrower body padding.
   These compose with the existing 640/600px blocks above (insight-card,
   insight-chart, quick-chips, body padding on the home page).
   ========================================================================= */

@media (max-width: 900px) {
  /* User Guide grid → single column. Sidebar floats above content with a
   * horizontal divider instead of the desktop right-border separator. The
   * sticky-top behavior is dropped — on mobile the sidebar scrolls with
   * the page. */
  .userguide-layout {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .userguide-sidebar {
    position: static;
    top: auto;
    border-right: none;
    border-bottom: 1px solid #c8c2b0;
    padding-right: 0;
    padding-bottom: 18px;
  }
  .userguide-content {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  /* Use Guide prompt-response data tables — convert to horizontal-scroll
   * blocks. Without this, tables wider than the viewport overflow the
   * .userguide-content column and break the page. white-space: nowrap on
   * cells keeps row-data readable rather than wrapping inside cramped cells. */
  .ug-data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Scoring panel: form rows wrap, action buttons wrap below input. */
  .scoring-model-row,
  .scoring-actions {
    flex-wrap: wrap;
  }
  .scoring-model-row select {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Tab strip at the top of the results panel — allow it to scroll if the
   * tab labels don't all fit on one row. Tab actions (Download CSV) wrap
   * below the tab strip rather than spilling off-screen. */
  .tab-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .tab-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 100%;
  }

  /* Insights post body — tighter inner padding. */
  .insight-post {
    padding: 0 6px;
  }

  /* About / Terms / Privacy pages — same. */
  .about-page,
  .legal-page {
    padding: 0 6px;
  }
}

@media (max-width: 480px) {
  /* Phone-portrait tightening. Shrinks the page padding, brand logo, and
   * the headline sizes that would otherwise dominate a 375px viewport. */
  body {
    padding: 18px 12px 50px;
  }
  .brand-logo {
    height: 40px;
  }
  header h1 {
    font-size: 22px;
  }
  .about-headline,
  .legal-headline {
    font-size: 22px;
  }
  .about-lead {
    font-size: 18px;
  }
  .about-body {
    font-size: 16px;
  }
  h2.ug-h {
    font-size: 22px;
  }
  h3.ug-h {
    font-size: 16px;
  }
  /* Insights post H1 + body */
  .insight-body {
    font-size: 15px;
  }
  .insight-body h2 {
    font-size: 18px;
  }
  /* Quick-chip chips on the home page already wrap (rule in earlier block);
   * further tighten label font + padding for very narrow viewports. */
  .quick-chip {
    font-size: 12px;
    padding: 7px 12px;
  }
}

/* ============================================================================
   Chat history sidebar — Phase B.
   Fixed-position left panel listing the signed-in user's prior conversations.
   The .auth-signed-only class (toggled by site.js) keeps anonymous users
   from ever seeing it; the sidebar is hidden by default for everyone and
   site.js sets [hidden] = false only when authenticated.

   Layout pattern: when shown on wide screens, body.has-sidebar adds left
   padding so the centered .container shifts right to make room. On narrow
   screens (<= 900px), the sidebar becomes an overlay above content with a
   click-to-dismiss backdrop.
   ============================================================================ */

.chat-history-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: #F0EBD7;
  border-right: 1px solid #d0cab8;
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: transform 220ms ease;
}
.chat-history-sidebar[hidden],
.chat-history-sidebar.collapsed { transform: translateX(-100%); }

/* When sidebar is shown on a wide screen, push body content right.
 * .has-sidebar is toggled on <body> by chat_history.js. */
body.has-sidebar {
  padding-left: 284px;   /* 260 sidebar + 24 breathing room */
  transition: padding-left 220ms ease;
}

/* Sidebar header — "New chat" CTA + close button */
.chat-history-header {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e0d9c0;
  flex-shrink: 0;
}
.chat-history-new {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #1a1a1a;
  color: #FBF8EE;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}
.chat-history-new:hover { background: #2a2a2a; }
.chat-history-new svg { flex-shrink: 0; }
.chat-history-close {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #6b6a62;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.chat-history-close:hover { background: #e0d9c0; color: #1a1a1a; }

/* Scrollable conversation list */
.chat-history-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 8px 14px;
}
.chat-history-list::-webkit-scrollbar { width: 6px; }
.chat-history-list::-webkit-scrollbar-thumb { background: #d0cab8; border-radius: 3px; }

/* Date-group heading (Today / Yesterday / This week / etc.) */
.chat-history-group {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8c887e;
  padding: 14px 8px 4px;
  font-weight: 600;
}
.chat-history-group:first-child { padding-top: 8px; }

/* One row per conversation */
.chat-history-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease;
  position: relative;
}
.chat-history-item:hover { background: #e0d9c0; }
.chat-history-item.active { background: #d8d0b4; }
.chat-history-item.active .chat-history-item-title { font-weight: 600; }

.chat-history-item-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Title-edit inline input (replaces .chat-history-item-title when renaming) */
.chat-history-item-edit {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  color: #1a1a1a;
  background: #FBF8EE;
  border: 1px solid #b8b09a;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
}

/* Hover-revealed action menu — rename, delete */
.chat-history-item-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.chat-history-item:hover .chat-history-item-actions,
.chat-history-item.menu-open .chat-history-item-actions {
  display: flex;
}
.chat-history-item-action {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6b6a62;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.chat-history-item-action:hover { background: #c9c2a8; color: #1a1a1a; }
.chat-history-item-action.confirm-pending {
  color: #a14b1c;
  font-weight: 600;
}

/* Empty state when the user has no saved conversations yet */
.chat-history-empty {
  padding: 14px 14px;
  font-size: 12.5px;
  color: #6b6a62;
  font-style: italic;
  line-height: 1.5;
}
.chat-history-empty.hidden { display: none; }

/* Mobile sidebar backdrop — semi-transparent overlay click-to-dismiss */
.chat-history-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 140;
  opacity: 1;
  transition: opacity 200ms ease;
}
.chat-history-backdrop.hidden { display: none; }

/* Sidebar-toggle button in the top nav — only visible when signed in.
 * Sits at the same vertical level as the hamburger. */
.chat-history-open {
  background: none;
  border: 1px solid #c8c2b0;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transition: background 120ms ease;
}
.chat-history-open:hover { background: #efeadb; }
.chat-history-open[hidden] { display: none; }

/* Narrow viewport: sidebar becomes a full overlay, body doesn't shift */
@media (max-width: 900px) {
  body.has-sidebar { padding-left: 24px; }
  .chat-history-sidebar { width: 280px; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18); }
}
