/* ============================================================
   Clarity — typography-first SearXNG theme overlay
   Fonts: Inter (UI/titles) + Literata (snippets) — self-hosted
   Enough whitespace to breathe, dense enough to scan quickly
   ============================================================ */

/* ---------- Face declarations ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/literata-400.woff2") format("woff2");
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/literata-400i.woff2") format("woff2");
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/literata-600.woff2") format("woff2");
}

/* ---------- Design tokens ---------- */
:root {
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-read: "Literata", "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-base: 0.95rem;
  --text-md: 1.05rem;
  --text-lg: 1.2rem;
  --text-xl: 1.35rem;

  --leading-tight: 1.3;
  --leading-snug: 1.45;
  --leading-read: 1.55;

  --space-result-y: 0.85rem;
  --space-result-gap: 0.15rem;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;

  /* Warm paper light — ink, not pure black */
  --color-base-font: #2a2724;
  --color-base-font-rgb: 42, 39, 36;
  --color-base-background: #faf9f7;
  --color-base-background-mobile: #f4f2ee;
  --color-header-background: #faf9f7ee;
  --color-header-border: #e8e4dc;
  --color-footer-background: #f4f2ee;
  --color-footer-border: #e8e4dc;

  --color-url-font: #0f6b63;
  --color-url-visited-font: #7a4fbf;

  --color-result-background: transparent;
  --color-result-border: #ece8e1;
  --color-result-url-font: #0f6b63;
  --color-result-link-font: #1a3a8a;
  --color-result-link-font-highlight: #1a3a8a;
  --color-result-link-visited-font: #7a4fbf;
  --color-result-description-highlight-font: #1a1816;
  --color-result-publishdate-font: #7a746c;
  --color-result-engines-font: #8a847c;
  --color-result-vim-selected: #f0ebe3;
  --color-result-vim-arrow: #1a3a8a;

  --color-search-background: #ffffff;
  --color-search-font: #1a1816;
  --color-search-border: #d9d3c8;
  --color-search-shadow: 0 1px 2px rgba(40, 32, 20, 0.04), 0 8px 24px rgba(40, 32, 20, 0.06);
  --color-search-background-hover: #1a3a8a;

  --color-btn-background: #1a3a8a;
  --color-btn-font: #ffffff;
  --color-categories-item-selected-font: #1a3a8a;
  --color-categories-item-border-selected: #1a3a8a;

  --color-autocomplete-background: #ffffff;
  --color-autocomplete-border: #d9d3c8;
  --color-autocomplete-shadow: 0 8px 28px rgba(40, 32, 20, 0.1);
  --color-autocomplete-background-hover: #f0ebe3;
  --color-autocomplete-font: #1a1816;

  --color-answer-background: #ffffff;
  --color-answer-font: #2a2724;
  --color-sidebar-background: #faf9f7;
  --color-sidebar-border: #e8e4dc;
  --color-sidebar-font: #2a2724;

  --color-show-btn-background: #ebe6dc;
  --color-show-btn-font: #2a2724;
}

