/* Kaizen2 — sistema de diseño "Slate & Moss" (mobile-first, dark mode) */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #EDEFF2;
  --text: #0B0D10;
  --text-soft: #5B636E;
  --border: #E1E4E9;
  --brand: #3F7A5E;        /* verde musgo, racionado */
  --brand-soft: #E7F0EB;
  --accent: #C2703D;       /* terracota */
  --accent-soft: #F6E7DC;
  --danger: #B4453A;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11,13,16,.06), 0 4px 16px rgba(11,13,16,.05);
  --nav-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0D10;
    --surface: #16191E;
    --surface-2: #1E232A;
    --text: #F4F5F7;
    --text-soft: #98A2AF;
    --border: #262C34;
    --brand: #5E9E7E;
    --brand-soft: #17251E;
    --accent: #D2854F;
    --accent-soft: #2A1D13;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* El atributo hidden debe ganar a display de las clases (botones del wizard, etc.) */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px; }

/* Tipografía */
h1 { font-size: 1.6rem; margin: 0 0 .2em; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 1.4em 0 .5em; }
.hero-num { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; }
.muted { color: var(--text-soft); }
.small { font-size: .85rem; }

/* Tarjetas */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card--brand { background: var(--brand-soft); border-color: transparent; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 12px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  text-decoration: none; width: 100%;
}
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--accent  { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost   { background: transparent; }
.btn:active { transform: translateY(1px); }

/* Formularios */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; }
.flash--notice { background: var(--brand-soft); color: var(--brand); }
.flash--alert  { background: var(--accent-soft); color: var(--accent); }

/* Auth centrado */
.auth { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.brand-mark { text-align: center; margin-bottom: 24px; }
.brand-mark .logo { font-size: 1.8rem; font-weight: 800; color: var(--brand); letter-spacing: -.03em; }
.brand-mark .tag { color: var(--text-soft); font-size: .95rem; }

/* Errores de validación */
.errors { background: var(--accent-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: .9rem; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--text-soft); font-size: .7rem; font-weight: 600;
}
.bottom-nav a.active { color: var(--brand); }
.bottom-nav .ico { font-size: 1.25rem; line-height: 1; }

/* Barra de progreso (wizard) */
.progress-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress-bar { height: 100%; width: 25%; background: var(--brand); border-radius: 999px; transition: width .25s ease; }

/* Anillos / métricas */
.metric { text-align: center; }
.metric .n { font-family: var(--serif); font-size: 2rem; font-weight: 700; }
.metric .l { color: var(--text-soft); font-size: .8rem; }
.macros { display: flex; gap: 10px; }
.macros .macro { flex: 1; text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 6px; }
.macros .macro b { display: block; font-size: 1.1rem; }
.macros .macro span { color: var(--text-soft); font-size: .75rem; }

/* Celebración de hábitos (reutilizado de Kaizen, adaptado a tokens) */
.habit-row { transition: background .2s ease; }
.habit-row.done { opacity: .55; }
@keyframes habitPop { 0%{transform:scale(1)} 40%{transform:scale(1.03)} 100%{transform:scale(1)} }
.just-done { animation: habitPop .4s ease; }
.xp-pop { position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); z-index: 200;
  font: 800 1.4rem var(--serif); color: var(--brand); pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,.15); animation: xpFloat 1.1s ease forwards; }
@keyframes xpFloat { 0%{opacity:0;transform:translate(-50%,10px) scale(.9)} 15%{opacity:1}
  100%{opacity:0;transform:translate(-50%,-46px) scale(1.05)} }
.celebrate-toast { position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 20px); z-index: 200;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: .92rem;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0;
  transition: opacity .3s ease, transform .3s cubic-bezier(.22,1,.36,1); max-width: 88%; text-align: center; }
.celebrate-toast.in { opacity: 1; transform: translate(-50%, 0); }
.confetti-canvas { position: fixed; inset: 0; z-index: 190; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .just-done, .xp-pop { animation: none; } }

/* Nivel / XP */
.xp-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.xp-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Utilidades */
.row { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
