:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde2e8;
  --text: #182230;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --green: #0e9f6e;
  --green-soft: #e7f8f1;
  --amber: #b7791f;
  --amber-soft: #fdf3dd;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  max-width: 1440px;
  min-height: 64px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  white-space: nowrap;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.primary-btn,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
}

.icon-btn:hover,
.primary-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

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

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e8ebef;
  border-radius: 10px;
}

.segment {
  height: 34px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segment-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.segment.active .segment-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.control-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.media {
  position: relative;
  display: grid;
  background: #10151d;
  border-bottom: 1px solid var(--border);
}

.media.compare {
  grid-template-columns: 1fr 34px 1fr;
}

.media.single {
  grid-template-columns: 1fr;
}

.media-slot {
  position: relative;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}

.media.compare .media-slot {
  aspect-ratio: 1 / 1;
}

.media.single .media-slot {
  aspect-ratio: 16 / 10;
}

.media-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.42));
  opacity: 0;
  transition: opacity 0.15s ease;
}

.media-slot:hover::after {
  opacity: 1;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #1c2430;
  color: #94a3b8;
  font-size: 12px;
}

.slot-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}

.compare-arrow {
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.compare-arrow svg {
  width: 16px;
  height: 16px;
}

.output-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: #272d37;
}

.output-stack .media-slot {
  aspect-ratio: 1 / 1;
}

.output-stack.many .media-slot {
  aspect-ratio: 16 / 10;
}

.output-more {
  display: grid;
  place-items: center;
  min-height: 40px;
  background: #272d37;
  color: #cbd5e1;
  font-size: 12px;
}

.status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-badge.done {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.done::before {
  background: var(--green);
}

.status-badge.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.pending::before {
  background: var(--amber);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.72);
  }
}

.card-body {
  padding: 14px 16px 16px;
}

.card-body h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.meta-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-block {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.state-block p {
  margin: 0;
}

.state-block svg {
  width: 24px;
  height: 24px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.primary-btn {
  height: 38px;
  padding: 0 16px;
  font-weight: 600;
}

.primary-btn svg {
  width: 16px;
  height: 16px;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.loaded-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(8, 12, 20, 0.9);
}

.lightbox img {
  max-width: min(92vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 760px) {
  .topbar-inner {
    min-height: 56px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .page {
    padding: 14px 14px 32px;
  }

  .control-bar {
    align-items: stretch;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    padding: 0 8px;
  }

  .control-meta {
    width: 100%;
    justify-content: space-between;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .media.compare {
    grid-template-columns: 1fr 26px 1fr;
  }
}
