/* ═══════════════════════════════════════════════════════════════════════════
   Centro de Trabajo Comunicación UNSL-VM — Main Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom properties ─────────────────────────────────────────────────────
   Paleta alineada con pm-v2 (Linear / Gestor Institucional)
   ─────────────────────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds — cool-tinted darks (misma paleta que pm-v2) */
  --bg:           #0D0D0F;
  --surface:      #111113;
  --surface-2:    #17171A;
  --surface-3:    #1E1E22;
  --surface-hover:#27272B;
  --border:       #2C2C30;
  --border-l:     #3A3A3F;

  /* Accent — indigo (Linear / pm-v2) */
  --accent:       #5E6AD2;
  --accent-dark:  #4F5BC4;
  --accent-glow:  rgba(94,106,210,.18);

  --gold:    #ffd166;
  --success: #4CC38A;
  --warning: #F5A623;

  /* Text */
  --txt:   #EDEDF0;
  --txt-2: #8B8B99;
  --txt-3: #4A4A55;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 2px 16px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.3);
  --shadow-card: 0 1px 3px rgba(0,0,0,.2);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv01','cv03','ss01';
}
code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .85em;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-8   { margin-top: 8px; }

/* ══════════════════════════════════════════════════════════ LOGIN SCREEN ══ */
#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(230,57,70,.12) 0%, var(--bg) 70%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.login-sub {
  color: var(--txt-2);
  font-size: .9rem;
  text-align: center;
  margin-bottom: 20px;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  color: #f87171;
  font-size: .85rem;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════ APP HEADER ══ */
#screen-app { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #1E1F6B;
  border-bottom: 2px solid #F5A623;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 14px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  justify-content: flex-end;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.header-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 26px;
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
}

.brand-title {
  font-size: .76rem;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  letter-spacing: -.01em;
}

/* Botones del header sobre fondo azul */
.btn-theme, .btn-history, .btn-settings, .btn-back, .btn-home {
  color: rgba(255,255,255,.85) !important;
  border-color: rgba(255,255,255,.2) !important;
}
.btn-theme:hover, .btn-history:hover, .btn-settings:hover,
.btn-back:hover, .btn-home:hover {
  background: rgba(255,255,255,.12) !important;
  color: #fff !important;
}

.btn-back {
  background: transparent;
  border: 1px solid var(--border-l);
  color: var(--txt-2);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem;
  white-space: nowrap;
  transition: all .15s;
}
.btn-back:hover { background: var(--surface-2); color: var(--txt); }

.btn-home {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-2);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem;
  white-space: nowrap;
  transition: all .15s;
}

/* History button */
.btn-history {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-3);
  padding: 5px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  transition: all .15s;
}
.btn-history:hover { border-color: var(--gold); color: var(--gold); }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-3);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
  white-space: nowrap;
  transition: all .15s;
  text-align: right;
}
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════════════ APP MAIN ══ */
.app-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════════════ SCREEN TRANSITIONS ══ */
@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-enter {
  animation: screenFadeIn 0.3s ease forwards;
}

/* ══════════════════════════════════════════════════════════ HOME SCREEN ══ */
#screen-app { min-height: 100vh; display: flex; flex-direction: column; }

#screen-home {
  flex: 1;
  overflow-y: auto;
}

/* ── Home sidebar + content layout ────────────────────────────────────── */
.home-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 52px);
  overflow: hidden;
  font-family: var(--font);
}

/* Sidebar */
.home-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.home-sidebar-top {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.home-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  overflow: hidden;
}

.home-brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.home-brand-text {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.home-brand-text strong {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.02em;
}

.home-brand-text span {
  display: block;
  font-size: .64rem;
  color: var(--txt-3);
  white-space: nowrap;
  letter-spacing: -.01em;
}

/* Profile tabs in sidebar */
.home-profile-switcher {
  display: flex;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}

.profile-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--txt-3);
  font-size: .76rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
  text-align: center;
  letter-spacing: -.01em;
}

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

.profile-btn--active {
  background: var(--surface-3);
  color: var(--txt);
  font-weight: 600;
}

/* Sidebar nav */
.home-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
}
.home-nav::-webkit-scrollbar { display: none; }

.home-nav-group { margin-bottom: 4px; }

.home-nav-group-label {
  padding: 8px 8px 3px;
  font-size: .58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--txt-3);
  white-space: nowrap;
}

.home-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 5px;
  margin-bottom: 1px;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 450;
  color: var(--txt-2);
  cursor: pointer;
  transition: background .12s, color .12s;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -.015em;
}

.home-nav-item:hover { background: var(--surface-2); color: var(--txt); }

.home-nav-icon {
  font-size: .8rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: .6;
}

.home-nav-item:hover .home-nav-icon { opacity: 1; }

/* Sidebar footer */
.home-sidebar-footer {
  padding: 8px 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Main content */
.home-content {
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.home-content-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}

.home-greeting {
  font-size: .82rem;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -.02em;
}

.home-stat-sep { color: var(--txt-3); font-size: .82rem; }

.home-stat-text {
  font-size: .78rem;
  color: var(--txt-3);
}

.home-tool-main {
  padding: 20px 24px;
  flex: 1;
}

/* Tool sections */
.home-section-block {
  margin-bottom: 24px;
}

.home-section-block-label {
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--txt-3);
  margin-bottom: 6px;
  padding-left: 2px;
}

/* Tool rows — estilo pm-v2 */
.home-tool-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  color: var(--txt);
  text-align: left;
  width: 100%;
  transition: background .12s, border-color .12s;
  letter-spacing: -.01em;
}

.home-tool-row:hover {
  background: var(--surface-2);
  border-color: var(--border-l);
}

.home-tool-icon {
  font-size: 1.1rem;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.home-tool-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.home-tool-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--txt);
  line-height: 1.3;
}

