/* Search is a native modal dialog: focus and background interaction stay contained. */
.search-modal {
  --search-paper: #faf9f5;
  --search-ink: #20392f;
  --search-muted: #69756d;
  --search-line: #dde2d8;
  --search-tint: #eef1e8;
  width: min(860px, calc(100% - 40px));
  max-width: none;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #bfaa7055;
  border-radius: 22px;
  background: var(--search-paper);
  color: var(--search-ink);
  box-shadow: 0 32px 120px #061d2366;
  font-family: var(--font-ui, Cairo, sans-serif);
  text-align: start;
  scrollbar-width: thin;
  scrollbar-color: #b1b9a7 transparent;
}
.search-modal::backdrop { background: #091d22b8; backdrop-filter: blur(7px); }
.search-modal[open] { animation: search-arrive .22s ease-out; }
.search-modal *, .search-modal *::before, .search-modal *::after { box-sizing: border-box; }
.search-modal [hidden] { display: none !important; }
.search-modal button, .search-modal select, .search-modal input { font: inherit; }
.search-modal button { cursor: pointer; }
.search-modal :is(button, a, select, summary):focus-visible { outline: 2px solid #ad8532; outline-offset: 4px; }
.search-head {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 34px 20px;
  background: #173d30;
  color: #fbf8ed;
  border-bottom: 3px solid #c4a663;
}
.search-head::before, .search-head::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 230px;
  height: 230px;
  inset-inline-end: 18px;
  top: -70px;
  border: 1px solid #c9b07540;
  border-radius: 50% 50% 0 0;
  transform: rotate(-28deg);
  pointer-events: none;
}
.search-head::after { width: 195px; height: 195px; top: -51px; inset-inline-end: 36px; }
.search-eyebrow { display: block; color: #dfce9f; font-size: 11px; letter-spacing: .02em; }
.search-head h2 { margin: 8px 0 4px; font: 700 38px/1.3 var(--font-heading, Amiri, serif); color: inherit; }
.search-head p { margin: 0; font-size: 13px; line-height: 1.9; color: #e1e7dc; }
.search-close { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; color: #eee7d1; border: 1px solid #eee7d144; border-radius: 50%; background: #173d3080; }
.search-close:hover { background: #ffffff1a; }
.search-body { padding: 20px 34px 18px; }
.search-form { display: flex; gap: 8px; align-items: center; margin: 0; padding: 6px 6px 6px 8px; background: var(--search-paper); border: 1px solid #a8b4a6; border-radius: 12px; transition: box-shadow .15s, border-color .15s; }
.search-form:focus-within { border-color: #63836a; box-shadow: 0 0 0 3px #678b691a; }
.search-field { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; padding-inline-start: 12px; }
.search-field svg { color: #6e856e; flex-shrink: 0; }
.search-input { width: 100%; min-width: 0; height: 48px; padding: 0; border: 0; background: transparent; color: var(--search-ink); font-size: 16px !important; outline: none; }
.search-input::placeholder { color: var(--search-muted); opacity: 1; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-submit { flex-shrink: 0; display: flex; align-items: center; gap: 18px; padding: 12px 18px; border: 0; border-radius: 8px; background: #234b39; color: #fff9e9; font-size: 13px !important; }
.search-submit:hover { background: #346548; }
.search-submit span { font-size: 20px; line-height: 1; }
.search-clear { width: 34px; height: 40px; flex-shrink: 0; border: 0; background: none; color: var(--search-muted); font-size: 24px !important; }
.search-hint { margin: 10px 0 20px; font-size: 11px; line-height: 1.9; color: var(--search-muted); }
.search-discover { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; font-size: 11px; color: var(--search-muted); }
.search-discover > span { flex-shrink: 0; }
.search-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.search-topics button { display: flex; align-items: center; gap: 12px; max-width: 100%; padding: 5px 11px; background: var(--search-tint); border: 1px solid var(--search-line); border-radius: 6px; color: var(--search-ink); font-size: 11px; text-align: start; overflow-wrap: anywhere; }
.search-topics button:hover { border-color: #a89150; }
.search-topics button span { color: #8d793f; }
.search-filters { border-block: 1px solid var(--search-line); margin-bottom: 18px; }
.search-filters summary { display: flex; justify-content: space-between; gap: 8px; padding: 12px 2px; list-style: none; cursor: pointer; font-size: 12px; color: var(--search-muted); }
.search-filters summary::-webkit-details-marker { display: none; }
.search-filters[open] summary span { transform: rotate(45deg); }
.search-tools-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-bottom: 16px; }
.search-tools-row label { display: grid; gap: 6px; min-width: 0; font-size: 11px; color: var(--search-muted); }
.search-tools-row select { width: 100%; min-width: 0; height: 42px; padding: 4px 9px; border: 1px solid var(--search-line); border-radius: 7px; background: var(--search-paper); color: var(--search-ink); font-size: 12px; }
.search-results-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.search-results-heading h3 { margin: 0; font-size: 13px; color: var(--search-ink); }
.search-results-heading [role=status] { color: var(--search-muted); font-size: 11px; }
.search-results { min-height: 100px; }
.search-results .sr-item { display: flex; align-items: flex-start; gap: 16px; padding: 19px 8px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--search-line); border-radius: 6px; transition: background .15s; }
.search-results .sr-item:hover, .search-results .sr-item.is-active { background: var(--search-tint); }
.sr-number { padding-top: 3px; color: #8c906e; font: 16px/1.5 Georgia, serif; font-style: italic; }
.sr-content { flex: 1; min-width: 0; }
.sr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--search-muted); font-size: 10px; line-height: 1.8; }
.sr-tag { color: var(--search-ink); }
.sr-meta time::before { content: '·'; margin-inline-end: 10px; }
.sr-title { margin: 6px 0 4px; font: 700 22px/1.55 var(--font-heading, Amiri, serif); color: var(--search-ink); overflow-wrap: anywhere; }
.sr-snippet { margin: 0; color: var(--search-muted); font-size: 12px; line-height: 1.9; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sr-arrow { padding-top: 27px; color: #8e956d; }
.search-results mark { background: #d8bd6b4d; color: inherit; border-radius: 2px; padding: 0; }
.search-empty { padding: 30px 14px; text-align: center; color: var(--search-muted); }
.search-empty-symbol { font: 48px/1 Georgia, serif; color: #a08b53; }
.search-empty h4 { margin: 12px 0 6px; color: var(--search-ink); font: 700 24px/1.6 var(--font-heading, Amiri, serif); }
.search-empty p { font-size: 12px; line-height: 1.8; margin: 0 0 16px; }
.search-empty button, .search-pagination button { min-height: 40px; padding: 6px 14px; border: 1px solid var(--search-line); border-radius: 6px; background: var(--search-tint); color: var(--search-ink); font-size: 12px; }
.search-pagination { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding-top: 18px; color: var(--search-muted); font-size: 12px; }
.search-pagination button:disabled { opacity: .4; cursor: default; }
.search-notice { color: var(--search-muted); background: var(--search-tint); border-inline-start: 2px solid #aa914e; padding: 8px 12px; font-size: 12px; line-height: 1.8; }
.search-loading { display: grid; gap: 18px; padding: 24px 8px; }
.search-loading i { display: block; height: 40px; width: 90%; background: var(--search-tint); border-radius: 6px; animation: search-pulse 1s ease-in-out infinite alternate; }
.search-loading i:nth-child(2) { width: 74%; animation-delay: .15s; }
.search-loading i:nth-child(3) { width: 82%; animation-delay: .3s; }
.search-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 34px; color: var(--search-muted); background: var(--search-tint); font-size: 10px; border-top: 1px solid var(--search-line); }
.search-keys { display: flex; align-items: center; gap: 6px; }
.search-keys kbd { font: 10px/1.5 var(--font-ui, sans-serif); padding: 1px 5px; border: 1px solid var(--search-line); border-bottom-width: 2px; border-radius: 4px; background: var(--search-paper); }
.search-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html[data-theme=dark] .search-modal { --search-paper: #162820; --search-ink: #ecebdb; --search-muted: #a7b5a8; --search-line: #344638; --search-tint: #203428; color-scheme: dark; }
html[data-theme=dark] .search-head { background: #10261e; }
html[data-theme=dark] .search-form { border-color: #6c7b59; }
html[data-theme=dark] .search-submit { background: #c7ad70; color: #152c20; }
@keyframes search-arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes search-pulse { from { opacity: .5; } to { opacity: 1; } }
@media (max-width: 600px) {
  .search-modal { width: 100%; max-height: 100vh; max-height: 100dvh; margin: 0 auto; border-radius: 0 0 18px 18px; border-top: 0; }
  .search-head { padding: 22px 20px 20px; }
  .search-head h2 { font-size: 34px; }
  .search-head p { font-size: 12px; }
  .search-eyebrow { font-size: 10px; }
  .search-body { padding: 20px 16px 16px; }
  .search-field { gap: 8px; padding-inline-start: 5px; }
  .search-field svg { width: 20px; }
  .search-submit { padding: 12px; }
  .search-submit span { display: none; }
  .search-hint { font-size: 10px; }
  .search-discover { flex-direction: column; gap: 8px; }
  .search-tools-row { grid-template-columns: 1fr 1fr; }
  .search-tools-row label:last-child { grid-column: 1 / -1; }
  .search-results .sr-item { gap: 10px; padding: 16px 3px; }
  .sr-title { font-size: 20px; }
  .sr-number { font-size: 13px; }
  .sr-arrow { display: none; }
  .search-foot { padding: 12px 20px max(12px, env(safe-area-inset-bottom)); }
  .search-keys { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .search-modal[open], .search-loading i { animation: none; }
  .search-modal * { transition: none !important; scroll-behavior: auto !important; }
}
@media print { .search-modal { display: none !important; } }
