:root {
  --bg: #f5f3f8; --panel: #fff; --texto: #231f33; --suave: #6e6a80; --borde: #e4e0ec;
  --prim: #7c4dff; --prim-osc: #5f35d6; --prim-suave: #efe9ff; --ok: #1fa463; --wa: #25d366;
  --radio: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15131c; --panel: #1f1c29; --texto: #f0eef6; --suave: #a7a2ba; --borde: #34304a; --prim-suave: #2c2547; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Nunito", system-ui, sans-serif; background: var(--bg); color: var(--texto); font-size: 15px; }
[hidden] { display: none !important; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -.01em; white-space: nowrap; }
.logo i { font-family: "Great Vibes", cursive; font-style: normal; font-weight: 400; font-size: 26px; color: var(--prim); }

button, .b-archivo { font: inherit; cursor: pointer; }
.b-prim { background: var(--prim); color: #fff; border: none; border-radius: 999px; padding: 10px 20px; font-weight: 800; }
.b-prim:hover { background: var(--prim-osc); }
.b-prim:disabled { opacity: .6; cursor: wait; }
.b-sec { background: transparent; color: var(--texto); border: 1.5px solid var(--borde); border-radius: 999px; padding: 9px 16px; font-weight: 700; }
.b-link { background: none; border: none; color: var(--prim); font-weight: 700; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }
.b-wa { display: block; text-align: center; background: var(--wa); color: #fff; border-radius: 999px; padding: 12px; font-weight: 800; text-decoration: none; margin: 12px 0 4px; }
.b-archivo { display: inline-block; background: var(--prim-suave); color: var(--prim); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 14px; }

/* Acceso */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #f1ebff, #fde8f1); }
@media (prefers-color-scheme: dark) { .acceso { background: linear-gradient(160deg, #1d1730, #2a1624); } }
.acceso-caja { background: var(--panel); border-radius: 24px; padding: 32px 26px; max-width: 400px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(60,30,120,.15); }
.acceso h1 { font-size: 24px; margin: 18px 0 6px; }
.acceso p { color: var(--suave); margin: 0 0 18px; }
.acceso input { width: 100%; font: inherit; font-size: 18px; text-align: center; letter-spacing: .1em; padding: 14px; border-radius: 12px; border: 1.5px solid var(--borde); background: var(--bg); color: var(--texto); margin-bottom: 12px; text-transform: uppercase; }
.acceso .b-prim { width: 100%; padding: 14px; font-size: 16px; }
.error { color: #d93025 !important; margin-top: 12px !important; }

/* Barra */
.barra { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--borde); }
.barra-acciones { margin-left: auto; display: flex; gap: 8px; }
.pestanas { display: none; }

/* Cuerpo */
.cuerpo { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 0; height: calc(100vh - 61px); }
.panel { overflow-y: auto; padding: 18px 20px 60px; border-right: 1px solid var(--borde); background: var(--panel); }
.paso { border: 1px solid var(--borde); border-radius: var(--radio); padding: 4px 16px 16px; margin-bottom: 12px; background: var(--panel); }
.paso summary { list-style: none; cursor: pointer; }
.paso summary::-webkit-details-marker { display: none; }
.paso summary h2::after { content: "▾"; margin-left: auto; color: var(--suave); transition: transform .2s; }
.paso:not([open]) summary h2::after { transform: rotate(-90deg); }
.paso h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 12px 0; }
.paso h2 span { width: 26px; height: 26px; border-radius: 50%; background: var(--prim); color: #fff; display: grid; place-items: center; font-size: 13px; flex: none; }
label { display: grid; gap: 5px; font-weight: 700; font-size: 13px; color: var(--suave); margin-top: 12px; }
label small, .et small { font-weight: 400; }
input:not([type=radio]):not([type=checkbox]):not([type=file]), textarea {
  font: inherit; font-size: 15px; color: var(--texto); background: var(--bg); border: 1.5px solid var(--borde); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--prim); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
fieldset { border: none; padding: 0; margin: 14px 0 0; }
fieldset + fieldset { border-top: 1px dashed var(--borde); padding-top: 14px; }
legend, .et { display: flex; align-items: center; gap: 8px; width: 100%; font-weight: 800; font-size: 14px; color: var(--texto); padding: 0; margin: 0 0 4px; }
.et { margin: 12px 0 8px; }

/* Interruptor */
.sw { margin-left: auto; position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.sw i { position: absolute; inset: 0; background: var(--borde); border-radius: 999px; transition: .2s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::after { transform: translateX(18px); }
.sw input:focus-visible + i { outline: 2px solid var(--prim); outline-offset: 2px; }

/* Plantillas */
.plantillas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.pl { margin: 0; cursor: pointer; text-align: center; }
.pl input { position: absolute; opacity: 0; }
.pl-muestra { display: grid; place-items: center; aspect-ratio: 3/4; border-radius: 12px; border: 3px solid transparent; transition: .15s; }
.pl-muestra b { font-size: 26px; }
.pl-nombre { display: block; margin-top: 6px; font-size: 12px; color: var(--texto); }
.pl input:checked + .pl-muestra { border-color: var(--prim); box-shadow: 0 0 0 3px var(--prim-suave); }
.pl input:focus-visible + .pl-muestra { outline: 2px solid var(--prim); outline-offset: 2px; }
.pl-xv .pl-muestra { background: radial-gradient(circle at 50% 30%, #26304f, #0f1424); }
.pl-xv b { font-family: "Great Vibes", cursive; font-weight: 400; font-size: 34px; color: #e7c873; }
.pl-boda .pl-muestra { background: #eef0e6; }
.pl-boda b { font-family: "Great Vibes", cursive; font-weight: 400; font-size: 28px; color: #55704b; }
.pl-inf .pl-muestra { background: linear-gradient(160deg, #4cc9f0, #7b61ff); }

/* Subidas */
.subida { padding: 4px 0 12px; border-bottom: 1px dashed var(--borde); }
.subida:last-child { border-bottom: none; }
.miniaturas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.miniaturas figure { position: relative; margin: 0; }
.miniaturas img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; display: block; }
.miniaturas button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: #231f33; color: #fff; font-size: 14px; line-height: 1; }
.archivo-musica { margin: 0 0 8px; color: var(--suave); }
.ayuda { color: var(--suave); font-size: 13px; margin: 10px 0 0; word-break: break-all; }
.guardado { text-align: center; }

/* Vista previa */
.vista { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; overflow: hidden; }
.telefono { width: 390px; height: min(800px, calc(100vh - 140px)); border-radius: 44px; padding: 12px; background: #111; box-shadow: 0 30px 80px rgba(30,10,80,.25); }
.telefono iframe { width: 100%; height: 100%; border: none; border-radius: 34px; background: #fff; }

/* Diálogos */
.dlg { border: none; border-radius: 20px; padding: 26px; width: min(440px, calc(100vw - 32px)); background: var(--panel); color: var(--texto); }
.dlg::backdrop { background: rgba(20,10,40,.5); }
.dlg h2 { margin: 0 0 8px; }
.dlg p { color: var(--suave); }
.enlace { display: flex; gap: 8px; }
.enlace input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--borde); background: var(--bg); color: var(--texto); }
.privado { margin: 14px 0; padding: 12px; background: var(--bg); border-radius: 12px; }
.privado summary { font-weight: 800; cursor: pointer; }
.cerrar { width: 100%; margin-top: 10px; }
#dlg-pub .b-link { display: block; text-align: center; }
.lista { list-style: none; padding: 0; margin: 0 0 14px; max-height: 50vh; overflow: auto; }
.lista li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.lista li div { flex: 1; display: grid; }
.lista small { color: var(--suave); }
.lista a { color: var(--prim); font-weight: 800; text-decoration: none; }
.lista .vacio { color: var(--suave); }
#btn-nueva { width: 100%; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #231f33; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 100; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }

/* Móvil: pestañas Editar / Vista previa */
@media (max-width: 860px) {
  .barra { flex-wrap: wrap; padding: 10px 16px; }
  .pestanas { display: flex; order: 3; width: 100%; background: var(--bg); border-radius: 999px; padding: 3px; }
  .pestanas button { flex: 1; border: none; background: none; padding: 8px; border-radius: 999px; font-weight: 800; color: var(--suave); }
  .pestanas button.activa { background: var(--panel); color: var(--texto); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
  #btn-mis { display: none; }
  .cuerpo { display: block; height: auto; }
  .panel { border-right: none; padding: 14px 16px 80px; }
  .vista { display: none; padding: 12px 16px; }
  body[data-vista="ver"] .panel { display: none; }
  body[data-vista="ver"] .vista { display: flex; }
  .telefono { width: 100%; max-width: 390px; height: calc(100vh - 170px); padding: 8px; border-radius: 36px; }
  .telefono iframe { border-radius: 28px; }
}
