@font-face {
  font-family: 'Telegraf';
  src: url('../fonts/Telegraf-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Telegraf';
  src: url('../fonts/Telegraf-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Telegraf';
  src: url('../fonts/Telegraf-UltraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sharp Grotesk';
  src: url('../fonts/SharpGrotesk-Book15.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sharp Grotesk';
  src: url('../fonts/SharpGrotesk-SemiBold15.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sharp Grotesk';
  src: url('../fonts/SharpGrotesk-Bold15.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --upn-yellow: #FDBA30;
  --upn-yellow-hover: #E5A41E;
  --upn-yellow-soft: color-mix(in oklab, var(--upn-yellow) 16%, white);
  --upn-yellow-tint: color-mix(in oklab, var(--upn-yellow) 8%, white);
  --upn-black: #141414;
  --upn-surface-dark: #1E1F24;
  --upn-dark-gray: #1E242C;
  --upn-white: #FFFFFF;
  --upn-bg: #F4F6FA;
  --upn-border: color-mix(in oklab, var(--upn-black) 11%, white);
  --upn-border-strong: color-mix(in oklab, var(--upn-black) 20%, white);
  --upn-text-muted: #4E5866;
  --upn-success: #16A34A;
  --upn-success-bg: color-mix(in oklab, #16A34A 12%, white);
  --upn-success-text: #14532D;
  --upn-warn: #D97706;
  --upn-warn-bg: color-mix(in oklab, #FDBA30 22%, white);
  --upn-warn-text: #78350F;
  --upn-info-bg: color-mix(in oklab, #2563EB 10%, white);
  --upn-info-text: #1E3A8A;
  --upn-danger-bg: color-mix(in oklab, #DC2626 11%, white);
  --upn-danger-text: #7F1D1D;
  --scrollbar-thumb: #5A6678;
  --scrollbar-track: #EEF2F7;
  --target-size: 24px;
  --font-heading: 'Sharp Grotesk', 'Telegraf', Arial, sans-serif;
  --font-display: 'Telegraf', Arial, sans-serif;
  --font-body: 'Telegraf', Arial, system-ui, sans-serif;
  --ease-ui: cubic-bezier(0.2, 0, 0, 1);
  --in-oklab: ;
  --in-oklch: ;
}

@supports (background: linear-gradient(in oklab, white, black)) {
  :root {
    --in-oklab: in oklab;
    --in-oklch: in oklch;
  }
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--upn-bg);
  color: var(--upn-dark-gray);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  font-size-adjust: from-font;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Escenario vivo Antigravity: retícula arquitectónica + aurora amarilla suave tras el cursor */
.aurora-stage {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  z-index: 0;
  isolation: isolate;
  contain: layout paint;
}

.aurora-dot-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(20, 20, 20, 0.055) 1px, transparent 1.35px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 88% 82% at 50% 45%, #000 45%, transparent 100%);
  mask-image: radial-gradient(ellipse 88% 82% at 50% 45%, #000 45%, transparent 100%);
}

.aurora-ambient {
  position: absolute;
  inset: -12%;
  background:
    radial-gradient(ellipse 58% 44% at 86% 10% var(--in-oklab), rgba(253, 186, 48, 0.30) 0%, rgba(254, 240, 138, 0.18) 42%, transparent 72%),
    radial-gradient(ellipse 52% 42% at 10% 88% var(--in-oklab), rgba(253, 186, 48, 0.30) 0%, rgba(254, 240, 138, 0.16) 48%, transparent 74%);
}

.aurora-orb {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
  transition: opacity 0.45s var(--ease-ui);
}

.aurora-orb--primary {
  width: 680px;
  height: 560px;
  margin-left: -340px;
  margin-top: -280px;
  background: radial-gradient(
    ellipse closest-side var(--in-oklab),
    rgba(253, 186, 48, 0.22) 0%,
    rgba(254, 240, 138, 0.13) 24%,
    rgba(253, 224, 71, 0.10) 48%,
    rgba(254, 249, 195, 0.04) 72%,
    transparent 98%
  );
}

.aurora-orb--trail {
  width: 580px;
  height: 460px;
  margin-left: -290px;
  margin-top: -230px;
  background: radial-gradient(
    ellipse closest-side var(--in-oklab),
    rgba(253, 186, 48, 0.18) 0%,
    rgba(254, 240, 138, 0.09) 26%,
    rgba(253, 224, 71, 0.06) 54%,
    transparent 98%
  );
}

.aurora-orb--core {
  width: 220px;
  height: 220px;
  margin-left: -110px;
  margin-top: -110px;
  background: radial-gradient(
    circle closest-side var(--in-oklab),
    rgba(253, 186, 48, 0.28) 0%,
    rgba(254, 240, 138, 0.16) 28%,
    rgba(253, 224, 71, 0.09) 60%,
    transparent 96%
  );
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .aurora-stage.is-active .aurora-orb--primary {
    opacity: 0.75;
  }
  .aurora-stage.is-active .aurora-orb--trail {
    opacity: 0.62;
  }
  .aurora-stage.is-active .aurora-orb--core {
    opacity: 0.68;
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  background: transparent;
  overflow: hidden;
}

/* Cabecera institucional estilizada con presencia visual */
.upn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.6rem, env(safe-area-inset-top)) max(1.1rem, env(safe-area-inset-right)) 0.6rem max(1rem, env(safe-area-inset-left));
  background: linear-gradient(120deg, #0D0F12 0%, #171A21 62%, #231D11 100%);
  color: var(--upn-white);
  border-bottom: 2px solid var(--upn-yellow);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.18);
  flex-shrink: 0;
  z-index: 5;
}

.upn-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.upn-emblem {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Logo cuadrado con esquinas redondeadas según identidad solicitada */
.upn-logo {
  display: block;
  width: 38px;
  height: 38px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(253, 186, 48, 0.35), 0 0 0 1px rgba(253, 186, 48, 0.4);
}

.upn-titles {
  min-width: 0;
}

.upn-titles h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(0.92rem, 0.84rem + 0.45vw, 1.14rem);
  font-size-adjust: from-font;
  line-height: 1.18;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--upn-white);
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

.upn-subtitle {
  margin: 0.08rem 0 0;
  font-family: var(--font-body);
  font-size: 0.73rem;
  font-weight: 400;
  color: #D4DBE6;
  letter-spacing: 0.025em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

/* Indicador discreto: únicamente punto verde animado sin texto */
.status-indicator {
  position: relative;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  flex-shrink: 0;
}

.status-indicator::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.42);
  pointer-events: none;
  opacity: 0;
  scale: 0.75;
}

@media (prefers-reduced-motion: no-preference) {
  .status-indicator[data-state="synced"]::after {
    animation: live-dot-pulse 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite;
  }
}

@keyframes live-dot-pulse {
  0% {
    opacity: 0.65;
    scale: 0.85;
  }
  75%, 100% {
    opacity: 0;
    scale: 2.15;
  }
}

.status-indicator[data-state="cached"] {
  background: var(--upn-yellow);
  box-shadow: 0 0 0 3px rgba(253, 186, 48, 0.3);
}

.status-indicator[data-state="pending"] {
  background: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.28);
}

.status-indicator[data-state="error"] {
  background: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.28);
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--upn-white);
  cursor: pointer;
  transition: background-color 0.16s var(--ease-ui), border-color 0.16s var(--ease-ui), color 0.16s var(--ease-ui);
}

.icon-btn:hover {
  background: rgba(253, 186, 48, 0.18);
  border-color: rgba(253, 186, 48, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 12px rgba(253, 186, 48, 0.16);
}

.header-history-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: inline-grid;
  place-items: center;
  min-inline-size: 26px;
  block-size: 26px;
  padding-block: 0;
  padding-inline: 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--upn-yellow);
  color: var(--upn-black);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size-adjust: none;
  line-height: 1;
  text-box: normal;
  text-align: center;
  border: 1.5px solid var(--upn-black);
}

.header-history-badge > .badge-value {
  display: block;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.header-history-badge[hidden] {
  display: none;
}

.icon-btn:focus-visible,
.prompt-chip:focus-visible,
.quick-chip:focus-visible,
.attach-btn:focus-visible,
.remove-image-btn:focus-visible,
.user-image-btn:focus-visible,
.lightbox-close-btn:focus-visible,
.send-btn:focus-visible,
.table-wrapper:focus-visible,
.drawer-close-btn:focus-visible,
.drawer-search-input:focus-visible,
.clear-history-btn:focus-visible,
.copy-response-btn:focus-visible {
  outline: 2px solid var(--upn-yellow);
  outline-offset: 2px;
}

/* Navigation Drawer modal en top layer con transición GPU-composited (modern-web-guidance: animate-to-from-top-layer, motion) */
.Drawer {
  --drawer-width: min(23.5rem, 88dvw, 100dvw - 24px);
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  overflow: hidden;
  pointer-events: none;
  transition-property: display, overlay;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

:is(.Drawer[open]):where(:not([data-closing])) {
  pointer-events: auto;
}

.Drawer::backdrop {
  background-color: rgba(15, 23, 42, 0);
  transition-property: background-color, display, overlay;
  transition-duration: 0.28s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

:is(.Drawer[open]):where(:not([data-closing]))::backdrop {
  background-color: rgba(15, 23, 42, 0.48);
}

@starting-style {
  :is(.Drawer[open]):where(:not([data-closing]))::backdrop {
    background-color: rgba(15, 23, 42, 0);
  }
}

.Drawer-scroller {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.Drawer-sheet {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: var(--drawer-width);
  height: 100svh;
  background: var(--upn-bg);
  color: var(--upn-dark-gray);
  contain: layout paint style;
  overflow: hidden;
  border-right: 1px solid var(--upn-border-strong);
  box-shadow: 14px 0 36px rgba(15, 23, 42, 0.22);
  opacity: 0;
  transition-property: transform, opacity;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: no-preference) {
  .Drawer-sheet {
    transform: translate3d(-100%, 0, 0);
  }

  .Drawer[open] .Drawer-sheet {
    will-change: transform;
  }
}

:is(.Drawer[open]):where(:not([data-closing])) .Drawer-sheet {
  opacity: 1;
}

@starting-style {
  :is(.Drawer[open]):where(:not([data-closing])) .Drawer-sheet {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  :is(.Drawer[open]):where(:not([data-closing])) .Drawer-sheet {
    transform: translate3d(0, 0, 0);
  }

  @starting-style {
    :is(.Drawer[open]):where(:not([data-closing])) .Drawer-sheet {
      transform: translate3d(-100%, 0, 0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .Drawer,
  .Drawer::backdrop,
  .Drawer-sheet {
    transition-duration: 0.1s;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0.85rem 1.05rem;
  background: linear-gradient(120deg, #0D0F12 0%, #171A21 62%, #231D11 100%);
  color: var(--upn-white);
  border-bottom: 2px solid var(--upn-yellow);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.drawer-title-icon {
  color: var(--upn-yellow);
  flex-shrink: 0;
}

.drawer-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  text-box: trim-both cap alphabetic;
  color: var(--upn-white);
}

.history-count {
  display: inline-grid;
  place-items: center;
  min-inline-size: 26px;
  block-size: 26px;
  padding-block: 0;
  padding-inline: 6px;
  box-sizing: border-box;
  border-radius: 999px;
  background: rgba(253, 186, 48, 0.16);
  color: var(--upn-yellow);
  border: 1px solid rgba(253, 186, 48, 0.38);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size-adjust: none;
  line-height: 1;
  text-box: normal;
  text-align: center;
}

.history-count > .badge-value {
  display: block;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.drawer-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: max(34px, var(--target-size));
  min-block-size: max(34px, var(--target-size));
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--upn-white);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.36);
}

.drawer-search {
  padding: 0.6rem 0.85rem;
  background: var(--upn-white);
  border-bottom: 1px solid var(--upn-border);
}

.drawer-search[hidden] {
  display: none;
}

.drawer-search-box {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  padding: 0.38rem 0.7rem;
  border-radius: 10px;
  background: var(--upn-bg);
  border: 1px solid var(--upn-border);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.drawer-search-box:focus-within {
  background: var(--upn-white);
  border-color: var(--upn-yellow);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--upn-yellow) 24%, transparent);
}

.drawer-search-icon {
  color: var(--upn-text-muted);
  flex-shrink: 0;
}

.drawer-search-input {
  width: 100%;
  min-width: 0;
  min-block-size: max(26px, var(--target-size));
  border: 0;
  background: transparent;
  color: var(--upn-black);
  font-family: var(--font-body);
  font-size: 0.84rem;
}

.drawer-search-input:focus {
  outline: none;
}

.drawer-search-input::placeholder {
  color: var(--upn-text-muted);
}

.history-list-wrap {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  container-type: scroll-state;
  scroll-padding-block: 0.75rem;
  scrollbar-gutter: stable;
  padding: 0.5rem 0.75rem 0.85rem;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

/* Sombras de desplazamiento en el historial (modern-web-guidance: scrollability-affordance-hints) */
.history-list-wrap::before,
.history-list-wrap::after {
  content: "";
  display: block;
  position: sticky;
  block-size: 0.85rem;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.history-list-wrap::before {
  inset-block-start: -0.5rem;
  margin-block-end: -0.85rem;
  background: radial-gradient(farthest-side at 50% 0, rgb(15 23 42 / 0.14), transparent);
}

.history-list-wrap::after {
  inset-block-end: -0.85rem;
  margin-block-start: -0.85rem;
  background: radial-gradient(farthest-side at 50% 100%, rgb(15 23 42 / 0.14), transparent);
}

@container scroll-state(scrollable: block-start) {
  .history-list-wrap::before {
    opacity: 1;
  }
}

@container scroll-state(scrollable: block-end) {
  .history-list-wrap::after {
    opacity: 1;
  }
}

@supports not (container-type: scroll-state) {
  .history-list-wrap::before,
  .history-list-wrap::after {
    animation: show-scroll-shadow linear both;
    animation-timeline: scroll();
  }

  .history-list-wrap::before {
    animation-range: 0 2rem;
  }

  .history-list-wrap::after {
    animation-direction: reverse;
    animation-range: calc(100% - 2rem) 100%;
  }
}

@keyframes show-scroll-shadow {
  to {
    opacity: 1;
  }
}

.history-list-wrap.more-start::before,
.history-list-wrap.more-end::after {
  opacity: 1;
}

.history-empty {
  margin: 1.5rem 0.5rem;
  padding: 1.25rem 1rem;
  text-align: center;
  border-radius: 12px;
  border: 1px dashed var(--upn-border-strong);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  color: var(--upn-text-muted);
  line-height: 1.5;
  text-wrap: pretty;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.history-group-label {
  padding: 0.65rem 0.3rem 0.2rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--upn-text-muted);
}

.history-group-label:first-child {
  padding-top: 0.15rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-inline-size: 0;
  padding-right: 0.35rem;
  background: var(--upn-white);
  border-radius: 12px;
  border: 1px solid var(--upn-border);
  border-left: 3px solid transparent;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: background-color 0.16s var(--ease-ui), border-color 0.16s var(--ease-ui);
}

.history-item:hover {
  border-color: color-mix(in oklab, var(--upn-yellow) 55%, var(--upn-border));
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

.history-item.is-active {
  background: linear-gradient(90deg, var(--upn-yellow-soft) 0%, #FFFFFF 100%);
  border-color: color-mix(in oklab, var(--upn-yellow) 68%, white);
  border-left-color: var(--upn-yellow);
}

.history-item-btn {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.26rem;
  padding: 0.62rem 0.55rem 0.62rem 0.72rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--upn-dark-gray);
  text-align: left;
  cursor: pointer;
  outline-offset: -2px;
}

.history-item-btn:focus-visible {
  outline: 2px solid var(--upn-yellow);
  outline-offset: -2px;
}

.history-item-title {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--upn-black);
}

.history-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.history-item-time {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--upn-text-muted);
}

.history-item-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.48rem;
  border-radius: 999px;
  background: #EEF2F7;
  color: #334155;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.history-item-thumb {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid var(--upn-border);
  flex-shrink: 0;
}

.history-item-delete {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: max(28px, var(--target-size));
  min-block-size: max(28px, var(--target-size));
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748B;
  cursor: pointer;
  transition: opacity 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

@media (hover: hover) and (pointer: fine) {
  .history-item-delete {
    opacity: 0;
  }

  .history-item:hover .history-item-delete,
  .history-item:focus-within .history-item-delete {
    opacity: 1;
  }
}

.history-item-delete:hover {
  background: var(--upn-danger-bg);
  color: var(--upn-danger-text);
  opacity: 1;
}

.history-item-delete:focus-visible {
  outline: 2px solid var(--upn-yellow);
  outline-offset: -2px;
  opacity: 1;
}

.drawer-footer {
  padding: 0.65rem 0.85rem max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--upn-border);
  background: var(--upn-white);
}

.drawer-footer[hidden] {
  display: none;
}

.clear-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-block-size: max(36px, var(--target-size));
  padding: 0.48rem 0.75rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--upn-text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.clear-history-label {
  text-box: trim-both cap alphabetic;
}

.clear-history-btn:hover {
  background: var(--upn-danger-bg);
  border-color: color-mix(in oklab, #DC2626 24%, white);
  color: var(--upn-danger-text);
}

.clear-history-btn[data-confirm="true"] {
  background: #DC2626;
  border-color: #B91C1C;
  color: #FFFFFF;
}

/* Lienzo principal a pantalla completa con textura sutil institucional */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: transparent;
}

.chat-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.chat-messages {
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  padding: 1.05rem max(1.5rem, env(safe-area-inset-right)) 1.35rem max(1.5rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

/* Tarjeta de bienvenida viva y estilizada */
.welcome-card {
  position: relative;
  isolation: isolate;
  margin: auto;
  width: 100%;
  max-width: 980px;
  background: linear-gradient(180deg var(--in-oklab), rgba(255, 255, 255, 0.90) 0%, rgba(255, 253, 247, 0.84) 100%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(253, 186, 48, 0.24);
  border-top: 3.5px solid var(--upn-yellow);
  border-radius: 20px;
  padding: 1.85rem;
  box-shadow:
    0 24px 52px -14px rgba(15, 23, 42, 0.11),
    0 8px 20px -6px rgba(253, 186, 48, 0.14),
    0 1px 4px rgba(15, 23, 42, 0.04);
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.82rem;
  border-radius: 999px;
  background: var(--upn-yellow-soft);
  border: 1px solid color-mix(in oklab, var(--upn-yellow) 55%, white);
  color: var(--upn-black);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  margin-bottom: 0.75rem;
}

.welcome-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--upn-yellow);
  box-shadow: 0 0 0 2px rgba(253, 186, 48, 0.35);
}

.welcome-card h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(1.1rem, 0.98rem + 0.6vw, 1.44rem);
  font-size-adjust: from-font;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: var(--upn-black);
}

.welcome-card p {
  margin: 0 0 1.25rem;
  color: var(--upn-text-muted);
  font-size: 0.95rem;
  text-wrap: pretty;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.prompt-chip {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  text-align: left;
  padding: 0.85rem 1.05rem;
  min-block-size: 3rem;
  border-radius: 14px;
  border: 1px solid var(--upn-border);
  border-left: 3px solid var(--upn-yellow);
  background: var(--upn-white);
  color: var(--upn-dark-gray);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: background-color 0.16s var(--ease-ui), border-color 0.16s var(--ease-ui), color 0.16s var(--ease-ui);
}

.prompt-chip:hover:not(:disabled) {
  background: var(--upn-yellow-soft);
  border-color: var(--upn-yellow);
  color: var(--upn-black);
  box-shadow: 0 10px 22px -6px rgba(253, 186, 48, 0.24);
}

/* Mensajes y ventanas de respuesta con entrada suave (@starting-style) */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  opacity: 1;
  translate: 0 0;
  transition: display, opacity ease-out, translate ease-out;
  transition-duration: 0.32s;
  transition-behavior: allow-discrete;
}

@starting-style {
  .message-row {
    opacity: 0;
    translate: 0 12px;
  }
}

.message-row[hidden] {
  display: none;
  opacity: 0;
  translate: 0 12px;
}

.message-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message-row.assistant {
  align-self: flex-start;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
}

.message-bubble {
  border-radius: 16px;
  font-size: 0.94rem;
  line-height: 1.56;
  word-break: break-word;
}

.message-row.user .message-bubble {
  padding: 0.85rem 1.15rem;
  background: linear-gradient(135deg, #16181D 0%, #232730 100%);
  color: var(--upn-white);
  border-bottom-right-radius: 4px;
  border-left: 3.5px solid var(--upn-yellow);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 22px -6px rgba(15, 23, 42, 0.22);
}

/* Ventana de respuesta ejecutiva con cabecera propia, badge de conteo y botón copiar */
.message-row.assistant .message-bubble {
  width: 100%;
  padding: 0;
  overflow: visible;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px) saturate(130%);
  color: var(--upn-dark-gray);
  border: 1px solid var(--upn-border);
  border-top: 3px solid var(--upn-yellow);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  box-shadow:
    0 14px 34px -10px rgba(15, 23, 42, 0.09),
    0 4px 12px -4px rgba(253, 186, 48, 0.08),
    0 1px 4px rgba(15, 23, 42, 0.04);
}

.response-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.62rem 1.1rem;
  background: linear-gradient(90deg, var(--upn-yellow-tint) 0%, #F8FAFC 100%);
  border-bottom: 1px solid var(--upn-border);
}

.response-card-identity {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.response-card-logo {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
}

.response-card-title {
  font-family: var(--font-display);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  text-transform: uppercase;
  color: var(--upn-black);
  white-space: nowrap;
}

.response-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.58rem;
  border-radius: 999px;
  background: var(--upn-yellow-soft);
  border: 1px solid color-mix(in oklab, var(--upn-yellow) 60%, white);
  color: var(--upn-black);
  font-family: var(--font-display);
  font-size: 0.71rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  white-space: nowrap;
}

.response-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.copy-response-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.62rem;
  border-radius: 8px;
  border: 1px solid var(--upn-border-strong);
  background: var(--upn-white);
  color: var(--upn-dark-gray);
  font-family: var(--font-body);
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.copy-response-btn:hover {
  background: var(--upn-yellow-soft);
  border-color: var(--upn-yellow);
  color: var(--upn-black);
}

.copy-response-btn[data-copied="true"] {
  background: var(--upn-success-bg);
  border-color: color-mix(in oklab, var(--upn-success) 45%, white);
  color: var(--upn-success-text);
}

.message-row.assistant .bubble-content {
  padding: 0.95rem 1.15rem 1.05rem;
}

.message-meta {
  margin-top: 0.3rem;
  padding: 0 0.3rem;
  font-size: 0.72rem;
  color: var(--upn-text-muted);
}

.stage-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--upn-text-muted);
  font-size: 0.89rem;
  font-weight: 600;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--upn-yellow);
}

@media (prefers-reduced-motion: no-preference) {
  .typing-dots span {
    animation: dot-pulse 1.1s infinite ease-in-out;
  }
  .typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
  }
  .typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
  }
}

@keyframes dot-pulse {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.bubble-content > :first-child {
  margin-top: 0;
}

.bubble-content > :last-child {
  margin-bottom: 0;
}

.bubble-content p {
  margin: 0.45rem 0;
  max-inline-size: 74ch;
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.bubble-content h3,
.bubble-content h4 {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--upn-black);
  margin: 0.75rem 0 0.35rem;
  font-size: 0.98rem;
}

.bubble-content ul,
.bubble-content ol {
  margin: 0.4rem 0;
  padding-left: 1.35rem;
}

.bubble-content li {
  margin: 0.22rem 0;
}

.bubble-content code {
  background: var(--upn-bg);
  border: 1px solid var(--upn-border);
  padding: 0.1rem 0.38rem;
  border-radius: 5px;
  font-size: 0.86em;
  color: var(--upn-black);
}

/* Badges de estado dentro de tablas con icono + texto (WCAG 1.4.1 / 1.4.3) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-badge--ok {
  background: var(--upn-success-bg);
  border-color: color-mix(in oklab, var(--upn-success) 38%, white);
  color: var(--upn-success-text);
}

.status-badge--warn {
  background: var(--upn-warn-bg);
  border-color: color-mix(in oklab, var(--upn-warn) 42%, white);
  color: var(--upn-warn-text);
}

.status-badge--info {
  background: var(--upn-info-bg);
  border-color: color-mix(in oklab, #2563EB 35%, white);
  color: var(--upn-info-text);
}

.status-badge--danger {
  background: var(--upn-danger-bg);
  border-color: color-mix(in oklab, #DC2626 35%, white);
  color: var(--upn-danger-text);
}

/* Tablas responsivas amplias sin cortes de códigos (modern-web-guidance: responsive-table) */
.table-wrapper {
  margin: 0.75rem 0;
  overflow: auto;
  max-inline-size: 100%;
  contain: layout style;
  border: 1px solid var(--upn-border-strong);
  border-radius: 13px;
  background: var(--upn-white);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  container-type: inline-size;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

.table-wrapper table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: clamp(0.76rem, 0.72rem + 0.12vw, 0.82rem);
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.table-wrapper thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.table-wrapper thead th {
  background: var(--upn-black);
  color: var(--upn-white);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.7rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-wrap: balance;
  padding: 0.56rem 0.55rem;
  border-bottom: 2.5px solid var(--upn-yellow);
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  vertical-align: bottom;
}

.table-wrapper tbody th,
.table-wrapper tbody td {
  padding: 0.48rem 0.55rem;
  line-height: 1.35;
  border-bottom: 1px solid var(--upn-border);
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: break-word;
}

.table-wrapper .col-nowrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-wrapper tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--upn-white);
  color: var(--upn-black);
  font-weight: 600;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  border-right: 1px solid var(--upn-border);
}

.table-wrapper tbody tr:nth-child(even) th,
.table-wrapper tbody tr:nth-child(even) td {
  background: #F8FAFC;
}

.table-wrapper tbody tr:hover th,
.table-wrapper tbody tr:hover td {
  background: var(--upn-yellow-soft);
}

.table-wrapper tbody tr:last-child th,
.table-wrapper tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrapper--wide table {
  font-size: clamp(0.73rem, 0.7rem + 0.1vw, 0.79rem);
}

.table-wrapper--wide thead th {
  font-size: 0.67rem;
  padding: 0.5rem 0.44rem;
}

.table-wrapper--wide tbody th,
.table-wrapper--wide tbody td {
  padding: 0.44rem 0.44rem;
}

@container (width < 520px) {
  .table-wrapper table,
  .table-wrapper thead,
  .table-wrapper tbody,
  .table-wrapper tr,
  .table-wrapper th,
  .table-wrapper td {
    display: block;
  }

  .table-wrapper thead {
    display: none;
  }

  .table-wrapper tbody tr {
    margin: 0.6rem;
    border: 1px solid var(--upn-border-strong);
    border-radius: 10px;
    overflow: hidden;
    background: var(--upn-white);
  }

  .table-wrapper tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--upn-black);
    color: var(--upn-white);
    border-bottom: 2px solid var(--upn-yellow);
    border-right: 0;
    font-weight: 700;
    min-width: 0;
    white-space: normal;
  }

  .table-wrapper tbody tr:nth-child(even) th,
  .table-wrapper tbody tr:hover th {
    background: var(--upn-black);
  }

  .table-wrapper tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    white-space: normal;
  }

  .table-wrapper tbody td::before {
    font-weight: 600;
    color: var(--upn-text-muted);
    flex-shrink: 0;
  }

  .table-wrapper td:nth-child(2)::before { content: var(--label-2, "Col 2") ": "; }
  .table-wrapper td:nth-child(3)::before { content: var(--label-3, "Col 3") ": "; }
  .table-wrapper td:nth-child(4)::before { content: var(--label-4, "Col 4") ": "; }
  .table-wrapper td:nth-child(5)::before { content: var(--label-5, "Col 5") ": "; }
  .table-wrapper td:nth-child(6)::before { content: var(--label-6, "Col 6") ": "; }
  .table-wrapper td:nth-child(7)::before { content: var(--label-7, "Col 7") ": "; }
  .table-wrapper td:nth-child(8)::before { content: var(--label-8, "Col 8") ": "; }
  .table-wrapper td:nth-child(9)::before { content: var(--label-9, "Col 9") ": "; }
  .table-wrapper td:nth-child(10)::before { content: var(--label-10, "Col 10") ": "; }
  .table-wrapper td:nth-child(11)::before { content: var(--label-11, "Col 11") ": "; }
  .table-wrapper td:nth-child(12)::before { content: var(--label-12, "Col 12") ": "; }
  .table-wrapper td:nth-child(13)::before { content: var(--label-13, "Col 13") ": "; }
  .table-wrapper td:nth-child(14)::before { content: var(--label-14, "Col 14") ": "; }
  .table-wrapper td:nth-child(15)::before { content: var(--label-15, "Col 15") ": "; }
}

/* Barra inferior de entrada y chips de acceso rápido */
.composer-bar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px) saturate(150%);
  border-top: 1px solid var(--upn-border);
  padding: 0.6rem max(1.5rem, env(safe-area-inset-right)) max(0.8rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.composer-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-access-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.1rem 0.05rem 0.15rem;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

.quick-chip {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-block-size: 2.2rem;
  padding: 0.44rem 0.92rem;
  border-radius: 999px;
  border: 1px solid var(--upn-border-strong);
  background: var(--upn-white);
  color: var(--upn-dark-gray);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  transition: background-color 0.16s var(--ease-ui), border-color 0.16s var(--ease-ui), color 0.16s var(--ease-ui);
}

.quick-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--upn-yellow);
  flex-shrink: 0;
}

.quick-chip:hover:not(:disabled) {
  background: var(--upn-yellow-soft);
  border-color: var(--upn-yellow);
  color: var(--upn-black);
  box-shadow: 0 6px 14px -4px rgba(253, 186, 48, 0.24);
}

.quick-chip:disabled,
.prompt-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-composer {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 0.44rem 0.5rem 0.44rem 0.95rem;
  border: 1.5px solid var(--upn-border-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.07);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.chat-composer:focus-within {
  border-color: var(--upn-yellow);
  background: var(--upn-white);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--upn-yellow) 24%, transparent), 0 8px 24px rgba(15, 23, 42, 0.08);
}

