:root {
  --navy: #1e293b;
  --navy-light: #334155;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #ca8a04;
  --yellow-bg: #fef9c3;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #0284c7;
  --blue-bg: #e0f2fe;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,0.08), 0 4px 12px rgba(15,23,42,0.04);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

html.scroll-locked,
body.scroll-locked {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.scroll-locked {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
}

.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-brand-text { min-width: 0; flex: 1; }

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.sidebar-nav { padding: 0.85rem 0.75rem 1rem; flex: 1; }

.nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.75rem 0.85rem 0.35rem;
  margin-top: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-link-featured {
  background: rgba(2, 132, 199, 0.18);
  border: 1px solid rgba(2, 132, 199, 0.35);
  color: #e0f2fe;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.65rem;
  border-radius: 10px;
}

.nav-link-featured .nav-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.nav-link-featured .nav-label strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.nav-link-featured .nav-label small {
  font-size: 0.68rem;
  font-weight: 500;
  color: #7dd3fc;
  opacity: 0.9;
}

.nav-link-featured:hover {
  background: rgba(2, 132, 199, 0.28);
  color: #fff;
}

.nav-link-featured.active {
  background: rgba(2, 132, 199, 0.38);
  border-color: rgba(125, 211, 252, 0.5);
  color: #fff;
}

.nav-link:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-link.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav-icon {
  width: 1.35rem;
  min-width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.05rem;
  line-height: 1;
  font-style: normal;
}
.nav-icon-lg { font-size: 1.2rem; }

.nav-emoji {
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.icon {
  display: inline-block;
  width: 1.125rem;
  height: 1.125rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-xs { width: 0.875rem; height: 0.875rem; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-xl { width: 2.25rem; height: 2.25rem; }
.icon-zone { width: 1.65rem; height: 1.65rem; opacity: 0.5; }
.icon-empty { width: 2.5rem; height: 2.5rem; opacity: 0.32; }

.empty-emoji {
  display: block;
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  opacity: 0.45;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-with-icon .icon { margin: 0; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  min-width: 2rem;
  min-height: 2rem;
}
.icon-btn .icon { margin: 0; }

.page-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
}
.page-back-icon .icon { width: 1.1rem; height: 1.1rem; }

.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.zone-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.video-card-play-btn .icon {
  width: 2rem;
  height: 2rem;
  opacity: 0.92;
}

.vm-center-btn .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.alert-banner .icon-inline {
  display: inline-flex;
  vertical-align: -0.15em;
  margin-right: 0.35rem;
}
.alert-banner .icon-inline .icon {
  width: 1rem;
  height: 1rem;
}

.ref-thumb-remove,
.job-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ref-thumb-remove .icon,
.job-del-btn .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-status {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #64748b;
}

.status-dot .icon {
  width: 0.85rem;
  height: 0.85rem;
  opacity: 0.65;
  flex-shrink: 0;
}

.status-dot .nav-emoji {
  opacity: 0.85;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.status-dot.ok::before { background: #4ade80; }
.status-dot.ok { color: #94a3b8; }

/* ── Main ────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.view { padding: 1.75rem 2rem 3rem; max-width: 1400px; }

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

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-header p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

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

/* ── Prompt library (card list, mobile-first) ────────── */
.prompt-library {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.prompt-lib-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.prompt-lib-text {
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 12rem;
  overflow-y: auto;
}

.prompt-lib-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.prompt-del-btn { color: var(--red) !important; }

.videos-filters { margin-bottom: 1rem; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(2,132,199,0.35); }
.btn-green { background: var(--navy); color: #fff; border: none; }
.btn-green:hover:not(:disabled) { background: var(--navy-light); box-shadow: 0 4px 12px rgba(30,41,59,0.35); }
.btn-genera {
  background: var(--purple);
  color: #fff;
  border: none;
}
.btn-genera:hover:not(:disabled) {
  background: #6d28d9;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }

/* ── KPI bar ──────────────────────────────────────────── */
.kpi-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.kpi.info .kpi-value { color: var(--blue); }
.kpi.success .kpi-value { color: var(--green); }
.kpi.warning .kpi-value { color: var(--yellow); }
.kpi.danger .kpi-value { color: var(--red); }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.35rem;
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.card-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: block;
}

/* ── Batch layout ────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.batch-page { position: relative; }

.batch-header { margin-bottom: 0.35rem; }
.batch-header-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}
.batch-header h2 { font-size: 1.1rem; margin: 0; flex: 1; min-width: 0; }
.batch-header p { display: none; }

.page-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.page-back-btn:hover {
  background: var(--blue-bg);
  border-color: #93c5fd;
  color: var(--blue);
}
.page-back-icon {
  font-size: 1rem;
  line-height: 1;
}
.page-back-label { line-height: 1.2; }

.batch-flow {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.batch-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow);
}

.batch-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.batch-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--blue-bg);
  color: var(--blue);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.batch-tag {
  font-size: 0.65rem;
  font-weight: 600;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.batch-tag.ok { color: var(--green); }

.mode-select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  background: var(--card);
  color: var(--text);
  margin-bottom: 0.35rem;
}

.batch-section .field-hint {
  margin: 0 0 0.55rem;
  font-size: 0.74rem;
  line-height: 1.4;
}

.batch-section .upload-zone {
  padding: 1rem 0.75rem;
  font-size: 0.82rem;
}

.batch-prompt-list {
  max-height: 150px;
}

.mode-chips {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.mode-chip {
  flex: 1;
  padding: 0.42rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.mode-chip.selected {
  border-color: var(--blue);
  background: var(--blue-bg);
  color: var(--blue);
}

.upload-zone.compact {
  padding: 0.65rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1.3;
}
.upload-zone.compact .zone-icon {
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

.img-preview.compact {
  max-height: 80px;
  margin-top: 0.4rem;
}

.toolbar.compact {
  margin-bottom: 0.4rem;
  gap: 0.35rem;
}
.toolbar.compact .search-input {
  min-width: 0;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
}
.btn-icon { min-width: 34px; padding-left: 0.4rem; padding-right: 0.4rem; }

.prompt-list.compact {
  max-height: 130px;
  gap: 0.35rem;
}
.prompt-list.compact .prompt-item {
  padding: 0.45rem 0.55rem;
  gap: 0.45rem;
  border-radius: 8px;
}
.prompt-list.compact .prompt-preview {
  font-size: 0.74rem;
  -webkit-line-clamp: 1;
  margin-top: 0.15rem;
}
.prompt-list.compact .prompt-actions {
  flex-direction: row;
  gap: 0.15rem;
}
.prompt-list.compact .prompt-actions .btn {
  padding: 0.15rem 0.35rem;
  font-size: 0.68rem;
  min-height: 0;
}

.lang-grid.compact {
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin-bottom: 0;
}
.lang-grid.compact .lang-chip {
  padding: 0.38rem 0.2rem;
  border-radius: 8px;
}
.lang-grid.compact .lang-code {
  font-size: 0.78rem;
}

.batch-advanced {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.batch-advanced summary {
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.batch-advanced summary::-webkit-details-marker { display: none; }
.batch-advanced-body {
  padding: 0 0.75rem 0.65rem;
  border-top: 1px solid var(--border);
}
.form-group.compact { margin-bottom: 0.45rem; }
.form-group.compact label {
  font-size: 0.68rem;
  margin-bottom: 0.15rem;
}
.form-group.compact select {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}
.form-row-3.compact { gap: 0.4rem; }
.checkbox-row.compact {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.batch-launch .launch-estimate {
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
  text-align: center;
}

.batch-launch .btn-genera {
  min-height: 48px;
  font-size: 1.05rem;
  font-weight: 700;
}

.batch-launch {
  margin-bottom: 1.5rem;
}

.videos-empty-cta {
  max-width: 360px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}
.videos-empty-cta .btn { min-height: 48px; font-size: 1rem; font-weight: 700; }

.alert-banner.compact {
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  margin-bottom: 0.45rem;
}

.batch-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.batch-bottom {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

/* ── Upload immagine ─────────────────────────────────── */
.image-mode-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 1rem;
}

.upload-block { margin-bottom: 0.75rem; }

.upload-label-text {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  background: #fafbfc;
  line-height: 1.4;
}

.upload-zone:hover,
.upload-zone.drag { border-color: var(--blue); background: var(--blue-bg); color: #0369a1; }
.upload-zone.has-file { border-color: var(--green); background: var(--green-bg); color: #166534; }

.upload-zone.upload-zone-green {
  border-color: #86efac;
  border-width: 2px;
  background: var(--green-bg);
  color: #166534;
  font-weight: 600;
}
.upload-zone.upload-zone-green:hover,
.upload-zone.upload-zone-green.drag {
  border-color: var(--green);
  background: #bbf7d0;
  color: #14532d;
}
.upload-zone.upload-zone-green.has-file {
  border-color: var(--green);
  background: #dcfce7;
}

.upload-zone .zone-icon { display: flex; justify-content: center; margin-bottom: 0.35rem; }

.img-preview {
  margin-top: 0.65rem;
  max-height: 140px;
  max-width: 100%;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid var(--border);
  display: block;
}

.refs-thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.65rem; }
.refs-loaded {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}
.ref-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.ref-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ref-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref-thumb-remove:hover { background: var(--red); }
.ref-remove-btn {
  color: var(--red) !important;
  border-color: var(--border) !important;
}
.ref-remove-btn:hover { background: var(--red-bg) !important; }
.refs-thumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ── Prompt list ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.toolbar-prompt {
  align-items: stretch;
}

.toolbar-prompt .search-input {
  flex: 1 1 100%;
  min-width: 0;
}

.btn-create-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 1 1 100%;
  min-height: 44px;
  padding: 0.6rem 1rem;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(30, 41, 59, 0.22);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-create-prompt:hover:not(:disabled) {
  background: var(--navy-light);
  box-shadow: 0 4px 14px rgba(30, 41, 59, 0.32);
}

.btn-create-prompt:active:not(:disabled) { transform: scale(0.98); }

#settingsSavedMsg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.search-input {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--card);
}

.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.prompt-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.prompt-item:hover { border-color: #94a3b8; }
.prompt-item.selected { border-color: var(--blue); background: var(--blue-bg); }

.prompt-item input[type=checkbox] { margin-top: 2px; accent-color: var(--blue); flex-shrink: 0; }

.prompt-meta { flex: 1; min-width: 0; }
.prompt-title { font-weight: 600; font-size: 0.875rem; }
.prompt-cat {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  background: var(--blue-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-top: 0.2rem;
}
.prompt-preview {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.prompt-item:hover .prompt-actions { opacity: 1; }

.prompt-actions .btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

/* ── Language chips ──────────────────────────────────── */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lang-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.lang-chip:hover { border-color: #94a3b8; }
.lang-chip.selected { border-color: var(--blue); background: var(--blue-bg); }
.lang-chip.disabled { opacity: 0.4; pointer-events: none; }

.lang-code { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.lang-name { font-size: 0.7rem; color: var(--muted); margin-top: 0.1rem; }
.lang-chip.selected .lang-code { color: var(--blue); }

/* ── Seedance config ─────────────────────────────────── */
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.form-group { margin-bottom: 0.75rem; }

.field-hint {
  margin: 0.4rem 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--card);
  color: var(--text);
}

.checkbox-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.checkbox-row label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.checkbox-row input { accent-color: var(--blue); }

.launch-estimate {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ── Badge / pill ────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-queued, .pill-ok { background: #f1f5f9; color: var(--muted); }
.pill-running { background: var(--blue-bg); color: var(--blue); }
.pill-completed { background: var(--green-bg); color: var(--green); }
.pill-partial { background: var(--yellow-bg); color: var(--yellow); }
.pill-failed { background: var(--red-bg); color: var(--red); }
.pill-dry_run { background: #f3e8ff; color: var(--purple); }

/* ── Job cards ───────────────────────────────────────── */
.jobs-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jobs-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.45rem;
}

.job-card {
  background: var(--card);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.job-card:hover { box-shadow: 0 2px 12px rgba(15,23,42,0.08); border-color: #cbd5e1; }
.job-card.active { border-color: var(--blue); background: #f8fbff; }

.job-card-header {
  margin-bottom: 0.35rem;
}

.job-card-main { min-width: 0; }

.job-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.job-card-id {
  font-family: monospace;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-card-langs {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.job-card-date { opacity: 0.85; }

.job-elapsed-running {
  font-weight: 700;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.job-elapsed-done {
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.job-card .pill {
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
  flex-shrink: 0;
}

.progress-wrap { margin: 0.3rem 0 0; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #38bdf8);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-fill.done { background: linear-gradient(90deg, var(--green), #86efac); }
.progress-fill.error { background: var(--red); }

/* ── Job items detail ────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  margin-top: 1.25rem;
}

.items-table th {
  text-align: left;
  padding: 0.65rem 1rem;
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.items-table tr:hover td { background: #fafbfc; }

.item-links a {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.8rem;
  margin-right: 8px;
}

.item-links a:hover { text-decoration: underline; }

/* ── Manifest box ─────────────────────────────────────── */
/* ── Cost display ──────────────────────────────────────── */
.cost-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(90deg, #0d2137 0%, #1a3a5c 100%);
  border-radius: 10px;
  padding: 0.85rem 1.2rem;
  margin-bottom: 1rem;
  color: #fff;
}
.cost-banner-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  flex-shrink: 0;
}
.cost-banner-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #4cd79a;
  letter-spacing: -0.01em;
}
.cost-banner-tokens {
  font-size: 0.8rem;
  opacity: 0.65;
  margin-left: auto;
}
.cost-cell {
  white-space: nowrap;
  font-size: 0.82rem;
  color: #1a3a5c;
  font-variant-numeric: tabular-nums;
}
.cost-tokens {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: #f0f4f9;
  padding: 1px 5px;
  border-radius: 4px;
}
.cost-est {
  color: var(--warning, #f59e0b);
  font-style: normal;
  font-size: 0.9em;
}
.job-card-cost {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #1a6640;
  background: #e6f7ee;
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
}

.job-detail-panel {
  margin-top: 0.25rem;
}

.job-detail-elapsed-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.job-detail-elapsed-wrap .job-elapsed-running,
.job-detail-elapsed-wrap .job-elapsed-done {
  font-size: 1rem;
}

.job-detail-status { font-size: 0.72rem !important; }

.manifest-box {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--green-bg);
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #166534;
}

/* ── Prompt library page ─────────────────────────────── */
.prompt-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.data-table td { padding: 0.7rem 1rem; border-top: 1px solid var(--border); vertical-align: top; }
.data-table tr:hover td { background: #fafbfc; }
.data-table td:last-child { max-width: 480px; font-size: 0.8rem; color: var(--muted); }

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

.empty-state .empty-icon { display: flex; justify-content: center; margin-bottom: 0.75rem; }

/* ── Alert banner ────────────────────────────────────── */
.alert-banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--yellow-bg);
  border: 1px solid #fde047;
  color: #854d0e;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.alert-banner.info { background: var(--blue-bg); border-color: #bae6fd; color: #0369a1; }
.alert-banner.danger { background: var(--red-bg); border-color: #fca5a5; color: #991b1b; }
.alert-banner.warn { background: var(--yellow-bg); border-color: #fde68a; color: #78350f; }

.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--card);
  color: var(--text);
  resize: vertical;
  line-height: 1.5;
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

/* ── Image page tabs ─────────────────────────────────── */
.img-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.img-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.img-tab:hover { border-color: #94a3b8; color: var(--text); }
.img-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Seedream image results ──────────────────────────── */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.preset-chip:hover { border-color: var(--blue); background: var(--blue-bg); }
.preset-chip strong { font-size: 0.82rem; }
.preset-chip span { font-size: 0.72rem; color: var(--muted); }

.image-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.image-result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f8fafc;
  box-shadow: var(--shadow);
}

.image-result-card img {
  width: 100%;
  display: block;
  aspect-ratio: 9/16;
  object-fit: cover;
  background: #e2e8f0;
}

.image-result-meta {
  padding: 0.75rem;
}

.image-result-meta > span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.image-result-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  animation: fadeIn 0.15s ease;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: min(55vh, 55dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  touch-action: auto;
}

.modal-lg { max-width: 720px; }

.modal-prompt {
  max-height: min(55vh, 55dvh);
}

.modal-prompt .modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-prompt .form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

.modal-prompt-header {
  gap: 0.75rem;
}

.modal-prompt-header h3 {
  flex: 1;
  min-width: 0;
}

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

.modal-paste-btn {
  font-size: 16px;
  white-space: nowrap;
}

.modal-prompt-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}

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

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0.25rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 1.35rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-prompt-textarea {
  width: 100%;
  flex: 1;
  min-height: 120px;
  height: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px !important;
  background: var(--card);
  color: var(--text);
  resize: none;
  line-height: 1.5;
  display: block;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.modal-prompt-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

.modal-body textarea,
.modal-body input,
.modal-body select {
  font-size: 16px;
}

.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--card);
  color: var(--text);
  resize: vertical;
  min-height: 110px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
.mt { margin-top: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes modalSheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
.fade-in { animation: fadeIn 0.2s ease; }

/* ── Job delete button ───────────────────────────────── */
.job-card { position: relative; }

.job-del-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 3px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  line-height: 1;
}

.job-card:hover .job-del-btn { opacity: 1; }
.job-del-btn:hover { background: var(--red-bg); color: var(--red); }

/* ── Clean preview box ───────────────────────────────── */
.clean-preview-box {
  background: var(--yellow-bg);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: #78350f;
}

/* ── Logs table ──────────────────────────────────────── */
.logs-table { font-size: 0.79rem; }
.logs-table th { white-space: nowrap; }
.log-ts    { white-space: nowrap; color: var(--muted); font-size: 0.74rem; }
.log-level { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.log-source { background: #f0f4f9; border-radius: 4px; padding: 1px 5px; font-size: 0.72rem; color: var(--muted); }
.log-msg   { max-width: 520px; word-break: break-word; }
.log-detail {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.3rem;
  background: #f8fafc;
  border-radius: 4px;
  padding: 4px 6px;
  white-space: pre-wrap;
  max-height: 60px;
  overflow: hidden;
}
.log-job-link {
  cursor: pointer;
  color: var(--blue);
  text-decoration: underline;
  font-size: 0.74rem;
}

/* ── Jobs filters bar ────────────────────────────────── */
.jobs-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.jobs-filters .search-input { flex: 1; min-width: 160px; }

.jobs-filters select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--card);
  color: var(--text);
}

/* ── Pagination ──────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 0 0.5rem;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.83rem;
  color: var(--muted);
}

/* ── Mobile header ───────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--navy);
  z-index: 200;
  align-items: center;
  padding: 0 0.85rem 0 0.65rem;
  gap: 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.mobile-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mobile-page-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.2s;
}

/* Stato aperto: X */
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar overlay (mobile) ─────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

.sidebar-overlay.visible { display: block; }

.prompt-cell-text {
  max-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
}

#mPrompt {
  min-height: 280px;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

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

.video-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.video-del-action { color: var(--red); }
.video-del-action:hover { background: var(--red-bg); }

.video-drive-btn {
  border-color: rgba(2, 132, 199, 0.35);
  color: var(--blue);
  font-weight: 600;
}

.video-drive-btn:hover:not(:disabled) {
  background: var(--blue-bg);
  border-color: var(--blue);
}

.video-drive-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.video-card-player {
  position: relative;
  cursor: pointer;
  background: #0f172a;
  aspect-ratio: 9/16;
  overflow: hidden;
}

.video-card-player video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.video-card-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
  transition: background 0.15s;
  pointer-events: none;
}

.video-card-duration {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  z-index: 2;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}

.video-card-dur-meta {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}
.video-card-dur-meta:empty { display: none; }

.video-card-player:hover .video-card-play-btn {
  background: rgba(0,0,0,0.45);
}

.video-card-info {
  padding: 0.65rem 0.75rem 0.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.video-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-card-date {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 0.75rem 0.2rem;
}

.video-card-actions {
  padding: 0.5rem 0.75rem 0.75rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Video in generazione (library) ─────────────────── */
.videos-pending-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue);
  margin: 0 0 0.65rem;
}

.video-card-pending {
  border-color: rgba(2, 132, 199, 0.35);
  box-shadow: 0 2px 14px rgba(2, 132, 199, 0.12);
}

.video-card-loading {
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 1rem 0.75rem;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 100%);
}

.video-card-loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: video-spin 0.85s linear infinite;
}

@keyframes video-spin {
  to { transform: rotate(360deg); }
}

.video-pending-pct {
  font-size: 1.35rem;
  font-weight: 700;
  color: #e0f2fe;
  letter-spacing: -0.02em;
  line-height: 1;
}

.video-pending-bar {
  width: 78%;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.video-pending-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.video-pending-status {
  font-size: 0.72rem;
  font-weight: 600;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.video-pending-eta {
  font-size: 0.68rem;
  color: #64748b;
}

.video-pending-meta {
  display: flex;
  align-items: center;
  padding: 0 0.85rem 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.video-pending-elapsed {
  font-weight: 600;
  color: var(--blue);
}

/* ── Settings page ───────────────────────────────────── */
.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.settings-section-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.settings-section-desc code {
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.82em;
  color: var(--navy-light);
}

.settings-lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.6rem;
}

.settings-lang-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.settings-folder-input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
}

.settings-folder-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: #fff;
}

/* ── Responsive breakpoints ──────────────────────────── */

/* Tablet */
@media (max-width: 1100px) {
  .batch-layout { grid-template-columns: 1fr; }
  .batch-bottom { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar-logo { display: none; }

  .main { margin-left: 0; padding-top: 56px; }

  .view { padding: 1.25rem 1rem 3rem; }

  /* Sidebar diventa drawer da sinistra */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 160;
    top: 0;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Layouts a colonna singola */
  .batch-layout { grid-template-columns: 1fr; }
  .batch-bottom { grid-template-columns: 1fr; }

  .view { padding: 1rem 0.85rem 1.5rem; }

  .lang-grid { grid-template-columns: repeat(3, 1fr); }
  .lang-grid .lang-name { display: block; font-size: 0.65rem; }
  .batch-prompt-list { max-height: 120px; }
  .batch-section .upload-zone { padding: 0.85rem 0.6rem; }
  .batch-advanced[open] summary { margin-bottom: 0; }

  /* KPI compatte */
  .kpi-bar { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .kpi-value { font-size: 1.4rem; }

  /* Jobs: griglia compatta */
  .jobs-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
  }
  .job-card { padding: 0.55rem 0.6rem; }
  .job-card-langs { font-size: 0.72rem; }
  .job-detail-elapsed-wrap .job-elapsed-running,
  .job-detail-elapsed-wrap .job-elapsed-done { font-size: 0.9rem; }

  /* Jobs: elenco e dettaglio in colonna */
  .jobs-panel { grid-template-columns: 1fr; }

  /* Tabella scroll orizzontale */
  .items-table-wrap, .items-table { overflow-x: auto; display: block; width: 100%; }
  .items-table { font-size: 0.78rem; }
  .items-table th, .items-table td { white-space: nowrap; padding: 0.5rem 0.65rem; }

  /* Page header compatto */
  .page-header { gap: 0.5rem; flex-direction: column; align-items: stretch; }
  .page-header h2 { font-size: 1.2rem; }
  .page-header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .page-header-actions .btn-primary {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    font-size: 0.95rem;
  }
  .page-header-secondary { flex-shrink: 0; }

  .prompt-lib-text { max-height: none; font-size: 0.82rem; }
  .prompt-lib-actions .btn { flex: 1; justify-content: center; min-height: 38px; }

  .videos-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .videos-filters select,
  .videos-filters .search-input { width: 100%; max-width: none; }

  /* Bottoni full-width su mobile */
  .launch-btn-wrap .btn-primary { width: 100%; justify-content: center; }

  /* Cost banner compatto */
  .cost-banner { flex-direction: column; align-items: flex-start; gap: 0.4rem; padding: 0.75rem 1rem; }
  .cost-banner-tokens { margin-left: 0; }

  /* Modal bottom sheet su mobile — metà schermo, flottante */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
  }

  .modal {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 55dvh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    box-shadow: 0 -12px 48px rgba(15, 23, 42, 0.22);
    animation: modalSheetIn 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .modal-prompt {
    height: 55dvh;
    max-height: 55dvh;
  }

  .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    margin: 0.55rem auto 0;
    border-radius: 999px;
    background: var(--border);
    flex-shrink: 0;
  }

  .modal-header {
    padding-top: 0.5rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .modal-footer {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .modal-prompt-textarea {
    min-height: 0;
  }

  /* Evita zoom automatico iOS su input/textarea */
  input,
  textarea,
  select,
  .form-group textarea,
  .form-group input,
  .form-group select,
  .search-input {
    font-size: 16px !important;
    touch-action: manipulation;
  }

  /* Image page tabs */
  .img-tabs { gap: 0.25rem; }
  .img-tab { font-size: 0.8rem; padding: 0.5rem 0.75rem; }

  /* Prompt list altezza ridotta */
  .prompt-list { max-height: 260px; }

  /* Image results grid 1 col */
  .image-results-grid { grid-template-columns: 1fr 1fr; }

  /* Video gallery 2 col su mobile */
  .video-gallery { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .video-card-actions { gap: 0.3rem; }
  .settings-lang-grid { grid-template-columns: 1fr; }
}

/* Schermi molto piccoli */
@media (min-width: 900px) {
  .batch-flow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .batch-advanced,
  .batch-launch {
    grid-column: 1 / -1;
  }
  .batch-prompt-list { max-height: 180px; }
}

@media (min-width: 1200px) {
  .jobs-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
  }
}

@media (max-width: 400px) {
  .jobs-list { grid-template-columns: 1fr; }
  .lang-grid { grid-template-columns: 1fr 1fr; }
  .kpi-bar { grid-template-columns: 1fr 1fr; }
  .image-results-grid { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
}

/* ── Video modal ──────────────────────────────────────── */
.vm-overlay {
  padding: 0;
  background: rgba(0,0,0,0.95);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  height: 100dvh;
  height: 100vh;
}

.vm-box {
  display: flex;
  flex-direction: column;
  width: 95vw;
  max-width: 900px;
  max-height: 95dvh;
  max-height: 95vh;
  background: #0a0a0a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  touch-action: auto;
}

.vm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: #111;
  flex-shrink: 0;
  min-height: 48px;
}

.vm-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.vm-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.vm-close:hover { background: rgba(255,255,255,0.2); }

.vm-body {
  flex: 1;
  min-height: 0;
  background: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.vm-video {
  width: 100%;
  height: 100%;
  max-height: calc(95dvh - 110px);
  max-height: calc(95vh - 110px);
  display: block;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.vm-center-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.vm-center-btn:active {
  transform: translate(-50%, -50%) scale(0.94);
}

.vm-center-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

.vm-play-btn {
  min-width: 6.5rem;
}

.vm-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: #111;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  min-height: 54px;
}

/* Mobile: fullscreen vero */
@media (max-width: 768px) {
  .vm-overlay {
    align-items: flex-start;
    padding: 0;
  }

  .vm-box {
    width: 100vw;
    max-width: 100%;
    height: 100dvh;
    height: 100vh;
    max-height: 100dvh;
    max-height: 100vh;
    border-radius: 0;
  }

  .vm-header {
    padding: 0.6rem 0.75rem;
    min-height: 52px;
  }

  .vm-video {
    max-height: calc(100dvh - 106px);
    max-height: calc(100vh - 106px);
  }

  .vm-center-btn {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }

  .vm-footer {
    padding: 0.5rem 0.75rem;
    min-height: 54px;
  }

  .vm-close {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
}
