:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e3e6ec;
  --text: #1d2433;
  --muted: #5a6477;
  --accent: #2a5cff;
  --accent-soft: #e9efff;
  --shadow: 0 4px 20px rgba(20, 32, 60, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: background 120ms ease;
}

.brand:hover {
  background: var(--accent-soft);
}

.topbar .meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  background: #fc6d26;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  transition: background 120ms ease;
}

.repo-link:hover {
  background: #e24329;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: calc(100vh - 57px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar .group {
  padding: 6px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 8px;
}

.sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.sidebar a:hover {
  background: var(--accent-soft);
}

.sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar a .count {
  color: var(--muted);
  font-size: 11px;
}

.content {
  overflow-y: auto;
  padding: 24px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.content-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.download-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  border: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

.download-all-btn:hover:not(:disabled) {
  background: #1f4ae5;
}

.download-all-btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

.search-bar {
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card .thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #eef0f5 center/contain no-repeat;
}

.card .meta {
  padding: 10px 12px;
}

.card .name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
  word-break: break-word;
}

.card .sub {
  color: var(--muted);
  font-size: 11px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0b1020;
  color: #f0f3fb;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: zoom-out;
  z-index: 0;
}

.modal-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-titles {
  min-width: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.modal-subtitle {
  color: rgba(240, 243, 251, 0.6);
  font-size: 12px;
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.version-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(240, 243, 251, 0.7);
}

.version-control select {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f3fb;
  min-width: 200px;
}

.version-control select option {
  color: #1d2433;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #f0f3fb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease;
}

.modal-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.modal-image-wrap {
  position: relative;
  z-index: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1020;
  padding: 24px 64px;
}

.modal-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f0f3fb;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-50%) scale(1.05);
}

.modal-nav:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: translateY(-50%);
}

.modal-nav-prev {
  left: 16px;
}

.modal-nav-next {
  right: 16px;
}

.modal-footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(240, 243, 251, 0.6);
}

.empty {
  color: var(--muted);
  padding: 40px;
  text-align: center;
}
