/* Panel de mods: mismo estilo oscuro y violeta que el editor.
   Distribución: barra arriba · capas (izq.) · vista previa (centro) · inspector (der.) */
:root {
  --accent: #a970ff;
  --danger: #ef6b6b;
  --live: #4cc9a0;
  --edit: #f2b84b;
  --bg: #100e15;
  --surf: #18151f;
  --line: #2a2535;
  --text: #ede9f5;
  --muted: color-mix(in srgb, var(--text) 60%, var(--bg));
  --field: color-mix(in srgb, var(--bg) 55%, var(--surf));
  --raised: color-mix(in srgb, var(--text) 6%, var(--surf));
  --r: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 14px "Segoe UI", system-ui, sans-serif; }
h2, h3 { margin: 0; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.grow { flex: 1; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--text);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.square { width: 28px; padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }
.ic { display: inline-flex; }

/* Varios botones pegados donde se elige uno */
.segmented { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: calc(var(--r) + 2px); background: var(--field); }
.segmented.wrap { flex-wrap: wrap; }
.segmented .btn { border-color: transparent; }
.segmented .btn:not(.primary) { background: transparent; color: var(--muted); }
.segmented .btn:not(.primary):hover { color: var(--text); }

/* ---------- Barra de arriba ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surf); }
.brand { font-family: "Jersey 10", sans-serif; font-size: 23px; line-height: 1; }
.brand b { color: var(--accent); font-weight: 400; }
.brand span { margin-left: 4px; padding: 1px 6px; border-radius: 4px; background: var(--raised); color: var(--muted); font: 600 11px "Segoe UI", sans-serif; text-transform: uppercase; letter-spacing: 0.06em; vertical-align: 2px; }
#mode, .mode { display: flex; align-items: center; gap: 8px; }
.mode .segmented .btn.primary { background: var(--live); border-color: var(--live); color: #0b1f18; }
body.editing .mode .segmented .btn.primary { background: var(--edit); border-color: var(--edit); color: #2a1c00; }
body.editing .topbar { box-shadow: inset 0 -2px 0 var(--edit); }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--raised); color: var(--accent); }
#hello { color: var(--text); font-weight: 600; }

.banner { padding: 8px 16px; background: color-mix(in srgb, var(--danger) 14%, var(--bg)); color: var(--danger); font-size: 13px; }

/* ---------- Distribución ---------- */
.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; gap: 12px; padding: 12px;
}
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surf); border: 1px solid var(--line); border-radius: calc(var(--r) * 1.5); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
.panel-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.panel-title small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.panel-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Columna izquierda: agregar + capas ---------- */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--text);
  font: 12px inherit; font-family: inherit; cursor: pointer;
}
.tool .ic svg { width: 18px; height: 18px; }
.tool:hover { border-color: var(--accent); }
.tool.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.count { padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--muted); font-size: 12px; }
.layer-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: var(--r); cursor: pointer; }
.layer-row:hover { background: var(--raised); }
.layer-row.on { background: color-mix(in srgb, var(--accent) 20%, var(--surf)); }
.layer-row.off .layer-name { color: var(--muted); text-decoration: line-through; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { padding: 16px 6px; color: var(--muted); font-size: 13px; }
.order-bar { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--line); }
.order-bar .hint { flex: 1; }

