:root {
  /* ADN Vidriera: papel claro, tinta casi negra, el violeta de la marca como acento y la etiqueta amarilla.
     Con la marca de fábrica, /brand.css solo trae el modo oscuro y lo claro sale de acá: por eso estos valores son
     exactamente los que shared/brand.js calcula para la paleta original (lo controla tests/brand.mjs). */
  --bg: #f1f2f4;
  --bg-2: #e6e7e9;
  --panel: #ffffff;
  --panel-2: #f6f6f9;
  --line: #dcdde3;
  --text: #17181d;
  --muted: #5c5f6b;
  --brand: #5b3fe0;
  --brand-2: #0e7490;
  /* Estados: de cada par, light-dark() usa el valor que corresponde al color-scheme vigente.
     El color-scheme lo pone el modo oscuro, y también una paleta oscura elegida en Admin → Marca. */
  --ok: light-dark(#1f7a4d, #6cc79a);
  --warn: light-dark(#9a5b00, #e3ad55);
  --danger: light-dark(#c2412d, #ee8a79);
  --tag: #ffe45c;
  /* Hover de los botones principales y texto sobre los colores de la marca (Admin → Marca los recalcula) */
  --text-hover: #333438;
  --on-text: #ffffff;
  --on-tag: #17181d;
  --on-brand: #ffffff;
  --radius: 12px;
  --shadow: 0 24px 50px -28px rgba(23, 24, 29, 0.45);
  --f-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-accent: 'Instrument Serif', Georgia, serif;
  font-family: var(--f-body);
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
/* Fondo de marca de todas las páginas (menos el editor). Sale de las variables de la marca que elige el admin,
   así acompaña cualquier paleta. Claro: papel limpio (apenas un degradé desde blanco y una trama de puntos casi invisible), así los acentos de la marca resaltan solos */
:root {
  --dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='2' cy='2' r='1.1' fill='%23000' fill-opacity='.035'/%3E%3C/svg%3E");
  /* Resaltado para texto: el amarillo no se lee sobre claro, así que ahí va el principal */
  --tag-ink: color-mix(in srgb, var(--brand) 88%, var(--text));
  --page-bg: var(--dots), linear-gradient(180deg, color-mix(in srgb, var(--bg) 40%, #ffffff), var(--bg) 32rem);
}
/* Oscuro: brillo del resaltado y del secundario, trama de puntos y un degradé del principal al fondo */
:root[data-theme='dark'] {
  --dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='2' cy='2' r='1.1' fill='%23fff' fill-opacity='.08'/%3E%3C/svg%3E");
  --tag-ink: var(--tag);
  --page-bg:
    radial-gradient(60rem 34rem at 10% -8%, color-mix(in srgb, var(--tag) 20%, transparent), transparent 70%),
    radial-gradient(50rem 40rem at 100% 28%, color-mix(in srgb, var(--brand-2) 26%, transparent), transparent 70%), var(--dots),
    linear-gradient(170deg, color-mix(in srgb, var(--brand) 38%, var(--bg)), var(--bg) 75%);
}
html,
body {
  margin: 0;
  color: var(--text);
}
html {
  background: var(--bg);
}
/* El fondo de marca es una capa fija aparte: se ve igual que un fondo "fixed", pero al deslizar no se repinta la página
   entera (en el celular, background-attachment: fixed hace que cueste deslizar) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--page-bg);
  pointer-events: none;
}
/* El editor queda fuera del tema de marca: fondo liso */
body.ed-page::before {
  content: none;
}
body.ed-page {
  background: var(--bg);
}
body {
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
h1,
h2,
h3 {
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0;
  font-family: var(--f-display);
  text-wrap: balance;
}
h1 em,
h2 em {
  font-family: var(--f-accent);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.hidden {
  display: none !important;
}

/* ---------- botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 0.6em 1.1em;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.btn:hover {
  background: var(--panel-2);
  border-color: color-mix(in srgb, var(--text) 22%, var(--line));
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--on-text, #fff);
}
.btn-primary:hover {
  background: var(--text-hover);
  border-color: var(--text-hover);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-color: transparent;
}
.btn-danger {
  color: var(--danger);
}
.btn-lg {
  padding: 0.85em 1.6em;
  font-size: 15px;
  border-radius: 12px;
}
.btn-sm {
  padding: 0.35em 0.7em;
  font-size: 12px;
}
.btn-icon {
  padding: 0.45em;
  width: 32px;
  height: 32px;
}

/* ---------- formularios ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field > label,
.sl-head > label,
.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.input,
.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field input[type='url'],
.field input[type='number'],
.field select,
.field textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6em 0.75em;
  outline: none;
  transition: border-color 0.15s;
}
.field textarea {
  resize: vertical;
  min-height: 70px;
}
.field textarea.code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  min-height: 140px;
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
}
.field input[type='range'] {
  width: 100%;
  accent-color: var(--brand);
}
/* Slider del editor (slider.js), al estilo de Carrd: nombre y número arriba, barra fina con una zona grande para agarrar */
.sl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.sl-head label {
  margin: 0;
}
.sl-val {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}
.field .sl-num {
  width: 58px;
  padding: 3px 6px;
  text-align: right;
  font-size: 12.5px;
  -moz-appearance: textfield;
}
.field .sl-num::-webkit-inner-spin-button,
.field .sl-num::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input.sl-range {
  -webkit-appearance: none;
  appearance: none;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.sl-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}
.sl-range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}
.sl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--brand);
}
.sl-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--panel);
}
.sl-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 30%, transparent);
}
.field input[type='color'] {
  width: 36px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  padding: 2px;
  cursor: pointer;
}
.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-row input[type='text'] {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.check {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 14px;
}
.check input {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}
.terms-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 4px 0 10px;
  color: var(--muted);
  line-height: 1.4;
  cursor: pointer;
}
.terms-check input {
  margin-top: 2px;
  flex: none;
}
.terms-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 190;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  line-height: 1.45;
}
.terms-bar p {
  margin: 0;
  flex: 1;
}
@media (max-width: 600px) {
  .terms-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
.err {
  color: var(--danger);
  font-size: 13px;
  min-height: 1em;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .spacer {
  flex: 1;
}
.theme-toggle {
  padding: 0.5em;
  line-height: 0;
}
.nav-inbox {
  gap: 6px;
}
.unread-badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--bg);
  font: 700 11px/1 var(--f-body);
}
[hidden] {
  display: none !important;
}

