/* ============================================================
   Cancun Villa Dossier — tokens + components + responsive
   "Marine Ink & Sand" — dark page, sand cards, coral pick, gold rank
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Color */
  --ink: #0E2230;
  --ink-raised: #16323F;
  --sand: #E8DEC9;
  --sand-edge: #D2C4A6;
  --coral: #FF6B53;
  --gold: #C9A24B;
  --silver: #AEB7BD;
  --bronze: #B07A4A;

  /* Text */
  --on-sand-head: #0E2230;
  --on-sand-body: #3A4A52;
  --on-sand-mute: #6B7780;
  --on-ink-head: #E8DEC9;
  --on-ink-body: #9FB0BA;

  /* Focus (contract mobile flag #2 — site-wide) */
  --focus: var(--coral);

  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Radius */
  --r-card: 4px; --r-chip: 3px;

  /* Elevation */
  --shadow-card: 0 6px 20px -8px rgba(0,0,0,.45);
  --shadow-modal: 0 24px 60px -12px rgba(0,0,0,.6);
  --scrim: rgba(8,18,26,.72);

  /* Type scale (rem) */
  --t-cap: 0.69rem;
  --t-label: 0.75rem;
  --t-sm: 0.875rem;
  --t-body: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.563rem;
  --t-xl: 1.953rem;
  --t-hero: 3.05rem;

  /* Motion */
  --mo-fast: 160ms ease;
  --mo-entry: 240ms cubic-bezier(.2,.7,.2,1);
  --mo-bar: 320ms cubic-bezier(.2,.7,.2,1);

  --ff-display: "Fraunces", Georgia, serif;
  --ff-body: "Inter", system-ui, sans-serif;
  --ff-mono: "IBM Plex Mono", ui-monospace, monospace;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--on-ink-body);
  font-family: var(--ff-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Site-wide visible focus (WCAG 2.4.11) — no native title tooltips anywhere */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--ff-body);
  font-weight: 500;
  font-size: var(--t-sm);
  border-radius: var(--r-card);
  border: 1px solid transparent;
  padding: 10px 16px;
  line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--mo-fast), border-color var(--mo-fast), opacity var(--mo-fast);
  min-height: 44px;
}
.btn-primary { background: var(--coral); color: #2A0E08; border-color: var(--coral); font-weight: 600; }
.btn-primary:hover { background: #ff7d68; }
.btn-ghost { background: transparent; color: var(--on-sand-head); border-color: var(--sand-edge); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .spinner { width: 14px; height: 14px; }

/* On-ink ghost variant */
.btn-ghost-ink { background: transparent; color: var(--on-ink-head); border-color: rgba(210,196,166,.4); }
.btn-ghost-ink:hover { border-color: var(--gold); }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   GATE
   ============================================================ */
.gate {
  min-height: 100dvh; display: grid; place-items: center;
  padding: var(--s-5);
  padding-top: calc(var(--s-5) + env(safe-area-inset-top));
  background: radial-gradient(120% 90% at 50% -10%, #16323F 0%, var(--ink) 60%);
}
.gate-card {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--ink-raised);
  border: 1px solid rgba(210,196,166,.18);
  border-radius: var(--r-card);
  padding: var(--s-7) var(--s-5);
  box-shadow: var(--shadow-modal);
}
.gate-brand { display: flex; align-items: center; justify-content: center; gap: 8px; }
.gate-hex, .brand-hex, .gate-wordmark { color: var(--gold); }
.gate-wordmark, .brand {
  font-family: var(--ff-mono); font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; font-size: var(--t-label); color: var(--on-ink-head);
}
.gate-sub { font-size: var(--t-sm); color: var(--on-ink-body); margin: 8px 0 var(--s-6); }
.gate-prompt { font-family: var(--ff-body); font-weight: 500; font-size: var(--t-body); color: var(--on-ink-head); margin: 0 0 var(--s-4); }
.gate-helper { font-size: var(--t-sm); color: var(--on-ink-body); margin: -8px 0 var(--s-5); }

.code-input { display: flex; gap: var(--s-2); justify-content: center; margin-bottom: var(--s-5); }
.code-cell {
  width: 56px; height: 64px; text-align: center;
  font-family: var(--ff-mono); font-size: var(--t-md); font-weight: 500;
  color: var(--on-ink-head); background: var(--ink);
  border: 1px solid var(--sand-edge); border-radius: var(--r-card);
  caret-color: var(--coral);
}
.code-cell:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.gate-error { color: var(--coral); font-size: var(--t-sm); margin: var(--s-4) 0 0; }

.identity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.identity-btn {
  min-height: 64px; border-radius: var(--r-card);
  background: var(--ink); border: 1px solid var(--sand-edge);
  color: var(--on-ink-head); font-size: var(--t-body); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color var(--mo-fast), background var(--mo-fast);
}
.identity-btn .hex { color: var(--gold); }
.identity-btn:hover { border-color: var(--coral); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--ink-raised);
  border-bottom: 1px solid rgba(210,196,166,.15);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; gap: var(--s-4);
  max-width: 1200px; margin: 0 auto; padding: 0 var(--s-5);
  height: 56px;
}
.brand { white-space: nowrap; }
.brand-hex { margin-right: 4px; }

.tabs { display: flex; gap: var(--s-2); margin: 0 auto; }
.tab {
  background: none; border: none; padding: 18px var(--s-4);
  color: var(--on-ink-body); font-size: var(--t-sm); font-weight: 500;
  border-bottom: 2px solid transparent; position: relative;
}
.tab[aria-current="page"] { color: var(--on-ink-head); border-bottom-color: var(--coral); }
.tab:hover { color: var(--on-ink-head); }

.identity-chip {
  background: var(--ink); border: 1px solid rgba(210,196,166,.25);
  color: var(--on-ink-head); border-radius: var(--r-card);
  padding: 8px 12px; font-size: var(--t-sm); display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
}
.identity-chip .hex { color: var(--gold); }
.identity-chip .caret { color: var(--on-ink-body); font-size: .7rem; }

/* Logistics */
.logistics { background: var(--ink-raised); border-bottom: 1px solid rgba(210,196,166,.12); }
.logistics-toggle { display: none; }
.logistics-content {
  display: flex; gap: 0; max-width: 1200px; margin: 0 auto;
  font-family: var(--ff-mono); font-size: var(--t-label);
  color: var(--on-ink-body);
}
.logi-cell { flex: 1; padding: 10px var(--s-5); }
.logi-cell + .logi-cell { border-left: 1px solid rgba(210,196,166,.12); }
.plane { color: var(--coral); margin-right: 6px; }

/* Main + views */
.main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: var(--s-6) var(--s-5); }
.view:focus { outline: none; }

.view-head { margin-bottom: var(--s-5); display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.view-title { font-family: var(--ff-display); font-weight: 420; font-size: var(--t-xl); color: var(--on-ink-head); margin: 0; letter-spacing: -.01em; }
.view-status { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-ink-body); }

/* Bottom tab bar (mobile only) */
.tabbar { display: none; }

/* ============================================================
   VILLA GRID + CARD
   ============================================================ */
.villa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); }

