/* Search dialog, the /search/ page and the answer card. search.js links this file
   when search first opens; /search/ links it in its front matter. */

/* ---- Search -------------------------------------------------------------- */
/* The box over the page (search.js builds it) and the /search/ page share
   the box and the result styles. */

.search-dialog { width: min(68rem, calc(100% - 2rem)); height: min(44rem, calc(100dvh - 4rem)); max-height: none; margin: clamp(1rem, 6vh, 4rem) auto auto; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--paper); color: var(--ink-2); box-shadow: 0 30px 60px -24px rgb(11 11 12 / 0.4); overflow: hidden; flex-direction: column; }
.search-dialog[open] { display: flex; }
.search-dialog::backdrop { background: rgb(11 11 12 / 0.38); }
@media (prefers-reduced-motion: no-preference) {
  .search-dialog[open] { animation: search-in 0.16s ease-out; }
  @keyframes search-in { from { opacity: 0; transform: translateY(-6px); } }
}

.search-box { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem 0.5rem 1.1rem; }
.search-box > .icon { width: 22px; height: 22px; color: var(--slate); }
.search-box__input { flex: 1; min-width: 0; min-height: 48px; font: inherit; font-size: 1.125rem; color: var(--ink); background: none; border: 0; padding: 0; }
.search-box__input:focus { outline: none; }
.search-box__input::-webkit-search-cancel-button { display: none; }
.search-box__close { font: 500 0.875rem var(--sans); color: var(--slate); background: var(--wash); border: 0; border-radius: 10px; padding: 0.45rem 0.7rem; cursor: pointer; }
.search-box__close:hover { color: var(--ink); background: var(--rule); }
.search-dialog .search-box { border-bottom: 1px solid var(--rule); }
/* The input drops its own outline, so the box shows where focus is. */
.search-dialog .search-box:focus-within { box-shadow: inset 0 -2px 0 var(--green); }
.search-box--page { max-width: 44rem; margin-top: 1.5rem; border: 1px solid var(--field-line); border-radius: var(--r-card); }
.search-box--page:focus-within { border-color: var(--green); outline: 2px solid var(--green); outline-offset: -1px; }

.search-status { margin: 0; font-size: 0.875rem; color: var(--slate); }
.search-status:empty { display: none; }
[data-search-page] .search-status { margin-top: 1.25rem; }

/* Icon tiles: neutral, with research and articles in the blue scale.
   Green stays for "right", per docs/graphics.md. */
.search-hit__icon, .search-entry__icon { display: grid; place-items: center; flex: none; border-radius: 10px; background: var(--wash); color: var(--ink-2); }
.search-hit__icon .icon, .search-entry__icon .icon { width: 18px; height: 18px; }
.kind-book, .kind-chart { background: color-mix(in srgb, var(--q1) 45%, var(--paper)); color: var(--q7); }

/* The box over the page: compact rows. */
.search-all { font-size: 0.875rem; font-weight: 500; white-space: nowrap; }
.search-all[hidden] { display: none; }
.search-all kbd { margin-left: 0.45rem; font: 500 0.75rem var(--sans); color: var(--slate); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 0.05rem 0.35rem; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-dialog .search-results { padding: 0 0.5rem 0.5rem; }
.search-hit { margin: 0; padding: 0; border-radius: 12px; }
.search-hit__link { display: flex; align-items: center; gap: 0.8rem; padding: 0.55rem 0.65rem; color: inherit; text-decoration: none; border-radius: 12px; }
.search-hit__icon { width: 2.25rem; height: 2.25rem; }
.search-hit__body { flex: 1; min-width: 0; }
.search-hit__link:hover, .search-hit[aria-selected="true"] > .search-hit__link { background: var(--wash); }
.search-hit[aria-selected="true"] > .search-hit__link { box-shadow: inset 3px 0 0 var(--green); }
.search-hit__title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 0.975rem; color: var(--ink); letter-spacing: -0.01em; }
.search-hit__section { font-weight: 400; color: var(--slate); }
.search-hit__text { margin: 0.1rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; line-height: 1.45; color: var(--slate); }
.search-hit__kind { flex: none; font-size: 0.75rem; color: var(--slate); }
.search-hit mark, .search-entry mark { background: var(--tint); color: var(--green-deep); border-radius: 3px; padding: 0 0.1em; font-weight: 500; }
@media (max-width: 40rem) { .search-hit__kind { display: none; } }

