:root{
  --bg:#f4f5ff; --panel:#ffffff; --ink:#1e2040; --muted:#6b6f93; --line:#e3e5f5;
  --brand:#5b6cff; --brand-ink:#ffffff; --brand-soft:#e8eaff; --ok:#2f9e44; --warn:#e67700; --err:#e03131;
  --radius:18px; --shadow:0 6px 20px rgba(40,50,120,.10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#14162b; --panel:#1f2240; --ink:#eef0ff; --muted:#a5a9d4; --line:#2f3360;
    --brand:#7c89ff; --brand-soft:#2a2f63; --shadow:0 6px 20px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"]{ --bg:#14162b; --panel:#1f2240; --ink:#eef0ff; --muted:#a5a9d4; --line:#2f3360; --brand:#7c89ff; --brand-soft:#2a2f63; color-scheme: dark; }

/* Escala que crece en tablet y TV */
html{ font-size: clamp(16px, .55vw + 12px, 30px); -webkit-text-size-adjust:100%; }
*{ box-sizing:border-box; }
body{ margin:0; background:var(--bg); color:var(--ink); font-family:"Nunito",system-ui,sans-serif; line-height:1.5; min-height:100vh; }
h1,h2,h3,.brand-t,.btn,.tile-t{ font-family:"Baloo 2","Nunito",system-ui,sans-serif; }
h1{ font-size:2rem; line-height:1.15; margin:.2em 0 .4em; }
h2{ font-size:1.4rem; margin:.2em 0; }
h3{ font-size:1.15rem; margin:.2em 0; }
a{ color:var(--brand); }
img{ max-width:100%; display:block; }
.muted{ color:var(--muted); }
.hint{ color:var(--muted); font-size:.92rem; margin:.3rem 0; }
.empty{ color:var(--muted); text-align:center; padding:1.5rem 1rem; }
.empty.small{ padding:.6rem; text-align:left; }
.wrap{ max-width:1500px; margin:0 auto; padding:1rem 16px 4rem; }

/* Barra superior */
.topbar{ position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:.5rem;
  padding:.5rem 16px; background:color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter:blur(8px); border-bottom:1px solid var(--line); }
.brand{ display:flex; align-items:center; gap:.4rem; text-decoration:none; color:var(--ink); font-weight:800; font-size:1.25rem; }
.logo{ font-size:1.6rem; }
.topnav{ display:flex; gap:.3rem; }
.badge{ background:var(--err); color:#fff; border-radius:999px; font-size:.75rem; padding:0 .45em; margin-left:.25em; }

/* Botones (grandes: dedos, ratón y mando de TV) */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:.35em; min-height:2.75rem; padding:.45em 1.05em;
  border-radius:14px; border:2px solid var(--line); background:var(--panel); color:var(--ink); font-size:1.05rem; font-weight:700;
  text-decoration:none; cursor:pointer; transition:transform .08s, box-shadow .15s, background .15s; white-space:nowrap; }
.btn:hover{ box-shadow:var(--shadow); }
.btn:active{ transform:scale(.97); }
.btn.primary{ background:var(--brand); border-color:var(--brand); color:var(--brand-ink); }
.btn.ghost{ background:transparent; border-color:transparent; }
.btn.ghost:hover{ background:var(--brand-soft); box-shadow:none; }
.btn.big{ min-height:3.4rem; font-size:1.25rem; padding:.5em 1.4em; }
.btn.small{ min-height:2.3rem; font-size:.95rem; padding:.3em .8em; }
.btn.danger{ color:var(--err); }
.btn.canva{ background:linear-gradient(135deg,#00c4cc,#7d2ae8); color:#fff; border:0; }
:focus-visible{ outline:4px solid #ffb703; outline-offset:3px; border-radius:12px; }
.row{ display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
.row.end{ justify-content:flex-end; }
.stack{ display:flex; flex-direction:column; gap:.8rem; }
.inline{ display:inline; }

/* Formularios */
input[type=text],input[type=password],input[type=url],input:not([type]),textarea{
  width:100%; font:inherit; font-size:1.1rem; padding:.7em .9em; border-radius:14px; border:2px solid var(--line);
  background:var(--panel); color:var(--ink); }
input:focus,textarea:focus{ border-color:var(--brand); outline:none; }
textarea{ resize:vertical; line-height:1.6; min-height:12rem; }
label{ display:flex; flex-direction:column; gap:.3rem; font-weight:700; }
label.check{ flex-direction:row; align-items:flex-start; gap:.6rem; font-weight:500; }
label.check input{ width:1.4rem; height:1.4rem; margin-top:.15rem; }
fieldset{ border:2px dashed var(--line); border-radius:var(--radius); padding:1rem; display:flex; flex-direction:column; gap:.6rem; }
legend{ font-weight:800; padding:0 .4rem; }
.pw{ position:relative; }
.pw input{ padding-right:3.2rem; }
.pw-toggle{ position:absolute; right:.4rem; top:50%; transform:translateY(-50%); border:0; background:none; font-size:1.3rem; cursor:pointer; }
.title-in{ font-size:1.4rem !important; font-weight:800; }

/* Tarjetas */
.card{ background:var(--panel); border-radius:var(--radius); box-shadow:var(--shadow); padding:1.4rem; }
.narrow{ max-width:440px; margin:6vh auto; text-align:center; }
.narrow .stack{ text-align:left; }
.hero-emoji{ font-size:3.6rem; }
body.center .wrap{ padding-top:0; }

.flash{ max-width:1500px; margin:.8rem auto 0; padding:.8rem 1rem; border-radius:14px; font-weight:700; width:calc(100% - 32px);
  background:#d3f9d8; color:#1b5e20; animation:pop .25s ease-out; }
.flash.err{ background:#ffe3e3; color:#a01818; }
@keyframes pop{ from{ transform:translateY(-6px); opacity:0 } }

/* Inicio */
.home-head{ display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap; }
.sortbar{ display:flex; gap:.4rem; align-items:center; flex-wrap:wrap; }
.chip{ font:inherit; font-weight:700; border:2px solid var(--line); background:var(--panel); color:var(--ink); border-radius:999px; padding:.4em .9em; min-height:2.6rem; cursor:pointer; }
.chip.on{ background:var(--brand); border-color:var(--brand); color:#fff; }
.grid.folders{ display:grid; gap:1.1rem; grid-template-columns:repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); margin-top:1rem; }
.tile{ position:relative; display:flex; flex-direction:column; background:var(--panel); border-radius:var(--radius); overflow:hidden;
  text-decoration:none; color:var(--ink); box-shadow:var(--shadow); border:3px solid transparent; transition:transform .12s, border-color .12s; cursor:pointer; user-select:none; }
.tile:hover,.tile:focus-visible{ transform:translateY(-3px); border-color:var(--c, var(--brand)); }
.thumb{ aspect-ratio:16/9; background:var(--c, var(--brand)); display:block; overflow:hidden; }
.thumb img{ width:100%; height:100%; object-fit:cover; pointer-events:none; }
.thumb-ph{ display:flex; align-items:center; justify-content:center; width:100%; height:100%; font-family:"Baloo 2",sans-serif;
  font-size:4rem; font-weight:800; color:rgba(255,255,255,.92); background:linear-gradient(135deg, rgba(255,255,255,.18), rgba(0,0,0,.12)); }
.tile-t{ font-size:1.25rem; font-weight:800; padding:.55rem .9rem 0; line-height:1.2; }
.tile-s{ font-size:.9rem; color:var(--muted); padding:0 .9rem .7rem; }
.new-tile{ border:3px dashed var(--line); background:transparent; box-shadow:none; align-items:center; justify-content:center; min-height:12rem; font:inherit; font-weight:800; font-size:1.15rem; color:var(--muted); gap:.3rem; }
.new-tile .plus{ font-size:3rem; line-height:1; color:var(--brand); }
.new-tile:hover{ border-color:var(--brand); color:var(--brand); }
.pend{ color:var(--warn); font-weight:700; font-size:.85em; }
.sortable-ghost{ opacity:.35; }
.sortable-chosen{ box-shadow:0 12px 30px rgba(40,50,120,.3); }

/* Carpeta */
.crumbs{ font-size:.95rem; color:var(--muted); margin:.2rem 0 .8rem; overflow-wrap:anywhere; }
.crumbs a{ text-decoration:none; font-weight:700; }
.folder-head{ display:grid; grid-template-columns:minmax(0, 26rem) 1fr; gap:1.4rem; align-items:start; background:var(--panel); border-radius:var(--radius); padding:1rem; box-shadow:var(--shadow); border-top:8px solid var(--c); }
.big-thumb{ position:relative; aspect-ratio:16/9; background:var(--c); border-radius:14px; overflow:hidden; }
.big-thumb img{ width:100%; height:100%; object-fit:cover; }
.drop-msg{ position:absolute; inset:0; display:none; align-items:center; justify-content:center; background:rgba(91,108,255,.85); color:#fff; font-weight:800; font-size:1.3rem; }
.dropzone.over .drop-msg{ display:flex; }
.fh-info h1{ margin-top:0; }
.wrap-row{ margin:.4rem 0; }
.howto{ margin-top:.8rem; color:var(--muted); }
.howto summary{ cursor:pointer; font-weight:700; color:var(--brand); }
.block{ background:var(--panel); border-radius:var(--radius); padding:1.1rem; box-shadow:var(--shadow); margin-top:1.2rem; }
.block-head{ display:flex; justify-content:space-between; align-items:center; gap:.6rem; flex-wrap:wrap; margin-bottom:.6rem; }
.chapters{ list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:.6rem; }
.ch{ display:flex; align-items:center; gap:.5rem; border:2px solid var(--line); border-radius:14px; padding:.4rem .5rem; background:var(--bg); }
.grip{ cursor:grab; font-size:1.4rem; color:var(--muted); padding:0 .3rem; touch-action:none; }
.ch-main{ flex:1; display:flex; align-items:center; gap:.8rem; text-decoration:none; color:var(--ink); min-width:0; }
.ch-cover{ width:5.5rem; aspect-ratio:16/10; border-radius:10px; overflow:hidden; background:var(--brand-soft); display:flex; align-items:center; justify-content:center; font-size:1.6rem; flex:none; }
.ch-cover img{ width:100%; height:100%; object-fit:cover; }
.ch-txt{ display:flex; flex-direction:column; min-width:0; }
.ch-txt b{ font-size:1.15rem; overflow:hidden; text-overflow:ellipsis; }
.ch-txt small{ color:var(--muted); }

/* Galería */
.gallery{ display:grid; gap:.6rem; grid-template-columns:repeat(auto-fill, minmax(min(46%, 11rem), 1fr)); }
.ph{ position:relative; margin:0; aspect-ratio:1; border-radius:12px; overflow:hidden; background:var(--brand-soft); }
.ph img{ width:100%; height:100%; object-fit:cover; cursor:zoom-in; }
.ph .del{ position:absolute; top:.3rem; right:.3rem; }
.ph .del button{ width:2.4rem; height:2.4rem; border-radius:50%; border:0; background:rgba(0,0,0,.6); color:#fff; font-size:1.1rem; cursor:pointer; }
.gallery .uploading{ display:flex; align-items:center; justify-content:center; flex-direction:column; font-weight:700; color:var(--muted); font-size:.9rem; padding:.5rem; text-align:center; }
.bar{ width:80%; height:.6rem; border-radius:99px; background:var(--line); overflow:hidden; margin-top:.4rem; }
.bar i{ display:block; height:100%; width:0; background:var(--brand); transition:width .2s; }

/* Lector */
.read{ background:var(--panel); border-radius:var(--radius); padding:clamp(1rem, 3vw, 2.4rem); box-shadow:var(--shadow); border-top:8px solid var(--c); }
.read-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; flex-wrap:wrap; }
.read-head h1{ font-size:2.4rem; margin:0; }
.prose{ font-size:1.25rem; line-height:1.7; max-width:48rem; }
.prose h2{ font-size:1.7rem; margin-top:1rem; }
.prose h3{ font-size:1.4rem; }
.prose p{ margin:.3rem 0; }
.prose .gap{ height:.7rem; }
.read .block{ box-shadow:none; padding:0; margin-top:2rem; }
.videos{ display:grid; gap:1rem; grid-template-columns:repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); }
.videos figure{ margin:0; }
.videos figcaption{ display:flex; justify-content:space-between; align-items:center; gap:.5rem; padding:.4rem .2rem; font-weight:700; }
.video{ position:relative; aspect-ratio:16/9; background:#000; border-radius:14px; overflow:hidden; }
.video iframe,.video video{ position:absolute; inset:0; width:100%; height:100%; border:0; }
.pending-video{ background:var(--brand-soft); display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:1rem; color:var(--ink); }
.pending-video span{ font-size:2.5rem; }
.reader .videos{ grid-template-columns:1fr; max-width:60rem; }
.pager{ display:flex; justify-content:space-between; gap:1rem; margin-top:1.2rem; flex-wrap:wrap; }
.pager .btn{ max-width:100%; overflow:hidden; text-overflow:ellipsis; }

/* Editor */
.toolbar{ display:flex; flex-wrap:wrap; gap:.3rem; }
.toolbar button{ font:inherit; min-height:2.6rem; min-width:2.6rem; padding:.2em .7em; border-radius:10px; border:2px solid var(--line); background:var(--bg); color:var(--ink); cursor:pointer; font-size:1.05rem; }
.toolbar button:hover{ border-color:var(--brand); }
.danger-zone{ box-shadow:none; background:transparent; padding:0; }

/* Diálogos */
.dlg{ border:0; border-radius:var(--radius); padding:1.4rem; width:min(560px, calc(100vw - 32px)); background:var(--panel); color:var(--ink); box-shadow:0 20px 60px rgba(0,0,0,.35); }
.dlg::backdrop{ background:rgba(20,22,43,.55); }
.dlg h2{ margin-top:0; }
.colors{ display:flex; align-items:center; gap:.45rem; flex-wrap:wrap; font-weight:700; }
.sw{ flex-direction:row; }
.sw input{ position:absolute; opacity:0; }
.sw span{ width:2.4rem; height:2.4rem; border-radius:50%; background:var(--c); border:4px solid transparent; cursor:pointer; display:block; }
.sw input:checked + span{ border-color:var(--ink); }
.sw input:focus-visible + span{ outline:4px solid #ffb703; }

/* Lightbox */
.lightbox{ position:fixed; inset:0; z-index:100; background:rgba(0,0,0,.92); display:flex; align-items:center; justify-content:center; }
.lightbox[hidden]{ display:none; }
.lightbox img{ max-width:94vw; max-height:92vh; object-fit:contain; border-radius:8px; }
.lightbox button{ position:absolute; background:rgba(255,255,255,.15); color:#fff; border:0; border-radius:50%; width:3.4rem; height:3.4rem; font-size:2rem; cursor:pointer; }
.lb-close{ top:1rem; right:1rem; }
.lb-prev{ left:1rem; top:50%; transform:translateY(-50%); }
.lb-next{ right:1rem; top:50%; transform:translateY(-50%); }

/* Padres */
.review{ list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:.5rem; }
.review li{ display:flex; justify-content:space-between; align-items:center; gap:.6rem; flex-wrap:wrap; padding:.6rem .8rem; border:2px solid var(--line); border-radius:14px; }
.rv-media > div{ flex:1; min-width:min(100%, 18rem); display:flex; flex-direction:column; gap:.4rem; }
.rv-media .video{ max-width:28rem; }
.two{ display:grid; gap:1rem; grid-template-columns:repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.two .card{ box-shadow:none; border:2px solid var(--line); }

/* Móvil */
@media (max-width: 640px){
  .hide-s{ display:none; }
  .brand-t{ font-size:1.05rem; }
  .folder-head{ grid-template-columns:1fr; }
  h1{ font-size:1.6rem; }
  .read-head h1{ font-size:1.8rem; }
  .prose{ font-size:1.12rem; }
  .ch-cover{ width:4rem; }
}
/* TV / pantallas grandes: textos más amplios para leer desde el sofá */
@media (min-width: 1700px){
  .wrap{ max-width:none; padding-left:3vw; padding-right:3vw; }
  .reader .prose{ max-width:60rem; }
}
.big-thumb .uploading{ position:absolute; inset:0; z-index:2; aspect-ratio:auto; border-radius:0; background:rgba(255,255,255,.88); }

/* Normas */
.site-foot{text-align:center;padding:24px 16px 32px;font-size:.95rem}
.site-foot a{color:inherit;opacity:.75;text-decoration:none}
.site-foot a:hover{opacity:1;text-decoration:underline}
.normas ol{padding-left:1.2em;line-height:1.55}
.normas li{margin:.6em 0}

/* Ayuda */
.ayuda{max-width:760px;margin:0 auto}
.ayuda h2{margin-top:1.6em;scroll-margin-top:16px}
.ayuda h3{margin:1em 0 .3em}
.ayuda ol,.ayuda ul{padding-left:1.3em;line-height:1.55}
.ayuda li{margin:.4em 0}
.ayuda-toc{text-align:center;margin:.5em 0 1em;line-height:2}
