:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e6e6e6;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #111111;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.back-btn:hover {
  border-color: #c9c9c9;
}

.view-title {
  font-size: 17px;
  font-weight: 650;
}

.groups-grid {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.group-card {
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.group-img {
  aspect-ratio: 16 / 10;
  width: 100%;
  object-fit: cover;
  display: block;
  background: #ececec;
}

.group-img-empty {
  background: linear-gradient(135deg, #f0f0f0, #e6e6e6);
}

.group-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 34px 16px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  color: #fff;
}

.group-name {
  font-size: 18px;
  font-weight: 650;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.group-count {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 1px;
}

.grid {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.card-media {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  display: block;
  background: #ececec;
}

.card-media-empty {
  background:
    linear-gradient(#e8e8e8, #e8e8e8),
    var(--surface);
}

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

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.card-group {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 8px;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 880px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.2fr 1fr;
}

@media (max-width: 720px) {
  .modal-card {
    grid-template-columns: 1fr;
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.gallery {
  padding: 16px;
}

.gallery-main {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #ececec;
  display: block;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  background: #ececec;
  flex: none;
}

.thumb.active {
  border-color: var(--accent);
}

.gallery-info {
  padding: 24px;
}

.gallery-info h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 650;
}

.modal-group {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.gallery-info p {
  margin: 0;
  font-size: 15px;
  color: #333;
  white-space: pre-wrap;
}