/* ---------- bandeja de mensajes (lista + mensaje abierto, a todo el ancho) ---------- */
.container.inbox-page {
  max-width: 1680px;
  padding: 20px 32px 24px;
}
.inbox-head {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.inbox-head h1 {
  margin: 0;
  font-size: 30px;
}
.inbox-head .count {
  color: var(--muted);
  font-size: 15px;
}
.inbox-head .spacer {
  flex: 1;
}
.inbox-head select {
  width: auto;
  min-width: 200px;
  max-width: 320px;
  font-size: 15px;
  padding: 9px 12px;
}
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 3px;
}
.seg button {
  border: 0;
  background: none;
  padding: 7px 14px;
  border-radius: 8px;
  font: 600 14px var(--f-body);
  color: var(--muted);
  cursor: pointer;
}
.seg button.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.inbox {
  display: grid;
  grid-template-columns: minmax(340px, 34%) minmax(0, 1fr);
  height: calc(100vh - 170px);
  min-height: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.inbox-list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.msg-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 4px 12px;
  width: 100%;
  padding: 16px 18px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.msg-item:hover {
  background: var(--panel-2);
}
.msg-item.on {
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--brand);
}
.msg-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 7px;
}
.msg-item.unread .msg-dot {
  background: var(--brand);
}
.msg-from {
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-item.unread .msg-from {
  font-weight: 800;
}
.msg-when {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  padding-top: 2px;
}
.msg-preview {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-item.unread .msg-preview {
  color: var(--text);
}
.msg-site {
  grid-column: 2 / 4;
  justify-self: start;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-more {
  padding: 16px;
  text-align: center;
}
.inbox-detail {
  overflow-y: auto;
  padding: 32px 40px;
}
.detail-back {
  display: none;
}
.detail-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.detail-head h2 {
  margin: 0 0 6px;
  font-size: 26px;
  overflow-wrap: anywhere;
}
.detail-meta {
  color: var(--muted);
  font-size: 15px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-actions .btn {
  font-size: 15px;
}
.detail-fields {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 14px 28px;
  font-size: 17px;
  line-height: 1.55;
  max-width: 900px;
}
.detail-fields dt {
  color: var(--muted);
  font-size: 15px;
  padding-top: 2px;
}
.detail-fields dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.detail-fields dd a {
  color: inherit;
}
.detail-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.inbox-empty {
  margin: auto;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  max-width: 460px;
}
.inbox-empty b {
  display: block;
  color: var(--text);
  font-size: 20px;
  margin: 8px 0;
}
@media (max-width: 860px) {
  .container.inbox-page {
    padding: 14px 12px;
  }
  .inbox-head h1 {
    font-size: 26px;
  }
  .inbox-head select {
    order: 10;
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
  }
  .inbox-head .spacer {
    display: none;
  }
  .inbox {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .inbox-list {
    border-right: 0;
  }
  .inbox.reading .inbox-list,
  .inbox:not(.reading) .inbox-detail {
    display: none;
  }
  .inbox-detail {
    padding: 18px 16px 24px;
  }
  .detail-back {
    display: inline-flex;
    margin-bottom: 14px;
  }
  .detail-head h2 {
    font-size: 22px;
  }
  .detail-fields {
    grid-template-columns: 1fr;
    gap: 2px;
    font-size: 16px;
  }
  .detail-fields dd {
    margin-bottom: 14px;
  }
  .detail-actions,
  .detail-actions .btn {
    width: 100%;
  }
  .detail-actions .btn {
    justify-content: center;
  }
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo-img {
  width: 30px;
  height: 30px;
  display: block;
  margin: -2px 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill-pro {
  background: var(--tag);
  color: var(--on-tag, var(--text));
  border: 0;
}
.pill-ok {
  color: var(--ok);
}
.pill-warn {
  color: var(--warn);
}
.pill-danger {
  color: var(--danger);
}
/* Borde y fondo salen del color de la propia píldora, así acompañan cualquier paleta y los dos modos */
.pill-ok,
.pill-warn,
.pill-danger {
  border-color: color-mix(in srgb, currentColor 28%, transparent);
  background: color-mix(in srgb, currentColor 12%, var(--panel-2));
}
.pill-unread {
  background: var(--danger);
  color: var(--bg);
  border: 0;
  text-decoration: none;
}

/* ---------- contenedores ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.grid {
  display: grid;
  gap: 18px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
}

/* ---------- modal + toast ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--text) 45%, transparent);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
  animation: fade 0.15s;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  width: min(440px, 100%);
  padding: 26px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow: auto;
}
.modal h2 {
  font-size: 20px;
  margin-bottom: 6px;
}
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  flex-wrap: wrap;
}
.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: up 0.2s;
  font-weight: 500;
}
.toast.error {
  background: color-mix(in srgb, var(--danger) 55%, var(--text));
  border-color: color-mix(in srgb, var(--danger) 55%, var(--text));
  color: var(--bg);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.env-banner {
  background: repeating-linear-gradient(45deg, #b45309 0 14px, #92400e 14px 28px);
  color: #fff;
  text-align: center;
  font:
    600 12px/1.4 system-ui,
    sans-serif;
  padding: 6px 12px;
}
.env-banner a {
  color: #fff;
}
.admin-notice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 44px;
  background: var(--brand);
  color: var(--on-brand, #fff);
  text-align: center;
  font:
    600 13px/1.45 system-ui,
    sans-serif;
}
.admin-notice-x {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}
.admin-notice-x:hover {
  opacity: 1;
}
.notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: min(400px, 100%);
}
.auth-card h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 18px 0 6px;
}

/* ---------- dashboard ---------- */
.sites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.site-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  /* Sin overflow:hidden: el menú ••• tiene que poder salir de la tarjeta. Las esquinas las recorta la miniatura. */
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.site-card:hover {
  border-color: color-mix(in srgb, var(--text) 28%, var(--line));
  box-shadow: var(--shadow);
}
.site-thumb {
  height: 170px;
  position: relative;
  overflow: hidden;
  border-radius: 17px 17px 0 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  display: block;
}
.site-thumb iframe {
  width: 400%;
  height: 400%;
  transform: scale(0.25);
  transform-origin: 0 0;
  border: 0;
  pointer-events: none;
}
.site-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.site-body h3 {
  font-size: 16px;
}
.site-url {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-url:hover {
  color: var(--text);
}
.site-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-top: auto;
  padding-top: 8px;
}
.site-actions {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.site-new {
  border: 2px dashed color-mix(in srgb, var(--text) 22%, var(--line));
  border-radius: 18px;
  display: grid;
  place-items: center;
  min-height: 290px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.site-new:hover {
  border-color: var(--brand);
  color: var(--text);
}
.menu {
  position: relative;
}
.menu-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  min-width: 170px;
  box-shadow: var(--shadow);
  z-index: 10;
}
/* Sin lugar arriba (la tarjeta está pegada a la barra de arriba): abre hacia abajo */
.menu-list.down {
  bottom: auto;
  top: calc(100% + 6px);
}
.menu-list button,
.menu-list a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.menu-list button:hover,
.menu-list a:hover {
  background: var(--panel-2);
}

/* ---------- templates ---------- */
.tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
  flex-wrap: wrap;
}
.tabs button {
  background: none;
  border: 0;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button {
  font-weight: 600;
}
.tabs button.on {
  color: var(--text);
  border-color: var(--text);
}
.templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}
.tpl {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition:
    transform 0.15s,
    border-color 0.15s;
}
.tpl:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
}
.tpl-thumb {
  height: 220px;
  overflow: hidden;
  position: relative;
  background: var(--bg-2);
}
.tpl-thumb iframe {
  width: 357.15%;
  height: 357.15%;
  transform: scale(0.28);
  transform-origin: 0 0;
  border: 0;
  pointer-events: none;
}
.tpl-name {
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tpl-blank {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 18px;
  background: var(--panel);
}

/* ---------- tablas ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.table td {
  white-space: pre-wrap;
  word-break: break-word;
}

/* iPhone hace zoom al tocar campos con letra de menos de 16 px */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    gap: 4px 6px;
    flex-wrap: wrap;
  }
  .topbar .btn {
    padding: 0.5em 0.7em;
  }
  .topbar a[href='/docs'] {
    display: none;
  }
  .site-new {
    min-height: 110px;
  }
  .container {
    padding: 24px 16px;
  }
  .templates {
    grid-template-columns: 1fr;
  }
}

/* ---------- Mi espacio: menú lateral y menú de usuario ---------- */
.app-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  max-width: 1720px;
  margin: 0 auto;
}
.side-nav {
  position: sticky;
  top: 66px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 28px 12px 24px 20px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font: 600 14.5px/1.2 var(--f-body);
  text-decoration: none;
  white-space: nowrap;
}
.side-item:hover {
  background: var(--panel-2);
  color: var(--text);
}
.side-item.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line);
}
.side-item.on .ico {
  color: var(--brand);
}
.side-item > .unread-badge,
.side-item > .pill {
  margin-left: auto;
}
.side-item > .pill {
  font-size: 9.5px;
  padding: 2px 6px;
}
.side-minor {
  font-weight: 500;
}
.side-sep {
  height: 1px;
  background: var(--line);
  margin: 10px 12px;
}
.ico {
  display: inline-flex;
  flex: none;
}
.ico svg {
  width: 18px;
  height: 18px;
}
.app-main {
  min-width: 0;
}
.app-main > .container {
  margin: 0;
}

.user-menu {
  position: relative;
}
.user-menu-btn {
  position: relative;
  display: flex;
  border: 0;
  padding: 3px;
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
.user-menu-btn:focus-visible {
  outline: 2px solid var(--brand);
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand, #fff);
  font: 700 15px/1 var(--f-display);
}
.user-menu-badge {
  position: absolute;
  top: -3px;
  right: -6px;
}
.user-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 250px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.user-menu-head {
  display: grid;
  gap: 2px;
  padding: 10px 12px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.user-menu-head b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-list a,
.user-menu-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: 500 14px var(--f-body);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.user-menu-list a:hover,
.user-menu-list button:hover {
  background: var(--panel-2);
}

@media (max-width: 860px) {
  .app-layout {
    display: block;
  }
  /* En el celular el menú lateral pasa a pestañas que se deslizan, debajo de la barra */
  .side-nav {
    top: 61px;
    z-index: 15;
    flex-direction: row;
    gap: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .side-nav::-webkit-scrollbar {
    display: none;
  }
  .side-item {
    flex: none;
    padding: 8px 12px;
    background: var(--panel);
    box-shadow: 0 0 0 1px var(--line);
  }
  .side-item.on {
    background: var(--text);
    color: var(--on-text, #fff);
    box-shadow: none;
  }
  .side-item.on .ico {
    color: inherit;
  }
  .side-sep,
  .side-minor {
    display: none;
  }
}

/* ---------- Avisos (banner) con tonos de la marca ---------- */
.banner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid currentColor;
  background: var(--panel);
  font-weight: 500;
}
.banner-danger {
  color: var(--danger);
}
.banner-warn {
  color: var(--warn);
}
.banner-ok {
  color: var(--ok);
}
.banner-brand {
  color: var(--brand);
}
.banner-info {
  color: var(--brand-2);
}

/* ---------- Mis sitios: resumen, primeros pasos, filtros y carpetas ---------- */
.grow {
  flex: 1;
}
.site-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.site-msgs {
  color: inherit;
  text-decoration: none;
}
.site-url-warn {
  color: var(--warn);
}
.btn-delete,
.btn-delete:hover {
  background: var(--danger);
  border-color: var(--danger);
}
.dash-empty {
  grid-column: 1 / -1;
  text-align: center;
}
.folder-pick {
  margin-bottom: 14px;
}
.folder-form {
  display: flex;
  gap: 8px;
}
.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dash-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.dash-stat b {
  font-family: var(--f-display);
  font-size: 22px;
}
.dash-stat span {
  color: var(--muted);
  font-size: 13px;
}
a.dash-stat:hover {
  border-color: var(--brand);
}
.dash-stat.alert b {
  color: var(--danger);
}
.dash-bar {
  display: block;
  height: 6px;
  margin-top: 4px;
  border-radius: 99px;
  background: var(--panel-2);
  overflow: hidden;
}
.dash-bar > i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}
.checklist {
  margin-bottom: 18px;
}
.checklist-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.checklist-head h2 {
  margin: 0;
  font-size: 18px;
}
.checklist-head .dash-bar {
  flex: 1;
  min-width: 80px;
  margin: 0;
}
.checklist ol {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.checklist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.checklist li > div {
  flex: 1;
  min-width: 0;
}
.checklist li.done b {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 500;
}
.check-dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}
.checklist li.done .check-dot {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--bg);
}
.dash-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.dash-tools:empty {
  display: none;
}
.dash-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dash-filters input[type='search'] {
  flex: 1 1 220px;
}
.dash-filters select {
  flex: 0 1 auto;
  width: auto;
}
.folder-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.folder-chips button {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.folder-chips button.on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.folder-chips button.on .muted {
  color: inherit;
  opacity: 0.7;
}
@media (max-width: 560px) {
  .dash-summary {
    grid-template-columns: 1fr 1fr;
  }
  .dash-summary > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .checklist li {
    flex-wrap: wrap;
  }
  .checklist li > .btn {
    margin-left: 34px;
  }
}

/* Desenfoques solo con mouse y pantalla grande: en el celular repintan todo al deslizar */
@media (hover: hover) and (min-width: 900px) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(10px);
  }
}
