/* ==========================================================================
   Escape Guiones — sistema visual inspirado en Pinterest (Gestalt)
   Claro, mucho blanco, pastillas redondeadas, rojo de marca, iconos sólidos.
   ========================================================================== */

:root {
  /* superficies */
  --white: #ffffff;
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #efefef;
  --surface-3: #e2e2e2;
  --surface-4: #dadada;

  /* texto */
  --text: #111111;
  --text-2: #5f5f5f;
  --text-3: #767676;
  --text-inv: #ffffff;

  /* líneas */
  --line: #efefef;
  --line-2: #e2e2e2;

  /* marca */
  --red: #e60023;
  --red-hover: #ad081b;
  --red-active: #8c0615;
  --red-soft: #fde7ea;
  --blue: #0074e8;
  --blue-soft: #e7f0fd;
  --focus: #cce1fc;

  /* estados del tablero */
  --e-idea: #767676;         --e-idea-bg: #efefef;
  --e-guion: #0074e8;        --e-guion-bg: #e7f0fd;
  --e-produccion: #7b3fd4;   --e-produccion-bg: #f1e9fd;
  --e-edicion: #b06f00;      --e-edicion-bg: #fdf2dd;
  --e-listo: #0a7c42;        --e-listo-bg: #e2f5ea;
  --e-publicado: #e60023;    --e-publicado-bg: #fde7ea;

  /* plataformas */
  --p-smowl: #6b4de6;        --p-smowl-bg: #efeafc;
  --p-ldb: #0074e8;          --p-ldb-bg: #e6f1fd;
  --p-seb: #00857a;          --p-seb-bg: #e0f4f2;
  --p-proctorio: #b06f00;    --p-proctorio-bg: #fdf2dd;

  --r-pill: 999px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;

  --shadow-1: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .12);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .16);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --topbar-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg { width: 1em; height: 1em; display: block; flex-shrink: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: inherit; }

::selection { background: var(--focus); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d6d6; border-radius: 10px; border: 3px solid var(--white); }
::-webkit-scrollbar-thumb:hover { background: #b9b9b9; }

:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); border-radius: var(--r-sm); }

/* ==========================================================================
   Login
   ========================================================================== */

body.is-login { display: grid; place-items: center; background: var(--white); }

.login-wrap { width: 100%; padding: 24px; display: grid; place-items: center; }

.login-card {
  width: min(400px, 100%);
  background: var(--white);
  border-radius: 32px;
  padding: 44px 40px;
  box-shadow: var(--shadow-3);
  text-align: center;
}

.login-mark {
  width: 56px; height: 56px;
  margin: 0 auto 20px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--red);
  color: var(--white);
  font-size: 32px;
}

.login-card h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; }
.login-card > p { color: var(--text-3); font-size: .95rem; margin: 4px 0 28px; }
.login-card .field { text-align: left; margin-bottom: 18px; }

.login-error {
  background: var(--red-soft);
  color: var(--red-hover);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: .86rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ==========================================================================
   Estructura
   ========================================================================== */

.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: var(--white);
  z-index: 60;
}

.logo {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  color: var(--red);
  font-size: 26px;
  cursor: default;
}
.logo:hover { background: var(--surface-2); }

.top-quick { display: flex; gap: 4px; margin-right: 4px; }

.pill-nav {
  border: 0; background: transparent;
  padding: 0 16px; height: 48px;
  border-radius: var(--r-pill);
  font-size: .95rem; font-weight: 600;
  color: var(--text); cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}
.pill-nav:hover { background: var(--surface-2); }
.pill-nav.is-active { background: var(--text); color: var(--text-inv); }

.searchbar { position: relative; flex: 1; min-width: 0; }
.searchbar-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--text-3); pointer-events: none;
}
.searchbar input {
  width: 100%; height: 48px;
  background: var(--surface-2);
  border: 0; border-radius: var(--r-pill);
  padding: 0 44px 0 44px;
  font-size: .95rem;
  outline: none;
  transition: background .12s, box-shadow .12s;
}
.searchbar input::placeholder { color: var(--text-3); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar input:focus {
  background: var(--white);
  box-shadow: 0 0 0 4px var(--focus);
}
.searchbar-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--text-3);
  border-radius: var(--r-pill); cursor: pointer; font-size: 18px;
}
.searchbar-clear:hover { color: var(--text); }

.top-actions { display: flex; align-items: center; gap: 2px; }

