* { box-sizing: border-box; }

:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-header: #171a21;
  --border: #262a35;
  --text: #e6e8ee;
  --text-dim: #c7cdd8;
  --text-muted: #9aa3b2;
  --accent: #6ea8ff;
  --star: #f5c518;
  --star-off: #3a4152;
  --input-bg: #1f2430;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --border: #e3e6ec;
  --text: #1a1d23;
  --text-dim: #4b5563;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --star: #f59e0b;
  --star-off: #d4d7dd;
  --input-bg: #ffffff;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

.header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
h1 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; word-break: break-all; }
.x-link { color: var(--accent); text-decoration: none; font-size: 14px; flex: none; }
.x-link:hover { text-decoration: underline; }

.header-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wf-link { color: var(--accent); text-decoration: none; font-size: 14px; }
.wf-link:hover { text-decoration: underline; }

.filters { display: flex; gap: 14px; flex-wrap: wrap; }
.filters label, .ctrl { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-dim); }
.ctrl { font-size: 13px; }

select, button {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}
button { cursor: pointer; }

.ctrl input[type="range"] { width: 90px; cursor: pointer; }
.zoom-value { color: var(--text); min-width: 14px; text-align: center; }

.count { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

.meta-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.meta { color: var(--text-muted); font-size: 12px; }

.info-wrap { position: relative; display: inline-flex; }
.info-btn {
  padding: 0 7px;
  height: 22px;
  line-height: 1;
  border-radius: 50%;
  font-size: 13px;
  color: var(--text-muted);
}
.info-pop {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 560px;
  max-width: 85vw;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  z-index: 100;
}
.info-wrap:hover .info-pop { display: block; }
.info-pop pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  max-height: 60vh;
  overflow: auto;
}

.cta {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

main#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-title {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.card video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; }

.rating { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rate-row { display: flex; align-items: center; gap: 8px; }
.rate-label { width: 92px; font-size: 11px; line-height: 1.25; color: var(--text-muted); flex: none; }

.stars { display: inline-flex; gap: 2px; }
.star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  color: var(--star-off);
  padding: 0;
  transition: color .1s;
}
.star.on { color: var(--star); }
.stars.locked .star { cursor: default; }

.avg { margin-left: auto; font-size: 12px; color: var(--star); white-space: nowrap; }
