/* ChatFull — dark purple creativo (marca propia) */

:root {
  color-scheme: dark;
  --bg: #0B0714;
  --bg-elevated: #0E0A1A;
  --surface: rgba(21, 16, 34, 0.88);
  --surface-solid: #151022;
  --surface-2: #1A1428;
  --border: rgba(139, 92, 246, 0.15);
  --border-strong: rgba(139, 92, 246, 0.28);
  --text: #F5F3FF;
  --text-secondary: #C4B5D8;
  --muted: #A89BB8;
  --accent: #8B5CF6;
  --accent-hover: #A78BFA;
  --accent-2: #A78BFA;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --user: linear-gradient(135deg, #7c3aed 0%, #8B5CF6 55%, #6d28d9 100%);
  --user-solid: #7c3aed;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --danger-border: rgba(248, 113, 113, 0.28);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.1);
  --shadow: 0 12px 40px rgba(8, 4, 20, 0.55);
  --shadow-sm: 0 4px 16px rgba(8, 4, 20, 0.35);
  --shadow-purple: 0 8px 28px rgba(139, 92, 246, 0.22);
  --radius: 16px;
  --radius-sm: 14px;
  --radius-xs: 12px;
  --radius-pill: 999px;
  --sidebar-w: 260px;
  --composer-max: 780px;
  --chat-gap: 18px;
  --bubble-user-max: 75%;
  --bubble-radius: 22px;
  --composer-radius: 28px;
  --topbar-h: 52px;
  --gtn-h: 58px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: 200ms cubic-bezier(0.22, 1, 0.36, 1);
  --ring: 0 0 0 3px rgba(139, 92, 246, 0.35);
  --glass: blur(12px) saturate(1.1);
  --scrollbar: rgba(139, 92, 246, 0.25);
  --scrollbar-hover: rgba(167, 139, 250, 0.4);
  --code-bg: #0a0612;
  --avatar-g: linear-gradient(145deg, #c4b5fd 0%, #8B5CF6 50%, #6d28d9 100%);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #F7F5FF;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-2: #F0ECFA;
  --border: rgba(109, 40, 217, 0.12);
  --border-strong: rgba(109, 40, 217, 0.22);
  --text: #1A1028;
  --text-secondary: #4A3F5C;
  --muted: #7A6B8F;
  --accent: #8B5CF6;
  --accent-hover: #7C3AED;
  --accent-2: #7C3AED;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --shadow: 0 8px 28px rgba(88, 28, 135, 0.1);
  --shadow-sm: 0 2px 10px rgba(88, 28, 135, 0.06);
  --shadow-purple: 0 8px 24px rgba(139, 92, 246, 0.2);
  --ring: 0 0 0 3px rgba(139, 92, 246, 0.28);
  --scrollbar: rgba(109, 40, 217, 0.18);
  --scrollbar-hover: rgba(109, 40, 217, 0.3);
  --code-bg: #F3F0FA;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --danger-border: rgba(239, 68, 68, 0.25);
}

html[data-theme="light"] .brand-text strong,
html[data-theme="light"] .gtn-brand strong,
html[data-theme="light"] .empty h2 {
  background: linear-gradient(90deg, #1e1b4b 0%, #6d28d9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #F7F5FF 100%);
}

html[data-theme="light"] .global-topnav {
  background: rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .orb {
  opacity: 0.28;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient mesh */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(139, 92, 246, 0.22), transparent 58%),
    radial-gradient(700px 460px at 92% 8%, rgba(109, 40, 217, 0.16), transparent 52%),
    radial-gradient(600px 480px at 50% 110%, rgba(88, 28, 135, 0.14), transparent 55%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  animation: floatOrb 18s ease-in-out infinite;
}

.orb-a {
  width: 280px;
  height: 280px;
  top: -60px;
  left: 20%;
  background: rgba(139, 92, 246, 0.35);
}

.orb-b {
  width: 320px;
  height: 320px;
  bottom: 10%;
  right: -40px;
  background: rgba(109, 40, 217, 0.22);
  animation-delay: -6s;
}

.orb-c {
  width: 200px;
  height: 200px;
  bottom: 30%;
  left: 8%;
  background: rgba(139, 92, 246, 0.12);
  animation-delay: -11s;
}

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -18px) scale(1.06); }
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Shell (debajo del top nav global) */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100dvh - var(--gtn-h));
  max-height: calc(100dvh - var(--gtn-h));
  margin-top: var(--gtn-h);
}

/* ——— Global top nav ——— */
.global-topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--gtn-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(11, 7, 20, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.gtn-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gtn-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 720;
  letter-spacing: -0.02em;
}

.gtn-brand strong {
  font-size: 1.05rem;
  background: linear-gradient(90deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gtn-mark {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
}

.gtn-modes {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

.gtn-modes::-webkit-scrollbar {
  display: none;
}

.gtn-link {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
  white-space: nowrap;
}

.gtn-link:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.gtn-link.active {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-purple);
}

.gtn-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gtn-theme {
  padding: 8px 12px !important;
  border-radius: var(--radius-pill) !important;
}

.gtn-theme .theme-label {
  display: none;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
  background: linear-gradient(180deg, #0E0A1A 0%, #0B0714 100%);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--avatar-g);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow:
    0 8px 24px rgba(139, 92, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.brand-text strong {
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  font-weight: 720;
  background: linear-gradient(90deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text span {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
}

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 0.9rem;
  box-shadow: var(--shadow-purple);
  transition: transform var(--ease), filter var(--ease), box-shadow var(--ease), background var(--ease);
}

.btn-new:hover:not(:disabled) {
  background: var(--accent-hover);
  filter: none;
  transform: translateY(-1px);
}

.btn-new:active:not(:disabled) {
  transform: translateY(0);
}

.btn-new svg {
  width: 16px;
  height: 16px;
}

.nav-section {
  margin-top: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 4px;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.thread-item {
  position: relative;
  padding-right: 32px !important;
  align-items: flex-start !important;
}

.thread-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.thread-item-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.thread-item-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.thread-item-del {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.thread-item-del:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.nav-studios {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto !important;
  overflow: visible !important;
}

/* Chips de tools del chat (estilo Omni) */
.chat-composer form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-composer #input {
  width: 100%;
  flex: none;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 8px 4px;
  line-height: 1.45;
  outline: none;
  box-shadow: none !important;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0 4px;
}

.chat-toolbar::-webkit-scrollbar {
  display: none;
}

.chat-tool-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chat-tool-chips::-webkit-scrollbar {
  display: none;
}

.chat-tool-chips[hidden] {
  display: none !important;
}

.chat-tool-chip {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.chat-tool-chip:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--accent-soft);
}

.chat-tool-chip.active,
.chat-tool-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.25);
}

.chat-tool-chip:disabled,
.chat-tool-chip.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-tool-chip-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
  border-radius: 50%;
}

.chat-send-up {
  margin-left: auto;
  flex: 0 0 auto;
}

.chat-toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.86rem;
  box-shadow: var(--shadow-md);
  animation: chat-toast-in 0.2s ease;
}

@keyframes chat-toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.85;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(56, 189, 248, 0.05));
  border: 1px solid var(--border);
  transition: border-color var(--ease), transform var(--ease);
}

.feature-card:hover {
  border-color: rgba(167, 139, 250, 0.28);
  transform: translateY(-1px);
}

