:root {
  --bg: #e8eaed;
  --modal: #ffffff;
  --border: #e3e5e8;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #0061fe;
  --accent-soft: #e8f0fe;
  --hover: #f4f5f7;
  --pill: #eef0f3;
  --shadow: 0 16px 48px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
}

.library-bg {
  position: fixed; inset: 0; z-index: 0;
}
.poster-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  padding: 72px 40px 40px;
  height: 100%;
}
.poster {
  border-radius: 10px;
  background: linear-gradient(145deg, #c5c9d0, #9aa1ad);
  opacity: 0.55;
  min-height: 180px;
  position: relative;
}
.poster:nth-child(2n) { background: linear-gradient(145deg, #b8bcc6, #8b93a1); }
.poster:nth-child(3n) { background: linear-gradient(160deg, #aeb4c0, #7d8696); }
.poster span {
  position: absolute; bottom: 10px; left: 10px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
}
.bg-blur {
  position: absolute; inset: 0;
  backdrop-filter: blur(18px);
  background: rgba(232, 234, 237, 0.55);
}

.chrome {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  pointer-events: none;
}
.chrome > * { pointer-events: auto; }
.wordmark { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.open-search {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.open-search kbd {
  margin-left: 8px;
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--pill);
  border-radius: 4px;
  padding: 3px 5px;
  color: var(--muted);
}
.build-chip {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; color: var(--muted);
}

.modal-root {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 24px;
  background: rgba(15, 23, 42, 0.28);
}
.modal-root.closed { display: none; }

.dash-modal {
  width: min(760px, 100%);
  max-height: min(640px, 76vh);
  background: var(--modal);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}

.dash-search-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.dash-search-row .ico { color: var(--muted); flex-shrink: 0; }
.dash-search-row input {
  flex: 1; border: 0; outline: none; font: inherit; font-size: 16px;
  background: transparent; color: var(--text);
}
.dash-search-row kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); background: var(--pill);
  border-radius: 4px; padding: 4px 6px;
}

.scope-row {
  display: flex; gap: 6px; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.chip {
  border: 0; background: var(--pill); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12px;
  font-weight: 500; cursor: pointer;
}
.chip.on { background: var(--accent-soft); color: var(--accent); }

.dash-body {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  min-height: 0; flex: 1;
}
.results-pane { overflow: auto; border-right: 1px solid var(--border); }
.preview-pane { overflow: auto; background: #fafbfc; padding: 16px; }

.section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  margin: 14px 16px 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; }
.chips .chip { background: #fff; border: 1px solid var(--border); }

.hit {
  width: 100%; display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px; align-items: start;
  text-align: left; border: 0; background: transparent;
  padding: 10px 16px; cursor: pointer; font: inherit; color: inherit;
  border-bottom: 1px solid #f0f1f3;
}
.hit:hover, .hit.sel { background: var(--hover); }
.hit.sel { background: var(--accent-soft); }
.hit-ico {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--pill); display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
}
.hit-main { min-width: 0; }
.hit-line { font-size: 13.5px; color: var(--text); }
.hit-line mark {
  background: transparent; color: inherit; font-weight: 700;
}
.hit-sub { margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--pill); border-radius: 4px; padding: 2px 6px;
}
.hit-t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 4px; }
.empty { padding: 24px 16px; color: var(--muted); }

.preview-empty { color: var(--muted); font-size: 13px; padding-top: 40px; text-align: center; }
.preview-content.hidden, .hidden { display: none !important; }
.preview-player {
  aspect-ratio: 16/9; border-radius: 8px;
  background: #1f2937; display: flex; align-items: center; justify-content: center;
  position: relative; margin-bottom: 12px;
}
.play-tiny {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,0.92); cursor: pointer; font-size: 12px;
}
.preview-ts {
  position: absolute; bottom: 8px; right: 8px;
  font-size: 11px; color: #fff; background: rgba(0,0,0,0.55);
  border-radius: 4px; padding: 2px 6px;
}
.preview-quote { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.preview-meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn-primary, .btn-ghost {
  border-radius: 7px; font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 12px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }

.snip-modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(15,23,42,0.4);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.snip-card {
  background: #fff; border-radius: 12px; padding: 22px;
  width: min(400px, 100%); box-shadow: var(--shadow);
}
.snip-card h2 { font-size: 16px; margin-bottom: 8px; }
.modal-quote { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.durations, .formats { display: flex; gap: 6px; }
.durations button, .formats button {
  flex: 1; border: 1px solid var(--border); background: #fff;
  border-radius: 7px; padding: 8px; font: inherit; cursor: pointer;
}
.durations button.on, .formats button.on {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 40; box-shadow: var(--shadow);
}

@media (max-width: 700px) {
  .dash-body { grid-template-columns: 1fr; }
  .preview-pane { display: none; }
  .results-pane { border-right: 0; }
}