.home-tool-desc {
  font-size: .74rem;
  color: var(--txt-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-tool-badge {
  font-size: .62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: .03em;
}

.home-tool-badge--ai {
  background: rgba(94,106,210,.15);
  color: #8B96E9;
}

.home-tool-arrow {
  color: var(--txt-3);
  font-size: 1.1rem;
  flex-shrink: 0;
  font-weight: 300;
  transition: color .12s, transform .12s;
}

.home-tool-row:hover .home-tool-arrow {
  color: var(--txt-2);
  transform: translateX(2px);
}

/* Fila destacada (Gestión de Tareas) */
.home-tool-row.option-card--featured {
  border-color: rgba(94,106,210,.3);
  background: rgba(94,106,210,.06);
}

.home-tool-row.option-card--featured:hover {
  background: rgba(94,106,210,.1);
  border-color: rgba(94,106,210,.5);
}

/* Fila IA */
.home-tool-row.option-card--ai {
  border-color: rgba(94,106,210,.2);
}

/* ── Option cards ─────────────────────────────────────────────────────── */
.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
  transition: background .15s, border-color .15s, box-shadow .15s;
  width: 100%;
}
.option-card:hover {
  background: var(--surface-2);
  border-color: var(--border-l);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.option-icon {
  font-size: 2.4rem;
  line-height: 1;
}
.option-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -.02em;
  line-height: 1.3;
}
/* Option grid */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  max-width: 100%;
}
body.compact .option-card { padding: 16px 12px; }
body.compact .option-icon { font-size: 1.8rem; }
/* Featured card — wide horizontal row */
.option-card--featured {
  flex-direction: row;
  text-align: left;
  gap: 20px;
  grid-column: 1 / -1;
  padding: 20px 28px;
  border-color: rgba(94,106,210,.35);
  background: rgba(94,106,210,.06);
}
.option-card--featured .option-icon {
  font-size: 2.2rem;
  flex-shrink: 0;
}
.option-card--featured .option-label {
  font-size: .95rem;
  font-weight: 700;
}
.option-card--featured:hover {
  background: rgba(94,106,210,.1);
  border-color: rgba(94,106,210,.5);
}
.tools-group { display: contents; }

#screen-work {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════ SUBCHOICE ══ */
.subchoice-screen {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 28px;
  min-height: 100%;
  background: var(--bg);
  overflow-y: auto;
  max-width: 960px;
  margin: 0 auto;
  box-sizing: border-box;
  width: 100%;
}

.subchoice-screen h2 {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--txt-3);
}

.subchoice-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.subchoice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 11px 18px;
  cursor: pointer;
  font-family: var(--font);
  color: var(--txt);
  transition: background .12s, border-color .12s;
}

.subchoice-card:hover {
  background: var(--surface-2);
  border-color: var(--border-l);
}

.subchoice-card .sc-icon { font-size: 1.2rem; flex-shrink: 0; }
.subchoice-card .sc-logo { height: 30px; width: auto; max-width: 80px; object-fit: contain; flex-shrink: 0; }
.subchoice-card .sc-label { font-size: .84rem; font-weight: 600; }

.subchoice-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subchoice-section-label {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--txt-3);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.subchoice-grid--row {
  flex-wrap: wrap;
  gap: 8px;
}

.subchoice-grid--row .subchoice-card {
  padding: 10px 16px;
  gap: 8px;
}

.subchoice-grid--row .subchoice-card .sc-icon { font-size: 1rem; }
.subchoice-grid--row .subchoice-card .sc-logo { height: 26px; }
.subchoice-grid--row .subchoice-card .sc-label { font-size: .82rem; }

/* ══════════════════════════════════════════════════════════ WORK HEADER ══ */
.work-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.work-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--txt);
}

.work-badge {
  background: rgba(94,106,210,.15);
  color: #8B96E9;
  font-size: .62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .04em;
}

/* ══════════════════════════════════════════════════════════ WORK LAYOUT ══ */
.work-layout {
  display: grid;
  grid-template-columns: 300px 1fr 1fr;
  gap: 20px;
  align-items: start;
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 24px;
  box-sizing: border-box;
  width: 100%;
}
/* Para imágenes de página web (FICA/FCEJS): un solo panel de preview a ancho completo */
.work-layout--page {
  grid-template-columns: 300px 1fr;
}
.work-layout--page .preview-panel--page {
  grid-column: 2 / -1;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  position: sticky;
  top: 76px;
}

/* ══════════════════════════════════════════════════════════ PREVIEW PANEL ══ */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Área de canvas limpia para imágenes de página web (sin frame Instagram) */
.page-canvas-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--surface-2, #1a1a1a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 200px;
}

.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  color: var(--txt-2);
  padding: 0 2px;
}

.preview-bar span:first-child { font-weight: 600; color: var(--txt); }

.px-label { color: var(--txt-3); font-size: .75rem; }

/* ── Canvas wrapper ──────────────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.canvas-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
}

.ra-wave-overlay {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  width: min(92%, 980px);
  pointer-events: none;
  z-index: 3;
}

.ra-wave-overlay img {
  display: block;
  width: 100%;
  height: auto;
}

.canvas-wrap canvas.has-photo  { cursor: grab; user-select: none; }
.canvas-wrap canvas.grabbing   { cursor: grabbing !important; }

/* Canvas activo en modo desacoplado */
.canvas-wrap.editing-active {
  box-shadow: 0 0 0 2px var(--accent);
}

.edit-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 99px;
  pointer-events: none;
}

/* ── Couple / Decouple row ───────────────────────────────────────────────── */
.couple-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.btn-secondary.decoupled {
  border-color: var(--gold);
  color: var(--gold);
}

.edit-selector {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: .78rem;
  color: var(--txt-2);
  min-width: 0;
}

.edit-selector-label {
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--txt-3);
}

.edit-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.edit-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .8rem;
  font-family: var(--font);
  color: var(--txt-2);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  text-align: left;
}

.edit-pill.active {
  background: var(--surface);
  border-color: var(--gold);
  color: var(--txt);
  box-shadow: 0 0 0 1px rgba(255, 193, 7, .22), var(--shadow-sm);
}

.edit-pill-kicker {
  font-size: .9rem;
  line-height: 1;
}

.edit-pill-title {
  font-weight: 700;
  line-height: 1.1;
}

.edit-pill-subtitle {
  font-size: .72rem;
  color: var(--txt-3);
  line-height: 1.1;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--txt-3);
  pointer-events: none;
  padding: 24px;
}

.canvas-placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 2px dashed var(--border-l);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 100%;
  max-width: 280px;
}

.canvas-placeholder span { font-size: 2.4rem; opacity: .45; }
.canvas-placeholder p    { font-size: .82rem; text-align: center; color: var(--txt-3); line-height: 1.5; }
.canvas-placeholder p strong { color: var(--txt-2); font-weight: 600; }