.feature-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.feature-card strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 2px;
}

.feature-card p {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.35;
  margin: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: border-color var(--ease), color var(--ease);
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ——— PWA install: Chrome/Edge Android + Windows/Mac ——— */

/* Chip en topbar (muy visible en PC) */
.install-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(56, 189, 248, 0.12));
  color: var(--text);
  font-weight: 650;
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), border-color var(--ease), filter var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}

.install-chip[hidden] {
  display: none !important;
}

.install-chip:hover {
  border-color: rgba(167, 139, 250, 0.7);
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.install-chip:active {
  transform: scale(0.98);
}

.install-chip svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Sidebar button */
.btn-install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(56, 189, 248, 0.12));
  color: var(--text);
  font-weight: 650;
  font-size: 0.9rem;
  transition: transform var(--ease), border-color var(--ease), filter var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}

.btn-install[hidden] {
  display: none !important;
}

.btn-install:hover {
  border-color: rgba(167, 139, 250, 0.65);
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-install:active {
  transform: scale(0.98);
}

.btn-install svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Banner flotante */
.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  width: min(540px, calc(100vw - 24px));
  animation: fadeUp 0.3s ease both;
  pointer-events: none;
}

.install-banner[hidden] {
  display: none !important;
}

.install-banner-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--bg-elevated) 94%, #8b5cf6 6%),
    var(--bg-elevated)
  );
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.install-banner-ico img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: block;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.install-banner-text p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.install-banner-cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  min-width: 120px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #6366f1 50%, #0ea5e9);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
  transition: filter var(--ease), transform var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}

.install-banner-cta:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.install-banner-cta:active {
  transform: scale(0.97);
}

.install-banner-cta svg {
  flex-shrink: 0;
}

.install-banner-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  transition: background var(--ease), color var(--ease);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.install-banner-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Escritorio: banner un poco más a la derecha del centro de la app */
@media (min-width: 901px) {
  .install-banner {
    left: auto;
    right: 24px;
    transform: none;
    width: min(420px, calc(100vw - 320px));
    bottom: 24px;
  }

  .install-banner-cta {
    min-width: 140px;
  }
}

