:root {
  color-scheme: light dark;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #eef1ea;
  --surface-3: #e5e9df;
  --text: #151a17;
  --muted: #5c665f;
  --faint: #7d8780;
  --line: #d6dbd3;
  --line-strong: #bbc4bc;
  --accent: #067a55;
  --accent-ink: #ffffff;
  --accent-soft: #d8f3e6;
  --focus: #078b60;
  --warning: #9a5b00;
  --shadow: 0 22px 60px rgba(25, 35, 28, .09);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1110;
    --surface: #141917;
    --surface-2: #1a211e;
    --surface-3: #222b27;
    --text: #f1f5f0;
    --muted: #a8b1aa;
    --faint: #7d8a82;
    --line: #2b3530;
    --line-strong: #3b4942;
    --accent: #5ce0aa;
    --accent-ink: #082116;
    --accent-soft: #153b2c;
    --focus: #6df0b9;
    --warning: #f0b964;
    --shadow: 0 30px 90px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  font-family: Manrope, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent); outline-offset: 2px; }

.page {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  margin-bottom: 26px;
}
.masthead h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.15rem, 5vw, 4.5rem);
  line-height: .98;
  letter-spacing: -.055em;
  font-weight: 650;
  text-wrap: balance;
}
.masthead p {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}
.health {
  position: relative;
  align-self: start;
  padding-top: 3px;
  color: var(--muted);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .72rem;
  white-space: nowrap;
}
.health summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0 7px 8px;
  cursor: pointer;
  list-style: none;
}
.health summary::-webkit-details-marker { display: none; }
.health summary::after {
  content: "?";
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--faint);
  font-size: .6rem;
}
.health-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
}
.health-dot.up {
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.health-dot.down {
  background: var(--warning);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--warning) 18%, transparent);
}
.health-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 5px);
  right: 0;
  width: 250px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  font: .72rem/1.55 Manrope, -apple-system, "Segoe UI", sans-serif;
  white-space: normal;
}
.health:not([open]) .health-popover { display: none; }
.health:hover .health-popover,
.health:focus-within .health-popover { display: block; }

.app-shell {
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.search-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
}
.mode-tabs {
  display: flex;
  border-right: 1px solid var(--line);
}
.mode-tab {
  position: relative;
  min-width: 100px;
  border: 0;
  padding: 0 22px;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}
.mode-tab[aria-selected="true"] { background: var(--surface-2); }
.mode-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 20px; right: 20px; bottom: -1px;
  height: 3px;
  background: var(--accent);
}
.query-wrap {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
}
.search-icon {
  width: 21px; height: 21px;
  margin-left: 21px;
  flex: 0 0 auto;
  color: var(--faint);
}
#query {
  width: 100%;
  min-width: 0;
  height: 72px;
  border: 0;
  padding: 0 18px;
  background: transparent;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 560;
}
#query::placeholder { color: var(--faint); }
#query:focus { outline: 0; }
.shortcut {
  margin-right: 16px;
  padding: 5px 8px;
  color: var(--faint);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font: 500 .68rem "DM Mono", ui-monospace, monospace;
}
.search-btn {
  min-width: 124px;
  margin: 11px;
  border: 0;
  padding: 0 22px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -.01em;
}
.search-btn:hover { filter: brightness(1.06); }
.search-btn:disabled { cursor: wait; opacity: .7; }

.recent-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.recent-strip[hidden] { display: none; }
.recent-label {
  flex: 0 0 auto;
  color: var(--faint);
  font: 500 .65rem "DM Mono", ui-monospace, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.recent-query {
  border: 1px solid var(--line);
  padding: 6px 9px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: .74rem;
  line-height: 1;
}
.recent-query:hover { border-color: var(--accent); color: var(--accent); }

.footnote {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 38px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font: .68rem/1.5 "DM Mono", ui-monospace, monospace;
}
.endpoint { color: var(--text); }
.docs-link {
  color: var(--accent);
  font-weight: 500;
  text-underline-offset: 3px;
}

.app-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 540px;
}
.filters {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}
.filter-toggle { display: none; }
.filter-group + .filter-group { margin-top: 28px; }
.label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font: 500 .7rem "DM Mono", ui-monospace, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.select, .text-field, .date-field {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 0 11px;
  background: var(--surface);
  color: var(--text);
}
.field-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: .74rem;
  line-height: 1.5;
}
.key-row { position: relative; }
.key-row .text-field { padding-right: 46px; }
.reveal-key {
  position: absolute;
  top: 1px; right: 1px;
  width: 40px; height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.platform-options { display: grid; gap: 10px; }
.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 35px;
  cursor: pointer;
  color: var(--muted);
  font-size: .87rem;
}
.check-row input {
  appearance: none;
  width: 17px; height: 17px; margin: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.check-row input:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface);
}
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.date-field { min-width: 0; padding: 0 7px; font-size: .75rem; }
.clear-btn {
  width: 100%;
  margin-top: 28px;
  border: 1px solid var(--line-strong);
  padding: 10px 12px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
}