/* Download row under canvases */
.dl-row {
  display: flex;
  gap: 8px;
}

.dl-row .btn-primary { flex: 1; font-size: .82rem; padding: 10px 8px; }

/* ── Panel action buttons (copy, share, download per canvas) ─────────────── */
.panel-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.panel-actions .btn-sm {
  flex: 1;
  font-size: .78rem !important;
  padding: 7px 6px !important;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════ FIELD GROUPS ══ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group > label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--txt-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field-group textarea,
.field-group input[type="text"],
.field-group input[type="password"],
.field-group input[type="number"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-family: var(--font);
  font-size: .9rem;
  padding: 9px 12px;
  width: 100%;
  resize: vertical;
  transition: border-color .15s;
}

.field-group textarea:focus,
.field-group input[type="text"]:focus,
.field-group input[type="password"]:focus,
.field-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.field-group textarea { min-height: 72px; }

.sub-label {
  font-size: .75rem;
  color: var(--txt-2);
  display: block;
  margin-bottom: 2px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

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

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.range-val {
  font-size: .75rem;
  color: var(--txt-2);
  min-width: 36px;
  text-align: right;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════ RESIZE HANDLES ══ */
.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .1s;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.canvas-wrap.has-media .resize-handle {
  opacity: 1;
  pointer-events: auto;
}
.canvas-wrap.has-media:hover .resize-handle {
  transform: scale(1.2);
}
.resize-handle--tl { top: 6px;    left: 6px;    cursor: nw-resize; }
.resize-handle--tr { top: 6px;    right: 6px;   cursor: ne-resize; }
.resize-handle--bl { bottom: 6px; left: 6px;    cursor: sw-resize; }
.resize-handle--br { bottom: 6px; right: 6px;   cursor: se-resize; }

/* canvas drag hint */
.canvas-drag-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.6);
  color: rgba(255,255,255,.8);
  font-size: .65rem;
  padding: 3px 8px;
  border-radius: 99px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s;
  z-index: 15;
}
.canvas-wrap.has-media:hover .canvas-drag-hint { opacity: 1; }

/* Video rotation bar */
.rv-rotate-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 0 2px;
}
.rv-rotate-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-l);
  color: var(--txt-2);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.rv-rotate-btn:hover { background: var(--surface-3); color: var(--txt); border-color: var(--accent); }
.rv-rotate-val {
  font-size: .78rem;
  font-weight: 700;
  color: var(--txt-3);
  min-width: 28px;
  text-align: center;
}

/* Number input for font size */
.fs-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 600;
  padding: 7px 10px;
  width: 100%;
  transition: border-color .15s;
}
.fs-input:focus { outline: none; border-color: var(--accent); }
.fs-input::-webkit-inner-spin-button { opacity: 1; cursor: pointer; }

/* Text section header (Texto 1 / Texto 2) */
.text-section {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.text-section-header {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

input[type="color"].color-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  padding: 3px 4px;
}

.field-hint {
  font-size: .75rem;
  color: var(--txt-3);
  line-height: 1.4;
}

/* Check label */
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--txt-2);
}

.check-label input[type="checkbox"] { accent-color: var(--accent); }

/* ── Adjust controls ─────────────────────────────────────────────────────── */
.adjust-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

/* ── Template upload slots (OTRO) ───────────────────────────────────────── */
.tpl-upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tpl-upload-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  align-items: flex-start;
}

.tpl-status {
  font-size: .72rem;
  color: var(--success);
  word-break: break-all;
}

/* ══════════════════════════════════════════════════════════ BUTTONS ══ */
.btn-primary {
  background: var(--accent);
  color: rgba(255,255,255,.95);
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-weight: 600;
  font-size: .84rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s;
  text-align: center;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}

.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { opacity: .9; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-3);
  color: var(--txt-2);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 500;
  font-size: .82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s, color .12s;
  letter-spacing: -.01em;
}

.btn-secondary:hover { background: var(--surface-hover); color: var(--txt); }

.btn-danger {
  background: rgba(229,72,77,.12);
  color: #E5484D;
  border: 1px solid rgba(229,72,77,.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s;
  font-size: .82rem;
}

.btn-danger:hover { background: rgba(229,72,77,.2); }

.btn-sm { padding: 5px 10px !important; font-size: .76rem !important; }

.full-width { width: 100%; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════ DROP ZONES ══ */
.drop-zone {
  border: 2px dashed var(--border-l);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--txt-2);
  font-size: .85rem;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--txt);
}

.drop-zone.has-file {
  border-color: var(--success);
  background: rgba(46,196,182,.06);
}

.dz-icon { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.dz-hint { font-size: .75rem; color: var(--txt-3); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════ REEL TABS ══ */
.reel-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 0;
}

.reel-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--txt-2);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.reel-tab-btn.active {
  background: var(--surface-3);
  color: var(--txt);
}

.reel-tab-pane { display: none; }
.reel-tab-pane.active { display: flex; flex-direction: column; gap: 14px; }

/* ══════════════════════════════════════════════════════════ PROGRESS ══ */
.progress-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.progress-label { font-size: .82rem; color: var(--txt-2); }
.progress-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.progress-pct   { font-size: .78rem; color: var(--txt-3); text-align: right; }

/* ══════════════════════════════════════════════════════════ TIME INPUT ══ */
.time-input {
  font-family: 'JetBrains Mono', monospace !important;
  text-align: center;
  letter-spacing: .1em;
}

/* ══════════════════════════════════════════════════════════ TOAST ══ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-3);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: .875rem;
  color: var(--txt);
  z-index: 999;
  opacity: 0;
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show          { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success       { border-color: var(--success); color: var(--success); }
.toast.error         { border-color: var(--accent);  color: #f87171; }

/* ══════════════════════════════════════════════════════════ SCROLLBAR ══ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-l); }

/* ══════════════════════════════════════════════════════════ RESPONSIVE ══ */
@media (max-width: 1100px) {
  .work-layout {
    grid-template-columns: 280px 1fr 1fr;
    gap: 14px;
  }
}

@media (max-width: 860px) {
  .work-layout {
    grid-template-columns: 1fr;
  }
  .controls-col {
    position: static;
    max-height: none;
  }
  .app-main { padding: 20px 16px; }
}

/* ══════════════════════════════════════════════════════════════════ HOME EXTRAS ══ */