.card {
  background: var(--sand); color: var(--on-sand-body);
  border: 1px solid var(--sand-edge); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform var(--mo-fast), border-color var(--mo-fast);
}
.card:hover { transform: translateY(-2px); border-color: rgba(201,162,75,.6); }

.card-photo { position: relative; aspect-ratio: 3/2; background: var(--sand-edge); overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.fav-chip {
  position: absolute; top: 8px; right: 8px;
  background: rgba(14,34,48,.78); color: var(--sand);
  font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em;
  padding: 4px 8px; border-radius: var(--r-chip);
}
/* In-place photo paging on the card (does NOT open detail) */
.photo-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(14,34,48,.6); color: var(--sand);
  font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--mo-fast), background var(--mo-fast);
}
.photo-nav.prev { left: 8px; }
.photo-nav.next { right: 8px; }
.photo-nav:hover { background: rgba(14,34,48,.85); }
.card-photo:hover .photo-nav, .photo-nav:focus-visible { opacity: 1; }
.photo-counter-wrap { position: absolute; bottom: 8px; right: 8px; }
.photo-count {
  background: rgba(14,34,48,.78); color: var(--sand);
  font-family: var(--ff-mono); font-size: var(--t-cap);
  padding: 4px 8px; border-radius: var(--r-chip);
}
/* Touch: arrows always visible (no hover) */
@media (hover: none) {
  .photo-nav { opacity: 1; }
}

