:root {
  --maroon: #7a1f2b;
  --maroon-dark: #591722;
  --cream: #faf3e8;
  --cream-dark: #f0e4cf;
  --gold: #b8862f;
  --ink: #2c2420;
  --muted: #7a6f63;
  --tier3: #7a1f2b;
  --tier2: #b8862f;
  --tier1: #8a9a5b;
  --radius: 10px;
  font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--maroon);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.nav a, .nav button {
  color: var(--cream);
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: 1px solid rgba(250,243,232,0.4);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
}

.nav a:hover, .nav button:hover { background: rgba(250,243,232,0.15); }
.nav .active { background: var(--gold); border-color: var(--gold); color: var(--maroon-dark); font-weight: 600; }

.app {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 18px;
}

h1 { font-size: 1.8rem; margin: 0 0 6px; color: var(--maroon-dark); }
h2 { font-size: 1.3rem; color: var(--maroon-dark); }
.subtitle { color: var(--muted); margin: 0 0 24px; }

.tier-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--cream-dark);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 22px;
  font-size: 0.88rem;
}
.tier-legend span.pies { margin-right: 6px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}

select, input, textarea, button.btn {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #d8cbb4;
  background: #fff;
}

button.btn {
  background: var(--maroon);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button.btn:hover { background: var(--maroon-dark); }
button.btn.secondary { background: transparent; color: var(--maroon); border: 1px solid var(--maroon); }
button.btn.secondary:hover { background: rgba(122,31,43,0.08); }
button.btn.danger { background: #a33; }

.pie-list { display: flex; flex-direction: column; gap: 12px; }

.pie-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-left: 5px solid transparent;
}
.pie-card.t3 { border-left-color: var(--tier3); }
.pie-card.t2 { border-left-color: var(--tier2); }
.pie-card.t1 { border-left-color: var(--tier1); }
.pie-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.14); }

.pie-card .info h3 { margin: 0 0 4px; font-size: 1.1rem; }
.pie-card .info .meta { color: var(--muted); font-size: 0.87rem; }
.pie-card .score { text-align: right; white-space: nowrap; }
.pie-card .score .pies { font-size: 1.2rem; }
.pie-card .score .num { font-size: 0.85rem; color: var(--muted); }

.region-group { margin-bottom: 30px; }
.region-group h2 { border-bottom: 2px solid var(--gold); padding-bottom: 4px; margin-bottom: 12px; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 520px;
  margin: 0 auto;
}

.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 0.88rem; font-weight: 600; color: var(--maroon-dark); }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.error { color: #a33; background: #fbe6e6; padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; margin-bottom: 12px; }
.notice { color: #4a5a2a; background: #eef2e2; padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; margin-bottom: 12px; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-badge { text-align: center; }
.detail-badge .pies { font-size: 2rem; display: block; }
.detail-badge .label { font-size: 0.85rem; color: var(--muted); }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 10px; margin: 16px 0; font-size: 0.92rem; }
.meta-grid div b { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }

.notes { background: var(--cream-dark); padding: 12px 14px; border-radius: 8px; margin: 16px 0; font-style: italic; }

.rate-box { background: var(--cream-dark); padding: 16px; border-radius: 10px; margin: 20px 0; }
.rate-box input[type=range] { width: 100%; }
.rate-value { font-weight: 700; font-size: 1.3rem; color: var(--maroon); }

.rating-list { list-style: none; padding: 0; margin: 10px 0; }
.rating-list li { padding: 10px 0; border-bottom: 1px solid var(--cream-dark); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rating-list .who { font-weight: 600; }
.rating-list .cmt { color: var(--muted); font-size: 0.9rem; }
.rating-list .sc { font-weight: 700; color: var(--maroon); white-space: nowrap; }
.rating-list .thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; margin-top: 8px; cursor: pointer; display: block; }

.photo-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.photo-btn { display: inline-flex; align-items: center; gap: 6px; }
.photo-preview-wrap { position: relative; display: inline-block; margin-top: 10px; }
.photo-preview { max-width: 160px; max-height: 160px; border-radius: 10px; display: block; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.photo-remove { position: absolute; top: -8px; right: -8px; background: var(--maroon); color: #fff; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 0.9rem; line-height: 1; }
.hidden-file-input { display: none; }

.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }

.map-container { width: 100%; height: 460px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.1); margin-bottom: 16px; }
.map-container.small { height: 220px; }
.leaflet-popup-content { font-family: inherit; }
.map-popup h4 { margin: 0 0 4px; }
.map-popup a { color: var(--maroon); font-weight: 600; }

.distance-chip { display: inline-block; background: var(--cream-dark); color: var(--maroon-dark); font-size: 0.78rem; padding: 2px 8px; border-radius: 12px; margin-top: 4px; }

.directions-btn { display: inline-flex; align-items: center; gap: 6px; }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(0,0,0,0.25); opacity: 0.95; }
.toast.error { background: #a33; }

.spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--maroon); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.welcome-hero { text-align: center; padding: 30px 10px 10px; }
.welcome-hero .pies-big { font-size: 2.4rem; }

.tier-key-card { display: flex; align-items: center; gap: 10px; }
.tier-key-card .pies { font-size: 1.3rem; min-width: 60px; }

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .pie-card { flex-direction: column; align-items: flex-start; }
  .pie-card .score { text-align: left; }
}