.home-section {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.home-section-title {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.hs-icon { font-size: .85rem; }

/* Home: recent thumbs */
.home-recent-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.home-recent-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .12s;
}

.home-recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-recent-thumb:hover { border-color: var(--border-l); }

/* ══════════════════════════════════════════════════════ HOME SPLASH ══ */
#screen-home {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(ellipse 700px 500px at 50% 42%, rgba(94,106,210,.09) 0%, transparent 100%),
    radial-gradient(ellipse 300px 200px at 20% 70%, rgba(94,106,210,.04) 0%, transparent 100%);
}

.home-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding: 32px 24px;
  width: 100%;
  max-width: 620px;
}

/* ── Hero text ── */
.home-hero { text-align: center; }

.home-hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--txt);
  letter-spacing: -.03em;
  line-height: 1.1;
  margin: 0 0 8px;
}

.home-hero-sub {
  font-size: .8rem;
  color: var(--txt-3);
  margin: 0;
  letter-spacing: .02em;
}

/* ── Cards ── */
.home-cards {
  display: flex;
  gap: 16px;
  width: 100%;
}

.home-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 42px 24px 38px;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), border-color .18s, box-shadow .18s;
}

/* Highlight line at top of card */
.home-card::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 70%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.1), transparent);
}

.home-card:hover {
  border-color: var(--accent);
  transform: translateY(-7px) scale(1.01);
  box-shadow: 0 22px 52px rgba(94,106,210,.22), 0 0 0 1px rgba(94,106,210,.18);
}

.home-card--last {
  border-color: rgba(94,106,210,.45);
  box-shadow: 0 0 0 1px rgba(94,106,210,.1), inset 0 0 40px rgba(94,106,210,.05);
}

/* Icon badge */
.home-card-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #2a2a30;
  border: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, border-color .18s;
}
.home-card:hover .home-card-icon-wrap {
  background: rgba(94,106,210,.2);
  border-color: rgba(94,106,210,.35);
}
body.light-theme .home-card-icon-wrap          { background: #3537b1; border-color: rgba(255,255,255,.12); }
body.light-theme .home-card:hover .home-card-icon-wrap { background: #3f42c4; border-color: rgba(255,255,255,.22); }

.home-card-icon  { font-size: 2.4rem; line-height: 1; }
.home-card-logo  { width: 48px; height: 48px; object-fit: contain; display: block; }
.home-card-title { font-size: 1.18rem; font-weight: 700; color: var(--txt); letter-spacing: -.01em; min-height: 2.8em; display: flex; align-items: center; justify-content: center; text-align: center; }
.home-card-desc  { font-size: .74rem; color: var(--txt-2); line-height: 1.75; }

#screen-home .home-greeting {
  font-size: .79rem;
  color: var(--txt-3);
}

/* legacy — kept para no romper referencias */
.home-welcome { display: none; }
.home-tagline { display: none; }
.home-welcome-stats { display: none; }

/* Option card description (alias for home-tool-desc) */
.option-desc {
  font-size: .74rem;
  color: var(--txt-2);
}

/* ══════════════════════════════════════════════════ TEXT ALIGN/WEIGHT BTNS ══ */
.text-controls-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.align-btns, .weight-btns {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.align-btn, .weight-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: .78rem;
  font-family: var(--font);
  color: var(--txt-2);
  cursor: pointer;
  transition: all .12s;
  line-height: 1;
}

.align-btn.active, .weight-btn.active {
  background: var(--accent);
  color: #fff;
}

.align-btn:hover:not(.active), .weight-btn:hover:not(.active) {
  background: var(--surface-3);
  color: var(--txt);
}

/* ══════════════════════════════════════════════════════ DATE INSERT BTN ══ */
.date-insert-btn {
  margin-top: 4px;
  font-size: .75rem !important;
}

/* ══════════════════════════════════════════════════════ UNDO INDICATOR ══ */
.undo-indicator {
  display: flex;
  gap: 8px;
  font-size: .72rem;
  color: var(--txt-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  align-items: center;
}

.undo-indicator span {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ══════════════════════════════════════════════════ FULLSCREEN PREVIEW ══ */
.btn-fs-preview {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-3);
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  transition: all .15s;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}
.btn-fs-preview:hover { border-color: var(--accent); color: var(--accent); }

.img-fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.img-fullscreen-modal.hidden {
  display: none !important;
}

.img-fullscreen-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.9);
  backdrop-filter: blur(4px);
}

.img-fullscreen-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-fullscreen-content img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
}

.img-fullscreen-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--txt);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  transition: all .15s;
}
.img-fullscreen-close:hover { background: var(--accent); border-color: var(--accent); }

/* kbd shortcut hint */
kbd {
  font-size: .65rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font);
}