/* The /search/ page: one entry per page, best match first. */
.search-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; max-width: 48rem; margin-top: 1rem; }
.search-filters[hidden] { display: none; }
.search-filter { display: inline-flex; align-items: center; gap: 0.4rem; font: 500 0.875rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--r-pill); padding: 0.35rem 0.8rem; cursor: pointer; }
.search-filter span { font-weight: 400; color: var(--slate); }
.search-filter:hover { border-color: var(--ink); }
.search-filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.search-filter[aria-pressed="true"] span { color: inherit; opacity: 0.7; }
.search-results--page { max-width: 48rem; margin-top: 1.25rem; padding: 0; counter-reset: none; }

.search-entry { position: relative; display: flex; gap: 1rem; margin: 0; padding: 1.1rem 0; border-top: 1px solid var(--rule); list-style: none; }
.search-entry[hidden] { display: none; }
.search-entry__icon { width: 2.75rem; height: 2.75rem; }
.search-entry__icon .icon { width: 22px; height: 22px; }
.search-entry__body { flex: 1; min-width: 0; }
.search-entry__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; margin: 0; font-size: 0.8125rem; color: var(--slate); }
.search-entry__kind { font-weight: 500; color: var(--ink-2); }
.search-entry__url { overflow-wrap: anywhere; }
.search-entry__title { margin: 0.15rem 0 0; font-size: 1.1875rem; line-height: 1.3; letter-spacing: -0.01em; }
.search-entry__title a { color: var(--ink); text-decoration: none; }
.search-entry__title a:hover { color: var(--green); text-decoration: underline; }
.search-entry__section { margin: 0.2rem 0 0; font-size: 0.875rem; color: var(--slate); }
.search-entry .search-hit__text { margin: 0.35rem 0 0; font-size: 0.9375rem; line-height: 1.55; color: var(--ink-2); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-entry__more { margin: 0.4rem 0 0; font-size: 0.875rem; color: var(--slate); }
.search-entry__n { position: absolute; right: 0; top: 1.1rem; font-size: 0.75rem; color: var(--slate); }
@media (max-width: 40rem) { .search-entry__icon { width: 2.25rem; height: 2.25rem; } .search-entry__n { display: none; } }

.search-dialog__foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: auto; padding: 0.65rem 1.1rem; border-top: 1px solid var(--rule); font-size: 0.8125rem; color: var(--slate); }
@media (hover: none), (max-width: 40rem) { .search-keys { display: none; } }

/* ---- Search and ask ------------------------------------------------------ */
/* One box for both: results as you type, and an answer written from the
   site's own pages once typing stops (or on Enter), with numbered sources
   and follow-up questions. The answer is neutral, not green: green means
   "checked and right", and an AI answer hasn't been checked. */

/* The box keeps one size from the moment it opens, so typing, results and
   the answer never move it. Once something is typed it splits: pages on the
   left, updating as you type, the answer on the right. Each column scrolls on
   its own, so a long answer never pushes the pages away. */
.search-box__clear { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; padding: 0; font: 400 1.35rem/1 var(--sans); color: var(--slate); background: none; border: 0; border-radius: 50%; cursor: pointer; }
.search-box__clear:hover { background: var(--wash); color: var(--ink); }
.search-box__clear[hidden] { display: none; }
.search-box__close { display: inline-flex; align-items: center; gap: 0.4rem; }
.search-box__close kbd { font: 500 0.75rem var(--sans); color: var(--slate); }
.search-box__close-x { display: none; }

.sd-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: minmax(0, 1fr); }
.sd-main[hidden] { display: none; }
.sd-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sd-col__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding: 0.75rem; }
.sd-col--answer { border-left: 1px solid var(--rule); background: color-mix(in srgb, var(--wash) 55%, var(--paper)); }
.sd-col--answer > .sd-col__scroll { padding: 0 0 1rem; }
.sd-col__head { display: flex; align-items: baseline; gap: 0.75rem; min-height: 2.75rem; padding: 0.85rem 1.1rem 0.35rem; }
.sd-col__h { margin: 0; font-size: 0.8125rem; font-weight: 500; color: var(--ink); }
.sd-col__h { flex: 1; }
.sd-col__head .search-status:empty { display: block; }
.sd-col__n { margin-left: 0.5rem; font-weight: 400; color: var(--slate); }
/* In the answer column the sources wrap instead of scrolling sideways. */
.sd-col--answer .answer__sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); overflow: visible; }
.sd-col--answer .answer__source { width: auto; }
/* Answers switched off: the pages take the whole box. */
.search-dialog.answers-off .sd-main { grid-template-columns: minmax(0, 1fr); }
.search-dialog.answers-off .sd-col--answer, .search-dialog.answers-off .sd-tabs { display: none; }

