:root {
  --bg: #F3EFE6;
  --ocean: #E7EDEE;
  --land: #D8D3C7;
  --land-hover: #C9C2B3;
  --border: #F6F3EC;
  --grat: rgba(40, 60, 70, .06);
  --ink: #1F2A2E;
  --ink-2: #56646A;
  --ink-3: #8A969B;
  --surface: #FFFDF8;
  --surface-2: #F6F2EA;
  --line: #E4DED2;
  --accent: #D9572B;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE5DB;
  --v1: #A9DCCF;
  --v2: #6CC3AE;
  --v3: #37A08A;
  --v4: #1E7A69;
  --v5: #0F5149;
  --sel: #D9572B;
  --shadow: 0 10px 30px rgba(35, 40, 30, .12), 0 2px 6px rgba(35, 40, 30, .06);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1315; --ocean: #111A1D; --land: #283136; --land-hover: #344046; --border: #111A1D;
    --grat: rgba(255,255,255,.04);
    --ink: #E9EEEC; --ink-2: #A8B4B6; --ink-3: #74838A;
    --surface: #172024; --surface-2: #1D282D; --line: #2A363C;
    --accent: #F07A4E; --accent-ink: #1A0E08; --accent-soft: #3A2219;
    --v1: #1F4C45; --v2: #237061; --v3: #2B977F; --v4: #45C1A1; --v5: #93E8CF;
    --sel: #F07A4E;
    --shadow: 0 10px 30px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1315; --ocean: #111A1D; --land: #283136; --land-hover: #344046; --border: #111A1D;
  --grat: rgba(255,255,255,.04);
  --ink: #E9EEEC; --ink-2: #A8B4B6; --ink-3: #74838A;
  --surface: #172024; --surface-2: #1D282D; --line: #2A363C;
  --accent: #F07A4E; --accent-ink: #1A0E08; --accent-soft: #3A2219;
  --v1: #1F4C45; --v2: #237061; --v3: #2B977F; --v4: #45C1A1; --v5: #93E8CF;
  --sel: #F07A4E;
  --shadow: 0 10px 30px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.ic { width: 18px; height: 18px; flex: none; display: block; }
.err { color: var(--accent); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px;
  white-space: nowrap; transition: background .15s, transform .1s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--accent); border-color: var(--accent-soft); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.plain { border-color: transparent; background: transparent; width: 32px; height: 32px; }
.icon-btn.plain:hover { background: var(--surface-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Brand ---------- */
.mark {
  width: 26px; height: 26px; border-radius: 50%; display: inline-block; flex: none;
  background:
    radial-gradient(circle at 62% 38%, var(--accent) 0 22%, transparent 23%),
    conic-gradient(from 200deg, var(--v2), var(--v4), var(--v3), var(--v1), var(--v2));
  box-shadow: inset 0 0 0 2px var(--surface);
}
.mark.big { width: 54px; height: 54px; }
.brand { display: flex; align-items: center; gap: 10px; }
.word { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }

/* ---------- Map stage ---------- */
#stage { position: fixed; inset: 0; background: var(--ocean); }
#map { width: 100%; height: 100%; display: block; touch-action: none; }
#map .sphere { fill: var(--ocean); }
#map .grat { fill: none; stroke: var(--grat); stroke-width: 1; vector-effect: non-scaling-stroke; }
#map .country {
  fill: var(--land); stroke: var(--border); stroke-width: .6; vector-effect: non-scaling-stroke;
  transition: fill .25s; cursor: pointer;
}
#map .country:hover { fill: var(--land-hover); }
#map .country.v1 { fill: var(--v1); } #map .country.v2 { fill: var(--v2); }
#map .country.v3 { fill: var(--v3); } #map .country.v4 { fill: var(--v4); }
#map .country.v5 { fill: var(--v5); }
#map .country.v1:hover, #map .country.v2:hover, #map .country.v3:hover,
#map .country.v4:hover, #map .country.v5:hover { filter: brightness(1.08); }
#map .country.sel { stroke: var(--sel); stroke-width: 1.8; }
#map .dot { stroke: var(--surface); stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: pointer; }
#map .dot.v1 { fill: var(--v1); } #map .dot.v2 { fill: var(--v2); } #map .dot.v3 { fill: var(--v3); }
#map .dot.v4 { fill: var(--v4); } #map .dot.v5 { fill: var(--v5); }
#map .dot.sel { stroke: var(--sel); stroke-width: 2; }

.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow);
  font-size: 13px; max-width: 260px; transform: translate(-50%, calc(-100% - 14px));
}
.tip b { display: block; font-size: 14px; }
.tip span { color: var(--ink-2); }

