/* ─────────────────────────────────────────────────────────────
   Panel de edición (colores y letras: assets/css/theme.css)
   Mismos colores y letras que la página, pensado para uso diario:
   denso, claro, sin adornos que estorben.
   ───────────────────────────────────────────────────────────── */

:root {
  --linea-2: color-mix(in srgb, var(--corteza) 24%, transparent);
  --ok: #2e6b3a;
  --error: #a4261b;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--sans); color: var(--texto); background: var(--harina); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--brasa); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: color-mix(in srgb, var(--corteza) 7%, transparent); padding: 1px 5px; border-radius: 4px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 8px; background: var(--corteza); color: var(--papel); }
.skip:focus { top: 12px; }
.boot { padding: 80px 20px; text-align: center; color: var(--texto-2); }

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1.5px solid transparent;
  font-size: 14.5px; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--corteza); color: var(--papel); }
.btn--primary:hover:not(:disabled) { background: var(--corteza-2); }
.btn--ghost { background: transparent; border-color: var(--linea-2); color: var(--corteza); }
.btn--ghost:hover:not(:disabled) { border-color: var(--corteza); background: rgba(255, 255, 255, .5); }
.btn--ghost.is-armed { border-color: var(--error); color: var(--error); }
.btn--text { min-height: 36px; padding: 0 6px; background: none; color: var(--texto-2); text-decoration: underline; text-underline-offset: 3px; }
.btn--sm { min-height: 38px; padding: 0 12px; font-size: 13.5px; }
.btn--block { width: 100%; }
.btn:has(input:focus-visible) { outline: 2.5px solid var(--brasa); outline-offset: 2px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 9px; border: 1.5px solid transparent; background: transparent; color: var(--corteza); cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--corteza) 7%, transparent); }
.icon-btn:disabled { opacity: .28; cursor: default; }
.icon-btn--danger:hover:not(:disabled) { color: var(--error); background: #f8e3df; }
.icon-btn.is-armed, .icon-btn.is-armed:hover:not(:disabled) {
  display: inline-flex; align-items: center; width: auto; gap: 6px; padding: 0 10px;
  font-size: 13px; font-weight: 700; white-space: nowrap; color: #fff; background: var(--error);
}

/* ── Acceso ──────────────────────────────────────────────────── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login__card {
  width: min(400px, 100%); padding: 32px 28px 28px; display: grid; gap: 14px;
  background: var(--papel); border: 1.5px solid var(--corteza); border-radius: 22px;
}
.login__arch {
  width: 64px; height: 72px; display: grid; place-items: center; margin-bottom: 4px;
  background: var(--brasa); color: var(--papel); border-radius: 32px 32px 8px 8px;
}
.login__arch svg { width: 28px; height: 28px; }
.login__title { font: 400 28px/1.1 var(--display); }
.login__sub { color: var(--texto-2); }
.login__form { display: grid; gap: 14px; margin-top: 6px; }
.login__help { font-size: 13px; color: var(--texto-2); }
.login .btn { margin-top: 4px; }
.pass { position: relative; }
.pass input { padding-right: 48px; }
.pass__toggle { position: absolute; right: 4px; top: 50%; translate: 0 -50%; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--texto-2); cursor: pointer; border-radius: 8px; }

/* ── Barra superior ──────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--corteza); color: var(--papel);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.topbar__brand strong { display: block; font: 400 18px/1.1 var(--display); }
.topbar__brand small { display: block; font-size: 12px; color: color-mix(in srgb, var(--papel) 72%, var(--corteza)); }
.topbar__mark { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--brasa); font: 400 15px/1 var(--display); }
.topbar__actions { display: flex; gap: 8px; }
.topbar .btn--ghost { border-color: color-mix(in srgb, var(--papel) 30%, transparent); color: var(--papel); }
.topbar .btn--ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--papel) 10%, transparent); border-color: var(--papel); }
.topbar .btn--ghost.is-armed { border-color: var(--trigo); color: var(--trigo); }
.mode { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mode--demo { background: var(--trigo); color: var(--corteza); }
.mode--supabase { background: #d9ead9; color: var(--ok); }
.demo-note { padding: 10px 16px; background: #f6e7c4; color: #5b3d0a; font-size: 13.5px; border-bottom: 1px solid rgba(91, 61, 10, .15); }
.billing-note { padding: 10px 16px; font-size: 13.5px; border-bottom: 1px solid rgba(0, 0, 0, .08); }
.billing-note--info { background: #e6eef6; color: #1d3a57; }
.billing-note--warn { background: #f6e7c4; color: #5b3d0a; }
.billing-note--error { background: #f7dcd8; color: #7a1f14; }

/* ── Distribución ────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.nav { position: sticky; top: 58px; z-index: 10; background: var(--harina); border-bottom: 1px solid var(--linea); overflow-x: auto; scrollbar-width: none; }
.nav ul { display: flex; gap: 4px; padding: 8px 12px; width: max-content; }
.nav__item {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--texto-2); white-space: nowrap;
}
.nav__item:hover { background: color-mix(in srgb, var(--corteza) 6%, transparent); color: var(--corteza); }
.nav__item[aria-current="page"] { background: var(--corteza); color: var(--papel); }
.nav__count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--corteza) 8%, transparent); font-size: 12px; font-weight: 700; text-align: center; }
.nav__item[aria-current="page"] .nav__count { background: color-mix(in srgb, var(--papel) 18%, transparent); }
/* Lista llena según el plan: rojo claro legible también sobre la pestaña activa (oscura) */
.nav__count.is-full,
.nav__item[aria-current="page"] .nav__count.is-full { background: #f7dcd8; color: #7a1f14; }
.editor-area { padding: 20px 16px 120px; outline: none; min-width: 0; }
.preview { display: none; }
@media (max-width: 899px) {
  .topbar { position: static; }
  .nav { top: 0; }
  .topbar__actions .btn { padding: 0 10px; }
}

@media (min-width: 900px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .nav { top: 58px; height: calc(100vh - 58px); border-bottom: 0; border-right: 1px solid var(--linea); overflow: auto; }
  .nav ul { flex-direction: column; width: auto; padding: 16px 12px; }
  .nav__count { margin-left: auto; }
  .editor-area { padding: 28px 32px 120px; }
  .panel { max-width: 720px; }
}
@media (min-width: 1240px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr) 420px; }
  .preview {
    display: flex; flex-direction: column; gap: 10px; align-items: center;
    position: sticky; top: 58px; height: calc(100vh - 58px); padding: 16px 20px;
    border-left: 1px solid var(--linea);
  }
  .preview__head { width: 375px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--texto-2); }
  .preview__phone {
    flex: 1; min-height: 0; width: 375px; max-height: 812px;
    border-radius: 36px; overflow: hidden; background: var(--papel);
    box-shadow: 0 0 0 8px var(--corteza), 0 30px 60px -30px color-mix(in srgb, var(--corteza) 50%, transparent);
  }
  .preview__frame { width: 100%; height: 100%; border: 0; display: block; }
}