.results {
  min-width: 0;
  padding: 28px clamp(22px, 4vw, 44px) 40px;
  background: var(--surface);
}
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.results-toolbar[hidden] { display: none; }
.result-count {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.timing { color: var(--faint); font: .72rem "DM Mono", ui-monospace, monospace; }
.results-list { display: grid; }
.result-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.result-card:first-child { border-top: 0; padding-top: 4px; }
.rank {
  padding-top: 4px;
  color: var(--faint);
  font: 500 .72rem "DM Mono", ui-monospace, monospace;
}
.result-domain {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--accent);
  font: 500 .7rem "DM Mono", ui-monospace, monospace;
}
.source-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.result-title {
  display: inline-block;
  margin: 0 0 7px;
  color: var(--text);
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.result-title:hover { color: var(--accent); }
.result-snippet {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.62;
  overflow-wrap: break-word;
}
.social-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 9px;
  color: var(--faint);
  font: .74rem "DM Mono", ui-monospace, monospace;
}
.platform-mark {
  font: 500 .67rem "DM Mono", ui-monospace, monospace;
  color: var(--faint);
}
.out-arrow {
  align-self: center;
  color: var(--faint);
  text-decoration: none;
  font-size: 1.2rem;
}
.out-arrow:hover { color: var(--accent); }
.empty-hint {
  padding: 48px 0;
  color: var(--faint);
  font-size: .9rem;
  text-align: center;
}
.empty-hint[hidden] { display: none; }

.notice {
  display: none;
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line));
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  font-size: .82rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}
.notice.show { display: block; }
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .page { width: min(100% - 24px, 720px); padding-top: 28px; }
  .masthead { grid-template-columns: 1fr; gap: 8px; }
  .health { order: -1; justify-self: start; }
  .health-popover { right: auto; left: 0; }
  .search-head { grid-template-columns: 1fr auto; }
  .mode-tabs { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--line); }
  .mode-tab { min-height: 50px; flex: 1; }
  .query-wrap { min-width: 0; }
  .search-btn { min-width: 96px; }
  .app-body { grid-template-columns: 1fr; }
  .filters { border-right: 0; border-bottom: 1px solid var(--line); }
  .filter-layout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .filter-group + .filter-group { margin-top: 0; }
  .clear-btn { margin-top: 18px; }
}

@media (max-width: 560px) {
  .page { width: 100%; padding: 12px 0 24px; }
  .masthead { gap: 4px; margin-bottom: 13px; padding: 0 16px; }
  .masthead h1 { max-width: 390px; font-size: clamp(1.72rem, 8vw, 2rem); line-height: 1.04; letter-spacing: -.045em; }
  .masthead p { max-width: 390px; margin-top: 8px; font-size: .8rem; line-height: 1.45; }
  .health { font-size: .66rem; }
  .health summary { padding: 3px 0; }
  .health-popover { top: calc(100% + 2px); width: min(260px, calc(100vw - 32px)); }
  .app-shell { border-left: 0; border-right: 0; }
  .app-body { min-height: 0; grid-template-rows: auto auto; }
  .search-head { grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
  .mode-tab { min-height: 42px; padding: 0 16px; font-size: .86rem; }
  .mode-tab[aria-selected="true"]::after { left: 16px; right: 16px; }
  .query-wrap { min-width: 0; }
  .search-icon { width: 18px; height: 18px; margin-left: 15px; }
  .shortcut { display: none; }
  #query { height: 54px; padding: 0 10px; font-size: .9rem; }
  .search-btn { min-width: 78px; height: 40px; margin: 7px 8px 7px 0; padding: 0 14px; font-size: .82rem; }
  .recent-strip { align-items: flex-start; gap: 8px; min-height: 0; padding: 8px 12px; }
  .recent-label { padding-top: 6px; font-size: .59rem; }
  .recent-list { gap: 5px; }
  .recent-query { padding: 5px 7px; font-size: .67rem; }
  .footnote { min-height: 34px; padding: 7px 12px; gap: 10px; font-size: .61rem; }
  .footnote .route-note { display: none; }
  .filters { padding: 0; }
  .filter-toggle {
    display: flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 0 14px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: .76rem;
    font-weight: 700;
  }
  .filter-toggle span { color: var(--faint); font: .62rem "DM Mono", ui-monospace, monospace; font-weight: 400; }
  .filter-toggle::after { content: "+"; color: var(--accent); font: 500 1rem "DM Mono", ui-monospace, monospace; }
  .filters.filters-open .filter-toggle::after { content: "−"; }
  .filter-content { display: none; padding: 2px 14px 16px; }
  .filters.filters-open .filter-content { display: block; }
  .filter-layout { grid-template-columns: 1fr; }
  .filter-group + .filter-group { margin-top: 16px; }
  .clear-btn { margin-top: 16px; }
  .results { padding: 17px 16px 26px; }
  .results-toolbar { gap: 10px; margin-bottom: 14px; }
  .result-count { flex-wrap: wrap; gap: 7px; font-size: .87rem; }
  .timing { font-size: .65rem; }
  .result-card { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 17px 0; }
  .result-title { font-size: .98rem; }
  .result-snippet { font-size: .82rem; line-height: 1.55; }
  .out-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