.legend {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: var(--ink-2);
}
.legend .scale { display: flex; gap: 3px; margin-top: 6px; }
.legend .sw { width: 30px; text-align: center; }
.legend .sw i { display: block; height: 10px; border-radius: 3px; margin-bottom: 3px; }
.zoom {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
}
.zoom .icon-btn { box-shadow: var(--shadow); }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .brand, .stats {
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; height: 44px; padding: 0 16px 0 9px;
}
.stats { display: flex; align-items: center; gap: 18px; padding: 0 18px; overflow-x: auto; scrollbar-width: none; }
.stats::-webkit-scrollbar { display: none; }
.stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.stat b { font-family: var(--display); font-weight: 600; font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums; }
.actions { margin-left: auto; display: flex; gap: 8px; }
.actions .btn, .actions .icon-btn { box-shadow: var(--shadow); height: 44px; }
.actions .icon-btn { width: 44px; }
.banner {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 9;
  background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: 12px;
  max-width: calc(100% - 32px); text-align: center;
}

/* ---------- Panel ---------- */
.panel {
  position: fixed; z-index: 20; top: calc(74px + env(safe-area-inset-top)); right: 16px; bottom: 16px; width: 420px;
  background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  transform: translateX(calc(100% + 32px)); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; outline: none;
}
.panel.open { transform: none; }
.panel-grip { display: none; }
.panel-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.panel-body { overflow-y: auto; padding: 22px 20px 40px; flex: 1; }
.p-head { display: flex; gap: 12px; align-items: center; padding-right: 48px; }
.flag { font-size: 34px; line-height: 1; }
.p-head h2 { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.p-sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.p-actions { display: flex; gap: 8px; margin: 16px 0 6px; }
.empty { text-align: center; color: var(--ink-2); padding: 36px 12px; }
.empty .ic { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--ink-3); }

.city { margin-top: 22px; }
.city-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.city-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.count { white-space: nowrap; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--ink-2); }
.city-head .ic { color: var(--accent); width: 16px; height: 16px; }