/* ---------- Centro: vista previa ---------- */
.center { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* Vista previa 16:9: el escenario de 1920 × 1080 adentro se escala con transform (ver mods-items.js) */
.stage-box {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r);
  background: repeating-conic-gradient(#1b1824 0 25%, #15121c 0 50%) 0 0 / 24px 24px;
}
.stage-box .mods-item { cursor: grab; outline-offset: 4px; touch-action: none; } /* touch-action: arrastrar en celular sin mover la página */
.stage-box .mods-item:active { cursor: grabbing; }
.stage-box .mods-item.selected { outline: 4px dashed var(--accent); }
.stage-box .mods-item.off { opacity: 0.35; }
.stage-box.drawing { cursor: crosshair; outline: 2px solid var(--accent); outline-offset: 2px; }
.draw-canvas { position: absolute; inset: 0; width: 1920px; height: 1080px; touch-action: none; }
.under-stage { min-height: 44px; display: flex; align-items: center; }
/* Líneas guía del imán (dentro del escenario de 1920 × 1080, por eso son gruesas: se ven escaladas) */
.snap-guide { position: absolute; background: #ff4f9a; pointer-events: none; z-index: 5; }
.snap-guide.vertical { top: 0; bottom: 0; width: 3px; margin-left: -1px; }
.snap-guide.horizontal { left: 0; right: 0; height: 3px; margin-top: -1px; }

/* Barra de dibujo (debajo de la vista previa) */
.draw-toolbar {
  flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px;
  background: var(--surf); border: 1px solid var(--accent); border-radius: var(--r);
}
.draw-size { width: 160px; }
.toolbar-sep { width: 1px; height: 20px; background: var(--line); }

/* ---------- Derecha: inspector ---------- */
.inspector { overflow: hidden; }
.inspector .panel-head { border-bottom: 1px solid var(--line); }
.inspector .empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: var(--muted); text-align: center; }
.inspector .empty .ic svg { width: 28px; height: 28px; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab {
  padding: 7px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font: 600 13px inherit; font-family: inherit; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline .range { flex: 1; min-width: 120px; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; min-width: 0; accent-color: var(--accent); }
.range em { min-width: 48px; text-align: right; font-style: normal; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.axis { color: var(--muted); font-size: 12px; font-weight: 700; }
.num { width: 72px; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); color: var(--text); font: inherit; }
.scale-pair { display: flex; align-items: center; gap: 8px; }
.scale-rows { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.saved-styles { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-radius: var(--r); background: var(--field); }
.saved-styles select { flex: 1 1 100%; }
.effect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.effect-grid .btn { height: auto; padding: 10px; justify-content: flex-start; text-align: left; white-space: normal; }
.effect-btn { display: flex; flex-direction: column; gap: 2px; }
.effect-btn small { color: color-mix(in srgb, currentColor 70%, transparent); font-size: 11px; }

textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--field); color: var(--text); font: inherit; resize: vertical;
}
select { height: 32px; padding: 0 8px; }
input[type="color"] { width: 36px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); cursor: pointer; }

/* ---------- Mi perfil (ventana) ---------- */
.profile-dialog {
  width: min(720px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: calc(var(--r) * 1.5);
  background: var(--surf); color: var(--text); box-shadow: 0 24px 80px rgb(0 0 0 / 0.6);
}
.profile-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-head > div { flex: 1; }
.dialog-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px; }
.dialog-section { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.dialog-section .field, .dialog-section .range { align-self: stretch; }
.style-list { align-self: stretch; display: flex; flex-direction: column; gap: 4px; }
.style-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: var(--r); background: var(--field); }
.style-sample { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }

/* ---------- Mensajes ---------- */
.locked { grid-column: 1 / -1; max-width: 460px; margin: 60px auto; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { padding: 10px 14px; background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 40px rgb(0 0 0 / 0.45); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---------- Pantallas más chicas ---------- */
/* Notebook: el inspector baja debajo de la vista previa */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .inspector { grid-column: 2; }
}
/* Celular: todo en una columna, la vista previa primero */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .center { order: -1; }
  .inspector { grid-column: auto; }
  /* En una columna la página crece hacia abajo: los paneles ya no se recortan ni tienen su propio scroll */
  .panel, .inspector { min-height: auto; overflow: visible; }
  .tab-body { overflow: visible; }
  .layer-list { flex: none; max-height: 260px; }
  .dialog-body { grid-template-columns: 1fr; }
}

/* ---------- Soundboard y notas (debajo de la vista previa) ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.board-panel { gap: 10px; padding-bottom: 14px; }
.board-panel > :not(.panel-head) { margin: 0 14px; }
.board-panel .panel-head { padding-bottom: 0; }
.board-panel .panel-head .hint { margin-left: auto; }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.sound-btn {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--text);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.sound-btn svg { flex: none; color: var(--accent); }
.sound-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sound-btn:hover:not(:disabled) { border-color: var(--accent); }
.sound-btn:active:not(:disabled) { transform: scale(0.97); }
.sound-btn:disabled { opacity: 0.4; cursor: default; }
.sound-btn.played { animation: sound-played 0.5s ease-out; }
@keyframes sound-played { from { background: color-mix(in srgb, var(--accent) 45%, var(--raised)); } }
.note-add { display: flex; gap: 8px; }
.note-input { flex: 1; min-width: 0; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); color: var(--text); font: inherit; font-size: 13px; }
.notes { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.note { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); }
.note.pinned { border-left: 3px solid var(--accent); }
.note-head { display: flex; align-items: center; gap: 8px; min-height: 24px; font-size: 13px; }
.note p { margin-top: 2px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