.growable-textarea {
  flex: 1;
  min-width: 0;
}

#chat-input {
  field-sizing: content;
  width: 100%;
  height: auto;
  min-block-size: 1.5lh;
  max-block-size: 6lh;
  padding: 0.4rem 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--upn-black);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.45;
  resize: none;
  outline: none;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

#chat-input::placeholder {
  color: #5C6675;
}

@supports not (field-sizing: content) {
  .growable-textarea {
    display: grid;
  }

  .growable-textarea::after,
  .growable-textarea > textarea {
    grid-area: 1 / 1 / 2 / 2;
    font: inherit;
    line-height: 1.45;
    padding: 0.4rem 0;
    border: 0;
  }

  .growable-textarea::after {
    content: attr(data-replicated-value) " ";
    white-space: pre-wrap;
    word-break: break-word;
    visibility: hidden;
    max-block-size: 9rem;
    overflow: hidden;
  }

  .growable-textarea > textarea {
    overflow-y: auto;
    max-block-size: 9rem;
  }
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #FDBA30 0%, #F59E0B 100%);
  color: var(--upn-black);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.34);
  transition: background-color 0.16s var(--ease-ui), opacity 0.16s var(--ease-ui);
}

.send-btn:hover {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.42);
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.send-btn .stop-icon {
  display: none;
}