/* ══════════════════════════════════════════════════════ HISTORY ACTIONS ══ */
.history-drawer-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.history-thumb-date {
  font-size: .65rem;
  color: var(--txt-3);
  display: block;
  text-align: center;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* ══════════════════════════════════════════════════════ RESPONSIVE TABLET ══ */
@media (max-width: 1024px) {
  .work-layout {
    grid-template-columns: 260px 1fr;
  }
  .controls-col--secondary {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .app-main { padding: 16px; }
  .work-layout { grid-template-columns: 1fr; }
  .home-welcome { flex-direction: column; align-items: flex-start; }
  .option-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .controls-col { max-height: none; position: static; }
  .app-header { padding: 0 12px; }
  .brand-title { font-size: .72rem; }
}

/* ══════════════════════════════════════════════════ COMPACT MODE ══ */
body.compact .app-main {
  padding: 16px 14px;
}

body.compact .controls-col {
  gap: 8px;
  padding: 12px;
  width: 240px;
}

body.compact .work-layout {
  grid-template-columns: 240px 1fr 1fr;
  gap: 12px;
}

body.compact .field-group > label {
  font-size: .72rem;
}

body.compact .field-group textarea,
body.compact .field-group input[type="text"] {
  font-size: .82rem;
  padding: 7px 10px;
}

body.compact .btn-primary,
body.compact .btn-secondary {
  padding: 8px 14px;
  font-size: .82rem;
}

body.compact .work-header {
  margin-bottom: 14px;
  padding-bottom: 10px;
}

body.compact .option-card {
  padding: 20px 14px;
  gap: 8px;
}

body.compact .option-icon { font-size: 1.8rem; }

body.compact .home-question {
  font-size: 1.3rem;
  margin-bottom: 24px;
}

/* ══════════════════════════════════════════════════ HISTORY DRAWER ══ */
.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.history-drawer:not(.hidden) {
  transform: translateX(0);
}

/* Override .hidden to allow transform animation — we use a JS class instead */
.history-drawer.hidden {
  display: flex !important; /* keep in DOM for transition */
  transform: translateX(100%);
  pointer-events: none;
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-drawer-title {
  font-size: .95rem;
  font-weight: 700;
}

.history-drawer-close {
  background: transparent;
  border: none;
  color: var(--txt-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all .15s;
}
.history-drawer-close:hover { background: var(--surface-2); color: var(--txt); }

.history-drawer-sub {
  font-size: .75rem;
  color: var(--txt-3);
  padding: 8px 20px 0;
  flex-shrink: 0;
}

.history-thumbs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
}

.history-empty {
  grid-column: 1 / -1;
  color: var(--txt-3);
  font-size: .82rem;
  text-align: center;
  padding: 24px 0;
}

.history-thumb {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
}

.history-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.history-thumb-label {
  font-size: .7rem;
  color: var(--txt-3);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════ DRAWER BACKDROP ══ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 499;
  transition: opacity .3s;
}

.drawer-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════ PRESET CHIPS ══ */
.presets-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 0 2px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border-l);
  border-radius: 99px;
  padding: 3px 10px 3px 12px;
  font-size: .75rem;
  color: var(--txt-2);
  cursor: pointer;
  transition: all .15s;
  max-width: 180px;
}

.preset-chip:hover {
  border-color: var(--accent);
  color: var(--txt);
}

.preset-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-del {
  background: transparent;
  border: none;
  color: var(--txt-3);
  font-size: .75rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
.preset-del:hover { color: var(--accent); }

.preset-save-btn {
  background: transparent;
  border: 1px dashed var(--border-l);
  border-radius: 99px;
  color: var(--txt-3);
  font-size: .72rem;
  padding: 3px 10px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.preset-save-btn:hover { border-color: var(--success); color: var(--success); }

/* ══════════════════════════════════════════════════ CHARACTER COUNTER ══ */
.char-counter {
  font-size: .72rem;
  color: var(--txt-3);
  text-align: right;
  margin-top: 2px;
  transition: color .15s;
}

.char-counter.ok   { color: var(--success); }
.char-counter.warn { color: var(--warning); }
.char-counter.over { color: var(--accent); font-weight: 600; }

/* ══════════════════════════════════════════════════ VIDEO MODAL ══ */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.video-modal.hidden {
  display: none !important;
}

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.75);
  cursor: pointer;
}

.video-modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  font-weight: 600;
}

.video-modal-header button {
  background: transparent;
  border: none;
  color: var(--txt-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all .15s;
}
.video-modal-header button:hover { background: var(--surface-2); color: var(--txt); }

.video-modal-video {
  width: 100%;
  display: block;
  background: #000;
  max-height: 60vh;
}

.video-modal-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.video-modal-actions .btn-primary  { flex: 2; }
.video-modal-actions .btn-secondary { flex: 1; }

/* ══════════════════════════════════════════════════ INSTAGRAM FRAME ══ */
.ig-frame {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ig-frame-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.ig-frame-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.ig-frame-user {
  flex: 1;
  margin-left: 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--txt);
}

.ig-frame-more {
  color: var(--txt-3);
  font-size: .9rem;
  letter-spacing: .1em;
}

.ig-frame-canvas-area {
  line-height: 0;
}

.ig-frame-canvas-area .canvas-wrap {
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ig-frame-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
}

.ig-frame-actions-left {
  display: flex;
  gap: 14px;
  font-size: 1.2rem;
}

.ig-frame-actions-left span,
.ig-frame-actions-right span {
  cursor: default;
  opacity: .6;
}

/* ══════════════════════════════════════════════════ PHONE FRAME ══ */
.phone-frame {
  background: #111;
  border: 3px solid #2a2a2a;
  border-radius: 40px;
  box-shadow: 0 0 0 1px #3a3a3a, 0 12px 48px rgba(0,0,0,.7);
  overflow: hidden;
  position: relative;
  padding: 14px 6px 10px;
}

.phone-frame-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 26px;
  background: #111;
  border-radius: 0 0 18px 18px;
  z-index: 10;
  border: 3px solid #2a2a2a;
  border-top: none;
}

.phone-frame-notch::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1e1e1e;
  border: 1px solid #333;
}

.phone-frame-canvas-area {
  border-radius: 32px;
  overflow: hidden;
  line-height: 0;
}

.phone-frame-canvas-area .canvas-wrap {
  border-radius: 0;
  border: none;
}

/* ══════════════════════════════════════════════════ VIDEO PREVIEW CONTROLS ══ */
.video-preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.video-preview-controls.hidden { display: none; }

.vp-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-l);
  color: var(--txt);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.vp-btn:hover { background: var(--border); }

.vp-seek {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

#rv-timecode,
#ra-timecode {
  font-size: .72rem;
  color: var(--txt-3);
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  min-width: 80px;
  text-align: right;
}

/* ══════════════════════════════════════════════════════ LIGHT THEME ══ */
body.light-theme {
  --bg:          #E8EAED;   /* gris medio — fondo del body */
  --surface:     #F2F3F5;   /* gris claro — tarjetas, panels */
  --surface-2:   #E4E6E9;   /* gris ligeramente más oscuro */
  --surface-3:   #D8DADD;   /* gris para inputs, code */
  --surface-hover:#ECEDEF;  /* hover */
  --border:      #CDD0D5;
  --border-l:    #B5B9C0;

  --accent:      #5E6AD2;
  --accent-dark: #4F5BC4;
  --accent-glow: rgba(94,106,210,.12);

  --gold:    #f59e0b;
  --success: #16a34a;
  --warning: #d97706;

  --txt:   #1A1C20;
  --txt-2: #4A4D55;
  --txt-3: #8A8E99;

  --shadow:    0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.07);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-card: 0 2px 4px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