/* Móvil */
@media (max-width: 900px) {
  .install-chip span {
    /* En pantallas muy estrechas el chip puede acortarse */
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .install-banner {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .install-banner-inner {
    position: relative;
    flex-wrap: wrap;
    padding: 14px;
    padding-right: 44px;
    gap: 10px;
  }

  .install-banner-text {
    flex: 1 1 calc(100% - 60px);
    min-width: 140px;
  }

  .install-banner-cta {
    flex: 1 1 auto;
    min-width: 140px;
  }

  .install-banner-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 420px) {
  .install-chip span {
    display: none;
  }

  .install-chip {
    min-width: 40px;
    padding: 8px;
    justify-content: center;
  }
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: transparent;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  /* El dropdown del selector debe quedar por encima del chat */
  position: relative;
  z-index: 50;
  overflow: visible;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background var(--ease);
}

.menu-btn:hover {
  background: var(--surface-2);
}

.menu-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-title h1 {
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.badge.accent {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.35);
  background: var(--accent-soft);
}

html[data-theme="light"] .badge.accent {
  color: #5b21b6;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 51;
  overflow: visible;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  transition: color var(--ease), border-color var(--ease), background var(--ease), transform var(--ease);
}

.icon-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.active {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.4);
  background: var(--accent-soft);
}

/* ——— Model picker ——— */
.model-picker {
  position: relative;
  z-index: 60;
}

.model-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(280px, 46vw);
  padding: 6px 10px 6px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.model-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.model-picker.open .model-trigger {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.model-trigger-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 750;
  color: #fff;
  flex-shrink: 0;
  background: var(--avatar-g);
}

.model-trigger-ico.accent-grok,
.model-option-ico.accent-grok {
  background: linear-gradient(145deg, #c4b5fd, #8b5cf6 50%, #38bdf8);
}
.model-trigger-ico.accent-kimi,
.model-option-ico.accent-kimi {
  background: linear-gradient(145deg, #5eead4, #14b8a6 45%, #0d9488);
}
.model-trigger-ico.accent-deepseek,
.model-option-ico.accent-deepseek {
  background: linear-gradient(145deg, #93c5fd, #3b82f6 45%, #1d4ed8);
}
.model-trigger-ico.accent-openai,
.model-option-ico.accent-openai {
  background: linear-gradient(145deg, #86efac, #22c55e 50%, #15803d);
}
.model-trigger-ico.accent-google,
.model-option-ico.accent-google {
  background: linear-gradient(145deg, #fde68a, #f59e0b 45%, #ea580c);
}
.model-trigger-ico.accent-qwen,
.model-option-ico.accent-qwen {
  background: linear-gradient(145deg, #a5b4fc, #6366f1 45%, #4338ca);
}
.model-trigger-ico.accent-mistral,
.model-option-ico.accent-mistral {
  background: linear-gradient(145deg, #fdba74, #f97316 45%, #c2410c);
}
.model-trigger-ico.accent-nvidia,
.model-option-ico.accent-nvidia {
  background: linear-gradient(145deg, #86efac, #16a34a 40%, #14532d);
}
.model-trigger-ico.accent-zai,
.model-option-ico.accent-zai {
  background: linear-gradient(145deg, #f9a8d4, #ec4899 45%, #be185d);
}
.model-trigger-ico.accent-minimax,
.model-option-ico.accent-minimax {
  background: linear-gradient(145deg, #c4b5fd, #7c3aed 45%, #5b21b6);
}
.model-trigger-ico.accent-writer,
.model-option-ico.accent-writer {
  background: linear-gradient(145deg, #fda4af, #f43f5e 45%, #be123c);
}
.model-trigger-ico.accent-default,
.model-option-ico.accent-default {
  background: linear-gradient(145deg, #94a3b8, #64748b);
}
.model-trigger-ico.accent-anthropic,
.model-option-ico.accent-anthropic {
  background: linear-gradient(135deg, #d4a27f, #c96442);
  color: #1a120b;
}
.model-trigger-ico.accent-workers,
.model-option-ico.accent-workers {
  background: linear-gradient(145deg, #fbbf24, #f97316 40%, #ea580c);
}

.model-trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
  text-align: left;
  gap: 0;
}

.model-trigger-name {
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.model-trigger-provider {
  display: none !important;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.model-chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform var(--ease);
}

.model-picker.open .model-chevron {
  transform: rotate(180deg);
}

.model-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, calc(100vw - 20px));
  max-height: min(560px, 75dvh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
  animation: fadeUp 0.18s ease both;
  z-index: 100;
  pointer-events: auto;
}

.model-menu[hidden],
.model-menu[aria-hidden="true"] {
  display: none !important;
  pointer-events: none;
}

.model-picker.open .model-menu {
  display: flex !important;
}

.model-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.model-menu-count {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.9;
}

.model-search-wrap {
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}

.model-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.model-search:focus {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.model-menu-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  flex: 1;
}

.model-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 6px 0 2px;
  padding: 6px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(6px);
}

.model-menu-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.model-option {
  display: grid;
  grid-template-columns: 40px 1fr 20px;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: background var(--ease), border-color var(--ease);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.model-option:hover {
  background: var(--accent-soft);
  border-color: rgba(167, 139, 250, 0.2);
}

.model-option.selected {
  background: var(--accent-soft);
  border-color: rgba(167, 139, 250, 0.35);
}

.model-option-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 750;
  color: #fff;
  flex-shrink: 0;
}

.model-option-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-option-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.model-option-name {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.model-option-badge {
  display: none !important;
  font-size: 0.65rem;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.model-option-desc {
  display: none !important;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
}

.model-option-check {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  line-height: 1.4;
  padding-top: 2px;
}

@media (max-width: 560px) {
  .model-trigger-text {
    display: none;
  }

  .model-trigger {
    padding: 6px;
    max-width: none;
  }

  .model-chevron {
    display: none;
  }

  .model-menu {
    right: -8px;
    width: min(340px, calc(100vw - 16px));
  }
}

/* Chat area */
.chat-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-area[hidden] {
  display: none !important;
}

/* ——— Chat de voz (Live) ——— */
.live-panel {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

.live-panel[hidden] {
  display: none !important;
}

.live-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  flex-shrink: 0;
}

.live-top-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.live-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 16px 32px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.live-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0;
  text-align: center;
}

.live-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 650;
  font-size: 0.95rem;
}

.live-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.live-status-dot[data-state="connecting"] {
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
  animation: livePulse 1s ease-in-out infinite;
}

.live-status-dot[data-state="listening"] {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2);
}

.live-status-dot[data-state="speaking"] {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25);
  animation: livePulse 0.8s ease-in-out infinite;
}

.live-status-dot[data-state="error"] {
  background: var(--danger);
}

.live-status-dot[data-state="mic"] {
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
}

.live-status-dot[data-state="ended"] {
  background: var(--muted);
}

.live-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  text-align: center;
}

.live-error[hidden] {
  display: none !important;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

.live-level {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.live-level-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.live-level-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 60ms linear;
}

.live-level-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.live-start-btn {
  min-width: 160px;
  border-radius: 999px !important;
}

.live-start-btn.live-active {
  background: var(--danger) !important;
  box-shadow: 0 8px 24px rgba(248, 113, 113, 0.25) !important;
}

.live-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

.live-transcript {
  flex: 1;
  min-height: 140px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.live-transcript-empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px;
}

.live-bubble {
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.live-bubble.user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--text);
}

.live-bubble.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.shell.live-open .model-picker {
  opacity: 0.45;
  pointer-events: none;
}

/* ——— Gemini Chat Flash (panel dedicado) ——— */
.gflash-panel {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

.gflash-panel[hidden] {
  display: none !important;
}

.gflash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 70%, var(--bg-elevated));
  backdrop-filter: var(--glass);
  flex-shrink: 0;
}

.gflash-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gflash-top-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.gflash-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gflash-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.gflash-messages::-webkit-scrollbar {
  width: 8px;
}
.gflash-messages::-webkit-scrollbar-track {
  background: transparent;
}
.gflash-messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}
.gflash-messages::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

.gflash-messages-inner {
  max-width: var(--composer-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--chat-gap);
  min-height: 100%;
  width: 100%;
}

.gflash-empty {
  margin: auto;
  text-align: center;
  max-width: 380px;
  padding: 24px;
  color: var(--muted);
}

.gflash-empty h3 {
  color: var(--text);
  font-size: 1.15rem;
  margin: 12px 0 8px;
}

.gflash-empty p {
  font-size: 0.9rem;
  line-height: 1.45;
}

.gflash-composer-wrap {
  flex-shrink: 0;
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--bg) 88%, transparent) 28%,
    var(--bg) 100%
  );
}

.gflash-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gflash-toolbar {
  width: 100%;
}

.gflash-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.gflash-sources-title {
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gflash-sources ul {
  margin: 0;
  padding-left: 1.1em;
  line-height: 1.45;
}

.gflash-sources a {
  color: var(--accent-hover);
  text-decoration: none;
  word-break: break-all;
}

.gflash-sources a:hover {
  text-decoration: underline;
}

.gflash-code-block {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}

.gflash-code-block summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
}

.gflash-code-block summary::-webkit-details-marker {
  display: none;
}

.gflash-code-block[open] summary {
  border-bottom: 1px solid var(--border);
}

.gflash-code-block pre {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.gflash-code-result {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.gflash-pending {
  max-width: var(--composer-max);
  margin: 0 auto 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gflash-pending[hidden] {
  display: none !important;
}

.gflash-pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
}

.gflash-pending-item img,
.gflash-pending-item video {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  flex-shrink: 0;
}

.gflash-pending-item .gflash-file-ico {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.gflash-pending-item .meta {
  min-width: 0;
  flex: 1;
}

.gflash-pending-item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.gflash-pending-item .rm {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.gflash-pending-item .rm:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.gflash-composer {
  max-width: var(--composer-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--composer-radius);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.gflash-composer:focus-within {
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.gflash-composer textarea {
  width: 100%;
  flex: none;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  max-height: 140px;
  min-height: 44px;
  padding: 10px 4px 4px;
}

.gflash-composer .tool-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color var(--ease), background var(--ease);
}

.gflash-composer .tool-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
}

.gflash-composer .tool-btn svg {
  width: 18px;
  height: 18px;
}

.gflash-hint {
  max-width: var(--composer-max);
  margin: 8px auto 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.gflash-msg-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.gflash-msg-att {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.75rem;
  max-width: 220px;
}

.gflash-msg-att img,
.gflash-msg-att video {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}

.gflash-msg-att .gflash-file-ico {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
}

.gflash-msg-att .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.shell.gflash-open .model-picker {
  opacity: 0.45;
  pointer-events: none;
}

/* ——— Gemini Omni Flash (panel dedicado, video) ——— */
.gomni-panel {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

.gomni-panel[hidden] {
  display: none !important;
}

.gomni-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: var(--glass);
  flex-shrink: 0;
}

.gomni-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.gomni-top-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.gomni-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gomni-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: var(--composer-max);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Studio layout: results scrolleable + composer fijo abajo */
.gomni-body--studio {
  max-width: none;
  padding: 0;
  gap: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.gomni-results-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.gomni-results-area::-webkit-scrollbar {
  width: 10px;
}
.gomni-results-area::-webkit-scrollbar-track {
  background: transparent;
}
.gomni-results-area::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.gomni-results-area::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
  background-clip: padding-box;
  border: 2px solid transparent;
}

.gomni-form-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.gomni-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .gomni-row {
    grid-template-columns: 1fr;
  }
}

.gomni-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  flex: 0 0 auto;
  padding-bottom: 8px;
}

/* Turnos tipo chat (como Imagine) */
.gomni-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(720px, 100%);
  width: 100%;
  animation: fadeUp 0.25s ease both;
}

.gomni-row.user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: var(--bubble-user-max);
}

.gomni-row.assistant {
  align-self: flex-start;
  align-items: flex-start;
  max-width: min(640px, 100%);
}

.gomni-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.gomni-row.user .gomni-bubble {
  background: var(--user);
  color: #fff;
  border-radius: var(--bubble-radius);
  border-bottom-right-radius: 8px;
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.22);
  max-width: 100%;
}

.gomni-row.assistant .gomni-card {
  width: 100%;
  max-width: 100%;
}

/* Composer fijo abajo del panel */
.gomni-composer-wrap {
  flex-shrink: 0;
  border-top: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--bg) 85%, transparent) 32%,
    var(--bg) 100%
  );
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}

.gomni-composer-wrap.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-soft);
}

