@font-face {
  font-family: 'Montserrat';
  src: url('assets/montserrat.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('assets/montserrat-italic.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
:root {
  --color-primary: #6440d8;
  --color-primary-hover: #5230bd;
  --color-cyan: #086c7d;
  --bg-app: #faf9f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f2efe9;
  --border-color: #e5e0d8;
  --text-main: #1c1a24;
  --text-muted: #6b667b;
  --font-editorial: 'Montserrat', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}
[data-theme="dark"] {
  --bg-app: #131118;
  --bg-surface: #1b1723;
  --bg-subtle: #242030;
  --border-color: #2e283d;
  --text-main: #f5f4f8;
  --text-muted: #9b94af;
  --color-cyan: #22d3ee;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 210px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.alma-symbol {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: url('assets/logo.png') center 28% / 300% auto no-repeat;
  flex-shrink: 0;
}
.brand-name { font-family: var(--font-editorial); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.btn-new-task {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 44px; padding: 0 14px; border-radius: var(--radius-md);
  background-color: var(--color-primary); color: #fff; font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; transition: background-color 0.15s ease;
}
.btn-new-task:hover { background-color: var(--color-primary-hover); }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius-sm); border: none; background: transparent; color: var(--text-muted);
  font-size: 15px; font-weight: 500; cursor: pointer; text-align: left;
}
.nav-item:hover, .nav-item.active { background-color: var(--bg-subtle); color: var(--text-main); }
.nav-item.active { color: var(--color-primary); font-weight: 600; }
.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 16px; border-top: 1px solid var(--border-color);
}
.user-profile { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background-color: var(--color-primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; font-size: 13px; line-height: 1.2; }
.user-name { font-weight: 600; color: var(--text-main); }
.user-role { color: var(--text-muted); font-size: 12px; }
.theme-toggle {
  width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-main); display: grid; place-items: center; cursor: pointer;
}
[data-theme="light"] .icon-theme-sun { display: none; }
[data-theme="dark"] .icon-theme-moon { display: none; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; max-width: 100%; }
.mobile-topbar {
  display: none; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 0 16px; background: var(--bg-surface); border-bottom: 1px solid var(--border-color);
}
.topbar-status {
  padding: 10px 24px; font-size: 13px; color: var(--text-muted); letter-spacing: 0.02em;
}
.content-area { flex: 1; max-width: 900px; width: 100%; margin: 0 auto; padding: 24px; }
.view-panel { display: none; flex-direction: column; gap: 28px; }
.view-panel.active { display: flex; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: var(--color-cyan); text-transform: uppercase; }
.headline-editorial {
  font-family: var(--font-editorial);
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 800; line-height: 1.08; letter-spacing: -0.03em; margin-top: 6px;
}
.headline-editorial .light-line { font-weight: 300; display: block; opacity: 0.9; }
.editorial-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.avatar-card {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px;
  background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
}
.avatar-crop {
  width: 60px; height: 60px; border-radius: 50%; overflow: hidden;
  position: relative; background: #dedede; flex-shrink: 0;
}
.avatar-img { width: 350%; max-width: none; position: absolute; left: -10%; top: 0; display: block; }
.avatar-info { display: flex; flex-direction: column; }
.avatar-title { font-size: 15px; font-weight: 700; }
.avatar-label { font-size: 13px; color: var(--text-muted); }
.suggestions-wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-chip {
  min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-main); font-size: 15px; font-weight: 500; cursor: pointer;
}
.btn-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chat-thread { display: flex; flex-direction: column; gap: 16px; }
.chat-bubble { max-width: 85%; padding: 16px 20px; border-radius: var(--radius-md); font-size: 17px; }
.bubble-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.user-bubble { align-self: flex-end; background-color: var(--color-primary); color: #fff; }
.user-bubble .bubble-meta { color: rgba(255, 255, 255, 0.8); }
.alma-bubble {
  align-self: flex-start; background-color: var(--bg-surface); border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
}
.summary-card {
  margin-top: 14px; padding: 16px; border-radius: var(--radius-sm);
  background-color: var(--bg-subtle); border-left: 3px solid var(--color-primary);
}
.card-badge { font-size: 12px; font-weight: 700; color: var(--color-primary); margin-bottom: 4px; }
.card-title { font-family: var(--font-editorial); font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.card-excerpt { font-style: italic; color: var(--text-muted); margin-bottom: 12px; }
.btn-primary, .btn-secondary {
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm); font-size: 15px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background-color: var(--color-primary); color: #fff; border: none; }
.btn-primary:hover { background-color: var(--color-primary-hover); }
.btn-secondary { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background-color: var(--bg-subtle); }
.composer-form {
  display: flex; gap: 10px; align-items: flex-end; padding: 10px;
  background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
}
.composer-textarea {
  flex: 1; border: none; background: transparent; font-family: var(--font-body);
  font-size: 17px; color: var(--text-main); resize: none; max-height: 160px; outline: none; padding: 8px;
}
.composer-submit {
  width: 44px; height: 44px; border-radius: var(--radius-sm); background-color: var(--color-primary);
  color: #fff; border: none; display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.section-header { display: flex; flex-direction: column; gap: 8px; }
.section-title { font-family: var(--font-editorial); font-size: clamp(28px, 4vw, 42px); font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.step-item.current { color: var(--color-primary); font-weight: 700; }
.review-card {
  display: grid; grid-template-columns: 280px 1fr; gap: 24px; padding: 24px;
  background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
}
.art-canvas {
  aspect-ratio: 1; background: linear-gradient(145deg, #231c38, #120e1e);
  border-radius: var(--radius-md); display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; color: #fff; padding: 20px;
}
.art-symbol {
  width: 36px; height: 36px; border-radius: 8px;
  background: url('assets/logo.png') center 28% / 300% auto no-repeat; margin-bottom: 12px;
}
.art-badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-cyan); margin-bottom: 8px; }
.art-headline { font-family: var(--font-editorial); font-size: 22px; font-weight: 800; }
.art-sub { font-size: 13px; opacity: 0.7; }
.review-details { display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.meta-row { display: flex; gap: 10px; align-items: center; }
.tag-badge { background: var(--bg-subtle); padding: 4px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; }
.version-meta { font-size: 14px; color: var(--text-muted); }
.field-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.field-value { font-size: 17px; }
.copy-box {
  padding: 12px 16px; background-color: var(--bg-subtle); border-radius: var(--radius-sm);
  font-style: italic; border-left: 2px solid var(--color-cyan);
}
.helper-text { font-size: 14px; color: var(--text-muted); }
.review-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-subtle); display: grid; place-items: center; }
.empty-icon.success { color: var(--color-cyan); }
.empty-title { font-family: var(--font-editorial); font-size: 24px; font-weight: 700; }
.empty-desc { max-width: 480px; color: var(--text-muted); font-size: 16px; margin-bottom: 8px; }
.mobile-bottom-nav { display: none; }
.native-dialog {
  margin: auto; border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 24px; background: var(--bg-surface); color: var(--text-main); max-width: 460px;
}
.native-dialog::backdrop { background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.dialog-content { display: flex; flex-direction: column; gap: 16px; }
.dialog-title { font-family: var(--font-editorial); font-size: 22px; font-weight: 700; }
.dialog-desc { color: var(--text-muted); font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background-color: var(--text-main); color: var(--bg-surface); padding: 12px 20px;
  border-radius: var(--radius-md); font-size: 15px; font-weight: 500; z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); text-align: center; max-width: 90vw;
}
.icon-svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
button:active { transform: scale(0.98); }
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .review-card { grid-template-columns: 1fr; }
  .content-area { padding: 16px 16px 84px 16px; }
  .mobile-bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-surface); border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom, 8px); z-index: 50;
  }
  .bottom-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 52px; background: transparent; border: none; color: var(--text-muted);
    font-size: 12px; cursor: pointer;
  }
  .bottom-item.active { color: var(--color-primary); font-weight: 600; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}/* Ajustes de revisión: legibilidad táctil, retrato y estados de alto contraste. */