body.light-theme .phone-frame {
  background: #e0e0e0;
  border-color: #c0c0c0;
  box-shadow: 0 0 0 1px #b0b0b0, 0 12px 48px rgba(0,0,0,.15);
}
body.light-theme .phone-frame-notch {
  background: #e0e0e0;
  border-color: #c0c0c0;
}
body.light-theme .phone-frame-notch::before { background: #ccc; border-color: #bbb; }

/* Theme toggle button */
.btn-theme {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-3);
  padding: 5px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  transition: all .15s;
}
.btn-theme:hover { border-color: var(--gold); color: var(--gold); }

/* ══════════════════════════════════════════════ HOME SECTION CATEGORIES ══ */
/* Each section gets a left-accent color for its cards */
.home-section--noticia .option-card {
  border-left: 3px solid #4361ee;
}
.home-section--noticia .option-card:hover {
  border-color: #4361ee;
  box-shadow: 0 6px 24px rgba(67,97,238,.22);
}
.home-section--noticia .home-section-title .hs-icon { color: #6c8aff; }

.home-section--video .option-card {
  border-left: 3px solid var(--success);
}
.home-section--video .option-card:hover {
  border-color: var(--success);
  box-shadow: 0 6px 24px rgba(46,196,182,.22);
}
.home-section--video .home-section-title .hs-icon { color: var(--success); }

.home-section--custom .option-card {
  border-left: 3px solid var(--gold);
}
.home-section--custom .option-card:hover {
  border-color: var(--gold);
  box-shadow: 0 6px 24px rgba(255,209,102,.22);
}
.home-section--custom .home-section-title .hs-icon { color: var(--gold); }

/* ══════════════════════════════════════════════ GALLERY STAT IN HOME ══ */
.home-stat.stat-gallery { cursor: pointer; transition: all .15s; }
.home-stat.stat-gallery:hover { border-color: var(--gold); }
.home-stat.stat-gallery .home-stat-num { color: var(--gold); }

/* ══════════════════════════════════════════════════════ GALLERY MODAL ══ */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gallery-modal.hidden { display: none !important; }

.gallery-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
}

.gallery-modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}
.gallery-modal-header h3 { font-size: 1rem; font-weight: 700; flex: 1; }
.gallery-modal-header .gallery-hint {
  font-size: .75rem;
  color: var(--txt-3);
}
.gallery-modal-header button {
  background: transparent;
  border: none;
  color: var(--txt-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all .15s;
}
.gallery-modal-header button:hover { background: var(--surface-2); color: var(--txt); }

.gallery-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gallery-count {
  font-size: .78rem;
  color: var(--txt-3);
  margin-left: auto;
}

.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  align-content: start;
}

.gallery-item {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: all .15s;
  aspect-ratio: 1;
  background: var(--surface-2);
}
.gallery-item:hover {
  border-color: var(--accent);
  transform: scale(1.03);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item-name {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: .62rem;
  padding: 4px 6px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.3;
}
.gallery-item-del {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.gallery-item:hover .gallery-item-del { opacity: 1; }
.gallery-item-del:hover { background: var(--accent) !important; }

.gallery-empty {
  grid-column: 1 / -1;
  color: var(--txt-3);
  font-size: .85rem;
  text-align: center;
  padding: 48px 20px;
  line-height: 1.7;
}
.gallery-empty strong { color: var(--txt-2); }

/* Gallery button near dropzone */
.dz-gallery-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  justify-content: center;
}

.btn-gallery {
  background: transparent;
  border: 1px solid var(--border-l);
  color: var(--txt-2);
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .75rem;
  font-family: var(--font);
  transition: all .15s;
  white-space: nowrap;
}
.btn-gallery:hover { border-color: var(--gold); color: var(--gold); }

/* ══════════════════════════════════════════════ HISTORY FILTER CHIPS ══ */
.history-filters {
  display: flex;
  gap: 5px;
  padding: 8px 20px 0;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.history-filter-chip {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: .7rem;
  font-family: var(--font);
  color: var(--txt-2);
  cursor: pointer;
  transition: all .15s;
}
.history-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.history-filter-chip:hover:not(.active) {
  border-color: var(--border-l);
  color: var(--txt);
}

/* ══════════════════════════════════════════════ PANEL SHORTCUTS FOOTER ══ */
.panel-shortcuts {
  border-top: 1px solid var(--border);
  padding: 8px 0 2px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.panel-shortcut {
  font-size: .68rem;
  color: var(--txt-3);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════ SERIE / NUEVA NOTA BTN ══ */
.btn-serie {
  background: transparent;
  border: 1px dashed var(--border-l);
  color: var(--txt-3);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: .82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  width: 100%;
  text-align: center;
}
.btn-serie:hover {
  border-style: solid;
  border-color: var(--success);
  color: var(--success);
  background: rgba(46,196,182,.06);
}

/* ══════════════════════════════════════════════ WIDE SCREEN LAYOUT ══ */
@media (min-width: 1500px) {
  .work-layout {
    grid-template-columns: 265px 1fr 1fr;
    gap: 24px;
  }
  .controls-col { padding: 18px; }
}

/* ── Grupos de herramientas en home ──────────────────────────────────── */
.tools-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.tools-group:last-child { margin-bottom: 0; }
.tools-group-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tools-group-label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Checkbox toggle row ──────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-label {
  font-size: .85rem;
  color: var(--txt-2);
}
.toggle-row:hover .toggle-label { color: var(--txt); }

/* ══════════════════════════════════════════════ PANEL SECTION DIVIDERS ══ */
.panel-section-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--accent);
  border-radius: 2px;
}

/* ══════════════════════════════════════════════ TEMPLATE CHIP SUGGESTIONS ══ */
.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.template-chip {
  background: var(--surface-3);
  border: 1px dashed var(--border-l);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: .7rem;
  color: var(--txt-3);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-chip:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--txt);
}

/* ══════════════════════════════════════════════════════ CAPTION BOT FAB ══ */
.caption-bot-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, #6c8aff 0%, #a855f7 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 20px 12px 16px;
  cursor: pointer;
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(108,138,255,.4), 0 2px 8px rgba(0,0,0,.3);
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
  user-select: none;
}
.caption-bot-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 28px rgba(108,138,255,.5), 0 4px 12px rgba(0,0,0,.3);
}
.caption-bot-fab.active {
  background: linear-gradient(135deg, #a855f7 0%, #6c8aff 100%);
  box-shadow: 0 0 0 3px rgba(168,85,247,.3), 0 4px 20px rgba(108,138,255,.4);
}
.caption-fab-icon { font-size: 1.1rem; line-height: 1; }
.caption-fab-label { white-space: nowrap; }

/* ══════════════════════════════════════════════════ CAPTION BOT PANEL ══ */
.caption-bot-panel {
  position: fixed;
  bottom: 90px;
  right: 28px;
  z-index: 601;
  width: 380px;
  max-height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* initial state: hidden & scaled down */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}
.caption-bot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.caption-bot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, rgba(108,138,255,.12) 0%, rgba(168,85,247,.08) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.caption-bot-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.caption-bot-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.caption-bot-title strong {
  display: block;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.2;
  background: linear-gradient(90deg, #6c8aff, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.caption-bot-sub {
  font-size: .68rem;
  color: var(--txt-3);
  display: block;
}
.caption-bot-close {
  background: transparent;
  border: none;
  color: var(--txt-3);
  font-size: .95rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: all .15s;
}
.caption-bot-close:hover { background: var(--surface-2); color: var(--txt); }

/* Profile row */
.caption-profile-row {
  display: flex;
  gap: 6px;
  padding: 12px 14px 0;
  flex-shrink: 0;
}
.caption-profile-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: .82rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--txt-2);
  cursor: pointer;
  transition: all .15s;
}
.caption-profile-btn.active {
  background: linear-gradient(135deg, rgba(108,138,255,.18) 0%, rgba(168,85,247,.12) 100%);
  border-color: #6c8aff;
  color: var(--txt);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(108,138,255,.3);
}
.caption-profile-btn:hover:not(.active) {
  background: var(--surface-3);
  border-color: var(--border-l);
}
.caption-profile-hint {
  font-size: .68rem;
  color: var(--txt-3);
  padding: 6px 14px 0;
  flex-shrink: 0;
  font-style: italic;
}