.send-btn.is-streaming {
  background: var(--upn-black);
  color: var(--upn-yellow);
}

.send-btn.is-streaming .send-icon {
  display: none;
}

.send-btn.is-streaming .stop-icon {
  display: block;
}

/* Barra de feedback accesible y vista previa de foto adjunta (modern-web-guidance: forms) */
.chat-main.is-dragover {
  outline: 3px dashed var(--upn-yellow);
  outline-offset: -8px;
  background-color: var(--upn-yellow-tint);
}

.composer-feedback {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.78rem;
  border-radius: 10px;
  border: 1px solid color-mix(in oklab, #DC2626 38%, white);
  background: var(--upn-danger-bg);
  color: var(--upn-danger-text);
  font-size: 0.82rem;
  font-weight: 600;
}

.composer-feedback[hidden] {
  display: none;
}

.image-preview-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  align-self: flex-start;
  max-width: 100%;
  padding: 0.42rem 0.6rem 0.42rem 0.45rem;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--upn-yellow) 65%, white);
  background: var(--upn-yellow-soft);
  box-shadow: 0 2px 10px rgba(253, 186, 48, 0.16);
}

.image-preview-bar[hidden] {
  display: none;
}

.image-preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--upn-border-strong);
  background: var(--upn-white);
  flex-shrink: 0;
}

