:root {
  --bg: #0e0e10;
  --fg: #e6e6e6;
  --muted: #8a8a90;
  --accent: #ff8d3b;
  --score: #60a5fa;
  --card: #17171a;
  --border: #2a2a30;
  --ok: #58c468;
  --bad: #d05151;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafaf7;
    --fg: #1a1a1c;
    --muted: #6b6b72;
    --card: #ffffff;
    --border: #e2e2dc;
    --score: #1e3a8a;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.25rem;
}

.site-header .gcse-search,
.site-header > div[id^="___gcse_"] {
  max-width: 880px;
  margin: 0 auto;
}

/* Google CSE theme overrides — match the rest of the site */
.gsc-control-cse,
.gsc-search-box,
.gsc-input-box,
table.gsc-search-box td.gsib_a,
table.gsc-search-box td.gsib_b {
  background: var(--bg) !important;
  border-color: var(--border) !important;
}

.gsc-control-cse,
.gsc-search-box {
  padding: 0 !important;
  border: 0 !important;
}

.gsc-input-box {
  border: 1px solid var(--border) !important;
  border-radius: 6px;
}

input.gsc-input,
.gsc-input-box input.gsc-input {
  background: var(--bg) !important;
  color: var(--fg) !important;
  font-family: var(--sans) !important;
  text-indent: 0 !important;
}

input.gsc-input::placeholder { color: var(--muted) !important; }

/* Search and clear buttons */
button.gsc-search-button-v2,
button.gsc-search-button {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

button.gsc-search-button-v2:hover {
  background: var(--border) !important;
}

button.gsc-search-button-v2 svg {
  fill: var(--fg) !important;
}

/* Clear "x" inside the input */
.gsst_a .gscb_a { color: var(--muted) !important; }

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

/* tabs */
.tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.25rem;
}

.tab {
  background: none;
  border: 0;
  padding: 0.6rem 0.1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover { color: var(--fg); }

.tab.is-active {
  color: var(--fg);
  border-bottom-color: var(--score);
}

.pane { display: none; }
.pane.is-active { display: block; }

/* aggregated feed */
.agg-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agg-item {
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.agg-item:first-child { border-top: none; }

.agg-title {
  color: var(--fg);
  text-decoration: none;
}

.agg-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.agg-sep {
  color: var(--muted);
  margin: 0 0.5rem;
  vertical-align: middle;
}

.agg-domain,
.agg-date {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

/* leaderboard */
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-item {
  position: relative;
  isolation: isolate;
}

.rank-item + .rank-item {
  border-top: 1px solid var(--border);
}

.rank-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--rank-bg, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: -1;
}

.rank-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
  text-decoration: none;
}

.rank-content {
  position: relative;
  z-index: 2;
  pointer-events: none;
  display: grid;
  grid-template-columns: 2.4rem 32px 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.9rem 0.25rem;
}

.rank-item:hover::before {
  opacity: 0.22;
}

.rank-num {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

.rank-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: block;
  object-fit: contain;
  background: var(--card);
}

.rank-icon--blank { background: var(--border); }

.rank-body { min-width: 0; }

.rank-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.rank-rss {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.rank-rss:hover {
  opacity: 1;
}

.rank-rss img {
  display: block;
  width: 18px;
  height: 18px;
}

.rank-domain {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--score);
  font-weight: 600;
  text-decoration: none;
  pointer-events: auto;
}

.rank-score:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.rank-name {
  font-size: 0.95rem;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* site detail */
.back {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  margin: 0 0 1.5rem;
}

.back:hover { color: var(--fg); }

.site-detail__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 640px) {
  .site-detail__header {
    grid-template-columns: 280px 1fr;
  }
}

.site-detail__shot {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  aspect-ratio: 1280 / 800;
  object-fit: cover;
  background: var(--card);
}

.site-detail__shot--blank { background: var(--card); }

.site-detail__head h1 {
  font-family: var(--mono);
  font-size: 1.9rem;
  margin: 0 0 0.25rem;
  line-height: 1.15;
}

.site-detail__domain {
  color: inherit;
  text-decoration: none;
}

.site-detail__domain:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-detail__name {
  margin: 0;
  color: var(--fg);
}

.site-detail__cat {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.site-detail__score {
  font-family: var(--mono);
  font-size: 2.4rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
  font-weight: 600;
  line-height: 1;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0 0;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.metric-card h3 {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  color: var(--muted);
}

.metric-card h3 a {
  color: inherit;
  text-decoration: none;
}

.metric-card h3 a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.metric-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.metric-card dt { color: var(--muted); }
.metric-card dd { margin: 0; text-align: right; }

.metric-card dt a {
  color: inherit;
  text-decoration: none;
}

.metric-card dt a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* backlinks page */
.backlinks-h1 {
  font-family: var(--mono);
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
  word-break: break-word;
  line-height: 1.3;
}

.backlinks-sub {
  color: var(--muted);
  margin: 0 0 2rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.backlinks-list {
  margin: 0;
  padding-left: 2.5em;
}

.backlinks-list li {
  margin-bottom: 0.35rem;
}

.backlinks-list a {
  color: var(--fg);
  text-decoration: none;
}

.backlinks-list a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.backlinks-ext {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.backlinks-sep {
  color: var(--muted);
  margin: 0 0.4rem;
}

.backlinks-article {
  color: var(--muted) !important;
}

/* feed page */
.feed-h1 {
  font-family: var(--sans);
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
  word-break: break-word;
}

.feed-sub {
  color: var(--muted);
  margin: 0 0 2rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.feed-raw {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed-list li {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.85rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.feed-list li:first-child { border-top: none; }

.feed-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.feed-title {
  color: var(--fg);
  text-decoration: none;
}

.feed-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