/* Context area */
.caption-context-wrap {
  padding: 10px 14px 0;
  flex-shrink: 0;
}
.caption-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.caption-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--txt-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.caption-ctx-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-3);
  padding: 3px 8px;
  border-radius: 99px;
  font-size: .68rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.caption-ctx-btn:hover { border-color: #6c8aff; color: #6c8aff; }

.caption-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-family: var(--font);
  font-size: .85rem;
  padding: 9px 11px;
  resize: vertical;
  min-height: 88px;
  max-height: 160px;
  transition: border-color .15s;
  line-height: 1.5;
}
.caption-textarea:focus {
  outline: none;
  border-color: #6c8aff;
}
.caption-kbd-hint {
  font-size: .65rem;
  color: var(--txt-3);
  margin-top: 4px;
  text-align: right;
}

/* Actions */
.caption-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
}
.caption-generate-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #6c8aff 0%, #a855f7 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.caption-generate-btn:hover { opacity: .92; }
.caption-generate-btn:active { transform: scale(.98); }
.caption-generate-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Spinner */
.caption-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Output */
.caption-output-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px;
  min-height: 60px;
}
.caption-output {
  font-size: .83rem;
  color: var(--txt-3);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  transition: all .2s;
  min-height: 52px;
}
.caption-output.has-content {
  color: var(--txt);
  border-color: rgba(108,138,255,.3);
  background: linear-gradient(135deg, rgba(108,138,255,.05) 0%, var(--surface-2) 100%);
}
.caption-output.has-error {
  color: #f87171;
  border-color: rgba(230,57,70,.3);
  background: rgba(230,57,70,.05);
}

/* Copy row */
.caption-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 14px;
  flex-shrink: 0;
}
.caption-char-count {
  font-size: .68rem;
  color: var(--txt-3);
}
.caption-copy-btns {
  display: flex;
  gap: 6px;
}

/* ═══════════════════════════════════ RESPONSIVE CAPTION BOT ══ */
@media (max-width: 480px) {
  .caption-bot-panel {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
  }
  .caption-bot-fab {
    right: 16px;
    bottom: 20px;
  }
  .caption-fab-label { display: none; }
  .caption-bot-fab { padding: 14px; border-radius: 50%; }
}

/* ══════════════════════════════════════════════ HOME WELCOME IMPROVEMENTS ══ */
/* Make the home welcome banner gradient more vivid */
.home-welcome {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(230,57,70,.06) 100%);
}
/* Improve card grid responsiveness */
.option-grid {
  max-width: 100%;
}
/* Slightly reduce card padding for better density */
.option-card {
  padding: 26px 18px;
}
body.compact .option-card { padding: 16px 12px; }
/* Simple Reel */
.simple-reel-shell {
  max-width: 1100px;
  margin: 0 auto;
}

.simple-reel-tabs {
  position: sticky;
  top: 64px;
  z-index: 5;
  background: var(--bg);
  padding: 8px 0;
}

.simple-reel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(280px, 420px);
  gap: 16px;
  align-items: start;
  justify-content: center;
}

.simple-reel-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.simple-reel-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.simple-step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
}

.simple-step-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  margin-top: 2px;
}

.simple-drop {
  min-height: 118px;
}

.simple-reel-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
}

.simple-reel-details summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 10px;
}

.simple-subs-style {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.simple-reel-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.simple-export-btn {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  min-height: 48px;
}

.simple-reel-preview {
  position: sticky;
  top: 124px;
}

.simple-reel-canvas-wrap canvas {
  max-height: min(68vh, 680px);
}

.video-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.video-controls.hidden {
  display: none;
}

.progress-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-size: .8rem;
  color: var(--txt-2);
}

.progress-wrap.hidden {
  display: none;
}

.progress-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

@media (max-width: 820px) {
  .simple-reel-shell {
    width: 100%;
  }

  .simple-reel-tabs {
    top: 56px;
  }

  .simple-reel-grid {
    grid-template-columns: 1fr;
  }

  .simple-reel-preview {
    position: static;
    order: -1;
  }

  .simple-reel-panel {
    border-radius: var(--radius);
    padding: 12px;
  }

  .simple-reel-canvas-wrap canvas {
    max-height: 58vh;
  }

  .simple-subs-style {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════ HOME TOOL GRID COMPACT ══ */
#profile-tools-grid .home-section {
  padding: 0 24px 10px;
}
#profile-tools-grid .home-section-title {
  padding: 12px 0 5px;
  margin-bottom: 5px;
}
#profile-tools-grid .option-card {
  padding: 14px 10px;
  gap: 6px;
}
#profile-tools-grid .option-icon {
  font-size: 1.6rem;
}
#profile-tools-grid .option-label {
  font-size: .8rem;
}
#profile-tools-grid .option-desc {
  font-size: .67rem;
  line-height: 1.3;
}
#profile-tools-grid .option-grid {
  gap: 8px;
}
#profile-tools-grid .option-card--featured {
  padding: 14px 20px;
  gap: 16px;
}
#profile-tools-grid .option-card--featured .option-icon {
  font-size: 1.85rem;
}
#profile-tools-grid .option-card--featured .option-label {
  font-size: .88rem;
}