.gomni-ref-count {
  max-width: 760px;
  margin: 0 auto 8px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  border: 0;
  padding: 0;
}

.gomni-composer {
  max-width: var(--composer-max);
  margin: 0 auto;
  padding: 10px 12px 10px;
  border-radius: var(--composer-radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: var(--glass);
  box-shadow: var(--shadow-sm), 0 8px 28px rgba(8, 4, 20, 0.22);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gomni-composer:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.gomni-composer textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 6px 4px 2px;
  min-height: 44px;
  max-height: 140px;
  outline: none;
  box-shadow: none !important;
  line-height: 1.4;
}

.gomni-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  overflow: visible;
  padding-bottom: 2px;
}

.gomni-chip {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.gomni-chip:hover:not(:disabled):not(.is-disabled) {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--accent-soft);
}

.gomni-chip.active,
.gomni-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.25);
}

.gomni-chip:disabled,
.gomni-chip.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gomni-chip-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
}

/* Chip con <select> nativo superpuesto (dropdown real del SO) */
.gomni-select-chip {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.gomni-select-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--accent-soft);
}

.gomni-select-chip:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.25);
  color: var(--text);
}

.gomni-select-chip.is-disabled,
.gomni-select-chip:has(select:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.gomni-select-chip-text {
  pointer-events: none;
}

.gomni-select-chevron {
  pointer-events: none;
  font-size: 0.7rem;
  opacity: 0.75;
}

.gomni-native-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font: inherit;
  border: 0;
  margin: 0;
  padding: 0;
  /* iOS/Android: el tap abre el picker nativo */
  -webkit-appearance: menulist-button;
  appearance: menulist-button;
}

.gomni-settings-note {
  max-width: 760px;
  margin: 6px auto 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.gomni-settings-note[hidden] {
  display: none !important;
}

.gomni-send {
  appearance: none;
  flex: 0 0 auto;
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--user);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-purple);
  transition: transform var(--ease), opacity var(--ease);
}

.gomni-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.gomni-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.gomni-send.is-loading {
  opacity: 0.7;
}

.gomni-composer-wrap .img-status {
  max-width: 760px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 0.82rem;
}

.gomni-body--studio .gomni-ref-list {
  max-width: 760px;
  margin: 0 auto 10px;
  justify-content: center;
}

@media (max-width: 640px) {
  .gomni-chip {
    padding: 6px 10px;
    font-size: 0.76rem;
  }
}

.gomni-empty {
  text-align: center;
  max-width: 440px;
  margin: 28px auto;
  padding: 24px 16px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.gomni-empty .empty-icon {
  font-size: 1.6rem;
  line-height: 1;
  opacity: 0.85;
  margin: 0;
}

.gomni-empty h3 {
  color: var(--text);
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gomni-empty-desc,
.gomni-empty p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  max-width: 36em;
  border: 0;
  padding: 0;
}

.gomni-empty-count {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  padding: 0;
  border: 0;
}

/* Card de resultado de video — video primero, sin huecos */
.gomni-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  flex-shrink: 0;
  width: 100%;
}

.gomni-card-media {
  position: relative;
  width: 100%;
  /* default landscape; JS setea --gomni-ar */
  aspect-ratio: var(--gomni-ar, 16 / 9);
  max-height: min(52vh, 420px);
  min-height: 180px;
  background: #0a0612;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}

/* 9:16 / 2:3: limitar alto para no comer toda la pantalla */
.gomni-card-media.is-portrait {
  max-height: min(58vh, 520px);
  min-height: 220px;
  margin: 0 auto;
  /* en portrait no forzar full width excesivo */
  max-width: min(100%, 360px);
  border-radius: 16px;
  margin-top: 10px;
}

.gomni-card-media.is-square {
  max-height: min(48vh, 400px);
}

.gomni-card video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0612;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
}

.gomni-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  min-height: 0;
}

.gomni-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  padding: 0;
  min-height: 0;
}

.gomni-card-meta {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.3;
  margin: 0;
  padding: 0;
}

.gomni-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.gomni-pill-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}

.gomni-pill-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

.gomni-pill-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gomni-pill-btn.primary {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.gomni-card-error-title {
  font-weight: 700;
  color: var(--danger);
  font-size: 0.95rem;
  padding: 12px 12px 0;
}

.gomni-card-error-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  padding: 6px 12px 0;
}

.gomni-error-dismiss {
  align-self: flex-start;
  margin: 10px 12px 12px;
}

/* Skeleton generando — misma proporción que el video */
.gomni-card.is-loading {
  min-height: 0;
}

.gomni-card.is-loading .gomni-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gomni-skel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.gomni-skel-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: gomni-spin 0.8s linear infinite;
}

@keyframes gomni-spin {
  to {
    transform: rotate(360deg);
  }
}

.gomni-skel-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@media (max-width: 520px) {
  .gomni-card-actions {
    grid-template-columns: 1fr;
  }
}

.gomni-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.gomni-admit {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--muted);
}

.gomni-admit-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.gomni-admit ul {
  margin: 0 0 8px;
  padding-left: 1.1em;
  line-height: 1.45;
}

.gomni-admit li {
  margin-bottom: 3px;
}

.gomni-admit strong {
  color: var(--text-secondary);
}

.gomni-note {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.9;
}

.gomni-refs-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.gomni-dropzone {
  position: relative;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 16px 12px;
  min-height: 72px;
  background: var(--surface-2);
  text-align: center;
  transition: border-color var(--ease), background var(--ease);
  cursor: pointer;
}

.gomni-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.gomni-dropzone.is-full {
  opacity: 0.65;
  cursor: not-allowed;
}

/* input real: oculto; se abre vía botón / dropzone click */
.gomni-dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.gomni-drop-hint {
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.gomni-add-btn {
  pointer-events: auto;
  display: inline;
  border: 0;
  background: none;
  color: var(--accent-hover);
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.gomni-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: none;
}

.gomni-drop-sub {
  font-size: 0.75rem;
  opacity: 0.85;
}

.gomni-ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  min-height: 0;
}

.gomni-ref-list:empty {
  display: none;
}

.gomni-ref-item {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
}

.gomni-ref-item img,
.gomni-ref-item video {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  flex-shrink: 0;
}

.gomni-ref-item .meta {
  min-width: 0;
  flex: 1;
}

.gomni-ref-item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  color: var(--text);
}

