/* Sorweb: shared look in the Sorrel brand colors (forest greens, copper fox, peach).
   Light and dark themes follow the device unless picked in Settings. */
:root {
  --bg: #f2f5ee;
  --bg-glow-1: rgba(255, 127, 78, 0.2);
  --bg-glow-2: rgba(156, 196, 136, 0.32);
  --bg-glow-3: rgba(255, 198, 158, 0.3);
  --surface: #ffffff;
  --surface-2: #e9efe4;
  --surface-3: #dbe4d4;
  --text: #0e1913;
  --text-2: #2b3a31;
  --muted: #536459;
  --border: #dbe3d5;
  --border-strong: #c3cfbd;
  --accent: #cb532e;
  --accent-hover: #b4441f;
  --accent-soft: rgba(203, 83, 46, 0.1);
  --leaf: #3f7a4c;
  --leaf-soft: rgba(63, 122, 76, 0.12);
  --link: #9a4421;
  --link-visited: #6e4a7a;
  --ring: rgba(255, 127, 78, 0.35);
  --spot: rgba(255, 127, 78, 0.08);
  --on-accent: #ffffff;
  --shadow-sm: 0 1px 2px rgba(14, 25, 19, 0.06);
  --shadow: 0 8px 28px rgba(14, 25, 19, 0.08), 0 1px 3px rgba(14, 25, 19, 0.06);
  --shadow-lg: 0 22px 60px rgba(14, 25, 19, 0.18);
  --header-bg: rgba(242, 245, 238, 0.78);
  --firefly: rgba(203, 83, 46, 0.5);
  --radius: 14px;
  --radius-lg: 22px;
  --indent: 214px; /* lines results up with the search box */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a130e;
    --bg-glow-1: rgba(255, 127, 78, 0.16);
    --bg-glow-2: rgba(35, 68, 52, 0.75);
    --bg-glow-3: rgba(203, 83, 46, 0.12);
    --surface: #10221a;
    --surface-2: #1a3426;
    --surface-3: #234434;
    --text: #e9f0e6;
    --text-2: #c6d4c6;
    --muted: #98ae9f;
    --border: #1d3427;
    --border-strong: #2c4a39;
    --accent: #ff7f4e;
    --accent-hover: #ff9468;
    --accent-soft: rgba(255, 127, 78, 0.13);
    --leaf: #9cc488;
    --leaf-soft: rgba(156, 196, 136, 0.13);
    --link: #ffb184;
    --link-visited: #e0b3d4;
    --ring: rgba(255, 127, 78, 0.38);
    --spot: rgba(255, 127, 78, 0.1);
    --on-accent: #1c0c05;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.6);
    --header-bg: rgba(10, 19, 14, 0.76);
    --firefly: rgba(255, 198, 158, 0.85);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a130e;
  --bg-glow-1: rgba(255, 127, 78, 0.16);
  --bg-glow-2: rgba(35, 68, 52, 0.75);
  --bg-glow-3: rgba(203, 83, 46, 0.12);
  --surface: #10221a;
  --surface-2: #1a3426;
  --surface-3: #234434;
  --text: #e9f0e6;
  --text-2: #c6d4c6;
  --muted: #98ae9f;
  --border: #1d3427;
  --border-strong: #2c4a39;
  --accent: #ff7f4e;
  --accent-hover: #ff9468;
  --accent-soft: rgba(255, 127, 78, 0.13);
  --leaf: #9cc488;
  --leaf-soft: rgba(156, 196, 136, 0.13);
  --link: #ffb184;
  --link-visited: #e0b3d4;
  --ring: rgba(255, 127, 78, 0.38);
  --spot: rgba(255, 127, 78, 0.1);
  --on-accent: #1c0c05;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.6);
  --header-bg: rgba(10, 19, 14, 0.76);
  --firefly: rgba(255, 198, 158, 0.85);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Logo */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex: none; }
.logo > svg { width: 34px; height: 34px; flex: none; }
.logo .word { font-family: var(--font-display); font-weight: 750; font-size: 1.3rem; letter-spacing: -0.03em; white-space: nowrap; }
.logo .word .accent { color: var(--accent); }

