/* ===== Diário da Viagem — Guarujá 2026 ===== */
:root {
  --azul-profundo: #0b3954;
  --azul-mar: #1273a3;
  --azul-claro: #bfe3f2;
  --areia: #f6efe3;
  --areia-escura: #e8dcc4;
  --coral: #ff6b57;
  --coral-escuro: #e0503d;
  --texto: #1d2c36;
  --texto-suave: #5b7180;
  --branco: #ffffff;
  --sombra: 0 4px 16px rgba(11, 57, 84, 0.12);
  --raio: 16px;
}

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

html, body {
  background: var(--areia);
  color: var(--texto);
  font-family: 'Nunito', system-ui, sans-serif;
  min-height: 100%;
}

.hidden { display: none !important; }

/* ---- Setup warning ---- */
.setup-warning {
  max-width: 480px; margin: 15vh auto; padding: 32px;
  background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra);
  text-align: center;
}
.setup-warning h1 { margin-bottom: 12px; }
.setup-warning code { background: var(--areia); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

/* ---- Header ---- */
.app-header {
  background: linear-gradient(160deg, var(--azul-profundo) 0%, var(--azul-mar) 100%);
  color: var(--branco);
  padding: max(16px, env(safe-area-inset-top)) 20px 20px;
  border-radius: 0 0 28px 28px;
  box-shadow: var(--sombra);
}
.header-inner { display: flex; align-items: center; gap: 12px; max-width: 720px; margin: 0 auto; }
.btn-back {
  background: rgba(255,255,255,0.15); color: var(--branco);
  border: none; border-radius: 12px; width: 40px; height: 40px;
  font-size: 20px; cursor: pointer; flex-shrink: 0;
}
.header-titles h1 {
  font-family: 'Caveat', cursive; font-size: 2rem; line-height: 1.1; font-weight: 600;
}
.header-titles p { font-size: 0.8rem; opacity: 0.85; }

/* ---- Countdown ---- */
.countdown { max-width: 720px; margin: 14px auto 0; text-align: center; }
.countdown-label {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px; opacity: 0.85; margin-bottom: 6px;
}
.countdown-grid { display: flex; justify-content: center; gap: 10px; }
.count-cell {
  background: rgba(255,255,255,0.14); border-radius: 12px;
  padding: 8px 0; min-width: 64px;
}
.count-num { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.count-unit { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.countdown-big {
  font-family: 'Caveat', cursive; font-size: 1.8rem; font-weight: 600;
}

/* ---- Main view ---- */
.view { max-width: 720px; margin: 0 auto; padding: 20px 16px 120px; }

/* ---- Lista de capítulos ---- */
.chapters { display: flex; flex-direction: column; gap: 14px; }
.chapter-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra);
  padding: 14px; cursor: pointer; border: none; text-align: left; width: 100%;
  font-family: inherit; color: inherit;
  transition: transform 0.1s ease;
}
.chapter-card:active { transform: scale(0.98); }
.chapter-cover {
  width: 64px; height: 64px; border-radius: 12px; flex-shrink: 0;
  background: var(--azul-claro); display: flex; align-items: center; justify-content: center;
  font-size: 30px; overflow: hidden;
}
.chapter-cover img { width: 100%; height: 100%; object-fit: cover; }
.chapter-info { flex: 1; min-width: 0; }
.chapter-title { font-weight: 800; font-size: 1rem; }
.chapter-date { font-size: 0.78rem; color: var(--texto-suave); }
.chapter-count {
  font-size: 0.78rem; color: var(--azul-mar); font-weight: 700; white-space: nowrap;
}
.chapter-add {
  background: transparent; border: 2px dashed var(--areia-escura); box-shadow: none;
  justify-content: center; color: var(--texto-suave); font-weight: 700; padding: 18px;
}

.seed-box {
  background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra);
  padding: 28px; text-align: center;
}
.seed-box p { color: var(--texto-suave); margin: 10px 0 18px; }

