:root {
  color-scheme: light dark;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --accent: #2f6f4f;
  --overlay: rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --surface: #1f1f18;
    --text: #f3f2ee;
    --muted: #a6a49b;
    --accent: #6fbf8f;
    --overlay: rgba(0, 0, 0, 0.7);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: env(safe-area-inset-top, 0) 16px 10px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.back-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  padding: 6px 4px;
  display: none;
  cursor: pointer;
}

.back-btn.visible {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.ideas-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(128, 128, 128, 0.4);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.ideas-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.15s ease;
}

.ideas-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.ideas-toggle[aria-pressed="true"] .dot {
  background: var(--accent);
}

.idea-count {
  font-weight: 400;
  opacity: 0.85;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 22px 0 10px;
}

.section-label:first-child {
  margin-top: 0;
}

.tips-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
}

.tips-box ul {
  margin: 0;
  padding-left: 18px;
}

.tips-box li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.tips-box li:last-child {
  margin-bottom: 0;
}

.tips-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tips-links a {
  display: inline-block;
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, 0.3);
}

.tips-empty {
  color: var(--muted);
  font-size: 14px;
}

main {
  padding: 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
}

/* Location grid */
#location-view.hidden,
#gallery-view.hidden {
  display: none;
}

.location-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .location-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.location-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

.location-card .label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(to top, var(--overlay), transparent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.location-card .count {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
}

.gallery-sections {
  display: block;
}

/* Gallery grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.photo-grid button {
  border: none;
  padding: 0;
  background: var(--surface);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
}

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

/* Lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

#lightbox.hidden {
  display: none;
}

#lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}

#lightbox .close-btn,
#lightbox .nav-btn {
  position: absolute;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#lightbox .close-btn {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
}

#lightbox .nav-btn.prev {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

#lightbox .nav-btn.next {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

#lightbox .counter {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  opacity: 0.8;
}

#lightbox .credit-line {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  left: 16px;
  right: 16px;
  text-align: center;
  color: #fff;
  font-size: 11px;
  opacity: 0.65;
}

#lightbox .credit-line.hidden {
  display: none;
}

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