:root {
  --bg: #121419;
  --panel: #1a1d25;
  --panel2: #212530;
  --border: #2c313e;
  --text: #e7e9ef;
  --muted: #8b93a5;
  --accent: #6d8dff;
  --accent-d: #3f5bd0;
  --danger: #ff6b6b;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden; overflow-y: auto;
}
/* La aplicación ocupa toda la ventana; el contenido informativo queda debajo */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Controles base ---------- */
button, .btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
button:hover:not(:disabled), .btn:hover { background: #2a2f3d; border-color: #3b4252; }
button:disabled { opacity: .4; cursor: default; }
button.primary, .btn.primary { background: #4a68e0; border-color: #4a68e0; color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.danger { color: var(--danger); }
button.small { padding: 4px 8px; font-size: 12px; }
button.icon { padding: 6px 9px; min-width: 32px; }
button.play { min-width: 40px; }
input[type=text], input[type=number], select, textarea {
  background: #11141a; color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 7px; font: inherit; width: 100%;
}
input[type=number] { -moz-appearance: textfield; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input[type=color] { width: 100%; height: 30px; padding: 2px; background: #11141a; border: 1px solid var(--border); border-radius: 6px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
textarea { resize: vertical; }
label { color: var(--muted); }
.sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.spacer, .grow { flex: 1; }
.muted { color: var(--muted); }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; margin-right: 8px; display: flex; align-items: center; gap: 8px; }
.logo { background: linear-gradient(135deg, #4a68e0, #8a4fd6); color: #fff; padding: 2px 7px; border-radius: 6px; font-size: 12px; letter-spacing: 1px; }
.hint-top { color: var(--muted); font-size: 12px; margin-right: 6px; }

/* ---------- Estructura ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.work { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side { width: 330px; border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; }

/* ---------- Escenario ---------- */
.stage { flex: 1; min-height: 0; display: flex; overflow: auto; position: relative; background: #0d0f13; }
.wrap { margin: auto; position: relative; padding: 20px; flex: none; }
.wrap canvas { display: block; }
#view {
  background:
    conic-gradient(#2a2e38 25%, #20232c 0 50%, #2a2e38 0 75%, #20232c 0) 0 0 / 16px 16px;
  box-shadow: 0 6px 30px rgba(0,0,0,.5);
}
#view.pixel { image-rendering: pixelated; }
#ui { position: absolute; left: 0; top: 0; touch-action: none; }
body:not(.has-gif) .wrap { display: none; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
body.has-gif .empty { display: none; }
.empty-card {
  pointer-events: auto; text-align: center; padding: 36px 44px; max-width: 460px;
  border: 2px dashed #3a4153; border-radius: 16px; background: rgba(26,29,37,.6);
}
.empty-card .big { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.empty-card p { color: var(--muted); margin: 0 0 18px; }

/* ---------- Transporte y herramientas ---------- */
.transport, .frametools {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--panel); border-top: 1px solid var(--border); flex-wrap: wrap;
}
.frametools { padding: 6px 12px; border-top: 1px solid var(--border); gap: 6px; }
.frametools label { display: inline-flex; align-items: center; gap: 5px; }
.frametools input[type=number] { width: 64px; }
#scrub { flex: 1; min-width: 120px; }
.counter { min-width: 92px; text-align: center; color: var(--text); font-variant-numeric: tabular-nums; }
.zoomlabel { min-width: 44px; text-align: center; color: var(--muted); }
#speedSel { width: auto; }
body:not(.has-gif) .transport, body:not(.has-gif) .frametools, body:not(.has-gif) .timeline { filter: grayscale(1) brightness(.7); pointer-events: none; }

/* ---------- Línea de tiempo ---------- */
.timeline {
  display: flex; gap: 8px; padding: 10px 12px 12px; overflow-x: auto; overflow-y: hidden;
  background: #15181f; border-top: 1px solid var(--border); min-height: 118px; align-items: flex-start;
}
.thumb {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; user-select: none;
  background: var(--panel);
}
.thumb:hover { border-color: #3b4252; }
.thumb.active { border-color: var(--accent); background: #232a44; }
.thumb.dragover { border-color: #fff; }
.thumb canvas {
  display: block; border-radius: 4px;
  background: conic-gradient(#2a2e38 25%, #20232c 0 50%, #2a2e38 0 75%, #20232c 0) 0 0 / 10px 10px;
}
.thumb .n { font-size: 11px; font-weight: 600; }
.thumb .d { font-size: 10px; color: var(--muted); margin-top: -3px; }

/* ---------- Panel lateral ---------- */
.panel { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-h { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: #b7bdcc; }
.field { margin-bottom: 8px; }
.field > label { display: block; font-size: 11px; margin-bottom: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.row.center { justify-content: center; }
.row.spaced, .chk.spaced { margin-top: 10px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.subhead { margin: 14px 0 8px; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #b7bdcc; border-top: 1px solid var(--border); padding-top: 10px; }
.small-note { font-size: 11px; margin-top: 4px; }
.readout { padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; background: #11141a; color: var(--muted); }
.follow {
  display: flex; gap: 8px; padding: 9px 10px; margin-bottom: 12px; cursor: pointer;
  background: #1f2640; border: 1px solid #36427a; border-radius: var(--radius); color: var(--text);
}
.follow small { color: #9fa9d4; }
.follow input { margin-top: 3px; }
.help ul { margin: 0; padding-left: 16px; color: var(--muted); font-size: 12px; }
.help li { margin-bottom: 4px; }
.help b { color: var(--text); }

/* ---------- Lista de capas ---------- */
.layers { display: flex; flex-direction: column; gap: 4px; }
.layer-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel2); cursor: pointer;
}
.layer-item.sel { border-color: var(--accent); background: #232a44; }
.layer-item canvas {
  width: 30px; height: 30px; border-radius: 4px; flex: none;
  background: conic-gradient(#2a2e38 25%, #20232c 0 50%, #2a2e38 0 75%, #20232c 0) 0 0 / 8px 8px;
}
.layer-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item.off .nm { opacity: .45; text-decoration: line-through; }
.layer-item button { padding: 2px 6px; background: transparent; border-color: transparent; color: var(--muted); }
.layer-item button:hover { color: var(--text); }

/* ---------- Modal / avisos ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,6,9,.72); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px; width: min(560px, 92vw); max-height: 92vh; overflow: auto; }
.modal-card h3 { margin: 0 0 14px; }
.bar { height: 10px; background: #0f1116; border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6d8dff, #b46dff); transition: width .1s; }
.result-preview {
  display: flex; justify-content: center; margin-bottom: 10px; padding: 10px; border-radius: 10px;
  background: conic-gradient(#2a2e38 25%, #20232c 0 50%, #2a2e38 0 75%, #20232c 0) 0 0 / 16px 16px;
}
.result-preview img { max-width: 100%; max-height: 50vh; }
.center { text-align: center; }
#modalProgress .row, #modalResult .row { margin-top: 14px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #2b3145; border: 1px solid #44507a; padding: 9px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: 80vw;
}
.dropveil { position: fixed; inset: 0; z-index: 70; background: rgba(109,141,255,.22); border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; pointer-events: none; }

@media (max-width: 900px) {
  .main { flex-direction: column; }
  .side { width: auto; max-height: 45vh; border-left: 0; border-top: 1px solid var(--border); }
}

/* ---------- Ampliaciones ---------- */
details.panel > summary.panel-h { cursor: pointer; list-style: none; margin-bottom: 0; user-select: none; }
details.panel > summary.panel-h::-webkit-details-marker { display: none; }
details.panel > summary.panel-h::before { content: "▸"; display: inline-block; width: 14px; transition: transform .15s; }
details.panel[open] > summary.panel-h::before { transform: rotate(90deg); }
details.panel[open] > summary.panel-h { margin-bottom: 10px; }
.timeline-hint { padding: 3px 12px; font-size: 11px; color: var(--muted); background: #15181f; border-top: 1px solid var(--border); }
.thumb { position: relative; }
.thumb.multi { border-color: #8fa5ff; background: #26305a; }
.thumb .kf { display: none; position: absolute; top: 5px; right: 6px; font-size: 11px; font-style: normal; color: #ffd24a; text-shadow: 0 1px 2px #000; pointer-events: none; }
.thumb.has-kf .kf { display: block; }
.multi-info { margin-bottom: 10px; padding: 8px 10px; border-radius: 8px; background: #1b2338; border: 1px solid #36427a; color: #bcc8f5; }
.align-row button { min-width: 34px; }
.layer-item.sel2 { border-color: #8fa5ff; background: #232a44; }
.layer-item.primary { box-shadow: inset 3px 0 0 var(--accent); }
.modal-card .grid2 { margin-bottom: 10px; }
.result-preview video, .result-preview img { max-width: 100%; max-height: 50vh; }
select { cursor: pointer; }

#langSel { width: auto; padding: 5px 8px; }

.layer-item button.del:hover { color: var(--danger); }


/* ---------- SEO: enlace, contenido informativo y noscript ---------- */
.brand { color: inherit; text-decoration: none; }
.noscript { background: #3a2a10; color: #ffd27a; padding: 10px 14px; text-align: center; }
.seo-link {
  display: block; text-align: center; padding: 4px 8px; font-size: 12px;
  color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); text-decoration: none;
}
.seo-link:hover { color: var(--text); }
.seo { background: var(--bg); border-top: 1px solid var(--border); padding: 48px 20px 24px; }
.seo article, .seo-foot { max-width: 980px; margin: 0 auto; }
.seo h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; }
.seo h2 { font-size: 21px; margin: 40px 0 14px; }
.seo h3 { font-size: 15px; margin: 0 0 6px; }
.seo p, .seo li { font-size: 14px; line-height: 1.6; color: #c3c8d4; }
.seo .lead { font-size: 16px; color: var(--text); max-width: 760px; }
.seo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.seo-grid section { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.seo-grid p { margin: 0; }
.seo-steps { padding-left: 22px; }
.faq h3 { margin-top: 18px; }
.faq p { margin: 0; max-width: 820px; }
.seo-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.seo-foot a { color: var(--accent); text-decoration: none; }

/* ---------- Aviso de idioma (versión española, navegador en otro idioma) ---------- */
.langbar {
  position: fixed; left: 14px; bottom: 14px; z-index: 65; display: flex; align-items: center; gap: 8px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: calc(100vw - 28px);
}

/* ---------- Publicidad (solo visible si está configurada) ---------- */
.ad-box { margin: 28px auto 0; max-width: 728px; text-align: center; }
.ad-box[hidden] { display: none !important; }
.ad-box:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { display: block; margin-bottom: 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.modal .ad-box { margin: 0 0 14px; max-width: 100%; }
.btn.is-wait { opacity: .55; pointer-events: none; cursor: default; }
.seo-foot { flex-wrap: wrap; }
