:root {
  --bg: #0f1117;
  --panel: #161922;
  --panel-2: #1e2331;
  --text: #e6e8ee;
  --muted: #8a92a6;
  --accent: #6ea8ff;
  --accent-2: #b6f0a8;
  --warn: #f0c674;
  --bad: #ff7a7a;
  --line: #262b3a;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body { background: var(--bg); color: var(--text); }
img, video, iframe { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 0 4px; border-radius: 4px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.brand .emoji { font-size: 1.3rem; margin-right: 4px; }
.topbar nav a { margin-left: 16px; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
footer { padding: 32px 24px; text-align: center; color: var(--muted); }

.hero h1 { margin: 0 0 8px; font-size: 1.8rem; }
.hero p { color: var(--muted); margin: 0 0 24px; }

h2 { font-size: 1.2rem; margin: 32px 0 12px; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.grid { display: grid; gap: 16px; }
.grid.releases { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.records { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  background: var(--panel); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  display: block; color: var(--text); transition: border-color 0.1s, transform 0.1s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }

.release .big { font-size: 1.3rem; font-weight: 600; }

.thumb-wrap { position: relative; }
.record img { width: 100%; height: 140px; object-fit: cover; border-radius: 4px; background: var(--panel-2); }
.record .thumb-placeholder {
  width: 100%; height: 140px; background: var(--panel-2); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  font-size: 2.5rem;
}
.record .title { margin-top: 8px; font-size: 0.95rem; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.type-badge {
  position: absolute; top: 6px; right: 6px;
  padding: 3px 8px; border-radius: 4px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(0,0,0,0.7); color: #fff;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}
.type-badge.type-pdf   { background: rgba(220, 60, 60, 0.85); }
.type-badge.type-video { background: rgba(110, 168, 255, 0.85); }
.type-badge.type-audio { background: rgba(182, 240, 168, 0.85); color: #0f1117; }
.type-badge.type-image { background: rgba(240, 198, 116, 0.85); color: #0f1117; }
.type-badge.type-other { background: rgba(138, 146, 166, 0.85); }

.local-heading {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 8px; font-size: 1rem; font-weight: 500; color: var(--muted);
}
.local-heading .type-badge { position: static; font-size: 0.8rem; padding: 4px 10px; }

/* Snapshot history list */
.snap-list { list-style: none; padding: 0; margin: 16px 0; }
.snap-row { margin-bottom: 8px; }
.snap-link {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text);
}
.snap-link:hover { border-color: var(--accent); text-decoration: none; }
.snap-row.snap-nofile .snap-link { opacity: 0.55; }
.snap-icon .type-badge { position: static; }
.snap-main { flex: 1 1 auto; min-width: 0; }
.snap-title { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.snap-action { flex: 0 0 auto; }

/* Snapshot detail */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.records-table { min-width: 640px; }
.records-table td, .records-table th { white-space: nowrap; }
.records-table td:nth-child(2) { white-space: normal; min-width: 280px; }
.code-block {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; max-height: 70vh; overflow: auto; font-size: 0.8rem;
  white-space: pre; -webkit-overflow-scrolling: touch;
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.filters input, .filters select, .filters button, .filters .reset {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 12px; border-radius: 4px; font: inherit;
  min-height: 44px;
}
/* Mobile-first: search input gets its own full-width row, the rest sits below */
.filters input  { flex: 1 1 100%; min-width: 0; }
.filters select { flex: 1 1 auto; }
.filters button { cursor: pointer; flex: 0 0 auto; }
.filters button:hover { background: var(--line); }
.filters .reset { display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; text-decoration: none; }

@media (min-width: 720px) {
  /* On desktop allow search to share its row with the controls */
  .filters input  { flex: 1 1 280px; }
  .filters select { flex: 0 1 180px; }
}

.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; margin-left: 4px; }
.badge.ok { background: rgba(110, 168, 255, 0.15); color: var(--accent); }
.badge.pending { background: rgba(240, 198, 116, 0.15); color: var(--warn); }
.badge.fail { background: rgba(255, 122, 122, 0.15); color: var(--bad); }

.pager { display: flex; gap: 16px; justify-content: center; margin: 32px 0; align-items: center; }

.rss { list-style: none; padding: 0; }
.rss li { padding: 12px 0; border-bottom: 1px solid var(--line); }

.status { width: 100%; border-collapse: collapse; }
.status th, .status td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; font-weight: normal; }
.status th { color: var(--muted); font-size: 0.85rem; }

.record-detail { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 24px; margin: 16px 0; }
.record-detail.no-thumb { grid-template-columns: 1fr; }
.record-detail img { width: 100%; border-radius: 4px; }
.btn {
  display: inline-block; background: var(--accent); color: var(--bg);
  padding: 10px 16px; border-radius: 6px; font-weight: 500;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.pdf-viewer { display: block; width: 100%; max-width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; background: white; }
.image-viewer { display: block; width: auto; max-width: 100%; max-height: 85vh; margin: 16px auto 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); object-fit: contain; }
.video-viewer { display: block; width: 100%; max-width: 100%; max-height: 85vh; height: auto; margin: 16px auto 0; border: 1px solid var(--line); border-radius: var(--radius); background: black; object-fit: contain; }

@media (max-width: 640px) {
  .record-detail { grid-template-columns: 1fr; }
}