.image-preview-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.image-preview-name {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--upn-black);
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

.image-preview-meta {
  font-size: 0.72rem;
  color: var(--upn-text-muted);
}

.remove-image-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--upn-border-strong);
  border-radius: 8px;
  background: var(--upn-white);
  color: var(--upn-black);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.remove-image-btn:hover {
  background: var(--upn-danger-bg);
  color: var(--upn-danger-text);
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--upn-border-strong);
  border-radius: 11px;
  background: var(--upn-white);
  color: var(--upn-dark-gray);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.16s var(--ease-ui), border-color 0.16s var(--ease-ui), color 0.16s var(--ease-ui);
}

.attach-btn:hover:not(:disabled) {
  background: var(--upn-yellow-soft);
  border-color: var(--upn-yellow);
  color: var(--upn-black);
}

.attach-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Imagen adjunta en burbuja de usuario y lightbox modal */
.user-image-btn {
  display: block;
  margin-bottom: 0.45rem;
  padding: 0;
  border: 1px solid rgba(253, 186, 48, 0.55);
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
  cursor: zoom-in;
}

.user-image-thumb {
  display: block;
  max-width: min(260px, 65vw);
  max-height: 200px;
  object-fit: cover;
}

.user-message-text {
  white-space: pre-wrap;
}