.card-body { padding: 20px; display: flex; flex-direction: column; gap: var(--s-3); flex: 1; }

.laurel { color: var(--gold); font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .1em; text-transform: uppercase; }
.card-name { font-family: var(--ff-display); font-weight: 420; font-size: var(--t-xl); line-height: 1.1; color: var(--on-sand-head); margin: 0; letter-spacing: -.01em; }
.card-tail { font-size: var(--t-sm); color: var(--on-sand-mute); margin: -6px 0 0; }
.card-area { font-family: var(--ff-mono); font-size: var(--t-label); letter-spacing: .06em; text-transform: uppercase; color: var(--on-sand-mute); }

.flag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.flag {
  font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: var(--r-chip);
  background: rgba(14,34,48,.08); color: var(--on-sand-body); border: 1px solid var(--sand-edge);
}
.flag-warn { color: var(--coral); border-color: var(--coral); background: rgba(255,107,83,.08); }

/* Data strip */
.data-strip { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-sand-body); line-height: 1.7; }
.data-strip .price-was { text-decoration: line-through; color: var(--sand-edge); margin-left: 6px; }
.data-strip .pp { color: var(--on-sand-head); font-weight: 500; }
.data-strip .nightly { color: var(--on-sand-mute); }
/* Card logistics hint — two facts, mono, lightly separated from price data */
.logi-hint { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--sand-edge); color: var(--on-sand-body); }

.card-actions { display: flex; gap: var(--s-2); margin-top: auto; padding-top: var(--s-2); }
.card-actions .btn { flex: 1; }

/* ============================================================
   SCORECARD (signature)
   ============================================================ */
.scorecard { border-top: 1px solid var(--sand-edge); border-bottom: 1px solid var(--sand-edge); padding: var(--s-3) 0; }
.scorecard-label { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .12em; color: var(--on-sand-mute); margin-bottom: var(--s-2); }
.glyph-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; list-style: none; margin: 0; padding: 0; }
.glyph-slot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; padding: 8px 0; min-height: 44px;
  font-family: var(--ff-mono); position: relative;
}
.glyph {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
}
/* verdict states — shape differs, not just color */
.glyph-yes { background: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,75,.35); }
.glyph-likely { background: linear-gradient(90deg, var(--gold) 50%, transparent 50%); box-shadow: 0 0 0 2px rgba(201,162,75,.45); }
.glyph-disputed { background: transparent; box-shadow: 0 0 0 2px var(--coral); color: var(--coral); }
.glyph-disputed::before { content: "/"; font-weight: 700; }
.glyph-no { background: transparent; box-shadow: 0 0 0 2px var(--on-sand-mute); }
.glyph-unknown { background: transparent; box-shadow: 0 0 0 2px var(--on-sand-mute); color: var(--on-sand-mute); }
.glyph-unknown::before { content: "?"; font-size: 10px; }
.glyph-na { background: transparent; box-shadow: 0 0 0 2px var(--sand-edge); color: var(--on-sand-mute); }
.glyph-na::before { content: "\2013"; }
.glyph-cap { font-size: var(--t-cap); letter-spacing: .04em; color: var(--on-sand-mute); }
.glyph-slot[aria-expanded="true"] .glyph { outline: 1px solid var(--coral); outline-offset: 2px; }