/* Icon buttons */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* Search box with suggestions */
.searchbox { position: relative; width: 100%; }
.searchbox form {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 5px 5px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.searchbox form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring), var(--shadow); }
.searchbox.open form { border-radius: 24px 24px 0 0; box-shadow: var(--shadow); }
.searchbox .lead-icon { width: 18px; height: 18px; color: var(--muted); flex: none; }
.searchbox input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.05rem;
  padding: 9px 6px;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox .clear { width: 34px; height: 34px; border-radius: 50%; }
.searchbox .go {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  flex: none;
  transition: background 0.15s, transform 0.1s;
}
.searchbox .go:hover { background: var(--accent-hover); }
.searchbox .go:active { transform: scale(0.95); }
.searchbox .go svg { width: 20px; height: 20px; }
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 6px 0 8px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-top: 1px solid var(--border);
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.suggest li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  cursor: pointer;
  color: var(--text-2);
}
.suggest li svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.suggest li .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li .label b { color: var(--text); font-weight: 650; }
.suggest li .hint { font-size: 0.8rem; color: var(--muted); flex: none; }
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.suggest .remove { width: 28px; height: 28px; border-radius: 8px; }
.suggest .section-title { padding: 6px 20px 2px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); cursor: default; }
.suggest .section-title:hover { background: none; }
.suggest .section-title button { margin-left: auto; border: 0; background: none; color: var(--accent); font-size: 0.75rem; text-transform: none; letter-spacing: 0; padding: 0; }

/* Settings panel */
dialog.settings {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
dialog.settings::backdrop { background: rgba(10, 5, 5, 0.45); backdrop-filter: blur(3px); }
.settings header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 24px; }
.settings h2 { margin: 0; font-size: 1.2rem; }
.settings .body { padding: 6px 24px 24px; display: grid; gap: 18px; }
.settings label.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
.settings .hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-size: 0.88rem; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 650; }
.select {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2385706a' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding: 10px 34px 10px 12px;
}
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.toggle input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; cursor: pointer; transition: background 0.15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.toggle input:checked { background: var(--leaf); }
.toggle input:checked::after { transform: translateX(18px); }

/* ---------- Homepage ---------- */
.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.home-top { display: flex; justify-content: flex-end; gap: 4px; padding: 14px 16px; }
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6vh 16px 40px; }

.hero .logo .word { font-size: clamp(2.4rem, 8vw, 3.6rem); }
.hero .logo { margin-bottom: 10px; animation: rise 0.6s ease-out both; }
.hero .lede { margin: 0 0 30px; color: var(--muted); font-size: 1.05rem; text-align: center; animation: rise 0.6s 0.08s ease-out both; }
.hero .searchbox { max-width: 640px; animation: rise 0.6s 0.14s ease-out both; }
.hero .searchbox form { padding: 7px 7px 7px 22px; box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; max-width: 640px; animation: rise 0.6s 0.2s ease-out both; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.87rem;
  color: var(--text-2);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); font-weight: 650; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; max-width: 900px; margin-top: 9vh; animation: rise 0.6s 0.28s ease-out both; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.feature .dot { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--leaf-soft); color: var(--leaf); margin-bottom: 12px; }
