:root {
  --ink: #1d2327;
  --muted: #5f6b73;
  --paper: #fbf8f3;
  --line: #e4ddd2;
  --accent: #b5532a;
  --food: #c8642f;
  --people: #3b6ea8;
  --places: #2f7d55;
  --unique: #82509a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 24, 28, .16);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

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

.map-page #map { position: fixed; inset: 0; background: #dfe6e9; }

.topbar {
  position: fixed; top: 12px; left: 12px; right: 12px; z-index: 1000;
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "titles . filters signin";
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.titles { grid-area: titles; }
.filters { grid-area: filters; }

.signin {
  grid-area: signin; justify-self: end;
  background: rgba(251, 248, 243, .94); backdrop-filter: blur(6px); box-shadow: var(--shadow);
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 9px 14px; border-radius: 999px; white-space: nowrap;
}
.signin:hover { color: var(--ink); }
.signin.is-signed-in { background: var(--accent); color: #fff; }

.edit-day {
  margin: 0 12px 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  text-align: center; color: var(--accent); font-weight: 700; font-size: 14px; text-decoration: none; background: #fff;
}
.titles {
  background: rgba(251, 248, 243, .94); backdrop-filter: blur(6px);
  padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.titles h1 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .2px; }
.titles p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.filters {
  display: flex; gap: 6px; padding: 6px; border-radius: 999px;
  background: rgba(251, 248, 243, .94); backdrop-filter: blur(6px); box-shadow: var(--shadow);
  overflow-x: auto; max-width: 100%;
}
.chip {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip-food[aria-pressed="true"] { background: var(--food); }
.chip-people[aria-pressed="true"] { background: var(--people); }
.chip-places[aria-pressed="true"] { background: var(--places); }
.chip-unique[aria-pressed="true"] { background: var(--unique); }

.empty {
  position: fixed; z-index: 900; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--paper); padding: 16px 22px; border-radius: var(--radius); box-shadow: var(--shadow); color: var(--muted);
}

/* pins */
.day-pin { background: none; border: 0; }
.leaflet-container .day-pin img {
  width: 46px !important; height: 46px; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); background: #ccc;
  transition: transform .15s ease;
}
.day-pin:hover img { transform: scale(1.08); }
.day-pin.is-active img { border-color: var(--accent); transform: scale(1.18); }

.cluster-pin {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); line-height: 1;
}
.cluster-pin span { font-size: 17px; font-weight: 700; }
.cluster-pin small { font-size: 9px; text-transform: uppercase; letter-spacing: .6px; opacity: .8; margin-top: 2px; }

.route-line { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 7; stroke-linecap: round; opacity: .75; fill: none; }

/* day panel */
.panel {
  position: fixed; z-index: 1100; background: var(--paper); box-shadow: var(--shadow);
  right: 12px; top: 84px; bottom: 12px; width: 380px; border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.panel-titles { flex: 1; min-width: 0; text-align: center; }
.panel-date { font-size: 13px; color: var(--muted); font-weight: 600; }
.panel-place { font-family: var(--serif); font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  font-size: 26px; line-height: 1; display: grid; place-items: center; flex: none;
}
.icon-btn:hover:not(:disabled) { background: rgba(0, 0, 0, .06); }
.icon-btn:disabled { opacity: .25; cursor: default; }
.icon-btn.close { font-size: 24px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; overflow-y: auto; }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden;
  background: #e9e3d9;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
button.tile:hover img { transform: scale(1.04); }
.tile-label {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--ink);
}
.tile-food .tile-label { background: var(--food); }
.tile-people .tile-label { background: var(--people); }
.tile-places .tile-label { background: var(--places); }
.tile-unique .tile-label { background: var(--unique); }
.tile-empty { display: grid; place-items: center; border: 2px dashed var(--line); background: transparent; }
.tile-empty .tile-label { position: static; background: transparent !important; color: #b0a89c; }
.tile-dim { opacity: .35; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 2000; background: rgba(12, 14, 16, .94);
  display: flex; align-items: center; justify-content: center;
}
.lightbox figure { margin: 0; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: 4px; }
.lightbox figcaption { color: #e8e4dc; margin-top: 12px; font-size: 15px; text-align: center; max-width: 640px; }
.lightbox .icon-btn { position: absolute; color: #fff; width: 48px; height: 48px; font-size: 34px; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "titles signin" "filters filters"; }
  .titles { justify-self: start; }
  .filters { justify-self: start; }
  .titles h1 { font-size: 18px; }
  .titles p { display: none; }
  .panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 62vh; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .panel-open .leaflet-bottom { bottom: 62vh; }
}

/* ------------------------------------------------------------ upload page */

.upload-page { background: var(--paper); }
.upload-wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.upload-wrap h1 { font-family: var(--serif); font-size: 26px; margin: 8px 0 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 0 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 14px; font-weight: 600; }
input[type="date"], input[type="text"], input[type="password"] {
  font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.hint button { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 0; text-decoration: underline; }
.warn { background: #fff4e5; border: 1px solid #f2c98b; color: #7a4a0b; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 10px; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot { display: flex; flex-direction: column; gap: 6px; }
.slot-pick {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px dashed var(--line);
  background: #faf7f2; display: grid; place-items: center; padding: 0;
}
.slot-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot-pick .plus { font-size: 34px; color: #b9ae9f; line-height: 1; }
.slot.filled .slot-pick { border-style: solid; border-color: transparent; }
.slot .tile-label { left: 8px; bottom: 8px; }
.slot-pending .slot-pick::after {
  content: "New"; position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.slot-remove {
  position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; display: grid; place-items: center; z-index: 2;
}
.slot input[type="text"] { font-size: 14px; padding: 8px 10px; }
.slot-meta { font-size: 12px; color: var(--muted); min-height: 1em; }

#pin-map { height: 260px; border-radius: 10px; margin-top: 4px; }
.pin-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 0; }
.photo-dot { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; background: rgba(251, 248, 243, .97);
  border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; justify-content: center;
}
.savebar .status { flex: 1; max-width: 360px; font-size: 14px; color: var(--muted); }
.status.error { color: #b3261e; }
.status.ok { color: var(--places); }
.primary {
  border: 0; background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
  padding: 12px 22px; border-radius: 12px; min-width: 120px;
}
.primary:disabled { opacity: .5; cursor: default; }
.secondary { border: 1px solid var(--line); background: #fff; font-weight: 600; padding: 10px 16px; border-radius: 10px; }
.danger { color: #b3261e; }
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }
.toplinks { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.toplinks a { color: var(--accent); font-weight: 600; text-decoration: none; }