/* ── Panel ───────────────────────────────────────────────────── */
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.panel__title { font: 400 32px/1.1 var(--display); letter-spacing: -.01em; }
.panel__intro { margin-top: 6px; max-width: 56ch; color: var(--texto-2); }

.group { margin: 0 0 18px; padding: 18px 18px 6px; border: 1.5px solid var(--linea); border-radius: 16px; background: var(--papel); }
.group__title { padding: 0 6px; margin-left: -6px; font: 400 20px/1 var(--display); }

.savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--harina); border-top: 1px solid var(--linea);
}
.savebar__state { font-size: 13.5px; color: var(--texto-2); }

/* ── Filas de listas ─────────────────────────────────────────── */
.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.rows__empty { padding: 28px; text-align: center; color: var(--texto-2); border: 1.5px dashed var(--linea-2); border-radius: 14px; }
.row { background: var(--papel); border: 1.5px solid var(--linea); border-radius: 14px; transition: border-color .2s var(--ease); }
.row.is-open { border-color: var(--corteza); }
.row.is-off .row__main { opacity: .5; }
.row__bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 6px; }
.row__main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 6px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer;
}
.row__main:hover { background: color-mix(in srgb, var(--corteza) 4%, transparent); }
.row__thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--miga); flex-shrink: 0; }
.row__icon, .row__day { width: 48px; height: 48px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--miga-2); }
.row__day { font: 400 20px/1 var(--display); }
.row__text { min-width: 0; display: flex; flex-direction: column; }
.row__text strong { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__text small { font-size: 13px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__edit { margin-left: auto; color: var(--texto-2); opacity: 0; transition: opacity .2s; }
.row__main:hover .row__edit, .row__main:focus-visible .row__edit, .row.is-open .row__edit { opacity: 1; }
.row__tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.row--new { margin-bottom: 14px; padding-top: 14px; border-color: var(--corteza); }
.row__newtitle { padding: 0 18px; font: 400 20px/1 var(--display); }
@media (max-width: 560px) {
  .row__bar { flex-wrap: wrap; }
  .row__tools { width: 100%; justify-content: flex-end; border-top: 1px solid var(--linea); padding-top: 4px; }
}

/* interruptor visible/oculto */
.switch { position: relative; display: inline-flex; align-items: center; padding: 8px 6px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.switch__track { width: 38px; height: 22px; border-radius: 999px; background: color-mix(in srgb, var(--corteza) 25%, var(--papel)); position: relative; transition: background-color .2s var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2.5px solid var(--brasa); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: .5; }

/* ── Formularios ─────────────────────────────────────────────── */
.editor { padding: 6px 18px 18px; border-top: 1px solid var(--linea); }
.form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.field { grid-column: 1 / -1; display: grid; gap: 6px; margin: 14px 0 0; align-content: start; }
.field--half { grid-column: span 1; }
@media (max-width: 480px) { .field--half { grid-column: 1 / -1; } }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field__label { font-size: 13.5px; font-weight: 700; color: var(--corteza); padding: 0; }
.field__sublabel { font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.field__hint { font-size: 12.5px; color: var(--texto-2); }
.field__count { font-size: 12px; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.field__error, .form-error { font-size: 13px; font-weight: 600; color: var(--error); }
.form-error { margin-top: 12px; }
.req { color: var(--brasa); }
.field input[type="text"], .field input[type="url"], .field input[type="tel"], .field input[type="email"],
.field input[type="password"], .field input[type="date"], .field input[type="time"], .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: #fff; border: 1.5px solid var(--linea-2); border-radius: 10px;
  transition: border-color .2s var(--ease);
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--corteza); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brasa) 18%, transparent); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--error); }
.fieldset-plain { margin: 0; padding: 0; border: 0; min-width: 0; }
.fieldset-plain legend { margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brasa); }
.editor__actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* selector de íconos */
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icons__opt { height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1.5px solid var(--linea); background: #fff; cursor: pointer; }
.icons__opt svg { width: 20px; height: 20px; }
.icons__opt:has(input:checked) { background: var(--corteza); border-color: var(--corteza); color: var(--papel); }
.icons__opt:has(input:focus-visible) { outline: 2.5px solid var(--brasa); outline-offset: 2px; }

/* días */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 44px)); gap: 6px; }
.daybox { height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1.5px solid var(--linea-2); background: #fff; font: 400 18px/1 var(--display); cursor: pointer; }
.daybox:has(input:checked) { background: var(--brasa); border-color: var(--brasa); color: var(--papel); }
.daybox:has(input:focus-visible) { outline: 2.5px solid var(--corteza); outline-offset: 2px; }

/* foto */
.imgpick { display: flex; gap: 14px; align-items: flex-start; }
.imgpick__preview { width: 112px; flex-shrink: 0; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px; background: var(--miga-2); display: grid; place-items: center; }
.imgpick__preview--arch { aspect-ratio: 4 / 5; border-radius: 56px 56px 10px 10px; }
.imgpick__preview--round { width: 80px; aspect-ratio: 1; border-radius: 50%; }
.imgpick__preview img { width: 100%; height: 100%; object-fit: cover; }
.imgpick__empty { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--texto-2); }
.imgpick__side { flex: 1; min-width: 0; display: grid; gap: 8px; }
.imgpick__buttons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.imgpick__status { font-size: 13px; color: var(--texto-2); }
.imgpick__status:empty { display: none; }
.field--image.is-busy .imgpick__preview { opacity: .5; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px;
  max-width: min(92vw, 420px); padding: 12px 16px; border-radius: 12px;
  background: var(--corteza); color: var(--papel); font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none;
  transition: opacity .24s var(--ease), transform .24s var(--ease);
}
.toast[data-tone="error"] { background: var(--error); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ── Selector de color (tarjeta) ─────────────────────────────── */
.colorrow { display: flex; align-items: center; gap: 10px; }
.colorrow input[type="text"] { flex: 1; min-width: 0; }
.colorpick { width: 48px; height: 44px; padding: 3px; border: 1.5px solid var(--linea-2); border-radius: 10px; background: var(--papel); cursor: pointer; }