/* Inline note panel (mobile card reveal) */
.scorecard-note {
  background: var(--sand-edge); padding: var(--s-3); margin-top: var(--s-2);
  border-radius: var(--r-chip);
}
.scorecard-note .note-head { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--on-sand-head); margin-bottom: 4px; }
.scorecard-note .note-body { font-size: var(--t-sm); color: var(--on-sand-body); }

/* Custom hover tooltip (desktop) — NEVER native title */
.tooltip {
  position: fixed; z-index: 60; max-width: 280px;
  background: var(--ink-raised); color: var(--sand);
  border: 1px solid rgba(210,196,166,.3); border-radius: var(--r-card);
  padding: 8px 10px; font-size: var(--t-sm); box-shadow: var(--shadow-modal);
  pointer-events: none;
}
.tooltip .tt-head { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }

/* Scorecard full-list (in detail) */
.scorecard-full { display: flex; flex-direction: column; gap: var(--s-3); }
.sc-full-row { display: grid; grid-template-columns: 24px 1fr; gap: var(--s-3); align-items: start; }
.sc-full-row .glyph { margin-top: 2px; }
.sc-full-head { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .06em; text-transform: uppercase; color: var(--on-sand-head); display: flex; justify-content: space-between; gap: 8px; }
.sc-full-head .state { color: var(--on-sand-mute); }
.sc-full-head .state.disputed { color: var(--coral); }
.sc-full-note { font-size: var(--t-sm); color: var(--on-sand-body); margin-top: 2px; }

/* ============================================================
   SKELETONS
   ============================================================ */
.skel-card { background: var(--sand); border: 1px solid var(--sand-edge); border-radius: var(--r-card); overflow: hidden; }
.skel-photo { aspect-ratio: 3/2; }
.skel-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.skel-bar { height: 14px; border-radius: 3px; background: var(--sand-edge); }
.skel-bar.w70 { width: 70%; } .skel-bar.w40 { width: 40%; } .skel-bar.w90 { width: 90%; }
.skel-glyphs { display: grid; grid-template-columns: repeat(6,1fr); gap: 6px; margin-top: 6px; }
.skel-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--sand-edge); margin: 0 auto; }
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================================================
   ERROR / EMPTY panels
   ============================================================ */
.panel {
  background: var(--sand); color: var(--on-sand-body);
  border: 1px solid var(--sand-edge); border-radius: var(--r-card);
  padding: var(--s-7) var(--s-5); text-align: center;
}
.panel p { margin: 0 0 var(--s-4); font-size: var(--t-body); color: var(--on-sand-body); }
.panel .panel-title { font-family: var(--ff-display); font-size: var(--t-md); color: var(--on-sand-head); }

/* ============================================================
   VOTE
   ============================================================ */
.ballot { display: flex; flex-direction: column; gap: var(--s-4); max-width: 720px; }
.ballot-sub { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-ink-body); margin: -8px 0 0; }
.slot {
  background: var(--sand); color: var(--on-sand-body);
  border: 1px solid var(--sand-edge); border-radius: var(--r-card);
  padding: var(--s-4); display: grid; grid-template-columns: 72px 1fr auto; gap: var(--s-4); align-items: center;
}
.slot.flash { animation: flash .5s ease; }
@keyframes flash { 0%,100% { border-color: var(--sand-edge); } 30% { border-color: var(--coral); } }
.slot-rank { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-sand-mute); }
.slot-thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 3px; background: var(--sand-edge); }
.slot-rankbadge { display: flex; align-items: center; gap: 6px; font-family: var(--ff-mono); font-size: var(--t-label); }
.slot-name { font-family: var(--ff-display); font-size: var(--t-md); color: var(--on-sand-head); margin: 2px 0; line-height: 1.1; }
.slot-area { font-size: var(--t-sm); color: var(--on-sand-mute); }
.slot-comment { font-size: var(--t-sm); font-style: italic; color: var(--on-sand-body); margin-top: 4px; }
.slot-mini-glyphs { display: flex; gap: 4px; margin-top: 6px; align-items: center; font-size: var(--t-cap); color: var(--on-sand-mute); }
.slot-mini-glyphs .glyph { width: 12px; height: 12px; }
.slot-controls { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--r-card); background: transparent; border: 1px solid var(--sand-edge); color: var(--on-sand-head); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:hover:not(:disabled) { border-color: var(--coral); color: var(--coral); }
.slot-empty { grid-template-columns: 1fr; text-align: center; color: var(--on-sand-mute); }
.slot-empty .slot-rank { text-align: left; }
.slot-empty p { margin: var(--s-2) 0 0; font-size: var(--t-sm); }