.image-lightbox {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(94vw, 960px);
  max-height: 90dvh;
}

.image-lightbox::backdrop {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.image-lightbox-box {
  position: relative;
  padding: 0.6rem;
  border-radius: 14px;
  background: var(--upn-black);
  border: 2px solid var(--upn-yellow);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.lightbox-img {
  display: block;
  max-width: calc(min(94vw, 960px) - 1.4rem);
  max-height: calc(90dvh - 1.4rem);
  border-radius: 9px;
  object-fit: contain;
}

.lightbox-close-btn {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 20, 20, 0.85);
  color: var(--upn-white);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

/* Respeto estricto de prefers-reduced-motion (physics-based-easing + animate-element-entry-exit) */
@media (prefers-reduced-motion: reduce) {
  .message-row {
    translate: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    .message-row {
      translate: none;
    }
  }

  .message-row[hidden] {
    translate: none;
  }

  .icon-btn,
  .prompt-chip,
  .quick-chip,
  .attach-btn,
  .send-btn,
  .history-item,
  .admin-btn-primary,
  .admin-btn-secondary {
    transition: none;
  }

  .aurora-orb {
    display: none;
  }

  .prompt-chip::after,
  .quick-chip::after,
  .followup-chip::after,
  .chat-composer::after,
  .admin-card::after {
    display: none;
    opacity: 0;
  }
}

/* Brillo superficial dorado suave reactivo al cursor (movido 100% en compositor vía translate3d) */
.prompt-chip::after,
.quick-chip::after,
.followup-chip::after,
.chat-composer::after,
.admin-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 260px;
  height: 260px;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(calc(var(--spot-x, -300px) - 50%), calc(var(--spot-y, -300px) - 50%), 0);
  transition: opacity 0.24s var(--ease-ui);
  background: radial-gradient(
    circle var(--in-oklab),
    rgba(253, 186, 48, 0.22) 0%,
    rgba(254, 240, 138, 0.09) 42%,
    transparent 70%
  );
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .prompt-chip.has-spot::after,
  .quick-chip.has-spot::after,
  .followup-chip.has-spot::after,
  .chat-composer.has-spot::after,
  .admin-card.has-spot::after {
    opacity: 1;
  }
}

.bubble-content .md-divider,
.message-content .md-divider {
  border: 0;
  border-top: 1px solid var(--upn-border);
  margin: 12px 0;
}

/* Soporte Forced Colors Mode / Alto Contraste de Windows (modern-web-guidance: color) */
@media (forced-colors: active) {
  .aurora-stage {
    display: none;
  }

  .upn-header,
  .Drawer-sheet,
  .drawer-search-box,
  .history-item,
  .clear-history-btn,
  .welcome-card,
  .message-row.user .message-bubble,
  .message-row.assistant .message-bubble,
  .prompt-chip,
  .quick-chip,
  .attach-btn,
  .image-preview-bar,
  .composer-feedback,
  .table-wrapper,
  .copy-response-btn,
  .status-badge {
    border: 1px solid CanvasText;
    box-shadow: none;
  }

  .upn-logo {
    outline: 1px solid CanvasText;
  }

  .status-indicator {
    background: Highlight;
    border: 2px solid CanvasText;
  }
}

/* Fallback WebKit scrollbar (modern-web-guidance: customize-scrollbar-color-and-thickness) */
@supports not (scrollbar-color: auto) {
  .chat-messages,
  .table-wrapper,
  .quick-access-bar,
  .history-list-wrap,
  #chat-input {
    scrollbar-width: auto;
  }

  .chat-messages::-webkit-scrollbar,
  .table-wrapper::-webkit-scrollbar,
  .quick-access-bar::-webkit-scrollbar,
  .history-list-wrap::-webkit-scrollbar,
  #chat-input::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  .chat-messages::-webkit-scrollbar-thumb,
  .table-wrapper::-webkit-scrollbar-thumb,
  .quick-access-bar::-webkit-scrollbar-thumb,
  .history-list-wrap::-webkit-scrollbar-thumb,
  #chat-input::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
  }

  .chat-messages::-webkit-scrollbar-track,
  .table-wrapper::-webkit-scrollbar-track,
  .quick-access-bar::-webkit-scrollbar-track,
  .history-list-wrap::-webkit-scrollbar-track,
  #chat-input::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

