:root {
  --purple: #7c3aed;
  --purple-dark: #5b21b6;
  --pink: #ec4899;
  --orange: #fb923c;
  --green: #22c55e;
  --blue: #38bdf8;
  --bg-dark: #1a1033;
  --card-bg: rgba(255,255,255,0.08);
  --text-light: #fdfcff;
  --radius: 22px;
  font-size: 16px;
}

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

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: linear-gradient(160deg, #2b1055 0%, #7c3aed 45%, #ec4899 100%);
  background-attachment: fixed;
  color: var(--text-light);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 28px;
  padding: 36px 28px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.login-emoji { font-size: 44px; margin-bottom: 8px; }

.login-card h1 {
  font-family: 'Baloo 2', cursive;
  font-size: 30px;
  margin: 0 0 2px;
}

.subtitle { opacity: 0.8; margin: 0 0 24px; font-weight: 600; }

#login-form { display: flex; flex-direction: column; gap: 14px; }

#password-input {
  padding: 16px 18px;
  border-radius: 16px;
  border: none;
  font-size: 17px;
  outline: none;
  text-align: center;
  background: rgba(255,255,255,0.92);
  color: #333;
}

.error-msg {
  color: #ffd1e3;
  font-weight: 700;
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 14px;
}

/* ---------- Instrucciones de instalación ---------- */
.install-toggle {
  margin-top: 18px;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}
.install-toggle:active { opacity: 0.7; }

.install-instructions {
  margin-top: 8px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
}

.install-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.install-tab {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 8px 6px;
  color: rgba(255,255,255,0.75);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.install-tab.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

.install-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(255,255,255,0.92);
}
.install-steps li { margin-bottom: 4px; }
.install-steps strong { color: white; }

/* ---------- Botones genéricos ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: transform .08s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: white;
}

.btn-ghost {
  background: rgba(255,255,255,0.12);
  color: var(--text-light);
  border: 1px solid rgba(255,255,255,0.25);
}

.btn-finish {
  background: linear-gradient(135deg, var(--green), #16a34a);
  color: white;
  flex: 1.3;
}

/* ---------- App shell ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 14px) 20px 14px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
}

.brand {
  font-family: 'Baloo 2', cursive;
  font-size: 22px;
  font-weight: 800;
}

.streak {
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 24px;
}

.view { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

/* ---------- Vista paseo ---------- */
.counters {
  display: flex;
  gap: 14px;
  margin: 10px 0 22px;
}

.counter-box {
  flex: 1;
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.15);
}

.counter-label { font-weight: 700; opacity: 0.85; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.counter-value { font-family: 'Baloo 2', cursive; font-size: 48px; line-height: 1.1; margin-top: 4px; }

.tap-buttons {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 22px;
}

.tap-btn {
  border: none;
  border-radius: 28px;
  padding: 34px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Baloo 2', cursive;
  font-size: 26px;
  font-weight: 700;
  color: white;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
  transition: transform .07s ease;
  user-select: none;
}
.tap-btn:active { transform: scale(0.95); }

.tap-emoji { font-size: 52px; }

.kid-btn { background: linear-gradient(135deg, var(--blue), var(--purple)); }
.dog-btn { background: linear-gradient(135deg, var(--orange), var(--pink)); }

.walk-actions {
  display: flex;
  gap: 12px;
}

/* ---------- Historial ---------- */
.chart-card {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  padding: 16px 10px 8px;
  margin-bottom: 18px;
}

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-date { font-weight: 800; }
.history-date .day-name { display: block; font-size: 12px; opacity: 0.7; font-weight: 700; }

.history-counts { display: flex; gap: 14px; font-weight: 700; }
.history-counts span { display: flex; align-items: center; gap: 4px; }

.empty-msg { text-align: center; opacity: 0.75; padding: 30px 10px; font-weight: 600; }

.logout-link {
  display: block;
  margin: 26px auto 4px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}
.logout-link:active { opacity: 0.7; }

/* ---------- Tabbar ---------- */
.tabbar {
  display: flex;
  background: rgba(0,0,0,0.25);
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
  gap: 8px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  border-radius: 14px;
  cursor: pointer;
}
.tab-btn span:first-child { font-size: 20px; }
.tab-btn.active {
  color: white;
  background: rgba(255,255,255,0.12);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,30,0.92);
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 50;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 10px); }
