/* El viaje de Tina — mobile first */
:root {
  --bg: #1d1a2e;
  --card: #2a2640;
  --card2: #353052;
  --ink: #f3f0ff;
  --ink-dim: #b6aed6;
  --accent: #ff7eb0;       /* rosa Tina */
  --accent2: #ffd166;      /* dorado */
  --ok: #7ce7a0;
  --done: #ff7eb0;
  --todo: #8b84ad;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
.hidden { display: none !important; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, #4a3f78 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #6b2e53 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}
.gate-card { width: 100%; max-width: 380px; text-align: center; }
.gate-cat { font-size: 64px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.gate h1 { margin: 8px 0 4px; font-size: 30px; letter-spacing: -.5px; }
.gate-sub { color: var(--ink-dim); font-size: 15px; line-height: 1.45; margin: 0 0 28px; }
.gate-btn {
  display: block; width: 100%; margin: 10px 0; padding: 16px;
  font-size: 17px; font-weight: 700; color: var(--ink);
  background: var(--card); border: 1px solid #453e6b; border-radius: var(--radius);
  cursor: pointer; box-shadow: var(--shadow);
}
.gate-btn.tina { background: linear-gradient(135deg, #ff7eb0, #c86dd7); color: #2a1030; border: none; }
.gate-btn.go { background: var(--accent2); color: #3a2a00; border: none; }
.gate-link { background: none; border: none; color: var(--ink-dim); margin-top: 14px; font-size: 14px; cursor: pointer; }
#gate-pin p { color: var(--ink-dim); margin: 0 0 10px; }
#pin-input {
  width: 100%; padding: 14px; font-size: 28px; text-align: center; letter-spacing: 12px;
  background: var(--card); color: var(--ink); border: 1px solid #453e6b; border-radius: var(--radius);
  outline: none;
}
#pin-input:focus { border-color: var(--accent); }
.pin-err { color: #ff9c9c; font-size: 14px; }

/* ---------- Mapa ---------- */
#map { position: fixed; inset: 0; z-index: 1; background: #12101f; }
.leaflet-container { font: inherit; }

/* Marcadores de parada */
.stop-pin {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--todo);
  font-size: 17px; box-shadow: 0 3px 10px rgba(0,0,0,.5);
}
.stop-pin.done { border-color: var(--pin, var(--done)); }
.stop-pin.current { border-color: var(--accent2); animation: pulse-ring 2s infinite; }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(255,209,102,.55); }
  70% { box-shadow: 0 0 0 14px rgba(255,209,102,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,209,102,0); }
}

/* Marcador de Tina */
.tina-marker { position: relative; }
.tina-marker .halo {
  position: absolute; inset: -8px; border-radius: 50%;
  background: color-mix(in srgb, var(--pin, #ff7eb0) 38%, transparent);
  animation: pulse-ring 2.2s infinite;
}
.tina-marker .face {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pin, #ff7eb0), #c86dd7);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.5);
}

.leaflet-popup-content-wrapper {
  background: var(--card); color: var(--ink); border-radius: 14px; box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--card); }
.leaflet-popup-content { margin: 12px 16px; font-size: 14px; line-height: 1.4; }
.leaflet-popup-content strong { color: var(--accent2); }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: calc(8px + var(--safe-top)); left: 10px; right: 10px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(29,26,46,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid #453e6b; border-radius: var(--radius); padding: 10px 14px;
  box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar-cat { font-size: 26px; }
.topbar strong { font-size: 16px; display: block; }
.live-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: blink 1.6s infinite; }
.dot.off { background: #8a8a8a; }
@keyframes blink { 50% { opacity: .4; } }
.iconbtn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid #453e6b;
  background: var(--card); font-size: 19px; cursor: pointer; color: var(--ink);
}

/* ---------- Controles de Tina ---------- */
.tina-controls {
  position: fixed; z-index: 20; left: 12px; right: 12px;
  bottom: calc(96px + var(--safe-bot));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.share-btn {
  display: flex; align-items: center; gap: 10px; padding: 13px 22px;
  border-radius: 999px; border: none; font-size: 16px; font-weight: 700;
  background: var(--card); color: var(--ink); border: 1px solid #453e6b;
  box-shadow: var(--shadow); cursor: pointer;
}
.share-btn.on { background: linear-gradient(135deg, #ff7eb0, #c86dd7); color: #2a1030; border: none; }
.quick-events { display: flex; gap: 8px; }
.quick-events button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid #453e6b;
  background: rgba(42,38,64,.92); font-size: 21px; cursor: pointer;
  box-shadow: var(--shadow);
}
.quick-events button:active { transform: scale(.9); }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg);
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.55);
  transition: transform .32s cubic-bezier(.3,1,.35,1);
  height: 78vh; transform: translateY(calc(78vh - 92px - var(--safe-bot)));
  display: flex; flex-direction: column;
  border-top: 1px solid #453e6b;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { flex: 0 0 auto; cursor: grab; padding-bottom: 6px; }
.handle-bar { width: 44px; height: 5px; border-radius: 3px; background: #554d7d; margin: 10px auto 6px; }
.sheet-peek { display: flex; align-items: center; gap: 12px; padding: 0 18px 10px; }
#peek-emoji { font-size: 30px; }
.peek-text { flex: 1; min-width: 0; }
.peek-text strong { display: block; font-size: 16px; }
.peek-text span { font-size: 13px; color: var(--ink-dim); }
.peek-chevron { color: var(--ink-dim); transition: transform .3s; }
.sheet.open .peek-chevron { transform: rotate(180deg); }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(28px + var(--safe-bot)); }
.sheet-h { font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-dim); margin: 18px 4px 10px; }

/* Eventos */
.events-feed:empty { display: none; }
.events-feed { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.ev {
  background: var(--card); border-radius: 14px; padding: 10px 14px;
  font-size: 14px; display: flex; gap: 10px; align-items: baseline;
  border: 1px solid #3b3560;
}
.ev time { color: var(--ink-dim); font-size: 12px; white-space: nowrap; }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 10px; top: 8px; bottom: 8px;
  width: 2px; background: #453e6b;
}
.tl-item { position: relative; margin-bottom: 10px; }
.tl-dot {
  position: absolute; left: -26px; top: 14px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--todo);
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.tl-item.done .tl-dot { border-color: var(--pin, var(--done)); background: #3d2438; }
.tl-item.current .tl-dot { border-color: var(--accent2); animation: pulse-ring 2s infinite; }
.tl-card {
  background: var(--card); border: 1px solid #3b3560; border-radius: 14px; padding: 12px 14px;
}
.tl-item.current .tl-card { border-color: var(--accent2); background: var(--card2); }
.tl-item.done .tl-card { opacity: .75; }
.tl-head { display: flex; align-items: center; gap: 8px; }
.tl-head .em { font-size: 20px; }
.tl-head strong { font-size: 15px; }
.tl-when { font-size: 12.5px; color: var(--accent2); margin-top: 2px; }
.tl-desc { font-size: 13.5px; color: var(--ink-dim); line-height: 1.45; margin-top: 6px; }
.tl-leg {
  margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.22);
  font-size: 13px; line-height: 1.4;
}
.tl-leg .lg-label { font-weight: 700; }
.tl-leg .lg-detail { color: var(--ink-dim); font-size: 12.5px; }
.tl-leg.tbd { border: 1px dashed #6b628f; background: none; }
.badge-cats {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,209,102,.15); color: var(--accent2); font-size: 11px; font-weight: 700;
}
.badge-eta { background: rgba(124,231,160,.14); color: var(--ok); }
.lg-detail i { color: var(--todo); font-style: normal; font-size: 11.5px; }
.tl-hotel {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(124,231,160,.08); border: 1px solid rgba(124,231,160,.25); font-size: 13px;
  line-height: 1.45;
}
.tl-hotel strong { color: var(--ok); }
.tl-hotel a { color: var(--ok); }
.tl-hotel details summary { cursor: pointer; color: var(--ink-dim); margin-top: 4px; }

/* Tabs de viajeras */
.human-tabs { display: flex; gap: 8px; margin: 0 4px 12px; }
.htab {
  flex: 1; padding: 10px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: var(--card); color: var(--ink); border: 1px solid #3b3560; cursor: pointer;
}
.htab.on {
  border-color: var(--pin, var(--accent));
  background: color-mix(in srgb, var(--pin, var(--accent)) 16%, var(--card));
}

/* Modal OCR */
.pmodal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
}
.pmodal-card {
  width: 100%; max-width: 460px; max-height: 80vh; overflow-y: auto;
  background: var(--bg); border: 1px solid #453e6b; border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + var(--safe-bot));
}
.pmodal-card h3 { margin: 0 0 4px; font-size: 19px; }
.pmodal-sub { color: var(--ink-dim); font-size: 13.5px; margin: 0 0 14px; }
.parse-list { display: flex; flex-direction: column; gap: 8px; }
.parse-row {
  display: flex; gap: 10px; align-items: flex-start; background: var(--card);
  border: 1px solid #3b3560; border-radius: 12px; padding: 12px; cursor: pointer;
}
.parse-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.parse-row b { font-size: 14.5px; display: block; }
.parse-row small { color: var(--ink-dim); font-size: 12.5px; }
.pmodal-actions { display: flex; gap: 10px; margin-top: 16px; }
.pm-btn {
  flex: 1; padding: 13px; border-radius: 12px; font-size: 15px; font-weight: 700;
  border: none; cursor: pointer;
}
.pm-btn.ghost { background: var(--card); color: var(--ink-dim); border: 1px solid #3b3560; }
.pm-btn.go { background: var(--accent2); color: #3a2a00; }

/* Toast */
.toast {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: calc(120px + var(--safe-bot));
  background: var(--card2); color: var(--ink); border: 1px solid #554d7d;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  max-width: 86vw; text-align: center;
}

@media (min-width: 700px) {
  .sheet { left: auto; right: 16px; width: 400px; border-radius: 22px 22px 0 0; }
  .tina-controls { left: 16px; right: auto; align-items: flex-start; }
}
