:root {
  --bg: #f5f3f7;
  --surface: #ffffff;
  --surface-2: #efebf3;
  --text: #1d1a22;
  --muted: #6b6475;
  --border: #e2dce8;
  --primary: #b83156;
  --primary-ink: #ffffff;
  --primary-soft: #f8e3ea;
  --ok: #1f8a5b;
  --z-empobrecido: #9aa0a6;
  --z-club: #2f8fd8;
  --z-autoritario: #e0662f;
  --z-medio: #c79a14;
  --z-equipo: #1f8a5b;
  --shadow: 0 1px 2px rgba(30, 20, 40, .06), 0 6px 20px rgba(30, 20, 40, .06);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131116;
    --surface: #1d1a22;
    --surface-2: #272330;
    --text: #f1edf5;
    --muted: #a49cae;
    --border: #353040;
    --primary: #e2577d;
    --primary-ink: #ffffff;
    --primary-soft: #3a1d27;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--primary); margin: 8px 0 20px;
}
.brand svg { width: 28px; height: 28px; }

.hero { padding-top: 12px; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.chip {
  background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: .85rem;
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 14px;
  font: inherit; font-weight: 600; text-decoration: none;
  background: var(--primary); color: var(--primary-ink);
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.link { background: none; color: var(--muted); min-height: 44px; padding: 0 8px; }
.stack { display: grid; gap: 12px; }
.spacer { flex: 1; }

/* ---------- formulario */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; min-height: 50px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* evita zoom en iOS */
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.error { color: var(--primary); font-size: .9rem; min-height: 1.4em; }

/* ---------- encuesta */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  margin: -16px -16px 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon-btn {
  appearance: none; border: 0; background: var(--surface-2); color: var(--text);
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:disabled { opacity: .35; }
.counter { font-weight: 600; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .25s ease; }

.question { animation: slide .22s ease; }
.question .num { color: var(--primary); font-weight: 700; font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; }
.question .text { font-size: 1.35rem; font-weight: 650; line-height: 1.35; margin: 6px 0 22px; min-height: 3.6em; }
.hint { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }

.options { display: grid; gap: 10px; }
.option {
  appearance: none; width: 100%; text-align: left; cursor: pointer;
  min-height: 56px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .12s ease, background .12s ease;
}
.option .dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center;
}
.option[aria-checked=true] { border-color: var(--primary); background: var(--primary-soft); }
.option[aria-checked=true] .dot { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 4px var(--primary-soft); }
.option .key { margin-left: auto; color: var(--muted); font-size: .8rem; }
@media (hover: none) { .option .key { display: none; } }

.nav-bottom { display: flex; gap: 10px; margin-top: 20px; }
.nav-bottom .btn { flex: 1; }

@keyframes slide { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .question { animation: none; } .progress > span { transition: none; } }

/* ---------- resultado */
.result-head { text-align: center; padding: 8px 0 4px; }
.style-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; letter-spacing: .03em; color: #fff;
}
.style-name { font-size: 2rem; font-weight: 750; margin: 10px 0 8px; }

.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.score { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.score .label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.score .value { font-size: 1.9rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.score .value small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.malla { width: 100%; height: auto; display: block; }
.malla text { fill: var(--muted); font-size: 10px; font-family: inherit; }
.malla .axis-title { fill: var(--text); font-size: 10.5px; font-weight: 600; }
.malla .gridline { stroke: var(--border); stroke-width: 1; }
.malla .frame { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.malla .zone-label { font-size: 8.5px; font-weight: 700; }
.malla .pt { stroke: var(--surface); stroke-width: 2; }
.malla .pt-main { fill: var(--primary); stroke: var(--surface); stroke-width: 3; }
.malla .pulse { fill: var(--primary); opacity: .25; transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .35; } to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .malla .pulse { animation: none; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

ul.recs { padding-left: 1.2em; margin: 0; }
ul.recs li { margin-bottom: 8px; }

.styles-list details { border-top: 1px solid var(--border); padding: 12px 0; }
.styles-list details:first-of-type { border-top: 0; }
.styles-list summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.styles-list summary::-webkit-details-marker { display: none; }
.styles-list summary i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.styles-list details p { margin: 8px 0 0; color: var(--muted); font-size: .92rem; }

.loading { display: grid; place-items: center; flex: 1; color: var(--muted); }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .card, .score { box-shadow: none; }
}
