/* ======================================================
   StarPaint Kids — BLOQUE 1 FRONTEND ESTABLE
   Objetivo: layout limpio, canvas exacto, paneles sin recortes.
====================================================== */

:root{
  --bg:#fff7ec;
  --paper:#fffdf8;
  --paper-strong:#ffffff;
  --text:#392d29;
  --muted:#82736c;
  --line:#efe3d8;

  --pink:#ff8fb1;
  --pink-strong:#ff4d6d;
  --yellow:#ffd166;
  --blue:#8bd3ff;
  --purple:#cdb4ff;
  --green:#a8e6a1;
  --orange:#f7a85b;

  --shadow:0 18px 54px rgba(68,42,28,.16);
  --soft:0 8px 28px rgba(68,42,28,.11);

  --radius:28px;
  --dock-h:92px;
  --safe-top:max(10px, env(safe-area-inset-top));
  --safe-bottom:max(10px, env(safe-area-inset-bottom));
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
}

html,
body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  color:var(--text);
  background:
    radial-gradient(circle at 12% 5%, rgba(255,209,102,.42), transparent 25%),
    radial-gradient(circle at 92% 8%, rgba(139,211,255,.42), transparent 25%),
    var(--bg);
  font-family:ui-rounded, "SF Pro Rounded", "Nunito", "Comic Sans MS", system-ui, sans-serif;
  user-select:none;
  overscroll-behavior:none;
}

button,
input,
select{
  font:inherit;
}

button{
  border:0;
  color:var(--text);
  cursor:pointer;
}

button:disabled{
  cursor:not-allowed;
  opacity:.6;
}

[hidden]{
  display:none !important;
}

/* ======================================================
   APP BASE
====================================================== */

.app-shell{
  width:100%;
  height:100dvh;
  max-width:1260px;
  margin:0 auto;
  padding:var(--safe-top) 14px calc(var(--dock-h) + var(--safe-bottom) + 12px);
  display:grid;
  grid-template-rows:auto auto auto minmax(0,1fr) auto auto;
  gap:10px;
  min-height:0;
}

.hero-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  min-height:58px;
}

.brand-lockup{
  display:grid;
  text-align:left;
  background:transparent;
  padding:0;
  min-width:0;
}

.eyebrow{
  color:var(--muted);
  font-size:12px;
  line-height:1;
  letter-spacing:.14em;
  text-transform:uppercase;
  font-weight:1000;
}

.brand-title{
  display:block;
  font-size:clamp(34px, 5vw, 58px);
  line-height:.92;
  letter-spacing:-.06em;
  font-weight:1000;
}

.hero-actions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
  max-width:50%;
}

.round-btn{
  width:50px;
  height:50px;
  border-radius:20px;
  background:rgba(255,255,255,.88);
  box-shadow:var(--soft);
  display:grid;
  place-items:center;
  font-size:22px;
  flex:0 0 auto;
}

.round-btn:active,
.mode-chip:active,
.tool-btn:active,
.primary-btn:active,
.soft-btn:active,
.ai-generate-btn:active,
.ai-lesson-btn:active{
  transform:translateY(1px) scale(.985);
}

/* ======================================================
   TOP MODES
====================================================== */

.mode-strip{
  display:flex;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x proximity;
  padding:2px 2px 6px;
  min-height:54px;
}

.mode-strip::-webkit-scrollbar,
.tooldock::-webkit-scrollbar,
.color-row::-webkit-scrollbar,
.chip-row::-webkit-scrollbar{
  display:none;
}

.mode-chip{
  min-width:126px;
  min-height:44px;
  flex:0 0 auto;
  border-radius:999px;
  background:rgba(255,255,255,.80);
  box-shadow:var(--soft);
  font-size:14px;
  font-weight:1000;
  padding:0 16px;
  scroll-snap-align:start;
}

.mode-chip.active{
  background:linear-gradient(135deg, #fff2a8, var(--yellow));
}

/* ======================================================
   MISSION CARD
====================================================== */

.mission-card{
  min-height:76px;
  padding:12px 16px;
  border-radius:28px;
  background:rgba(255,255,255,.78);
  box-shadow:var(--soft);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  overflow:hidden;
}

.mission-left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.mission-badge{
  width:56px;
  height:56px;
  flex:0 0 56px;
  border-radius:21px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg, var(--pink), var(--yellow));
  box-shadow:var(--soft);
  font-size:28px;
}

.mission-copy{
  min-width:0;
}

.mission-copy h2{
  margin:0;
  font-size:clamp(20px, 2.4vw, 28px);
  line-height:1.05;
  font-weight:1000;
}

.mission-copy p{
  margin:5px 0 0;
  color:var(--muted);
  font-size:clamp(12px, 1.5vw, 16px);
  line-height:1.2;
  font-weight:850;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.stars{
  font-size:26px;
  color:#f0a800;
  font-weight:1000;
  white-space:nowrap;
}

/* ======================================================
   CANVAS
====================================================== */

.stage-card{
  min-height:0;
  border-radius:30px;
  background:rgba(255,255,255,.72);
  box-shadow:var(--shadow);
  padding:10px;
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
}

.canvas-status{
  display:flex;
  justify-content:space-between;
  gap:8px;
  padding:0 5px 9px;
  font-size:13px;
  color:var(--muted);
  font-weight:1000;
}

.canvas-status span{
  max-width:48%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  padding:8px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.84);
  border:2px solid rgba(255,255,255,.95);
}

.canvas-wrap{
  min-height:0;
  position:relative;
  overflow:hidden;
  border-radius:24px;
  background:#fff;
  border:4px solid rgba(255,255,255,.96);
  touch-action:none;
}

#drawingCanvas{
  display:block;
  width:100%;
  height:100%;
  touch-action:none;
}

/* ======================================================
   STEPS
====================================================== */

.step-console{
  min-height:82px;
  padding:10px;
  border-radius:25px;
  background:rgba(255,255,255,.86);
  box-shadow:var(--soft);
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  grid-template-areas:
    "meter meter meter"
    "copy score actions";
  gap:8px;
  align-items:center;
}

.step-meter{
  grid-area:meter;
  height:9px;
  background:var(--line);
  overflow:hidden;
  border-radius:999px;
}

.step-progress{
  width:0;
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg, var(--pink), var(--yellow));
}

.step-copy{
  grid-area:copy;
  min-width:0;
}

.step-copy strong{
  font-size:17px;
  font-weight:1000;
}

