:root {
  color-scheme: dark;
  --bg: #16161c;
  --card: #22222c;
  --line: #343442;
  --text: #f2f2f4;
  --muted: #9a9aaa;
  --on: #3d6bff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 20px 12px;
  background: rgba(22, 22, 28, 0.96);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 20px;
}

.sub, .count {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

#search {
  width: min(480px, 100%);
  margin-top: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101014;
  color: var(--text);
  font-size: 14px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.filter-label {
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

button.on {
  background: var(--on);
  border-color: var(--on);
}

#master-sync {
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}

#master-sync:active {
  transform: translateY(1px) scale(0.96);
  background: var(--on);
  border-color: var(--on);
}

#master-sync.syncing {
  background: var(--on);
  border-color: var(--on);
  animation: sync-pulse 0.7s ease-in-out infinite;
}

@keyframes sync-pulse {
  50% { background: #1c4fd4; }
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #343442;
  position: relative;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
}

.switch input:checked + .switch-track {
  background: var(--on);
}

.switch input:checked + .switch-track::after {
  left: 18px;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--on);
  outline-offset: 2px;
}

#more {
  height: 1px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 20px 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.frame {
  position: relative;
}

.ue-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: #2f6fed;
  color: white;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.thumb, .empty {
  width: 100%;
  aspect-ratio: 1;
  background: #2a2a34;
  object-fit: contain;
}

.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.meta {
  padding: 8px 10px 10px;
}

.name {
  margin: 0;
  font-size: 14px;
  word-break: break-all;
}

.where, .path {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}