@media (max-width: 640px) {
  .upn-subtitle {
    font-size: 0.7rem;
  }

  .chat-messages {
    padding: 0.85rem 0.85rem 1rem;
  }

  .composer-bar {
    padding: 0.5rem 0.85rem max(0.75rem, env(safe-area-inset-bottom));
  }

  .message-row {
    max-width: 96%;
  }

  .welcome-card {
    padding: 1.15rem;
  }

  .response-card-header {
    padding: 0.5rem 0.85rem;
  }

  .message-row.assistant .bubble-content {
    padding: 0.85rem 0.9rem;
  }
}

/* ==========================================================================
   Panel Administrativo de Sincronización (/sync-admin.php)
   ========================================================================== */
body.admin-page {
  min-height: 100dvh;
  overflow-y: auto;
  background: var(--upn-bg);
}

.admin-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.admin-header-actions {
  gap: 0.5rem;
}

.admin-inline-form {
  display: inline-flex;
  margin: 0;
}

.admin-nav-link,
.admin-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 36px;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--upn-white);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  text-box: trim-both cap alphabetic;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-nav-link:hover,
.admin-logout-btn:hover {
  background: rgba(253, 186, 48, 0.18);
  border-color: var(--upn-yellow);
  color: var(--upn-yellow);
}