.round-btn {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  border-radius: var(--r-pill);
  color: var(--text-3); font-size: 20px;
  cursor: pointer; text-decoration: none;
  transition: background .1s, color .1s;
}
.round-btn:hover { background: var(--surface-2); color: var(--text); }

.shell { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 8px 12px 16px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 48px;
  padding: 0 14px;
  border: 0; border-radius: var(--r-lg);
  background: transparent;
  color: var(--text);
  font-size: .92rem; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background .1s;
}
.nav-item svg { font-size: 19px; color: var(--text-3); }
.nav-item span { flex: 1; white-space: nowrap; }
.nav-item em {
  font-style: normal; font-size: .74rem; font-weight: 600;
  color: var(--text-3); background: var(--surface-2);
  border-radius: var(--r-pill); padding: 2px 8px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active { background: var(--surface-2); font-weight: 700; }
.nav-item.is-active svg { color: var(--red); }
.nav-item.is-active em { background: var(--white); }

.sidebar-foot { padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--line); }

.api-state {
  display: flex; align-items: center; gap: 9px;
  font-size: .8rem; color: var(--text-3);
  padding: 8px 14px;
}
.api-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-4); flex-shrink: 0; }
.api-state.is-ok .dot { background: #0a7c42; }
.api-state.is-bad .dot { background: var(--red); }

.main { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--white); }

.view { display: none; padding: 8px 32px 80px; max-width: 1600px; }
.view.is-active { display: block; }

/* ==========================================================================
   Cabecera de página
   ========================================================================== */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 20px 0 18px;
}
.page-head h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.025em; }
.page-sub { font-size: .88rem; color: var(--text-3); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 0; border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: .88rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  white-space: nowrap;
  transition: background .1s, color .1s, transform .06s;
}
.btn svg { font-size: 16px; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary { background: var(--red); color: var(--text-inv); }
.btn-primary:hover { background: var(--red-hover); }
.btn-primary:active { background: var(--red-active); }

.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-soft:hover { background: var(--surface-3); }

.btn-danger { background: var(--red-soft); color: var(--red-hover); }
.btn-danger:hover { background: #fbd3d9; }

.btn-link {
  background: transparent; color: var(--text-2);
  text-decoration: underline; text-underline-offset: 3px;
  padding: 0 10px;
}
.btn-link:hover { background: transparent; color: var(--text); }

.btn-tiny { height: 32px; padding: 0 12px; font-size: .8rem; }
.btn-lg { height: 48px; padding: 0 22px; font-size: .95rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text-3);
  cursor: pointer; font-size: 15px;
  transition: background .1s, color .1s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-on { color: var(--red); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red-hover); }
.icon-btn.chev svg { transition: transform .2s; }
.card.is-open .icon-btn.chev svg { transform: rotate(180deg); }

/* ==========================================================================
   Barra de vistas y filtros
   ========================================================================== */

.viewbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding-bottom: 14px;
}
.viewbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 2px; max-width: 100%; overflow-x: auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-pill);
  font-size: .88rem; font-weight: 600;
  color: var(--text-2); cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: background .1s, color .1s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--text); color: var(--text-inv); }

.segmented {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 3px;
}
.seg {
  border: 0; background: transparent;
  height: 34px; min-width: 38px; padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--text-2); cursor: pointer;
  font-size: .85rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .1s, color .1s;
}
.seg svg { font-size: 16px; }
.seg:hover { color: var(--text); }
.seg.is-active { background: var(--white); color: var(--text); box-shadow: var(--shadow-1); }

.select {
  height: 40px;
  background: var(--surface-2);
  border: 0; border-radius: var(--r-pill);
  padding: 0 34px 0 14px;
  font-size: .86rem; font-weight: 600; color: var(--text);
  cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23111111'%3E%3Cpath d='M12 15.7 4.9 8.6a1.3 1.3 0 0 1 1.8-1.8L12 12.1l5.3-5.3a1.3 1.3 0 1 1 1.8 1.8L12 15.7Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 13px;
  max-width: 260px;
}
.select:hover { background-color: var(--surface-3); }
.select:focus { box-shadow: 0 0 0 4px var(--focus); }
.select-block { width: 100%; max-width: none; }

.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.filter-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }

.chipset { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: .82rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .1s, color .1s;
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .55; }
.chip.f-plain .chip-dot { display: none; }
.chip.is-on { background: var(--text); color: var(--text-inv); }
.chip.is-on .chip-dot { opacity: 1; }