/* Dark — soft charcoal, cool links, warm body text */
:root.theme-dark,
:root.theme-auto,
.theme-dark,
.theme-auto {
  --color-base-font: #d8d4ce;
  --color-base-font-rgb: 216, 212, 206;
  --color-base-background: #12141a;
  --color-base-background-mobile: #12141a;
  --color-header-background: #12141aee;
  --color-header-border: #252933;
  --color-footer-background: #0e1015;
  --color-footer-border: #252933;

  --color-url-font: #7dcdc2;
  --color-url-visited-font: #c4a3f0;

  --color-result-background: transparent;
  --color-result-border: #252933;
  --color-result-url-font: #7dcdc2;
  --color-result-link-font: #9ec0ff;
  --color-result-link-font-highlight: #9ec0ff;
  --color-result-link-visited-font: #c4a3f0;
  --color-result-description-highlight-font: #f0ebe3;
  --color-result-publishdate-font: #8b8680;
  --color-result-engines-font: #7a7670;
  --color-result-vim-selected: #1a1e28;
  --color-result-vim-arrow: #9ec0ff;

  --color-search-background: #1a1e28;
  --color-search-font: #f0ebe3;
  --color-search-border: #333846;
  --color-search-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.35);
  --color-search-background-hover: #9ec0ff;

  --color-btn-background: #3d6fd9;
  --color-btn-font: #0e1015;
  --color-categories-item-selected-font: #9ec0ff;
  --color-categories-item-border-selected: #9ec0ff;

  --color-autocomplete-background: #1a1e28;
  --color-autocomplete-border: #333846;
  --color-autocomplete-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --color-autocomplete-background-hover: #252a38;
  --color-autocomplete-font: #f0ebe3;

  --color-answer-background: #1a1e28;
  --color-answer-font: #d8d4ce;
  --color-sidebar-background: #161920;
  --color-sidebar-border: #252933;
  --color-sidebar-font: #d8d4ce;

  --color-show-btn-background: #2a2f3c;
  --color-show-btn-font: #d8d4ce;
}

/* True black mode keeps high contrast */
:root.theme-black,
.theme-black {
  --color-base-background: #000000;
  --color-base-background-mobile: #000000;
  --color-header-background: #000000ee;
  --color-footer-background: #000000;
  --color-search-background: #0a0a0c;
  --color-result-vim-selected: #111114;
  --color-sidebar-background: #000000;
  --color-answer-background: #0a0a0c;
  --color-autocomplete-background: #0a0a0c;
}

/* Prefer light tokens when OS is light + theme-auto */
@media (prefers-color-scheme: light) {
  :root.theme-auto,
  .theme-auto {
    --color-base-font: #2a2724;
    --color-base-font-rgb: 42, 39, 36;
    --color-base-background: #faf9f7;
    --color-base-background-mobile: #f4f2ee;
    --color-header-background: #faf9f7ee;
    --color-header-border: #e8e4dc;
    --color-footer-background: #f4f2ee;
    --color-footer-border: #e8e4dc;
    --color-url-font: #0f6b63;
    --color-url-visited-font: #7a4fbf;
    --color-result-border: #ece8e1;
    --color-result-url-font: #0f6b63;
    --color-result-link-font: #1a3a8a;
    --color-result-link-font-highlight: #1a3a8a;
    --color-result-link-visited-font: #7a4fbf;
    --color-result-description-highlight-font: #1a1816;
    --color-result-publishdate-font: #7a746c;
    --color-result-engines-font: #8a847c;
    --color-result-vim-selected: #f0ebe3;
    --color-result-vim-arrow: #1a3a8a;
    --color-search-background: #ffffff;
    --color-search-font: #1a1816;
    --color-search-border: #d9d3c8;
    --color-search-shadow: 0 1px 2px rgba(40, 32, 20, 0.04), 0 8px 24px rgba(40, 32, 20, 0.06);
    --color-search-background-hover: #1a3a8a;
    --color-btn-background: #1a3a8a;
    --color-btn-font: #ffffff;
    --color-categories-item-selected-font: #1a3a8a;
    --color-categories-item-border-selected: #1a3a8a;
    --color-autocomplete-background: #ffffff;
    --color-autocomplete-border: #d9d3c8;
    --color-autocomplete-shadow: 0 8px 28px rgba(40, 32, 20, 0.1);
    --color-autocomplete-background-hover: #f0ebe3;
    --color-autocomplete-font: #1a1816;
    --color-answer-background: #ffffff;
    --color-answer-font: #2a2724;
    --color-sidebar-background: #faf9f7;
    --color-sidebar-border: #e8e4dc;
    --color-sidebar-font: #2a2724;
    --color-show-btn-background: #ebe6dc;
    --color-show-btn-font: #2a2724;
  }
}

/* ---------- Base typography ---------- */
html {
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01" on, "cv11" on, "kern" on;
}