/* ---- Grade de mídia do capítulo ---- */
.media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
@media (min-width: 560px) { .media-grid { grid-template-columns: repeat(4, 1fr); } }
.media-item {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--areia-escura); cursor: pointer; border: none; padding: 0;
}
.media-item img, .media-item video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-item .video-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.55); color: #fff; border-radius: 8px;
  font-size: 0.7rem; padding: 2px 6px;
}
.media-item .item-author {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: #fff; font-size: 0.65rem; padding: 10px 6px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.empty-chapter {
  text-align: center; padding: 48px 20px; color: var(--texto-suave);
}
.empty-chapter .big { font-size: 48px; margin-bottom: 12px; }

/* ---- FAB ---- */
.fab-area {
  position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); right: 20px; z-index: 40;
}
.fab {
  display: flex; align-items: center; gap: 8px;
  background: var(--coral); color: var(--branco);
  font-weight: 800; font-size: 1rem;
  padding: 14px 22px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(255, 107, 87, 0.45);
  cursor: pointer; user-select: none;
}
.fab:active { background: var(--coral-escuro); }
.fab span { font-size: 1.2rem; }

/* ---- Upload tray ---- */
.upload-tray {
  position: fixed; bottom: max(84px, calc(env(safe-area-inset-bottom) + 64px));
  left: 16px; right: 16px; z-index: 39;
  display: flex; flex-direction: column; gap: 8px; max-width: 480px; margin: 0 auto;
}
.upload-row {
  background: var(--branco); border-radius: 12px; box-shadow: var(--sombra);
  padding: 10px 14px; font-size: 0.8rem;
}
.upload-row .bar {
  height: 5px; background: var(--areia-escura); border-radius: 99px; margin-top: 6px; overflow: hidden;
}
.upload-row .bar-fill { height: 100%; background: var(--azul-mar); width: 0%; transition: width 0.2s; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 20, 28, 0.96);
  display: flex; flex-direction: column;
}
.lb-close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 61;
  background: rgba(255,255,255,0.15); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px; cursor: pointer;
}
.lb-media {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 10px;
}
.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lb-info { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); color: #fff; }
.lb-caption { font-size: 1rem; margin-bottom: 6px; min-height: 1.2em; }
.lb-caption:empty::before { content: 'Sem legenda'; opacity: 0.4; font-style: italic; }
.lb-meta { font-size: 0.78rem; opacity: 0.7; display: flex; gap: 12px; margin-bottom: 10px; }
.lb-actions { display: flex; gap: 10px; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(8, 20, 28, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--branco); border-radius: 20px; padding: 28px;
  max-width: 360px; width: 100%; text-align: center;
}
.modal-emoji { font-size: 44px; margin-bottom: 8px; }
.modal h2 { margin-bottom: 6px; }
.modal p { color: var(--texto-suave); font-size: 0.88rem; margin-bottom: 16px; }
.modal input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--areia-escura); font-family: inherit; font-size: 1rem;
  margin-bottom: 12px; outline: none;
}
.modal input:focus { border-color: var(--azul-mar); }

/* ---- Botões ---- */
.btn {
  font-family: inherit; font-weight: 800; font-size: 0.95rem;
  border: none; border-radius: 12px; padding: 12px 20px; cursor: pointer;
}
.btn-primary { background: var(--azul-mar); color: var(--branco); width: 100%; }
.btn-primary:active { background: var(--azul-profundo); }
.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; font-size: 0.85rem; padding: 8px 14px; }
.btn-danger { color: #ff9d90; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: max(90px, calc(env(safe-area-inset-bottom) + 70px));
  left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--azul-profundo); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  box-shadow: var(--sombra); white-space: nowrap;
}

