/* 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; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; }
.gate-avatar {
  width: 110px; height: 110px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--accent); box-shadow: var(--shadow);
  animation: float 3s ease-in-out infinite;
}
.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); }

/* ---------- Cabecera dentro del drawer ---------- */
.drawer-top {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px 4px;
}
.drawer-avatar {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--accent); flex: 0 0 auto;
}
.drawer-top strong { font-size: 16px; display: block; }
.drawer-top .peek-text { flex: 1; min-width: 0; }
.live-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); }
.session-label { font-size: 10.5px; color: var(--accent2); opacity: .85; margin-top: 1px; }
.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; }
.share-btn.alt { background: var(--accent2); color: #3a2a00; border: none; font-size: 15px; }
.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); }

/* ---------- Drawer superior (baja desde arriba) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; top: 0; z-index: 30;
  background: rgba(29,26,46,.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 0 0 22px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.55);
  transition: max-height .32s cubic-bezier(.3,1,.35,1);
  max-height: calc(148px + var(--safe-top)); overflow: hidden;
  display: flex; flex-direction: column;
  border-bottom: 1px solid #453e6b;
  padding-top: var(--safe-top);
}
.sheet.open { max-height: 82vh; }
.sheet-handle { flex: 0 0 auto; cursor: grab; }
.handle-bar { width: 44px; height: 5px; border-radius: 3px; background: #554d7d; margin: 4px auto 8px; }
.sheet-peek { display: flex; align-items: center; gap: 12px; padding: 4px 18px 0; }
#peek-emoji { font-size: 26px; }
.peek-text { flex: 1; min-width: 0; }
.peek-text strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-text span { font-size: 12.5px; color: var(--ink-dim); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.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 28px; transition: opacity .2s; }
.sheet:not(.open) .sheet-body { opacity: 0; visibility: hidden; }
.sheet-h { font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-dim); margin: 18px 4px 10px; }

/* Reloj de aeropuerto flotante (transparente: el mapa se ve detrás) */
.fly-clock {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 160px);
  background: rgba(6,6,10,.32);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  border-radius: 14px;
  padding: 6px 16px 8px; text-align: center;
  cursor: pointer; user-select: none;
}
.fc-route {
  font-family: 'Orbitron', monospace; font-weight: 600; font-size: 12px;
  letter-spacing: 3px; color: #fff; white-space: nowrap;
  text-shadow: 0 0 8px rgba(0,0,0,.9), 0 1px 3px rgba(0,0,0,.9);
}
.fc-label {
  font-family: 'Orbitron', monospace; font-weight: 600; font-size: 10px;
  letter-spacing: 4px; color: #cfcbe6; margin-top: 2px;
  text-shadow: 0 0 8px rgba(0,0,0,.9);
}
.fc-time {
  font-family: 'Orbitron', monospace; font-weight: 800; font-size: 30px;
  letter-spacing: 4px; line-height: 1.15;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  color: #59f48c; text-shadow: 0 0 16px rgba(89,244,140,.55), 0 1px 3px rgba(0,0,0,.9);
  transition: color 1s, text-shadow 1s;
}
.fc-time.warn { color: #ffb000; text-shadow: 0 0 16px rgba(255,176,0,.55), 0 1px 3px rgba(0,0,0,.9); }
.fc-time.danger {
  color: #ff5252; text-shadow: 0 0 18px rgba(255,82,82,.65), 0 1px 3px rgba(0,0,0,.9);
  animation: fc-pulse 1s infinite;
}
@keyframes fc-pulse { 50% { opacity: .55; } }

/* Próximo vuelo */
.next-flight {
  background: linear-gradient(135deg, rgba(255,209,102,.14), rgba(255,126,176,.10));
  border: 1px solid rgba(255,209,102,.45); border-radius: 16px;
  padding: 14px 16px; margin: 6px 0 4px;
}
.nf-tag { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent2); }
.nf-route { font-size: 17px; font-weight: 800; margin: 3px 0 2px; }
.nf-count { font-size: 26px; font-weight: 800; color: var(--accent2); margin: 2px 0; }
.nf-line { font-size: 13px; color: var(--ink-dim); line-height: 1.45; }

