:root {
  --bg0: #dff0ec;
  --bg1: #f3f7f6;
  --ink: #14302d;
  --muted: #4d6763;
  --brand: #0f5c56;
  --brand-2: #147a72;
  --accent: #c45c26;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(20, 48, 45, 0.1);
  --shadow: 0 18px 50px rgba(15, 92, 86, 0.12);
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg1);
  -webkit-font-smoothing: antialiased;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, #9fd4cb 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f2d4c2 0%, transparent 45%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #eef4f3);
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100%;
  padding: 16px 18px calc(88px + var(--safe-b));
}
.app.flow-pad {
  padding-bottom: calc(28px + var(--safe-b));
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(247, 251, 250, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 40;
}
.tabbar[hidden] { display: none !important; }
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 6px 4px;
  border-radius: 14px;
  display: grid;
  justify-items: center;
  gap: 3px;
  cursor: pointer;
  text-decoration: none;
}
.tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab.on {
  color: var(--brand);
  background: rgba(15, 92, 86, 0.08);
}
.tab.tab-new {
  color: #f4fffc;
}
.tab.tab-new .tab-fab {
  width: 42px;
  height: 42px;
  margin-top: -18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  box-shadow: 0 10px 22px rgba(15, 92, 86, 0.28);
  display: grid;
  place-items: center;
  color: #eefaf7;
}
.tab.tab-new .tab-fab svg { width: 22px; height: 22px; stroke: currentColor; }
.tab.tab-new span { color: var(--brand); margin-top: 2px; }
.tab.tab-new.on span { color: var(--brand); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 {
  font-size: 1.7rem;
  line-height: 1.1;
}
.page-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}
.page-count {
  min-width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(15, 92, 86, 0.1);
  color: var(--brand);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.75);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.chip.on {
  background: rgba(15, 92, 86, 0.12);
  border-color: rgba(15, 92, 86, 0.28);
  color: var(--brand);
}

.menu-list {
  display: grid;
  gap: 8px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 22px rgba(15, 92, 86, 0.06);
  cursor: pointer;
  font: inherit;
  width: 100%;
  text-align: left;
}
.menu-item .mi-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(15, 92, 86, 0.1);
  color: var(--brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
}
.menu-item .mi-ico.warn { background: rgba(196, 92, 38, 0.12); color: #8a4b12; }
.menu-item .mi-body { flex: 1; min-width: 0; }
.menu-item strong { display: block; font-size: 1rem; }
.menu-item span { display: block; color: var(--muted); font-size: 0.84rem; margin-top: 2px; line-height: 1.35; }
.menu-item .mi-chev { color: var(--muted); font-size: 1.2rem; }

.section-title {
  font-size: 1.05rem;
  margin: 22px 0 10px;
}
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.quick-actions .btn { font-size: 0.9rem; padding: 12px 10px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 6px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
}
.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--brand);
}
.stat span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  animation: rise 0.55s ease both;
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  color: #e7f2f0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}
.brand h1 { font-size: 1.55rem; line-height: 1.1; }
.brand p { color: var(--muted); font-size: 0.92rem; margin-top: 2px; }