.feature .dot svg { width: 20px; height: 20px; }
.feature h3 { margin: 0 0 4px; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.home-foot { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 20px 16px 28px; }
.home-foot kbd, .kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.78rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Results page ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .row { display: flex; align-items: center; gap: 20px; padding: 12px 24px 6px; }
.topbar .searchbox { max-width: 680px; }
.topbar .actions { margin-left: auto; display: flex; gap: 2px; }
.tabs-row { display: flex; align-items: center; gap: 16px; padding: 0 24px 0 var(--indent); overflow-x: auto; scrollbar-width: none; }
.tabs-row::-webkit-scrollbar { display: none; }
.tabs { display: flex; gap: 4px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px 11px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 550;
  text-decoration: none;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; gap: 8px; margin-left: auto; }
.filter {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2385706a' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border-radius: 999px;
  padding: 5px 28px 5px 12px;
  font-size: 0.84rem;
  color: var(--text-2);
  cursor: pointer;
}
.filter.set { border-color: var(--accent); color: var(--accent); background-color: var(--accent-soft); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(0, 380px);
  gap: 48px;
  padding: 18px 24px 64px var(--indent);
}
.layout.wide { grid-template-columns: minmax(0, 1fr); padding-left: 24px; }
.main { min-width: 0; }
.side { min-width: 0; }
.notice { color: var(--muted); font-size: 0.9rem; margin: 2px 0 16px; }
.notice a { color: var(--link); font-weight: 600; }
.error-card { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px; }

/* Web result */
.result { position: relative; padding: 14px 16px; margin: 0 -16px 6px; border-radius: var(--radius); transition: background 0.15s; animation: fade 0.35s ease-out both; }
.result.kb-active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.result .source { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 4px; }
.favicon { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; flex: none; overflow: hidden; }
.favicon img { width: 16px; height: 16px; }
.favicon .letter { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.source .meta { min-width: 0; line-height: 1.25; }
.source .name { font-size: 0.88rem; color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .path { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result h3 { margin: 0 0 4px; font-size: 1.2rem; font-weight: 550; line-height: 1.3; }
.result h3 a { color: var(--link); text-decoration: none; }
.result h3 a:visited { color: var(--link-visited); }
.result h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Makes the whole card clickable */
.result h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.result .body { display: flex; gap: 16px; }
.result .text { flex: 1; min-width: 0; }
.result p { margin: 0; color: var(--text-2); font-size: 0.95rem; overflow-wrap: anywhere; }
.result p strong { color: var(--text); font-weight: 650; }
.result .extra { margin-top: 4px; font-size: 0.88rem; color: var(--muted); }
.result .age { color: var(--muted); }
.result .thumb { width: 104px; height: 74px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.sitelinks { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sitelinks a { font-size: 0.83rem; color: var(--link); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; background: var(--surface); }
.sitelinks a:hover { border-color: var(--link); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Sections inside results (news, videos, discussions, FAQ) */
.block { margin: 10px 0 26px; animation: fade 0.35s ease-out both; }
.block-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1.02rem; font-weight: 700; }
.block-title svg { width: 18px; height: 18px; color: var(--accent); }
.block-title a { margin-left: auto; font-size: 0.85rem; font-weight: 600; color: var(--link); text-decoration: none; }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; scrollbar-width: thin; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  scroll-snap-align: start;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card .media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.card .media img { width: 100%; height: 100%; object-fit: cover; }
.card .duration, .row-card .duration { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 0.75rem; font-weight: 650; padding: 2px 6px; border-radius: 6px; }
.card .play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 0.15s; }
.card:hover .play { opacity: 1; }
.card .play span { width: 46px; height: 46px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; }
.card .play svg { width: 20px; height: 20px; color: #fff; margin-left: 3px; }
.card .info { padding: 10px 12px 12px; display: grid; gap: 4px; }
.card .title { font-size: 0.92rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .by { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.card .by img { width: 14px; height: 14px; border-radius: 3px; }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--on-accent); background: var(--accent); border-radius: 5px; padding: 1px 6px; }

.discussions { display: grid; gap: 10px; }
.discussion { position: relative; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
.discussion:hover { border-color: var(--border-strong); }
.discussion .forum { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.discussion .title { font-weight: 600; color: var(--link); margin: 3px 0; }
.discussion .snippet { font-size: 0.9rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq .answer { padding: 0 16px 14px; color: var(--text-2); font-size: 0.93rem; }
.faq .answer a { color: var(--link); font-size: 0.85rem; }

/* Instant answer (calculator) */
.instant { background: linear-gradient(135deg, var(--accent-soft), var(--leaf-soft)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 20px; animation: fade 0.35s ease-out both; }
.instant .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 650; }
.instant .expr { color: var(--text-2); font-size: 1rem; margin-top: 6px; overflow-wrap: anywhere; }
.instant .value { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 750; letter-spacing: -0.02em; overflow-wrap: anywhere; }

/* Info panel */
.infobox { position: sticky; top: 128px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); animation: fade 0.35s ease-out both; }
.infobox .hero-img { width: 100%; max-height: 220px; object-fit: cover; background: var(--surface-2); }
.infobox .inner { padding: 18px 20px 20px; }
.infobox h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.01em; }
.infobox .sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.infobox .desc { color: var(--text-2); font-size: 0.93rem; margin: 12px 0 0; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.infobox .desc.full { -webkit-line-clamp: unset; }
.infobox .more { border: 0; background: none; color: var(--link); padding: 4px 0 0; font-size: 0.88rem; font-weight: 600; }
.infobox .src { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.infobox .src a { color: var(--link); }
.facts { margin: 16px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 0.88rem; border-top: 1px solid var(--border); padding-top: 14px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.profiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.profiles a { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px 4px 6px; font-size: 0.82rem; text-decoration: none; color: var(--text-2); }
.profiles a:hover { border-color: var(--border-strong); }
.profiles img { width: 16px; height: 16px; border-radius: 4px; }
.website-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; background: var(--accent); color: var(--on-accent); text-decoration: none; border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 0.88rem; }
.website-btn:hover { background: var(--accent-hover); }

/* News and video lists (their own tabs) */
.list-grid { display: grid; gap: 14px; }
.row-card { position: relative; display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s; animation: fade 0.35s ease-out both; }
.row-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.row-card.kb-active { box-shadow: 0 0 0 2px var(--accent); }
.row-card .media { position: relative; width: 180px; flex: none; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.row-card .media img { width: 100%; height: 100%; object-fit: cover; }
.row-card .text { min-width: 0; display: grid; gap: 4px; align-content: start; }
.row-card .title { font-weight: 650; font-size: 1.05rem; line-height: 1.3; color: var(--link); }
.row-card .desc { font-size: 0.9rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row-card .by { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-card .by img { width: 14px; height: 14px; border-radius: 3px; }

/* Images */
.image-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.image-grid::after { content: ""; flex-grow: 999; }
.tile {
  position: relative;
  height: 190px;
  flex-grow: 1;
  border: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  animation: fade 0.35s ease-out both;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.tile:hover img { transform: scale(1.04); }
.tile .cap { position: absolute; inset: auto 0 0 0; padding: 22px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.72)); color: #fff; font-size: 0.76rem; text-align: left; opacity: 0; transition: opacity 0.2s; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; }
.lightbox {
  border: 0;
  padding: 0;
  margin: auto;
  width: min(1000px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 4, 4, 0.82); backdrop-filter: blur(4px); }
.lightbox .frame { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.lightbox .stage { position: relative; background: #0d0a0a; display: grid; place-items: center; min-height: 320px; max-height: calc(100vh - 24px); }
.lightbox .stage img { max-width: 100%; max-height: calc(100vh - 24px); object-fit: contain; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; display: grid; place-items: center; }
.lightbox .nav:hover { background: rgba(255, 255, 255, 0.26); }
.lightbox .nav svg { width: 22px; height: 22px; }
.lightbox .prev { left: 12px; }
.lightbox .next { right: 12px; }
.lightbox aside { padding: 18px 20px 22px; display: grid; gap: 10px; align-content: start; }
.lightbox aside .close { justify-self: end; margin: -6px -8px 0 0; }
.lightbox aside h2 { margin: 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.lightbox aside .dim { color: var(--muted); font-size: 0.85rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 10px 16px; font-weight: 600; font-size: 0.9rem; text-decoration: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: background 0.15s, border-color 0.15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn svg { width: 16px; height: 16px; }

/* Load more, loading and empty states */
.more-wrap { display: flex; justify-content: center; margin: 22px 0 0; }
.more-wrap .btn { min-width: 200px; }
.skeleton { margin: 0 0 22px; }
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
.sk.line { height: 12px; margin: 8px 0; }
.sk.title { height: 20px; width: 62%; margin: 8px 0 10px; }
.sk.circle { width: 28px; height: 28px; border-radius: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--leaf); opacity: 0.6; }
.empty h2 { color: var(--text); margin: 0 0 6px; font-size: 1.25rem; }
.credit { color: var(--muted); font-size: 0.8rem; margin-top: 36px; display: flex; gap: 14px; flex-wrap: wrap; }
.credit kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.74rem; border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1180px) {
  .tabs-row { padding-left: 24px; }
  .layout { padding-left: 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 32px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { order: -1; }
  .infobox { position: static; }
  .infobox .desc { -webkit-line-clamp: 4; }
  .features { grid-template-columns: 1fr; max-width: 520px; margin-top: 7vh; }
  .lightbox .frame { grid-template-columns: 1fr; }
  .lightbox .stage { max-height: 60vh; }
  .lightbox .stage img { max-height: 60vh; }
}
@media (max-width: 640px) {
  .topbar .row { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px 4px; }
  .topbar .searchbox { order: 3; flex-basis: 100%; }
  .topbar .logo .word { font-size: 1.15rem; }
  .tabs-row { padding: 0 16px; gap: 10px; }
  .filters .filter { font-size: 0.8rem; }
  .layout, .layout.wide { padding: 14px 16px 48px; }
  .result { margin: 0 -10px 4px; padding: 12px 10px; }
  .result h3 { font-size: 1.08rem; }
  .result .thumb { width: 76px; height: 56px; }
  .row-card { flex-direction: column; }
  .row-card .media { width: 100%; }
  .tile { height: 120px; }
  .carousel { grid-auto-columns: 72%; }
  .hero { padding-top: 4vh; }
}

/* ---------- The fox and motion ---------- */
.fox { display: block; width: 100%; height: auto; aspect-ratio: 1; overflow: visible; }
.logo .fox-wrap { width: 40px; flex: none; transform-origin: 50% 90%; transition: transform 0.4s var(--ease-spring); }
.logo:hover .fox-wrap { transform: translateY(-4px) rotate(-6deg); }
.logo .word .ch { display: inline-block; }

/* Drifting glow behind every page, plus fireflies (placed by app.js) */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.aurora i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.9; will-change: transform; }
.aurora i:nth-child(1) { width: 52vw; height: 52vw; left: -12vw; top: -22vw; background: var(--bg-glow-1); animation: drift-a 26s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 60vw; height: 60vw; right: -18vw; top: -8vw; background: var(--bg-glow-2); animation: drift-b 32s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { width: 46vw; height: 46vw; left: 22vw; bottom: -30vw; background: var(--bg-glow-3); animation: drift-c 28s ease-in-out infinite alternate; }
.results-page .aurora i { opacity: 0.45; }
@keyframes drift-a { to { transform: translate(14vw, 10vh) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-12vw, 14vh) scale(0.9); } }
@keyframes drift-c { to { transform: translate(-10vw, -12vh) scale(1.2); } }
.firefly { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--firefly); box-shadow: 0 0 10px 2px var(--firefly); opacity: 0; animation: firefly var(--d, 9s) ease-in-out var(--delay, 0s) infinite; }
@keyframes firefly {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20% { opacity: 0.9; }
  50% { opacity: 0.35; transform: translate(var(--dx, 30px), var(--dy, -40px)); }
  80% { opacity: 0.8; }
}

/* Homepage fox: trots in, settles, breathes, hops now and then, perks up while you type and dashes off when you search */
.hero-fox { position: relative; width: clamp(110px, 16vw, 150px); margin-bottom: 4px; }
.hero-fox .runner { animation: fox-arrive 1.25s var(--ease-out) both; }
.hero-fox .body { transform-origin: 50% 100%; animation: fox-trot 0.16s ease-in-out 7 alternate, fox-idle 6s ease-in-out 1.3s infinite; }
.hero-fox .shadow { position: absolute; left: 18%; right: 6%; bottom: -2px; height: 10px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.22), transparent); animation: fox-shadow 6s ease-in-out 1.3s infinite; }
.hero-fox.perk .body { animation: fox-perk 0.45s var(--ease-spring); }
.hero-fox.dash .runner { animation: fox-dash 0.5s cubic-bezier(0.5, 0, 0.9, 0.4) forwards; }
.hero-fox.dash .body { animation: fox-trot 0.1s ease-in-out infinite alternate; }
@keyframes fox-arrive { from { transform: translateX(-46vw); } to { transform: none; } }
@keyframes fox-trot { from { transform: translateY(0) rotate(0); } to { transform: translateY(-7px) rotate(-3deg); } }
@keyframes fox-idle {
  0%, 70%, 100% { transform: scale(1, 1); }
  35% { transform: scale(1.015, 1.035); }
  82% { transform: translateY(-16px) scale(0.98, 1.04) rotate(-4deg); }
  88% { transform: translateY(0) scale(1.04, 0.95); }
  92% { transform: scale(1, 1); }
}
@keyframes fox-shadow { 0%, 70%, 100% { transform: scaleX(1); opacity: 1; } 82% { transform: scaleX(0.7); opacity: 0.5; } 88% { transform: scaleX(1.06); opacity: 1; } }
@keyframes fox-perk { 0% { transform: none; } 40% { transform: translateY(-10px) rotate(-5deg) scale(1.03); } 100% { transform: none; } }
@keyframes fox-dash { 0% { transform: none; } 15% { transform: translateX(-12px) scaleX(-1); } 100% { transform: translateX(60vw) scaleX(-1); opacity: 0; } }

/* Wordmark: letters spring up one after another */
.hero .logo { flex-direction: column; gap: 0; margin-bottom: 8px; animation: none; }
.hero .logo .word { font-size: clamp(3rem, 10vw, 4.6rem); letter-spacing: -0.045em; line-height: 1; }
.hero .logo .word .ch { animation: letter-in 0.7s var(--ease-spring) both; animation-delay: calc(0.55s + var(--i) * 0.06s); }
.hero .logo .word .ch:hover { animation: letter-wiggle 0.5s var(--ease-spring); color: var(--accent); }
@keyframes letter-in { from { opacity: 0; transform: translateY(0.5em) rotate(8deg) scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes letter-wiggle { 30% { transform: translateY(-0.12em) rotate(-6deg); } 60% { transform: translateY(0.03em) rotate(3deg); } }
.hero .lede { animation-delay: 0.85s; }
.hero .searchbox { animation-delay: 0.95s; }
.chips { animation-delay: 1.05s; }
.features { animation-delay: 1.15s; }

/* Search box: a copper light runs around the edge while it's in use */
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.searchbox form { position: relative; isolation: isolate; }
.searchbox form::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--spin), transparent 0 55%, var(--accent) 75%, var(--leaf) 88%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity 0.3s;
  animation: spin 3.2s linear infinite;
  pointer-events: none;
}
.searchbox form:focus-within::before { opacity: 1; }
.searchbox.open form::before { opacity: 0; }
@keyframes spin { to { --spin: 360deg; } }
.searchbox .go { transition: background 0.15s, transform 0.25s var(--ease-spring); }
.searchbox .go:hover { transform: rotate(-12deg) scale(1.06); }

/* Progress: a little fox runs along the top while results load */
.loading-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 3px; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.loading-bar.on { opacity: 1; }
.loading-bar .track { position: absolute; inset: 0; background: linear-gradient(90deg, var(--leaf), var(--accent), #ffc69e); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform 0.4s var(--ease-out); }
.loading-bar .mini-fox { position: absolute; top: 2px; left: 0; width: 26px; transform: translateX(calc(var(--p, 0) * (100vw - 30px))) scaleX(-1); transition: transform 0.4s var(--ease-out); }
.loading-bar .mini-fox .fox { animation: fox-trot 0.12s ease-in-out infinite alternate; }

/* Sliding tab underline */
.tabs { position: relative; }
.tabs .ink { position: absolute; bottom: 0; left: 0; height: 2.5px; border-radius: 2px; background: var(--accent); width: var(--w, 0); transform: translateX(var(--x, 0)); transition: transform 0.35s var(--ease-out), width 0.35s var(--ease-out); }
.tabs.has-ink .tab[aria-current="page"] { border-bottom-color: transparent; }

/* Cards light up where the pointer is */
.result::before, .row-card::before, .card::before, .discussion::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--spot), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.result:hover::before, .row-card:hover::before, .card:hover::before, .discussion:hover::before { opacity: 1; }
.result, .row-card, .card, .discussion, .tile { animation-delay: calc(min(var(--i, 0), 12) * 45ms); }

/* Empty and error states: the fox wanders */
.empty .wander { position: relative; height: 90px; overflow: hidden; margin: 0 auto 10px; max-width: 420px; }
.empty .wander .fox-wrap { position: absolute; bottom: 0; left: 0; width: 80px; animation: wander 9s linear infinite; }
.empty .wander .fox { animation: fox-trot 0.16s ease-in-out infinite alternate; }
@keyframes wander {
  0% { transform: translateX(-90px) scaleX(-1); }
  48% { transform: translateX(430px) scaleX(-1); }
  50% { transform: translateX(430px) scaleX(1); }
  98% { transform: translateX(-90px) scaleX(1); }
  100% { transform: translateX(-90px) scaleX(-1); }
}

/* Header fox perks up when results arrive */
.topbar .fox-wrap.wake { animation: fox-perk 0.5s var(--ease-spring); }

/* "by Sorrel" under the homepage wordmark */
.hero .logo .byline { font-family: var(--font-display); font-size: clamp(0.95rem, 2.4vw, 1.15rem); font-weight: 600; color: var(--muted); letter-spacing: 0.02em; margin-top: 6px; animation: letter-in 0.7s var(--ease-spring) 1s both; }
.hero .logo .byline .accent { color: var(--accent); }
