:root {
  --bg: #f6f7f9; --card: #fff; --text: #16202b; --muted: #5b6875; --line: #dde2e8; --accent: #0b6e99;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #10161d; --card: #1a232d; --text: #e8edf2; --muted: #9aa7b4; --line: #2a3541; --accent: #5cc0e6; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
header, main, footer { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 28px; }
h1 { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.2; }
h1 span { color: var(--muted); font-weight: 400; font-size: 1.1rem; margin-left: 6px; }
nav { display: flex; gap: 6px; margin: 10px 0 14px; border-bottom: 1px solid var(--line); }
nav a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header p { margin: 0 0 16px; color: var(--muted); max-width: 70ch; }
header p span, footer span { display: block; }
#filter {
  width: 100%; max-width: 420px; padding: 10px 12px; font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
#filter:focus-visible, .card a:focus-visible, button:focus-visible, .bar a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
#controls #filter { flex: 1 1 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .sort select {
  font: inherit; font-size: 0.9rem; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; min-height: 40px; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.sort select { border-radius: 8px; max-width: 100%; }
.sort select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#shown { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
#none { margin-top: 16px; }
#cards {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card[hidden] { display: none; }
.card a {
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.card a:hover { border-color: var(--accent); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.length {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px;
  background: rgb(0 0 0 / 0.8); color: #fff; font-size: 0.8rem; font-variant-numeric: tabular-nums;
}
.title {
  margin: 10px 12px 4px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.meta span { display: block; }
.meta { margin-top: auto; padding: 4px 12px 12px; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
footer { padding-top: 32px; padding-bottom: 32px; color: var(--muted); font-size: 0.875rem; }
dialog {
  width: min(1100px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 10px;
  background: #000; color: #fff; overflow: hidden;
}
dialog::backdrop { background: rgb(0 0 0 / 0.8); }
.frame { aspect-ratio: 16 / 9; max-height: calc(100vh - 90px); width: 100%; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: #16202b; }
.bar a { color: #9fd8f0; }
.bar button {
  font: inherit; color: #fff; background: #2a3541; border: 1px solid #4a5866; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; min-height: 40px;
}
