/* Palette and layout mirror the design mock: neutral dark developer aesthetic,
   a single cyan accent, monospace for anything that represents machine output. */
:root {
  --bg: #0d0f11;
  --fg: #e6e8ea;
  --fg-dim: #c3cad2;
  --muted: #9aa4b0;
  --muted-2: #8a939e;
  --muted-3: #6b7480;
  --muted-4: #5a636e;
  --muted-5: #4e5661;
  --line: #1e2226;
  --line-2: #262b31;
  --line-3: #24292f;
  --panel: #111417;
  --panel-2: #121518;
  --panel-3: #16191d;
  --panel-4: #10141a;
  --rail: #1c2126;
  --accent: oklch(0.78 0.11 190);
  --accent-dim: oklch(0.5 0.08 190);
  --amber: oklch(0.8 0.13 75);
  --green: oklch(0.78 0.11 145);
  --red: oklch(0.75 0.15 30);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Motion: light on purpose — just enough to take the edge off state
     changes, never enough to make the demo feel animated. */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 140ms;
  --t-slow: 200ms;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes soft-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

/* `display:` rules on our own classes outrank the UA's [hidden] style,
   so make the attribute authoritative. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: oklch(0.88 0.09 190); }
::selection { background: oklch(0.78 0.11 190 / 0.3); }

.mono { font-family: var(--mono); }
.spacer { flex: 1; }
.hint { font-size: 10.5px; color: var(--muted-4); }
.label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-3); }

/* ---------- header ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: rgba(13, 15, 17, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted-3); }

.auth { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-4);
  transition: background-color var(--t-slow) var(--ease);
}
.dot.demo { background: var(--amber); }
.dot.live { background: var(--green); }
.dot.out { background: oklch(0.65 0.16 30); }
.auth-label { color: var(--muted); }
.auth-subject { color: var(--muted-3); }
.sep { color: var(--muted-4); }

.badge {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid oklch(0.5 0.09 75);
  background: oklch(0.3 0.05 75 / 0.35);
  padding: 4px 8px;
  border-radius: 3px;
}

.btn {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  color: var(--fg-dim);
  padding: 6px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition:
    border-color var(--t) var(--ease),
    background-color var(--t) var(--ease),
    color var(--t) var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { color: #454d57; cursor: default; }

.linkish {
  background: none;
  border: none;
  padding: 0;
  font-size: 10px;
  color: var(--muted-3);
  cursor: pointer;
  transition: color var(--t) var(--ease);
}
.linkish:hover { color: var(--fg); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  max-width: 1360px;
  margin: 0 auto;
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px 22px 60px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 74px;
}
.main {
  padding: 24px 28px 80px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* ---------- facets ---------- */
.facet-head { display: flex; flex-direction: column; gap: 10px; }
.facet-head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
#facets { display: flex; flex-direction: column; gap: 26px; }
.facet-group { display: flex; flex-direction: column; gap: 8px; }
.facet-field { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.facet-buckets { display: flex; flex-direction: column; gap: 1px; }
.bucket {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  transition:
    background-color var(--t) var(--ease),
    border-left-color var(--t) var(--ease);
}
.bucket:hover { background: var(--panel-3); }
.bucket.on { background: #151b1e; border-left-color: var(--accent); }
.bucket-value {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  transition: color var(--t) var(--ease);
}
.bucket.on .bucket-value { color: var(--fg); }
.bucket-count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- search ---------- */
.searchblock { display: flex; flex-direction: column; gap: 10px; }
.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  border-radius: 4px;
  padding: 0 12px;
  transition: border-color var(--t-slow) var(--ease);
}
.searchbar:focus-within { border-color: var(--accent-dim); }
.prefix { font-size: 12px; color: var(--muted-4); }
#q {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  padding: 12px 0;
}
.searching {
  font-size: 10.5px;
  color: var(--accent);
  animation: soft-pulse 1.2s var(--ease) infinite;
}
.reqline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 10.5px; }
.reqline .verb { color: var(--muted-3); }
.reqline .url { color: var(--muted); word-break: break-all; }