/* ---- Tela de login ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 90;
  background: linear-gradient(160deg, var(--azul-profundo) 0%, var(--azul-mar) 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--branco); border-radius: 22px; padding: 34px 28px;
  max-width: 340px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.login-emoji { font-size: 52px; }
.login-card h1 { font-family: 'Caveat', cursive; font-size: 2.4rem; color: var(--azul-profundo); line-height: 1; }
.login-sub { color: var(--texto-suave); margin-bottom: 20px; font-weight: 700; }
.login-card input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 2px solid var(--areia-escura); font-family: inherit; font-size: 1rem;
  margin-bottom: 12px; outline: none; text-align: center;
}
.login-card input:focus { border-color: var(--azul-mar); }
.login-error { color: var(--coral-escuro); font-weight: 700; margin-top: 12px; }

/* ---- Cadastro (modal) ---- */
.reg-label { display: block; text-align: left; font-size: 0.8rem; color: var(--texto-suave); font-weight: 700; margin: 4px 2px; }
.reg-select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--areia-escura);
  font-family: inherit; font-size: 1rem; margin-bottom: 12px; background: var(--branco); outline: none;
}
.reg-select:focus { border-color: var(--azul-mar); }
.reg-photo-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 10px; border-radius: 12px; border: 2px dashed var(--areia-escura);
  color: var(--texto-suave); font-weight: 700; cursor: pointer; margin-bottom: 14px;
}
.reg-photo-preview { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

/* ---- Quem Vai (roster) ---- */
.roster { display: flex; flex-direction: column; gap: 18px; }
.car-group { background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra); padding: 14px; }
.car-head {
  display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 12px;
  color: var(--azul-profundo);
}
.car-plate {
  font-size: 0.7rem; background: var(--areia); color: var(--texto-suave);
  padding: 2px 8px; border-radius: 6px; letter-spacing: 1px; font-weight: 700;
}
.car-count { margin-left: auto; background: var(--azul-mar); color: #fff; font-size: 0.72rem; padding: 2px 9px; border-radius: 999px; }
.person-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 480px) { .person-grid { grid-template-columns: repeat(5, 1fr); } }
.person-card { background: none; border: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; font-family: inherit; }
.person-photo {
  width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: var(--azul-claro); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: var(--azul-profundo);
}
.person-photo img { width: 100%; height: 100%; object-fit: cover; }
.person-name { font-size: 0.72rem; font-weight: 700; color: var(--texto); text-align: center; line-height: 1.1; word-break: break-word; }
.car-empty { color: var(--texto-suave); font-size: 0.82rem; font-style: italic; padding: 4px; }
.roster-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn-ghost2 { background: var(--branco); color: var(--azul-mar); border: 2px solid var(--azul-mar); }
.roster-cta .chapter-cover { color: #fff; }

/* ---- Cápsula do tempo (Melhores Momentos trancado) ---- */
.locked { text-align: center; padding: 40px 24px; background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra); }
.locked-lock { font-size: 60px; margin-bottom: 8px; }
.locked h2 { color: var(--azul-profundo); margin-bottom: 10px; }
.locked p { color: var(--texto-suave); line-height: 1.5; max-width: 380px; margin: 0 auto 18px; }
.locked-date { display: inline-block; background: var(--coral); color: #fff; font-weight: 800; padding: 10px 18px; border-radius: 999px; }

/* ---- Abas Roteiro / Eventos ---- */
.tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.tab {
  flex: 1; padding: 10px; border-radius: 12px; border: 2px solid var(--areia-escura);
  background: var(--branco); color: var(--texto-suave); font-family: inherit; font-weight: 800;
  font-size: 0.9rem; cursor: pointer;
}
.tab-on { background: var(--azul-mar); border-color: var(--azul-mar); color: #fff; }
.tab-empty { text-align: center; color: var(--texto-suave); padding: 30px 16px; }
.tab-empty p { margin-top: 8px; line-height: 1.4; }
.del-chapter-btn { display: block; width: 100%; margin-top: 18px; color: var(--coral-escuro); border-color: var(--coral); }

/* ---- Banner de pendências offline ---- */
.pending-banner {
  position: fixed; left: 12px; right: 12px;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 66px));
  z-index: 45; max-width: 480px; margin: 0 auto;
  background: var(--azul-profundo); color: #fff; text-align: center;
  padding: 10px 14px; border-radius: 12px; font-size: 0.82rem; font-weight: 700;
  box-shadow: var(--sombra); cursor: pointer;
}