.admin-main {
  width: 100%;
  max-inline-size: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.admin-alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--upn-border);
  font-size: 0.9rem;
  line-height: 1.45;
}

.admin-alert--danger {
  background: var(--upn-danger-bg);
  color: var(--upn-danger-text);
  border-color: color-mix(in oklab, #DC2626 30%, white);
}

.admin-alert--warn {
  background: var(--upn-warn-bg);
  color: var(--upn-warn-text);
  border-color: color-mix(in oklab, #FDBA30 48%, white);
}

.admin-alert--success {
  background: var(--upn-success-bg);
  color: var(--upn-success-text);
  border-color: color-mix(in oklab, #16A34A 32%, white);
}

.admin-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px) saturate(130%);
  border: 1px solid var(--upn-border);
  border-radius: 16px;
  padding: 1.35rem 1.4rem;
  box-shadow:
    0 12px 28px -8px rgba(15, 23, 42, 0.07),
    0 3px 10px -4px rgba(253, 186, 48, 0.08);
}

.admin-login-card {
  width: 100%;
  max-inline-size: 470px;
  margin: 2rem auto 0;
  border-top: 3px solid var(--upn-yellow);
}

.admin-card-header {
  margin-bottom: 1rem;
}

.admin-eyebrow {
  display: inline-block;
  margin-bottom: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #9A6700;
}

.admin-card h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--upn-black);
}