.gomni-ref-item .rm {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.gomni-ref-item .rm:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.shell.gomni-open .model-picker {
  opacity: 0.45;
  pointer-events: none;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 16px 14px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.messages::-webkit-scrollbar {
  width: 8px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}
.messages::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

.messages-inner {
  max-width: var(--composer-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--chat-gap);
  min-height: 100%;
  width: 100%;
  padding-bottom: 4px;
}

/* Empty state */
.empty {
  position: relative;
  margin: auto;
  max-width: 580px;
  text-align: center;
  padding: 40px 16px 52px;
  animation: fadeUp 0.4s ease both;
}

.empty-glow {
  position: absolute;
  top: 10%;
  left: 50%;
  width: 220px;
  height: 220px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35), transparent 68%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}

.empty-icon {
  position: relative;
  z-index: 1;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 24px;
  background: var(--avatar-g);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow:
    0 16px 48px rgba(139, 92, 246, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.empty-icon svg {
  width: 34px;
  height: 34px;
}

.empty h2 {
  position: relative;
  z-index: 1;
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 750;
  letter-spacing: -0.035em;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #fff 20%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.empty p {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 0.94rem;
  margin-bottom: 24px;
  line-height: 1.55;
  max-width: 42ch;
  margin-left: auto;
  margin-right: auto;
}

.empty .chips {
  position: relative;
  z-index: 1;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-secondary);
  font-size: 0.82rem;
  transition: border-color var(--ease), background var(--ease), color var(--ease), transform var(--ease);
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  border-color: rgba(139, 92, 246, 0.45);
  background: var(--accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.empty-privacy {
  position: relative;
  z-index: 1;
  margin-top: 26px;
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.chip {
  backdrop-filter: blur(8px);
}

.composer {
  position: relative;
}

.composer::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.35), transparent 40%, rgba(56, 189, 248, 0.25));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.55;
}

/* Messages — patrón unificado (chat limpio, marca ChatFull) */
.msg-row {
  display: flex;
  gap: 10px;
  animation: fadeUp 0.28s ease both;
  max-width: 100%;
  width: 100%;
}

.msg-row.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  flex-shrink: 0;
  display: none; /* layout limpio tipo chat moderno */
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
}

.avatar.grok {
  background: var(--avatar-g);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.avatar.user {
  background: linear-gradient(135deg, #64748b, #475569);
}

.msg-col {
  min-width: 0;
  max-width: min(100%, 760px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-row.user .msg-col {
  align-items: flex-end;
  max-width: var(--bubble-user-max);
}

.msg-row.assistant .msg-col {
  max-width: min(100%, 760px);
  width: 100%;
  align-items: flex-start;
}

.msg-meta {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 4px;
}

.msg-row.user .msg-meta {
  flex-direction: row-reverse;
}

.bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: var(--bubble-radius);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-shadow: none;
}

/* Asistente: texto limpio, casi sin caja */
.msg-row.assistant .bubble {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 2px 2px 4px;
  box-shadow: none;
  width: 100%;
}

/* Usuario: pill a la derecha */
.msg-row.user .bubble {
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 8px;
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.22);
  max-width: 100%;
}

/* Texto plano (user / fallback) */
.bubble .body.plain {
  white-space: pre-wrap;
}

.bubble .body p + p {
  margin-top: 0.65em;
}

/* ——— Markdown prose (assistant, estilo grok/docs) ——— */
.md {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: anywhere;
}

.md > *:first-child {
  margin-top: 0 !important;
}

.md > *:last-child {
  margin-bottom: 0 !important;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin: 1.15em 0 0.45em;
}

.md h1 { font-size: 1.28rem; }
.md h2 { font-size: 1.12rem; margin-top: 1.25em; }
.md h3 { font-size: 1.02rem; font-weight: 650; }

.md p {
  margin: 0.55em 0;
  line-height: 1.65;
  color: var(--text-secondary);
}

.md strong {
  color: var(--text);
  font-weight: 650;
}

.md em {
  font-style: italic;
}

.md del {
  opacity: 0.75;
}

.md ul,
.md ol {
  margin: 0.55em 0;
  padding-left: 1.35em;
  color: var(--text-secondary);
}

.md li {
  margin: 0.28em 0;
  padding-left: 0.15em;
}

.md li > ul,
.md li > ol {
  margin: 0.25em 0;
}

.md blockquote {
  margin: 0.75em 0;
  padding: 0.55em 0.9em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  color: var(--text-secondary);
}

.md blockquote p {
  margin: 0.3em 0;
}

.md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.1em 0;
}

.md a {
  color: #a78bfa;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html[data-theme="light"] .md a {
  color: #5b21b6;
}

.md a:hover {
  color: var(--accent-2);
}

/* Tablas */
.md .table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.85em 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  -webkit-overflow-scrolling: touch;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 420px;
}

.md thead th {
  text-align: left;
  font-weight: 650;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-solid) 70%, var(--accent-soft));
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.md tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.md tbody tr:nth-child(even) td {
  background: rgba(127, 127, 160, 0.06);
}

.md tbody tr:last-child td {
  border-bottom: none;
}

/* Código */
.md :not(pre) > code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: rgba(127, 127, 160, 0.16);
  color: var(--text);
}

.md .code-block {
  position: relative;
  margin: 0.85em 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  overflow: hidden;
}

.md .code-block .code-lang {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  pointer-events: none;
}

.md .code-block .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
  border: 1px solid var(--border);
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}

.md .code-block .code-copy:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.md .code-block pre {
  margin: 0;
  padding: 36px 14px 14px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre;
  background: transparent;
  border: none;
}

.md .code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: inherit;
  background: none;
  padding: 0;
  color: var(--text);
}

/* Chips de opciones al final de la respuesta */
.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 4px;
}

.choice-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.35);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 550;
  text-align: left;
  transition: transform var(--ease), border-color var(--ease), filter var(--ease);
  max-width: 100%;
}

.choice-chip:hover:not(:disabled) {
  border-color: rgba(139, 92, 246, 0.65);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.choice-chip:disabled {
  opacity: 0.5;
}

/* User bubble code (simple) */
.msg-row.user .bubble pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow-x: auto;
  font-size: 0.82rem;
  white-space: pre;
}

.msg-row.user .bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.msg-row.user .bubble :not(pre) > code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attach-preview img.thumb {
  max-width: 160px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: zoom-in;
  transition: transform var(--ease);
}

.attach-preview img.thumb:hover {
  transform: scale(1.02);
}

.attach-chip {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.msg-row.assistant .attach-chip {
  background: var(--surface-2);
  border-color: var(--border);
}

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
  padding: 0 2px;
}

.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions {
  opacity: 1;
  pointer-events: auto;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.msg-action:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.msg-action svg {
  width: 13px;
  height: 13px;
}

/* Error / system cards */
.card-error {
  max-width: var(--composer-max);
  margin: 0 auto;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.45;
  animation: fadeUp 0.28s ease both;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.card-error svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.card-image {
  max-width: var(--composer-max);
  margin: 0 auto;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.28s ease both;
}

.card-image h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.card-image img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 12px;
  display: block;
  cursor: zoom-in;
  border: 1px solid var(--border);
}

.card-image .note {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeUp 0.2s ease both;
}

.typing .bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 120px;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  display: block;
  animation: bounce 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

/* Composer — barra redondeada fija abajo */
.composer-wrap {
  flex-shrink: 0;
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--bg) 85%, transparent) 32%,
    var(--bg) 100%
  );
}

.composer {
  max-width: var(--composer-max);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--composer-radius);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow-sm), 0 8px 28px rgba(8, 4, 20, 0.28);
  padding: 10px 12px 8px;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.composer:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.pending:empty {
  display: none;
}

.pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 0.78rem;
  max-width: 100%;
}

.pending-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.pending-item .meta {
  min-width: 0;
  color: var(--muted);
}

.pending-item .name {
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-item .rm {
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
}

.pending-item .rm:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

#input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 8px;
  min-height: 44px;
  max-height: 160px;
  line-height: 1.45;
  outline: none;
  box-shadow: none !important;
}

#input::placeholder {
  color: var(--muted);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
}

.tool-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
}

