@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

:root {
  --bg: #f8f3ec;
  --paper: #fffdf9;
  --text: #1d1b19;
  --muted: #746f68;
  --line: #e6ddd3;
  --gold: #c49538;
  --gold-dark: #9d7528;
  --soft-gold: #f2e6cb;
  --success: #40664c;
  --warning: #956a26;
  --danger: #8b4747;
  --radius: 24px;
  --shadow: 0 12px 40px rgba(40, 30, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.screen--active {
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  padding-top: 4px;
}

.brand-logo {
  display: block;
  width: 146px;
  max-width: 48vw;
  height: auto;
  object-fit: contain;
}

.hero {
  margin-top: clamp(56px, 12vw, 92px);
}

.eyebrow {
  display: inline-block;
  color: var(--gold-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(31px, 8vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.04em;
  margin: 12px 0 18px;
}

h2 {
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h3 {
  font-size: 20px;
  line-height: 1.2;
}

.hero p,
.section-copy p,
.result-hero p,
.recommendation p {
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 36px 0 30px;
}
.home-options {
  display: grid;
  gap: 14px;
  margin: 36px 0 24px;
}

.entry-card,
.type-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 22px;
  padding: 18px 16px;
  display: grid;
  grid-template-columns: 34px 1fr 20px;
  align-items: start;
  gap: 12px;
  box-shadow: var(--shadow);
}

.entry-card:active,
.type-card:active {
  transform: scale(.99);
}

.entry-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft-gold);
  color: var(--gold-dark);
  font-size: 11px;
  font-weight: 700;
}

.entry-copy strong,
.type-card strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.entry-copy p,
.type-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.entry-arrow {
  align-self: center;
  justify-self: end;
  color: var(--gold-dark);
  font-size: 18px;
}

.type-grid {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.type-card {
  grid-template-columns: 1fr;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}


.feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.feature span {
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
}

.feature p {
  margin: 0;
  font-size: 14px;
}

.btn {
  min-height: 52px;
  border-radius: 16px;
  padding: 0 18px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--full {
  width: 100%;
}

.btn--primary {
  background: var(--text);
  color: white;
}

.btn--secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.legal-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
  margin: 14px auto 0;
  max-width: 430px;
}

.topbar,
.camera-header {
  min-height: 50px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 30px;
}

.topbar > span:nth-child(2) {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
}

.topbar-spacer {
  width: 44px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 21px;
  cursor: pointer;
}

.section-copy {
  margin-bottom: 26px;
}

.section-copy h2 {
  margin: 9px 0 12px;
}

.tips {
  display: grid;
  gap: 10px;
  margin-bottom: auto;
}

.tips article {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.tip-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft-gold);
  color: var(--gold-dark);
  font-weight: 700;
  font-size: 12px;
}

.tips h3 {
  font-size: 14px;
  margin: 0 0 5px;
}

.tips p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

#openCameraBtn {
  margin-top: 32px;
}

.screen--camera {
  padding: 0;
  background: #111;
  color: white;
  position: relative;
}

.camera-header {
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0));
}

.icon-btn--dark {
  border-color: rgba(255,255,255,.25);
  color: white;
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(8px);
}

.camera-title {
  text-align: center;
  min-width: 0;
}

.camera-title span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
}

.camera-title small {
  display: block;
  font-size: 9px;
  color: rgba(255,255,255,.72);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.camera-logo {
  width: 96px;
  max-height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.result-logo-wrap {
  margin-top: 2px;
  margin-bottom: 18px;
}

.result-logo {
  width: 124px;
  max-width: 42vw;
  height: auto;
  display: block;
}

.camera-stage {
  position: relative;
  min-height: 72dvh;
  overflow: hidden;
  background: #111;
}

#video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#video {
  object-fit: cover;
}

#overlay {
  pointer-events: none;
}

.face-guide {
  position: absolute;
  left: 50%;
  top: 49%;
  width: min(72vw, 330px);
  aspect-ratio: 0.76;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 48% 48% 45% 45%;
  box-shadow: 0 0 0 999px rgba(0,0,0,.17);
  pointer-events: none;
}

.face-guide::before,
.face-guide::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 46%;
  height: 1px;
  background: rgba(255,255,255,.38);
  transform: translateX(-50%);
}

.face-guide::before {
  top: 31%;
}

.face-guide::after {
  top: 61%;
}

.guide-t {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 34%;
  height: 58%;
  transform: translateX(-50%);
  border: 1px dashed rgba(255,255,255,.42);
  border-radius: 34% 34% 46% 46%;
}

.quality-badge {
  position: absolute;
  left: 50%;
  top: max(82px, calc(env(safe-area-inset-top) + 70px));
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.18);
}

.quality-badge--warn {
  background: rgba(92, 63, 17, .62);
}

.quality-badge--ok {
  background: rgba(30, 92, 52, .72);
}

.camera-hint {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  text-align: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(12px);
}

.camera-hint strong,
.camera-hint span {
  display: block;
}

.camera-hint strong {
  font-size: 14px;
}

.camera-hint span {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.5;
  color: rgba(255,255,255,.72);
}

.camera-controls {
  min-height: 28dvh;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
}

.capture-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.65);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.capture-btn span {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  display: block;
  transition: transform .15s ease, opacity .15s ease;
}

.capture-btn:not(:disabled):active span {
  transform: scale(.92);
}

.capture-btn:disabled {
  opacity: .35;
}

.camera-controls small {
  max-width: 330px;
  margin-top: 13px;
  color: rgba(255,255,255,.62);
  text-align: center;
  line-height: 1.5;
  font-size: 9px;
}

.processing-wrap {
  margin: auto 0;
  text-align: center;
}