.admin-muted {
  margin: 0.45rem 0 0;
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--upn-text-muted);
}

.admin-status-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.admin-metric {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--upn-bg);
  border: 1px solid var(--upn-border);
}

.admin-metric dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--upn-text-muted);
  margin-bottom: 0.28rem;
}

.admin-metric dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--upn-black);
  overflow-wrap: anywhere;
}

.admin-num {
  font-variant-numeric: tabular-nums;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.admin-pill--synced {
  background: var(--upn-success-bg);
  color: var(--upn-success-text);
}

.admin-pill--cached,
.admin-pill--pending {
  background: var(--upn-warn-bg);
  color: var(--upn-warn-text);
}

.admin-diag-foot {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--upn-border);
  font-size: 0.82rem;
  color: var(--upn-text-muted);
}

.admin-error-log {
  margin: 0.45rem 0 0;
  color: var(--upn-danger-text);
  overflow-wrap: anywhere;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

.admin-side-stack {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.admin-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--upn-black);
}

.admin-input,
.admin-file-input {
  width: 100%;
  min-block-size: 44px;
  padding: 0.58rem 0.8rem;
  border-radius: 10px;
  border: 1.5px solid var(--upn-border-strong);
  background: var(--upn-white);
  color: var(--upn-black);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 0.15s ease;
}

.admin-input:focus,
.admin-file-input:focus {
  outline: none;
  border-color: var(--upn-yellow);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--upn-yellow) 26%, transparent);
}

.admin-input--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.admin-secret-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
}

.admin-secret-wrap .admin-input {
  flex: 1;
  min-width: 0;
}

.admin-secret-toggle {
  flex-shrink: 0;
  min-block-size: 44px;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1.5px solid var(--upn-border-strong);
  background: var(--upn-bg);
  color: var(--upn-black);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-secret-toggle:hover {
  border-color: var(--upn-yellow);
  background: var(--upn-yellow-tint);
}

.admin-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-legend {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--upn-black);
  margin-bottom: 0.45rem;
}

.admin-radio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.admin-radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1.5px solid var(--upn-border);
  background: var(--upn-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.admin-radio-card:has(input:checked) {
  border-color: var(--upn-yellow);
  background: var(--upn-yellow-tint);
}

.admin-radio-card input {
  margin-top: 0.18rem;
  accent-color: #B45309;
}

.admin-radio-card strong {
  display: block;
  font-size: 0.83rem;
  color: var(--upn-black);
}

.admin-radio-card small {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--upn-text-muted);
}

.admin-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 32px;
  font-size: 0.84rem;
  color: var(--upn-dark-gray);
  cursor: pointer;
}

.admin-checkbox input {
  accent-color: #B45309;
  width: 16px;
  height: 16px;
}

.admin-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--upn-text-muted);
}

.admin-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.15rem;
}

.admin-btn-primary,
.admin-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 44px;
  padding: 0.6rem 1.15rem;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.admin-btn-primary {
  border: 0;
  background: linear-gradient(135deg, #FDBA30 0%, #F59E0B 100%);
  color: var(--upn-black);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.28);
}

.admin-btn-primary:hover {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

.admin-btn-primary.is-submitting {
  opacity: 0.72;
}

.admin-btn-secondary {
  min-block-size: 36px;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--upn-border-strong);
  background: var(--upn-white);
  color: var(--upn-black);
  font-size: 0.8rem;
}

.admin-btn-secondary:hover {
  border-color: var(--upn-yellow);
  background: var(--upn-yellow-tint);
}

.admin-webhook-info {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.admin-kv {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-copy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-code-inline {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--upn-bg);
  border: 1px solid var(--upn-border);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}

.admin-code-block {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: var(--upn-black);
  color: #F8FAFC;
  font-size: 0.76rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (forced-colors: active) {
  .admin-card,
  .admin-metric,
  .admin-input,
  .admin-radio-card,
  .admin-alert,
  .admin-btn-primary,
  .admin-btn-secondary,
  .admin-secret-toggle {
    border: 1px solid CanvasText;
    box-shadow: none;
  }
}

@media (max-width: 820px) {
  .admin-grid,
  .admin-field-row,
  .admin-radio-grid {
    grid-template-columns: 1fr;
  }

  .admin-main {
    padding: 1rem 0.85rem 2rem;
  }

  .admin-card {
    padding: 1.05rem;
  }
}