.field-label { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--on-ink-body); display: block; margin-bottom: 6px; }
.textarea {
  width: 100%; background: var(--sand); color: var(--on-sand-head);
  border: 1px solid var(--sand-edge); border-radius: var(--r-card);
  padding: var(--s-3); font-family: var(--ff-body); font-size: var(--t-body); resize: vertical; min-height: 72px;
}
.textarea:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.autosave { font-family: var(--ff-mono); font-size: var(--t-cap); color: var(--on-ink-body); text-align: right; }
.autosave .ok { color: var(--gold); }

/* ============================================================
   TALLY
   ============================================================ */
.tally-list { display: flex; flex-direction: column; gap: var(--s-5); max-width: 820px; }
.tally-row .t-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: 6px; }
.t-name { font-family: var(--ff-display); font-size: var(--t-md); color: var(--on-ink-head); display: flex; align-items: center; gap: 8px; }
.medal { font-size: var(--t-md); }
.medal.g1 { color: var(--gold); } .medal.g2 { color: var(--silver); } .medal.g3 { color: var(--bronze); }
.t-points { font-family: var(--ff-mono); font-size: var(--t-sm); color: var(--on-ink-head); white-space: nowrap; }
.bar { display: flex; height: 40px; border-radius: var(--r-chip); overflow: hidden; background: var(--ink-raised); border: 1px solid rgba(210,196,166,.15); }
.seg { border: none; display: flex; align-items: center; padding: 0 8px; color: #1b1206; font-family: var(--ff-mono); font-size: var(--t-cap); white-space: nowrap; overflow: hidden; min-width: 0; transition: width var(--mo-bar); }
.seg + .seg { border-left: 1px solid rgba(14,34,48,.3); }
.seg.s1 { background: var(--gold); } .seg.s2 { background: var(--silver); } .seg.s3 { background: var(--bronze); color: #fff; }
.t-meta { font-family: var(--ff-mono); font-size: var(--t-cap); color: var(--on-ink-body); margin-top: 6px; }
.t-legend { display: none; gap: var(--s-3); margin-top: 6px; flex-wrap: wrap; }
.legend-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--ff-mono); font-size: var(--t-cap); color: var(--on-ink-body); }
.legend-sq { width: 12px; height: 12px; border-radius: 2px; }
.legend-sq.s1 { background: var(--gold); } .legend-sq.s2 { background: var(--silver); } .legend-sq.s3 { background: var(--bronze); }
.comment-reveal { background: var(--ink-raised); border: 1px solid rgba(210,196,166,.18); border-radius: var(--r-card); padding: var(--s-3); margin-top: var(--s-2); font-size: var(--t-sm); color: var(--on-ink-head); }
.comment-reveal .who { font-family: var(--ff-mono); font-size: var(--t-cap); color: var(--gold); }

.tally-divider { display: flex; align-items: center; gap: var(--s-3); color: var(--on-ink-body); font-family: var(--ff-mono); font-size: var(--t-cap); text-transform: uppercase; letter-spacing: .08em; margin: var(--s-4) 0; }
.tally-divider::before, .tally-divider::after { content: ""; flex: 1; height: 1px; background: rgba(210,196,166,.2); }
.novote-toggle { background: none; border: none; color: var(--on-ink-body); font-family: var(--ff-mono); font-size: var(--t-cap); text-align: left; padding: 6px 0; }
.novote-toggle:hover { color: var(--on-ink-head); }
.whos-voted { margin-top: var(--s-6); }
.whos-voted .label { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; color: var(--on-ink-body); margin-bottom: var(--s-2); }
.voter-chips { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.voter-chip { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-ink-body); display: inline-flex; align-items: center; gap: 6px; }
.voter-chip .hex { color: var(--gold); }
.voter-chip .check { color: var(--gold); } .voter-chip .pending { color: var(--coral); }