.tool-btn.active {
  background: var(--accent-soft);
  color: #c4b5fd;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--user);
  box-shadow: var(--shadow-purple);
  transition: filter var(--ease), transform var(--ease), opacity var(--ease);
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.3);
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 2px;
  font-size: 0.7rem;
  color: var(--muted);
}

.file-count {
  color: var(--muted);
}

#fileInput {
  display: none;
}

/* Image drawer */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Tool pages (estudios) — full width bajo top nav */
.drawer.tool-page {
  position: fixed;
  top: var(--gtn-h);
  left: 0;
  right: 0;
  z-index: 45;
  width: 100%;
  height: calc(100dvh - var(--gtn-h));
  background: var(--bg);
  border-left: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.drawer.tool-page.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* fallback drawer (si no tool-page) */
.drawer:not(.tool-page) {
  position: fixed;
  top: var(--gtn-h);
  right: 0;
  z-index: 45;
  width: min(420px, 100%);
  height: calc(100dvh - var(--gtn-h));
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer:not(.tool-page).open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.drawer-header h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 750;
  letter-spacing: -0.03em;
}

.drawer-header p {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field textarea,
.field select,
.field-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  padding: 12px 14px;
  transition: border-color var(--ease);
  font: inherit;
}

.field-input:focus {
  border-color: rgba(167, 139, 250, 0.5);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.field-hint {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.req {
  color: var(--danger);
}

/* Toggles estudio musical */
.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  transition: border-color var(--ease), background var(--ease);
}

.toggle:hover {
  border-color: var(--border-strong);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background var(--ease), border-color var(--ease);
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform var(--ease);
}

.toggle input:checked + .toggle-ui {
  background: linear-gradient(135deg, #8b5cf6, #0ea5e9);
  border-color: transparent;
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.toggle input:disabled + .toggle-ui {
  opacity: 0.5;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toggle-text strong {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text);
}

.toggle-text small {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Galería de canciones */
.music-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.music-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
}

.music-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.35;
}

.music-player {
  width: 100%;
  display: block;
  margin-bottom: 10px;
  border-radius: 8px;
}

.music-card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: border-color var(--ease), color var(--ease);
}

.music-card-actions a:hover {
  border-color: var(--border-strong);
  color: var(--accent);
}

.music-status {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ——— Imagine (selector de modelo siempre visible) ——— */
.imagine-panel {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

.imagine-panel[hidden] {
  display: none !important;
}

.main {
  position: relative;
}

.imagine-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: var(--glass);
  flex-shrink: 0;
}

.imagine-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.imagine-top-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.imagine-model-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  background: color-mix(in srgb, var(--accent, #7c5cff) 18%, var(--surface-solid, #1a1a22));
  border: 1px solid color-mix(in srgb, var(--accent, #7c5cff) 45%, var(--border));
  white-space: nowrap;
}

.imagine-guidance {
  width: 72px;
}

.imagine-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Barra prominente del selector de modelo — no ocultar */
.imagine-model-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent, #7c5cff) 10%, var(--bg-elevated, #14141a));
  flex-shrink: 0;
  z-index: 2;
}

.imagine-model-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.imagine-model-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.imagine-model-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-solid, #1a1a22);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
  line-height: 1.25;
  min-height: 46px;
}

.imagine-model-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent, #7c5cff) 55%, var(--border));
}

.imagine-model-btn.active {
  border-color: var(--accent, #7c5cff);
  background: color-mix(in srgb, var(--accent, #7c5cff) 22%, var(--surface-solid, #1a1a22));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #7c5cff) 40%, transparent);
  color: var(--text);
}

.imagine-model-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Select nativo de respaldo (siempre legible) */
.imagine-model-select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 48px;
  cursor: pointer;
}

/* En pantallas anchas priorizar botones; en muy angostas el select también queda */
@media (min-width: 480px) {
  .imagine-model-select {
    /* se mantiene visible como alternativa accesible compacta debajo de botones */
  }
}

.imagine-options-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.imagine-opts-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.imagine-opts-row[hidden] {
  display: none !important;
}

.imagine-opts-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.imagine-size {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.82rem;
  min-height: 38px;
}

.imagine-custom-size {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.imagine-custom-size[hidden] {
  display: none !important;
}

.imagine-dim {
  width: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-size: 0.82rem;
}

.imagine-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: var(--chat-gap);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.imagine-messages::-webkit-scrollbar {
  width: 8px;
}
.imagine-messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}

.imagine-empty {
  margin: auto;
  text-align: center;
  max-width: 360px;
  padding: 24px;
  color: var(--muted);
}

.imagine-empty h3 {
  color: var(--text);
  font-size: 1.15rem;
  margin: 12px 0 8px;
}

.imagine-empty p {
  font-size: 0.9rem;
  line-height: 1.45;
}

.imagine-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(720px, 100%);
  animation: fadeUp 0.25s ease both;
  width: 100%;
}

.imagine-row.user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: var(--bubble-user-max);
}

.imagine-row.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.imagine-bubble {
  padding: 12px 16px;
  border-radius: var(--bubble-radius);
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.imagine-row.user .imagine-bubble {
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 8px;
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.22);
}

.imagine-row.assistant .imagine-bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 2px 0;
  color: var(--text-secondary);
}

/* override residual box if any */
.imagine-row.assistant .imagine-bubble.legacy-box {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  color: var(--text-secondary);
}

.imagine-ref {
  max-width: 160px;
  max-height: 120px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.imagine-out-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.imagine-out-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  max-width: min(360px, 100%);
  box-shadow: var(--shadow-sm);
}

.imagine-out-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #0a0a0c;
  cursor: zoom-in;
}

.imagine-out-actions {
  display: flex;
  gap: 8px;
  padding: 8px;
}

.imagine-out-actions a,
.imagine-out-actions button {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.imagine-out-actions a:hover,
.imagine-out-actions button:hover {
  border-color: var(--border-strong);
}

.imagine-composer-wrap {
  flex-shrink: 0;
  border-top: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--bg) 85%, transparent) 32%,
    var(--bg) 100%
  );
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}

.imagine-pending-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  max-width: var(--composer-max);
  margin-left: auto;
  margin-right: auto;
}

.imagine-pending-list[hidden] {
  display: none !important;
}

.imagine-pending-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-solid);
}

.imagine-pending-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}

.imagine-pending-rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  border: none;
}

.imagine-pending-rm:hover {
  background: rgba(248, 113, 113, 0.9);
}

.imagine-pending-rm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.imagine-ref-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 100%;
}

.imagine-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: var(--composer-max);
  margin: 0 auto;
  padding: 10px 12px;
  border-radius: var(--composer-radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: var(--glass);
  box-shadow: var(--shadow-sm), 0 8px 28px rgba(8, 4, 20, 0.22);
}

.imagine-composer:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.imagine-composer textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 6px;
  min-height: 44px;
  max-height: 140px;
  outline: none;
  box-shadow: none !important;
}

.imagine-hint {
  max-width: 720px;
  margin: 6px auto 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

/* Galería de video */
.video-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.video-player {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 10px;
  background: #000;
  margin-bottom: 8px;
}

.video-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: -4px 0 8px;
}

.video-notice {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 10px;
}

.video-ref-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
}

.video-ref-preview[hidden] {
  display: none !important;
}

.music-live-help {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 8px;
}