.step-copy p{
  margin:2px 0 0;
  color:var(--muted);
  font-size:13px;
  font-weight:850;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.step-score{
  grid-area:score;
  border-radius:17px;
  background:#fff4e2;
  padding:10px 13px;
  color:var(--muted);
  font-weight:1000;
  white-space:nowrap;
}

.step-actions{
  grid-area:actions;
  display:flex;
  gap:8px;
}

/* ======================================================
   PALETTE
====================================================== */

.palette-card{
  min-height:70px;
  padding:8px 10px 10px;
  border-radius:24px;
  background:rgba(255,255,255,.78);
  box-shadow:var(--soft);
}

.section-title{
  margin-bottom:7px;
  color:var(--muted);
  font-size:12px;
  letter-spacing:.06em;
  text-transform:uppercase;
  font-weight:1000;
}

.color-row{
  display:grid;
  grid-template-columns:repeat(10, minmax(36px, 1fr));
  gap:8px;
}

.color-dot{
  height:38px;
  min-width:36px;
  border-radius:14px;
  border:3px solid rgba(255,255,255,.98);
  box-shadow:0 5px 14px rgba(58,46,42,.14);
  position:relative;
}

.color-dot.active::after{
  content:"✓";
  position:absolute;
  inset:-6px;
  border:3px solid var(--text);
  border-radius:18px;
  color:#fff;
  text-shadow:0 1px 5px rgba(0,0,0,.45);
  font-size:20px;
  font-weight:1000;
  display:grid;
  place-items:center;
}

/* ======================================================
   BOTTOM DOCK
====================================================== */

.tooldock{
  position:fixed;
  z-index:80;
  left:50%;
  bottom:var(--safe-bottom);
  transform:translateX(-50%);
  width:min(1220px, calc(100vw - 16px));
  height:var(--dock-h);
  padding:8px;
  border-radius:30px;
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(18px);
  box-shadow:0 20px 60px rgba(68,42,28,.22);
  display:flex;
  gap:6px;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x proximity;
}

.tool-btn{
  flex:0 0 70px;
  min-width:0;
  padding:6px 3px;
  border-radius:20px;
  background:transparent;
  display:grid;
  gap:2px;
  place-items:center;
  scroll-snap-align:start;
  font-weight:1000;
}

.tool-btn span{
  font-size:22px;
  line-height:1;
}

.tool-btn small{
  color:var(--muted);
  font-size:9px;
  line-height:1.1;
  white-space:nowrap;
  font-weight:1000;
}

.tool-btn.active{
  background:linear-gradient(135deg, #fff2a8, var(--yellow));
}

.tool-btn.danger{
  color:#8f241c;
}

/* ======================================================
   MODAL WINDOWS — DECISIÓN FINAL: FULLSCREEN OVERLAY
====================================================== */

html.sheet-open,
body.sheet-open{
  overflow:hidden !important;
}

body.sheet-open .tooldock,
.tooldock.dock-hidden{
  display:none !important;
}

body.sheet-open .app-shell{
  filter:blur(5px) saturate(.86);
  pointer-events:none;
}

.sheet-backdrop{
  position:fixed;
  inset:0;
  z-index:900;
  background:rgba(58,46,42,.30);
  backdrop-filter:blur(7px);
}

.bottom-sheet{
  position:fixed;
  z-index:1000;
  left:50%;
  top:max(16px, env(safe-area-inset-top));
  bottom:max(16px, env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(1180px, calc(100vw - 30px));
  max-width:calc(100vw - 30px);
  height:auto;
  max-height:none;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
  border-radius:30px;
  padding:16px 18px 32px;
  background:var(--paper);
  box-shadow:0 30px 95px rgba(58,46,42,.38);
}

.bottom-sheet.tall{
  top:max(12px, env(safe-area-inset-top));
  bottom:max(12px, env(safe-area-inset-bottom));
}

.bottom-sheet::after{
  content:"";
  display:block;
  height:54px;
}

.sheet-close{
  position:sticky;
  top:8px;
  float:right;
  z-index:20;
  width:42px;
  height:42px;
  border-radius:16px;
  background:#fff4e2;
  box-shadow:var(--soft);
  display:grid;
  place-items:center;
  font-size:28px;
  line-height:1;
  font-weight:1000;
}

.sheet-handle{
  position:sticky;
  top:0;
  z-index:15;
  width:58px;
  height:7px;
  border-radius:999px;
  margin:0 auto 12px;
  background:#e8dacf;
}

.bottom-sheet > h2,
.sheet-head{
  position:sticky;
  top:0;
  z-index:12;
  padding:8px 54px 12px 0;
  margin:0 0 12px;
  background:linear-gradient(180deg, var(--paper) 80%, rgba(255,253,248,.92));
}

.bottom-sheet h2{
  font-size:clamp(24px, 3vw, 34px);
  line-height:1.05;
}

.sheet-subtitle,
.ai-note{
  color:var(--muted);
  font-size:14px;
  line-height:1.35;
  font-weight:850;
}

.sheet-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}

.sheet-head h2{
  margin:0;
}

.sheet-head .sheet-subtitle{
  margin:6px 0 0;
}

.bottom-sheet::-webkit-scrollbar{
  width:10px;
}

.bottom-sheet::-webkit-scrollbar-track{
  border-radius:999px;
  background:rgba(240,228,216,.45);
}

.bottom-sheet::-webkit-scrollbar-thumb{
  border:3px solid var(--paper);
  border-radius:999px;
  background:rgba(138,122,114,.66);
}

/* ======================================================
   CARDS / GRIDS
====================================================== */

.welcome-hero{
  text-align:center;
}

.welcome-icon{
  font-size:50px;
}

.welcome-hero p{
  max-width:560px;
  margin:8px auto 16px;
  color:var(--muted);
  font-weight:850;
}

.home-grid,
.lesson-grid,
.template-grid,
.pack-grid,
.gallery-grid,
.reward-grid,
.next-actions,
.mission-list{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
  align-items:stretch;
  padding-bottom:20px;
}

.home-card,
.lesson-card,
.template-card,
.option-btn,
.pack-card,
.gallery-card,
.reward-card,
.next-card,
.mission-task-card{
  min-height:108px;
  border-radius:24px;
  padding:13px;
  text-align:left;
  background:linear-gradient(135deg,#fff,#fff4e4);
  border:3px solid rgba(255,255,255,.88);
  box-shadow:var(--soft);
  font-weight:1000;
}

.home-card span,
.lesson-card .emoji,
.template-card span,
.pack-card .emoji,
.reward-card .emoji,
.next-card .emoji,
.mission-task-card .emoji{
  display:block;
  font-size:34px;
}

.home-card small,
.lesson-card small,
.pack-card small,
.gallery-card small,
.reward-card small,
.next-card small,
.mission-task-card small{
  display:block;
  margin-top:5px;
  color:var(--muted);
  font-size:13px;
  line-height:1.25;
  font-weight:850;
}

.template-card{
  text-align:center;
  display:grid;
  place-items:center;
}

.pack-card{
  min-height:145px;
}

.pack-card.locked,
.reward-card.locked{
  filter:grayscale(.58);
  opacity:.70;
}

.pack-card.locked::after{
  content:"🔒";
  position:absolute;
}

.pack-items{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  margin-top:10px;
}

.pack-pill{
  padding:5px 8px;
  border-radius:999px;
  background:rgba(255,255,255,.78);
  color:var(--muted);
  font-size:11px;
  font-weight:950;
}

.gallery-card img{
  width:100%;
  height:120px;
  display:block;
  object-fit:cover;
  background:#fff;
  border-radius:18px;
}

.gallery-card strong{
  display:block;
  margin-top:8px;
}

.reward-card.claimed{
  background:linear-gradient(135deg,#fff2a8,var(--yellow));
}

.option-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(170px,1fr));
  gap:12px;
}

.option-btn{
  text-align:center;
  display:grid;
  place-items:center;
}

.option-btn.active{
  border-color:var(--pink);
  background:#fff0f6;
}

.chip-row{
  display:flex;
  gap:8px;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  padding:0 0 12px;
}

.chip{
  flex:0 0 auto;
  padding:10px 15px;
  border-radius:999px;
  background:#fff4e2;
  box-shadow:var(--soft);
  font-weight:1000;
}

.chip.active{
  background:var(--yellow);
}

/* ======================================================
   MISSIONS / REWARDS / PROFILE
====================================================== */

.mission-daily-card{
  margin:10px 0 14px;
  padding:16px;
  border-radius:26px;
  background:linear-gradient(135deg,#fff2a8,var(--yellow));
  box-shadow:var(--soft);
  font-weight:1000;
}

.mission-daily-card strong{
  display:block;
  font-size:20px;
}

.mission-daily-card small{
  display:block;
  margin-top:5px;
  color:var(--muted);
  font-weight:900;
}

.mission-task-card.done{
  border-color:var(--green);
  background:linear-gradient(135deg,#efffea,#fff);
}

.mission-progress-line{
  height:9px;
  overflow:hidden;
  border-radius:999px;
  background:var(--line);
  margin-top:10px;
}

.mission-progress-line span{
  display:block;
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg,var(--pink),var(--yellow));
}

.pro-stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
  gap:12px;
  margin:12px 0;
}

.pro-stat-card{
  border-radius:22px;
  padding:15px;
  background:linear-gradient(135deg,#fff,#fff4e4);
  box-shadow:var(--soft);
  border:3px solid rgba(255,255,255,.86);
}

.pro-stat-card strong{
  display:block;
  font-size:27px;
  line-height:1;
}

.pro-stat-card small{
  display:block;
  margin-top:6px;
  color:var(--muted);
  font-weight:900;
}

.mini-heading{
  margin:18px 0 10px;
  font-size:17px;
}

.profile-card{
  padding:16px;
  border-radius:24px;
  background:linear-gradient(135deg,#fff,#fff4e4);
  box-shadow:var(--soft);
  font-weight:900;
}

.profile-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:11px 0;
  border-bottom:1px solid var(--line);
}

.profile-row:last-child{
  border-bottom:0;
}

/* ======================================================
   AI / PARENT FORMS
====================================================== */

.ai-label{
  display:block;
  margin:13px 0 7px;
  color:var(--muted);
  font-size:12px;
  letter-spacing:.06em;
  text-transform:uppercase;
  font-weight:1000;
}

.ai-input-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) 58px;
  gap:9px;
}

.ai-input,
.ai-select{
  width:100%;
  min-height:58px;
  padding:0 16px;
  border-radius:21px;
  border:3px solid var(--line);
  outline:none;
  background:#fffaf2;
  color:var(--text);
  font-weight:950;
  user-select:text;
}

.ai-random-btn{
  min-height:58px;
  border-radius:21px;
  background:#fff2a8;
  box-shadow:var(--soft);
  font-size:24px;
}

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

.ai-levels{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
}

.ai-level{
  min-height:58px;
  border-radius:20px;
  background:#fff4e2;
  box-shadow:var(--soft);
  border:3px solid transparent;
  font-weight:1000;
}

.ai-level.active{
  border-color:var(--pink);
  background:#fff0f6;
}

.ai-action-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-top:16px;
  margin-bottom:18px;
}

.ai-generate-btn,
.ai-lesson-btn,
.primary-btn,
.soft-btn,
.primary-small{
  min-height:54px;
  border-radius:21px;
  box-shadow:var(--soft);
  font-weight:1000;
}

.ai-generate-btn,
.primary-btn,
.primary-small{
  background:linear-gradient(135deg,var(--pink),var(--yellow));
}

.ai-lesson-btn{
  background:linear-gradient(135deg,var(--blue),var(--purple));
}

.soft-btn{
  background:#f2ece6;
}

.primary-small{
  min-height:44px;
  padding:0 15px;
}

.full{
  width:100%;
}

.parent-settings-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin:14px 0 18px;
}

.parent-setting{
  display:grid;
  gap:8px;
  padding:13px;
  border-radius:22px;
  background:#fffaf2;
  box-shadow:var(--soft);
  font-weight:1000;
}

.parent-setting span{
  color:var(--muted);
  font-size:12px;
  letter-spacing:.06em;
  text-transform:uppercase;
}

.export-box{
  max-height:260px;
  margin-top:12px;
  padding:13px;
  overflow:auto;
  border-radius:18px;
  background:#2b2522;
  color:#fff;
  white-space:pre-wrap;
  user-select:text;
  font-size:12px;
}

/* ======================================================
   DIALOGS
====================================================== */

.confirm-dialog,
.reward-dialog{
  width:min(370px, calc(100vw - 32px));
  border:0;
  padding:0;
  border-radius:30px;
  background:var(--paper);
  box-shadow:0 30px 90px rgba(58,46,42,.36);
}

.confirm-dialog::backdrop,
.reward-dialog::backdrop{
  background:rgba(58,46,42,.36);
  backdrop-filter:blur(5px);
}

.confirm-dialog form,
.reward-dialog form{
  padding:24px;
  text-align:center;
}

.dialog-emoji,
.reward-burst{
  font-size:52px;
}

.dialog-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.dialog-btn{
  min-height:52px;
  border-radius:18px;
  background:#eef8ff;
  font-weight:1000;
}

.dialog-btn.danger{
  background:#ffe1df;
  color:#8a201b;
}

.reward-stars{
  margin:12px 0 16px;
  color:#f0a800;
  font-size:30px;
}

/* ======================================================
   RESPONSIVE
====================================================== */

