/* Capsule de Création · IG Preview Widget
   Colores: cambiá los valores de :root para ajustar la paleta. */
:root {
  --fondo: #F6EFE4;        /* crema */
  --barra: #E8E3DC;        /* gris suave cálido */
  --texto: #3A2820;        /* marrón oscuro */
  --texto-suave: #7D6C62;
  --acento: #4F0D0B;       /* rojo bordó */
  --azul: #6E879E;         /* azul grisáceo (handle) */
  --manteca: #F8E4A0;      /* amarillo manteca */
  --negro: #17110F;
  --placeholder: #DDD6CD;
  --linea: rgba(58, 40, 32, .12);
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --script: 'Parisienne', 'Snell Roundhand', cursive;
  --gap: 2px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); }
body {
  font-family: var(--sans);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

.app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 700px;
  display: flex;
  flex-direction: column;
  background: var(--fondo);
  overflow: hidden;
}

/* 1 · Barra de título */
.barra {
  flex: none;
  background: var(--barra);
  text-align: center;
  padding: 9px 12px 8px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: .01em;
  color: var(--texto);
}

/* 2 · Handle + botones */
.cabecera {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
}
.handle {
  font-family: var(--script);
  font-size: 27px;
  line-height: 1;
  color: var(--azul);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 2px 2px 0;
  min-width: 0;
}
.handle.fraunces {
  font-family: 'Fraunces', var(--serif);
  font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -.01em;
}
.acciones { display: flex; align-items: center; gap: 6px; flex: none; }
.btn-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px 0 12px;
  border: 1px solid var(--linea);
  border-radius: 999px;
  background: transparent;
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  color: var(--texto);
  transition: background .15s, border-color .15s;
}
.btn-refresh:hover { background: rgba(79, 13, 11, .06); border-color: rgba(79, 13, 11, .3); }
.btn-refresh svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-refresh.girando svg { animation: girar .8s linear infinite; }
.btn-refresh:disabled { cursor: default; opacity: .75; }
.btn-icono {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--linea); border-radius: 8px; background: transparent;
}
.btn-icono:hover { background: rgba(79, 13, 11, .06); }
.btn-icono svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* 3 · Tabs */
.tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--linea);
}
.tab {
  display: grid; place-items: center;
  height: 38px;
  background: none; border: 0;
  color: var(--texto-suave);
  position: relative;
}
.tab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tab svg .relleno { fill: currentColor; stroke: none; }
.tab.activa { color: var(--texto); }
.tab.activa::after {
  content: ''; position: absolute; left: 50%; bottom: -1px;
  width: 38px; height: 2px; transform: translateX(-50%);
  background: var(--acento);
}
.tab:focus-visible, .btn-refresh:focus-visible, .btn-icono:focus-visible, .post:focus-visible {
  outline: 2px solid var(--acento); outline-offset: -2px;
}

.aviso-demo {
  flex: none;
  font-size: 10.5px; letter-spacing: .04em;
  text-align: center; padding: 5px 8px;
  background: var(--manteca); color: var(--texto);
}

/* Scroll interno sin barra visible */
.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 56px;
}
.scroll::-webkit-scrollbar { display: none; }

/* 4 · Grid 3 columnas, 4:5 */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.post {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  background: var(--placeholder);
  overflow: hidden;
  color: #fff;
  text-decoration: none;
}
@supports not (aspect-ratio: 4 / 5) {
  .post { height: 0; padding-bottom: 125%; }
}
.post.aprobado::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--acento);
}
.medios { position: absolute; inset: 0; display: flex; transition: transform .28s ease; }
.medio { flex: 0 0 100%; width: 100%; height: 100%; position: relative; }
.medio img, .medio video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .25s;
}
.medio.cargado img, .medio.cargado video { opacity: 1; }
.medio:not(.cargado):not(.fallo)::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2px solid rgba(58, 40, 32, .18); border-top-color: rgba(58, 40, 32, .5);
  animation: girar .8s linear infinite;
}

