:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --muted: #667085; --line: #e4e7ec;
  --accent: #1f6feb; --accent-soft: #e8f0fe; --warn: #b54708; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --panel: #171b21; --text: #e6e8eb; --muted: #98a2b3; --line: #2a3038;
          --accent: #5b9dff; --accent-soft: #1b2a40; --warn: #f79009; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center;
       padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
#q { flex: 1; max-width: 560px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
#toggleFilters { display: none; }

.layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 20px; max-width: 1500px; margin: 0 auto; }
.filters { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow: auto;
           background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.filters h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.filters section { margin-bottom: 16px; }
.filters select { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.checks label { display: block; margin: 4px 0; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.chip small { color: var(--muted); margin-left: 3px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on small { color: #dbe7ff; }

button.ghost { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button.primary { border: 0; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px 18px; cursor: pointer; }
.wide { width: 100%; }

.listHead { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text);
        display: flex; flex-direction: column; transition: transform .1s, box-shadow .1s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.thumb { aspect-ratio: 1 / 1; background: #fff; display: grid; place-items: center; position: relative; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: contain; }
.thumb .noimg { color: #98a2b3; font-size: 13px; }
.badge { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 999px; }
.badge.instr { right: auto; left: 8px; background: #12b76a; }
.card .body { padding: 10px 12px; }
.card .name { font-weight: 600; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.more { text-align: center; margin: 22px 0; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* detail */
.back { display: inline-block; margin-bottom: 12px; }
.detailGrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; }
.player { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.player video, .player img { width: 100%; display: block; max-height: 70vh; object-fit: contain; background: #fff; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 4px; font-size: 24px; }
.panel h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sub { color: var(--muted); margin-bottom: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
a.tag:hover { filter: brightness(.95); }
.tag.syn { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.instr ol { padding-left: 20px; margin: 0 0 10px; }
.instr li { margin-bottom: 6px; }
.instr .mist li::marker { content: "✕  "; color: var(--warn); }
.instr .tip { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; }
.pending { color: var(--muted); font-style: italic; }
.similar { margin-top: 26px; }
.similar h3 { margin: 0 0 10px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .filters { display: none; position: static; max-height: none; }
  .filters.open { display: block; }
  #toggleFilters { display: inline-block; }
  .detailGrid { grid-template-columns: 1fr; }
  .brand { font-size: 16px; }
}