body {
  letter-spacing: -0.011em;
}

/* ---------- Search chrome ---------- */
#search,
#search_header,
#search_view {
  font-family: var(--font-ui);
}

#search_form input[type="text"],
#q,
input#q {
  font-family: var(--font-ui) !important;
  font-size: var(--text-md) !important;
  font-weight: 400;
  letter-spacing: -0.015em;
  border-radius: var(--radius-md) !important;
}

#categories,
#categories label,
.category {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Slightly softer search bar shadow already via tokens */
#search_form {
  border-radius: var(--radius-md);
}

/* ---------- Results list: clear hierarchy ---------- */
/* Text results only — image galleries use full width (see below) */
#results:not(.only_template_images) #urls {
  max-width: 46rem;
}

.result {
  margin: var(--space-result-gap) 0 !important;
  padding: var(--space-result-y) 0.65rem !important;
  border-left: 2px solid transparent !important;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.result:hover {
  background: color-mix(in srgb, var(--color-result-vim-selected) 65%, transparent);
}

.result[data-vim-selected],
article.result[data-vim-selected] {
  border-left-color: var(--color-result-vim-arrow) !important;
  background: var(--color-result-vim-selected);
}

/* URL line — quiet, precise */
.result .url_wrapper,
.result .url_header {
  font-family: var(--font-ui);
  font-size: var(--text-xs) !important;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: var(--leading-tight);
  color: var(--color-result-url-font);
  opacity: 0.92;
  margin-bottom: 0.15rem;
}

.result .favicon {
  border-radius: 3px;
}

/* Title — Inter, clear weight, no muddy bold */
.result h3 {
  font-family: var(--font-ui) !important;
  font-size: var(--text-lg) !important;
  line-height: var(--leading-tight) !important;
  margin: 0.2rem 0 0.28rem !important;
  letter-spacing: -0.02em;
}

.result h3 a {
  font-family: var(--font-ui) !important;
  font-size: 1em !important;
  font-weight: 500 !important;
  color: var(--color-result-link-font);
  text-decoration: none;
  text-underline-offset: 0.14em;
  text-decoration-thickness: 1px;
}

.result h3 a:hover,
.result h3 a:focus {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}

/* Snippet — Literata, the reading experience */
.result .content,
.result .stat {
  font-family: var(--font-read) !important;
  font-size: var(--text-sm) !important;
  line-height: var(--leading-read) !important;
  max-width: 42rem !important;
  color: var(--color-base-font);
  opacity: 0.92;
  margin-top: 0.1rem !important;
  font-optical-sizing: auto;
}

.result .content .highlight,
.result .stat .highlight {
  font-weight: 600 !important;
  color: var(--color-result-description-highlight-font) !important;
  background: transparent !important;
}

.result .content.empty_element {
  font-style: italic;
  opacity: 0.55;
  font-family: var(--font-read);
}

/* Meta row: engines, dates */
.result .engines,
.result .published_date,
.result .result_length,
.result .result_views,
.result .result_author,
.result .result_shipping,
.result .result_source_country {
  font-family: var(--font-ui);
  font-size: var(--text-xs) !important;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.result .engines {
  opacity: 0.75;
  margin-top: 0.35rem;
}

/* Answers / infoboxes */
#answers,
.answer,
#infoboxes,
.infobox {
  font-family: var(--font-ui);
  border-radius: var(--radius-md);
}

.answer,
#answers .answer {
  font-family: var(--font-read);
  font-size: var(--text-base);
  line-height: var(--leading-read);
  padding: 0.9rem 1rem !important;
}

#infoboxes .title,
.infobox h2,
.infobox .title {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Sidebar */
#sidebar {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

#sidebar .title,
#sidebar summary {
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Suggestions chips */
#suggestions a,
.suggestion {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-pill);
}

/* Pagination */
#pagination,
#pagination input,
#pagination button {
  font-family: var(--font-ui);
  font-weight: 500;
  border-radius: var(--radius-sm);
}

