/* ───────────────────────── Tokens ───────────────────────── */
:root {
    /* ── Paleta cálida «parchment + dorado» (inspirada en ui-skills.com) ── */
    --bg:            #faf9f4;            /* lienzo crema cálido */
    --editor-bg:     #faf9f4;            /* plano de escritura: una sola superficie crema clara (estilo Typefully), sin tarjeta encima */
    --panel:         #ffffff;
    --preview-bg:    #f5f2e9;
    --sidebar-bg:    #f5f2e9;
    --text:          #1c1917;            /* tinta cálida casi negra */
    --text-2:        #6a635b;
    --text-3:        #a8a29e;
    --border:        rgba(28, 25, 23, .09);
    --border-2:      rgba(28, 25, 23, .15);
    --hover:         rgba(28, 25, 23, .04);
    --hover-2:       rgba(28, 25, 23, .06);

    --blue:          #e3b341;            /* dorado — CTA principal: publicar · generar (texto oscuro encima) */
    --blue-700:      #d4a32c;            /* hover (dorado más intenso) */
    --blue-ink:      #3d2f08;            /* texto/icono oscuro SOBRE el dorado */
    --blue-strong:   #9c7b15;            /* dorado oscuro legible para texto/iconos sobre fondo claro */
    --blue-soft:     rgba(227, 179, 65, .18);

    --sky:           #e3d8c2;            /* programar — arena cálida (secundario tranquilo) */
    --sky-700:       #d8cab0;            /* hover (un punto más tostado) */
    --sky-ink:       #5f5230;            /* tinta marrón cálida sobre la arena y sobre blanco */
    --sky-soft:      rgba(160, 140, 96, .22);

    --ai:            #c08a3e;            /* asistente IA — ámbar cálido */
    --ai-700:        #a9762f;
    --ai-soft:       #f3ecdd;
    --ai-tint:       rgba(192, 138, 62, .12);

    --ok:            #5b7c2f;            /* verde oliva cálido */
    --danger:        #c2410c;

    --radius:        13px;
    --radius-sm:     9px;
    --shadow-sm:     0 1px 2px rgba(20, 20, 20, .04);
    --shadow-md:     0 6px 24px -8px rgba(20, 20, 20, .14);
    --shadow-pop:    0 18px 48px -16px rgba(20, 20, 20, .30);

    --sidebar-w:     340px;
    --preview-w:     380px;           /* compacta: más ancho para el editor, sin esconder la vista previa */
    --header-h:      72px;            /* franja superior: alinea marca · barra del editor · título de preview */
    --top-gap:       26px;            /* aire entre la franja superior y el contenido */
    --dock-h:        104px;           /* hueco reservado abajo para la barra de IA flotante (el pie del editor queda por encima) */
    --ease:          cubic-bezier(.4, 0, .2, 1);

    --font:          "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-system:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ángulo animado para el borde-gradiente mágico de la barra de IA */
@property --ai-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}
@keyframes ai-rotate { to { --ai-angle: 360deg; } }

/* ───────────────────────── Base ───────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* el atributo gana aunque la clase fije display:flex */

html, body { margin: 0; height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--blue-soft); }
button { font-family: inherit; cursor: pointer; }
svg { display: block; }
.ico { width: 16px; height: 16px; stroke: currentColor; fill: none; }

.list::-webkit-scrollbar, .canvas::-webkit-scrollbar, .content::-webkit-scrollbar,
.preview::-webkit-scrollbar, .sched-pop::-webkit-scrollbar,
.ai-pop::-webkit-scrollbar, .ctx-pop::-webkit-scrollbar { width: 9px; }
.list::-webkit-scrollbar-thumb, .canvas::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb,
.preview::-webkit-scrollbar-thumb, .sched-pop::-webkit-scrollbar-thumb,
.ai-pop::-webkit-scrollbar-thumb, .ctx-pop::-webkit-scrollbar-thumb {
    background: rgba(28, 25, 23, .14);
    border-radius: 99px;
    border: 3px solid transparent;
    background-clip: content-box;
}

/* ───────────────────────── Layout ───────────────────────── */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--preview-w);
    height: 100vh;
    height: 100dvh;
}

/* ───────────────────────── Sidebar ───────────────────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0 14px 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
}
/* la marca ocupa la franja superior (misma altura que la barra del editor y el título de preview) */
.brand { display: flex; align-items: center; gap: 10px; height: var(--header-h); flex: 0 0 auto; padding: 0 8px; margin-bottom: var(--top-gap); }
.brand-mark { display: flex; flex: 0 0 auto; }
.brand-mark img { width: 38px; height: 38px; object-fit: contain; display: block; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }

/* botón para ocultar el panel (esquina superior derecha del sidebar), icono azul */
.sidebar-collapse {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex: 0 0 auto; margin-left: auto;
    border: 0; border-radius: 8px; background: transparent; color: var(--blue-strong);
    transition: background .12s var(--ease), color .12s var(--ease);
}
.sidebar-collapse:hover { background: var(--blue-soft); color: var(--blue-ink); }
.sidebar-collapse svg { width: 19px; height: 19px; stroke: currentColor; fill: none; }

