:root {
  --bg: #F7F3EC;
  --white: #FFFFFF;
  --text: #2B2B26;
  --muted: #57574C;
  --border: #E4DFD3;
  --border-strong: #C7BFA8;
  --green: #3F5D45;
  --green-light: #6C8B62;
  --green-tint: #EAF0E6;
  --orange: #C1622D;
  --orange-dark: #9A4A1F;
  --input-bg: #FBF9F5;
  --font-display: 'Fraunces', serif;
  --font-body: 'Public Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #D9D2C2;
  font-family: var(--font-body);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }
button { all: unset; box-sizing: border-box; cursor: pointer; font-family: inherit; }
img { display: block; }

.app-frame {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.12);
}

@media (min-width: 481px) {
  html, body { display: flex; justify-content: center; }
  .app-frame { min-height: 100vh; margin: 24px auto; border-radius: 28px; overflow: hidden; }
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ---------- shared bits ---------- */

.header {
  padding: 26px 20px 4px;
}
.header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  color: var(--text);
}
.header-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.chips {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}
.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

.navbar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 74px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 10px);
  margin-top: auto;
  flex: none;
}
.navbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px;
  min-height: 44px;
  justify-content: center;
}
.navbtn.active { color: var(--green); }

/* ---------- list ---------- */

.list-body {
  flex-grow: 1;
  padding: 4px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  height: 190px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(43,43,38,0.10);
}
.card-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(20,20,15,0.62) 0%, rgba(20,20,15,0.0) 70%);
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--white);
  text-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.rating-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.94);
  border-radius: 14px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

.fab {
  position: fixed;
  right: calc((100vw - min(100vw, 480px)) / 2 + 20px);
  bottom: 92px;
  width: 52px;
  height: 52px;
  border-radius: 26px;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(193,98,45,0.40);
  z-index: 5;
}

/* ---------- map ---------- */

.map-wrap {
  flex-grow: 1;
  position: relative;
  margin: 0 20px 20px;
  min-height: 420px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #DCE7DA 0%, #C8D9C2 40%, #B9CDAE 100%);
}
.map-region-label {
  position: absolute;
  top: 14px; left: 14px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 700;
  opacity: 0.8;
}
.pin {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -100%);
}
.map-legend {
  position: absolute;
  left: 14px; bottom: 14px;
  background: rgba(255,255,255,0.94);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- detail ---------- */

.detail-hero {
  height: 260px;
  flex: none;
  position: relative;
}
.detail-back {
  position: absolute;
  top: 20px; left: 20px;
  width: 44px; height: 44px;
  border-radius: 22px;
  background: rgba(255,255,255,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-body {
  flex-grow: 1;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: -18px;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  position: relative;
}
.tag {
  display: inline-block;
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--green-tint);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.detail-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  color: var(--text);
}
.detail-meta { font-size: 13px; color: var(--muted); }

.rate-row {
  display: flex;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.rate { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rate-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.rate-stars { display: flex; gap: 2px; }

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-val { font-size: 16px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 11px; color: var(--muted); }

.detail-body h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}
.detail-body p {
  font-size: 14px;
  line-height: 1.55;
  color: #4A4A42;
  margin: 0;
  white-space: pre-wrap;
}
.thumbs { display: flex; gap: 10px; overflow-x: auto; }
.thumb {
  flex: none;
  width: 64px; height: 64px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
}
.detail-actions { display: flex; gap: 10px; }
.btn-danger, .btn-edit {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  display: block;
}
.btn-danger { color: var(--orange-dark); }
.btn-edit { color: var(--white); background: var(--green); border-color: var(--green); }

/* ---------- form ---------- */

.form-header {
  flex: none;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.form-back {
  width: 44px; height: 44px;
  border-radius: 22px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.form-save {
  font-size: 14px;
  font-weight: 700;
  color: var(--orange-dark);
  padding: 8px;
}

.form-body {
  flex-grow: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--white);
}

.upload-box {
  height: 150px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: var(--input-bg);
  width: 100%;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
}
.upload-box .upload-hint {
  font-size: 13px;
  font-weight: 600;
}
.upload-box.has-image .upload-hint { display: none; }
.upload-box.has-image svg { display: none; }

.field { display: flex; flex-direction: column; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--input-bg);
}
.field textarea { resize: none; min-height: 64px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.starbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
}
.stars-edit { display: flex; gap: 2px; }

.thumb-row { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb-add {
  width: 56px; height: 56px;
  border-radius: 10px;
  border: 1.5px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
}
.thumb-small {
  width: 56px; height: 56px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  position: relative;
}
.thumb-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  color: var(--white);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.btn-primary {
  width: 100%;
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  background: var(--green);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  display: block;
}

.error-text {
  font-size: 12px;
  color: var(--orange-dark);
  min-height: 16px;
}
