:root {
  --parchment: #ECDBBA;
  --parchment-light: #F8F5E9;
  --parchment-dark: #D2B88E;
  --gold: #BFA357;
  --gold-dark: #9C7F3C;
  --ink: #2B2118;
  --ink-soft: #55493A;
  --danger: #B3261E;
  --success: #3E6B4F;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--parchment-light);
  color: var(--ink);
  font-family: Georgia, "Lora", serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .heading {
  font-family: "Libre Bodoni", Georgia, serif;
  color: var(--ink);
  font-weight: 600;
  margin: 0 0 8px 0;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: calc(16px + var(--safe-top)) 16px 16px 16px;
}
.screen.active { display: flex; }
.screen.no-scroll { overflow: hidden; padding: 0; }
#content.flush { padding: 0 !important; overflow: hidden !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  position: sticky;
  top: 0;
  background: var(--parchment-light);
  z-index: 5;
}
.topbar h2 { flex: 1; margin: 0; font-size: 20px; }
.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
}
.icon-btn:active { background: rgba(0,0,0,0.06); }

.card {
  background: var(--parchment);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(43,33,24,0.12);
  border: 1px solid var(--parchment-dark);
  cursor: pointer;
}
.card:active { background: var(--parchment-dark); }
.card .title { font-family: "Libre Bodoni", Georgia, serif; font-weight: 600; font-size: 17px; margin-bottom: 4px; }
.card .subtitle { font-size: 14px; color: var(--ink-soft); }
.card .cover-img {
  width: 100%; height: 140px; object-fit: cover; border-radius: 12px; margin-bottom: 10px;
  background: var(--parchment-dark);
}

.btn {
  display: inline-block;
  background: var(--gold-dark);
  color: var(--parchment-light);
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  font-family: Georgia, serif;
}
.btn:active { background: var(--ink); }
.btn.secondary { background: transparent; color: var(--gold-dark); border: 1.5px solid var(--gold-dark); }
.btn.full { width: 100%; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; }

input[type=text], input[type=password], input[type=email] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--parchment-dark);
  background: var(--parchment-light);
  font-size: 16px;
  margin-bottom: 12px;
  font-family: Georgia, serif;
  color: var(--ink);
}
input:focus { outline: none; border-color: var(--gold-dark); }

.center-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
}

.logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; }
.logo-wrap .logo-circle {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gold-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: "Libre Bodoni", serif; font-size: 30px; color: var(--parchment-light); font-weight: 700;
}

.error-text { color: var(--danger); font-size: 14px; margin: -6px 0 10px 0; }
.hint { color: var(--ink-soft); font-size: 14px; }

/* Bottom tab bar */
#tabbar {
  display: flex;
  background: var(--ink);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}
#tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: rgba(248,245,233,0.55);
  padding: 10px 4px 8px 4px;
  font-family: Georgia, serif;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
#tabbar button .tab-icon { font-size: 21px; }
#tabbar button.active { color: var(--gold); }

/* Info card tree */
.deep-dive-tile {
  display: flex; align-items: center; gap: 12px;
  background: var(--parchment-light);
  border: 1px solid var(--parchment-dark);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.deep-dive-tile:active { background: var(--parchment-dark); }
.deep-dive-tile .dd-icon { font-size: 20px; width: 26px; text-align: center; }
.deep-dive-tile .dd-title { font-weight: 600; flex: 1; }
.deep-dive-tile .dd-arrow { color: var(--ink-soft); }

.pager-nav {
  position: sticky; bottom: 0;
  display: flex; gap: 10px; padding: 12px 0 calc(8px + var(--safe-bottom)) 0;
  background: var(--parchment-light);
}
.pager-nav .btn { flex: 1; }

.video-embed {
  position: relative; width: 100%; padding-top: 56.25%; margin-bottom: 14px;
  border-radius: 12px; overflow: hidden; background: #000;
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

/* Map */
#map-screen { padding: 0 !important; }
#leaflet-map { flex: 1; width: 100%; }

/* AR */
#ar-screen { background: #000; position: relative; }
#ar-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ar-overlay { position: absolute; inset: 0; pointer-events: none; }
.ar-marker {
  position: absolute;
  width: 180px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  border: 1.2px solid var(--gold);
  border-radius: 14px;
  padding: 8px 12px;
  color: #fff;
  pointer-events: auto;
  font-family: Georgia, serif;
  cursor: pointer;
}
.ar-marker .ar-marker-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.ar-marker .ar-marker-dist { color: var(--parchment); font-size: 12px; margin-top: 2px; }
.ar-compass-bar {
  position: absolute; top: calc(16px + var(--safe-top)); left: 16px; right: 16px;
  background: rgba(0,0,0,0.54); color: #fff; border-radius: 20px;
  padding: 8px 16px; text-align: center; font-weight: 600; font-family: Georgia, serif;
  pointer-events: none;
}
.ar-hint {
  position: absolute; bottom: calc(24px + var(--safe-bottom)); left: 24px; right: 24px;
  background: rgba(0,0,0,0.54); color: #fff; border-radius: 10px; padding: 12px; text-align: center;
}
.ar-gate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--parchment-light); text-align: center; padding: 24px;
}

.loading-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--parchment-dark); border-top-color: var(--gold-dark);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; color: var(--ink-soft); padding: 40px 20px; }

.profile-row {
  display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--parchment-dark);
}
.profile-row .label { color: var(--ink-soft); }
