  :root {
    --cream: #F5EFE0;
    --cream-dark: #EDE4CF;
    --navy: #2C4770;
    --navy-deep: #1E3355;
    --gold: #C8912E;
    --gold-soft: #E3B45C;
    --white: #FFFFFF;
    --muted: #5F6C86; /* a11y: contraste AA (>=4.5:1) sobre blanco, mismo tono */
    --line: #E2DCC9;
    --shadow: 0 8px 24px rgba(44, 71, 112, .10);
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { height: 100%; }

  /* a11y: foco visible por teclado en todo elemento interactivo (2.4.7 AA).
     Se conserva el estilo visual; solo se añade contorno para el teclado. */
  a:focus-visible, button:focus-visible, input:focus-visible,
  select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
    /* !important: gana sobre los reset `outline:none` de igual especificidad
       (.field input / .stepper input / .select-wrap select) sin depender del
       orden. Solo aplica en foco de teclado; garantiza 2.4.7 AA. */
    outline: 3px solid var(--navy) !important;
    outline-offset: 2px;
    border-radius: 6px;
  }
  /* a11y: enlace "saltar al contenido" (2.4.1 A) — oculto hasta recibir foco. */
  .skip-link {
    position: absolute; left: 8px; top: -48px; z-index: 1000;
    background: var(--navy); color: #fff; padding: 10px 16px;
    border-radius: 10px; font-weight: 700; text-decoration: none;
    transition: top .15s ease;
  }
  .skip-link:focus { top: 8px; }
  /* a11y: respeta la preferencia de menos movimiento (2.3.3). */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .001ms !important;
      scroll-behavior: auto !important;
    }
  }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(160deg, #8A5A38, #6B4226);
    display: flex; justify-content: center; align-items: center;
    min-height: 100dvh;
  }
  #app {
    width: 100%; max-width: 430px; height: 100dvh; max-height: 932px;
    background: var(--cream);
    display: flex; flex-direction: column; overflow: hidden;
    position: relative;
  }
  @media (min-width: 480px) {
    #app { border-radius: 44px; height: 92dvh; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
  }

  .screen { display: none; flex-direction: column; flex: 1; overflow-y: auto; }
  .screen.active { display: flex; }
  .screen .content { padding: 18px 20px 24px; }

  /* ---------- LOGO ---------- */
  .logo-lockup { display: flex; align-items: center; gap: 10px; }
  .logo-text { font-weight: 800; letter-spacing: .12em; color: var(--navy); line-height: 1.15; }
  .logo-text .deg { color: var(--gold); }

  /* ---------- LOGIN ---------- */
  #login { padding: 48px 24px 24px; }
  .login-head { display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; }
  .login-head .logo-text { font-size: 20px; text-align: center; margin-top: 10px; }
  #login h1 { color: var(--navy); font-size: 28px; margin-top: 22px; }
  #login .sub { color: var(--muted); font-size: 15px; margin-top: 6px; }
  .card {
    background: var(--white); border-radius: 22px; box-shadow: var(--shadow);
    padding: 22px; margin-top: 22px;
  }
  .field label { display: block; color: var(--navy); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
  .field input {
    width: 100%; padding: 14px 16px; font-size: 16px;
    border: 1.5px solid #C9D4E4; border-radius: 14px; color: var(--navy);
    outline: none; background: var(--white);
  }
  .field input:focus { border-color: var(--navy); }
  .field + .field { margin-top: 16px; }
  .btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 15px; border-radius: 14px; border: none;
    font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 20px;
    transition: transform .06s ease, opacity .2s;
  }
  .btn:active { transform: scale(.98); }
  .btn-primary { background: var(--navy); color: var(--white); }
  .btn-primary:disabled { background: #A9BBD6; }
  .btn-ghost { background: var(--white); color: var(--navy); border: 1.5px solid var(--navy); margin-top: 12px; }
  .link-gold {
    display: block; text-align: center; color: var(--gold); font-weight: 700;
    font-size: 14px; margin-top: 16px; text-decoration: none;
  }
  .login-foot { margin-top: auto; text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0 8px; }
  .login-foot a { color: var(--navy); font-weight: 800; text-decoration: none; }

  /* ---------- HEADERS ---------- */
  .home-top { display: flex; justify-content: space-between; align-items: center; }
  .home-top .logo-text { font-size: 15px; }
  .bell { position: relative; background: none; border: none; cursor: pointer; padding: 6px; }
  .bell::after {
    content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
    background: var(--gold); border-radius: 50%;
  }
  .page-title { color: var(--navy); font-size: 26px; margin-top: 18px; }
  .page-title .accent { color: var(--gold); }
  .page-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

  /* ---------- HOME ---------- */
  .hero { display: flex; gap: 12px; margin-top: 18px; align-items: flex-start; }
  .hero h2 { color: var(--navy); font-size: 26px; line-height: 1.15; }
  .hero h2 .accent { color: var(--gold); }
  .hero p { color: var(--muted); font-size: 13.5px; margin-top: 10px; line-height: 1.45; max-width: 24ch; }
  .hero-img {
    width: 132px; height: 158px; border-radius: 18px; object-fit: cover; flex-shrink: 0;
    background: var(--cream-dark);
  }
  .form-card { padding: 18px; }
  .frow { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
  .frow + .frow { margin-top: 18px; }
  .ficon {
    width: 34px; height: 34px; border-radius: 50%; background: var(--cream);
    display: flex; align-items: center; justify-content: center; color: var(--navy); flex-shrink: 0;
  }
  .frow label, .frow .field-label { display: block; color: var(--navy); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
  .stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 10px; }
  .stepper button {
    height: 48px; border-radius: 12px; border: 1.5px solid #C9D4E4; background: var(--white);
    font-size: 22px; color: var(--navy); cursor: pointer; font-weight: 700;
  }
  .stepper input {
    height: 48px; text-align: center; font-size: 18px; font-weight: 700; color: var(--navy);
    border: 1.5px solid #C9D4E4; border-radius: 12px; width: 100%; outline: none;
  }
  .select-wrap select {
    width: 100%; height: 48px; padding: 0 16px; font-size: 15px; font-weight: 600; color: var(--navy);
    border: 1.5px solid #C9D4E4; border-radius: 12px; background: var(--white);
    appearance: none; outline: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%232C4770' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center;
  }
  .chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .chip {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 10px 6px; border-radius: 14px; border: 1.5px solid #C9D4E4;
    background: var(--white); color: var(--navy); font-weight: 700; font-size: 13.5px; cursor: pointer;
  }
  .chip svg { width: 24px; height: 17px; color: var(--navy); }
  .chip .dogsil { fill: currentColor; }
  .chip.selected { background: var(--navy); color: var(--white); border-color: var(--navy); }
  .chip.selected svg { color: var(--white); }

  .result-card { padding: 18px; margin-top: 16px; }
  .result-line { display: flex; align-items: center; gap: 14px; }
  .ring { width: 46px; height: 46px; flex-shrink: 0; }
  .result-line p { color: var(--navy); font-size: 14.5px; }
  .result-line b { font-weight: 800; }

  /* ---------- BOTTOM NAV ---------- */
  #mainnav {
    display: grid; grid-template-columns: repeat(6, 1fr);
    background: var(--white); border-top: 1px solid var(--line);
    padding: 10px 6px calc(12px + env(safe-area-inset-bottom));
  }
  #mainnav.hidden { display: none; }
  #mainnav button {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer;
  }
  #mainnav button.active { color: var(--navy); font-weight: 800; }
  #mainnav svg { width: 22px; height: 22px; }

  /* ---------- RESULT ---------- */
  .result-top { display: flex; justify-content: space-between; align-items: center; }
  .back-btn { background: none; border: none; color: var(--navy); font-size: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 4px; }
  .badge {
    background: var(--cream-dark); color: var(--gold); font-size: 11px; font-weight: 800;
    letter-spacing: .08em; padding: 8px 12px; border-radius: 10px;
  }
  .tags { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  .tag {
    background: var(--white); border: 1px solid var(--line); color: var(--navy);
    font-size: 13px; font-weight: 700; padding: 7px 14px; border-radius: 999px;
  }
  .recipe-head { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
  .recipe-head .ficon { width: 44px; height: 44px; }
  .recipe-head h3 { color: var(--navy); font-size: 17px; line-height: 1.3; }
  .recipe-head .freq { color: var(--muted); font-size: 13px; margin-top: 4px; }
  .ingredients { margin-top: 14px; }
  .ing { display: flex; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid var(--line); }
  .ing:last-child { border-bottom: none; }
  .ing span { color: var(--navy); font-size: 14.5px; font-weight: 600; }
  .ing b { color: var(--gold); font-size: 14.5px; font-weight: 800; }
  .steps-card h3 { color: var(--navy); font-size: 16px; margin-bottom: 14px; }
  .step { display: grid; grid-template-columns: 26px 1fr; gap: 12px; margin-bottom: 14px; }
  .step:last-child { margin-bottom: 0; }
  .step .n {
    width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: var(--white);
    font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  }
  .step p { color: var(--navy); font-size: 14px; line-height: 1.5; }

  /* ---------- SALUD ---------- */
  .card h3 { color: var(--navy); font-size: 16px; }
  .card .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
  .levels { display: flex; gap: 8px; margin-top: 16px; }
  .level {
    flex: 1; padding: 10px 4px 8px; border-radius: 14px; border: 1.5px solid #C9D4E4;
    background: var(--white); cursor: pointer; text-align: center;
  }
  .level .face { font-size: 22px; display: block; }
  .level .lbl { font-size: 10.5px; font-weight: 700; color: var(--muted); margin-top: 4px; display: block; }
  .level.selected { background: var(--navy); border-color: var(--navy); }
  .level.selected .lbl { color: var(--white); }
  .saved-note { color: var(--gold); font-size: 13px; font-weight: 700; margin-top: 12px; text-align: center; min-height: 16px; }
  .week-chart { display: flex; gap: 10px; align-items: flex-end; height: 110px; margin-top: 18px; }
  .bcol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
  .btrack { width: 100%; flex: 1; background: var(--cream); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
  .bfill { width: 100%; background: var(--navy); border-radius: 8px; transition: height .3s ease; }
  .bcol.today .bfill { background: var(--gold); }
  .bcol .day { font-size: 11px; font-weight: 700; color: var(--muted); }
  .bcol.today .day { color: var(--gold); }

  /* ---------- RUTINA ---------- */
  .progress-line { display: flex; align-items: center; gap: 14px; }
  .progress-line p { color: var(--navy); font-size: 14.5px; }
  .task { display: flex; align-items: center; gap: 14px; padding: 14px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .task:last-child { border-bottom: none; }
  .task input { width: 22px; height: 22px; accent-color: var(--navy); cursor: pointer; flex-shrink: 0; }
  .task .t-name { color: var(--navy); font-size: 14.5px; font-weight: 700; }
  .task .t-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
  .task.done .t-name { text-decoration: line-through; opacity: .55; }
  .task .t-tag {
    margin-left: auto; background: var(--cream); color: var(--gold); font-size: 11px;
    font-weight: 800; padding: 5px 10px; border-radius: 999px; flex-shrink: 0;
  }

  /* ---------- CUIDADOS ---------- */
  details.care { background: var(--white); border-radius: 18px; box-shadow: var(--shadow); margin-top: 14px; overflow: hidden; }
  details.care summary {
    display: flex; align-items: center; gap: 12px; padding: 16px 18px;
    color: var(--navy); font-weight: 800; font-size: 15px; cursor: pointer; list-style: none;
  }
  details.care summary::-webkit-details-marker { display: none; }
  details.care summary::after { content: "+"; margin-left: auto; color: var(--gold); font-size: 20px; font-weight: 700; }
  details.care[open] summary::after { content: "−"; }
  details.care .body { padding: 0 18px 16px; color: var(--navy); font-size: 14px; line-height: 1.55; }
  details.care .body li { margin: 6px 0 6px 18px; }

  /* ---------- CLASES ---------- */
  .lesson { background: var(--white); border-radius: 18px; box-shadow: var(--shadow); margin-top: 14px; overflow: hidden; }
  .lesson-head { display: grid; grid-template-columns: 64px 1fr 28px; gap: 12px; padding: 14px; align-items: center; cursor: pointer; }
  .thumb {
    width: 64px; height: 48px; border-radius: 12px; position: relative;
    background: linear-gradient(135deg, var(--navy), #47679A);
    display: flex; align-items: center; justify-content: center;
  }
  .thumb::after {
    content: ""; width: 0; height: 0; border-style: solid;
    border-width: 7px 0 7px 12px; border-color: transparent transparent transparent #fff;
    margin-left: 3px;
  }
  .lesson-head h4 { color: var(--navy); font-size: 14.5px; line-height: 1.3; }
  .lesson-meta { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 600; }
  .lesson-check { font-size: 18px; color: var(--line); text-align: center; }
  .lesson.watched .lesson-check { color: var(--gold); }
  .lesson.watched .thumb { opacity: .65; }
  .lesson-body { display: none; padding: 0 16px 16px; }
  .lesson.open .lesson-body { display: block; }
  .lesson-body li { color: var(--navy); font-size: 13.5px; line-height: 1.5; margin: 6px 0 6px 18px; }
  .lesson-body .soon {
    margin-top: 12px; background: var(--cream); color: var(--gold); font-weight: 800;
    font-size: 12px; letter-spacing: .06em; text-align: center; padding: 12px; border-radius: 12px;
  }
  .lesson-body .markbtn {
    margin-top: 10px; width: 100%; padding: 12px; border-radius: 12px; border: 1.5px solid var(--navy);
    background: var(--white); color: var(--navy); font-weight: 700; font-size: 13.5px; cursor: pointer;
  }
  .lesson.watched .lesson-body .markbtn { background: var(--navy); color: var(--white); }

  /* ---------- PERFIL ---------- */
  .profile-head { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
  .avatar {
    width: 92px; height: 92px; border-radius: 50%; background: var(--cream-dark);
    display: flex; align-items: center; justify-content: center; font-size: 44px;
    border: 3px solid var(--white); box-shadow: var(--shadow);
  }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
  .stat { background: var(--white); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 8px; text-align: center; }
  .stat b { display: block; color: var(--navy); font-size: 19px; font-weight: 800; }
  .stat span { color: var(--muted); font-size: 11.5px; font-weight: 700; }
  .plist { padding: 6px 18px; }
  .mini-inp, .mini-sel {
    margin-left: auto; width: 120px; height: 38px; padding: 0 12px;
    border: 1.5px solid #C9D4E4; border-radius: 10px; background: var(--white);
    color: var(--navy); font-weight: 700; font-size: 14px; outline: none; text-align: right;
  }
  .mini-sel { appearance: none; text-align: left; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232C4770' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
  }
  .prow { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--navy); font-size: 14.5px; font-weight: 700; }
  .prow:last-child { border-bottom: none; }
  .prow .val { margin-left: auto; color: var(--muted); font-weight: 600; }
  .btn-danger { background: var(--white); color: #B3453A; border: 1.5px solid #E4BDB8; }

  /* ---------- STREAK + RECORDATORIO ---------- */
  .streak {
    display: inline-flex; align-items: center; background: var(--white); color: var(--gold);
    font-weight: 800; font-size: 12.5px; padding: 8px 14px; border-radius: 999px;
    box-shadow: var(--shadow); margin-top: 14px;
  }
  .bath-banner {
    display: flex; width: 100%; align-items: center; gap: 8px; background: var(--navy);
    color: #fff; border: none; border-radius: 14px; padding: 13px 16px;
    font-size: 13.5px; font-weight: 700; margin-top: 14px; cursor: pointer; text-align: left;
  }

  /* ---------- MIS PERROS ---------- */
  .petrow {
    display: flex; align-items: center; gap: 10px; padding: 13px 0;
    border-bottom: 1px solid var(--line); cursor: pointer;
    color: var(--navy); font-weight: 700; font-size: 14.5px;
  }
  .petrow:last-child { border-bottom: none; }
  .petrow .val { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 13px; }
  .petrow .activetag { background: var(--cream); color: var(--gold); font-size: 10.5px; font-weight: 800; padding: 4px 8px; border-radius: 999px; }
  .petrow .del { color: #B3453A; font-weight: 800; padding: 2px 8px; font-size: 13px; }

  /* ---------- IMPRESIÓN (PDF) ---------- */
  #printArea { display: none; }
  @media print {
    body { background: #fff !important; display: block; min-height: 0; }
    #app { display: none !important; }
    #printArea { display: block; font-family: Georgia, 'Times New Roman', serif; color: #1E3355; padding: 8px; }
    #printArea .ph { display: flex; align-items: center; gap: 12px; border-bottom: 3px solid #C8912E; padding-bottom: 14px; }
    #printArea .ph img { width: 54px; height: 54px; border-radius: 12px; }
    #printArea h1 { font-size: 24px; margin: 18px 0 4px; }
    #printArea .meta { color: #7E8BA3; font-size: 13px; margin-bottom: 16px; }
    #printArea h2 { font-size: 16px; margin: 18px 0 8px; color: #C8912E; }
    #printArea table { width: 100%; border-collapse: collapse; }
    #printArea td { padding: 8px 4px; border-bottom: 1px solid #E2DCC9; font-size: 14px; }
    #printArea td:last-child { text-align: right; font-weight: 700; }
    #printArea ol { margin-left: 20px; }
    #printArea li { margin: 8px 0; font-size: 14px; line-height: 1.5; }
    #printArea .foot { margin-top: 22px; font-size: 11.5px; color: #7E8BA3; border-top: 1px solid #E2DCC9; padding-top: 10px; }
  }

  /* ---------- CARGANDO RECETA ---------- */
  #genOverlay {
    position: absolute; inset: 0; z-index: 50; background: var(--cream);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
    opacity: 0; pointer-events: none; transition: opacity .3s ease; padding: 0 32px;
  }
  #genOverlay.show { opacity: 1; pointer-events: auto; }
  .gen-spinner { width: 88px; height: 88px; }
  .gen-arc { transform-origin: 50% 50%; animation: genspin 1.1s linear infinite; }
  @keyframes genspin { to { transform: rotate(360deg); } }
  #genText {
    color: var(--navy); font-size: 17px; font-weight: 700; text-align: center;
    min-height: 44px; line-height: 1.4;
  }
  #genText.tick { animation: fadeUp .3s ease both; }
  .gen-dots { display: flex; gap: 7px; }
  .gen-dots span {
    width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
    animation: dotpulse 1s ease-in-out infinite;
  }
  .gen-dots span:nth-child(2) { animation-delay: .18s; }
  .gen-dots span:nth-child(3) { animation-delay: .36s; }
  @keyframes dotpulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }

  .fade-in { animation: fadeUp .35s ease both; }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  /* Aviso de revisión clínica (gate de publicación) */
  .review-notice { display: none; border-radius: 12px; padding: 12px 14px; margin: 10px 0 4px;
    font-size: 13px; line-height: 1.45; font-weight: 600; }
  .review-notice.draft { display: block; background: #FBF0DA; color: #6B4E17;
    border: 1.5px solid var(--gold); }
  .review-notice.reviewed { display: block; background: #E9F2EA; color: #2C5233;
    border: 1.5px solid #6E9C77; }

  /* Contenido clínico accionable retenido del público (pendiente de vincular
     la evidencia de la aprobación veterinaria). El contenido no se borra; solo
     no se presenta públicamente como recomendación. */
  .withheld-box { border: 1.5px solid var(--gold); background: #FBF0DA; color: #6B4E17;
    font-size: 14px; line-height: 1.55; font-weight: 600; }