.comment-rail { margin-top: var(--s-6); }
.comment-rail h3 { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--on-ink-body); }
.rail-item { font-size: var(--t-sm); color: var(--on-ink-body); padding: 6px 0; border-bottom: 1px solid rgba(210,196,166,.1); }
.rail-item .who { font-family: var(--ff-mono); font-size: var(--t-cap); color: var(--gold); margin-right: 6px; }

/* ============================================================
   OVERLAYS: modal (detail) + bottom sheets
   ============================================================ */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 40;
  display: grid; place-items: center; padding: var(--s-5);
  animation: fade var(--mo-fast);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--sand); color: var(--on-sand-body);
  width: 100%; max-width: 920px; max-height: 88vh; overflow: hidden;
  border-radius: var(--r-card); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column;
  animation: rise var(--mo-entry);
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

.modal-head { padding: var(--s-5); border-bottom: 1px solid var(--sand-edge); display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.modal-title { font-family: var(--ff-display); font-size: var(--t-lg); color: var(--on-sand-head); margin: 0; line-height: 1.1; }
.modal-sub { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .06em; text-transform: uppercase; color: var(--on-sand-mute); margin-top: 6px; }
.modal-close { width: 44px; height: 44px; flex: none; background: transparent; border: 1px solid var(--sand-edge); border-radius: var(--r-card); color: var(--on-sand-head); font-size: 18px; }
.modal-close:hover { border-color: var(--coral); }
.modal-body { padding: var(--s-5); overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
/* let grid tracks shrink below their content's intrinsic width (stops the full-res
   hero image from forcing horizontal scroll); cap every media element to its column */
.modal-body > div { min-width: 0; }
.modal-body img, .modal-body iframe { max-width: 100%; }
.modal-actions { display: flex; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--sand-edge); }
.modal-actions .btn { flex: 1; }

.gallery-hero { aspect-ratio: 3/2; background: var(--sand-edge); border-radius: var(--r-card); overflow: hidden; position: relative; }
.gallery-hero img { width: 100%; height: 100%; object-fit: cover; }
.gallery-nav { position: absolute; bottom: 8px; right: 8px; display: flex; gap: 6px; align-items: center; }
.gallery-nav button { width: 36px; height: 36px; border-radius: var(--r-card); background: rgba(14,34,48,.78); color: var(--sand); border: none; }
.gallery-count { background: rgba(14,34,48,.78); color: var(--sand); font-family: var(--ff-mono); font-size: var(--t-cap); padding: 6px 8px; border-radius: var(--r-chip); }
/* Thumbnail strip — single scrollable band, handles all 18 photos */
.thumb-strip { display: flex; gap: 6px; margin-top: var(--s-2); overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--sand-edge) transparent; }
.thumb-strip::-webkit-scrollbar { height: 6px; }
.thumb-strip::-webkit-scrollbar-thumb { background: var(--sand-edge); border-radius: 3px; }
.thumb-strip button { flex: none; width: 64px; height: 42px; border-radius: 3px; overflow: hidden; border: 1px solid transparent; background: var(--sand-edge); padding: 0; }
.thumb-strip button[aria-current="true"] { border-color: var(--coral); }
.thumb-strip img { width: 100%; height: 100%; object-fit: cover; }

.modal-data { font-family: var(--ff-mono); font-size: var(--t-label); color: var(--on-sand-body); line-height: 1.8; }
.modal-section-label { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--on-sand-mute); margin: var(--s-4) 0 4px; }
.modal-notes { font-size: var(--t-sm); color: var(--on-sand-body); }