.resulthead {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.count { font-size: 13px; color: var(--muted); }
.count span { color: var(--fg); font-weight: 600; }

.banner {
  border: 1px solid oklch(0.45 0.12 30);
  background: oklch(0.25 0.06 30 / 0.4);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 11px;
  color: oklch(0.82 0.11 30);
  animation: panel-in 180ms var(--ease);
}
.empty {
  border: 1px dashed var(--line-2);
  border-radius: 4px;
  padding: 40px;
  text-align: center;
  color: var(--muted-3);
  font-size: 13px;
}

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 8px; }
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 4px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  transition:
    border-color var(--t-slow) var(--ease),
    background-color var(--t-slow) var(--ease);
  /* Tiny staggered entrance, only when the result list actually changes.
     --i is set per card by app.js and capped there. */
  animation: card-in 190ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.card:hover { border-color: var(--line-2); }
.card.active,
.card.active:hover { border-color: oklch(0.45 0.07 190); background: #101619; }

.play {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--mono);
  transition:
    border-color var(--t) var(--ease),
    background-color var(--t) var(--ease),
    color var(--t) var(--ease);
}
.play:hover { border-color: var(--accent); }
.card.active .play {
  border-color: var(--accent);
  background: oklch(0.78 0.11 190 / 0.14);
  color: oklch(0.85 0.1 190);
}

.card-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted-3); }
.card-desc {
  font-size: 12.5px;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail {
  height: 6px;
  border-radius: 3px;
  background: var(--rail);
  cursor: pointer;
  position: relative;
  margin-top: 2px;
  transition: background-color var(--t) var(--ease);
}
.rail:hover { background: #232a30; }
.rail-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  /* Linear, and a shade longer than the ~250ms timeupdate cadence, so the
     bar glides instead of stepping. */
  transition: width var(--t-slow) linear;
}
/* Suppress the glide when the position jumps (seek, track change). */
.rail-fill.jump { transition: none; }
.times {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-4);
  font-variant-numeric: tabular-nums;
}
.card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-4);
}
.tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; max-width: 240px; }
.tag {
  border: 1px solid var(--line-3);
  border-radius: 2px;
  padding: 2px 6px;
  color: #7d8792;
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.card:hover .tag { border-color: #2c333a; color: #8b959f; }
.storage-key { color: var(--muted-5); }

/* ---------- signed url panel ---------- */
.signed {
  border: 1px solid var(--line-3);
  background: var(--panel-4);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 11px;
  position: sticky;
  bottom: 12px;
  animation: panel-in var(--t-slow) var(--ease);
}
.signed-head { display: flex; align-items: center; gap: 10px; color: var(--muted-3); flex-wrap: wrap; }
.signed-head .ok { color: var(--green); }
.expiry { color: var(--amber); transition: color var(--t-slow) var(--ease); }
.expiry.gone { color: var(--red); }
.signed-url { color: var(--muted-2); word-break: break-all; line-height: 1.7; }
.signed-expired { color: var(--red); border-top: 1px solid var(--line-3); padding-top: 8px; }
.signed-foot { color: var(--muted-5); }
#player { width: 100%; height: 34px; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; gap: 8px; padding-top: 6px; flex-wrap: wrap; }
.pages { display: flex; gap: 8px; }
.page {
  font-family: var(--mono);
  font-size: 11px;
  min-width: 32px;
  text-align: center;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted-2);
  padding: 7px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition:
    border-color var(--t) var(--ease),
    background-color var(--t) var(--ease),
    color var(--t) var(--ease);
}
.page:hover { border-color: #3a424b; }
.page.on { border-color: var(--accent-dim); background: oklch(0.78 0.11 190 / 0.12); color: var(--fg); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .card { grid-template-columns: 40px minmax(0, 1fr); }
  .card-side { display: none; }
}