.scan-orb {
  width: 122px;
  height: 122px;
  border: 1px solid var(--line);
  border-radius: 50%;
  margin: 0 auto 30px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #fff, #f4ead8);
}

.scan-orb::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  height: 1px;
  background: var(--gold);
  animation: scan 1.6s ease-in-out infinite;
}

.scan-orb span {
  width: 72px;
  height: 88px;
  border: 1px solid var(--gold);
  border-radius: 47% 47% 44% 44%;
}

@keyframes scan {
  0%,100% { top: 24%; opacity: .35; }
  50% { top: 76%; opacity: 1; }
}

.processing-wrap h2 {
  margin: 10px 0 24px;
}

.processing-list {
  width: min(100%, 330px);
  margin: 0 auto;
  text-align: left;
  border-top: 1px solid var(--line);
}

.processing-list p {
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.processing-list p.done {
  color: var(--success);
  font-weight: 600;
}

.result-hero {
  padding: 4px 0 22px;
}

.result-hero h2 {
  margin: 8px 0 12px;
  font-size: clamp(36px, 10vw, 50px);
}

.metrics-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  background: white;
}

.metric + .metric {
  margin-top: 22px;
}

.metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.metric-head span {
  font-size: 12px;
  font-weight: 600;
}

.metric-head strong {
  font-size: 10px;
  color: var(--gold-dark);
  letter-spacing: .12em;
}

.meter {
  height: 7px;
  background: #efe9e1;
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d9c08b, var(--gold-dark));
  border-radius: inherit;
  transition: width .5s ease;
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-top: 7px;
}

.recommendation {
  margin-top: 18px;
  background: var(--soft-gold);
  border-radius: var(--radius);
  padding: 22px;
}

.recommendation h3 {
  margin: 8px 0 8px;
  font-size: 22px;
}

.recommendation p {
  margin-bottom: 0;
}

.routine {
  margin-top: 30px;
}

.routine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1eee9;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.routine ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.routine li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.routine li > span {
  color: var(--gold-dark);
  font-weight: 700;
  font-size: 11px;
  padding-top: 2px;
}

.routine strong {
  display: block;
  font-size: 13px;
}

.routine small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

@media (min-width: 700px) {
  body {
    padding: 24px;
  }

  .app-shell {
    min-height: calc(100dvh - 48px);
    border-radius: 28px;
    box-shadow: 0 20px 70px rgba(30,20,10,.12);
  }

  .screen {
    min-height: calc(100dvh - 48px);
  }

  .camera-stage {
    min-height: calc((100dvh - 48px) * .72);
  }

  .camera-controls {
    min-height: calc((100dvh - 48px) * .28);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


.confidence-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.confidence-card > div {
  min-width: 0;
}

.confidence-card strong {
  display: block;
  margin-top: 5px;
  font-size: 26px;
  line-height: 1;
}

.confidence-card p {
  margin: 0;
  max-width: 190px;
  text-align: right;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.technical-readout {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.technical-readout summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  list-style: none;
}

.technical-readout summary::-webkit-details-marker {
  display: none;
}

.technical-readout summary::after {
  content: "+";
  margin-left: auto;
  color: var(--gold-dark);
  font-size: 18px;
}

.technical-readout[open] summary::after {
  content: "−";
}

.technical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.technical-grid div {
  min-width: 0;
  padding: 12px 14px;
  background: #fff;
}

.technical-grid span,
.technical-grid strong {
  display: block;
}

.technical-grid span {
  color: var(--muted);
  font-size: 9px;
}

.technical-grid strong {
  margin-top: 4px;
  font-size: 13px;
}

.technical-readout > p,
.technical-readout > small {
  display: block;
  margin: 0;
  padding: 12px 14px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.technical-readout > small {
  padding-bottom: 14px;
}

@media (max-width: 360px) {
  .confidence-card {
    grid-template-columns: 1fr;
  }
  .confidence-card p {
    max-width: none;
    text-align: left;
  }
}

/* ============================== */
/* V4 · CONFIRMACIÓN SEGÚN GUÍA   */
/* ============================== */

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 18px;
}

.mini-metrics > div {
  min-width: 0;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.mini-metrics span,
.mini-metrics strong {
  display: block;
}

.mini-metrics span {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.mini-metrics strong {
  margin-top: 5px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.paper-test-card {
  padding: 20px;
  margin: 4px 0 16px;
  border-radius: var(--radius);
  background: var(--soft-gold);
}

.paper-test-card h3 {
  margin: 7px 0 8px;
}

.paper-test-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.choice-stack {
  display: grid;
  gap: 10px;
}

.choice-card {
  width: 100%;
  min-height: 68px;
  padding: 15px 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.choice-card strong,
.choice-card span {
  display: block;
}

.choice-card strong {
  font-size: 12px;
  line-height: 1.4;
}

.choice-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.choice-card:active,
.choice-card.is-selected {
  border-color: var(--gold);
  background: #fbf6ea;
}

.conditional-step {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.conditional-step h3 {
  margin: 8px 0 14px;
  font-size: 18px;
}

.camera-only-btn {
  margin-top: 24px;
}

@media (max-width: 360px) {
  .mini-metrics {
    grid-template-columns: 1fr;
  }
}

/* V7: respuesta más rápida en cámara */
.capture-btn:not(:disabled) {
  opacity: 1;
}

.capture-btn:not(:disabled) span {
  box-shadow: 0 0 0 6px rgba(255,255,255,.10);
}

/* V8: estado táctil del botón de captura */
.capture-btn {
  position: relative;
  z-index: 20;
  touch-action: manipulation;
  pointer-events: auto;
}
.capture-btn:not(:disabled) {
  opacity: 1;
}
.capture-btn.is-capturing span {
  transform: scale(.82);
  opacity: .75;
}