.visit {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  background: var(--surface); scroll-margin-top: 80px;
}
.visit.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); } }
.visit-top { display: flex; align-items: center; gap: 8px; }
.visit-date { font-weight: 600; font-size: 14px; }
.visit-top .sp { flex: 1; }
.rating { display: inline-flex; gap: 1px; color: var(--accent); }
.rating .ic { width: 13px; height: 13px; fill: currentColor; }
.visit p { margin: 8px 0 0; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.with { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px 3px 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip .ic { width: 14px; height: 14px; color: var(--v4); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.thumbs button { padding: 0; border: 0; border-radius: 9px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.thumbs button:hover img { transform: scale(1.04); }

/* timeline */
.tl-tools { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 8px; }
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.search input { width: 100%; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px 0 36px; }
.years { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.years button { flex: none; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.years button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tl-year { font-family: var(--display); font-size: 20px; font-weight: 600; margin: 20px 0 6px; color: var(--ink-2); }
.tl-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 8px; margin: 0 -8px;
  border: 0; background: none; border-radius: 10px; width: calc(100% + 16px);
}
.tl-row:hover { background: var(--surface-2); }
.tl-row .flag { font-size: 24px; width: 30px; text-align: center; }
.tl-row .t { flex: 1; min-width: 0; }
.tl-row .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-row .t span { font-size: 13px; color: var(--ink-2); }
.tl-row .mi { display: flex; gap: 3px; color: var(--v4); }
.tl-row .mi .ic { width: 14px; height: 14px; }
.tl-foot { display: flex; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(6px);
  transition: opacity .35s, visibility .35s;
}
body:not(.locked) .gate { opacity: 0; visibility: hidden; pointer-events: none; }
body.locked .topbar, body.locked .legend, body.locked .zoom, body.locked .panel { visibility: hidden; }
.gate-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 34px 30px 26px; width: min(360px, 100%); text-align: center;
}
.gate-card h1 { font-family: var(--display); font-weight: 600; font-size: 32px; margin: 12px 0 2px; letter-spacing: -.01em; }
.gate-card .muted { margin: 0 0 22px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); margin-top: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.pin { display: flex; gap: 12px; justify-content: center; }
.pin input {
  width: 58px; height: 66px; text-align: center; font-family: var(--display); font-size: 30px; font-weight: 600;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2); caret-color: var(--accent);
  -webkit-text-security: disc;
}
.pin input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.pin.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin.busy input { opacity: .5; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(15, 20, 20, .38); animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); width: 100%;
  max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px 22px 22px; animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-card.wide { max-width: 620px; }
.modal-card.narrow { max-width: 360px; text-align: center; }
.modal-card.narrow .modal-head { text-align: left; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; position: sticky; bottom: -22px; background: var(--surface); padding: 12px 0 0; }

.vform { display: flex; flex-direction: column; gap: 14px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.field > span { margin-bottom: 0; }
.field em { color: var(--accent); font-style: normal; }
.field small { font-weight: 400; color: var(--ink-3); }
.field input[type=text], .field input[type=date], .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; min-height: 42px;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field.invalid input { border-color: var(--accent); }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 3; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 240px; overflow-y: auto;
}
.combo-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.combo-list li[aria-selected=true], .combo-list li:hover { background: var(--surface-2); }
.combo-list li small { margin-left: auto; color: var(--v4); font-size: 12px; }

.memo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.memo {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; font-size: 12px; color: var(--ink-2);
  transition: all .15s;
}
.memo .ic { width: 22px; height: 22px; }
.memo:hover { border-color: var(--ink-3); }
.memo[aria-pressed=true] { border-color: var(--v4); background: color-mix(in srgb, var(--v1) 35%, var(--surface)); color: var(--ink); }
.memo[aria-pressed=true] .ic { color: var(--v4); }

.stars { display: flex; gap: 2px; height: 42px; align-items: center; }
.stars button { border: 0; background: none; padding: 4px; color: var(--ink-3); }
.stars button .ic { width: 24px; height: 24px; }
.stars button.on { color: var(--accent); }
.stars button.on .ic { fill: currentColor; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.photo, .photo-add { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .rm {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center;
}
.photo .rm .ic { width: 14px; height: 14px; }
.photo.loading::after {
  content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.5);
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  background-size: 200% 100%; animation: shimmer 1s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  border: 1.5px dashed var(--line); color: var(--ink-2); font-size: 12px; background: var(--surface-2);
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.photo-add .ic { width: 22px; height: 22px; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8,10,10,.92); display: grid; place-items: center; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox .icon-btn { position: absolute; background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.lb-close { top: calc(16px + env(safe-area-inset-top)); right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-cap { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(255,255,255,.8); font-size: 13px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 70;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .topbar .brand { height: 40px; }
  .word { font-size: 19px; }
  .actions .btn, .actions .icon-btn { height: 40px; }
  .actions .icon-btn { width: 40px; }
  .actions .btn .lbl { display: none; }
  .actions .btn { width: 40px; padding: 0; justify-content: center; }
  .stats { order: 3; width: 100%; height: 38px; gap: 14px; padding: 0 14px; justify-content: space-between; }
  .stat b { font-size: 16px; }
  .banner { top: calc(108px + env(safe-area-inset-top)); }
  .legend { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 8px 10px; }
  .legend .sw { width: 24px; }
  .zoom { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .zoom .icon-btn { width: 38px; height: 38px; }

  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: min(64dvh, 640px); border: 0; border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0; transform: translateY(105%);
  }
  .panel.open { transform: none; }
  .panel-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
  .panel-close { top: 12px; right: 12px; }
  .panel-body { padding: 10px 16px calc(32px + env(safe-area-inset-bottom)); }

  .modal { padding: 0; place-items: end stretch; }
  .modal-card { border-radius: 22px 22px 0 0; max-height: 94dvh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .modal-card.narrow { max-width: none; }
  .modal-foot { bottom: calc(-18px - env(safe-area-inset-bottom)); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .row.two { grid-template-columns: 1fr; }
  .memo-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .memo { font-size: 11px; padding: 10px 2px 8px; }
  .pin input { width: 54px; height: 62px; }
  .field input[type=text], .field input[type=date], .field textarea { font-size: 16px; } /* no iOS zoom */
  .lb-prev, .lb-next { top: auto; bottom: calc(56px + env(safe-area-inset-bottom)); transform: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- date range field + picker ---------- */
.field.dates { position: relative; }
.datefield {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 10px 12px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; text-align: left;
  color: var(--ink-3); font-size: 15px;
}
.datefield.filled { color: var(--ink); }
.datefield:hover { border-color: var(--ink-3); }
.datefield[aria-expanded="true"] { border-color: var(--accent); background: var(--surface); }
.datefield .ic { color: var(--ink-3); }
.datefield .dl { flex: 1; }
.dp {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px; animation: pop .16s cubic-bezier(.2,.8,.2,1);
}
.dp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dp-head strong { flex: 1; text-align: center; font-size: 14px; font-weight: 600; }
.dp-head .icon-btn[disabled] { opacity: .3; cursor: default; }
.dp-months { display: flex; gap: 22px; }
.dp-month { flex: 1; min-width: 232px; }
.dp-mname { font-family: var(--display); font-weight: 600; font-size: 16px; text-align: center; margin-bottom: 8px; }
.dp-dows, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dp-dows span { text-align: center; font-size: 11px; color: var(--ink-3); padding-bottom: 4px; }
.dp-grid { row-gap: 2px; }
.dp-pad { height: 34px; }
.dp-day {
  height: 34px; border: 0; background: none; border-radius: 9px; font-size: 13px; color: var(--ink);
  position: relative; font-variant-numeric: tabular-nums;
}
.dp-day:hover:not(:disabled) { background: var(--surface-2); }
.dp-day:disabled { color: var(--ink-3); opacity: .35; cursor: default; }
.dp-day.today { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dp-day.in { background: var(--accent-soft); border-radius: 0; }
.dp-day.from, .dp-day.to { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dp-day.from:hover, .dp-day.to:hover { background: var(--accent); }
.dp-day.from { border-radius: 9px 0 0 9px; }
.dp-day.to { border-radius: 0 9px 9px 0; }
.dp-day.from.to, .dp-day.from:not(.to):last-child { border-radius: 9px; }
.dp-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.dp-foot .sp { flex: 1; }
.thumbs button.missing { position: relative; }
.thumbs button.missing img { opacity: 0; }
.thumbs button.missing::after {
  content: "photo unavailable"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10px; color: var(--ink-3); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 9px; padding: 4px; text-align: center;
}
@media (max-width: 760px) {
  .dp { position: static; box-shadow: none; margin-top: 8px; padding: 10px 4px; }
  .dp-month { min-width: 0; }
  .dp-day, .dp-pad { height: 40px; }
}