/* Getting around — three labeled reference rows */
.around { display: flex; flex-direction: column; gap: var(--s-2); }
.around-row { display: grid; grid-template-columns: 72px 1fr; gap: var(--s-3); align-items: start; }
.around-label { font-family: var(--ff-mono); font-size: var(--t-cap); letter-spacing: .06em; color: var(--on-sand-mute); padding-top: 2px; }
.around-value { font-size: var(--t-sm); color: var(--on-sand-head); }
.around-note { font-size: var(--t-sm); color: var(--on-sand-mute); margin-top: 2px; }

/* Map clipping — pinned location artifact, always a working Google Maps link */
.map-link { display: block; position: relative; border: 1px solid var(--sand-edge); border-radius: var(--r-card); overflow: hidden; text-decoration: none; }
.map-link:hover { border-color: var(--gold); }
.map-img { width: 100%; height: 200px; object-fit: cover; display: block; background: var(--sand-edge); }
/* OSM embed shown as a non-interactive picture; clicks fall through to the wrapping
   <a>, so the whole map opens Google Maps. */
.map-frame { width: 100%; height: 220px; display: block; border: 0; background: var(--sand-edge); pointer-events: none; }
.map-cta { position: absolute; bottom: 8px; right: 8px; background: rgba(14,34,48,.82); color: var(--sand); font-family: var(--ff-mono); font-size: var(--t-cap); padding: 5px 9px; border-radius: var(--r-chip); }
/* Fallback when tiles fail to load — still clickable */
.map-fallback { display: grid; place-items: center; min-height: 120px; background: var(--ink-raised); }
.map-fallback .map-cta { position: static; }
.map-fallback-text { color: var(--coral); font-family: var(--ff-mono); font-size: var(--t-sm); padding: var(--s-4); }

/* Bottom sheet (rank picker / identity) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--sand); color: var(--on-sand-body);
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-modal);
  padding: var(--s-4) var(--s-5);
  padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: sheetUp var(--mo-entry);
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--sand-edge); margin: 0 auto var(--s-4); }
.sheet-ink { background: var(--ink-raised); color: var(--on-ink-head); }
.sheet-ink .sheet-handle { background: rgba(210,196,166,.4); }
.sheet-title { font-family: var(--ff-body); font-weight: 500; font-size: var(--t-body); margin: 0 0 var(--s-3); }
.sheet-ink .sheet-title { color: var(--on-ink-head); }
.sheet-divider { height: 1px; background: var(--sand-edge); margin: var(--s-3) 0; }

.rank-btns { display: flex; gap: var(--s-3); margin-bottom: var(--s-4); }
.rank-btn {
  width: 56px; height: 56px; border-radius: var(--r-card);
  background: var(--ink-raised); color: var(--sand);
  border: 1px solid var(--sand-edge); font-family: var(--ff-display); font-size: var(--t-lg);
}
.rank-btn[aria-pressed="true"] { background: var(--coral); color: #2A0E08; border-color: var(--coral); }
.swap-prompt { background: rgba(255,107,83,.08); border: 1px solid var(--coral); border-radius: var(--r-card); padding: var(--s-3); margin-bottom: var(--s-4); }
.swap-prompt p { margin: 0 0 var(--s-2); color: var(--on-sand-head); font-size: var(--t-sm); }
.swap-prompt .row { display: flex; gap: var(--s-2); }
.sheet-actions { display: flex; gap: var(--s-3); margin-top: var(--s-4); }
.sheet-actions .btn { flex: 1; }

.identity-rows { display: flex; flex-direction: column; }
.identity-row {
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  background: none; border: none; border-bottom: 1px solid rgba(210,196,166,.15);
  color: var(--on-ink-head); font-size: var(--t-body); text-align: left; padding: 0 4px;
}
.identity-row .hex { color: var(--gold); }
.identity-row .current { margin-left: auto; color: var(--coral); font-family: var(--ff-mono); font-size: var(--t-cap); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-root { position: fixed; z-index: 70; right: var(--s-5); bottom: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.toast {
  background: var(--ink-raised); color: var(--sand);
  border-left: 4px solid var(--coral); border-radius: var(--r-card);
  padding: 12px 16px; font-size: var(--t-sm); box-shadow: var(--shadow-modal);
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  animation: toastIn var(--mo-entry); max-width: 360px;
}
.toast.ok { border-left-color: var(--gold); }
.toast .toast-action { background: none; border: 1px solid rgba(210,196,166,.4); color: var(--sand); border-radius: 3px; padding: 4px 10px; font-size: var(--t-cap); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

.offline-banner { background: var(--sand-edge); color: var(--on-sand-head); font-family: var(--ff-mono); font-size: var(--t-cap); text-align: center; padding: 8px; }

/* ============================================================
   RESPONSIVE — tablet
   ============================================================ */