/* Placeholder sin imagen */
.ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--placeholder);
  color: rgba(58, 40, 32, .45);
  padding: 8px; text-align: center;
}
.ph svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.ph small { font-size: 9.5px; line-height: 1.25; color: rgba(58, 40, 32, .7); max-width: 92%; }
.ph.canva { background: #E5DCD0; }

/* 5 · Superposiciones */
.pill {
  position: absolute; top: 5px; left: 5px; z-index: 2;
  padding: 2px 5px 2px;
  border-radius: 4px;
  background: rgba(23, 17, 15, .52);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  font-size: 9.5px; font-weight: 500; letter-spacing: .01em; line-height: 1.35;
  color: #fff; white-space: nowrap;
}
.iconos {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  display: flex; gap: 4px;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .45));
}
.iconos svg { width: 15px; height: 15px; fill: #fff; stroke: none; }
.iconos svg .linea { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.dots {
  position: absolute; left: 0; right: 0; bottom: 5px; z-index: 2;
  display: flex; justify-content: center; gap: 3px;
}
.dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 0 2px rgba(0, 0, 0, .35);
}
.dots i.on { background: #fff; }
.flecha {
  position: absolute; top: 50%; z-index: 3;
  width: 20px; height: 20px; margin-top: -10px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(23, 17, 15, .45); color: #fff;
  opacity: 0; transition: opacity .15s;
}
.flecha svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.flecha.prev { left: 4px; }
.flecha.next { right: 4px; }
.post:hover .flecha, .post:focus-within .flecha { opacity: 1; }
.flecha[hidden] { display: none; }
@media (hover: none) { .flecha { opacity: .85; } }

.post.esqueleto { pointer-events: none; }
.post.esqueleto::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  border: 2px solid rgba(58, 40, 32, .14); border-top-color: rgba(58, 40, 32, .4);
  animation: girar .8s linear infinite;
}
.sin-fechas .pill { display: none; }

/* Estados vacíos y errores */
.estado {
  margin: 28px 18px; padding: 18px 16px;
  border: 1px solid var(--linea); border-radius: 10px;
  text-align: center; font-size: 13px; line-height: 1.5; color: var(--texto);
  background: rgba(255, 255, 255, .35);
}
.estado h3 { font-family: var(--serif); font-weight: 400; font-size: 21px; margin: 0 0 6px; color: var(--acento); }
.estado p { margin: 0 0 10px; }
.estado p:last-child { margin-bottom: 0; }
.estado a { color: var(--acento); }
.estado code { font-size: 11px; background: rgba(58, 40, 32, .07); padding: 1px 4px; border-radius: 3px; word-break: break-all; }

/* 6 · Toast */
.toast {
  position: absolute; left: 50%; bottom: 14px; z-index: 20;
  transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 24px);
  padding: 9px 14px 9px 11px;
  border-radius: 10px;
  background: var(--negro); color: var(--fondo);
  font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .25s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-icono { width: 15px; height: 15px; flex: none; }
.toast-icono svg { width: 15px; height: 15px; fill: none; stroke: var(--manteca); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.toast.cargando .toast-icono svg { animation: girar .8s linear infinite; }

/* Panel de ajustes */
.panel-fondo { position: absolute; inset: 0; z-index: 30; background: rgba(23, 17, 15, .25); }
.panel {
  position: absolute; left: 10px; right: 10px; top: 84px; z-index: 31;
  padding: 16px; border-radius: 12px;
  background: var(--fondo); border: 1px solid var(--linea);
  box-shadow: 0 10px 30px rgba(23, 17, 15, .12);
}
.panel h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 12px; color: var(--acento); }
.campo { display: flex; flex-direction: column; gap: 5px; font-size: 12px; margin-bottom: 12px; }
.campo.fila { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.campo.fila input[type=checkbox] { order: 2; width: 16px; height: 16px; accent-color: var(--acento); }
.campo input[type=text], .campo select {
  font: inherit; font-size: 13px; color: var(--texto);
  padding: 7px 9px; border: 1px solid var(--linea); border-radius: 7px; background: #fff;
}
.ayuda { font-size: 11px; color: var(--texto-suave); margin: 0 0 12px; }
.btn-primario {
  width: 100%; height: 34px; border: 0; border-radius: 8px;
  background: var(--acento); color: var(--fondo);
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
[hidden] { display: none !important; }

@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 2s !important; transition: none !important; }
}