/* Footer */
footer,
footer p {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  opacity: 0.8;
}

/* Top nav links */
#links_on_top a {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Preferences tables */
#main_preferences,
.preferences_page {
  font-family: var(--font-ui);
}

#main_preferences h2,
#main_preferences legend {
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Index / home title */
.index .title,
#main_index .title {
  letter-spacing: -0.03em;
}

/* Code / packages */
.result-packages .attributes,
.code-highlight,
pre,
code {
  font-family: var(--font-mono);
}

/* Image result captions */
.result-images span.title,
.result-images span.source {
  font-family: var(--font-ui);
  font-weight: 500;
}

/* Video titles */
.result-videos h3 a {
  font-weight: 500;
}

/* Slightly tighter page column for reading focus when centered */
.center-alignment-yes #main_results #results:not(.only_template_images, .image-detail-open) {
  /* keep layout; typography does the work */
}

/* Autocomplete polish */
.autocomplete,
ul.autocomplete {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Buttons */
input[type="submit"],
#results button[type="submit"],
.button,
button {
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
}

/* Mobile: keep readable measure, slightly less padding */
@media screen and (max-width: 50em) {
  html {
    font-size: 15.5px;
  }
  .result {
    padding: 0.75rem 0.35rem !important;
  }
  .result h3 {
    font-size: 1.1rem !important;
  }
  #urls {
    max-width: 100%;
  }
}

/* Selection color — subtle brand tint */
::selection {
  background: color-mix(in srgb, var(--color-result-link-font) 22%, transparent);
  color: inherit;
}

/* ============================================================
   Category tabs (General / Images / Map / …)
   Pill chips instead of thin underlines — calm, scannable
   ============================================================ */

#categories,
.search_categories {
  font-family: var(--font-ui);
  font-size: 100%;
  margin-top: 0.15rem;
}

#categories_container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.4rem;
  position: relative;
}

/* Shared chip base */
.category_checkbox,
.category_button,
button.category_button,
.category.category_checkbox,
.category.category_button {
  margin: 0 !important;
  padding: 0 !important;
  display: inline-flex !important;
  position: relative;
  vertical-align: middle;
  width: auto !important;
}

.category_checkbox label,
button.category_button,
.category_button {
  font-family: var(--font-ui) !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  letter-spacing: -0.01em;
  text-transform: capitalize;
  line-height: 1.2;
  color: var(--color-base-font) !important;
  background: color-mix(in srgb, var(--color-base-font) 5.5%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--color-base-font) 9%, transparent) !important;
  border-bottom: 1px solid color-mix(in srgb, var(--color-base-font) 9%, transparent) !important;
  border-radius: 999px !important;
  padding: 0.38rem 0.78rem 0.38rem 0.62rem !important;
  margin: 0 !important;
  gap: 0.35rem;
  align-items: center;
  display: inline-flex !important;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: none !important;
  transition:
    background-color 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.12s ease;
  opacity: 0.88;
}

/* Icons — always visible, calm weight */
.category_checkbox label svg,
button.category_button svg,
.category svg {
  display: inline-block !important;
  width: 0.95rem !important;
  height: 0.95rem !important;
  min-width: 0.95rem;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
  opacity: 0.72;
  transition: opacity 0.14s ease;
}

.category_checkbox label div.category_name,
button.category_button .category_name,
.category_name {
  margin: 0 !important;
  white-space: nowrap;
}

/* Hover */
.category_checkbox label:hover,
button.category_button:hover {
  background: color-mix(in srgb, var(--color-base-font) 9%, transparent) !important;
  border-color: color-mix(in srgb, var(--color-base-font) 16%, transparent) !important;
  opacity: 1;
  color: var(--color-base-font) !important;
}

.category_checkbox label:hover svg,
button.category_button:hover svg {
  opacity: 0.9;
}

