:root {
  --bg: #0f1115;
  --surface: #161a21;
  --surface-2: #1d222b;
  --text: #e6e8eb;
  --muted: #8a93a3;
  --accent: #7aa2ff;
  --border: #262c37;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #14171c;
    --muted: #5b6473;
    --accent: #2b59c3;
    --border: #e1e4ea;
    --shadow: 0 1px 2px rgba(20,23,28,.06), 0 8px 24px rgba(20,23,28,.06);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); font-weight: 400; }

.meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

#refresh {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
}
#refresh:hover { background: var(--surface-2); }

main.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 24px 28px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.preview {
  display: block;
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.preview iframe {
  position: absolute;
  inset: 0;
  width: 250%;
  height: 250%;
  border: 0;
  transform: scale(0.4);
  transform-origin: 0 0;
  pointer-events: none;
  background: white;
}
.preview-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 2;
}
.preview-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
  z-index: 1;
}
.fallback-host {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--text);
}
.card.no-preview .preview iframe { display: none; }
.card.no-preview .preview-fallback { display: flex; }

.body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

a.title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
a.title:hover { color: var(--accent); }

.desc {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.host {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

footer {
  padding: 14px 28px 28px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
footer code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
}