.music-live-status-row {
  justify-content: flex-start;
  margin: 4px 0;
}

.music-live-actions {
  justify-content: flex-start;
}

.music-live-actions .btn-cta {
  min-width: 120px;
}

#musicLiveControls .field input[type="text"],
#musicLiveControls .field input[type="number"] {
  width: 100%;
  padding: 10px 12px;
}

.music-lyrics {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-solid, #1a1a22) 90%, #000);
  border: 1px solid var(--border);
  color: var(--text-secondary, var(--muted));
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  font-family: inherit;
}

.video-ref-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

#videoImageFile {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
}

.field textarea:focus,
.field select:focus {
  border-color: rgba(139, 92, 246, 0.5);
}

.btn-cta {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-pill);
  font-weight: 650;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-purple);
  transition: background var(--ease), transform var(--ease);
}

.btn-cta:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.img-status {
  font-size: 0.84rem;
  color: var(--muted);
  min-height: 1.25em;
  line-height: 1.4;
}

.img-status.error { color: var(--danger); }
.img-status.ok { color: var(--ok); }

.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gallery-item {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: zoom-in;
  background: #000;
}

.gallery-item .actions {
  padding: 8px;
}

.gallery-item a {
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  transition: color var(--ease), border-color var(--ease);
}

.gallery-item a:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 90dvh;
  border-radius: 12px;
  box-shadow: var(--shadow);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
}

/* Sidebar overlay mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Tool split layout */
.tool-split {
  display: grid !important;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 20px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 20px 28px !important;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.tool-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  align-self: start;
}

.tool-preview {
  min-height: 320px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.tool-preview-placeholder {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.tool-preview-placeholder .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 12px;
  font-size: 1.4rem;
}

.tool-preview-placeholder p {
  font-size: 0.92rem;
}

.tool-preview:has(.music-card),
.tool-preview:has(.video-card),
.tool-preview:has(.gomni-card) {
  /* when results exist */
}

.tool-preview:has(.music-gallery:not(:empty)) .tool-preview-placeholder,
.tool-preview:has(.video-gallery:not(:empty)) .tool-preview-placeholder,
.tool-preview:has(.gomni-results .gomni-card) .tool-preview-placeholder {
  display: none;
}

.mode-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 22px;
  position: relative;
  z-index: 1;
}

.mode-pill {
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.mode-pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

.mode-pill.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-purple);
}

.chat-area.is-empty .composer-wrap {
  /* home: composer más centrado visualmente */
  padding-bottom: 8vh;
}

.composer {
  border-radius: var(--radius-pill) !important;
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}

.send-btn {
  border-radius: var(--radius-pill) !important;
  background: var(--accent) !important;
  box-shadow: var(--shadow-purple) !important;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover) !important;
}

.model-trigger {
  border-radius: var(--radius-pill) !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
}

.topbar-compact {
  min-height: 48px;
  padding: 8px 16px !important;
  background: transparent !important;
  border-bottom: 1px solid transparent !important;
}

.install-chip {
  border-radius: var(--radius-pill) !important;
  background: var(--accent-soft) !important;
  color: var(--accent-hover) !important;
  border: 1px solid var(--border) !important;
}

.field input,
.field select,
.field textarea {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  border-radius: 14px !important;
  color: var(--text) !important;
}

.gomni-body.tool-split {
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 20px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 24px;
  box-sizing: border-box;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.gomni-form-card.tool-controls {
  margin: 0;
  max-width: none;
}

/* Responsive */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: var(--gtn-h);
    left: 0;
    z-index: 40;
    width: min(var(--sidebar-w), 88vw);
    height: calc(100dvh - var(--gtn-h));
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow);
  }

  .shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    top: var(--gtn-h);
  }

  .shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: inline-flex;
  }

  /* Mobile: top nav en dos filas (marca + modos) */
  .global-topnav {
    height: auto;
    min-height: var(--gtn-h);
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 6px;
  }

  .gtn-left {
    order: 1;
  }

  .gtn-right {
    order: 2;
    margin-left: auto;
  }

  .gtn-modes {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    padding: 4px 0 2px;
  }

  .shell {
    /* topnav más alto en mobile por segunda fila */
    --gtn-h: 96px;
  }

  .tool-split,
  .gomni-body.tool-split {
    grid-template-columns: 1fr !important;
  }

  .messages {
    padding: 14px 12px 8px;
  }

  .composer-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }

  .msg-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .gallery {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .empty h2 {
    font-size: 1.25rem;
  }

  .chip {
    font-size: 0.78rem;
    padding: 9px 12px;
  }

  .topbar-title h1 {
    font-size: 0.9rem;
  }

  .gtn-brand strong {
    font-size: 0.95rem;
  }
}