/* Selected / active — soft filled pill, no harsh underline */
.category_checkbox input[type="checkbox"]:checked + label,
button.category_button.selected,
button.category_button:active,
button.category_button.selected:hover {
  color: var(--color-categories-item-selected-font) !important;
  background: color-mix(in srgb, var(--color-categories-item-selected-font) 12%, transparent) !important;
  border-color: color-mix(in srgb, var(--color-categories-item-selected-font) 32%, transparent) !important;
  border-bottom-color: color-mix(in srgb, var(--color-categories-item-selected-font) 32%, transparent) !important;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--color-categories-item-selected-font) 10%, transparent) !important;
  opacity: 1;
  font-weight: 600 !important;
}

.category_checkbox input[type="checkbox"]:checked + label svg,
button.category_button.selected svg {
  opacity: 1;
  color: var(--color-categories-item-selected-font);
}

/* Focus ring for keyboard */
.category_checkbox label:focus-visible,
button.category_button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-categories-item-selected-font) 55%, transparent);
  outline-offset: 2px;
}

/* Kill stock no-js selected underline reset weirdness */
.no-js #categories_container:has(button.category_button:focus-within) button.category_button.selected {
  color: var(--color-base-font) !important;
  border: 1px solid color-mix(in srgb, var(--color-base-font) 9%, transparent) !important;
  background: color-mix(in srgb, var(--color-base-font) 5.5%, transparent) !important;
}

.no-js #categories_container:has(button.category_button:focus-within) button.category_button:focus-within {
  color: var(--color-categories-item-selected-font) !important;
  background: color-mix(in srgb, var(--color-categories-item-selected-font) 12%, transparent) !important;
  border-color: color-mix(in srgb, var(--color-categories-item-selected-font) 32%, transparent) !important;
}

/* Index homepage — slightly larger chips under the search box */
.index .category label,
#main_index .category_checkbox label,
#main_index button.category_button {
  padding: 0.42rem 0.9rem 0.42rem 0.7rem !important;
  border-bottom: 1px solid color-mix(in srgb, var(--color-base-font) 9%, transparent) !important;
}

#main_index #categories,
#main_results #categories {
  overflow: auto hidden;
  scrollbar-width: thin;
  text-align: left;
  padding: 0.15rem 0 0.35rem;
}

/* Mobile: keep icons + compact pills (stock hid icons & used huge padding) */
@media screen and (max-width: 50em) {
  .category svg,
  .category_checkbox label svg,
  button.category_button svg {
    display: inline-block !important;
  }

  .category_checkbox label,
  button.category_button,
  .category_button {
    padding: 0.4rem 0.72rem 0.4rem 0.58rem !important;
    margin: 0 !important;
    font-size: 0.8rem !important;
  }

  #categories_container {
    gap: 0.3rem;
    width: max-content;
    min-width: 100%;
  }
}

/* Preferences category chips — same language */
#main_preferences .category label {
  border-radius: 999px !important;
  border: 1px solid color-mix(in srgb, var(--color-base-font) 12%, transparent) !important;
  padding: 0.28rem 0.65rem !important;
  font-family: var(--font-ui);
  font-weight: 500;
  background: color-mix(in srgb, var(--color-base-font) 4%, transparent);
}

#main_preferences .category input[type="checkbox"]:checked + label {
  border-color: color-mix(in srgb, var(--color-categories-item-border-selected) 55%, transparent) !important;
  background: color-mix(in srgb, var(--color-categories-item-selected-font) 12%, transparent);
  color: var(--color-categories-item-selected-font);
}


/* ============================================================
   Image results — full-width centered masonry-ish flex grid
   (stock + Clarity text max-width left them jammed left)
   ============================================================ */

#main_results #results.only_template_images {
  width: 100% !important;
  max-width: none !important;
  margin: 1rem auto 0 !important;
  padding: 0 1.25rem;
  box-sizing: border-box;
  justify-self: stretch;
  align-self: stretch !important;
  grid-template-columns: 100% !important;
}

