/* ================================================================
   Trumbo — Application Styles
   Base: Pico.css 2 (classless + semantic). This file adds layout,
   cards, modals, and utilities on top. No Tailwind, no build step.
   ================================================================ */

[x-cloak] { display: none !important; }

/* ── Custom properties ─────────────────────────────────────────── */
/* Dark theme only: every page sets <html data-theme="dark"> (Pico's dark
   palette, whatever the OS preference) and native controls follow suit. */
:root {
  color-scheme: dark;
  --trumbo-brand: #e63946;
  --trumbo-muted: var(--pico-muted-color, #8891a4);
  --trumbo-border: var(--pico-card-border-color, #2a3140);
  --trumbo-review-border: #f0b400;
  --trumbo-review-bg: rgba(240, 180, 0, 0.1);
  --trumbo-danger: #e63946;
  --trumbo-radius: 0.5rem;
  --trumbo-nav-height: 5rem;
  --trumbo-transition: 150ms ease;
}

/* ── Top navigation ────────────────────────────────────────────── */
.trumbo-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--pico-background-color, #13171f);
  border-bottom: 1px solid var(--trumbo-border);
  padding-block: 0.5rem;
  display: flex;
  align-items: center;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-block: 0;
}

.nav-brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
}

.brand {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--pico-muted-color);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.nav-logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ── Navigation: user area ─────────────────────────────────────── */
.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 1rem;
}

.nav-link {
  font-size: 0.875rem;
  text-decoration: none;
}

.nav-user {
  font-size: 0.875rem;
  color: var(--trumbo-muted);
}

.nav-btn,
.nav-actions [role="button"] {
  margin: 0;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
}

/* ── Login ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 24rem;
}

.login-card header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

/* ── Users ─────────────────────────────────────────────────────── */
.users-loading {
  text-align: center;
  padding: 2rem;
  color: var(--trumbo-muted);
}

.users-table td { vertical-align: middle; }

.users-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.375rem;
}

.users-actions button {
  margin: 0;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
}

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  vertical-align: middle;
}

.required-mark { color: var(--trumbo-danger); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Page header ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-block: 2rem 1.5rem;
}

.page-header h1 { margin-bottom: 0.25rem; }

.page-header p {
  margin: 0;
  color: var(--trumbo-muted);
  font-size: 0.875rem;
}

.page-header button { margin: 0; }

/* ── Movie grid ────────────────────────────────────────────────── */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* ── Movie card ────────────────────────────────────────────────── */
.movie-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  transition: box-shadow var(--trumbo-transition), transform var(--trumbo-transition);
  margin-bottom: 0;
}

.movie-card:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.11);
  transform: translateY(-2px);
}

.card-link {
  display: block;
  padding: 1.25rem 1.25rem 1rem;
  text-decoration: none;
  color: inherit;
  flex: 1;
}

.card-link:hover { color: inherit; }

.card-title {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--trumbo-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0;
  min-height: 3.9rem;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--trumbo-border);
  margin: 0;
}

.card-actions [role="button"],
.card-actions button {
  flex: 1;
  font-size: 0.8125rem;
  padding: 0.375rem 0.5rem;
  margin: 0;
  text-align: center;
}

/* ── Character grid ────────────────────────────────────────────── */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.character-card {
  padding: 1rem;
  margin-bottom: 0;
}

.character-card .char-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.character-card .char-role {
  font-size: 0.8rem;
  color: var(--trumbo-muted);
  margin-bottom: 0.5rem;
}

.character-card .char-desc {
  font-size: 0.8rem;
  color: var(--trumbo-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.75rem;
  min-height: 2.4rem;
}

.character-card .char-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: none;
}

.character-card .char-actions button {
  flex: 1 1 auto;
  font-size: 0.75rem;
  padding: 0.3rem 0.35rem;
  margin: 0;
  white-space: nowrap;
}

.character-card .char-actions .ai-assist-btn {
  flex-basis: 100%;
}

/* ── Danger button variant ─────────────────────────────────────── */
button.danger,
[role="button"].danger {
  --pico-background-color: var(--trumbo-danger);
  --pico-border-color: var(--trumbo-danger);
  --pico-color: #fff;
}

button.outline.danger,
[role="button"].outline.danger {
  --pico-color: var(--trumbo-danger);
  --pico-border-color: var(--trumbo-danger);
  background: transparent;
}