@media (max-width: 1024px) {
  .villa-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVE — mobile (<560px): contract + mobile-spec
   ============================================================ */
@media (max-width: 559px) {
  /* Shell */
  .topbar-inner { height: 48px; padding: 0 var(--s-4); }
  .tabs { display: none; }                    /* desktop tabs hidden */
  .brand { font-size: var(--t-cap); }
  .main { padding: var(--s-4); padding-bottom: calc(56px + env(safe-area-inset-bottom) + var(--s-4)); }

  /* Logistics collapses to toggle, scrolls with page (not sticky) */
  .logistics { border-bottom: 1px solid rgba(210,196,166,.12); }
  .logistics-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: var(--ink-raised); border: none; color: var(--on-ink-head);
    font-family: var(--ff-mono); font-size: var(--t-label); text-transform: uppercase; letter-spacing: .06em;
    padding: 12px var(--s-4); min-height: 40px;
  }
  .logistics-toggle .info-glyph { color: var(--coral); }
  .logistics-toggle .chev { margin-left: auto; color: var(--on-ink-body); transition: transform var(--mo-fast); }
  .logistics-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
  .logistics-content { display: none; flex-direction: column; padding: 0 var(--s-4) var(--s-3); }
  .logistics-content.open { display: flex; }
  .logi-cell { padding: 4px 0; }
  .logi-cell + .logi-cell { border-left: none; }

  /* Bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--ink-raised); border-top: 1px solid rgba(210,196,166,.2);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar-btn {
    flex: 1; min-height: 56px; background: none; border: none;
    color: var(--on-ink-body); font-size: var(--t-label); font-weight: 500;
    text-transform: uppercase; letter-spacing: .04em;
    border-top: 2px solid transparent;
  }
  .tabbar-btn[aria-current="page"] { color: var(--on-ink-head); border-top-color: var(--coral); }

  /* Grid → single column, tighter gap */
  .villa-grid { grid-template-columns: 1fr; gap: var(--s-4); }

  /* Villa name stepped down (contract flag #1) */
  .card-name { font-size: var(--t-lg); }

  /* Vote slots stack */
  .slot { grid-template-columns: 64px 1fr; grid-template-areas: "thumb body" "controls controls"; }
  .slot-thumb { grid-area: thumb; }
  .slot-controls { grid-area: controls; justify-content: flex-end; margin-top: var(--s-2); }

  /* Tally: hide inline segment labels, show legend row */
  .seg { font-size: 0; padding: 0; }
  .t-legend { display: flex; }

  /* Modal → full-screen sheet, 16px top corners */
  .scrim { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; max-height: 100dvh; height: 100dvh;
    border-radius: 16px 16px 0 0; animation: sheetUp var(--mo-entry);
  }
  .modal-body { grid-template-columns: 1fr; }
  .gallery-hero { aspect-ratio: 16/9; }     /* contract flag #5 */
  .modal-actions { position: sticky; bottom: 0; padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); }

  /* Toasts bottom-center above tab bar */
  .toast-root { right: var(--s-4); left: var(--s-4); bottom: calc(56px + env(safe-area-inset-bottom) + var(--s-4)); align-items: center; }
}

@media (max-width: 360px) {
  .card-actions { flex-direction: column; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .shimmer::after { animation: none; }
}