.btn-new {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; height: 40px; margin-bottom: 18px;
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    background: var(--panel); color: var(--text);
    font-size: 13px; font-weight: 600; box-shadow: var(--shadow-sm);
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn-new:hover { background: var(--hover); }
.btn-new:active { background: var(--hover-2); }
.btn-new .ico { width: 17px; height: 17px; }

/* tab bar — segmented control con aire */
.tabs {
    display: flex; gap: 3px; padding: 4px; margin: 0 0 14px;
    background: var(--hover); border-radius: 12px;
}
.tab {
    flex: 1 1 0; min-width: 0;
    border: 0; border-radius: 8px; background: transparent;
    padding: 10px 6px; font-size: 12px; font-weight: 550; color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    white-space: nowrap; letter-spacing: -.01em;
    transition: color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }
.tab .count {
    font-size: 10.5px; font-weight: 650; color: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.tab.is-active .count {
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
    background: var(--blue); color: var(--blue-ink);
    display: inline-flex; align-items: center; justify-content: center;
}

.list {
    flex: 1; min-height: 0; overflow-y: auto;
    margin: 0 -6px; padding: 2px 6px 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.card {
    position: relative; padding: 13px 14px; border-radius: 12px;
    border: 1px solid transparent; cursor: pointer;
    transition: background .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.card:hover { background: var(--hover); }
.card.is-active { background: var(--panel); border-color: rgba(20, 20, 20, .06); box-shadow: 0 4px 16px -6px rgba(20, 20, 20, .15); }

.card-title {
    font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px;
}
.card-title.is-empty { color: var(--text-3); font-weight: 600; font-style: italic; }
.card-preview {
    margin-top: 3px; font-size: 12.5px; line-height: 1.42; color: var(--text-3);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
}
.card-meta {
    margin-top: 10px; display: flex; align-items: center; gap: 7px;
    font-size: 12px; color: var(--text-3);
}
.li-badge {
    width: 20px; height: 20px; border-radius: 5px; background: var(--blue-strong); flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
}
.li-badge svg { width: 11px; height: 11px; }
.card-time { font-weight: 500; }
.card-del {
    position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
    border: 0; border-radius: 7px; background: transparent; color: var(--text-3);
    display: none; align-items: center; justify-content: center;
}
.card:hover .card-del { display: inline-flex; }
.card-del:hover { background: var(--hover-2); color: var(--danger); }
.card-del svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.empty { margin: 26px 10px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.55; white-space: pre-line; }

/* secciones placeholder al fondo del sidebar (no clicables de momento) */
.sidebar-foot {
    flex: 0 0 auto; margin: 0 -6px; padding: 8px 0 14px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: 9px;
    font-size: 13px; font-weight: 550; color: var(--text-2);
    cursor: default; user-select: none;
}
.nav-item svg { width: 19px; height: 19px; stroke: currentColor; fill: none; flex: 0 0 auto; }
.nav-label { flex: 1; min-width: 0; }
.nav-soon {
    font-size: 10px; font-weight: 600; letter-spacing: .02em; color: var(--text-3);
    background: rgba(20, 20, 20, .05); padding: 2px 7px; border-radius: 99px; flex: 0 0 auto;
}

/* ───────────────────────── Editor (centro) ───────────────────────── */
.editor { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--editor-bg); }

.editor-bar {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    /* franja superior: misma altura que la marca y el título de preview → fila alineada */
    height: var(--header-h); flex: 0 0 auto; padding: 0 24px;
}
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 99px; background: var(--hover); color: var(--text-2); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.status-chip[data-status="programado"] { background: var(--sky-soft); color: var(--sky-ink); }
.status-chip[data-status="publicado"]  { background: rgba(91, 124, 47, .14); color: var(--ok); }
.actions { display: flex; gap: 9px; min-width: 0; flex: 0 1 auto; }
/* Programar/Publicar mantienen su tamaño; el botón de objetivo es el que cede espacio */
.actions > .schedule-wrap, .actions > .btn-publish { flex: 0 0 auto; }

/* botones base */
.btn {
    display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    font-size: 13px; font-weight: 600; letter-spacing: -.005em;
    transition: background .15s var(--ease), border-color .15s var(--ease), opacity .15s var(--ease), transform .05s var(--ease);
}
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }

.btn-publish { background: var(--blue); color: var(--blue-ink); }
.btn-publish:hover { background: var(--blue-700); }

.btn-schedule { background: var(--sky); color: var(--sky-ink); padding-right: 8px; }
.btn-schedule:hover { background: var(--sky-700); }
.btn-schedule .ico { width: 16px; height: 16px; }
.btn-arrow { display: inline-flex; align-items: center; padding-left: 9px; margin-left: 2px; border-left: 1px solid rgba(95, 82, 48, .30); }
.btn-arrow svg { width: 17px; height: 17px; stroke: currentColor; fill: none; transition: transform .18s var(--ease); }
.schedule-wrap.open .btn-arrow svg { transform: translateX(2px); }

/* ───────────────────────── Popover calendario ───────────────────────── */
.schedule-wrap { position: relative; }
.sched-pop {
    position: absolute; top: calc(100% + 12px); right: 0; width: 360px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow-pop); padding: 20px; z-index: 40;
    animation: pop .16s var(--ease);
}
.sched-pop::before {
    content: ""; position: absolute; top: -7px; right: 54px; width: 14px; height: 14px;
    background: var(--panel); border-left: 1px solid var(--border); border-top: 1px solid var(--border);
    transform: rotate(45deg); border-radius: 3px 0 0 0;
}
.sched-head { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 16px; }
.cal-ico { width: 19px; height: 19px; stroke: var(--sky-ink); fill: none; }

.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month { font-size: 13.5px; font-weight: 650; }
.cal-arrow { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.cal-arrow:hover { background: var(--hover); color: var(--text); }
.cal-arrow svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 6px 0 8px; }
.cal-day {
    width: 38px; height: 36px; margin: 0 auto; border: 0; border-radius: 99px; background: transparent;
    font-size: 13px; font-weight: 500; color: var(--text);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s var(--ease), color .12s var(--ease);
    font-variant-numeric: tabular-nums;
}
.cal-day:hover:not(:disabled):not(.sel) { background: var(--hover-2); }
.cal-day:disabled { color: var(--text-3); opacity: .55; cursor: default; }
.cal-day.today { color: var(--sky-ink); font-weight: 700; }
.cal-day.sel { background: var(--sky); color: var(--sky-ink); font-weight: 650; }
.cal-day.blank { pointer-events: none; }

.time-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.time-label { font-size: 13px; font-weight: 600; color: var(--text); }
.time-selects { display: flex; align-items: center; gap: 8px; }
.time-select {
    appearance: none; -webkit-appearance: none;
    height: 40px; padding: 0 30px 0 14px; border: 1px solid var(--border-2); border-radius: 10px;
    background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a6a70' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
    background-size: 15px; font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
    cursor: pointer; font-variant-numeric: tabular-nums;
}
.time-select:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
.time-colon { font-weight: 700; color: var(--text-2); }

.quick-chips { display: flex; gap: 8px; margin-top: 16px; }
.chip {
    flex: 1; border: 0; border-radius: 9px; background: var(--hover); color: var(--text);
    padding: 9px 6px; font-size: 12px; font-weight: 550; white-space: nowrap;
    transition: background .12s var(--ease);
}
.chip:hover { background: var(--hover-2); }

.sched-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.sched-summary { font-size: 13px; font-weight: 600; color: var(--text); }
.btn-schedule-go { background: var(--sky); color: var(--sky-ink); height: 42px; padding: 0 20px; border-radius: 11px; }
.btn-schedule-go:hover { background: var(--sky-700); }
.btn-schedule-go .ico { width: 17px; height: 17px; }

/* ───────────────────────── Lienzo de escritura ───────────────────────── */
/* padding-top = --top-gap: arranca el "papel" a la misma altura que Nuevo borrador
   (sidebar) y la tarjeta de vista previa = --header-h + --top-gap desde arriba */
/* El lienzo ya NO scrollea con posts largos: rellena el alto disponible y deja que el
   textarea scrollee por dentro (chrome fijo, estilo Typefully). overflow-y:auto queda solo
   como red de seguridad para viewports muy bajos donde no quepa el mínimo. */
.canvas { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: var(--top-gap) 24px 0; }

/* "papel" disuelto: ya no es una tarjeta blanca sobre fondo tostado, sino el propio plano
   de escritura. Columna flex de alto completo → autor fijo arriba, texto scrollea en medio,
   pie fijo abajo. El padding inferior (--dock-h) reserva sitio para la barra de IA flotante. */
.paper {
    width: 100%; max-width: 640px;
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column;
    background: transparent; border: 0; box-shadow: none;
    padding: 0 2px var(--dock-h);
}

/* ───────────────────────── Selector de objetivo ───────────────────────── */
/* ── Embudo de estrategia (objetivo · sector · rol) ──
   Antes vivía en la barra superior; ahora se construye dentro del piso "Tu estrategia" del
   panel Contexto (ver .ctx-tier-strat). Estas clases las reutiliza buildStrategy(). */
.goal-menu-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 4px 8px 7px; }
/* divisor entre las tres secciones del embudo (Objetivo · Sector · Rol) */
.goal-opt + .goal-menu-label,
.obj-chips + .goal-menu-label { margin-top: 7px; padding-top: 11px; border-top: 1px solid var(--border); }