button.outline.danger:hover {
  background: var(--trumbo-danger);
  color: #fff;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--trumbo-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.empty-state h2 { margin-bottom: 0.5rem; }

.empty-state p { margin-bottom: 0; }

.empty-state button {
  margin-top: 1.25rem;
  display: inline-flex;
}

/* ── Loading skeleton ─────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton-title,
.skeleton-text {
  border-radius: 0.25rem;
  background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

.skeleton-title  { height: 1.25rem; width: 60%; margin-bottom: 0.75rem; }
.skeleton-text   { height: 0.875rem; width: 100%; margin-bottom: 0.45rem; }
.skeleton-text.short { width: 50%; }

/* ── Error banner ─────────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff3f3;
  border: 1px solid #f5c2c2;
  border-radius: var(--trumbo-radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: var(--trumbo-danger);
  font-size: 0.875rem;
}

/* ── Form error ───────────────────────────────────────────────── */
.form-error {
  color: var(--trumbo-danger);
  font-size: 0.875rem;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
}

/* ── Modal overrides ──────────────────────────────────────────── */
dialog {
  width: min(96vw, 1100px);
  max-width: 96vw;
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

dialog article {
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

dialog article.wide {
  /* inherits full width — .wide no longer needed but kept for compatibility */
}

dialog article form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

dialog article header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--trumbo-border);
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

dialog article header h3 { margin: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  border: none;
}

.modal-actions button { margin: 0; }

/* ── Close button ─────────────────────────────────────────────── */
.close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--trumbo-muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  margin: 0;
  width: auto;
  border-radius: 0.25rem;
}

.close-btn:hover {
  color: inherit;
  background: var(--trumbo-border);
}

/* ── Toast notifications ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--trumbo-radius);
  font-size: 0.875rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  color: #fff;
  max-width: 340px;
  pointer-events: auto;
  animation: toast-in 200ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast--success { background: #2d9e5c; }
.toast--error   { background: var(--trumbo-danger); }
.toast--info    { background: #3a86ff; }

/* ── Section tabs (movie detail) ──────────────────────────────── */
.section-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.section-tabs button {
  margin: 0;
  min-width: 9rem;
}

/* ── Section header ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 { margin: 0; }

.section-header button { margin: 0; }

/* ── Movie detail header ──────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--trumbo-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-block: 1.25rem 0.5rem;
}

.back-link:hover { color: inherit; }

.movie-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--trumbo-border);
  margin-bottom: 1.75rem;
}

.movie-detail-header h1 { margin: 0 0 0.375rem; }

.movie-detail-header .movie-meta {
  color: var(--trumbo-muted);
  font-size: 0.9375rem;
  margin: 0;
}

.movie-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  min-width: 0;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.movie-detail-actions button,
.movie-detail-actions [role="button"] {
  margin: 0;
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  white-space: nowrap;
}

/* ── Acts accordion ────────────────────────────────────────────── */
details.act-details {
  margin-bottom: 1rem;
  border: 1px solid var(--trumbo-border);
  border-radius: var(--trumbo-radius);
  overflow: hidden;
}

details.act-details > summary {
  padding: 0.875rem 1rem;
  background: var(--pico-card-background-color, #181c25);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

details.act-details > summary::marker,
details.act-details > summary::-webkit-details-marker { display: none; }

/* Pico draws its own chevron with ::after; we render .summary-chevron instead. */
details.act-details > summary::after { display: none; }

details.act-details > summary .summary-chevron {
  font-size: 0.75rem;
  color: var(--trumbo-muted);
  transition: transform var(--trumbo-transition);
}

details.act-details[open] > summary .summary-chevron {
  transform: rotate(180deg);
}

details.act-details > summary .summary-actions {
  display: flex;
  gap: 0.375rem;
}

details.act-details > summary .summary-actions button {
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  margin: 0;
}

.act-body {
  padding: 1rem;
  border-top: 1px solid var(--trumbo-border);
}

/* ── Scene card ────────────────────────────────────────────────── */
.scene-card {
  margin-bottom: 0.75rem;
  padding: 0.875rem 1rem;
}

.scene-card:last-child { margin-bottom: 0; }

.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.scene-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.scene-actions {
  display: flex;
  gap: 0.375rem;
}

.scene-actions button {
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  margin: 0;
}

.scene-content {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  color: var(--pico-color);
  margin: 0;
  line-height: 1.6;
}

.scene-empty {
  color: var(--trumbo-muted);
  font-size: 0.875rem;
  font-style: italic;
  margin: 0;
}

.add-scene-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--trumbo-border);
}

.add-scene-row button {
  margin: 0;
  font-size: 0.875rem;
  padding: 0.4rem 0.9rem;
}

/* ── Two-column form grid ─────────────────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
}

/* ── AI review state ──────────────────────────────────────────── */
.review-state {
  border: 1px dashed var(--trumbo-review-border);
  background: var(--trumbo-review-bg);
  padding: 0.75rem;
  border-radius: var(--trumbo-radius);
}

.review-state[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

.review-state {
  margin-bottom: var(--pico-spacing);
}

.review-state__label {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.review-state__label span {
  font-weight: 400;
  color: var(--trumbo-muted);
}

.review-state input { margin-bottom: 0.5rem; }

.review-state__actions {
  display: flex;
  gap: 0.5rem;
}

.review-state__actions button {
  margin: 0;
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
}

/* ── Pagination ───────────────────────────────────────────────── */
.load-more {
  display: flex;
  justify-content: center;
  margin-block: 1.5rem;
}

/* ── AI result dialog ─────────────────────────────────────────── */
.ai-result-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--trumbo-muted);
}

/* ══════════════════════════════════════════════════════════════
   Chat IA — chat.html
   ══════════════════════════════════════════════════════════════ */

/* ── Page layout ───────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--trumbo-nav-height));
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.chat-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--trumbo-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--pico-background-color, #13171f);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--trumbo-border);
  flex-shrink: 0;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sidebar-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--trumbo-muted);
  font-size: 0.875rem;
}

.sidebar-empty button {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  padding: 0.4rem 0.85rem;
}

/* Body that holds both sections */
.sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Generic section block */
.sidebar-section {
  display: flex;
  flex-direction: column;
}

/* Label above each section ("En curso" / "Historial") */
.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--trumbo-muted);
  padding: 0.75rem 1rem 0.25rem;
  flex-shrink: 0;
}