.center-alignment-yes #main_results #results.only_template_images,
.center-alignment-yes #main_results #results.only_template_images.image-detail-open {
  align-self: stretch !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

#main_results #results.only_template_images #urls {
  max-width: none !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 0.25rem 0 1rem;
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 0.45rem;
}

/* stock uses :after flex-grow:10 to fill last row left-aligned; neutralize */
#main_results #results.only_template_images #urls::after {
  content: none !important;
  display: none !important;
  flex-grow: 0 !important;
}

#main_results #results.only_template_images .result-images,
#urls .result-images {
  margin: 0 !important;
  border-radius: 12px;
  overflow: hidden;
  flex: 1 1 14rem;
  max-width: 22rem;
  min-width: 12rem;
  height: 26rem;
}

#main_results #results.only_template_images .result-images img.image_thumbnail,
#urls .result-images img.image_thumbnail {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center 30%;
}

/* When detail pane is open, keep gallery usable but not weirdly left */
#main_results #results.only_template_images.image-detail-open {
  width: min(98%, 100%) !important;
  max-width: none !important;
}

#main_results #results.only_template_images #pagination {
  margin: 1rem auto 2rem;
  text-align: center;
  width: 100%;
}

@media screen and (max-width: 50em) {
  #main_results #results.only_template_images {
    padding: 0 0.5rem;
    margin-top: 0.5rem !important;
  }
  #main_results #results.only_template_images .result-images {
    max-width: 48%;
    min-width: 46%;
    flex: 1 1 46%;
    height: 22rem;
  }
}

@media screen and (min-width: 90em) {
  #main_results #results.only_template_images {
    padding: 0 2rem;
  }
}


/* ============================================================
   Atmosphere + homepage hero + chrome polish
   ============================================================ */

html {
  min-height: 100%;
}

body {
  background-color: var(--color-base-background);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -18%,
      color-mix(in srgb, var(--color-url-font) 11%, transparent),
      transparent 62%),
    radial-gradient(ellipse 55% 45% at 100% 110%,
      color-mix(in srgb, var(--color-result-link-font) 8%, transparent),
      transparent 58%);
  background-attachment: fixed;
}

/* Quiet top links */
#links_on_top a {
  opacity: 0.78;
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.55rem;
}
#links_on_top a:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--color-base-font) 6%, transparent);
}

/* ---------- Homepage ---------- */
/* Stock hides the h1 and paints a PNG wordmark on .title — replace with type */
#main_index {
  margin-top: 0 !important;
  min-height: calc(100dvh - 5.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#main_index .index {
  width: min(42rem, 92vw);
  margin: 0 auto;
  padding: 1.5rem 0 3.5rem;
  text-align: center;
}

.index .title {
  background: none !important;
  background-image: none !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 auto 0.15rem !important;
}

.index h1,
.index .title h1 {
  visibility: visible !important;
  position: static !important;
  font-family: var(--font-ui) !important;
  font-weight: 600 !important;
  font-size: clamp(2.2rem, 5vw, 3.2rem) !important;
  letter-spacing: -0.055em;
  line-height: 1.05;
  color: var(--color-base-font) !important;
  -webkit-text-fill-color: var(--color-base-font) !important;
  background: none !important;
  margin: 0 0 0.35rem !important;
}

.index .title h1 .mark {
  color: var(--color-url-font) !important;
  -webkit-text-fill-color: var(--color-url-font) !important;
}

.index .title::after {
  content: none !important;
  display: none !important;
}

.clarity-tagline {
  display: block;
  font-family: var(--font-read);
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.3;
  color: var(--color-base-font);
  opacity: 0.58;
  margin: 0 0 1.7rem;
}

#main_index #search,
#main_index #search_header,
#main_index #search_view {
  width: 100%;
}

#main_index .search_box {
  min-height: 3.35rem;
  border-radius: 14px !important;
  border: 1px solid var(--color-search-border) !important;
  box-shadow: var(--color-search-shadow) !important;
  background: var(--color-search-background) !important;
  overflow: hidden;
}