.chip.p-smowl { color: var(--p-smowl); background: var(--p-smowl-bg); }
.chip.p-ldb { color: var(--p-ldb); background: var(--p-ldb-bg); }
.chip.p-seb { color: var(--p-seb); background: var(--p-seb-bg); }
.chip.p-proctorio { color: var(--p-proctorio); background: var(--p-proctorio-bg); }
.chip.e-idea { color: var(--e-idea); background: var(--e-idea-bg); }
.chip.e-guion { color: var(--e-guion); background: var(--e-guion-bg); }
.chip.e-produccion { color: var(--e-produccion); background: var(--e-produccion-bg); }
.chip.e-edicion { color: var(--e-edicion); background: var(--e-edicion-bg); }
.chip.e-listo { color: var(--e-listo); background: var(--e-listo-bg); }
.chip.e-publicado { color: var(--e-publicado); background: var(--e-publicado-bg); }
/* Seleccionado: el color propio en sólido, para no perder la identidad. */
.chip.is-on.p-smowl { background: var(--p-smowl); color: var(--white); }
.chip.is-on.p-ldb { background: var(--p-ldb); color: var(--white); }
.chip.is-on.p-seb { background: var(--p-seb); color: var(--white); }
.chip.is-on.p-proctorio { background: var(--p-proctorio); color: var(--white); }
.chip.is-on.e-idea { background: var(--e-idea); color: var(--white); }
.chip.is-on.e-guion { background: var(--e-guion); color: var(--white); }
.chip.is-on.e-produccion { background: var(--e-produccion); color: var(--white); }
.chip.is-on.e-edicion { background: var(--e-edicion); color: var(--white); }
.chip.is-on.e-listo { background: var(--e-listo); color: var(--white); }
.chip.is-on.e-publicado { background: var(--e-publicado); color: var(--white); }

.chipset-pick .chip { height: 38px; font-size: .85rem; }

.bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: .86rem; font-weight: 600;
}
.bulkbar > span:first-child { flex: 1; }
.bulkbar .select { background: var(--white); }

/* ==========================================================================
   Tarjeta de guion
   ========================================================================== */

.scripts-root { display: flex; flex-direction: column; gap: 12px; }

.group-head {
  display: flex; align-items: center; gap: 8px;
  margin: 20px 0 4px;
  font-size: 1rem; font-weight: 700; letter-spacing: -.01em;
  color: var(--text);
}
.group-head:first-child { margin-top: 0; }
.group-head .n {
  font-size: .74rem; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border-radius: var(--r-pill); padding: 2px 9px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow-1); border-color: var(--line-2); }
.card.is-selected { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }

.card-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  cursor: pointer; user-select: none;
  border-radius: var(--r-lg);
  transition: background .1s;
}
.card-head:hover { background: var(--bg-soft); }

.card-num {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
  transition: background .1s, color .1s;
}
.card-num:hover { background: var(--text); color: var(--text-inv); }
.card.p-smowl .card-num { background: var(--p-smowl-bg); color: var(--p-smowl); }
.card.p-ldb .card-num { background: var(--p-ldb-bg); color: var(--p-ldb); }
.card.p-seb .card-num { background: var(--p-seb-bg); color: var(--p-seb); }
.card.p-proctorio .card-num { background: var(--p-proctorio-bg); color: var(--p-proctorio); }
.card.is-selected .card-num { background: var(--text); color: var(--text-inv); }

.card-title-area { flex: 1; min-width: 0; }
.card-title {
  font-size: 1rem; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }

.tag {
  font-size: .74rem; font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.tag-platform.p-smowl { background: var(--p-smowl-bg); color: var(--p-smowl); }
.tag-platform.p-ldb { background: var(--p-ldb-bg); color: var(--p-ldb); }
.tag-platform.p-seb { background: var(--p-seb-bg); color: var(--p-seb); }
.tag-platform.p-proctorio { background: var(--p-proctorio-bg); color: var(--p-proctorio); }
.tag-ai { background: var(--red-soft); color: var(--red); }
.tag-date { background: transparent; color: var(--text-3); padding-left: 2px; }

.estado-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: var(--r-pill);
  padding: 3px 8px 3px 9px;
  font-size: .74rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
  transition: filter .1s;
}
button.estado-pill:hover { filter: brightness(.94); }
.estado-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.estado-caret { font-size: 11px; opacity: .6; }