/* ── En curso section ─────────────────────────────────────────── */
.sidebar-section--current {
  flex-shrink: 0;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--trumbo-border);
}

.chat-item--current {
  margin: 0 0.625rem;
  padding: 0.625rem 0.75rem;
  background: rgba(230, 57, 70, 0.06);
  border: 1px solid rgba(230, 57, 70, 0.2);
  border-radius: var(--trumbo-radius);
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-item--current:hover {
  background: rgba(230, 57, 70, 0.09);
}

.chat-item--current .chat-item-title {
  font-weight: 600;
}

.chat-item--current .chat-item-delete {
  opacity: 0.35;
}

.chat-item--current:hover .chat-item-delete {
  opacity: 1;
}

/* ── Historial section ────────────────────────────────────────── */
.sidebar-section--history {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.chat-list {
  padding: 0.375rem 0.5rem;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--trumbo-radius);
  cursor: pointer;
  transition: background var(--trumbo-transition);
}

.chat-item:hover  { background: var(--pico-card-border-color, #f0f0f0); }

.chat-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.chat-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  font-size: 0.75rem;
  color: var(--trumbo-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-delete {
  background: none;
  border: none;
  color: var(--trumbo-muted);
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 0.25rem;
  opacity: 0;
  transition: opacity var(--trumbo-transition), background var(--trumbo-transition),
              color var(--trumbo-transition);
  margin: 0;
  width: auto;
  flex-shrink: 0;
}

.chat-item:hover .chat-item-delete { opacity: 1; }

.chat-item-delete:hover {
  background: var(--trumbo-border);
  color: var(--trumbo-danger);
}

/* ── Main area ─────────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Empty state ───────────────────────────────────────────────── */
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 2rem;
}

.chat-empty-icon {
  font-size: 3rem;
  line-height: 1;
  margin: 0 0 0.5rem;
}

.chat-empty h2 { margin: 0; font-size: 1.25rem; }

.chat-empty p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--trumbo-muted);
}

.chat-empty button { margin-top: 1rem; }

/* ── Chat window ───────────────────────────────────────────────── */
.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--trumbo-border);
  flex-shrink: 0;
  background: var(--pico-background-color, #13171f);
  gap: 0.75rem;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-movie-badge {
  font-size: 0.78rem;
  color: var(--trumbo-muted);
  background: var(--pico-card-border-color, #f0f0f0);
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Messages ──────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-messages-empty {
  text-align: center;
  color: var(--trumbo-muted);
  font-size: 0.875rem;
  padding: 2rem 0;
}

.message {
  display: flex;
  max-width: 78%;
}

.message--user      { align-self: flex-end;  flex-direction: row-reverse; }
.message--assistant { align-self: flex-start; }

.message-bubble {
  padding: 0.625rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
}

.message--user .message-bubble {
  background: var(--trumbo-brand);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
  white-space: pre-wrap;
}

.message--assistant .message-bubble {
  background: var(--pico-card-background-color, #f8f9fa);
  border: 1px solid var(--trumbo-border);
  border-bottom-left-radius: 0.25rem;
  color: inherit;
}

/* Markdown dentro del burbuja del asistente */
.message--assistant .message-bubble p:last-child  { margin-bottom: 0; }
.message--assistant .message-bubble h1,
.message--assistant .message-bubble h2,
.message--assistant .message-bubble h3 { font-size: 1rem; margin-block: 0.5rem; }
.message--assistant .message-bubble pre  { overflow-x: auto; font-size: 0.8rem; }
.message--assistant .message-bubble code { font-size: 0.8rem; }

/* ── Typing indicator ──────────────────────────────────────────── */
.message-bubble--typing {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  min-width: 3.25rem;
  padding-block: 0.75rem;
}

.message-bubble--typing span {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--trumbo-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.message-bubble--typing .typing-label {
  margin-left: 0.5rem;
  font-size: 0.8125rem;
  color: var(--trumbo-muted);
}

.message-bubble--typing span:nth-child(2) { animation-delay: 0.2s; }
.message-bubble--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
  30%           { transform: translateY(-6px); opacity: 1;    }
}

/* ── Error ─────────────────────────────────────────────────────── */
.chat-error {
  color: var(--trumbo-danger);
  font-size: 0.8125rem;
  padding: 0.5rem 1.25rem;
  margin: 0;
  flex-shrink: 0;
}

/* ── Input bar ─────────────────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--trumbo-border);
  flex-shrink: 0;
  background: var(--pico-background-color, #13171f);
  margin: 0;
}

.chat-input-bar textarea {
  width: 100%;
  resize: none;
  margin: 0;
  font-size: 0.875rem;
  max-height: 8rem;
  overflow-y: auto;
  line-height: 1.5;
}

.chat-input-bar button {
  align-self: flex-end;
  margin: 0;
  padding: 0.5rem 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-sidebar {
    width: 220px;
    min-width: 220px;
  }
}

/* ── Scene AI assist ───────────────────────────────────────────── */
.label-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.375rem;
}

.label-with-action label { margin-bottom: 0; }

.ai-assist-btn {
  font-size: 0.8rem;
  padding: 0.2rem 0.65rem;
  margin: 0;
}

.assist-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--trumbo-muted);
  margin-bottom: 0.4rem;
}

.char-assist-section {
  background: var(--pico-card-background-color, #f8f8f8);
  border: 1px solid var(--pico-muted-border-color, #ddd);
  border-radius: 0.375rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
}

.assist-section-hint {
  font-weight: normal;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
}

.assist-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.875rem;
}

.assist-input-row input {
  flex: 1;
  margin: 0;
}

.assist-input-row textarea {
  flex: 1;
  margin: 0;
  resize: vertical;
  min-height: 3rem;
}

.assist-input-row button {
  flex-shrink: 0;
  margin: 0;
  white-space: nowrap;
}

.assist-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  transition: grid-template-columns 200ms ease;
}

.assist-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.assist-original {
  background: var(--pico-card-background-color, #f8f9fa);
  border: 1px solid var(--trumbo-border);
  border-radius: var(--trumbo-radius);
  padding: 0.75rem 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  height: 22rem;
  overflow-y: auto;
  color: var(--pico-muted-color);
  flex: 1;
}

.assist-result {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  height: 22rem;
  resize: none;
  margin: 0;
  flex: 1;
}

/* ── Rewrite mode pills ──────────────────────────────────────── */
.ai-rewrite-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.ai-rewrite-pill {
  font-size: 0.78rem;
  padding: 0.2rem 0.65rem;
  margin: 0;
  background: transparent;
  border: 1px solid var(--pico-primary);
  color: var(--pico-primary);
  border-radius: 2rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ai-rewrite-pill:hover:not(:disabled) {
  background: var(--pico-primary);
  color: #fff;
}

.ai-rewrite-pill:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ── AI result rendered Markdown area ───────────────────────── */
.ai-result-content {
  background: var(--pico-card-background-color, #f8f9fa);
  border: 1px solid var(--trumbo-border, #ddd);
  border-radius: var(--trumbo-radius, 0.375rem);
  padding: 1rem 1.25rem;
  line-height: 1.7;
  font-size: 0.9rem;
  max-height: 28rem;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.ai-result-content h2,
.ai-result-content h3 {
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.ai-result-content ul,
.ai-result-content ol {
  padding-left: 1.5rem;
}

/* ── Character chat reply ────────────────────────────────────── */
.char-chat-reply {
  font-style: italic;
  border-left: 3px solid var(--pico-primary);
  background: transparent;
  padding-left: 1rem;
}

/* ── Global spinner overlay ───────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.global-spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.55);
  pointer-events: none;
}

.global-spinner-overlay::after {
  content: "";
  width: 3rem;
  height: 3rem;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--trumbo-brand, #e63946);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