/* 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; position: relative;
}
.tl-leg.vuelo { background: rgba(108,156,255,.10); border: 1px solid rgba(108,156,255,.28); }
.tl-leg.tierra { background: rgba(255,166,87,.10); border: 1px solid rgba(255,166,87,.28); }

/* Sellos por tipo de checkpoint */
.blk-tag {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: 1.5px;
  padding: 2px 7px; border-radius: 5px; margin-bottom: 3px;
}
.blk-tag.vuelo { background: rgba(108,156,255,.22); color: #a8c2ff; }
.blk-tag.tierra, .blk-tag.road { background: rgba(255,166,87,.22); color: #ffc899; }
.blk-tag.hosp { background: rgba(124,231,160,.18); color: var(--ok); }
.tl-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.tl-chip {
  font-size: 10.5px; font-weight: 700; padding: 2.5px 9px; border-radius: 999px;
}
.tl-chip.hosp { background: rgba(124,231,160,.14); color: var(--ok); }
.tl-chip.aero { background: rgba(108,156,255,.16); color: #a8c2ff; }
.tl-chip.road { background: rgba(255,166,87,.16); color: #ffc899; }

/* ⚡ corrección rápida */
.tl-fix {
  position: absolute; top: 7px; right: 8px;
  background: rgba(255,209,102,.15); border: 1px solid rgba(255,209,102,.4);
  color: var(--accent2); border-radius: 8px; font-size: 13px; padding: 3px 8px; cursor: pointer;
}
.fix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fix-btn {
  padding: 13px 8px; border-radius: 12px; font-size: 14.5px; font-weight: 700;
  background: var(--card); color: var(--ink); border: 1px solid #453e6b; cursor: pointer;
}
.fix-btn:active { background: var(--card2); }
.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; }

/* Editor de parada */
.edit-form label { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 10px; }
.edit-form input, .edit-form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  background: var(--card); color: var(--ink); border: 1px solid #453e6b;
  border-radius: 10px; font-size: 15px; font-family: inherit;
}
.edit-form input:focus, .edit-form textarea:focus { outline: none; border-color: var(--accent); }
.ed-row { display: flex; gap: 10px; }
.ed-row label { flex: 1; }
.ed-row .ed-mini { flex: 0 0 72px; }
.tl-edit {
  margin-left: auto; background: none; border: 1px solid #3b3560; border-radius: 8px;
  color: var(--ink-dim); font-size: 14px; padding: 4px 8px; cursor: pointer;
}

/* Minichecks (sub-checkpoints) */
.tl-subs { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.tl-sub {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-dim);
  cursor: pointer; padding: 3px 0;
}
.tl-sub .sub-box {
  width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid #554d7d;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  color: var(--ok); flex: 0 0 auto;
}
.tl-sub.done { color: var(--ink); }
.tl-sub.done .sub-box { border-color: var(--ok); background: rgba(124,231,160,.12); }
.tl-sub.done span:last-child { text-decoration: line-through; opacity: .75; }
.tl-dot.subs-ok { border-color: var(--ok) !important; color: var(--ok); }

/* Enlaces de vuelo */
.flight-link { color: #a8c2ff; text-decoration: underline dotted; font-weight: 700; }

/* Agente de viajes */
.agent-ta {
  width: 100%; padding: 10px 12px; background: var(--card); color: var(--ink);
  border: 1px solid #453e6b; border-radius: 10px; font-size: 14px; font-family: inherit; resize: none;
}
.agent-ta:focus { outline: none; border-color: var(--accent); }

/* 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: 0 0 22px 22px; }
  .tina-controls { left: 16px; right: auto; align-items: flex-start; }
}