:root { --color-accent-text: #6440d8; }
[data-theme="dark"] { --color-accent-text: #b5a0ff; }
.nav-item.active, .step-item.current, .bottom-item.active, .card-badge { color: var(--color-accent-text); }
.avatar-img { height: auto; top: -25%; }
.avatar-label, .bubble-meta, .topbar-status, .field-label, .tag-badge, .user-role { font-size: 14px; }
.card-badge, .art-badge, .art-sub { font-size: 14px; }
.art-badge { color: #67e8f9; }
.empty-desc, .dialog-desc { font-size: 17px; }
.composer-submit:hover { background: var(--color-primary-hover); }
button:active { transform: translateY(1px); }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--color-accent-text); outline-offset: 4px; }
@media (max-width: 768px) {
 .bottom-item { font-size: 14px; }
 .content-area { padding-bottom: calc(190px + env(safe-area-inset-bottom, 0px)); }
 .composer-form { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 40; margin: 0; box-shadow: 0 0 0 8px var(--bg-app); }
}
@media (prefers-reduced-motion: reduce) { button:active { transform:none; } }

@media (max-width:768px) { .composer-form::after { content:""; position:absolute; inset:-8px -16px -24px; background:var(--bg-app); z-index:-1; } }

/* Revisión solicitada por Rafa: presencia sin marco y accesos en fila. */
/* accesos.css - Estilos para Presencia integrada de Alma y Accesos Rápidos */

:root {
  --lavender-chip-bg: #eee8fa;
  --lavender-chip-bg-hover: #e2d7f5;
  --lavender-chip-text: #4d319e;
  --lavender-accent: #c4b5fd;
  --alma-fade-start: 75%;
}

[data-theme="dark"] {
    --lavender-chip-bg: #292137;
    --lavender-chip-bg-hover: #362c47;
    --lavender-chip-text: #d1c2ff;
    --lavender-accent: #6d5b97;
}

/* Integración Editorial Header */
.editorial-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

/* Presencia de Alma: sin marco, sin círculo, no interactiva */
.alma-presence {
  display: inline-flex;
  align-items: flex-end;
  gap: 12px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
  user-select: none;
}

.alma-portrait-wrap {
  position: relative;
  width: 124px;
  height: 170px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Contenedor de recorte para el primer panel (x:0..435, y:0..600) */
.alma-portrait {
  width: 124px;
  height: 170px;
  position: relative;
  overflow: hidden;
  background: transparent;
  -webkit-mask-image: 
    linear-gradient(to bottom, transparent 0%, black 5%, black var(--alma-fade-start), transparent 100%),
    linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  mask-image: 
    linear-gradient(to bottom, transparent 0%, black 5%, black var(--alma-fade-start), transparent 100%),
    linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

/* Bitmap completo posicionado para renderizar panel 1 sin deformación */
.alma-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 412px;
  height: auto;
  max-width: none;
  display: block;
  mix-blend-mode: multiply;
}

[data-theme="dark"] .alma-img {
    mix-blend-mode: normal;
    opacity: 0.94;
}

/* Acento sutil inferior lavanda */
.alma-base-glow {
  position: absolute;
  bottom: 0;
  left: 15%;
  width: 70%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--lavender-accent), transparent);
  pointer-events: none;
}

