:root {
  --fox: #e8742a;
  --fox-dark: #c65a17;
  --ink: #2b2118;
  --muted: #7a6d62;
  --paper: #fbf6ef;
  --card: #ffffff;
  --line: #eadfd2;
  --ok: #2fa35b;
  --err: #d64545;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 35, 10, .08);
  --topbar-h: 58px;
  --bottombar-h: 0px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--fox-dark); }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--err); font-weight: 600; }
.center { text-align: center; justify-content: center; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.container { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1rem 6rem; }
.container.wide { max-width: 1200px; }
.page-head { margin: .5rem 0 1.2rem; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1.2rem; }
.notice { background: #fff3e4; border: 1px solid #f5cfa6; border-radius: 10px; padding: .7rem 1rem; margin: 0 0 1rem; }
.stack { display: grid; gap: .8rem; }
label { display: grid; gap: .25rem; font-weight: 600; font-size: .92rem; }
input, textarea, select {
  font: inherit; font-weight: 400; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--fox); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .6rem 1rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--fox); }
.btn.primary { background: var(--fox); border-color: var(--fox); color: #fff; }
.btn.primary:hover { background: var(--fox-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn.small { padding: .35rem .75rem; font-size: .85rem; }
.btn.big { padding: .85rem 1.5rem; font-size: 1.05rem; }
.btn:disabled, label.btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--ink); padding: .2rem .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; font-size: .85rem; white-space: nowrap;
}
.chip.on { border-color: var(--fox); background: #fff3e4; }
.chip.person { border-color: var(--line); opacity: .45; padding-left: .25rem; }
.chip.person.on { opacity: 1; border-color: var(--c); background: #fff; box-shadow: inset 0 0 0 1px var(--c); }

/* ---------------------------------------------------------------- top bar / nav */
.topbar {
  position: sticky; top: 0; z-index: 1000; height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-fox { font-size: 1.3rem; }
.nav { display: flex; gap: .2rem; margin-left: auto; }
.nav a {
  display: flex; align-items: center; gap: .35rem; padding: .4rem .7rem; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem;
}
.nav a.active { background: #fff3e4; color: var(--fox-dark); }
.nav-avatar { width: 22px; height: 22px; border-radius: 50%; display: block; }
.logout { margin: 0; }

@media (max-width: 760px) {
  :root { --topbar-h: 50px; --bottombar-h: 64px; }
  /* no backdrop-filter here: it would turn the fixed bottom nav into a child of the top bar */
  .topbar { justify-content: space-between; backdrop-filter: none; background: #fff; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; margin: 0;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line); justify-content: space-around;
  }
  .nav a { flex-direction: column; gap: 0; font-size: .7rem; border-radius: 10px; padding: .35rem .3rem; flex: 1; }
  .nav .ico { font-size: 1.25rem; line-height: 1.4; }
  .nav-avatar { width: 26px; height: 26px; }
  h1 { font-size: 1.4rem; }
}

/* ---------------------------------------------------------------- auth */
.auth-page main { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 2rem 1.6rem; text-align: center; }
.auth-card form { text-align: left; margin: 1rem 0; }
.auth-fox { font-size: 3.5rem; line-height: 1; }

/* ---------------------------------------------------------------- avatars */
.avatar { border-radius: 50%; object-fit: cover; border: 2px solid #fff; display: inline-block; vertical-align: middle; flex: none; background: #fff; }
.avatar-initials { display: inline-grid; place-items: center; color: #fff; font-weight: 700; }

/* ---------------------------------------------------------------- my photos */
.counter { display: flex; align-items: center; gap: .8rem; margin-top: .6rem; }
.counter-bar { flex: 1; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 320px; }
#counter-fill { height: 100%; width: 0; background: var(--fox); transition: width .3s; }
#counter-text { font-weight: 700; }
.upload-zone { background: #fff; border: 2px dashed #f1c79f; border-radius: var(--radius); padding: 1.2rem; text-align: center; margin-bottom: 1.4rem; }
.upload-zone p { max-width: 560px; margin: .7rem auto 0; }
#upload-queue { display: grid; gap: .4rem; margin-top: .6rem; }
.qrow { display: grid; grid-template-columns: 1fr 120px auto; gap: .6rem; align-items: center; font-size: .85rem; text-align: left; }
.qrow.err .qstate { color: var(--err); }
.qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qbar { height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; }
.qbar span { display: block; height: 100%; width: 0; background: var(--fox); transition: width .2s; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 2rem; }
.pcard { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; border: 2px solid transparent; }
.pcard.incomplete { border-color: #f5cfa6; }
.pcard-img { position: relative; aspect-ratio: 4 / 3; background: #f1ebe4; cursor: zoom-in; }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-num { position: absolute; top: .5rem; left: .5rem; background: var(--fox); color: #fff; font-weight: 800; border-radius: 99px; min-width: 28px; height: 28px; display: grid; place-items: center; font-size: .85rem; }
.pcard-body { padding: .9rem; display: grid; gap: .7rem; }
.field { display: grid; gap: .25rem; }
.field-label { font-weight: 600; font-size: .85rem; display: flex; justify-content: space-between; gap: .5rem; }
.src { font-weight: 400; color: var(--muted); font-size: .78rem; }
.charcount { font-weight: 400; color: var(--muted); font-size: .78rem; }
.loc-line { display: flex; align-items: center; gap: .5rem; justify-content: space-between; min-height: 2.2rem; }
.loc-text { font-size: .9rem; }
.warn p { margin: 0; font-size: .82rem; color: #a05a14; }
.pcard-foot { display: flex; justify-content: space-between; align-items: center; }
.save-state { font-size: .8rem; color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--err); }

/* ---------------------------------------------------------------- dialogs */
.dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog.wide { width: min(720px, 96vw); }
.dialog::backdrop, .lightbox::backdrop { background: rgba(30, 20, 10, .6); }
.dialog-inner { padding: 1rem 1.1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.loc-search input { flex: 1; min-width: 0; }
.dialog-head, .dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.dialog-foot { flex-wrap: wrap; }
.dialog-foot .btn { flex: 1 1 auto; }
.dialog-head h2 { margin: 0; }
.loc-search { display: flex; gap: .4rem; }
.loc-results { list-style: none; margin: 0; padding: 0; max-height: 170px; overflow: auto; border-radius: 10px; }
.loc-results li { padding: .45rem .6rem; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .9rem; }
.loc-results li:hover { background: #fff3e4; }
.loc-map { height: min(340px, 42vh); border-radius: 12px; }
.photo-view { background: transparent; box-shadow: none; width: auto; max-width: 96vw; }
.photo-view img { max-height: 88vh; border-radius: 12px; display: block; }
.close-float { position: absolute; top: .4rem; right: .4rem; background: rgba(255,255,255,.85); border-radius: 50%; width: 36px; height: 36px; }

/* ---------------------------------------------------------------- profile / avatar builder */
.avatar-current { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs { display: flex; gap: .3rem; background: #f4ede5; padding: .25rem; border-radius: 999px; }
.tab { border: 0; background: none; padding: .45rem .9rem; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; font-size: .9rem; }
.tab.active { background: #fff; box-shadow: var(--shadow); }
.builder { display: grid; grid-template-columns: 220px 1fr; gap: 1.2rem; align-items: start; }
.builder-preview svg { width: 100%; height: auto; border-radius: 50%; box-shadow: var(--shadow); display: block; }
.ctl-row { display: grid; grid-template-columns: 110px 1fr; gap: .6rem; align-items: center; margin-bottom: .55rem; }
.ctl-label { font-weight: 600; font-size: .85rem; }
.ctl-opts { display: flex; flex-wrap: wrap; gap: .35rem; }
.row-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.mini { width: 26px; height: 26px; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
@media (max-width: 640px) {
  .builder { grid-template-columns: 1fr; }
  .builder-preview { width: 170px; margin: 0 auto; }
  .ctl-row { grid-template-columns: 1fr; gap: .25rem; }
}

/* ---------------------------------------------------------------- timeline */
.month-bar {
  position: sticky; top: var(--topbar-h); z-index: 500; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
  background: rgba(251, 246, 239, .95); backdrop-filter: blur(6px); padding: .5rem .2rem; margin: 0 -.2rem 1rem;
  justify-content: space-between;
}
.month-bar::-webkit-scrollbar, .chips.scroll-x::-webkit-scrollbar { display: none; }
.month-bar a {
  flex: 1 0 auto; text-align: center; text-decoration: none; color: var(--ink); font-weight: 700; font-size: .85rem;
  padding: .35rem .55rem; border-radius: 999px; text-transform: capitalize; position: relative;
}
.month-bar a.empty { color: #c3b6a8; }
.month-bar a.current { background: var(--fox); color: #fff; }
.mcount { font-size: .65rem; font-weight: 600; margin-left: .15rem; opacity: .75; vertical-align: super; }

.timeline { position: relative; padding: 0 0 3rem; }
.timeline::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: var(--line); transform: translateX(-50%); }
.tl-month { position: relative; text-align: center; margin: 2rem 0 1rem; scroll-margin-top: 140px; }
.tl-month span {
  position: relative; display: inline-block; background: var(--ink); color: #fff; font-weight: 800; text-transform: capitalize;
  padding: .35rem 1.1rem; border-radius: 999px; font-size: 1.05rem;
}
.tl-empty { text-align: center; color: #b9ab9c; font-size: .85rem; position: relative; background: var(--paper); width: max-content; margin: 0 auto; padding: 0 .5rem; }
.tl-item { position: relative; width: 50%; padding: .6rem 2.2rem; }
.tl-item.left { margin-right: 50%; }
.tl-item.right { margin-left: 50%; }
.tl-dot { position: absolute; top: 1.6rem; width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--c); }
.tl-item.left .tl-dot { right: -8px; }
.tl-item.right .tl-dot { left: -8px; }
.tl-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; border-top: 4px solid var(--c); transition: transform .15s, box-shadow .15s; }
.tl-card:hover, .tl-card:focus { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(60, 35, 10, .14); outline: none; }
.tl-card img { width: 100%; display: block; max-height: 420px; object-fit: cover; background: #f1ebe4; }
.tl-card-body { padding: .75rem .9rem .9rem; }
.tl-who { display: flex; align-items: center; gap: .5rem; }
.tl-when { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.tl-desc { margin: .45rem 0 0; }
@media (max-width: 760px) {
  .timeline::before { left: 14px; }
  .tl-item, .tl-item.left, .tl-item.right { width: 100%; margin: 0; padding: .5rem 0 .5rem 2.2rem; }
  .tl-item .tl-dot, .tl-item.left .tl-dot, .tl-item.right .tl-dot { left: 6px; right: auto; }
  .tl-month { text-align: left; }
  .tl-empty { margin: 0 0 0 2.2rem; }
  .month-bar { justify-content: flex-start; }
}

/* ---------------------------------------------------------------- lightbox */
.lightbox { border: 0; padding: 0; width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; background: #120c07; color: #fff; }
.lb-inner { display: grid; grid-template-columns: 1fr 340px; height: 100%; position: relative; }
.lb-figure { margin: 0; display: grid; place-items: center; min-height: 0; padding: 1rem; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 2rem); object-fit: contain; border-radius: 6px; }
.lb-meta { background: #1d140d; padding: 1.3rem 1.2rem; overflow: auto; }
.lb-meta .muted { color: #b5a796; }
.lb-who { display: flex; gap: .7rem; align-items: center; }
.lb-desc { font-size: 1.15rem; line-height: 1.45; margin: 1rem 0; }
.lb-dl { display: grid; grid-template-columns: auto 1fr; gap: .45rem .8rem; font-size: .9rem; margin: 1rem 0; }
.lb-dl dt { color: #b5a796; white-space: nowrap; }
.lb-dl dd { margin: 0; }
.lb-map { height: 180px; border-radius: 10px; margin: .5rem 0 1rem; }
.lb-actions { display: flex; gap: .5rem; }
.lb-actions .btn { background: #2d2118; color: #fff; border-color: #4a3829; }
.lb-close { position: absolute; top: .6rem; right: .8rem; z-index: 5; color: #fff; background: rgba(0,0,0,.4); border-radius: 50%; width: 40px; height: 40px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; background: rgba(0,0,0,.35); color: #fff; border: 0; font-size: 2.4rem; width: 52px; height: 72px; cursor: pointer; border-radius: 10px; }
.lb-nav.prev { left: .5rem; }
.lb-nav.next { right: calc(340px + .5rem); }
@media (max-width: 860px) {
  .lb-inner { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .lb-figure { padding: 3.2rem .3rem .3rem; }
  .lb-figure img { max-height: 62vh; }
  .lb-nav { top: 34vh; width: 40px; height: 56px; font-size: 2rem; }
  .lb-nav.next { right: .3rem; }
  .lb-nav.prev { left: .3rem; }
  .lb-meta { padding-bottom: 2rem; }
}

/* ---------------------------------------------------------------- map */
.map-page .map-main { padding: 0; }
#map { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: var(--bottombar-h); z-index: 1; background: #e9e4dc; }
.map-panel {
  position: fixed; z-index: 600; top: calc(var(--topbar-h) + .7rem); left: .7rem; right: .7rem; max-width: 760px; margin: 0 auto;
  background: rgba(255,255,255,.95); backdrop-filter: blur(6px); border-radius: 16px; box-shadow: var(--shadow); padding: .6rem; display: grid; gap: .5rem;
}
.map-controls { display: flex; gap: .5rem; align-items: center; }
.map-range { display: flex; align-items: center; gap: .5rem; flex: 1; font-size: .82rem; }
.map-range span { min-width: 92px; text-transform: capitalize; }
.map-range input { padding: 0; accent-color: var(--fox); }
.pin { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--c); background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.3); cursor: pointer; transition: transform .15s; }
.pin:hover { transform: scale(1.15); }
.pin img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; border: 2px solid #fff; }
.pin span { position: absolute; bottom: -6px; right: -6px; background: var(--c); color: #fff; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; border: 2px solid #fff; }
.map-popup { position: relative; width: min(290px, 80vw); background: #fff; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.25); padding: .6rem; }
.map-popup::after { content: ""; position: absolute; left: 50%; bottom: -9px; margin-left: -9px; border: 9px solid transparent; border-bottom: 0; border-top-color: #fff; }
.popup-close { position: absolute; top: .9rem; right: .9rem; z-index: 2; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); cursor: pointer; font-size: .9rem; }
.pop-img { width: 100%; height: 180px; border-radius: 8px; display: block; object-fit: cover; cursor: zoom-in; background: #f1ebe4; }
.pop-who { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; }
.pop-when, .pop-where { font-size: .8rem; color: var(--muted); }
.pop-desc { margin: .4rem 0 0; font-size: .95rem; line-height: 1.4; }
.pop-nav { display: flex; justify-content: space-between; margin-top: .5rem; }

/* OpenLayers controls */
#map .ol-zoom { top: auto; left: auto; right: .7rem; bottom: 2.4rem; }
.ol-control button { width: 2rem; height: 2rem; font-size: 1.2rem; }
.ol-attribution { font-size: .7rem; }
.loc-map, .lb-map { position: relative; overflow: hidden; }

/* ---------------------------------------------------------------- admin */
.toggles { display: grid; gap: .7rem; }
.toggle { display: flex; align-items: center; gap: .7rem; cursor: pointer; font-weight: 600; }
.toggle input { display: none; }
.toggle span { width: 46px; height: 26px; border-radius: 99px; background: #d9cdbf; position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggles .btn { justify-self: start; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl details summary { list-style: none; }
.tbl details summary::-webkit-details-marker { display: none; }
.action-menu { display: grid; gap: .4rem; padding: .5rem 0; min-width: 240px; }
form.inline { display: flex; gap: .4rem; align-items: center; margin: 0; }
form.inline input { padding: .35rem .5rem; font-size: .85rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; align-items: end; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
label.check input { width: auto; }
.music-form { margin-top: .8rem; }
.video-status { margin-top: 1rem; }
.video-preview { width: 100%; max-width: 640px; border-radius: 10px; background: #000; }
.log { background: #1d140d; color: #e8dccd; padding: .7rem; border-radius: 10px; font-size: .75rem; overflow-x: auto; white-space: pre-wrap; }

/* ---------------------------------------------------------------- misc */
.locked { text-align: center; padding: 4rem 1rem; }
.locked-fox { font-size: 4rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottombar-h) + 1.2rem); transform: translate(-50%, 150%); z-index: 3000;
  background: var(--ink); color: #fff; padding: .65rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
  transition: transform .25s, opacity .25s; max-width: 92vw; text-align: center; pointer-events: none;
  opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.err { background: var(--err); }
@media (max-width: 760px) {
  .pop-img { height: 130px; }
  .map-panel { top: calc(var(--topbar-h) + .4rem); left: .4rem; right: .4rem; }
}