/* chips de Sector y Rol */
.obj-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 3px 5px 7px; }
.obj-chip {
    border: 1px solid var(--border-2); border-radius: 99px; background: var(--panel);
    color: var(--text-2); padding: 6px 12px; font-size: 12px; font-weight: 550;
    transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.obj-chip:hover { background: var(--hover); color: var(--text); }
.obj-chip.is-active { background: rgba(156, 123, 21, .14); color: var(--blue-strong); border-color: transparent; font-weight: 650; }
.goal-opt {
    display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
    border: 0; background: transparent; border-radius: 10px; padding: 10px 11px;
    transition: background .12s var(--ease);
}
.goal-opt:hover { background: var(--hover); }
.goal-opt-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.goal-opt-txt strong { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.goal-opt-txt em { font-style: normal; font-size: 12px; line-height: 1.45; color: var(--text-3); }
.goal-check { width: 18px; height: 18px; stroke: var(--blue-strong); fill: none; flex: 0 0 auto; margin-top: 1px; opacity: 0; transition: opacity .12s var(--ease); }
.goal-opt.is-active .goal-check { opacity: 1; }
.goal-opt.is-active .goal-opt-txt strong { color: var(--blue-strong); }
.composer { width: 100%; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* las tarjetas auxiliares (generar imagen, tira de medios) no deben encogerse: ceden espacio
   el textarea (flex:1), no ellas */
.composer > .imggen, .composer > .media-strip { flex: 0 0 auto; }
.author { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex: 0 0 auto; }
.avatar {
    width: 46px; height: 46px; border-radius: 99px; background: var(--sky); color: var(--sky-ink);
    display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex: 0 0 auto;
}
.author-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.author-sub { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.globe { width: 12px; height: 12px; stroke: currentColor; fill: none; }

.content {
    width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
    font-family: var(--font-system); font-size: 16px; line-height: 1.7; letter-spacing: -.003em;
    flex: 1 1 auto; min-height: 120px; overflow-y: auto;   /* rellena su zona y scrollea por dentro; el cursor se mantiene a la vista solo */
}
.content::placeholder { color: var(--text-3); }
.content:disabled { color: var(--text); cursor: default; }

/* pie fijo (imagen · imagen IA · estado · contador): separado del texto por aire, sin filete */
.canvas-foot { width: 100%; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 12px; padding: 8px 2px 2px; }
.save-state { font-size: 12px; color: var(--text-3); transition: opacity .2s var(--ease); }
.counter { font-size: 12px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--danger); }

/* ───────────────────────── Barra de IA ───────────────────────── */
/* Barra flotante: se posa sobre el editor (no ocupa flujo) → más aire para el post.
   El degradado hacia el fondo hace que el texto se desvanezca al pasar por detrás. */
.ai-dock {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; justify-content: center; padding: 32px 24px 20px;
    pointer-events: none;
    background: linear-gradient(to top, var(--editor-bg) 50%, transparent);
}
.ai-bar-wrap, .ai-pop, .ctx-pop { pointer-events: auto; }   /* el dock es pointer-events:none; los popovers deben reactivarlo o sus botones no reciben clics */

/* halo mágico difuso detrás de la barra (tenue, gira muy despacio) */
.ai-bar-wrap { position: relative; width: 100%; max-width: 640px; }
.ai-bar-wrap::before {
    content: ""; position: absolute; inset: -2px; z-index: 0; border-radius: 14px;
    background: conic-gradient(from var(--ai-angle),
        #e3b341, #efd9a0, #e0a96b, #d8b06a, #ead9b0, #e3b341);
    filter: blur(8px); opacity: .07;
    animation: ai-rotate 13s linear infinite;
}
.ai-bar-wrap:focus-within::before { opacity: .16; }

.ai-bar {
    position: relative; z-index: 1;
    width: 100%; display: flex; align-items: center; gap: 8px;
    border: 1.2px solid transparent; border-radius: 13px;
    padding: 5px 5px 5px 12px;
    background:
        linear-gradient(var(--panel), var(--panel)) padding-box,
        conic-gradient(from var(--ai-angle),
            #e3b341, #efd9a0, #e0a96b, #d8b06a, #ead9b0, #e3b341) border-box;
    animation: ai-rotate 13s linear infinite;
    box-shadow: var(--shadow-md);
    transition: box-shadow .2s var(--ease);
}
.ai-bar:focus-within { box-shadow: 0 0 0 3px var(--ai-tint), 0 10px 34px -12px rgba(192, 138, 62, .38); }
.ai-spark { width: 17px; height: 17px; stroke: var(--ai); fill: none; flex: 0 0 auto; }
.ai-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-family: inherit; font-size: 13px; color: var(--text); padding: 7px 0; }
.ai-input::placeholder { color: var(--text-3); }

.mejorar-wrap { position: relative; flex: 0 0 auto; }
.ai-mejorar {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
    border: 1px solid var(--border-2); border-radius: 9px; background: var(--panel);
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    transition: background .12s var(--ease), color .12s var(--ease);
}
.ai-mejorar:hover { background: var(--hover); color: var(--text); }
.ai-mejorar .ico { width: 14px; height: 14px; }
.ai-mejorar .chev { width: 14px; height: 14px; stroke: currentColor; fill: none; transition: transform .18s var(--ease); }
.mejorar-wrap.open .chev { transform: rotate(180deg); }

.mejorar-menu {
    position: absolute; bottom: calc(100% + 8px); right: 0; width: 210px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-pop); padding: 6px; z-index: 30; animation: pop .14s var(--ease);
}
.mm-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 9px 11px; font-size: 13px; font-weight: 500; color: var(--text); }
.mm-item:hover { background: var(--ai-soft); color: var(--ai-700); }

.ai-generar {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
    border: 0; border-radius: 9px; background: var(--blue); color: var(--blue-ink);
    font-size: 13px; font-weight: 650; transition: background .15s var(--ease);
}
.ai-generar:hover { background: var(--blue-700); }
.ai-generar .ico { width: 15px; height: 15px; }

/* spinner del botón Generar (oculto salvo durante la carga) */
.ai-spin { display: none; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: ai-spin .7s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* texto de estado animado (shimmer) que sustituye al input mientras la IA escribe */
.ai-status {
    display: none; flex: 1; min-width: 0; align-items: center;
    font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: linear-gradient(90deg, var(--text-3) 0%, var(--ai) 45%, var(--text-3) 90%);
    background-size: 220% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: ai-shimmer 1.5s linear infinite;
}
@keyframes ai-shimmer { to { background-position: -220% 0; } }

/* ── estado de carga: barra "viva" mientras el modelo trabaja ── */
.ai-dock.is-loading .ai-bar { pointer-events: none; animation-duration: 1.5s; }       /* el borde gira más rápido */
.ai-dock.is-loading .ai-bar-wrap::before { animation-duration: 1.5s; opacity: .32; }  /* el halo brilla más */
.ai-dock.is-loading .ai-input { display: none; }
.ai-dock.is-loading .ai-status { display: inline-flex; }
.ai-dock.is-loading .ai-spark { animation: ai-pulse 1s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .35; transform: scale(.88); } }
.ai-dock.is-loading .mejorar-wrap { opacity: .4; }
.ai-dock.is-loading .ai-generar .ico,
.ai-dock.is-loading .ai-generar .ai-generar-lbl { display: none; }
.ai-dock.is-loading .ai-generar .ai-spin { display: inline-block; }

/* popover de IA (acciones rápidas + prompts) */
.ai-pop {
    position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 640px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-pop); padding: 10px; z-index: 35; animation: pop .16s var(--ease);
    max-height: min(72vh, 540px); overflow-y: auto;   /* viewport bajo: scroll interno en vez de desbordar sobre la barra */
}
.ai-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 2px 6px 5px; }
.ai-prompts { list-style: none; margin: 0; padding: 0; }
.ai-prompt {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    border: 0; background: transparent; border-radius: 9px; padding: 7px 9px;
    font-size: 13px; color: var(--text); transition: background .12s var(--ease);
}
.ai-prompt:hover { background: var(--hover); }
.spark { width: 15px; height: 15px; stroke: var(--ai); fill: none; flex: 0 0 auto; }