.e-idea { background: var(--e-idea-bg); color: var(--e-idea); }
.e-guion { background: var(--e-guion-bg); color: var(--e-guion); }
.e-produccion { background: var(--e-produccion-bg); color: var(--e-produccion); }
.e-edicion { background: var(--e-edicion-bg); color: var(--e-edicion); }
.e-listo { background: var(--e-listo-bg); color: var(--e-listo); }
.e-publicado { background: var(--e-publicado-bg); color: var(--e-publicado); }

.card-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.card-body { display: none; border-top: 1px solid var(--line); }
.card.is-open .card-body { display: block; }

.sec { border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }

.sec-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  cursor: pointer; user-select: none;
  transition: background .1s;
}
.sec-head:hover { background: var(--bg-soft); }

.sec-num {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: var(--r-sm); display: grid; place-items: center;
  font-size: .72rem; font-weight: 700;
}
.sn-1 { background: var(--p-ldb-bg); color: var(--p-ldb); }
.sn-2 { background: var(--p-smowl-bg); color: var(--p-smowl); }
.sn-3 { background: var(--p-seb-bg); color: var(--p-seb); }
.sn-4 { background: var(--p-proctorio-bg); color: var(--p-proctorio); }
.sn-5 { background: var(--red-soft); color: var(--red); }

.sec-title { flex: 1; font-size: .92rem; font-weight: 600; }
.sec-toggle { color: var(--text-3); font-size: 15px; transition: transform .2s; }
.sec.is-open .sec-toggle { transform: rotate(180deg); }
.sec-content { display: none; padding: 2px 16px 20px 54px; }
.sec.is-open .sec-content { display: block; }

.f { margin-bottom: 16px; }
.f:last-child { margin-bottom: 0; }
.f-label {
  font-size: .7rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px;
}
.f-value { font-size: .92rem; color: var(--text-2); white-space: pre-line; }
.f-value.strong { color: var(--text); font-weight: 600; }

.hook-box {
  color: var(--text); font-weight: 700; font-size: 1.05rem; line-height: 1.35;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-soft);
  border-left: 4px solid var(--red);
}

.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-item {
  display: flex; gap: 14px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
}
.tl-time {
  font-family: var(--mono); font-size: .74rem; font-weight: 500;
  color: var(--red); flex-shrink: 0; width: 44px; padding-top: 2px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-beat { font-size: .68rem; font-weight: 700; letter-spacing: .07em; color: var(--text-3); }
.tl-text { font-size: .92rem; color: var(--text); margin: 2px 0 6px; font-weight: 500; }
.tl-extra { font-size: .78rem; color: var(--text-3); display: flex; flex-direction: column; gap: 3px; }
.tl-extra span { display: flex; gap: 8px; }
.tl-extra b {
  font-weight: 700; font-size: .64rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); flex-shrink: 0; width: 44px; padding-top: 2px;
}

.res-list { list-style: none; }
.res-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: .9rem; color: var(--text-2);
}
.res-list li:last-child { border-bottom: 0; }
.res-list b { color: var(--text); font-weight: 700; }

.code {
  background: var(--bg-soft);
  border-radius: var(--r-md);
  padding: 16px;
  font-family: var(--mono);
  font-size: .78rem; line-height: 1.75;
  color: #333;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.hashtags {
  font-family: var(--mono); font-size: .78rem;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  word-break: break-word;
  line-height: 1.7;
}

.sec-tools { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

/* ==========================================================================
   Mosaico y columnas
   ========================================================================== */

.masonry { columns: 3 340px; column-gap: 14px; }
.masonry-item { break-inside: avoid; margin-bottom: 14px; }

.cols-scroll { overflow-x: auto; padding-bottom: 12px; margin: 0 -4px; }
.cols { display: flex; gap: 14px; padding: 0 4px; align-items: flex-start; }
.cols-col { width: 330px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.cols-col > .group-head { margin: 0 0 2px; }
.cols .card-body { max-height: 440px; overflow-y: auto; }

/* En tarjetas estrechas solo caben la estrella y el chevrón. */
.cols .card-actions .icon-btn,
.masonry .card-actions .icon-btn { display: none; }
.cols .card-actions .icon-btn.chev,
.cols .card-actions .icon-btn[data-act="star"],
.masonry .card-actions .icon-btn.chev,
.masonry .card-actions .icon-btn[data-act="star"] { display: grid; }
.cols .sec-content,
.masonry .sec-content { padding-left: 16px; }
.cols .card-title,
.masonry .card-title { font-size: .95rem; }

/* ==========================================================================
   Tabla
   ========================================================================== */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 860px; }
table.grid th {
  text-align: left; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-soft); position: sticky; top: 0; z-index: 2;
}
table.grid td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: var(--bg-soft); }
table.grid .t-num { color: var(--text-3); font-weight: 600; width: 48px; }
table.grid .t-title { color: var(--text); font-weight: 600; cursor: pointer; }
table.grid .t-title:hover { text-decoration: underline; text-underline-offset: 3px; }
table.grid .t-right { text-align: right; }
table.grid .t-right .card-actions { justify-content: flex-end; }