@media(max-width:860px){
  :root{
    --dock-h:88px;
  }

  .app-shell{
    padding-inline:10px;
    gap:8px;
  }

  .hero-actions{
    max-width:58%;
    gap:6px;
  }

  .round-btn{
    width:44px;
    height:44px;
    border-radius:17px;
    font-size:20px;
  }

  .mode-chip{
    min-width:112px;
    min-height:40px;
    font-size:12px;
    padding:0 12px;
  }

  .mission-card{
    min-height:66px;
    padding:10px 12px;
  }

  .mission-badge{
    width:48px;
    height:48px;
    flex-basis:48px;
    border-radius:18px;
    font-size:24px;
  }

  .mission-copy p{
    display:none;
  }

  .color-row{
    display:flex;
    overflow-x:auto;
    gap:7px;
  }

  .color-dot{
    flex:0 0 42px;
  }

  .tooldock{
    width:calc(100vw - 14px);
    padding:7px;
    gap:5px;
    border-radius:26px;
  }

  .tool-btn{
    flex-basis:64px;
  }

  .tool-btn span{
    font-size:20px;
  }

  .tool-btn small{
    font-size:8.5px;
  }

  .bottom-sheet,
  .bottom-sheet.tall{
    left:8px;
    right:8px;
    top:max(8px, env(safe-area-inset-top));
    bottom:max(8px, env(safe-area-inset-bottom));
    transform:none;
    width:auto;
    max-width:none;
    border-radius:24px;
    padding:12px 12px 26px;
  }

  .bottom-sheet > h2,
  .sheet-head{
    padding-right:48px;
  }

  .home-grid,
  .lesson-grid,
  .template-grid,
  .pack-grid,
  .gallery-grid,
  .reward-grid,
  .next-actions,
  .mission-list{
    grid-template-columns:repeat(auto-fit, minmax(150px, 1fr));
    gap:10px;
  }

  .home-card,
  .lesson-card,
  .template-card,
  .pack-card,
  .gallery-card,
  .reward-card,
  .next-card,
  .mission-task-card{
    min-height:100px;
  }

  .two-cols,
  .ai-action-grid,
  .parent-settings-grid{
    grid-template-columns:1fr;
  }

  .step-console{
    grid-template-columns:1fr;
    grid-template-areas:
      "meter"
      "copy"
      "score"
      "actions";
  }

  .step-actions{
    width:100%;
  }

  .step-actions button{
    flex:1;
  }
}

@media(max-height:760px){
  :root{
    --dock-h:80px;
  }

  .brand-title{
    font-size:36px;
  }

  .mode-strip{
    min-height:45px;
  }

  .mode-chip{
    min-height:38px;
  }

  .mission-card{
    min-height:58px;
  }

  .mission-badge{
    width:44px;
    height:44px;
    flex-basis:44px;
  }

  .palette-card{
    min-height:60px;
    padding:6px 8px 8px;
  }

  .color-dot{
    height:32px;
  }

  .tooldock{
    height:var(--dock-h);
  }

  .tool-btn{
    flex-basis:60px;
  }
}


/* ======================================================
   BLOQUE 4 — BIBLIOTECA IA
====================================================== */

.ai-library-panel{
  margin-top:18px;
  padding-top:14px;
  border-top:2px solid var(--line);
}

.ai-library-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.ai-library-head h3{
  margin:0;
  font-size:20px;
}

.ai-library-head .sheet-subtitle{
  margin:4px 0 0;
}

.ai-library-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(190px, 1fr));
  gap:12px;
  margin-top:10px;
}