/* Phones pick a column with these; wider screens show both. */
.sd-tabs { display: none; }
.sd-tab { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; flex: 1; min-height: 40px; font: 500 0.9375rem var(--sans); color: var(--slate); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.sd-tab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.sd-tab__n { font-weight: 400; font-size: 0.8125rem; }
.sd-tab__dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--slate); }
.sd-tab.is-busy .sd-tab__dot { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .sd-tab.is-busy .sd-tab__dot { animation: answer-dot 1.2s ease-in-out infinite; }
}

/* Before typing: the same two columns, popular pages and questions to ask. */
.sd-empty { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.sd-empty[hidden] { display: none; }
.sd-empty__col { padding: 0.85rem 0.5rem 1rem; }
.sd-empty__col--ask { padding: 0.85rem 1.1rem 1rem; border-left: 1px solid var(--rule); background: color-mix(in srgb, var(--wash) 55%, var(--paper)); }
.sd-empty__h { margin: 0 0 0.55rem; padding: 0.1rem 0.6rem 0; font-size: 0.8125rem; font-weight: 500; color: var(--ink); }
.sd-empty__col--ask .sd-empty__h { padding-inline: 0; }
.sd-empty .search-results { padding: 0; }
.sd-empty .search-hit__link > .icon { width: 16px; height: 16px; flex: none; color: var(--slate); opacity: 0; transition: opacity 0.15s ease; }
.sd-empty .search-hit__link:hover > .icon { opacity: 1; }
.sd-empty__note { margin: 1rem 0 0; font-size: 0.8125rem; line-height: 1.45; color: var(--slate); }
.sd-ideas { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.sd-ideas li { margin: 0; padding: 0; }
.sd-idea { display: flex; align-items: center; gap: 0.65rem; width: 100%; min-height: 44px; padding: 0.6rem 0.85rem; font: 400 0.9375rem/1.35 var(--sans); color: var(--ink); text-align: left; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; cursor: pointer; transition: border-color 0.15s ease; }
.sd-idea:hover { border-color: var(--rule-strong); }
.sd-idea .icon { width: 18px; height: 18px; flex: none; color: var(--slate); }

/* Holds the answer's place until it's asked. */
.answer--idle .answer__head { margin-bottom: 0.75rem; }
.sd-idle__ask { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.6rem 0.65rem; font: inherit; color: var(--ink); text-align: left; background: var(--wash); border: 0; border-radius: 12px; cursor: pointer; }
.sd-idle__ask:hover { background: var(--rule); }
.sd-idle__ask[hidden] { display: none; }
.sd-idle__icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none; border-radius: 10px; background: var(--ink); color: var(--paper); }
.sd-idle__icon .icon { width: 18px; height: 18px; }
.sd-idle__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.975rem; }
.sd-idle__label { font-weight: 500; margin-right: 0.4rem; }
.sd-idle__q { color: var(--ink-2); }
.sd-idle__q::before { content: "“"; } .sd-idle__q::after { content: "”"; }
.sd-idle__ask kbd { flex: none; font: 500 0.75rem var(--sans); color: var(--slate); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 0.05rem 0.35rem; background: var(--paper); }
@media (hover: none) { .sd-idle__ask kbd { display: none; } }
.sd-idle__note { margin: 0.75rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--slate); }
.sd-idle__ask:not([hidden]) + .sd-idle__note { margin-top: 0.6rem; }