/* ==========================================================================
   Tablero de producción (kanban)
   ========================================================================== */

.kanban-scroll { overflow-x: auto; padding: 4px 0 24px; margin: 0 -4px; }
.kanban { display: flex; gap: 14px; padding: 0 4px; align-items: flex-start; min-height: 60vh; }

.kcol {
  width: 300px; flex-shrink: 0;
  background: var(--bg-soft);
  border-radius: var(--r-lg);
  padding: 14px 12px 12px;
  display: flex; flex-direction: column;
}

.kcol-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.kcol-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.kcol.e-idea .kcol-dot { background: var(--e-idea); }
.kcol.e-guion .kcol-dot { background: var(--e-guion); }
.kcol.e-produccion .kcol-dot { background: var(--e-produccion); }
.kcol.e-edicion .kcol-dot { background: var(--e-edicion); }
.kcol.e-listo .kcol-dot { background: var(--e-listo); }
.kcol.e-publicado .kcol-dot { background: var(--e-publicado); }

.kcol-head h3 { flex: 1; font-size: .92rem; font-weight: 700; letter-spacing: -.01em; }
.kcol-n {
  font-size: .74rem; font-weight: 700; color: var(--text-3);
  background: var(--surface-3); border-radius: var(--r-pill); padding: 1px 9px;
}
.kcol-desc { font-size: .74rem; color: var(--text-3); padding: 4px 4px 12px; line-height: 1.35; }

.kcol-body {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 90px; border-radius: var(--r-md);
  transition: background .12s, box-shadow .12s;
}
.kcol-body.is-over { background: var(--focus); box-shadow: inset 0 0 0 2px var(--blue); }

.kcol-empty {
  border: 1.5px dashed var(--surface-4);
  border-radius: var(--r-md);
  padding: 20px 12px;
  text-align: center;
  font-size: .78rem; color: var(--text-3);
}

.kcard {
  background: var(--white);
  border-radius: var(--r-md);
  padding: 12px;
  box-shadow: var(--shadow-1);
  cursor: grab;
  transition: box-shadow .12s, transform .12s;
}
.kcard:hover { box-shadow: var(--shadow-2); }
.kcard:active { cursor: grabbing; }
.kcard.is-dragging { opacity: .45; transform: rotate(1.5deg); }