.ai-creation-card{
  min-height:132px;
  padding:12px;
  border-radius:24px;
  background:linear-gradient(135deg,#fff,#fff4e4);
  border:3px solid rgba(255,255,255,.88);
  box-shadow:var(--soft);
  text-align:left;
  font-weight:1000;
  display:grid;
  gap:8px;
}

.ai-creation-preview{
  height:92px;
  border-radius:18px;
  background:#fff;
  border:2px solid rgba(240,228,216,.85);
  display:grid;
  place-items:center;
  overflow:hidden;
}

.ai-creation-preview img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.ai-creation-preview .ai-creation-emoji{
  font-size:42px;
}

.ai-creation-meta{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:12px;
  font-weight:900;
}

.ai-creation-actions{
  display:grid;
  grid-template-columns:1fr auto;
  gap:7px;
}

.ai-open-btn,
.ai-delete-btn{
  min-height:38px;
  border-radius:15px;
  font-weight:1000;
  box-shadow:var(--soft);
}

.ai-open-btn{
  background:linear-gradient(135deg,var(--blue),var(--purple));
}

.ai-delete-btn{
  width:42px;
  background:#ffe1df;
  color:#8a201b;
}

@media(max-width:760px){
  .ai-library-head{
    display:grid;
  }

  .ai-library-grid{
    grid-template-columns:repeat(auto-fit, minmax(148px, 1fr));
  }
}


/* ======================================================
   BLOQUE 6 — UX INFANTIL PRO + PIN PADRES + IA SEGURA
====================================================== */

.backend-status{
  min-width:72px;
  height:34px;
  border-radius:999px;
  padding:0 12px;
  display:grid;
  place-items:center;
  background:rgba(255,255,255,.88);
  color:var(--muted);
  font-size:12px;
  font-weight:1000;
  box-shadow:var(--soft);
}

.backend-status.ok{
  background:#eaffea;
  color:#217a30;
}

.backend-status.warn{
  background:#fff4d7;
  color:#9b6900;
}

.backend-status.error{
  background:#ffe1df;
  color:#8a201b;
}

.ai-guard-banner{
  margin:10px 0 12px;
  padding:12px 14px;
  border-radius:22px;
  background:linear-gradient(135deg,#fff2a8,#fff);
  box-shadow:var(--soft);
  color:var(--text);
  font-weight:1000;
  line-height:1.25;
}

.ai-guard-banner.blocked{
  background:linear-gradient(135deg,#ffe1df,#fff);
  color:#8a201b;
}

.ai-guard-banner.ready{
  background:linear-gradient(135deg,#eaffea,#fff);
  color:#217a30;
}

.ai-generate-btn.blocked,
.ai-lesson-btn.blocked{
  filter:grayscale(.5);
  opacity:.62;
}

.toast-stack{
  position:fixed;
  z-index:12000;
  left:50%;
  bottom:max(18px, env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(520px, calc(100vw - 26px));
  display:grid;
  gap:10px;
  pointer-events:none;
}

.toast{
  padding:13px 15px;
  border-radius:22px;
  background:rgba(255,255,255,.96);
  box-shadow:0 18px 54px rgba(58,46,42,.22);
  border:3px solid rgba(255,255,255,.92);
  color:var(--text);
  font-weight:1000;
  line-height:1.25;
  animation:toastIn .22s ease-out;
}

.toast.good{
  background:#eaffea;
}

.toast.warn{
  background:#fff4d7;
}

.toast.error{
  background:#ffe1df;
}

@keyframes toastIn{
  from{ opacity:0; transform:translateY(12px) scale(.98); }
  to{ opacity:1; transform:translateY(0) scale(1); }
}

.pin-dialog{
  width:min(390px, calc(100vw - 32px));
  border:0;
  padding:0;
  border-radius:30px;
  background:var(--paper);
  box-shadow:0 30px 90px rgba(58,46,42,.36);
}

.pin-dialog::backdrop{
  background:rgba(58,46,42,.38);
  backdrop-filter:blur(6px);
}

.pin-form{
  padding:24px;
  text-align:center;
}

.pin-input{
  width:100%;
  min-height:58px;
  margin:12px 0;
  border-radius:22px;
  border:3px solid var(--line);
  background:#fffaf2;
  color:var(--text);
  text-align:center;
  font-size:28px;
  letter-spacing:.12em;
  font-weight:1000;
  outline:none;
  user-select:text;
}

.pin-note{
  margin:10px 0 0;
  color:var(--muted);
  font-size:12px;
  font-weight:850;
}

@media(max-width:760px){
  .backend-status{
    min-width:58px;
    height:32px;
    font-size:10px;
    padding:0 8px;
  }

  .toast-stack{
    bottom:max(10px, env(safe-area-inset-bottom));
  }
}


/* ======================================================
   BLOQUE 7 — PINCELES PRO + PLANTILLAS GRANDES
====================================================== */

.brush-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(185px, 1fr));
  gap:12px;
  margin-top:12px;
}

.brush-option{
  min-height:124px;
  padding:14px;
  border-radius:24px;
  text-align:left;
  background:linear-gradient(135deg,#fff,#fff4e4);
  border:3px solid rgba(255,255,255,.88);
  box-shadow:var(--soft);
  display:grid;
  gap:7px;
  font-weight:1000;
}

.brush-option.active{
  border-color:var(--pink);
  background:linear-gradient(135deg,#fff0f6,#fff);
}

.brush-option span{
  display:block;
  font-size:32px;
}

.brush-option small{
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
  font-weight:850;
}

.brush-preview{
  height:12px;
  border-radius:999px;
  background:#222;
}

.brush-preview.crayon{
  background:repeating-linear-gradient(90deg,#ff4d6d 0 8px,#ff8fb1 8px 14px);
}

.brush-preview.marker{
  background:linear-gradient(90deg,#2f80ed,#8bd3ff);
}

.brush-preview.watercolor{
  height:18px;
  filter:blur(.4px);
  background:linear-gradient(90deg,rgba(155,93,229,.25),rgba(255,143,177,.55),rgba(255,209,102,.28));
}

.brush-preview.shade{
  height:22px;
  background:radial-gradient(circle,rgba(0,0,0,.35),rgba(0,0,0,.04));
}

.brush-preview.airbrush{
  height:22px;
  background:radial-gradient(circle,rgba(47,128,237,.45),rgba(47,128,237,.02));
}

.brush-preview.glitter{
  height:16px;
  background:
    radial-gradient(circle at 12% 50%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 38% 42%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 70% 55%, #fff 0 2px, transparent 3px),
    linear-gradient(90deg,#9b5de5,#ffd166,#ff8fb1);
}

.template-card{
  min-height:126px;
  font-size:15px;
}

.template-card span{
  font-size:42px;
}

.template-card::after{
  content:"PRO";
  display:inline-grid;
  place-items:center;
  min-width:38px;
  height:21px;
  border-radius:999px;
  margin-top:6px;
  background:#fff2a8;
  color:#7a4a00;
  font-size:10px;
  font-weight:1000;
}

@media(max-width:760px){
  .brush-grid{
    grid-template-columns:repeat(auto-fit, minmax(145px, 1fr));
  }

  .brush-option{
    min-height:112px;
  }
}


/* ======================================================
   BLOQUE 8 — ACADEMIA GUIADA PRO
====================================================== */

.academy-console{
  min-height:132px;
  grid-template-columns:minmax(0,1fr) auto;
  grid-template-areas:
    "meter meter"
    "topline score"
    "copy score"
    "coach actions";
  align-items:stretch;
}

.academy-topline{
  grid-area:topline;
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
  min-width:0;
}

.academy-topline span{
  display:inline-flex;
  align-items:center;
  min-height:28px;
  padding:5px 10px;
  border-radius:999px;
  background:#fff4e2;
  color:var(--muted);
  font-size:12px;
  font-weight:1000;
  white-space:nowrap;
}

.academy-coach{
  grid-area:coach;
  min-height:42px;
  padding:10px 12px;
  border-radius:18px;
  background:linear-gradient(135deg,#fff2a8,#fff);
  color:#6b4d00;
  font-size:13px;
  line-height:1.25;
  font-weight:950;
  display:flex;
  align-items:center;
}

.academy-console .step-score{
  align-self:center;
}

.academy-console .step-actions{
  align-self:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.academy-console .step-actions button{
  min-height:44px;
  padding:0 12px;
}

#quickColorBtn{
  background:linear-gradient(135deg,var(--blue),var(--purple));
}

.lesson-card.done{
  border-color:var(--green);
  background:linear-gradient(135deg,#efffea,#fff);
}

.lesson-card .lesson-badge-line{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  margin-top:7px;
}

.lesson-pill{
  display:inline-flex;
  align-items:center;
  min-height:20px;
  padding:3px 7px;
  border-radius:999px;
  background:rgba(255,255,255,.76);
  color:var(--muted);
  font-size:10px;
  font-weight:1000;
}

@media(max-width:860px){
  .academy-console{
    grid-template-columns:1fr;
    grid-template-areas:
      "meter"
      "topline"
      "copy"
      "coach"
      "score"
      "actions";
  }

  .academy-console .step-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    width:100%;
  }

  .academy-console .step-actions #nextStepBtn{
    grid-column:1 / -1;
  }
}


/* ======================================================
   BLOQUE 9 — SESIONES + AUTOSAVE + COLOR PRO
====================================================== */

.continue-access{
  background:linear-gradient(135deg,#eaffea,#fff);
}

.canvas-status{
  align-items:center;
}

.canvas-status span{
  max-width:33%;
}

.autosave-status{
  color:#3f7b2b !important;
  background:#eaffea !important;
}

.autosave-status.saving{
  color:#8a6500 !important;
  background:#fff4d7 !important;
}

.autosave-status.error{
  color:#8a201b !important;
  background:#ffe1df !important;
}

.palette-card{
  min-height:76px;
}

.color-row{
  display:flex !important;
  grid-template-columns:none !important;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  padding:2px 3px 9px;
  scroll-snap-type:x proximity;
  -webkit-overflow-scrolling:touch;
}

.color-row::-webkit-scrollbar{
  height:6px;
  display:block;
}

.color-row::-webkit-scrollbar-thumb{
  background:rgba(58,46,42,.18);
  border-radius:999px;
}

.color-dot{
  flex:0 0 43px;
  width:43px;
  height:40px;
  scroll-snap-align:start;
}

.color-dot[data-color="#ffffff"],
.color-dot[data-color="#fff7ec"],
.color-dot[data-color="#f7fbff"]{
  box-shadow:inset 0 0 0 1px rgba(58,46,42,.14), 0 5px 14px rgba(58,46,42,.12);
}

.session-current-card{
  margin:12px 0;
  padding:16px;
  border-radius:24px;
  background:linear-gradient(135deg,#fff,#fff4e4);
  box-shadow:var(--soft);
  display:grid;
  gap:8px;
}

.session-current-card strong{
  font-size:18px;
}

.session-current-card p{
  margin:0;
  color:var(--muted);
  font-weight:900;
  line-height:1.35;
}

.session-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:4px;
}

.mini-section-title{
  margin:18px 0 10px;
  font-size:18px;
}

.session-history-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
}

.session-card{
  min-height:150px;
  padding:12px;
  border-radius:22px;
  background:rgba(255,255,255,.88);
  box-shadow:var(--soft);
  text-align:left;
  display:grid;
  gap:6px;
}

.session-card img{
  width:100%;
  height:92px;
  object-fit:cover;
  border-radius:16px;
  background:#fff;
  border:2px solid rgba(255,255,255,.95);
}

.session-card strong{
  font-size:15px;
}

.session-card small{
  color:var(--muted);
  font-weight:900;
}

.session-card .session-card-actions{
  display:flex;
  gap:6px;
  margin-top:4px;
}

.session-card .session-card-actions button{
  min-height:34px;
  padding:0 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:1000;
  background:#fff4e2;
}

.session-card .session-card-actions button.danger{
  background:#ffe1df;
}

.continue-card{
  background:linear-gradient(135deg,#eaffea,#fff);
}

@media(min-width:1100px){
  .app-shell{
    max-width:1400px;
    gap:8px;
    grid-template-rows:auto auto auto minmax(0, 1.4fr) auto auto;
  }

  .stage-card{
    min-height:min(58vh, 720px);
  }

  .canvas-wrap{
    min-height:clamp(420px, 51vh, 680px);
  }
}

@media(max-width:760px){
  .canvas-status span{
    max-width:50%;
  }

  .autosave-status{
    display:none;
  }

  .color-dot{
    flex-basis:40px;
    width:40px;
    height:38px;
  }
}


/* ======================================================
   BLOQUE 9.1 — HOTFIX LAYOUT + COLOR EN PANEL
   Corrige:
   - botones superiores desplazados a la derecha
   - lienzo cortado
   - paleta demasiado larga en una sola línea
====================================================== */

html,
body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

.app-shell{
  width:min(100%, 1380px);
  max-width:1380px;
  height:100dvh;
  overflow:hidden;
  padding-left:clamp(8px, 1.2vw, 16px);
  padding-right:clamp(8px, 1.2vw, 16px);
  grid-template-rows:auto auto auto minmax(0, 1fr) auto auto !important;
}

.hero-top{
  display:grid !important;
  grid-template-columns:minmax(150px, auto) minmax(0, 1fr);
  align-items:start;
  gap:10px;
  min-width:0;
}

.hero-actions{
  min-width:0;
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
  max-width:100%;
}

.round-btn{
  width:clamp(42px, 4.1vw, 56px);
  height:clamp(42px, 4.1vw, 56px);
  min-width:clamp(42px, 4.1vw, 56px);
  flex:0 0 auto;
}

.backend-status{
  min-height:36px;
  padding:0 12px;
  flex:0 0 auto;
}

.brand-title{
  font-size:clamp(34px, 4.6vw, 58px);
  line-height:.9;
}

.eyebrow{
  font-size:clamp(10px, 1vw, 13px);
}

.mode-strip{
  max-width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom:2px;
}

.mode-chip{
  min-width:auto;
  flex:1 0 118px;
  max-width:165px;
}

.stage-card{
  min-height:0 !important;
  max-width:100%;
  overflow:hidden;
  padding:10px;
}

.canvas-status{
  display:grid !important;
  grid-template-columns:auto minmax(0, 1fr) auto;
  align-items:center;
  gap:8px;
}

.canvas-status span{
  max-width:none !important;
}

#activeTemplate{
  text-align:right;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.canvas-wrap{
  width:100%;
  max-width:100%;
  min-height:clamp(320px, 46vh, 610px) !important;
  height:100%;
  overflow:hidden;
  box-sizing:border-box;
}

#drawingCanvas{
  width:100% !important;
  height:100% !important;
}

.compact-palette{
  min-height:58px !important;
  padding:7px !important;
  display:flex;
  align-items:center;
}

.palette-open-btn{
  width:100%;
  min-height:48px;
  border-radius:20px;
  padding:6px 12px;
  background:rgba(255,255,255,.86);
  box-shadow:var(--soft);
  display:grid;
  grid-template-columns:auto auto minmax(0, 1fr);
  align-items:center;
  gap:10px;
  text-align:left;
}

.palette-open-btn strong{
  font-size:17px;
}

.palette-open-btn small{
  color:var(--muted);
  font-weight:1000;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.selected-color-preview,
.selected-color-large{
  width:34px;
  height:34px;
  border-radius:13px;
  border:3px solid #fff;
  box-shadow:0 5px 14px rgba(58,46,42,.18), inset 0 0 0 1px rgba(58,46,42,.08);
  background:var(--current-color, #ff4d6d);
}

.selected-color-large{
  width:52px;
  height:52px;
  border-radius:18px;
  flex:0 0 auto;
}

.color-sheet{
  max-height:min(72vh, 620px);
}

.color-groups{
  display:grid;
  gap:14px;
  margin-top:12px;
  padding-bottom:10px;
}

.color-group{
  display:grid;
  gap:9px;
}

.color-group-title{
  color:var(--muted);
  font-size:12px;
  font-weight:1000;
  letter-spacing:.06em;
  text-transform:uppercase;
  padding-left:4px;
}

.color-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(42px, 1fr));
  gap:9px;
}

.color-grid .color-dot{
  width:100%;
  min-width:42px;
  height:42px;
  flex:initial;
}

.color-row{
  display:none !important;
}

.tooldock{
  left:50%;
  transform:translateX(-50%);
  width:min(100% - 20px, 1320px);
  max-width:1320px;
  overflow-x:auto;
  overflow-y:hidden;
  justify-content:flex-start;
  padding:8px;
}

.tool-btn{
  flex:0 0 clamp(64px, 7.1vw, 92px);
  min-width:clamp(64px, 7.1vw, 92px);
}

.bottom-sheet{
  width:min(100% - 20px, 1180px);
  max-width:1180px;
  left:50%;
  transform:translateX(-50%);
  max-height:calc(100dvh - 86px);
  overflow:auto;
}

@media(min-width:1100px){
  .stage-card{
    min-height:0 !important;
  }

  .canvas-wrap{
    min-height:clamp(360px, 49vh, 640px) !important;
  }
}

@media(max-width:900px){
  .app-shell{
    gap:8px;
  }

  .hero-top{
    grid-template-columns:1fr;
  }

  .hero-actions{
    justify-content:flex-start;
  }

  .brand-lockup{
    max-width:100%;
  }

  .mode-chip{
    flex:0 0 auto;
  }

  .canvas-wrap{
    min-height:clamp(300px, 43vh, 540px) !important;
  }

  .canvas-status{
    grid-template-columns:1fr auto;
  }

  .autosave-status{
    display:none !important;
  }
}

@media(max-height:780px){
  .app-shell{
    gap:7px;
  }

  .mission-card{
    min-height:64px;
    padding:10px 14px;
  }

  .mission-copy h2{
    font-size:clamp(20px, 2.4vw, 31px);
  }

  .mission-copy p{
    font-size:13px;
  }

  .canvas-wrap{
    min-height:clamp(275px, 41vh, 500px) !important;
  }

  .step-console{
    min-height:96px;
  }

  .compact-palette{
    min-height:52px !important;
  }

  .tooldock{
    min-height:74px;
  }
}


/* ======================================================
   BLOQUE 9.2 — HOTFIX MENÚ INFERIOR
====================================================== */

body{
  overscroll-behavior-x:none;
}

.app-shell{
  padding-bottom:clamp(92px, 10vh, 118px);
}

/* Escritorio: todos los botones encajan en una sola barra completa */
@media(min-width:1050px){
  .tooldock{
    display:grid !important;
    grid-template-columns:repeat(16, minmax(54px, 1fr));
    gap:5px;
    width:min(calc(100vw - 34px), 1500px) !important;
    max-width:1500px !important;
    left:50% !important;
    right:auto !important;
    transform:translateX(-50%) !important;
    overflow:visible !important;
    padding:8px 10px !important;
    min-height:86px !important;
    box-sizing:border-box;
  }

  .tool-btn{
    min-width:0 !important;
    width:auto !important;
    flex:initial !important;
    padding:7px 3px !important;
    border-radius:18px !important;
    gap:3px !important;
  }

  .tool-btn span{
    font-size:clamp(20px, 1.35vw, 26px) !important;
    line-height:1;
  }

  .tool-btn small{
    font-size:clamp(9px, .72vw, 11px) !important;
    line-height:1.05;
    max-width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .tool-btn.active{
    transform:none !important;
  }
}

/* Tablet/móvil: scroll horizontal limpio */
@media(max-width:1049px){
  .tooldock{
    display:flex !important;
    width:calc(100vw - 18px) !important;
    max-width:calc(100vw - 18px) !important;
    left:9px !important;
    right:9px !important;
    transform:none !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
    justify-content:flex-start !important;
    scroll-snap-type:x proximity;
    padding:8px !important;
  }

  .tooldock::-webkit-scrollbar{
    height:6px;
    display:block;
  }

  .tooldock::-webkit-scrollbar-thumb{
    background:rgba(58,46,42,.20);
    border-radius:999px;
  }

  .tool-btn{
    flex:0 0 76px !important;
    min-width:76px !important;
    scroll-snap-align:start;
  }
}

/* Pantallas bajas: barra más compacta */
@media(max-height:760px) and (min-width:1050px){
  .app-shell{
    padding-bottom:88px;
  }

  .tooldock{
    min-height:74px !important;
    padding:6px 8px !important;
  }

  .tool-btn{
    padding:5px 2px !important;
    border-radius:16px !important;
  }

  .tool-btn span{
    font-size:20px !important;
  }

  .tool-btn small{
    font-size:9px !important;
  }
}

.bottom-sheet{
  padding-bottom:calc(18px + env(safe-area-inset-bottom));
}

dialog{
  max-width:min(92vw, 560px);
}


/* ======================================================
   BLOQUE 10 — VISIÓN / EVALUACIÓN FINAL + VALIDACIÓN PRO
====================================================== */
.assess-access{background:linear-gradient(135deg,#fff2a8,#fff);}
.assessment-sheet{max-height:min(82vh,780px);}
.assessment-hero{margin-top:12px;padding:16px;border-radius:28px;background:linear-gradient(135deg,#fff,#fff4e4);box-shadow:var(--soft);display:grid;grid-template-columns:auto minmax(0,1fr);gap:14px;align-items:center;}
.assessment-score-circle{width:86px;height:86px;border-radius:30px;display:grid;place-items:center;background:linear-gradient(135deg,#ff8fb1,#ffd166);color:#2f2a26;font-size:26px;font-weight:1000;box-shadow:0 10px 26px rgba(58,46,42,.18);}
.assessment-hero strong{display:block;font-size:22px;}
.assessment-hero p{margin:5px 0 0;color:var(--muted);font-weight:900;line-height:1.35;}
.assessment-grid{margin-top:12px;display:grid;grid-template-columns:repeat(auto-fit,minmax(205px,1fr));gap:12px;}
.assessment-card{padding:14px;border-radius:24px;background:rgba(255,255,255,.9);box-shadow:var(--soft);display:grid;gap:6px;}
.assessment-card span{font-size:28px;}
.assessment-card strong{font-size:16px;}
.assessment-card p{margin:0;color:var(--muted);font-weight:900;line-height:1.35;}
.assessment-history{display:grid;gap:10px;padding-bottom:8px;}
.assessment-history-item{padding:12px;border-radius:20px;background:rgba(255,255,255,.86);box-shadow:var(--soft);display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:center;}
.assessment-history-item strong{font-size:16px;}
.assessment-history-item small{color:var(--muted);font-weight:900;}
.assessment-pill{min-width:54px;height:38px;border-radius:999px;background:#fff2a8;display:grid;place-items:center;font-weight:1000;}


/* ======================================================
   BLOQUE 11 — FAMILIA REAL + SQLITE
====================================================== */

.child-badge{
  justify-self:end;
  align-self:center;
  min-height:38px;
  padding:0 14px;
  border-radius:999px;
  display:flex;
  align-items:center;
  background:linear-gradient(135deg,#eaffea,#fff);
  color:#3f7b2b;
  font-size:14px;
  font-weight:1000;
  box-shadow:var(--soft);
}

.family-panel{
  margin:14px 0;
  padding:16px;
  border-radius:28px;
  background:linear-gradient(135deg,#fff,#fff8e8);
  box-shadow:var(--soft);
  display:grid;
  gap:14px;
}

.family-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.family-head h3{
  margin:0;
  font-size:22px;
}

.family-head p{
  margin:4px 0 0;
  color:var(--muted);
  font-weight:900;
}

.family-db-pill{
  display:inline-flex;
  align-items:center;
  min-height:32px;
  padding:0 12px;
  border-radius:999px;
  background:#eaffea;
  color:#3f7b2b;
  font-weight:1000;
}

.family-active-card{
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  gap:12px;
  align-items:center;
  padding:12px;
  border-radius:24px;
  background:rgba(255,255,255,.86);
}

.family-active-card span{
  width:54px;
  height:54px;
  border-radius:18px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
  font-size:28px;
}

.family-active-card strong{
  display:block;
  font-size:20px;
}

.family-active-card small{
  color:var(--muted);
  font-weight:900;
}

.family-children-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(170px,1fr));
  gap:10px;
}

.family-child-card{
  min-height:92px;
  padding:12px;
  border-radius:22px;
  background:rgba(255,255,255,.88);
  box-shadow:var(--soft);
  text-align:left;
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  gap:10px;
  align-items:center;
}

.family-child-card.active{
  outline:4px solid rgba(95,181,109,.42);
  background:linear-gradient(135deg,#eaffea,#fff);
}

.family-child-avatar{
  width:46px;
  height:46px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background:#fff4e2;
  font-size:24px;
}

.family-child-card strong{
  font-size:16px;
}

.family-child-card small{
  color:var(--muted);
  font-weight:900;
}

.family-create-grid{
  display:grid;
  grid-template-columns:2fr 1fr 1fr auto;
  gap:10px;
  align-items:end;
}

.family-create-grid label{
  display:grid;
  gap:5px;
  color:var(--muted);
  font-size:12px;
  font-weight:1000;
  text-transform:uppercase;
}

.family-input{
  min-height:48px;
  padding:0 14px;
  border-radius:18px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--ink);
  font:inherit;
  font-weight:900;
  outline:none;
}

.family-create-btn{
  min-height:48px;
}

.family-action-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

@media(max-width:820px){
  .family-create-grid{
    grid-template-columns:1fr;
  }

  .child-badge{
    justify-self:start;
  }
}


/* ======================================================
   BLOQUE 15 — AUTH LOGIN SEGURIDAD
====================================================== */

.auth-overlay{
  position:fixed;
  inset:0;
  z-index:9999;
  display:grid;
  place-items:center;
  padding:18px;
  background:
    radial-gradient(circle at top left, rgba(255,143,177,.42), transparent 42%),
    radial-gradient(circle at bottom right, rgba(86,204,242,.40), transparent 44%),
    rgba(255,247,236,.94);
  backdrop-filter:blur(18px);
}

.auth-overlay[hidden]{display:none !important;}

.auth-card{
  width:min(100%, 460px);
  padding:24px;
  border-radius:34px;
  background:rgba(255,255,255,.94);
  box-shadow:0 24px 70px rgba(58,46,42,.22);
  display:grid;
  gap:14px;
}

.auth-logo{display:grid;grid-template-columns:auto minmax(0,1fr);gap:12px;align-items:center;}
.auth-logo span{width:58px;height:58px;border-radius:22px;display:grid;place-items:center;font-size:30px;background:linear-gradient(135deg,#ff8fb1,#ffd166);}
.auth-logo strong{display:block;font-size:21px;}
.auth-logo small{color:var(--muted);font-weight:900;}
.auth-card h1{margin:4px 0 0;font-size:38px;line-height:.95;}
.auth-copy{margin:0;color:var(--muted);font-weight:900;line-height:1.35;}
.auth-field{display:grid;gap:6px;color:var(--muted);font-size:12px;font-weight:1000;text-transform:uppercase;}
.auth-field input{min-height:54px;padding:0 15px;border-radius:20px;border:3px solid #efe4d8;background:#fffaf2;color:var(--ink);font:inherit;font-weight:1000;outline:none;}
.auth-primary,.auth-secondary{min-height:54px;border-radius:22px;font:inherit;font-weight:1000;cursor:pointer;}
.auth-primary{background:linear-gradient(135deg,#ff8fb1,#ffd166);color:#33251f;box-shadow:var(--soft);}
.auth-secondary{background:#fff;color:var(--muted);border:3px solid #efe4d8;}
.auth-status{min-height:20px;margin:0;font-weight:1000;color:var(--muted);}
.auth-warning{padding:12px;border-radius:20px;background:#fff4d7;color:#6d4b00;font-size:13px;font-weight:900;line-height:1.35;}
.auth-warning code{background:rgba(255,255,255,.75);padding:1px 4px;border-radius:6px;}
.logout-access{background:linear-gradient(135deg,#e8f7ff,#fff);}


/* ======================================================
   BLOQUE 15.1 — LANDING / LOGIN / SOLICITUD DE ACCESO
====================================================== */

.auth-shell{
  width:min(100%, 980px);
  display:grid;
  place-items:center;
}

.auth-view{
  width:min(100%, 620px);
  padding:24px;
  border-radius:34px;
  background:rgba(255,255,255,.96);
  box-shadow:0 24px 70px rgba(58,46,42,.22);
  display:grid;
  gap:14px;
}

.auth-view[hidden]{display:none !important;}

.auth-landing{
  width:min(100%, 920px);
  padding:30px;
}

.auth-hero-badge{
  width:max-content;
  padding:10px 14px;
  border-radius:999px;
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
  color:#33251f;
  font-weight:1000;
  box-shadow:var(--soft);
}

.auth-landing h1{
  margin:0;
  max-width:780px;
  font-size:clamp(34px,6vw,68px);
  line-height:.92;
  letter-spacing:-2px;
}

.auth-copy-large{
  max-width:720px;
  margin:0;
  color:var(--muted);
  font-size:18px;
  font-weight:900;
  line-height:1.38;
}

.auth-feature-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}

.auth-feature-grid div{
  padding:16px;
  border-radius:24px;
  background:linear-gradient(135deg,#fffaf2,#fff);
  box-shadow:var(--soft);
}

.auth-feature-grid span{
  display:block;
  font-size:32px;
  margin-bottom:8px;
}

.auth-feature-grid strong{
  display:block;
  font-size:17px;
}

.auth-feature-grid p{
  margin:6px 0 0;
  color:var(--muted);
  font-weight:900;
  line-height:1.32;
}

.auth-actions-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

.auth-link-btn{
  border:0;
  background:transparent;
  color:var(--muted);
  font:inherit;
  font-weight:1000;
  cursor:pointer;
  min-height:48px;
  padding:0 10px;
}

.auth-back{
  justify-self:start;
  border:0;
  background:#fff4e2;
  color:var(--ink);
  border-radius:999px;
  min-height:38px;
  padding:0 12px;
  font:inherit;
  font-weight:1000;
  cursor:pointer;
}

.auth-view h2{
  margin:2px 0 0;
  font-size:36px;
  line-height:1;
}

.auth-field textarea{
  padding:12px 14px;
  border-radius:20px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--ink);
  font:inherit;
  font-weight:900;
  outline:none;
  resize:vertical;
}

@media(max-width:760px){
  .auth-feature-grid{grid-template-columns:1fr;}
  .auth-landing{padding:22px;}
  .auth-actions-row{display:grid;}
}


/* ======================================================
   BLOQUE 16 — ADMIN CORE
====================================================== */

.admin-only[hidden]{
  display:none !important;
}

.admin-sheet{
  max-width:1040px;
}

.admin-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}

.admin-summary-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin:14px 0;
}

.admin-stat-card{
  padding:14px;
  border-radius:22px;
  background:linear-gradient(135deg,#fff,#fff8e8);
  box-shadow:var(--soft);
  display:grid;
  gap:3px;
}

.admin-stat-card strong{
  font-size:28px;
  line-height:1;
}

.admin-stat-card span{
  color:var(--muted);
  font-weight:1000;
  font-size:12px;
  text-transform:uppercase;
}

.admin-tabs{
  display:flex;
  gap:8px;
  overflow:auto;
  padding:4px 0 10px;
}

.admin-tab{
  min-height:42px;
  padding:0 14px;
  border-radius:999px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--muted);
  font:inherit;
  font-weight:1000;
  cursor:pointer;
  white-space:nowrap;
}

.admin-tab.active{
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
  color:#33251f;
  border-color:transparent;
}

.admin-panel-section{
  display:none;
}

.admin-panel-section.active{
  display:grid;
  gap:12px;
}

.admin-section-head{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}

.admin-section-head h3{
  margin:0;
  font-size:22px;
}

.admin-section-head span{
  color:var(--muted);
  font-weight:900;
}

.admin-list{
  display:grid;
  gap:10px;
}

.admin-item{
  padding:14px;
  border-radius:24px;
  background:#fff;
  box-shadow:var(--soft);
  display:grid;
  gap:10px;
}

.admin-item-head{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
}

.admin-item strong{
  font-size:17px;
}

.admin-item small{
  color:var(--muted);
  font-weight:900;
}

.admin-meta-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(150px,1fr));
  gap:8px;
}

.admin-meta{
  padding:9px 10px;
  border-radius:16px;
  background:#fff8e8;
  font-size:13px;
  font-weight:900;
  color:var(--muted);
}

.admin-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.admin-actions button{
  min-height:38px;
  padding:0 12px;
  border-radius:999px;
  border:0;
  font:inherit;
  font-weight:1000;
  cursor:pointer;
}

.admin-actions .approve{
  background:#eaffea;
  color:#2f7d32;
}

.admin-actions .deny,
.admin-actions .disable{
  background:#ffecec;
  color:#b43b3b;
}

.admin-actions .enable,
.admin-actions .edit{
  background:#e8f7ff;
  color:#21617a;
}

.admin-pill{
  display:inline-flex;
  min-height:30px;
  padding:0 10px;
  border-radius:999px;
  align-items:center;
  font-size:12px;
  font-weight:1000;
  background:#fff4e2;
  color:#7a5520;
}

.admin-pill.ok{
  background:#eaffea;
  color:#2f7d32;
}

.admin-pill.warn{
  background:#fff4d7;
  color:#8a5b00;
}

.admin-pill.bad{
  background:#ffecec;
  color:#b43b3b;
}

.admin-security-box{
  display:grid;
  gap:10px;
}

.admin-warning-card{
  padding:12px;
  border-radius:20px;
  background:#fff4d7;
  color:#6d4b00;
  font-weight:900;
}

.admin-event-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  padding:12px;
  border-radius:20px;
  background:#fff;
  box-shadow:var(--soft);
}

@media(max-width:760px){
  .admin-summary-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .admin-head,
  .admin-section-head,
  .admin-item-head{
    display:grid;
  }
}


/* ======================================================
   BLOQUE 17 — IA REAL + LÍMITES
====================================================== */

.ai-quota-panel{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  padding:14px;
  border-radius:24px;
  background:linear-gradient(135deg,#e8f7ff,#fffaf2);
  box-shadow:var(--soft);
  margin:10px 0;
}

.ai-quota-panel strong{display:block;font-size:16px;}
.ai-quota-panel span{display:block;color:var(--muted);font-weight:900;margin-top:3px;}

.ai-admin-provider{
  padding:14px;
  border-radius:24px;
  background:linear-gradient(135deg,#fffaf2,#fff);
  box-shadow:var(--soft);
  display:grid;
  gap:8px;
}

.ai-admin-quota-form{
  display:grid;
  grid-template-columns:2fr 1fr 1fr 1fr auto;
  gap:8px;
  margin:10px 0;
}

.ai-admin-quota-form input{
  min-height:42px;
  padding:0 12px;
  border-radius:16px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--ink);
  font:inherit;
  font-weight:900;
  outline:none;
}

.ai-usage-mini{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:start;
}

.ai-usage-mini .cost{font-weight:1000;}

@media(max-width:860px){
  .ai-quota-panel{display:grid;}
  .ai-admin-quota-form{grid-template-columns:1fr;}
}


/* ======================================================
   HOTFIX 17.1 — ADMIN TABS / PANEL REAL
====================================================== */

.admin-sheet{
  min-height:min(760px, 88vh);
}

.admin-panel-section.active{
  min-height:260px;
}

.admin-list .empty-card,
.admin-panel-section .empty-card{
  padding:18px;
  border-radius:24px;
  background:linear-gradient(135deg,#fffaf2,#fff);
  box-shadow:var(--soft);
  color:var(--muted);
  font-weight:900;
  line-height:1.35;
}

.admin-list .empty-card strong,
.admin-panel-section .empty-card strong{
  color:var(--ink);
  font-size:18px;
}

.admin-tab{
  pointer-events:auto;
  user-select:none;
}

.admin-tab:active{
  transform:translateY(1px);
}


/* ======================================================
   BLOQUE 18 — FREEMIUM / PREMIUM / PACKS
====================================================== */

.plan-badge-btn.premium{
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
}

.plan-badge-btn.free{
  background:#fff;
}

.plans-sheet{
  max-width:980px;
}

.current-plan-card{
  padding:18px;
  border-radius:26px;
  background:linear-gradient(135deg,#fffaf2,#e8f7ff);
  box-shadow:var(--soft);
  margin:12px 0;
}

.current-plan-card strong{
  font-size:24px;
  display:block;
}

.current-plan-card p{
  margin:6px 0 0;
  color:var(--muted);
  font-weight:900;
}

.plans-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:12px;
}

.plan-card{
  padding:18px;
  border-radius:28px;
  background:#fff;
  box-shadow:var(--soft);
  display:grid;
  gap:10px;
  border:3px solid transparent;
}

.plan-card.current{
  border-color:#ff8fb1;
  background:linear-gradient(135deg,#fff,#fff4f8);
}

.plan-card h3{
  margin:0;
  font-size:24px;
}

.plan-card .price{
  font-size:30px;
  font-weight:1000;
}

.plan-card ul{
  margin:0;
  padding-left:18px;
  color:var(--muted);
  font-weight:900;
  line-height:1.45;
}

.pack-card.premium-locked{
  position:relative;
  filter:saturate(.7);
}

.pack-card.premium-locked::after{
  content:"Premium";
  position:absolute;
  top:12px;
  right:12px;
  border-radius:999px;
  padding:5px 9px;
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
  font-size:12px;
  font-weight:1000;
  color:#33251f;
}

.admin-plan-pill{
  display:inline-flex;
  align-items:center;
  min-height:30px;
  padding:0 10px;
  border-radius:999px;
  background:#fff4e2;
  color:#7a5520;
  font-size:12px;
  font-weight:1000;
}

.admin-plan-pill.premium{
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
  color:#33251f;
}

.ai-admin-quota-form select{
  min-height:42px;
  padding:0 12px;
  border-radius:16px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--ink);
  font:inherit;
  font-weight:900;
  outline:none;
}


/* ======================================================
   BLOQUE 19 — PRIVACIDAD INFANTIL / CONSENTIMIENTO
====================================================== */

.legal-sheet{
  max-width:980px;
}

.legal-status-card,
.parent-legal-card{
  padding:16px;
  border-radius:26px;
  background:linear-gradient(135deg,#fffaf2,#e8f7ff);
  box-shadow:var(--soft);
  display:flex;
  justify-content:space-between;
  gap:14px;
  align-items:center;
  margin:12px 0;
}

.parent-legal-card p,
.legal-status-card p{
  margin:4px 0 0;
  color:var(--muted);
  font-weight:900;
}

.legal-status-card.good{
  background:linear-gradient(135deg,#eaffea,#fff);
}

.legal-status-card.warn{
  background:linear-gradient(135deg,#fff4d7,#fff);
}

.legal-doc-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:10px;
  margin:12px 0;
}

.legal-doc-card{
  padding:14px;
  border-radius:24px;
  background:#fff;
  box-shadow:var(--soft);
  display:grid;
  gap:6px;
}

.legal-doc-card strong{
  font-size:17px;
}

.legal-doc-card small{
  color:var(--muted);
  font-weight:900;
}

.legal-consent-form{
  display:grid;
  gap:10px;
}

.legal-consent-form label:not(.legal-check){
  display:grid;
  gap:5px;
  font-weight:1000;
  color:var(--muted);
}

.legal-consent-form input[type="text"],
.legal-consent-form input[type="email"]{
  min-height:46px;
  padding:0 14px;
  border-radius:18px;
  border:3px solid #efe4d8;
  background:#fffaf2;
  color:var(--ink);
  font:inherit;
  font-weight:900;
}

.legal-check{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding:12px;
  border-radius:18px;
  background:#fff;
  box-shadow:var(--soft);
  color:var(--ink);
  font-weight:900;
}

.legal-check input{
  width:22px;
  height:22px;
  accent-color:#ff8fb1;
}

.legal-danger-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.soft-btn.danger{
  background:#ffecec;
  color:#b43b3b;
}

.admin-legal-ok{
  background:#eaffea;
  color:#2f7d32;
}

.admin-legal-bad{
  background:#ffecec;
  color:#b43b3b;
}

@media(max-width:760px){
  .legal-status-card,
  .parent-legal-card{
    display:grid;
  }
}


/* ======================================================
   HOTFIX 19.2 — FRONTEND UX / MENÚS / SCROLL REAL
   Objetivo: que ningún menú quede cortado y todos los paneles naveguen.
====================================================== */

html,
body{
  min-width:0;
}

body{
  overscroll-behavior:none;
}

.app-shell{
  overflow-y:auto;
  overflow-x:hidden;
  scrollbar-gutter:stable both-edges;
  scroll-padding-bottom:calc(var(--dock-h) + var(--safe-bottom) + 28px);
  -webkit-overflow-scrolling:touch;
}

.hero-top{
  display:grid;
  grid-template-columns:minmax(150px, auto) minmax(0, 1fr);
  align-items:start;
}

.hero-actions{
  max-width:100%;
  min-width:0;
  flex-wrap:nowrap;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x proximity;
  padding:2px 2px 8px;
  justify-content:flex-start;
}

.hero-actions .round-btn{
  scroll-snap-align:start;
}

.mode-strip,
.tooldock,
.hero-actions,
.admin-tabs,
.color-row,
.chip-row{
  scrollbar-width:thin;
  scrollbar-color:rgba(58,46,42,.28) rgba(255,255,255,.34);
}

.mode-strip::-webkit-scrollbar,
.tooldock::-webkit-scrollbar,
.hero-actions::-webkit-scrollbar,
.admin-tabs::-webkit-scrollbar,
.color-row::-webkit-scrollbar,
.chip-row::-webkit-scrollbar{
  display:block !important;
  height:8px;
  width:8px;
}

.mode-strip::-webkit-scrollbar-thumb,
.tooldock::-webkit-scrollbar-thumb,
.hero-actions::-webkit-scrollbar-thumb,
.admin-tabs::-webkit-scrollbar-thumb,
.color-row::-webkit-scrollbar-thumb,
.chip-row::-webkit-scrollbar-thumb{
  background:rgba(58,46,42,.26);
  border-radius:999px;
}

.mode-strip::-webkit-scrollbar-track,
.tooldock::-webkit-scrollbar-track,
.hero-actions::-webkit-scrollbar-track,
.admin-tabs::-webkit-scrollbar-track,
.color-row::-webkit-scrollbar-track,
.chip-row::-webkit-scrollbar-track{
  background:rgba(255,255,255,.36);
  border-radius:999px;
}

.mode-chip{
  min-width:max-content;
  white-space:nowrap;
}

.stage-card{
  min-height:clamp(360px, 54dvh, 720px);
}

.canvas-wrap{
  min-height:320px;
}

.tooldock{
  overflow-x:auto !important;
  overflow-y:hidden !important;
  scroll-padding-inline:10px;
  padding-bottom:12px;
}

.tool-btn{
  flex:0 0 74px;
}

/* Paneles: siempre con scroll interno real */
.bottom-sheet{
  height:auto;
  max-height:calc(100dvh - max(32px, env(safe-area-inset-top)) - max(32px, env(safe-area-inset-bottom)));
  overflow-y:auto !important;
  overflow-x:hidden !important;
  scrollbar-gutter:stable;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}

.bottom-sheet[hidden]{
  display:none !important;
}

.bottom-sheet.tall{
  max-height:calc(100dvh - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
}

.bottom-sheet::-webkit-scrollbar{
  display:block !important;
  width:10px;
}

.bottom-sheet::-webkit-scrollbar-thumb{
  background:rgba(58,46,42,.25);
  border-radius:999px;
}

.bottom-sheet::-webkit-scrollbar-track{
  background:rgba(255,255,255,.6);
  border-radius:999px;
}

.sheet-head,
.admin-head{
  position:sticky;
  top:0;
  z-index:30;
  padding:8px 54px 10px 0;
  background:linear-gradient(180deg, var(--paper) 70%, rgba(255,253,248,0));
}

.sheet-close{
  z-index:40;
}

.admin-tabs{
  position:sticky;
  top:64px;
  z-index:28;
  background:rgba(255,253,248,.96);
  backdrop-filter:blur(10px);
  border-radius:999px;
  padding:8px;
  margin:4px 0 12px;
  flex-wrap:nowrap;
}

.admin-tab{
  flex:0 0 auto;
}

.admin-panel-section{
  min-width:0;
}

.admin-panel-section.active{
  display:grid !important;
  gap:12px;
}

.admin-list,
.admin-security-box,
.adminSummaryGrid,
.plans-grid,
.legal-doc-grid,
.gallery-grid,
.packs-grid,
.reward-grid,
.lesson-grid,
.challenge-grid,
.missions-grid,
.template-grid,
.ai-library-grid{
  min-width:0;
}

.admin-event-row,
.admin-item,
.plan-card,
.pack-card,
.legal-doc-card{
  min-width:0;
  overflow-wrap:anywhere;
}

.export-box,
pre{
  max-width:100%;
  overflow:auto;
}

@media(max-width:900px){
  .hero-top{
    grid-template-columns:1fr;
  }

  .hero-actions{
    width:100%;
    max-width:100%;
  }

  .brand-title{
    font-size:clamp(32px, 12vw, 54px);
  }

  .stage-card{
    min-height:clamp(380px, 58dvh, 680px);
  }
}

@media(max-width:640px){
  :root{
    --dock-h:96px;
  }

  .app-shell{
    padding-left:10px;
    padding-right:10px;
    gap:8px;
  }

  .mission-card{
    display:grid;
    min-height:auto;
  }

  .stars{
    justify-self:start;
  }

  .canvas-status{
    overflow-x:auto;
    scrollbar-width:thin;
  }

  .canvas-status span{
    flex:0 0 auto;
    max-width:none;
  }

  .bottom-sheet{
    width:calc(100vw - 12px);
    max-width:calc(100vw - 12px);
    left:6px;
    right:6px;
    transform:none;
    border-radius:24px;
    padding:14px 12px 34px;
  }

  .sheet-head,
  .admin-head{
    padding-right:52px;
  }

  .admin-tabs{
    top:58px;
    border-radius:22px;
  }

  .tool-btn{
    flex-basis:68px;
  }
}

/* Botones invisibles nunca deben ocupar hueco roto */
.admin-only[hidden],
[hidden]{
  display:none !important;
}


/* ======================================================
   HOTFIX 20.2 — LIENZO GRANDE / SIN RECORTES
   Problema: el grid principal dejaba poco alto al canvas.
   Solución: el lienzo manda; el resto puede desplazarse.
====================================================== */

.app-shell{
  height:auto !important;
  min-height:100dvh !important;
  overflow-y:auto !important;
  grid-template-rows:auto auto auto auto auto auto !important;
  align-content:start;
  padding-bottom:calc(var(--dock-h) + var(--safe-bottom) + 28px) !important;
}

/* El canvas deja de depender de "lo que sobre" en pantalla */
.stage-card{
  height:clamp(560px, 68dvh, 860px) !important;
  min-height:560px !important;
  max-height:none !important;
  grid-template-rows:auto minmax(500px, 1fr) !important;
  overflow:visible !important;
}

.canvas-wrap{
  min-height:500px !important;
  height:100% !important;
  overflow:hidden !important;
  border-width:5px;
}

#drawingCanvas{
  width:100% !important;
  height:100% !important;
}

/* Más espacio real para los dibujos en desktop */
@media(min-width:960px){
  .stage-card{
    height:clamp(620px, 72dvh, 920px) !important;
    min-height:620px !important;
    grid-template-rows:auto minmax(560px, 1fr) !important;
  }

  .canvas-wrap{
    min-height:560px !important;
  }
}

/* En móvil/tablet el lienzo sigue siendo grande y el menú queda por scroll */
@media(max-width:760px){
  .mission-card{
    min-height:64px;
    padding:10px 12px;
  }

  .mission-badge{
    width:46px;
    height:46px;
    flex-basis:46px;
    font-size:24px;
  }

  .mission-copy p{
    white-space:normal;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
  }

  .stage-card{
    height:clamp(540px, 70dvh, 760px) !important;
    min-height:540px !important;
    grid-template-rows:auto minmax(485px, 1fr) !important;
    border-radius:24px;
    padding:8px;
  }

  .canvas-wrap{
    min-height:485px !important;
    border-radius:20px;
  }

  .canvas-status{
    overflow-x:auto;
    padding-bottom:8px;
  }

  .canvas-status span{
    flex:0 0 auto;
    max-width:none;
  }
}

/* En pantallas muy bajas, priorizar dibujo y permitir scroll */
@media(max-height:720px){
  .stage-card{
    height:620px !important;
    min-height:620px !important;
  }

  .canvas-wrap{
    min-height:560px !important;
  }
}

/* Evita sensación de corte en line-art grueso: borde más limpio */
.canvas-wrap::after{
  content:"";
  pointer-events:none;
  position:absolute;
  inset:0;
  border-radius:inherit;
  box-shadow:inset 0 0 0 1px rgba(58,45,41,.05);
}


/* ======================================================
   HOTFIX 20.3 — SCROLL VERTICAL REAL / DOCK NO TAPA
   Corrección: en 20.2 se dijo que habría scroll vertical,
   pero el layout seguía pudiendo quedar bloqueado por alturas
   fijas/overflow. Aquí se fuerza scroll real del documento.
====================================================== */

html{
  height:auto !important;
  min-height:100% !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
}

body{
  height:auto !important;
  min-height:100dvh !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  position:relative !important;
  touch-action:pan-y !important;
}

/* Cuando hay panel modal abierto, sólo entonces se bloquea el fondo */
html.sheet-open,
body.sheet-open{
  overflow:hidden !important;
}

/* La app deja de comportarse como pantalla cerrada sin scroll */
.app-shell{
  height:auto !important;
  min-height:100dvh !important;
  max-height:none !important;
  overflow:visible !important;
  display:flex !important;
  flex-direction:column !important;
  gap:12px !important;
  padding-bottom:24px !important;
}

/* El dock deja de flotar encima del canvas. Entra en el flujo real. */
.tooldock{
  position:sticky !important;
  bottom:max(8px, env(safe-area-inset-bottom)) !important;
  left:auto !important;
  right:auto !important;
  transform:none !important;
  width:100% !important;
  max-width:1180px !important;
  margin:8px auto 0 !important;
  z-index:90 !important;
  flex:0 0 auto !important;
}

/* El canvas gana espacio sin depender de un footer flotante */
.stage-card{
  flex:0 0 auto !important;
  height:auto !important;
  min-height:clamp(620px, 76dvh, 940px) !important;
  display:grid !important;
  grid-template-rows:auto minmax(560px, 1fr) !important;
}

.canvas-wrap{
  min-height:560px !important;
  height:auto !important;
}

/* Móvil: el dock sigue abajo, pero no tapa el lienzo */
@media(max-width:760px){
  .app-shell{
    padding-bottom:18px !important;
  }

  .tooldock{
    position:sticky !important;
    bottom:max(6px, env(safe-area-inset-bottom)) !important;
    margin-top:6px !important;
  }

  .stage-card{
    min-height:clamp(590px, 76dvh, 820px) !important;
    grid-template-rows:auto minmax(525px, 1fr) !important;
  }

  .canvas-wrap{
    min-height:525px !important;
  }
}

/* Pantallas muy bajas: se prioriza lienzo y el resto se alcanza con scroll real */
@media(max-height:740px){
  .stage-card{
    min-height:680px !important;
    grid-template-rows:auto minmax(610px, 1fr) !important;
  }

  .canvas-wrap{
    min-height:610px !important;
  }
}

/* Botón visual opcional: si aparece el dock, no debe cubrir nada */
body:not(.sheet-open) .tooldock{
  box-shadow:0 12px 40px rgba(58,45,41,.18);
}


/* ======================================================
   HOTFIX 20.4 — VALIDACIÓN AMABLE
====================================================== */

.step-hint{
  min-height:36px;
}

.validation-soft-note{
  font-weight:900;
  color:var(--muted);
}


/* ======================================================
   BLOQUE 21 — MODO PINTAR GRANDE / TABLET
   Convierte la app en un estudio de dibujo limpio sin
   cabecera, landing ni menús de distracción.
====================================================== */

.focus-exit-btn{
  position:absolute;
  top:14px;
  right:14px;
  z-index:75;
  border:0;
  border-radius:999px;
  padding:10px 14px;
  background:linear-gradient(135deg,#fff,#fff4d7);
  color:var(--ink);
  font-weight:1000;
  box-shadow:var(--soft);
  cursor:pointer;
}

body.draw-focus{
  overflow:hidden !important;
  background:#fff8ef;
}

body.draw-focus .app-shell{
  height:100dvh !important;
  min-height:100dvh !important;
  overflow:hidden !important;
  display:grid !important;
  grid-template-rows:1fr auto !important;
  padding:8px !important;
  gap:8px !important;
}

body.draw-focus .hero-top,
body.draw-focus .mode-strip,
body.draw-focus .mission-card,
body.draw-focus .palette-card{
  display:none !important;
}

body.draw-focus .stage-card{
  height:calc(100dvh - 106px) !important;
  min-height:0 !important;
  max-height:none !important;
  padding:8px !important;
  border-radius:26px !important;
  grid-template-rows:auto minmax(0, 1fr) !important;
  overflow:hidden !important;
}

body.draw-focus .canvas-status{
  min-height:38px;
  padding-right:172px;
}

body.draw-focus .canvas-wrap{
  min-height:0 !important;
  height:100% !important;
  border-radius:22px !important;
}

body.draw-focus .step-console{
  position:absolute;
  left:14px;
  right:14px;
  bottom:112px;
  z-index:70;
  max-height:42dvh;
  overflow:auto;
  box-shadow:0 22px 50px rgba(58,45,41,.16);
}

body.draw-focus .tooldock{
  position:relative !important;
  bottom:auto !important;
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  z-index:95 !important;
  border-radius:24px !important;
  overflow-x:auto !important;
}

body.draw-focus .tool-btn{
  flex-basis:76px;
}

body.draw-focus .focus-exit-btn{
  display:inline-flex !important;
}

body:not(.draw-focus) .focus-exit-btn{
  display:none !important;
}

body.draw-focus .bottom-sheet{
  max-height:92dvh;
}

body.draw-focus .focus-dock-btn,
body.draw-focus .focus-draw-top{
  background:linear-gradient(135deg,#ff8fb1,#ffd166);
}

@media(max-width:760px){
  body.draw-focus .app-shell{
    padding:5px !important;
    gap:6px !important;
  }

  body.draw-focus .stage-card{
    height:calc(100dvh - 98px) !important;
    padding:6px !important;
    border-radius:20px !important;
  }

  body.draw-focus .canvas-status{
    min-height:34px;
    padding-right:128px;
    font-size:12px;
  }

  body.draw-focus .focus-exit-btn{
    top:10px;
    right:10px;
    padding:8px 10px;
    font-size:12px;
  }

  body.draw-focus .tooldock{
    border-radius:20px !important;
  }

  body.draw-focus .tool-btn{
    flex-basis:67px;
  }
}

@media(orientation:landscape) and (max-height:620px){
  body.draw-focus .stage-card{
    height:calc(100dvh - 86px) !important;
  }

  body.draw-focus .tool-btn{
    min-height:64px;
  }

  body.draw-focus .tool-btn small{
    font-size:10px;
  }
}


/* ======================================================
   BLOQUE 22 — QA FRONTEND / PREDEPLOY
====================================================== */

.qa-action-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin:10px 0;
}

.qa-score-card{
  padding:18px;
  border-radius:26px;
  background:linear-gradient(135deg,#fffaf2,#e8f7ff);
  box-shadow:var(--soft);
  display:grid;
  gap:6px;
  margin:10px 0;
}

.qa-score-card strong{
  font-size:24px;
}

.qa-score-card p{
  margin:0;
  color:var(--muted);
  font-weight:900;
}

.qa-score-card.good{
  background:linear-gradient(135deg,#eaffea,#fff);
}

.qa-score-card.warn{
  background:linear-gradient(135deg,#fff4d7,#fff);
}

.qa-score-card.bad{
  background:linear-gradient(135deg,#ffecec,#fff);
}

.qa-check-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:start;
  padding:13px;
  border-radius:20px;
  background:#fff;
  box-shadow:var(--soft);
  overflow-wrap:anywhere;
}

.qa-check-row strong{
  display:block;
  font-size:15px;
}

.qa-check-row small{
  display:block;
  color:var(--muted);
  font-weight:900;
  margin-top:3px;
}

.qa-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:76px;
  min-height:30px;
  border-radius:999px;
  padding:0 10px;
  font-size:12px;
  font-weight:1000;
  background:#f0f0f0;
}

.qa-pill.ok{
  background:#eaffea;
  color:#2f7d32;
}

.qa-pill.warn{
  background:#fff4d7;
  color:#8a5a00;
}

.qa-pill.fail{
  background:#ffecec;
  color:#b43b3b;
}

.qa-grid{
  display:grid;
  gap:8px;
}

@media(max-width:680px){
  .qa-check-row{
    grid-template-columns:1fr;
  }

  .qa-pill{
    justify-self:start;
  }
}


/* ======================================================
   HOTFIX 22.1 — QA / ADMIN TABS / FALSE POSITIVES
====================================================== */

/* Evita que las pestañas Admin se monten encima del título/subtítulo */
.admin-head{
  position:relative !important;
  top:auto !important;
  z-index:auto !important;
  background:transparent !important;
  padding-bottom:12px !important;
}

.admin-tabs{
  position:relative !important;
  top:auto !important;
  z-index:auto !important;
  transform:none !important;
  margin:12px 0 18px !important;
  background:rgba(255,253,248,.92) !important;
  backdrop-filter:blur(10px);
  overflow-x:auto !important;
  overflow-y:hidden !important;
  scroll-snap-type:x proximity;
}

.admin-tab{
  scroll-snap-align:start;
}

/* El contenido del panel QA no debe quedar pegado arriba */
#adminTabQa{
  padding-top:6px;
}

/* El panel admin debe dejar aire superior al hacer scroll */
.admin-sheet{
  scroll-padding-top:24px;
}

/* Cuando QA se ejecuta dentro de modal, el dock de fondo no debe contarse como fallo visual */
body.sheet-open .tooldock{
  pointer-events:none;
}
