/* Shared sizing rules: content wraps instead of being clipped. */
*,*::before,*::after{box-sizing:border-box}
html,body{max-width:100%;margin:0}
body{overflow-wrap:anywhere}
img,video,canvas{max-width:100%}
input,textarea,select,button{min-width:0;max-width:100%}
button{white-space:normal;overflow-wrap:anywhere}
button:disabled{opacity:.45;cursor:not-allowed}
.main,.view,.card,.grid>*,.post-user,.dp-main,.dp-side,.dp-identity,.dp-header-actions,.chat-log,.chat-compose>*,.dm-thread,.explore-nameblock,.admin-item>div{min-width:0}
.avatar{flex-shrink:0;aspect-ratio:1}
.avatar img{object-fit:cover}
.post-media img,.forum-cover{display:block;width:auto;max-width:100%;height:auto;object-fit:contain;margin:12px auto;border-radius:12px}
.forum-cover{max-height:460px}
.forum-list{grid-template-columns:minmax(0,1fr);min-width:0}
.forum-create,.thread,.forum-thread-detail,.forum-reply,.forum-reply-box{padding:clamp(12px,3vw,20px);min-width:0;max-width:100%}
.forum-head-row>div{min-width:0;max-width:100%}
.forum-head-row h2,.forum-head-row h3{margin-top:0;overflow-wrap:anywhere}
.thread p,.forum-thread-detail p,.forum-reply p{overflow-wrap:anywhere;white-space:pre-wrap}
#forumForm:not(.hidden){display:grid;gap:12px;min-width:0}
.post-head{grid-template-columns:44px minmax(0,1fr) auto}
.post-body,.chat-message-body,.dm,.explore-bio,.dp-about-card p{overflow-wrap:anywhere;white-space:pre-wrap}
.composer-row,.forum-actions,.forum-head-row,.chat-line-head,.chat-line-actions,.post-meta,.dp-title-row,.dp-profile-actions,.dp-editor-actions,.dp-section-title,.profile-stats,.list-item{flex-wrap:wrap}
.badge,.pill{max-width:100%;white-space:normal}
.chat-compose>div:first-child{flex:1}
.chat-mini-btn{width:auto!important;min-width:0;height:auto!important;padding:5px 7px!important;font-size:11px}
.chat-log{min-height:0}
.explore-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,310px),1fr))}
.explore-nameblock strong{display:flex;flex-wrap:wrap;align-items:center;gap:4px}
.explore-actions{margin-top:auto;display:flex;flex-wrap:wrap;padding-top:14px}
.dp-mascot-card{display:flex;flex-direction:column;align-items:center;gap:14px}
.dp-mascot-card img{width:100%!important;height:auto!important;max-height:none!important;object-fit:contain}
.auth{overflow-y:auto;align-items:start;padding-top:32px;padding-bottom:85px}
.auth input:not([type=checkbox]),.auth select{width:100%;min-width:0}
.auth .policy-consent{display:flex;align-items:flex-start;gap:10px;font-size:13px;line-height:1.5}
.auth .policy-consent input{width:20px;height:20px;padding:0;flex:0 0 20px;margin-top:3px}
a{color:#d7a2ff}
.legal-footer{position:relative;display:flex;flex-wrap:wrap;justify-content:center;gap:8px 20px;padding:16px;background:#09060f;font-size:12px;z-index:51}
body:has(.auth:not(.hidden)) .legal-footer{position:fixed;bottom:0;left:0;right:0}
.sidebar{overflow-y:auto}
.sidebar-foot .ghost{margin-top:8px}
dialog{width:min(540px,calc(100% - 24px));max-height:90dvh;overflow:auto;background:#100c18;color:#eee;border:1px solid #593665;border-radius:18px;padding:24px}
dialog::backdrop{background:#000b}
.recovery-code{display:block;white-space:normal;overflow-wrap:anywhere;padding:12px;background:#050307;border:1px solid #58365e;border-radius:8px;margin:14px 0;user-select:all}
.legal-page{max-width:1040px;margin:auto;padding:28px 24px 60px;line-height:1.7}
.legal-intro{display:grid;grid-template-columns:minmax(0,1fr) 240px;gap:32px;align-items:center}
.legal-intro img{width:100%;height:auto;max-height:330px;object-fit:contain}
.legal-page h1{font-size:clamp(28px,5vw,44px);line-height:1.15}
.legal-page h2{margin-top:30px;font-size:21px;color:#dbaaff}
.legal-nav{display:flex;gap:16px;flex-wrap:wrap}
.legal-page section{padding:4px 0;border-bottom:1px solid #31203e}
@media(max-width:850px){
  .app{grid-template-columns:minmax(0,1fr)}
  .sidebar{left:0;top:0;width:min(86vw,290px);height:100vh;height:100dvh;transform:translateX(-100%);visibility:hidden;pointer-events:none;box-shadow:none;transition:transform .25s ease,visibility .25s;overflow-x:hidden;overscroll-behavior:contain}
  .sidebar.open{left:0;transform:translateX(0);visibility:visible;pointer-events:auto;box-shadow:18px 0 50px rgba(0,0,0,.2)}
}
@media(max-width:700px){
  .view{width:calc(100% - 20px)}
  .grid.two,.admin-grid,.admin-item,.explore-grid,.dp-body,.dp-info-grid,.dp-editor-grid,.dp-editor-media,.dp-social-grid,.dp-extra-card,.status-shop-grid,.privilege-grid,.album-grid,.album-submissions,.album-mod-card,.anim-admin-create{grid-template-columns:minmax(0,1fr)!important}
  .post-head{grid-template-columns:44px minmax(0,1fr)}
  .post-time{grid-column:2}
  .post,.pad{padding:12px}
  .chat-line-head{gap:8px}
  .chat-line-actions{justify-content:flex-start}
  .dm{max-width:95%}
  .chat-compose{flex-wrap:wrap}
  .chat-compose>div:first-child{flex-basis:100%}
  .chat-compose button{margin-left:auto}
  .dp-identity-row{grid-template-columns:minmax(0,1fr)!important}
  .dp-stats{grid-template-columns:minmax(0,1fr)!important}
  .dp-cover-brand{grid-template-columns:minmax(0,1fr)!important;gap:0!important}
  .dp-cover-brand-main{max-width:100%!important}
  .dp-editor-sheet{width:100%;padding:14px}
  .topbar{height:auto;min-height:64px;gap:8px;flex-wrap:wrap;padding:10px}
  .me-chip{max-width:100%;overflow-wrap:anywhere}
  .explore-user-identity{grid-template-columns:68px minmax(0,1fr)}
  .explore-actions{display:flex!important;flex-wrap:wrap}
  .explore-actions button{flex:1 1 100%;width:100%}
  .legal-intro{grid-template-columns:minmax(0,1fr);gap:10px}
  .legal-intro img{max-height:230px}
  .legal-page{padding:20px 16px 40px}
  .auth{padding:16px 10px 85px}
  .auth-card{padding:18px;min-width:0}
  .list-item>div{min-width:0;max-width:100%;flex-wrap:wrap}
}

/* Personalizacion existente y vista previa: mismos estilos que el perfil. */
.dp-editor{--dp-accent:#b44aff}
.dementia-profile-page.accent-red{--dp-accent:#ff4545}
.dementia-profile-page.accent-ice{--dp-accent:#9de8ff}
.dementia-profile-page.accent-lime{--dp-accent:#b7ff39}
.dementia-profile-page.accent-gold{--dp-accent:#ffd04c}
.profile-live-preview{margin:16px 0;border:1px solid var(--dp-accent);border-radius:14px;overflow:hidden;min-width:0}
.profile-live-preview .dp-cover{height:86px;min-height:0;margin:0;border-radius:0}
.profile-live-preview .preview-identity{display:flex;align-items:center;gap:18px;padding:16px;overflow-wrap:anywhere;min-width:0}
.profile-live-preview .preview-identity strong{min-width:0}
.profile-live-preview .dp-avatar{width:72px;height:72px;flex:0 0 72px;margin:0}
.profile-live-preview .dp-avatar .avatar{width:100%;height:100%;object-fit:cover}
.profile-live-preview .dp-about-card{margin:0 12px 12px;padding:14px;white-space:pre-wrap;overflow-wrap:anywhere}
#recoveryHelpDialog{max-width:min(540px,90vw);max-height:85dvh;overflow:auto}
#recoveryHelpDialog button{margin-top:12px}
/* Single layout owner. The drawer never occupies a mobile grid column. */
.app{width:100%;grid-template-columns:250px minmax(0,1fr);isolation:isolate}
.main{width:100%;min-width:0}
.view{width:calc(100% - 32px);max-width:960px;margin:24px auto 90px;min-width:0}
.forum-list,.forum-replies{display:grid;grid-template-columns:minmax(0,1fr);gap:14px}
.forum-list>.thread,.forum-thread-detail,.forum-reply,.forum-reply-box{width:100%;margin:0;padding:18px;background:#0d0913;position:relative;overflow:visible}
.forum-head-row{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.forum-head-row>div:first-child{flex:1 1 220px}
.forum-actions,.forum-react-buttons{display:flex;flex-wrap:wrap;gap:8px}
.forum-react{border-top:1px solid #38204d;margin-top:14px;padding-top:12px}
.forum-react small{display:block;margin-bottom:10px}
.forum-react button[aria-pressed=true]{border-color:#da8bff;background:#402052}
.app:not(.hidden)::before{z-index:-1!important}
@media(max-width:850px){
 .app{display:block;grid-template-columns:minmax(0,1fr)}
 .sidebar{position:fixed!important}
 .menu-btn{display:block}
 .view{width:calc(100% - 24px);margin:16px auto 80px}
 .forum-list>.thread,.forum-thread-detail,.forum-reply,.forum-reply-box{padding:14px}
}
.recovery-code{font-size:24px;letter-spacing:.18em;text-align:center}
.emonick-editor{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;max-width:1400px}
.emonick-editor>h2,.emonick-editor>p,.emonick-toolbar,.emonick-editor>.emonick-footer,.emonick-editor>#enFontsAdmin{grid-column:1}
.emonick-editor>h2{margin-bottom:0}.emonick-editor>p{margin-top:0;margin-bottom:2px}
.emonick-toolbar{display:flex;flex-wrap:wrap;gap:8px;padding:8px;border:1px solid #49315b;border-radius:12px;background:#120b1c;position:sticky;top:8px;z-index:2}
.emonick-tool{border:1px solid #5d3974;border-radius:9px;background:#1b1028;color:#eee0ff;padding:10px 13px;cursor:pointer;font-weight:700}
.emonick-tool:hover,.emonick-tool.active{background:#8c24e8;color:#fff;border-color:#c56aff;box-shadow:0 0 12px #8c24e866}
.emonick-workspace{display:grid;grid-template-columns:minmax(270px,340px) minmax(0,1fr);gap:16px;align-items:start;min-width:0}
.emonick-controls{grid-column:1;min-width:0;max-height:calc(100dvh - 270px);overflow:auto;padding-right:4px;margin:0}
.emonick-controls fieldset{min-width:0;border:1px solid #49315b;border-radius:12px;padding:14px;display:grid;gap:10px;margin:0}
.emonick-controls fieldset[hidden]{display:none!important}
.emonick-editor label{display:grid;gap:6px;font-size:14px}
.emonick-stage{grid-column:2;min-width:0;position:sticky;top:68px;align-self:start}
.emonick-stage>.emonick-preview{aspect-ratio:10/3;min-height:220px;max-height:calc(100dvh - 360px);display:grid;place-items:center}
.emonick-stage>.emonick-preview canvas{width:100%;height:100%;max-height:none;object-fit:contain}
.emonick-playbar{display:flex;align-items:center;gap:10px;min-height:42px;margin-top:10px}
.emonick-playbar #enInfo{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.emonick-editor>.emonick-footer{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.emonick-editor .emonick-controls .emonick-preview{min-height:0;background:repeating-conic-gradient(#372d43 0% 25%,#20192c 0% 50%) 0 0/20px 20px}
.emonick-editor .emonick-controls .emonick-preview canvas{min-height:0}
.emonick-editor .hint{display:block;color:#a79dac;line-height:1.35}
.emonick-preview{background:repeating-conic-gradient(#372d43 0% 25%,#20192c 0% 50%) 0 0/20px 20px;border-radius:12px;overflow:hidden}
.emonick-preview canvas{width:100%;height:auto;display:block;touch-action:none}
.emonick-font-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:12px 0;border-bottom:1px solid #34203e}
.emonick-font-row span{flex:1 1 200px}
@media(max-width:800px){.emonick-workspace{grid-template-columns:minmax(0,1fr)}.emonick-controls{grid-column:1;grid-row:2;max-height:none;overflow:visible;padding-right:0}.emonick-stage{grid-column:1;grid-row:1;position:static}.emonick-stage>.emonick-preview{aspect-ratio:10/3;min-height:180px;max-height:45vh}.emonick-toolbar{position:static}.emonick-playbar{margin-bottom:4px}}

/* El generador es una mesa de trabajo: ocupa todo el lienzo disponible y no hereda el ancho público del resto de vistas. */
.view.emonick-view{width:100%;max-width:none;margin:0;padding:16px;min-height:calc(100dvh - 72px)}
.view.emonick-view .emonick-editor{width:100%;max-width:none;min-height:calc(100dvh - 104px);margin:0}
.app:has(.emonick-view)::before{display:none!important}
.view.emonick-view .emonick-workspace{grid-template-columns:minmax(300px,360px) minmax(0,1fr);min-height:0}
.view.emonick-view .emonick-stage{min-width:0}
.view.emonick-view .emonick-stage>.emonick-preview{width:100%;min-height:clamp(300px,calc(100dvh - 360px),680px);max-height:none}
.view.emonick-view .emonick-stage>.emonick-preview canvas{max-height:100%;object-fit:contain}
@media(max-width:800px){.view.emonick-view{padding:10px}.view.emonick-view .emonick-editor{min-height:0}.view.emonick-view .emonick-workspace{grid-template-columns:minmax(0,1fr)}}
.habitants-form{display:grid;gap:12px;border-top:1px solid #59376b;margin-top:20px;padding-top:20px}
.habitants-form label{display:block;margin:10px 0}
/* v2 revision R2: viewport dialogs, live preview and one-target moderation. */
dialog.dp-editor{display:none;position:fixed;inset:0;margin:auto;padding:0;width:min(920px,calc(100vw - 24px));max-width:none;height:min(850px,calc(100vh - 32px));height:min(850px,calc(100dvh - 32px));max-height:none;background:#0b0810;color:#f4eff9;border:1px solid #624077;border-radius:18px;overflow:hidden;box-shadow:0 25px 90px #000b}
dialog.dp-editor[open]{display:block}
dialog.dp-editor::backdrop{background:#000b;backdrop-filter:blur(5px)}
dialog.dp-editor .dp-editor-sheet{width:100%;height:100%;max-height:none;padding:0;display:flex;flex-direction:column;border:0;overflow:hidden;border-radius:0}
.dp-editor-head{flex:none;padding:16px 20px;margin:0;border-bottom:1px solid #3b284b;background:#100a18}
.dp-editor-head>div{min-width:0}.dp-editor-head button{flex:none}
.dp-editor-body{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:18px 20px;scrollbar-gutter:stable}
.dp-editor-sheet>.dp-editor-actions{flex:none;margin:0;padding:14px 20px;gap:12px;align-items:center;border-top:1px solid #3b284b;background:#100a18}
#profileSaveStatus{flex:1 1 180px;font-size:13px;overflow-wrap:anywhere}
.profile-preview-wrap{margin-bottom:18px}.profile-live-preview{margin:8px 0;background:#0c0813;width:100%}
.profile-live-preview .dp-cover{height:70px;min-height:70px}.profile-live-preview .dp-about-card{max-height:96px;overflow:auto}
.profile-live-preview .name-gif{width:auto;max-width:100%;max-height:68px;object-fit:contain}
.profile-live-preview .preview-identity{padding:12px;gap:14px}.profile-live-preview .dp-avatar{border-radius:50%;border:2px solid var(--dp-accent)}
code.recovery-code{display:flex!important;align-items:center;justify-content:center;width:min(100%,360px);min-height:100px;margin:20px auto;padding:14px 18px!important;font-size:clamp(32px,7vw,48px)!important;font-family:ui-monospace,monospace;font-weight:800;line-height:1.2;letter-spacing:.18em;text-indent:.18em;white-space:nowrap;text-align:center!important;background:#09050f;border:2px solid #b84fff;border-radius:16px;user-select:all;color:#fff;overflow:visible}
#recoveryDialog{width:min(540px,calc(100vw - 24px));max-height:calc(100dvh - 24px);padding:24px;overflow:auto}
#recoveryDialog form{display:inline-block;margin:12px 0 0 8px}.sidebar{overflow-y:auto;overscroll-behavior:contain}.sidebar-foot{padding-top:18px}
#adminUserSelect,#adminUserSearch{width:100%;margin:8px 0 12px}#adminUserList{margin-top:16px}#adminUserList:empty{display:none}
.privilege-admin{min-width:0}.privilege-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.privilege-card{min-width:0}
.badge-tier{border:1px solid #aa8340;background:#35270f;color:#ffda83}
.forum-list .thread{box-sizing:border-box;min-width:0;max-width:100%}.forum-head-row h3,.forum-thread-detail h2,.forum-list p,.forum-thread-detail p,.forum-reply p{overflow-wrap:anywhere;white-space:pre-wrap}
.forum-head-row>div{min-width:0}.forum-react-buttons button{min-height:42px}.forum-cover{display:block;width:100%;height:auto;max-height:440px;object-fit:contain}
@media(max-width:600px){
 dialog.dp-editor{width:calc(100vw - 16px);height:calc(100vh - 16px);height:calc(100dvh - 16px);border-radius:12px}
 .dp-editor-head,.dp-editor-body,.dp-editor-sheet>.dp-editor-actions{padding:12px}
 .dp-editor-head h3{font-size:18px}.profile-live-preview .preview-identity{gap:10px}
 .privilege-grid{grid-template-columns:minmax(0,1fr)}
 #recoveryDialog{padding:18px}code.recovery-code{min-height:92px;padding:12px!important}
}

.deployment-warning{margin:0;padding:12px;background:#53202b;color:white;text-align:center;font-weight:bold;position:relative;z-index:10000}

/* v2.1 — account management: target, action, confirmation. */
.ha-panel{min-width:0;overflow-wrap:anywhere}
.ha-panel [hidden]{display:none!important}
.ha-panel label{display:block;margin:12px 0 6px}

/* v2.1 editor layout: keep the live result visible while editing. */
dialog.dp-editor{width:min(1180px,calc(100vw - 32px));height:min(900px,calc(100dvh - 24px))}
dialog.dp-editor .dp-editor-body{display:grid;grid-template-columns:minmax(0,1.08fr) minmax(360px,.92fr);gap:20px;align-content:start;overflow:auto}
dialog.dp-editor .dp-editor-body>*:not(.profile-preview-wrap){grid-column:1;min-width:0}
dialog.dp-editor .dp-editor-body>.profile-preview-wrap{grid-column:2;grid-row:1 / span 6;position:sticky;top:0;align-self:start;margin:0;min-width:0}
dialog.dp-editor .profile-live-preview{min-height:310px;max-height:calc(100dvh - 180px);overflow:auto;border:1px solid #624077;border-radius:14px;padding:10px}
dialog.dp-editor .profile-preview-wrap small{display:block;margin-top:8px;color:#a79dac}
@media(max-width:800px){
  dialog.dp-editor{width:calc(100vw - 16px);height:calc(100dvh - 16px)}
  dialog.dp-editor .dp-editor-body{display:flex;flex-direction:column;overflow:auto}
  dialog.dp-editor .dp-editor-body>.profile-preview-wrap{order:-1;position:relative;top:auto}
  dialog.dp-editor .profile-live-preview{max-height:none;min-height:220px}
}
.ha-target{margin:20px 0;padding:16px;border:1px solid #744395;border-radius:14px;background:#160c21}
.ha-target h3{margin:6px 0}.ha-target small{font-size:.85em}.ha-target p{margin:6px 0}
.ha-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.ha-action{display:flex;flex-direction:column;align-items:flex-start;gap:8px;text-align:left;padding:16px;white-space:normal;min-width:0}
.ha-action span{font-size:.88rem;line-height:1.45;font-weight:400}
.ha-action:disabled{opacity:.55;cursor:not-allowed}
.ha-confirm-target,.ha-summary{padding:12px;border-radius:10px;background:#21132d}
.ha-dates{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.habitants-form fieldset{min-width:0;border:1px solid #59376b;border-radius:10px;padding:12px}
.habitants-form .ha-check{display:flex;align-items:center;gap:10px}
.habitants-form .ha-check input{width:auto;flex:0 0 auto}
.habitants-form .field{width:100%;min-width:0;box-sizing:border-box}
@media(max-width:600px){.ha-actions,.ha-dates{grid-template-columns:minmax(0,1fr)}.ha-panel{padding:14px}.habitants-form .composer-row button{max-width:100%;white-space:normal}}

.ha-auth{box-sizing:border-box;width:min(480px,calc(100vw - 24px));max-height:calc(100dvh - 32px);overflow:auto;margin:auto;padding:22px;border:1px solid #744395;border-radius:16px;background:#100a19;color:#eee8f4;overflow-wrap:anywhere}
.ha-auth::backdrop{background:#000b}
.ha-auth .field{display:block;width:100%;min-width:0;box-sizing:border-box;margin:10px 0}
.ha-auth .composer-row{display:flex;flex-wrap:wrap;gap:10px}
