:root {
  --cream: #FAF6EF;
  --cream-deep: #F0E9DA;
  --pine: #2B4A35;
  --pine-light: #3E6A4C;
  --apricot: #E8A85C;
  --apricot-deep: #D68F3B;
  --coral: #E07856;
  --ink: #2B2620;
  --ink-soft: #6B6154;
  --white: #FFFFFF;
  --line: #E4DCC8;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 20px rgba(43, 74, 53, 0.08);
  --font-display: "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: 84px; /* espacio para la barra de pestañas */
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--pine);
  margin: 0 0 8px;
  line-height: 1.15;
}

h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 12px; color: var(--ink-soft); line-height: 1.5; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ---------- Cabecera ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--cream);
}

.avatar {
  border-radius: 50%;
  background: var(--pine-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cream);
  font-family: var(--font-display);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.app-header .avatar {
  width: 46px;
  height: 46px;
  font-size: 18px;
  border: 2px solid var(--apricot);
}

.app-header .titles { flex: 1; min-width: 0; }
.app-header .titles .brand { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.app-header .titles h1 { font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Contenido ---------- */
main {
  padding: 4px 20px 28px;
  max-width: 640px;
  margin: 0 auto;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.card-tight { padding: 14px 16px; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--apricot-deep);
  margin-bottom: 4px;
  display: block;
}

/* ---------- Formularios ---------- */
label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  margin-bottom: 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pine-light);
  background: var(--white);
}

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  transition: transform .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--pine); color: var(--cream); }
.btn-accent { background: var(--apricot); color: var(--pine); }
.btn-ghost { background: transparent; color: var(--pine); border: 1.5px solid var(--pine); }
.btn-danger { background: transparent; color: var(--coral); border: 1.5px solid var(--coral); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- Listas / checklists ---------- */
.checklist-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 24px; height: 24px; margin: 0; flex-shrink: 0; accent-color: var(--pine);
}
.checklist-item .txt { flex: 1; }
.checklist-item .txt .name { font-weight: 600; }
.checklist-item .txt .desc { font-size: 12.5px; color: var(--ink-soft); }

.progress-bar {
  height: 8px;
  background: var(--cream-deep);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 2px;
}
.progress-bar > div { height: 100%; background: var(--apricot); border-radius: 999px; transition: width .3s ease; }

/* ---------- Barra inferior de pestañas ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.tabbar button svg { width: 22px; height: 22px; stroke: var(--ink-soft); fill: none; }
.tabbar button.active { color: var(--pine); }
.tabbar button.active svg { stroke: var(--pine); }

/* ---------- Mapa de etapas (trail) ---------- */
.trail-wrap { padding: 6px 2px 2px; }
.trail-stage {
  display: flex;
  gap: 14px;
  padding: 10px 2px;
  position: relative;
}
.trail-stage .dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--cream-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; position: relative; z-index: 1;
  border: 2px solid var(--line);
}
.trail-stage.current .dot { background: var(--apricot); border-color: var(--apricot-deep); }
.trail-stage.done .dot { background: var(--pine); border-color: var(--pine); color: var(--cream); }
.trail-stage:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 19px; top: 40px; bottom: -10px;
  width: 2px;
  background: var(--line);
}
.trail-stage .body { padding-top: 2px; }
.trail-stage .range { font-size: 11px; font-weight: 700; color: var(--apricot-deep); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Utilidades ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 999px; background: var(--cream-deep); color: var(--pine);
}
.tag-alert { background: #FBE4DC; color: var(--coral); }
.empty-state { text-align: center; padding: 30px 10px; color: var(--ink-soft); }
.empty-state svg { width: 48px; height: 48px; stroke: var(--line); margin-bottom: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid .photo {
  aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--cream-deep);
}
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--pine); color: var(--cream); padding: 12px 18px; border-radius: 16px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, bottom .25s ease;
  max-width: min(88vw, 380px); text-align: center; line-height: 1.4;
}
.toast.show { opacity: 1; bottom: 108px; }

.banner-tip {
  background: var(--cream-deep);
  border-left: 4px solid var(--apricot);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 14px;
}
.banner-tip strong { color: var(--pine); }

/* ---------- Bienvenida (primera vez) ---------- */
.onboarding-overlay {
  position: fixed; inset: 0; background: rgba(43, 38, 32, 0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  padding: 16px;
}
.onboarding-card {
  background: var(--white); border-radius: var(--radius); padding: 24px 22px;
  max-width: 460px; width: 100%; box-shadow: var(--shadow);
}

.habilidad-nombre {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--pine);
}

.etapas-progreso {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.etapa-btn {
  border: 1.5px solid var(--line);
  background: var(--cream);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}
.etapa-btn.activa {
  background: var(--pine);
  border-color: var(--pine);
  color: var(--cream);
}

.consejos-detail {
  margin: 0;
}
.consejos-detail summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--pine);
  background: var(--cream-deep);
  padding: 9px 16px;
  border-radius: 999px;
  list-style: none;
  border: 1.5px solid var(--line);
}
.consejos-detail summary::-webkit-details-marker { display: none; }
.consejos-detail summary::after {
  content: "›";
  font-size: 16px;
  line-height: 1;
  transition: transform .2s ease;
}
.consejos-detail[open] summary {
  background: var(--pine);
  color: var(--cream);
  border-color: var(--pine);
}
.consejos-detail[open] summary::after {
  transform: rotate(90deg);
}
.consejos-detail p {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream-deep);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
