@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Nunito+Sans:wght@400;600;700&display=swap");

:root {
  --bg-a: #f7f3ea;
  --bg-b: #eaf2f1;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --ink: #173246;
  --muted: #5a6b7b;
  --line: #cfdbe5;
  --accent: #0e7a72;
  --accent-strong: #065f58;
  --accent-soft: #daf2ef;
  --danger: #b4232b;
  --shadow-soft: 0 14px 32px rgba(23, 50, 70, 0.1);
  --shadow-card: 0 8px 20px rgba(23, 50, 70, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Nunito Sans", sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 216, 182, 0.55), transparent 38%),
    radial-gradient(circle at 84% 12%, rgba(150, 208, 197, 0.45), transparent 36%),
    linear-gradient(170deg, var(--bg-a), var(--bg-b));
}

body.lightbox-open {
  overflow: hidden;
}

.app-shell {
  width: min(980px, 100% - 2rem);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

.hero {
  margin-bottom: 1.1rem;
  padding: 1.2rem 1.3rem;
  border-radius: 22px;
  background: linear-gradient(132deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.56));
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  margin: 0;
  font-size: 1.02rem;
  color: var(--accent-strong);
  font-weight: 700;
  letter-spacing: 0.04em;
}

h1 {
  margin: 0.35rem 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  padding: 1rem;
  margin-bottom: 1rem;
}

h2 {
  margin: 0 0 0.35rem;
  font-family: "Fraunces", serif;
  font-size: 1.55rem;
}

.muted {
  color: var(--muted);
}

.auth-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.65rem;
}

.auth-form[hidden] {
  display: none !important;
}

label {
  font-size: 1rem;
  font-weight: 700;
}

input {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 0.9rem;
  font-size: 1.05rem;
  background: #ffffff;
}

input:focus {
  outline: 3px solid rgba(14, 122, 114, 0.18);
  border-color: var(--accent);
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.btn {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #15978c);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(14, 122, 114, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-strong), #0f8f84);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-soft {
  background: #eef4f8;
  color: #4f667a;
  border: 1px solid #d8e4ed;
}

.btn-soft.is-active,
.btn-primary.is-active {
  box-shadow: 0 0 0 2px rgba(14, 122, 114, 0.14) inset;
}

.btn-mini {
  min-height: 34px;
  padding: 0 0.7rem;
  font-size: 0.9rem;
  border: 1px solid #b9ddd8;
  background: #f2fbfa;
  color: #09665f;
}

.btn-danger {
  border-color: #f3c2c8;
  background: #fff3f4;
  color: var(--danger);
}

.btn-mom,
.btn-open-mail {
  margin-top: 0.6rem;
  width: 100%;
}

.auth-choice {
  display: grid;
  gap: 0.55rem;
}

.message {
  min-height: 1.3rem;
  margin: 0.75rem 0 0;
  font-weight: 700;
}

.toolbar {
  display: grid;
  gap: 0.7rem;
}

.toolbar-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.search-bar {
  margin-top: 0.2rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding-right: 2.4rem;
}

.search-clear {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.8rem;
  height: 1.8rem;
  border: 0;
  border-radius: 999px;
  background: #e5eef7;
  color: #496078;
  font-weight: 700;
  cursor: pointer;
}

.search-hint {
  margin: 0.6rem 0 0;
  min-height: 1.2rem;
}

.listening {
  background: #ffe9ec;
  color: #8d1f37;
  border: 1px solid #f4b8c3;
}

.tab {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.tab.is-active {
  background: linear-gradient(135deg, #e2f7f3, #d3f1ed);
  border-color: #9dded6;
  color: var(--accent-strong);
}

.content-area {
  margin-top: 1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.section-title {
  margin: 0.35rem 0 0.8rem;
  font-family: "Fraunces", serif;
  font-size: 1.3rem;
}

.photo-card {
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-strong);
  box-shadow: var(--shadow-card);
}

.photo-card-clickable {
  cursor: zoom-in;
}

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

.photo-meta {
  padding: 0.65rem;
}

.photo-detail {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.photo-actions {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.country-filter {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.btn-mini.is-selected {
  background: #0b7a72;
  color: #ffffff;
  border-color: #0b7a72;
}

.count {
  font-weight: 700;
  color: var(--accent-strong);
  margin: 0.35rem 0 0;
}

.place-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 0.2rem 0 1rem;
}

.place-card {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #f3f8fb);
  box-shadow: var(--shadow-card);
  padding: 0.85rem;
  cursor: pointer;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 0.22rem;
  min-height: 142px;
  position: relative;
}

.place-card:hover {
  border-color: #addfd8;
  background: linear-gradient(145deg, #ffffff, #ecf9f7);
}

.place-title {
  margin: 0;
  padding-right: 1.5rem;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 0;
}

.country-flag {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  position: absolute;
  top: 0.42rem;
  right: 0.42rem;
}

.place-card .photo-detail {
  min-height: 0;
}

.place-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.7rem 0 1rem;
}

.places-map {
  width: 100%;
  height: min(48vh, 360px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.map-photo-icon-wrap {
  background: transparent;
  border: 0;
}

.map-photo-icon {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(6, 24, 38, 0.3);
}

.logout-subtle {
  display: block;
  margin: 1.1rem auto 0;
  border: 0;
  background: transparent;
  color: #8a9aab;
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
}

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

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 25, 37, 0.82);
}

.lightbox-dialog {
  position: relative;
  width: min(940px, calc(100% - 1rem));
  max-height: calc(100vh - 1rem);
  background: #0f1d2a;
  border-radius: 14px;
  padding: 0.6rem;
  z-index: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(237, 243, 248, 0.95);
  color: #274158;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-prev {
  left: 0.45rem;
}

.lightbox-next {
  right: 0.45rem;
}

.lightbox-close {
  border: 0;
  border-radius: 999px;
  background: #edf3f8;
  color: #2c445a;
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

#lightboxImage {
  width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  border-radius: 10px;
  background: #0a141f;
  touch-action: pan-y;
}

.lightbox-meta {
  margin: 0.55rem 0 0;
  color: #d4e3ef;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 1rem);
    padding-top: 0.65rem;
  }

  .hero,
  .card {
    border-radius: 16px;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  .search-bar {
    grid-template-columns: 1fr auto;
  }

  .toolbar-header {
    grid-template-columns: 1fr;
  }

  .toolbar-right {
    justify-content: space-between;
  }

  .place-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .gallery-grid .photo-card img {
    aspect-ratio: 1 / 1;
  }

  .places-map {
    height: 320px;
  }

  .lightbox-dialog {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    padding: 0.45rem;
  }

  #lightboxImage {
    max-height: calc(100vh - 7.2rem);
    border-radius: 8px;
  }

  .lightbox-close {
    position: sticky;
    top: 0.2rem;
    z-index: 2;
  }

  .lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
    background: rgba(237, 243, 248, 0.9);
  }

  .lightbox-prev {
    left: 0.35rem;
  }

  .lightbox-next {
    right: 0.35rem;
  }
}

@media (max-width: 980px) and (min-width: 641px) {
  .place-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