/* Tipografía de presencia */
.alma-caption {
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.alma-name {
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
}

.alma-role {
  font-size: 14px;
  opacity: 0.75;
}

/* Accesos rápidos: 3 iguales en 1 fila */
.suggestions-wrap {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
  width: 100%;
  box-sizing: border-box;
}

.btn-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 10px 8px;
  border-radius: 12px !important;
  background-color: var(--lavender-chip-bg);
  color: var(--lavender-chip-text);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-chip svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-chip span {
  font-size: 14.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  word-break: normal;
  overflow-wrap: break-word;
}

@media (hover: hover) and (pointer: fine) {
  .btn-chip:hover {
    background-color: var(--lavender-chip-bg-hover);
  }
}

.btn-chip:active {
  filter: brightness(0.95);
}

/* Responsivo para móviles y anchos reducidos */
@media (max-width: 768px) {
  .editorial-header > *:not(.alma-presence) {
    width: 100%;
  }

  .alma-portrait-wrap,
  .alma-portrait {
    width: 124px;
    height: 170px;
    max-height: 170px;
  }

  .btn-chip {
    min-height: 76px;
    padding: 8px 4px;
  }

  .btn-chip span {
    font-size: 14px;
  }
}

.btn-chip:hover { color:var(--lavender-chip-text); border-color:transparent; }

/* Tratamiento de visualización del fondo blanco, sin alterar el PNG original. */


/* PNG transparente original: margen superior, sin filtro ni recorte de cabeza. */
.alma-portrait-wrap { width:140px; height:170px; }
.alma-portrait {
 width:140px; height:170px; padding-top:12px; overflow:visible;
 -webkit-mask-image:none; mask-image:none;
}
.alma-img, [data-theme="dark"] .alma-img {
 position:relative; top:0; left:0; width:140px; height:auto; max-width:100%;
 object-fit:contain; filter:none; mix-blend-mode:normal; opacity:1;
 -webkit-mask-image:linear-gradient(to bottom,#000 70%,transparent 100%);
 mask-image:linear-gradient(to bottom,#000 70%,transparent 100%);
}
.alma-base-glow { display:none; }
@media (max-width:768px) {
 .alma-portrait-wrap, .alma-portrait { width:140px; height:170px; max-height:none; }
}

/* Ajuste de composición: identidad compacta y algo más alta, sin mover la foto. */
.alma-caption { padding-bottom:28px; gap:2px; }
.alma-name { line-height:1; }
.alma-role { line-height:1.15; }
/* En claro, caída más progresiva y casi transparente antes del borde del PNG. */
:root:not([data-theme="dark"]) .alma-img {
 -webkit-mask-image:linear-gradient(to bottom,#000 70%,rgba(0,0,0,.82) 75%,rgba(0,0,0,.45) 81%,rgba(0,0,0,.16) 87%,rgba(0,0,0,.025) 94%,transparent 100%);
 mask-image:linear-gradient(to bottom,#000 70%,rgba(0,0,0,.82) 75%,rgba(0,0,0,.45) 81%,rgba(0,0,0,.16) 87%,rgba(0,0,0,.025) 94%,transparent 100%);
}

/* ==========================================================================
   MEJORAS FRONTEND DEMO - ALMA
   ========================================================================== */

/* 1. LOGO */
.sidebar-brand {
  gap: 4px !important;
}
.sidebar-brand .brand-name {
  margin: 0 !important;
}

/* 2. CABECERA COMPACTA */
html.chat-started .editorial-header {
  max-height: 64px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  box-sizing: border-box;
}
html.chat-started .editorial-titles,
html.chat-started .suggestions-wrap {
  display: none !important;
}
html.chat-started figure.alma-presence {
  width: 44px !important;
  height: 56px !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 0 0 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}
html.chat-started figure.alma-presence .alma-portrait-wrap,
html.chat-started figure.alma-presence .alma-portrait {
  width: 44px !important;
  height: 44px !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
html.chat-started img.alma-img {
  width: 44px !important;
  height: auto !important;
  padding-top: 4px !important;
}
html.chat-started figcaption.alma-caption {
  display: flex !important;
  align-items: baseline !important;
  justify-content: center !important;
  gap: 4px !important;
  margin: 0 !important;
}
html.chat-started figcaption.alma-caption .alma-name {
  font-size: 18px !important;
  line-height: 1.2 !important;
}
html.chat-started figcaption.alma-caption .alma-role {
  font-size: 14px !important;
  line-height: 1.2 !important;
}
.btn-toggle-welcome {
  display: none;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--bg-surface, #ffffff);
  color: var(--color-accent-text, #6d28d9);
  border: 1px solid var(--border-color, #e2e8f0);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
html.chat-started .btn-toggle-welcome {
  display: inline-flex;
}

/* 3. VISOR DE ARTES */
.btn-open-viewer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  margin-top: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-surface, #ffffff);
  color: var(--text-main, #1a1a24);
  border: 1px solid var(--border-color, #e2e8f0);
}
.btn-open-viewer:hover {
  background: rgba(0, 0, 0, 0.04);
}

dialog#art-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(18, 16, 24, 0.96);
  color: #f4f4f5;
  z-index: 99999;
  box-sizing: border-box;
}
dialog#art-viewer:not([open]) {
  display: none;
}
dialog#art-viewer[open] {
  display: flex;
  flex-direction: column;
}
dialog#art-viewer::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}
body.viewer-open {
  overflow: hidden !important;
}

.viewer-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-sizing: border-box;
}
.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(24, 24, 27, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 52px;
}
.viewer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.viewer-title {
  font-size: 15px;
  font-weight: 600;
  color: #fafafa;
}
.viewer-counter {
  font-size: 13px;
  color: #a1a1aa;
}
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.viewer-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.viewer-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #09090b;
}
.viewer-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.viewer-img {
  max-width: 90%;
  max-height: 85%;
  object-fit: contain;
  transition: transform 0.12s ease-out;
}
.viewer-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.viewer-prev-btn { left: 16px; }
.viewer-next-btn { right: 16px; }
.viewer-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(24, 24, 27, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 60px;
}
.viewer-adjust-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--color-primary, #6d28d9);
  color: #ffffff;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* 4. CORRECCIÓN POR PIEZA */
#chat-form {
  flex-wrap: wrap !important;
}
.correction-context {
  flex-basis: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 6px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-main, #1a1a24);
  box-sizing: border-box;
  text-wrap: wrap;
}
.correction-context .context-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.correction-context .btn-remove-context {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #71717a);
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
}
.correction-context .btn-remove-context:hover {
  background: rgba(0, 0, 0, 0.05);
}
#chat-form textarea#chat-input {
  flex: 1 !important;
}
#chat-form button#chat-submit {
  min-width: 44px !important;
  min-height: 44px !important;
}

.piece-annotation-badge {
  display: block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(109, 40, 217, 0.12);
  color: var(--color-accent-text, #6d28d9);
  font-size: 12px;
  font-weight: 500;
  width: fit-content;
}

@media (prefers-reduced-motion: reduce) {
  .editorial-header,
  figure.alma-presence,
  dialog#art-viewer,
  .viewer-img {
    transition: none !important;
    animation: none !important;
  }
}

/* Revisión de composición compacta y zoom con dimensiones reales para paneo completo. */
html.chat-started .editorial-header { padding:0; min-height:64px; max-height:none; flex-wrap:nowrap; gap:8px; overflow:visible; }
html.chat-started .editorial-header > * { width:auto!important; }
html.chat-started figure.alma-presence { width:auto!important; height:56px!important; flex-direction:row!important; align-items:center!important; gap:8px; padding:0!important; }
html.chat-started figure.alma-presence .alma-portrait-wrap,html.chat-started figure.alma-presence .alma-portrait { height:52px!important; padding-top:4px; }
html.chat-started figcaption.alma-caption { align-items:flex-start!important; padding-bottom:0; gap:2px!important; flex-direction:column; }
html.chat-started img.alma-img { padding-top:0!important; }
.viewer-toolbar,.viewer-footer { flex-shrink:0; }
.viewer-toolbar { gap:8px; }
.viewer-meta { min-width:0; }
.viewer-stage { min-height:0; }
.viewer-viewport { position:absolute; inset:0; display:block; overscroll-behavior:contain; touch-action:pan-y; }
.viewer-img { display:block; margin:auto; max-width:none; max-height:none; transition:none; pointer-events:none; }
.correction-context,.viewer-counter { font-size:14px; }
.correction-context .context-label { white-space:normal; overflow:visible; text-overflow:clip; line-height:1.3; }
.piece-annotation-badge { color:inherit; background:rgba(255,255,255,.14); font-size:14px; }
.art-preview-image { display:block; width:100%; height:auto; border-radius:14px; }
.art-gallery-caption { font-size:14px; color:var(--text-muted); margin-top:12px; }
.viewer-btn:disabled { opacity:.4; cursor:default; }