/* The answer card */
.answer { position: relative; margin: 0.75rem 0.75rem 0; padding: 1rem 1.1rem 1.05rem; border: 1px solid var(--rule); border-radius: 16px; background: var(--paper); box-shadow: 0 1px 0 rgb(11 11 12 / 0.02), 0 8px 24px -16px rgb(11 11 12 / 0.18); }
.answer[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .search-dialog .answer, .search-answer .answer { animation: answer-in 0.2s ease-out; }
  @keyframes answer-in { from { opacity: 0; transform: translateY(4px); } }
}
.answer--follow { margin-top: 1.25rem; }
.answer__q { margin: 0 0 0.75rem; font-size: 1.125rem; line-height: 1.35; letter-spacing: -0.01em; color: var(--ink); }
.answer__head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.55rem; }
.answer__badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem 0.2rem 0.45rem; font-size: 0.8125rem; font-weight: 600; color: var(--paper); background: var(--ink); border-radius: var(--r-pill); }
.answer__badge .icon { width: 15px; height: 15px; }
.answer__from { font-size: 0.8125rem; color: var(--slate); }
.answer__state { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.4rem; font-size: 0.875rem; color: var(--slate); }
.answer__state:empty { display: none; }
.answer__body { font-size: 1.0625rem; line-height: 1.6; color: var(--ink); }
.answer__body p { margin: 0 0 0.65rem; }
.answer__body p:last-child, .answer__body ul:last-child { margin-bottom: 0; }
.answer__body ul { margin: 0 0 0.65rem; padding-left: 1.2rem; }
.answer__body li { margin: 0 0 0.3rem; padding-left: 0.15rem; }
.answer__body strong { font-weight: 600; }
.answer__none { color: var(--ink-2) !important; font-size: 0.975rem; }
.answer__retry { font: inherit; font-weight: 500; color: var(--green); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

.cite { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; margin: 0 0.1rem; padding: 0 0.3rem; vertical-align: 0.12em; font: 600 0.6875rem/1 var(--sans); color: var(--ink-2); text-decoration: none; background: var(--wash); border: 1px solid var(--rule-strong); border-radius: 6px; transition: background-color 0.15s ease, color 0.15s ease; }
.cite:hover, .cite:focus-visible { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.answer__caret { display: inline-block; width: 0.5em; height: 1.05em; margin-left: 0.12em; vertical-align: -0.15em; background: var(--ink); border-radius: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .answer__caret { animation: answer-blink 1s steps(2, start) infinite; }
  @keyframes answer-blink { to { visibility: hidden; } }
}
.answer__dots { display: inline-flex; gap: 3px; }
.answer__dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--slate); opacity: 0.35; }
.answer__skeleton { display: grid; gap: 0.55rem; padding: 0.25rem 0 0.1rem; }
.answer__skeleton i { display: block; height: 0.8rem; border-radius: 6px; background: var(--wash); }
.answer__skeleton i:nth-child(2) { width: 92%; } .answer__skeleton i:nth-child(3) { width: 64%; }
@media (prefers-reduced-motion: no-preference) {
  .answer__dots i { animation: answer-dot 1.2s ease-in-out infinite; }
  .answer__dots i:nth-child(2) { animation-delay: 0.15s; } .answer__dots i:nth-child(3) { animation-delay: 0.3s; }
  @keyframes answer-dot { 30% { opacity: 1; transform: translateY(-2px); } }
  .answer__skeleton i { background: linear-gradient(90deg, var(--wash) 0%, var(--rule) 40%, var(--wash) 80%) 0 0 / 300% 100%; animation: answer-shine 1.4s linear infinite; }
  @keyframes answer-shine { from { background-position: 100% 0; } to { background-position: -50% 0; } }
  .answer[data-state="done"] .answer__body { animation: none; }
}

.answer__sub { margin: 0 0 0.45rem; font-size: 0.8125rem; color: var(--slate); }
.answer__sources-wrap { margin-top: 0.95rem; }
.answer__sources-wrap[hidden] { display: none; }
.answer__sources { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.45rem; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.answer__sources::-webkit-scrollbar { display: none; }
.answer__sources li { margin: 0; padding: 0; flex: 0 0 auto; scroll-snap-align: start; }
.answer__source { display: flex; align-items: flex-start; gap: 0.5rem; width: 13.5rem; height: 100%; padding: 0.55rem 0.65rem; color: inherit; text-decoration: none; background: var(--wash); border: 1px solid transparent; border-radius: 12px; transition: border-color 0.15s ease, background-color 0.15s ease; }
.answer__source:hover { background: var(--paper); border-color: var(--rule-strong); }
.answer__source-n { display: grid; place-items: center; flex: none; width: 1.25rem; height: 1.25rem; font: 600 0.6875rem/1 var(--sans); color: var(--ink-2); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 6px; }
.answer__source-t { min-width: 0; font-size: 0.8125rem; line-height: 1.35; }
.answer__source-t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.answer__source-t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--slate); }

.answer__foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.85rem; }
.answer__note { margin: 0; font-size: 0.75rem; line-height: 1.4; color: var(--slate); }
.answer__note[hidden], .answer__tool[hidden], .answer__next[hidden] { display: none; }
.answer__tool { display: inline-flex; align-items: center; gap: 0.35rem; flex: none; padding: 0.3rem 0.55rem; font: 500 0.8125rem var(--sans); color: var(--ink-2); background: none; border: 1px solid var(--rule-strong); border-radius: 8px; cursor: pointer; }
.answer__tool:hover { border-color: var(--ink); color: var(--ink); }
.answer__tool .icon { width: 14px; height: 14px; }

