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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  user-select: none; /* Sensación de aplicación nativa */
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  user-select: auto;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  outline: none; /* Se sobreescribe abajo para teclado */
}

/* Prevenir que elementos hijos dentro de botones intercepten toques o clics */
button > *, .btn > *, .dashboard-action-card > *, .card-clickable > *, .modal-choice-card > * {
  pointer-events: none;
}
button input, button select, button textarea, .card-clickable input, .card-clickable select, .card-clickable textarea {
  pointer-events: auto;
}

/* Accesibilidad: mostrar foco visible solo cuando se navega con teclado */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Scrollbar personalizada sutil */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Contenedor Principal de la App */
#app-container {
  width: 100%;
  max-width: 600px; /* Centrado en tablets/desktop, 100% en móviles */
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--nav-height) + var(--safe-bottom) + 32px) 16px;
  flex: 1;
}

/* Utilidades Tipográficas */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 1.65rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }

p {
  color: var(--text-secondary);
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-danger { color: var(--color-danger); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