.kcard-top { display: flex; align-items: flex-start; gap: 6px; }
.kcard-drag { color: var(--surface-4); font-size: 15px; padding-top: 2px; }
.kcard-title {
  flex: 1; font-size: .88rem; font-weight: 700; line-height: 1.3;
  cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kcard-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.kcard-hook {
  font-size: .78rem; color: var(--text-3); margin: 6px 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kcard-meta { display: flex; gap: 5px; flex-wrap: wrap; }
.kcard-meta .tag { font-size: .68rem; padding: 2px 8px; }

/* ==========================================================================
   Menú flotante
   ========================================================================== */

.popmenu {
  position: fixed; z-index: 200;
  min-width: 216px;
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 8px;
  animation: pop-in .12s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.popmenu-head {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); padding: 6px 10px 8px;
}
.popmenu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: 0; background: transparent; border-radius: var(--r-sm);
  font-size: .88rem; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left;
}
.popmenu-item span { flex: 1; }
.popmenu-item svg { font-size: 16px; color: var(--red); }
.popmenu-item:hover { background: var(--surface-2); }
.popmenu-item .estado-dot { width: 9px; height: 9px; }
.popmenu-item.e-idea { background: transparent; color: var(--text); }
.popmenu-item.e-idea .estado-dot { background: var(--e-idea); }
.popmenu-item.e-guion .estado-dot { background: var(--e-guion); }
.popmenu-item.e-produccion .estado-dot { background: var(--e-produccion); }
.popmenu-item.e-edicion .estado-dot { background: var(--e-edicion); }
.popmenu-item.e-listo .estado-dot { background: var(--e-listo); }
.popmenu-item.e-publicado .estado-dot { background: var(--e-publicado); }
.popmenu-item[class*="e-"] { background: transparent; color: var(--text); }
.popmenu-item[class*="e-"]:hover { background: var(--surface-2); }

/* ==========================================================================
   Ganchos
   ========================================================================== */

.hooks-root { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

.hook-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s;
}
.hook-card:hover { box-shadow: var(--shadow-1); }
.hook-card.is-off { opacity: .5; }
.hook-card-top { display: flex; align-items: flex-start; gap: 10px; }
.hook-label { flex: 1; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.hook-text { font-size: .9rem; color: var(--text-2); }
.hook-example {
  font-size: .82rem; color: var(--text-3);
  border-left: 3px solid var(--line-2); padding-left: 12px;
}
.hook-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 4px; }
.hook-uses {
  font-size: .74rem; font-weight: 700;
  background: var(--red-soft); color: var(--red);
  padding: 3px 10px; border-radius: var(--r-pill);
}

/* ==========================================================================
   Paneles y formularios
   ========================================================================== */

.gen-grid, .io-grid { display: grid; gap: 16px; }
.gen-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.io-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.panel-hint { font-size: .8rem; color: var(--text-3); }
.panel-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel-run { grid-column: 1 / -1; }

.subpanel {
  background: var(--bg-soft);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.subpanel h4 { font-size: .92rem; font-weight: 700; }
.subpanel .field input, .subpanel .field textarea { background: var(--white); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .field-label {
  font-size: .74rem; font-weight: 700; color: var(--text-2);
}
.field em { font-style: normal; font-weight: 500; color: var(--text-3); }

.field input[type="text"], .field input[type="number"], .field input[type="password"],
.field textarea {
  width: 100%;
  background: var(--white);
  border: 2px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 11px 14px;
  font-size: .92rem;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { resize: vertical; font-family: inherit; line-height: 1.55; }
.field input:focus, .field textarea:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 4px var(--focus);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:disabled { background: var(--surface-2); color: var(--text-3); }

.check { display: flex; align-items: center; gap: 10px; font-size: .88rem; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--red); cursor: pointer; }

.muted { color: var(--text-3); font-size: .86rem; }
.model-note { font-size: .82rem; color: var(--text-3); }

/* Formatos con cantidad */
.qty-list { display: flex; flex-direction: column; gap: 6px; }
.qty-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 14px;
  background: var(--bg-soft);
  border-radius: var(--r-pill);
  transition: background .1s, box-shadow .1s;
}
.qty-row.is-on { background: var(--red-soft); box-shadow: inset 0 0 0 2px var(--red); }
.qty-label { flex: 1; font-size: .88rem; font-weight: 600; }
.qty-row.is-on .qty-label { color: var(--red-hover); }
.qty-ctrl {
  display: flex; align-items: center; gap: 2px;
  background: var(--white); border-radius: var(--r-pill); padding: 2px;
}
.qty-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text-2);
  font-size: 1.05rem; font-weight: 700; line-height: 1;
  cursor: pointer;
}
.qty-btn:hover { background: var(--surface-2); color: var(--text); }
.qty-input {
  width: 38px; height: 28px;
  border: 0; background: transparent;
  text-align: center; font-size: .88rem; font-weight: 700;
  outline: none;
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.batch-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.batch-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.batch-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .1s, box-shadow .1s;
}
.batch-item:hover { background: var(--surface-2); }
.batch-item.is-on { background: var(--red-soft); box-shadow: inset 0 0 0 2px var(--red); }
.batch-item input { margin-top: 2px; accent-color: var(--red); width: 17px; height: 17px; }
.batch-item-body { flex: 1; min-width: 0; }
.batch-item-title { font-size: .9rem; font-weight: 600; }
.batch-item-meta { font-size: .78rem; color: var(--text-3); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

.queue-preview {
  max-height: 240px; overflow-y: auto;
  border-radius: var(--r-md);
  background: var(--bg-soft);
}
.queue-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: .84rem; color: var(--text-2);
}
.queue-row:last-child { border-bottom: 0; }
.queue-row .qi { font-family: var(--mono); font-size: .74rem; color: var(--text-3); width: 24px; flex-shrink: 0; }
.queue-row .qh { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.queue-row.is-done { color: #0a7c42; }
.queue-row.is-fail { color: var(--red); }
.queue-row.is-run { color: var(--text); font-weight: 700; }

.run-row { display: flex; gap: 8px; align-items: center; }

.progress { display: flex; flex-direction: column; gap: 8px; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--red); border-radius: var(--r-pill); transition: width .3s; }
.progress-text { font-size: .82rem; color: var(--text-3); font-weight: 500; }

.run-log {
  max-height: 240px; overflow-y: auto;
  font-family: var(--mono); font-size: .74rem; line-height: 1.8;
  background: var(--bg-soft);
  border-radius: var(--r-md); padding: 14px;
  color: var(--text-2);
}
.run-log .ok { color: #0a7c42; }
.run-log .err { color: var(--red); }

.dropzone {
  border: 2px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-3);
  transition: border-color .12s, background .12s, color .12s;
}
.dropzone svg { font-size: 30px; margin-bottom: 6px; }
.dropzone strong { color: var(--text); font-size: .95rem; font-weight: 700; }
.dropzone span { font-size: .82rem; }
.dropzone:hover, .dropzone.is-over { border-color: var(--red); background: var(--red-soft); color: var(--red-hover); }
.dropzone:hover strong, .dropzone.is-over strong { color: var(--red-hover); }

.import-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.import-result {
  font-size: .88rem; font-weight: 600; padding: 12px 14px; border-radius: var(--r-md);
  background: #e2f5ea; color: #0a7c42;
}
.import-result.is-bad { background: var(--red-soft); color: var(--red-hover); }

.io-links { display: flex; gap: 8px; flex-wrap: wrap; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-back {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0, 0, 0, .5);
  display: grid; place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.modal {
  width: min(780px, 100%);
  max-height: 88vh;
  background: var(--white);
  border-radius: 32px;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 24px 16px;
}
.modal-head h3 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.modal-head .icon-btn { width: 40px; height: 40px; font-size: 18px; }
.modal-body { padding: 4px 24px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 16px 24px 20px; border-top: 1px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-soft);
  border-radius: var(--r-md); padding: 12px;
}
.row-item .grow { flex: 1; display: grid; gap: 8px; min-width: 0; }
.row-item input, .row-item textarea {
  width: 100%; background: var(--white); border: 2px solid var(--line-2);
  border-radius: var(--r-sm); padding: 8px 11px; font-size: .86rem; outline: none;
  font-family: inherit;
}
.row-item input:focus, .row-item textarea:focus {
  border-color: var(--white); box-shadow: 0 0 0 3px var(--focus);
}
.row-cols { display: grid; grid-template-columns: 84px 1fr; gap: 8px; }

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-root {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--text-inv);
  border-radius: var(--r-lg);
  padding: 14px 20px;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow-3);
  animation: toast-in .18s ease-out;
  max-width: 420px;
}
.toast.is-bad { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Vacíos
   ========================================================================== */

.empty {
  text-align: center; padding: 72px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-mark {
  width: 64px; height: 64px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-3);
  display: grid; place-items: center; font-size: 28px;
  margin-bottom: 4px;
}
.empty strong { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; }
.empty p { font-size: .92rem; max-width: 400px; color: var(--text-3); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  .masonry { columns: 2 320px; }
}

@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; padding: 0 10px; gap: 6px; }
  .top-quick { display: none; }
  .logo { width: 40px; height: 40px; font-size: 22px; }
  .round-btn { width: 40px; height: 40px; font-size: 18px; }
  .searchbar input { height: 44px; font-size: .9rem; }

  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 6px 10px; position: sticky; top: var(--topbar-h); z-index: 50;
  }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; height: 40px; padding: 0 14px; flex-shrink: 0; }
  .nav-item em { display: none; }
  .sidebar-foot { display: none; }

  .main { overflow: visible; }
  .view { padding: 4px 16px 60px; }
  .page-head h2 { font-size: 1.35rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hooks-root { grid-template-columns: 1fr; }
  .masonry { columns: 1; }
  .modal { border-radius: 24px; }
  .modal-body { padding-left: 18px; padding-right: 18px; }
  .sec-content { padding-left: 16px; }
  .toast-root { bottom: 16px; left: 16px; right: 16px; transform: none; }
  .toast { max-width: none; width: 100%; }
}