.answer__next { margin-top: 0.95rem; padding-top: 0.85rem; border-top: 1px solid var(--rule); }
.answer__next ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.answer__next li { margin: 0; padding: 0; }
.answer__ask { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px; padding: 0.35rem 0.8rem 0.35rem 0.6rem; font: 400 0.9rem/1.3 var(--sans); color: var(--ink); text-align: left; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--r-pill); cursor: pointer; }
.answer__ask:hover { border-color: var(--ink); background: var(--wash); }
.answer__ask .icon { width: 14px; height: 14px; flex: none; color: var(--slate); }

/* The follow-up box at the bottom */
.sd-composer-wrap { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem; border-top: 1px solid var(--rule); background: var(--paper); }
.sd-composer-wrap[hidden] { display: none; }
.sd-composer { display: flex; align-items: center; flex: 1; min-width: 0; gap: 0.4rem; padding: 0.25rem 0.3rem 0.25rem 0.9rem; border: 1px solid var(--rule-strong); border-radius: var(--r-pill); background: var(--paper); transition: border-color 0.15s ease; }
.sd-composer:focus-within { border-color: var(--ink); }
.sd-composer[hidden] { display: none; }
.sd-composer__input { flex: 1; min-width: 0; min-height: 40px; font: inherit; font-size: 1rem; color: var(--ink); background: none; border: 0; padding: 0; }
.sd-composer__input:focus { outline: none; }
.sd-composer__send { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex: none; padding: 0; color: var(--paper); background: var(--ink); border: 0; border-radius: 50%; cursor: pointer; }
.sd-composer__send .icon { width: 18px; height: 18px; transform: rotate(-90deg); }
.sd-composer__send:hover { background: var(--ink-2); }
.sd-stop { display: block; width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.sd-composer__new { flex: none; font: 500 0.875rem var(--sans); color: var(--slate); background: none; border: 0; padding: 0.4rem 0.3rem; cursor: pointer; }
.sd-composer__new:hover { color: var(--ink); }
.sd-composer--page { margin-top: 1rem; }
.search-dialog__more { font-size: 0.8125rem; color: var(--slate); }
.search-dialog.has-thread .search-dialog__foot { display: none; }
.sd-composer-wrap { flex: none; }

/* The answer on /search/: beside the results on a wide screen, held in view
   as they scroll; above them on a narrow one. While a new query is typed the
   old answer fades instead of going, so nothing below it jumps. */
.search-layout { display: flex; flex-direction: column; }
.search-layout__main { min-width: 0; }
.search-answer { max-width: 48rem; order: -1; transition: opacity 0.2s ease; }
.search-answer[hidden] { display: none; }
.search-answer.is-stale { opacity: 0.45; }
.search-answer .answer { margin: 1.25rem 0 0; padding: 1.15rem 1.3rem 1.2rem; }
@media (min-width: 64rem) {
  .search-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 30rem); gap: 3rem; align-items: start; }
  .search-answer { order: 0; position: sticky; top: 6rem; max-height: calc(100dvh - 7rem); overflow-y: auto; overscroll-behavior: contain; margin-top: 1.25rem; }
  .search-answer .answer { margin: 0; box-shadow: none; }
}

/* Phones and narrow windows: one column at a time, picked with the tabs. */
@media (max-width: 52rem) {
  .sd-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sd-tabs { display: flex; padding: 0 0.5rem; border-bottom: 1px solid var(--rule); }
  .search-dialog[data-view="pages"] .sd-col--answer, .search-dialog[data-view="answer"] .sd-col--pages { display: none; }
  .sd-col--answer { border-left: 0; }
  .sd-col__head { justify-content: flex-end; min-height: 0; padding-top: 0.6rem; }
  .sd-col__h { display: none; }
  .sd-empty { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sd-empty__col--ask { order: -1; border-left: 0; border-bottom: 1px solid var(--rule); }
}
@media (max-width: 40rem) {
  .search-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .search-dialog .search-box { padding: max(0.4rem, env(safe-area-inset-top)) 0.5rem 0.4rem 0.9rem; }
  .search-box__close kbd { display: none; }
  .search-box__close-x { display: inline; }
  .answer { margin: 0.6rem 0.5rem 0; padding: 0.9rem 0.95rem 1rem; }
  .answer__body { font-size: 1rem; }
  .answer__source { width: 12rem; }
  .answer__foot { flex-direction: column; align-items: flex-start; }
  .sd-composer-wrap { padding: 0.5rem 0.6rem max(0.5rem, env(safe-area-inset-bottom)); }
  .search-dialog__foot { padding-bottom: max(0.65rem, env(safe-area-inset-bottom)); }
  .search-dialog:has(.sd-composer-wrap:not([hidden])) .search-dialog__foot { display: none; }
}
@media (min-width: 40.01rem) { .search-box__close .search-box__close-x { display: none; } }