/* ══════════════════════════════════════ APP WORK LAYOUT — PROFILE SIDEBAR ══ */
#screen-work {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-work-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-profile-sidebar {
  width: 188px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.app-ps-header {
  font-size: .72rem;
  font-weight: 700;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--txt);
  letter-spacing: .03em;
  flex-shrink: 0;
}

.app-ps-group {
  display: flex;
  flex-direction: column;
}

.app-ps-group-label {
  font-size: .59rem;
  font-weight: 700;
  color: var(--txt-2);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 12px 14px 4px;
}

.app-ps-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  color: var(--txt-2);
  font-family: var(--font);
  font-size: .82rem;
  text-align: left;
  transition: background .12s, color .12s, border-color .12s;
}
.app-ps-item:hover {
  background: var(--surface-2);
  color: var(--txt);
}
.app-ps-item.active {
  background: var(--surface-2);
  color: var(--txt);
  border-left-color: var(--accent);
}

.app-ps-icon { font-size: 1.05rem; flex-shrink: 0; }

.app-ps-label { font-size: .78rem; line-height: 1.2; }

/* Chevron en items expandibles */
.app-ps-item--expand { justify-content: space-between; }
.app-ps-chev { font-size: .68rem; color: var(--txt-2); flex-shrink: 0; transition: transform .15s; }

/* Sub-items accordion */
.app-ps-subitems {
  padding: 4px 6px 8px;
  background: var(--bg);
  border-left: 2px solid var(--accent);
  margin-bottom: 2px;
}
.app-ps-subitems.hidden { display: none; }

/* Etiquetas de grupo dentro del acordeón — siempre sobre fondo bg */
.app-ps-sub-label {
  font-size: .56rem;
  font-weight: 700;
  color: rgba(255,255,255,.45);   /* dark mode: bg muy oscuro → texto claro */
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 2px 4px;
}
body.light-theme .app-ps-sub-label { color: var(--txt-3); }

.app-ps-sub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 2px;
}

.app-ps-subitem {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a2a30;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  height: 40px;
  transition: background .12s, border-color .12s;
}
.app-ps-subitem:hover  { background: #333339; border-color: rgba(255,255,255,.13); }
.app-ps-subitem.active { border-color: var(--accent); background: rgba(94,106,210,.22); }

/* Tema claro: fondo oscuro fijo para que los logos blancos sean visibles */
body.light-theme .app-ps-subitem              { background: #3537b1; border-color: rgba(255,255,255,.12); }
body.light-theme .app-ps-subitem:hover        { background: #3f42c4; border-color: rgba(255,255,255,.22); }
body.light-theme .app-ps-subitem.active       { background: #2a2ca0; border-color: rgba(255,255,255,.35); }

.app-ps-sub-logo  { max-width: 100%; max-height: 28px; object-fit: contain; display: block; }
.app-ps-sub-icon  { font-size: 1.15rem; }

/* Sub-items en modo lista de texto (Producción, Herramientas) */
.app-ps-sub-list { display: flex; flex-direction: column; gap: 1px; }

.app-ps-subitem--text {
  display: flex;
  align-items: center;
  gap: 7px;
  height: auto;
  padding: 5px 8px;
  border-radius: 5px;
  text-align: left;
  font-size: .76rem;
  color: rgba(255,255,255,.72);
}
.app-ps-subitem--text .app-ps-sub-icon { font-size: .88rem; flex-shrink: 0; color: rgba(255,255,255,.55); }
.app-ps-sub-text { font-size: .76rem; line-height: 1.2; color: rgba(255,255,255,.72); }
.app-ps-subitem--text:hover .app-ps-sub-text,
.app-ps-subitem--text:hover { color: rgba(255,255,255,.92); }
.app-ps-subitem--text.active .app-ps-sub-text,
.app-ps-subitem--text.active { color: #fff; }

/* Ocultar sidebar propia del PM cuando está dentro del app-tool-area */
#app-tool-area .pm-sidebar { display: none !important; }

.app-tool-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ══════════════════════════════════════ IMAGE PICKER — SIDEBAR LAYOUT ══ */
.img-work-outer {
  display: flex;
  align-items: flex-start;
  min-height: 0;
}

.img-picker-sidebar {
  width: 130px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: hidden;
  padding: 0 0 12px;
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px);
  align-self: flex-start;
}

.img-picker-sidebar-header {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.img-picker-group {
  margin-bottom: 2px;
}

.img-picker-group-label {
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 8px 10px 4px;
}

/* Grilla 2 columnas dentro de cada grupo */
.img-picker-items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 2px 6px;
}

.img-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--txt-2);
  font-family: var(--font);
  transition: background .12s, border-color .12s;
}
.img-picker-item:hover {
  background: var(--surface-2);
}
.img-picker-item.active {
  background: var(--surface-2);
  border-color: var(--accent);
}

.img-picker-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
  transition: transform .15s;
}
.img-picker-item:hover .img-picker-logo,
.img-picker-item.active .img-picker-logo {
  transform: scale(1.1);
}

.img-picker-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.img-generator-area {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* Responsive: barra horizontal en pantallas pequeñas */
@media (max-width: 860px) {
  .img-work-outer { flex-direction: column; }
  .img-picker-sidebar {
    width: 100%;
    overflow-y: visible;
    position: static;
    max-height: none;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .img-picker-sidebar-header { display: none; }
  .img-picker-group { display: contents; }
  .img-picker-group-label { display: none; }
  .img-picker-items-grid {
    display: contents;
  }
  .img-picker-item {
    padding: 6px 8px;
    border-radius: 6px;
  }
  .img-picker-logo { width: 32px; height: 32px; }
  .img-picker-icon { font-size: 1.2rem; }
}