/* ��� Creador web ��� */
.wb-panel {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}
.wb-panel[hidden] { display: none !important; }
.wb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: var(--glass);
  flex-shrink: 0;
}
.wb-top-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.wb-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0;
}
.wb-controls {
  padding: 14px 16px 18px;
  border-right: 1px solid var(--border);
  overflow: auto;
  min-height: 0;
  background: color-mix(in srgb, var(--surface-solid) 55%, transparent);
}
.wb-desc {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.wb-opt {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}
.wb-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.wb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.wb-status {
  min-height: 1.2em;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.wb-status.ok { color: var(--ok); }
.wb-status.error { color: var(--danger); }
.wb-error {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.85rem;
}
.wb-history-wrap { margin-top: 16px; }
.wb-history-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.wb-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}
.wb-history-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 0;
}
.wb-history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.wb-history-item:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}
.wb-history-item.active {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.wb-hist-title {
  font-size: 0.84rem;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wb-hist-time { font-size: 0.72rem; color: var(--muted); }
.wb-result {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.wb-result-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wb-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wb-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.wb-preview-col,
.wb-code-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.wb-preview-col {
  border-right: 1px solid var(--border);
}
.wb-col-label {
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.wb-preview {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  background: #fff;
}
.wb-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wb-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.wb-tab:hover { color: var(--text); background: var(--accent-soft); }
.wb-tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--border-strong);
}
.wb-code-pane {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  background: var(--code-bg);
  color: var(--text-secondary);
  outline: none;
}
.wb-code-pane[hidden] { display: none !important; }
.wb-stitch-note a {
  color: var(--accent-hover);
  text-decoration: underline;
}
@media (max-width: 960px) {
  .wb-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .wb-controls {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
  }
  .wb-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 45%) 1fr;
  }
  .wb-preview-col { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ��� Traducir video ��� */
.vt-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}
.vt-panel[hidden] { display: none !important; }
.vt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 70%, var(--bg-elevated));
  flex-shrink: 0;
}
.vt-top-left h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.vt-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.vt-desc {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 16px;
}
.vt-form { display: flex; flex-direction: column; gap: 14px; }
.vt-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.vt-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.vt-dropzone.is-disabled { opacity: 0.65; pointer-events: none; }
.vt-drop-ico {
  font-size: 1.4rem;
  opacity: 0.7;
  margin-bottom: 6px;
}
.vt-drop-title { font-weight: 700; margin-bottom: 4px; }
.vt-drop-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.vt-file-name {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  word-break: break-all;
}
.vt-local-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  margin: 12px auto 0;
  border-radius: 12px;
  background: #000;
}
.vt-clear { margin-top: 8px; }
.vt-source-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vt-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.vt-or::before,
.vt-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong, var(--border));
  opacity: 0.7;
}
.vt-url-field input[type="url"] {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface-solid, var(--surface));
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.vt-url-field input[type="url"]:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}
.vt-url-field input[type="url"].is-invalid {
  border-color: var(--danger, #f87171);
}
.vt-url-help {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}
.vt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.vt-check-field { display: flex; align-items: flex-end; }
.vt-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  padding-bottom: 8px;
}
.vt-submit { width: 100%; min-height: 44px; font-weight: 700; }
.vt-progress-wrap { margin-top: 16px; }
.vt-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.vt-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #38bdf8));
  transition: width 0.35s ease;
}
.vt-progress-bar.indeterminate {
  width: 40% !important;
  animation: vt-indeterminate 1.2s ease-in-out infinite;
}
@keyframes vt-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}
.vt-progress-text {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.vt-status {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.vt-status.ok { color: var(--success, #34d399); }
.vt-status.busy { color: var(--accent-hover); }
.vt-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-bg, rgba(239, 68, 68, 0.12));
  color: var(--danger, #f87171);
  font-size: 0.9rem;
}
.vt-result-card {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
  box-shadow: var(--shadow-sm);
}
.vt-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.vt-result-meta { font-size: 0.82rem; color: var(--muted); }
.vt-result-video {
  width: 100%;
  max-height: 420px;
  border-radius: 12px;
  background: #000;
}
.vt-result-actions { margin-top: 12px; display: flex; gap: 10px; }
@media (max-width: 640px) {
  .vt-row { grid-template-columns: 1fr; }
}

.vt-cancel {
  width: 100%;
  margin-top: 8px;
  min-height: 40px;
}
.vt-status.error { color: var(--danger, #f87171); }

/* Motor selector Traducir video */
.vt-engine {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin: 0 0 14px;
  display: grid;
  gap: 8px;
  background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
}
.vt-engine legend {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vt-engine-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin: 0;
}
.vt-engine-opt input {
  margin-top: 6px;
  accent-color: var(--accent);
}
.vt-engine-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: border-color var(--ease), background var(--ease);
}
.vt-engine-opt input:checked + .vt-engine-card {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.vt-engine-card strong { font-size: 0.95rem; }
.vt-engine-card small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.vt-engine-opt input:disabled + .vt-engine-card {
  opacity: 0.45;
  cursor: not-allowed;
}
#vtSpeakingRate { width: 100%; }

/* ——— Agentes ——— */
.ag-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 16px 18px 28px;
}
.ag-panel[hidden] { display: none !important; }
.ag-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ag-top-left h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}
.ag-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 42rem;
}
.ag-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ag-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 920px;
}
.ag-section-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
}
.ag-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.ag-card {
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 140px;
}
.ag-card h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.ag-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  flex: 1;
}
.ag-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-hover, var(--accent));
  background: var(--accent-soft, rgba(99, 102, 241, 0.12));
  padding: 2px 8px;
  border-radius: 999px;
}
.ag-badge.custom {
  color: var(--text-secondary, var(--muted));
  background: color-mix(in srgb, var(--border) 50%, transparent);
}
.ag-card-actions { margin-top: auto; }
.ag-card-actions .btn-primary { width: 100%; min-height: 40px; }
.ag-muted { color: var(--muted); font-size: 0.9rem; }
.ag-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger, #f87171) 14%, transparent);
  color: var(--danger, #f87171);
  font-size: 0.9rem;
}
.ag-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ag-hist-item {
  text-align: left;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: inherit;
}
.ag-hist-item:hover {
  border-color: var(--accent);
}
.ag-hist-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ag-hist-meta {
  font-size: 0.78rem;
  color: var(--muted);
}
.ag-hist-snip {
  font-size: 0.84rem;
  color: var(--text-secondary, var(--muted));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ag-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ag-pill.ok { background: color-mix(in srgb, #34d399 22%, transparent); color: #059669; }
.ag-pill.error { background: color-mix(in srgb, #f87171 22%, transparent); color: #dc2626; }
.ag-pill.running { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-hover, var(--accent)); }
.ag-pill.pending { background: color-mix(in srgb, var(--border) 60%, transparent); color: var(--muted); }

.ag-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}
.ag-modal[hidden] { display: none !important; }
.ag-modal-card {
  width: min(520px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  border-radius: 18px;
  background: var(--surface-solid, var(--surface));
  border: 1px solid var(--border-strong, var(--border));
  padding: 16px 18px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.ag-modal-wide { width: min(560px, 100%); }
.ag-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.ag-modal-head h3 { margin: 0; font-size: 1.1rem; }
.ag-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.ag-run-inputs .field,
.ag-new-form .field { margin-bottom: 12px; }
.ag-run-inputs textarea,
.ag-new-form textarea,
.ag-run-inputs input,
.ag-new-form input,
.ag-new-form select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface-solid, var(--surface));
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.ag-steps {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ag-step {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.ag-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.ag-step.running .ag-step-dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.ag-step.ok .ag-step-dot { background: #34d399; }
.ag-step.error .ag-step-dot { background: #f87171; }
.ag-step-st { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.ag-step-err {
  grid-column: 2 / -1;
  font-size: 0.8rem;
  color: var(--danger, #f87171);
}
.ag-result {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.ag-result-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0 0;
  max-height: 280px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--border) 35%, transparent);
}
.ag-run-error {
  margin-top: 10px;
  color: var(--danger, #f87171);
  font-size: 0.9rem;
}
#agRunDone { margin-top: 12px; width: 100%; }

@media (max-width: 640px) {
  .ag-top { flex-direction: column; }
  .ag-top-actions { width: 100%; justify-content: flex-end; }
}

/* ——— Transcribir ——— */
.tr-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 16px 18px 28px;
}
.tr-panel[hidden] { display: none !important; }
.tr-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tr-top-left h2 { margin: 0 0 4px; font-size: 1.35rem; }
.tr-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.tr-body { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.tr-form { display: flex; flex-direction: column; gap: 12px; }
.tr-dropzone {
  border: 1.5px dashed var(--border-strong, var(--border));
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
  cursor: pointer;
}
.tr-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tr-dropzone.is-disabled { opacity: 0.65; pointer-events: none; }
.tr-drop-title { font-weight: 700; margin-bottom: 4px; }
.tr-drop-hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 12px; }
.tr-file-name {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary, var(--muted));
  word-break: break-all;
}
.tr-clear { margin-top: 8px; }
.tr-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tr-or::before,
.tr-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong, var(--border));
  opacity: 0.7;
}
.tr-url-help {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}
.tr-submit { width: 100%; min-height: 44px; font-weight: 700; }
.tr-status { font-size: 0.9rem; min-height: 1.2em; }
.tr-status.ok { color: var(--success, #34d399); }
.tr-status.busy { color: var(--accent-hover, var(--accent)); }
.tr-status.error { color: var(--danger, #f87171); }
.tr-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger, #f87171) 14%, transparent);
  color: var(--danger, #f87171);
  font-size: 0.9rem;
}
.tr-result {
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
}
.tr-result-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tr-result-meta { font-size: 0.8rem; color: var(--muted); }
.tr-result-text {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--border) 28%, transparent);
  color: var(--text);
  padding: 12px;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}
.tr-result-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