.hero {
  margin-bottom: 22px;
  animation: rise 0.65s ease both;
}
.hero h2 {
  font-size: clamp(1.7rem, 6vw, 2.15rem);
  line-height: 1.12;
  max-width: 14ch;
}
.hero p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
  max-width: 34ch;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 999px;
  padding: 14px 18px;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #f4fffc;
  box-shadow: 0 12px 28px rgba(15, 92, 86, 0.28);
  width: 100%;
}
.btn-secondary {
  background: rgba(255,255,255,0.7);
  color: var(--brand);
  border: 1px solid var(--line);
  width: 100%;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 10px 0;
}
.btn-danger {
  background: transparent;
  color: #9b2c2c;
  width: 100%;
}
.btn-row {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.btn-row.two {
  grid-template-columns: 1fr 1fr;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.5s ease both;
}

.list { display: grid; gap: 12px; margin-top: 8px; }
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 10px 28px rgba(15, 92, 86, 0.08);
  animation: rise 0.45s ease both;
}
.card-link h3 { font-size: 1.08rem; margin-bottom: 4px; }
.card-meta { color: var(--muted); font-size: 0.86rem; }
.badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
  background: rgba(15, 92, 86, 0.1);
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.done { color: #7a3e12; background: rgba(196, 92, 38, 0.12); }
.badge.control { color: #1a4a6e; background: rgba(26, 74, 110, 0.12); }
.badge.estudio { color: #5a3d8a; background: rgba(90, 61, 138, 0.12); }
.badge.sintoma { color: #0f5c56; background: rgba(15, 92, 86, 0.1); }
.badge.warn { color: #8a4b12; background: rgba(196, 120, 38, 0.14); }
.badge.ok { color: #0f5c56; background: rgba(15, 92, 86, 0.14); }
.badge.deseo { color: #4d6763; background: rgba(77, 103, 99, 0.12); }

.reminders { margin-top: 26px; }
.reminders h2 { font-size: 1.15rem; margin-bottom: 10px; }
.remind-card {
  display: grid;
  gap: 4px;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 248, 240, 0.9);
  border: 1px solid rgba(196, 120, 38, 0.25);
  border-radius: 16px;
  padding: 14px 16px;
}
.remind-card.preguntas {
  background: rgba(231, 242, 240, 0.95);
  border-color: rgba(15, 92, 86, 0.22);
}
.remind-card.indicaciones {
  background: rgba(243, 236, 250, 0.95);
  border-color: rgba(90, 61, 138, 0.22);
}
.remind-card strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.remind-card.preguntas strong { color: var(--brand); }
.remind-card.indicaciones strong { color: #5a3d8a; }
.remind-card.cita strong { color: #8a4b12; }

.avisos-list {
  margin: 14px 0 4px;
  padding-left: 1.15rem;
  color: var(--ink);
  line-height: 1.45;
}
.avisos-list li { margin: 6px 0; }

.indicaciones-box {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(90, 61, 138, 0.08);
  border: 1px solid rgba(90, 61, 138, 0.18);
}
.indicaciones-box h3 {
  font-size: 0.95rem;
  color: #5a3d8a;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.indicaciones-box p,
.indicaciones-box li {
  font-size: 1.05rem;
  line-height: 1.45;
}
.indicaciones-box ul {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 6px;
}
.remind-card span { font-size: 0.95rem; line-height: 1.35; }

.callout {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 92, 86, 0.08);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.callout.warn {
  background: rgba(196, 120, 38, 0.12);
  color: #6b3d10;
}

.offers {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}
.offer-card {
  display: grid;
  gap: 12px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(15, 92, 86, 0.16);
  box-shadow: 0 8px 24px rgba(20, 50, 45, 0.06);
}
.offer-body {
  display: grid;
  gap: 4px;
}
.offer-body strong {
  font-size: 1rem;
  color: var(--ink);
}
.offer-body span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}
.offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.offer-actions .btn {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
  width: auto;
  flex: 0 0 auto;
}
.offer-actions .btn-ghost {
  color: var(--muted);
  box-shadow: none;
}

.ask-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--line);
}
.ask-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand);
}

.type-pick {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}
.type-card {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(15, 92, 86, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.type-card:active { transform: scale(0.98); }
.type-card:focus-visible {
  outline: none;
  border-color: rgba(15, 92, 86, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 92, 86, 0.12);
}
.type-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.type-card span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.choice {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.choice.on {
  border-color: rgba(15, 92, 86, 0.45);
  background: rgba(15, 92, 86, 0.1);
  color: var(--brand);
}

.pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.pick-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  line-height: 1.25;
}
.pick-chip.on {
  border-color: rgba(15, 92, 86, 0.45);
  background: rgba(15, 92, 86, 0.12);
  color: var(--brand);
}
.pick-chip.otro {
  border-style: dashed;
}

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.voice-wrap {
  display: grid;
  gap: 6px;
}
.voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.voice-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 2px;
  border-radius: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(15, 92, 86, 0.25);
}
.voice-btn:disabled {
  opacity: 0.35;
  cursor: default;
  text-decoration: none;
}
.voice-btn.recording {
  color: #8a4b12;
  text-decoration-color: rgba(138, 75, 18, 0.45);
}
.voice-status {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 4px;
}

.empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.topbar h2 { flex: 1; font-size: 1.25rem; }
.step-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.step-dots span {
  height: 6px;
  flex: 1;
  border-radius: 999px;
  background: rgba(15, 92, 86, 0.15);
}
.step-dots span.on { background: var(--brand); }

label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin: 14px 0 6px;
}
input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(15, 92, 86, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 92, 86, 0.12);
}
.hint { color: var(--muted); font-size: 0.84rem; margin-top: 6px; line-height: 1.4; }

.script-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(15, 92, 86, 0.08);
  border: 1px dashed rgba(15, 92, 86, 0.25);
  font-size: 1.02rem;
  line-height: 1.45;
}

.questions { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; counter-reset: q; }
.questions li {
  counter-increment: q;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 12px 48px;
  position: relative;
  line-height: 1.4;
}
.questions li::before {
  content: counter(q);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #eefaf7;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
}

.doctor-mode {
  background: #f7fbfa;
  border-radius: 24px;
  padding: 18px;
  border: 1px solid var(--line);
}
.doctor-mode h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}
.doctor-mode .block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.doctor-mode .block h3 {
  font-size: 0.95rem;
  color: var(--brand);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doctor-mode p, .doctor-mode li {
  font-size: 1.12rem;
  line-height: 1.45;
}
.doctor-mode ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #f4fffc;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 50;
  white-space: nowrap;
  max-width: min(90vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.onboard {
  min-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: rise 0.45s ease both;
}
.onboard-top {
  display: flex;
  justify-content: flex-end;
}
.onboard-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0 20px;
}
.ob-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}
.onboard-body h1 {
  font-size: clamp(1.65rem, 6vw, 2.1rem);
  line-height: 1.12;
  max-width: 14ch;
}
.ob-body {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
  max-width: 34ch;
}
.ob-visual { margin-top: 28px; }
.onboard-foot { margin-top: auto; padding-top: 12px; }
.ob-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.ob-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(15, 92, 86, 0.18);
}
.ob-dots span.on { background: var(--brand); width: 22px; border-radius: 999px; }

.ob-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.ob-step {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.ob-step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: var(--brand);
  color: #eefaf7;
  font-size: 0.8rem;
}
.ob-arrow { color: var(--muted); font-weight: 700; }

.ob-types { display: grid; gap: 10px; }
.ob-type {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}
.ob-type strong { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.ob-type span { color: var(--muted); font-size: 0.88rem; }

.ob-demo {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.ob-demo-bar {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  margin-bottom: 12px;
}
.ob-demo-plus {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: #eefaf7;
  vertical-align: middle;
}
.ob-demo-card {
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.ob-demo-card p { color: var(--muted); font-size: 0.88rem; margin: 4px 0 8px; }

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