:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --border: #2b2f38;
  --text: #e7e9ee;
  --muted: #9aa2b1;
  --accent: #ffb648;
  --accent-dim: #4a4530;
  --good: #4caf7d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

#sidebar h1 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
}

#progress-total {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  cursor: pointer;
}

#section-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#section-list li {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 2px;
}

#section-list li:hover {
  background: #262a33;
}

#section-list li.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

#section-list .count {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

#section-list li.done .count {
  color: var(--good);
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

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

#section-title {
  margin: 0;
  font-size: 20px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.card.rated {
  border-color: var(--good);
}

.card:hover, .card.hovered {
  border-color: var(--accent);
}

.thumb-wrap {
  height: 170px;
  background: #0e0f12;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}

.thumb-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-footer {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filename {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 2px;
}

.stars button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px;
  color: #454b58;
}

.stars button.on {
  color: var(--accent);
}

.stars button:hover,
.stars button:hover ~ button {
  color: var(--accent);
}

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--good);
  color: #06210f;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 9, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
}

.lightbox.hidden {
  display: none;
}

.lightbox-inner {
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: default;
}

.lightbox-inner img {
  max-width: 92vw;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-inner .filename {
  font-size: 13px;
  color: var(--muted);
}

.lightbox-inner .stars button {
  font-size: 28px;
}

#lightbox-close {
  position: fixed;
  top: 18px;
  right: 24px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  z-index: 101;
}

.lightbox-inner .filename ~ .stars {
  margin-top: 0;
}

#lightbox-position {
  font-size: 12px;
  color: var(--muted);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}