#main_index #q,
#main_index input#q {
  font-size: 1.12rem !important;
  padding-inline: 1.15rem 0.4rem !important;
}

#main_index .search_box:focus-within {
  border-color: color-mix(in srgb, var(--color-categories-item-selected-font) 45%, var(--color-search-border)) !important;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--color-categories-item-selected-font) 16%, transparent),
    var(--color-search-shadow) !important;
}

#main_index #send_search,
#main_index #clear_search {
  border-radius: 10px !important;
}

/* Results-page search bar: same language, slightly tighter */
#main_results .search_box {
  border-radius: 12px !important;
  border: 1px solid var(--color-search-border) !important;
  box-shadow: 0 1px 2px rgba(40, 32, 20, 0.04) !important;
  background: var(--color-search-background) !important;
}

#main_results .search_box:focus-within {
  border-color: color-mix(in srgb, var(--color-categories-item-selected-font) 40%, var(--color-search-border)) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-categories-item-selected-font) 14%, transparent) !important;
}

#search_logo {
  opacity: 0.88;
}
#search_logo:hover {
  opacity: 1;
}

/* ---------- Category chips: never clip names ---------- */
#categories,
.search_categories {
  overflow: visible !important;
}

#categories_container {
  flex-wrap: wrap !important;
  overflow: visible !important;
  width: 100% !important;
  min-width: 0 !important;
}

.category_checkbox label,
button.category_button,
.category_button {
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
  overflow: visible !important;
}

.category_name {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
  max-width: none !important;
}

/* ---------- Engine badges ---------- */
.result .engines {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
}

.result .engines span {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.48rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-base-font) 6%, transparent);
  color: var(--color-result-engines-font);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

/* ---------- Infobox / answers ---------- */
#infoboxes .infobox,
.infobox {
  border: 1px solid var(--color-sidebar-border);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--color-base-font) 4%, transparent);
  overflow: hidden;
}

#answers .answer,
.answer {
  border: 1px solid var(--color-sidebar-border);
  background: var(--color-answer-background);
}

/* ---------- Footer ---------- */
footer {
  opacity: 0.72;
}
#main_index ~ footer,
body.index_endpoint footer {
  opacity: 0.55;
}

/* Dark atmosphere: cooler glows, keep charcoal ground */
:root.theme-dark body,
:root.theme-auto body,
.theme-dark body,
.theme-auto body {
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -15%,
      color-mix(in srgb, var(--color-url-font) 14%, transparent),
      transparent 60%),
    radial-gradient(ellipse 50% 40% at 0% 100%,
      color-mix(in srgb, var(--color-result-link-font) 10%, transparent),
      transparent 55%);
}

@media (prefers-color-scheme: light) {
  :root.theme-auto body,
  .theme-auto body {
    background-image:
      radial-gradient(ellipse 90% 55% at 50% -18%,
        color-mix(in srgb, var(--color-url-font) 11%, transparent),
        transparent 62%),
      radial-gradient(ellipse 55% 45% at 100% 110%,
        color-mix(in srgb, var(--color-result-link-font) 8%, transparent),
        transparent 58%);
  }
}

@media screen and (max-width: 80em) {
  #main_index {
    margin-top: 0 !important;
  }
}

@media screen and (max-width: 50em) {
  #main_index {
    min-height: calc(100dvh - 6.5rem);
    justify-content: flex-start;
    padding-top: 12vh;
    margin-top: 0 !important;
  }
  .index h1,
  .index .title h1 {
    font-size: 2.25rem !important;
  }
  #categories_container {
    flex-wrap: nowrap !important;
    width: max-content !important;
    min-width: 100% !important;
  }
  #categories {
    overflow: auto hidden !important;
    scrollbar-width: thin;
  }
}

@media (prefers-reduced-motion: reduce) {
  .result,
  .category_checkbox label,
  button.category_button {
    transition: none !important;
  }
}