/* tendencias del nicho dentro del popover de IA (motor de enriquecimiento) */
.ai-trends-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-trends-head .ai-label { padding-bottom: 3px; }
.ai-trends-refresh { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3); }
.ai-trends-refresh:hover { background: var(--hover); color: var(--ai-700); }
.ai-trends-refresh svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.ai-trends { display: flex; flex-direction: column; gap: 1px; }
.ai-trends-msg { font-size: 12.5px; color: var(--text-3); padding: 8px 9px; }
.ai-trend { display: flex; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 8px 9px; transition: background .12s var(--ease); }
.ai-trend:hover { background: var(--hover); }
.ai-trend.is-active { background: var(--ai-soft); }
.ai-trend-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ai-trend-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-trend-src { flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; }
.ai-trend-src[data-src="reddit"]   { background: rgba(255, 69, 0, .12);   color: #c2410c; }
.ai-trend-src[data-src="x"]        { background: rgba(28, 25, 23, .10);   color: var(--text); }
.ai-trend-src[data-src="linkedin"] { background: rgba(55, 143, 233, .15); color: #1d6fd1; }
.ai-trend-topic { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-trend-mom { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; color: var(--ai-700); white-space: nowrap; }
.ai-trend-angle { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───────────────────────── Botón de contexto ───────────────────────── */
/* Vive en la barra de IA, a la izquierda de "Mejorar". Tinte ámbar (familia IA) para
   distinguirlo. Cuando hay contexto afinado, un punto lo señala. */
.ai-ctx {
    position: relative; flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
    border: 1px solid var(--border-2); border-radius: 9px; background: var(--panel);
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.ai-ctx:hover { background: var(--ai-soft); color: var(--ai-700); border-color: transparent; }
.ai-ctx .ico { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.ai-ctx.is-set { background: var(--ai-tint); color: var(--ai-700); border-color: transparent; }
.ai-ctx-dot { display: none; width: 6px; height: 6px; border-radius: 99px; background: var(--ai); margin-left: 1px; }
.ai-ctx.is-set .ai-ctx-dot { display: inline-block; }
.ai-dock.is-loading .ai-ctx { opacity: .4; pointer-events: none; }

/* post publicado: la barra de IA se apaga (lo ya publicado no se edita) */
.ai-dock.is-readonly .ai-bar-wrap { opacity: .5; pointer-events: none; }

/* panel de preguntas (popover sobre la barra, como .ai-pop) */
.ctx-pop {
    position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 640px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-pop); padding: 18px 20px 16px; z-index: 36;
    max-height: min(90vh, 660px); overflow-y: auto;   /* tope alto: el contenido cabe sin scroll; auto solo como red de seguridad en ventanas muy bajas */
    animation: ctx-pop-in .16s var(--ease); transform-origin: bottom center;
}
@keyframes ctx-pop-in { from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.99); } }

.ctx-head { display: flex; flex-direction: column; gap: 1px; margin-bottom: 11px; }
.ctx-title { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.ctx-spark { width: 16px; height: 16px; stroke: var(--ai); fill: none; flex: 0 0 auto; }
.ctx-sub { font-size: 11.5px; color: var(--text-3); }

.ctx-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.ctx-tag { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-tag-topic { background: var(--hover); color: var(--text-2); }
.ctx-tag-goal  { background: rgba(156, 123, 21, .12); color: var(--blue-strong); }
.ctx-tag-trend { background: var(--ai-tint); color: var(--ai-700); }

/* ── Pisos del panel: "Tu estrategia" (persistente) + "Este post" (afinado del post) ── */
/* Etiqueta-separador entre pisos: eyebrow en mayúsculas con filete superior hairline */
.ctx-tier-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
    margin: 16px 0 9px; padding-top: 14px; border-top: 1px solid var(--border);
}
/* Piso 1: tarjeta tenue anidada (white-on-pale) que lo separa del afinado del post */
.ctx-tier-strat {
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 11px 13px; margin-bottom: 2px;
}
.ctx-tier-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ctx-tier-head .ctx-tier-label { margin: 0; padding: 0; border: 0; }   /* dentro de la tarjeta, sin filete */
.ctx-tier-hint {
    text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 10px; color: var(--text-3);
    background: var(--hover); padding: 2px 7px; border-radius: 99px;
}
.ctx-tier-toggle {
    display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
    border: 0; background: transparent; color: var(--blue-strong); font-size: 12px; font-weight: 650; padding: 2px;
}
.ctx-tier-toggle:hover { text-decoration: underline; }
.ctx-tier-toggle svg { width: 15px; height: 15px; stroke: currentColor; fill: none; transition: transform .18s var(--ease); }
.ctx-tier-strat.is-open .ctx-tier-toggle svg { transform: rotate(180deg); }
.ctx-strat-summary {
    display: block; width: 100%; text-align: left; margin-top: 8px; border: 0; background: transparent; padding: 0;
    font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; cursor: pointer;
}
.ctx-strat-summary.is-empty { font-weight: 500; color: var(--text-3); }
.ctx-strat-body { margin-top: 4px; }
.ctx-strat-body .goal-menu-label:first-child { padding-top: 8px; }

/* Audiencia del post: por defecto hereda sector·rol; "cambiar" abre los chips */
.ctx-aud {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; padding: 8px 11px;
}
.ctx-aud-val { min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-aud-val.is-empty { font-weight: 500; color: var(--text-3); }
.ctx-aud-change { flex: 0 0 auto; border: 0; background: transparent; color: var(--blue-strong); font-size: 12px; font-weight: 650; padding: 2px 4px; }
.ctx-aud-change:hover { text-decoration: underline; }

/* Campo estrella anti-genérico (dato/anécdota real): acento ámbar discreto */
.ctx-field-star .ctx-q { color: var(--ai-700); }
.ctx-field-star .ctx-q::before { content: "★ "; color: var(--ai); }
.ctx-field-star .ctx-textarea { border-color: var(--ai-tint); }

.ctx-field { margin-bottom: 12px; }
.ctx-field:last-of-type { margin-bottom: 0; }
.ctx-q { font-size: 12px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.ctx-q em { font-style: normal; font-weight: 500; color: var(--text-3); }

.ctx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ctx-chip {
    border: 1px solid var(--border-2); border-radius: 99px; background: var(--panel);
    color: var(--text-2); padding: 5px 11px; font-size: 11.5px; font-weight: 550;
    transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.ctx-chip:hover { background: var(--hover); color: var(--text); }
.ctx-chip.is-active { background: var(--ai-tint); color: var(--ai-700); border-color: transparent; font-weight: 650; }

.ctx-input, .ctx-textarea {
    width: 100%; border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg);
    font-family: inherit; font-size: 13px; color: var(--text); padding: 8px 11px; outline: 0;
    transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.ctx-input::placeholder, .ctx-textarea::placeholder { color: var(--text-3); }
.ctx-input:focus, .ctx-textarea:focus { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-tint); }
.ctx-textarea { resize: vertical; min-height: 44px; line-height: 1.45; }

.ctx-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); }
.ctx-skip {
    height: 36px; padding: 0 15px; border: 1px solid var(--border-2); border-radius: 9px;
    background: var(--panel); color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.ctx-skip:hover { background: var(--hover); color: var(--text); }
.ctx-go { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--blue); color: var(--blue-ink); font-size: 13px; font-weight: 650; transition: background .15s var(--ease); }
.ctx-go:hover { background: var(--blue-700); }
.ctx-go svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

/* ───────────────────────── Recomendación de formato ───────────────────────── */
/* Tira sobria sobre el "papel": el papel sigue siendo la masa focal. */
.reco {
    width: 100%; max-width: 640px; flex: 0 0 auto; margin-bottom: 16px;
    display: flex; align-items: center; gap: 12px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 13px;
    box-shadow: none; padding: 11px 13px;
}
.reco.is-applied { background: var(--ai-soft); border-color: transparent; }
.reco-ic { width: 20px; height: 20px; stroke: var(--ai); fill: none; flex: 0 0 auto; }
.reco.is-applied .reco-ic { stroke: var(--ai-700); }
.reco-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.reco-line { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reco-line strong { font-weight: 700; }
.reco-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reco-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.reco-btn {
    height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-2);
    background: var(--panel); color: var(--text-2); font-size: 12px; font-weight: 600;
    transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.reco-btn:hover { background: var(--hover); color: var(--text); }
.reco-apply { background: var(--blue); color: var(--blue-ink); border-color: transparent; }
.reco-apply:hover { background: var(--blue-700); }
.reco-x { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.reco-x:hover { background: var(--hover-2); color: var(--text); }
.reco-x svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }

/* ───────────────────────── Vista previa LinkedIn ───────────────────────── */
.preview { display: flex; flex-direction: column; min-height: 0; background: var(--preview-bg); border-left: 1px solid var(--border); padding: 0 18px 18px; overflow-y: auto; }
/* la cabecera de preview ocupa la franja superior → alineada con la marca y la barra del editor */
.preview-head { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); flex: 0 0 auto; margin-bottom: var(--top-gap); }
.preview-title { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.eye { width: 16px; height: 16px; stroke: currentColor; fill: none; }

.view-toggle { display: flex; gap: 2px; padding: 3px; background: var(--hover); border-radius: 9px; }
.view-toggle button { width: 34px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; transition: background .12s var(--ease), color .12s var(--ease); }
.view-toggle button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.view-toggle button.is-active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

.preview-stage { transition: padding .2s var(--ease); }
.preview-stage[data-view="mobile"] { padding: 0; }
.preview-stage[data-view="mobile"] .li-card {
    max-width: 368px; margin: 6px auto; border-radius: 26px;
    border: 6px solid #e6e1d6; box-shadow: var(--shadow-md);
}
.preview-stage[data-view="mobile"] .li-actions button { font-size: 11.5px; gap: 4px; padding: 11px 0; }
.preview-stage[data-view="mobile"] .li-actions svg { width: 18px; height: 18px; }

.li-card { font-family: var(--font-system); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 16px 16px 6px; }
.li-head { display: flex; align-items: flex-start; gap: 12px; }
.li-avatar { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 99px; background: var(--sky); color: var(--sky-ink); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.li-meta { min-width: 0; flex: 1; padding-top: 1px; }
.li-name { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
.li-deg { font-weight: 400; color: var(--text-3); }
.li-headline { font-size: 12.5px; color: var(--text-2); line-height: 1.35; margin-top: 1px; }
.li-time { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); margin-top: 3px; }
.li-time .globe { width: 13px; height: 13px; }
.li-top-right { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding-top: 1px; }
/* botones decorativos de la vista previa: sin acción → sin reacción al hover */
.li-follow { border: 0; background: transparent; color: var(--blue-strong); font-size: 14px; font-weight: 700; padding: 2px 4px; white-space: nowrap; cursor: default; }
.li-more { border: 0; background: transparent; color: var(--text-3); width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; cursor: default; }
.li-more svg { width: 20px; height: 20px; fill: currentColor; }

.li-body {
    position: relative;
    font-size: 14px; line-height: 1.45; color: var(--text); margin: 13px 0 0; white-space: pre-wrap; word-break: break-word;
}
.li-body.is-empty { color: var(--text-3); }
/* colapsado: 3 líneas como LinkedIn */
.li-body.is-clamped {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.li-seemore { display: inline; border: 0; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; padding: 0; cursor: pointer; }
.li-seemore:hover { color: var(--text); text-decoration: underline; }
/* "… ver más" al final de la 3ª línea, pegado a la derecha, con degradado para fundir el texto */
.li-seemore-clamp {
    position: absolute; right: 0; bottom: 0; padding-left: 4px;
    background: var(--panel); color: var(--text-2);
}
.li-seemore-clamp::before {
    content: ""; position: absolute; right: 100%; top: 0; bottom: 0; width: 28px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--panel));
    pointer-events: none;
}

.li-stats { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 10px; font-size: 12.5px; color: var(--text-2); }
.li-reactions { display: flex; align-items: center; }
.coin { width: 20px; height: 20px; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--panel); margin-left: -5px; }
.coin:first-child { margin-left: 0; }
.coin svg { width: 11px; height: 11px; fill: #fff; }
.coin.like { background: #378fe9; }
.coin.celebrate { background: #6dae4f; }
.coin.love { background: #df704d; }
.react-count { margin-left: 7px; color: var(--text-2); }
.li-engage { color: var(--text-2); }

.li-actions { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding: 4px 0 0; }
.li-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; color: #5f5952; font-size: 12.5px; font-weight: 600; padding: 11px 2px; border-radius: 8px; white-space: nowrap; cursor: default; }
.li-actions svg { width: 19px; height: 19px; stroke: currentColor; fill: none; flex: 0 0 auto; }

/* ───────────────────────── Toast ───────────────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 16px;
    background: var(--text); color: #fff; font-size: 13px; font-weight: 500;
    padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-md); z-index: 60;
    animation: toast-in .22s var(--ease); max-width: 88vw; text-align: center;
}
.toast.err { background: var(--danger); }
.toast-action {
    flex: 0 0 auto; border: 0; background: transparent; color: var(--blue);
    font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 0;
}
.toast-action:hover { text-decoration: underline; }

/* ───────────────────────── Configuración (modal) ───────────────────────── */
.nav-item-btn {
    width: 100%; border: 0; background: transparent; font: inherit;
    color: var(--text-2); cursor: pointer; text-align: left;
}
.nav-item-btn:hover { background: var(--hover); color: var(--text); }

.cfg-overlay {
    position: fixed; inset: 0; z-index: 100; padding: 24px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(28, 25, 23, .50); backdrop-filter: blur(2px);
    animation: cfg-fade .15s var(--ease);
}
@keyframes cfg-fade { from { opacity: 0; } }
.cfg-modal {
    width: 100%; max-width: 620px; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-pop); animation: pop .16s var(--ease);
}
.cfg-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.cfg-title { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; color: var(--text); }
.cfg-title svg { width: 18px; height: 18px; stroke: var(--ai); fill: none; }
.cfg-x { display: inline-flex; border: 0; background: transparent; border-radius: 8px; padding: 6px; cursor: pointer; color: var(--text-3); }
.cfg-x svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.cfg-x:hover { background: var(--hover); color: var(--text); }

.cfg-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.cfg-field { display: flex; flex-direction: column; gap: 6px; }
.cfg-label { font-size: 12.5px; font-weight: 650; color: var(--text); }
.cfg-input, .cfg-textarea {
    width: 100%; border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg);
    font-family: inherit; font-size: 13px; color: var(--text); padding: 10px 12px; outline: 0;
    transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.cfg-input:focus, .cfg-textarea:focus { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-tint); }
.cfg-textarea { resize: vertical; min-height: 230px; line-height: 1.55; }
.cfg-hint { font-size: 11.5px; color: var(--text-3); }
.cfg-hint a { color: var(--ai-700); }
.cfg-hint code { font-size: 11px; background: var(--hover); padding: 1px 5px; border-radius: 5px; }
.cfg-warn { font-size: 12.5px; color: #92400e; background: #fef3c7; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; }

/* Voz del autor: pegar muestras + lista de ejemplos aprendidos */
.cfg-voice { border-top: 1px solid var(--border); padding-top: 16px; }
.cfg-voice-count { font-weight: 500; color: var(--text-3); }
.cfg-voice-input { min-height: 110px; }
.cfg-voice-actions { display: flex; justify-content: flex-end; }
.cfg-voice-add {
    height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-2);
    background: var(--ai-soft); color: var(--ai-700); font-size: 12.5px; font-weight: 650; cursor: pointer;
    transition: background .12s var(--ease);
}
.cfg-voice-add:hover { background: var(--ai-tint); }
.cfg-voice-add:disabled { opacity: .55; cursor: default; }
.cfg-voice-empty { font-size: 12px; color: var(--text-3); margin: 2px 0 0; line-height: 1.5; }
.cfg-voice-list { display: flex; flex-direction: column; gap: 8px; }
.cfg-voice-item { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding: 10px 12px; }
.cvi-text { margin: 0 0 7px; font-size: 12px; line-height: 1.5; color: var(--text-2); white-space: pre-wrap; }
.cvi-foot { display: flex; align-items: center; justify-content: space-between; }
.cvi-src { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.cvi-del { border: 0; background: transparent; color: var(--text-3); font-size: 11.5px; cursor: pointer; padding: 2px 4px; }
.cvi-del:hover { color: var(--danger); text-decoration: underline; }

/* Onboarding de voz (1.ª vez) — reutiliza el chasis de .cfg-modal */
.onb-modal { max-width: 540px; }
.onb-title svg { stroke: var(--ai); fill: none; }
.onb-lead { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.onb-input { min-height: 150px; }
.onb-hint { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.onb-hint code { font-size: 11px; background: var(--hover); padding: 1px 5px; border-radius: 5px; }
.onb-foot { justify-content: flex-end; }

.cfg-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); }
.cfg-foot-right { display: inline-flex; gap: 9px; }
.cfg-reset { border: 0; background: transparent; color: var(--text-3); font-size: 12.5px; font-weight: 500; cursor: pointer; padding: 8px 2px; }
.cfg-reset:hover { color: var(--text); text-decoration: underline; }
.cfg-cancel, .cfg-save { height: 38px; padding: 0 16px; border-radius: 10px; font-size: 13px; font-weight: 650; cursor: pointer; }
.cfg-cancel { border: 1px solid var(--border-2); background: var(--panel); color: var(--text-2); }
.cfg-cancel:hover { background: var(--hover); }
.cfg-save { border: 0; background: var(--blue); color: var(--blue-ink); }
.cfg-save:hover { background: var(--blue-700); }

/* ───────────────────────── Plan de contenido (modal) ───────────────────────── */
.plan-overlay {
    position: fixed; inset: 0; z-index: 100; padding: 24px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(28, 25, 23, .50); backdrop-filter: blur(2px);
    animation: cfg-fade .15s var(--ease);
}
.plan-modal {
    width: 100%; max-width: 540px; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-pop); animation: pop .16s var(--ease);
}
.plan-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.plan-title { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; color: var(--text); }
.plan-title svg { width: 18px; height: 18px; stroke: var(--blue-strong); fill: none; }
.plan-x { display: inline-flex; border: 0; background: transparent; border-radius: 8px; padding: 6px; cursor: pointer; color: var(--text-3); }
.plan-x svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.plan-x:hover { background: var(--hover); color: var(--text); }

.plan-body { padding: 18px; overflow-y: auto; }
.plan-cadence { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.plan-cadence-lbl { font-size: 13px; font-weight: 600; color: var(--text); }
.plan-cadence-chips { display: inline-flex; gap: 5px; padding: 4px; background: var(--hover); border-radius: 10px; }
.plan-cad {
    width: 36px; height: 32px; border: 0; border-radius: 7px; background: transparent;
    font-size: 13px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums;
    transition: background .12s var(--ease), color .12s var(--ease), box-shadow .12s var(--ease);
}
.plan-cad:hover { color: var(--text); }
.plan-cad.is-active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

.plan-week { display: flex; flex-direction: column; gap: 6px; }
.plan-day { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; background: var(--bg); }
.plan-day.is-today { background: var(--blue-soft); }
.plan-day.is-applied { background: var(--ai-soft); }
.plan-day-name { width: 84px; flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--text); }
.plan-day-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.plan-day-fmt { font-size: 13px; font-weight: 600; color: var(--text); }
.plan-day-visual { font-size: 11.5px; color: var(--text-3); }
.plan-use { flex: 0 0 auto; height: 30px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--panel); color: var(--text-2); font-size: 12px; font-weight: 600; transition: background .12s var(--ease), color .12s var(--ease); }
.plan-use:hover { background: var(--hover); color: var(--text); }
.plan-use.is-applied { background: var(--blue); color: var(--blue-ink); border-color: transparent; }

.plan-note { margin: 18px 2px 0; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.plan-note strong { color: var(--text-2); font-weight: 650; }

/* ───────────────────────── Animaciones ───────────────────────── */
@keyframes pop      { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.ai-pop { transform-origin: bottom center; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ───────────────────────── Responsive ───────────────────────── */
.menu-toggle {
    display: none; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-right: 4px;
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    background: var(--panel); color: var(--text);
}
.menu-toggle:hover { background: var(--hover); }
.menu-toggle svg { width: 19px; height: 19px; stroke: currentColor; fill: none; }
.scrim { display: none; }

/* Panel lateral colapsable (escritorio): el botón de la esquina lo oculta;
   el menú (hamburguesa) de la barra del editor lo vuelve a mostrar. */
@media (min-width: 821px) {
    .app { transition: grid-template-columns .25s var(--ease); }
    .sidebar { transition: transform .25s var(--ease); }
    .app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr) var(--preview-w); }
    .app.sidebar-collapsed .sidebar { width: var(--sidebar-w); transform: translateX(-100%); }
    .app.sidebar-collapsed .menu-toggle { display: inline-flex; }
}

/* oculta la vista previa en pantallas medianas */
@media (max-width: 1080px) {
    .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .preview { display: none; }
}

@media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: 86%; max-width: 320px; z-index: 50;
        background: var(--sidebar-bg); box-shadow: var(--shadow-pop);
        transform: translateX(-103%); transition: transform .25s var(--ease);
    }
    .app.nav-open .sidebar { transform: none; }
    .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 20, 20, .3); z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
    .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
    .menu-toggle { display: inline-flex; }
    .editor-bar { padding: 0 16px; }
    .btn-schedule .lbl { display: none; }
    .canvas { padding: var(--top-gap) 16px 0; }
    .paper { padding: 0 2px 88px; }   /* móvil: sin tarjeta; reserva menor para la barra de IA */
    .content { font-size: 16px; }
    .ai-dock { padding: 28px 16px 14px; }
    .ai-mejorar { padding: 0 10px; }
    .ai-ctx { padding: 0 9px; }
    .ai-ctx-lbl { display: none; }        /* móvil: solo icono para no apretar la barra */
    .sched-pop { width: min(360px, calc(100vw - 32px)); }
    .reco { flex-wrap: wrap; }            /* móvil: las acciones bajan a una segunda fila */
    .reco-actions { width: 100%; justify-content: flex-end; }
}

/* ───────────────────────── Conexión con LinkedIn (panel lateral) ───────────────────────── */
.li-conn { margin: 2px 4px 12px; }
.li-conn.is-muted .li-conn-note {
    display: block; font-size: 11.5px; color: var(--text-3); text-align: center;
    padding: 9px 10px; border: 1px dashed var(--border-2); border-radius: var(--radius-sm);
}
.li-conn-btn {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    text-decoration: none; background: #0a66c2; color: #fff;     /* azul oficial de LinkedIn */
    font: 600 13.5px/1 var(--font); padding: 11px 12px; border-radius: var(--radius-sm);
    transition: filter .15s ease, transform .15s ease;
}
.li-conn-btn:hover { filter: brightness(.93); transform: translateY(-1px); }
.li-conn-mark { display: inline-flex; width: 16px; height: 16px; }
.li-conn-mark svg { width: 16px; height: 16px; }

.li-conn.is-on {
    display: flex; align-items: center; gap: 9px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 9px; box-shadow: var(--shadow-sm);
}
.li-conn-ava { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; object-fit: cover; display: block; }
.li-conn-ava-ini { display: grid; place-items: center; background: #0a66c2; color: #fff; font: 700 13px/1 var(--font); text-transform: uppercase; }
.li-conn-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.li-conn-meta strong { font: 600 13px/1.2 var(--font); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-conn-meta em { font: 400 11px/1.2 var(--font); font-style: normal; color: var(--ok); }
.li-conn.is-expired .li-conn-meta em { color: var(--danger); }
.li-conn-relink { margin-left: auto; flex-shrink: 0; font: 600 11.5px/1 var(--font); color: var(--blue-ink); background: var(--blue-soft); padding: 6px 9px; border-radius: 999px; text-decoration: none; }
.li-conn-x { margin-left: auto; flex-shrink: 0; width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-3); cursor: pointer; border-radius: 6px; }
.li-conn.is-expired .li-conn-x { margin-left: 4px; }
.li-conn-x:hover { background: var(--hover); color: var(--text); }
.li-conn-x svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-linecap: round; }

/* foto de perfil real (de LinkedIn) en el avatar del editor y de la vista previa */
.avatar img, .li-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* ───────────────────────── Confirmar publicación (modal) ───────────────────────── */
.pub-modal { max-width: 460px; }
.pub-title svg { width: 18px; height: 18px; fill: #0a66c2; stroke: none; }
.pub-body { gap: 14px; }
.pub-account {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
}
.pub-account.is-warn { background: #fef3c7; border-color: #fde68a; color: #92400e; font-size: 13px; font-weight: 500; }
.pub-warn-ic { width: 20px; height: 20px; flex-shrink: 0; stroke: #92400e; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pub-ava { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; object-fit: cover; display: block; }
.pub-ava-ini { display: grid; place-items: center; background: #0a66c2; color: #fff; font: 700 15px/1 var(--font); text-transform: uppercase; }
.pub-acc-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.pub-acc-meta strong { font: 650 14px/1.2 var(--font); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-acc-meta em { font: 400 12px/1.2 var(--font); font-style: normal; color: var(--text-3); }
.pub-preview {
    font: 400 13.5px/1.55 var(--font); color: var(--text-2);
    white-space: pre-wrap; word-break: break-word;
    background: var(--panel); border: 1px solid var(--border); border-left: 3px solid #0a66c2;
    border-radius: 8px; padding: 11px 13px; max-height: 180px; overflow-y: auto;
}
.pub-note { font-size: 12px; color: var(--text-3); margin: 0; }
.pub-foot { justify-content: flex-end; }
.pub-go { background: #0a66c2; color: #fff; }
.pub-go:hover { background: #004182; }

/* ───────────────────────── Imágenes adjuntas ───────────────────────── */
/* Botones "Imagen" / "Imagen IA" a la izquierda del pie; save-state empuja el resto a la derecha. */
.img-add {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border-2); border-radius: 99px; background: var(--panel);
    color: var(--text-2); padding: 6px 13px 6px 11px; font-size: 12px; font-weight: 600;
    transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.img-add:hover { background: var(--hover); color: var(--text); }
.img-add .ico { width: 17px; height: 17px; stroke: currentColor; fill: none; }
.img-add.is-disabled, .img-add:disabled { opacity: .45; pointer-events: none; }
.canvas-foot .save-state { margin-left: auto; }   /* separa los botones (izq.) del contador (der.) */

/* Variante IA: acento ámbar del asistente (un solo acento, contenido). */
.img-ai { color: var(--ai-700); }
.img-ai .ico { stroke: var(--ai-700); fill: none; stroke-linejoin: round; }
.img-ai:hover { background: var(--ai-soft); color: var(--ai-700); border-color: transparent; }

/* Panel "Imagen IA" en 2 pasos: la IA propone 3 ideas (se elige una) y se genera. */
.imggen {
    display: flex; flex-direction: column; gap: 12px; margin-top: 14px;
    background: var(--panel); border: 1px solid var(--border-2); border-radius: 16px;
    padding: 14px;
}
.imggen-head { display: flex; align-items: center; gap: 8px; }
.imggen-spark { width: 16px; height: 16px; stroke: var(--ai); fill: none; flex: 0 0 auto; }
.imggen-title { font-size: 12.5px; font-weight: 650; color: var(--text); }

/* Las 3 ideas, una bajo otra. */
.imggen-ideas { display: flex; flex-direction: column; gap: 8px; }

/* Cada idea: tarjeta seleccionable (paso 1). */
.imggen-idea {
    display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
    border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
    padding: 10px 12px; cursor: pointer; font-family: inherit;
    transition: border-color .12s var(--ease), background .12s var(--ease), box-shadow .12s var(--ease);
}
.imggen-idea:hover { border-color: var(--ai); }
.imggen-idea.is-selected { border-color: var(--ai); background: var(--ai-tint); box-shadow: 0 0 0 3px var(--ai-tint); }
.imggen-idea-title { font-size: 13px; font-weight: 650; color: var(--text); }
.imggen-idea-desc {
    font-size: 11.5px; line-height: 1.45; color: var(--text-2);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Loader circular dorado mientras la IA propone las 3 ideas. */
.imggen-loader { display: flex; justify-content: center; padding: 22px 0; }
.imggen-loader::after {
    content: ""; width: 26px; height: 26px;
    border: 3px solid var(--ai-tint); border-top-color: var(--ai);
    border-radius: 50%; animation: media-spin .7s linear infinite;
}

/* Fila de error con "Reintentar". */
.imggen-error {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 12px; color: var(--text-2);
    border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: 10px 12px;
}
.imggen-retry {
    flex: 0 0 auto; border: 1px solid var(--border-2); border-radius: 99px; background: var(--panel);
    color: var(--text); padding: 5px 12px; font-size: 11.5px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: border-color .12s var(--ease), color .12s var(--ease);
}
.imggen-retry:hover { border-color: var(--ai); color: var(--ai-700); }

/* Pie: botón "Generar" (paso 2), alineado a la derecha. */
.imggen-foot { display: flex; justify-content: flex-end; }
.imggen-go {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
    border: 0; border-radius: 99px; background: var(--ai); color: #fff;
    padding: 8px 18px; font-size: 12.5px; font-weight: 650; cursor: pointer;
    transition: background .12s var(--ease);
}
.imggen-go:hover { background: var(--ai-700); }
.imggen-go:disabled { opacity: .5; cursor: default; }
.imggen-spin { display: none; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: media-spin .7s linear infinite; }
.imggen.is-loading .imggen-go, .imggen.is-loading-ideas .imggen-go { pointer-events: none; }
.imggen.is-loading .imggen-spin { display: inline-block; }

/* Tira de miniaturas bajo el textarea. */
.media-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.media-thumb {
    position: relative; width: 96px; height: 96px; border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg); flex: 0 0 auto;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-del {
    position: absolute; top: 5px; right: 5px; width: 24px; height: 24px;
    border: 0; border-radius: 99px; background: rgba(28, 25, 23, .62); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    transition: background .12s var(--ease);
}
.media-del:hover { background: rgba(28, 25, 23, .85); }
.media-del svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
/* placeholder mientras sube */
.media-thumb.is-uploading { display: grid; place-items: center; }
.media-spin {
    width: 22px; height: 22px; border-radius: 99px;
    border: 2.5px solid var(--border-2); border-top-color: var(--text-3);
    animation: media-spin .7s linear infinite;
}
@keyframes media-spin { to { transform: rotate(360deg); } }

/* zona de arrastrar y soltar */
.paper.is-dragover { outline: 2px dashed var(--blue-strong); outline-offset: 4px; }

/* Imagen en la tarjeta de vista previa de LinkedIn (ancho completo, como el feed real). */
.li-media { margin: 12px -16px 0; border-top: 1px solid var(--border); }
.li-media-img { width: 100%; max-height: 520px; object-fit: cover; display: block; }

/* indicador de imagen en las tarjetas de la lista lateral */
.card-img-ic { display: inline-flex; align-items: center; color: var(--text-3); }
.card-img-ic svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.pub-preview.is-empty { color: var(--text-3); font-style: italic; }
