/* ===========================================================================
   FRAMEWORKS DESIGN SYSTEM
   Brand: Purple #BE00FF · Black #000 · White #FFF
   Font primario (titoli): Helvetica Now Display → Inter/Helvetica Neue
   Font serif editoriale (accent): GT Super Display → Fraunces
   Font UI (digitale): Google Sans → Inter
   =========================================================================== */
:root {
  --brand: #BE00FF;
  --brand-2: #00CFFF;          /* electric cyan: solo gradienti/hero, echo della cover */
  --accent: var(--brand);
  --accent-2: var(--brand);
  --radius: 12px;
  --radius-lg: 18px;
  --font-display: "Helvetica Now Display", "Helvetica Neue", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ui: "Google Sans", "Product Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "GT Super Display", "Fraunces", Georgia, "Times New Roman", serif;
  /* Sidebar: sempre brand-black in entrambi i temi (identità forte). */
  --sb-bg: #0b0b0e;
  --sb-text: rgba(255,255,255,0.66);
  --sb-text-hover: #ffffff;
  --sb-active-bg: rgba(190,0,255,0.16);
  --sb-line: rgba(255,255,255,0.08);
  --sb-hover: rgba(255,255,255,0.06);
  --sidebar-w: 256px;
}
/* Alias di compatibilità: i vecchi nomi puntano alle nuove superfici. */
:root {
  --panel: var(--surface);
  --panel-solid: var(--surface);
  --panel-2: var(--surface-2);
  --glass: var(--surface);
  --glass-strong: var(--appbar-bg);
}
:root, :root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-soft: #efeff2;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --line: rgba(10,10,15,0.10);
  --line-strong: rgba(10,10,15,0.16);
  --text: #0a0a0c;
  --muted: #6a6a76;
  --error: #d11f1f;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(10,10,20,0.04), 0 8px 30px rgba(10,10,20,0.06);
  --appbar-bg: rgba(255,255,255,0.82);
}
:root[data-theme="dark"] {
  --bg: #0c0c0f;
  --bg-soft: #131318;
  --surface: #141418;
  --surface-2: #1c1c22;
  --line: rgba(255,255,255,0.10);
  --line-strong: rgba(255,255,255,0.18);
  --text: #f2f2f6;
  --muted: #9a9aa8;
  --error: #ff6b6b;
  --ok: #36c46b;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 40px rgba(0,0,0,0.4);
  --appbar-bg: rgba(14,14,18,0.8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, .section-title { font-family: var(--font-display); letter-spacing: -0.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.error { color: var(--error); font-size: 0.85rem; }

/* Icone monocromatiche dal set (mask → prendono il colore corrente) */
.ico {
  display: inline-block; width: 18px; height: 18px; flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}
.ico[data-ico="layers"]   { --ico: url(/assets/icons/layers.svg); }
.ico[data-ico="frames"]   { --ico: url(/assets/icons/frames.svg); }
.ico[data-ico="video"]    { --ico: url(/assets/icons/video.svg); }
.ico[data-ico="image"]    { --ico: url(/assets/icons/image.svg); }
.ico[data-ico="library"]  { --ico: url(/assets/icons/library.svg); }
.ico[data-ico="film"]     { --ico: url(/assets/icons/film.svg); }
.ico[data-ico="clock"]    { --ico: url(/assets/icons/clock.svg); }
.ico[data-ico="list"]     { --ico: url(/assets/icons/list.svg); }
.ico[data-ico="coin"]     { --ico: url(/assets/icons/coin.svg); }
.ico[data-ico="users"]    { --ico: url(/assets/icons/users.svg); }
.ico[data-ico="menu"]     { --ico: url(/assets/icons/menu.svg); }
.ico[data-ico="settings"] { --ico: url(/assets/icons/settings.svg); }
.ico[data-ico="home"]     { --ico: url(/assets/icons/home.svg); }
.ico[data-ico="flow"]     { --ico: url(/assets/icons/flow.svg); }
.ico[data-ico="wave"]     { --ico: url(/assets/icons/wave.svg); }
.ico[data-ico="person"]   { --ico: url(/assets/icons/person.svg); }
.ico[data-ico="sliders"]  { --ico: url(/assets/icons/sliders.svg); }
.ico[data-ico="cut"]      { --ico: url(/assets/icons/cut.svg); }
.ico[data-ico="edit"]     { --ico: url(/assets/icons/edit.svg); }
.ico[data-ico="wand"]     { --ico: url(/assets/icons/wand.svg); }
.ico[data-ico="book"]     { --ico: url(/assets/icons/book.svg); }

/* ---------------- LOGIN (hero gradiente glossy) ---------------- */
.login-screen {
  min-height: 100vh; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #07070a;
}
.login-aurora {
  position: absolute; inset: -20% -10% -10% -10%; z-index: 0; filter: blur(40px) saturate(140%);
  background:
    radial-gradient(40% 55% at 22% 30%, rgba(0,207,255,0.55), transparent 70%),
    radial-gradient(45% 60% at 70% 45%, rgba(190,0,255,0.65), transparent 72%),
    radial-gradient(40% 50% at 55% 80%, rgba(255,0,140,0.45), transparent 70%);
  animation: aurora 18s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1.05) rotate(-3deg); }
  100% { transform: translate3d(4%, 3%, 0) scale(1.15) rotate(4deg); }
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(12,12,16,0.55); border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(26px) saturate(150%); -webkit-backdrop-filter: blur(26px) saturate(150%);
  padding: 2.6rem 2.4rem; border-radius: var(--radius-lg);
  width: 340px; display: flex; flex-direction: column; gap: 0.7rem; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  color: #fff;
}
.login-logo { width: 168px; height: 26px; margin: 0 auto 0.4rem; background: #fff; }
.login-title { margin: 0; font-size: 2.6rem; font-weight: 800; letter-spacing: -0.04em; color: #fff; }
.login-sub { margin: -0.5rem 0 0; font-family: var(--font-serif); font-style: italic; font-size: 1rem; color: #fff; opacity: 0.9; }
.login-note { color: rgba(255,255,255,0.6) !important; margin-top: 0.2rem; }
.login-card input { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); color: #fff; }
.login-card input::placeholder { color: rgba(255,255,255,0.5); }
.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 0.95rem;
  padding: 0.7rem 1rem; border-radius: 10px; text-decoration: none; border: none;
}
.google-btn:hover { background: #f1f1f3; }

/* ---------------- APP SHELL: sidebar + main-col ---------------- */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
body.sidebar-collapsed #app { --sidebar-w: 72px; }

/* Brand logo (mask monocromatica) */
.brand-logo {
  display: inline-block; width: 150px; height: 22px; flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url(/assets/fw-logo-white.svg) left center / contain no-repeat;
  mask: url(/assets/fw-logo-white.svg) left center / contain no-repeat;
}

/* SIDEBAR (sempre brand-black) */
.sidebar {
  background: var(--sb-bg); color: var(--sb-text);
  border-right: 1px solid var(--sb-line);
  display: flex; flex-direction: column; gap: 0.5rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.1rem 0.85rem 1rem;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0.2rem 0.4rem 0.9rem; }
.sidebar .brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: #fff; }
.sidebar .brand-logo { width: 130px; }
.sidebar .brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; display: none; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 1rem;
}
.sidebar .icon-btn { border-color: var(--sb-line); color: rgba(255,255,255,0.7); }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.sidebar .icon-btn:hover { color: #fff; border-color: rgba(255,255,255,0.3); }
.nav { display: flex; flex-direction: column; gap: 1.1rem; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-group-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.34); padding: 0 0.6rem 0.3rem;
}
.sidebar .tab {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--sb-text); font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500;
  padding: 0.55rem 0.6rem; border-radius: 10px; position: relative; text-align: left;
}
.sidebar .tab .ico { width: 19px; height: 19px; opacity: 0.9; }
.sidebar .tab:hover { background: var(--sb-hover, rgba(255,255,255,0.06)); color: var(--sb-text-hover); }
.sidebar .tab.active { background: var(--sb-active-bg); color: #fff; font-weight: 600; }
.sidebar .tab.active::before {
  content: ""; position: absolute; left: -0.85rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar .tab.active .ico { opacity: 1; color: var(--brand); }
.sidebar-foot { padding: 0.6rem 0.7rem 0.2rem; border-top: 1px solid var(--sb-line); margin-top: 0.4rem; }
.brand-byline { font-size: 0.68rem; color: rgba(255,255,255,0.4); }
.brand-byline b { color: rgba(255,255,255,0.7); font-weight: 700; }

/* Sidebar collassata: solo icone */
body.sidebar-collapsed .sidebar .brand-name,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .brand-byline,
body.sidebar-collapsed .sidebar .brand-logo { display: none; }
body.sidebar-collapsed .sidebar .tab { justify-content: center; padding: 0.6rem; }
body.sidebar-collapsed .sidebar-head { justify-content: center; }
body.sidebar-collapsed .sidebar .queue-badge { display: none; }

/* APPBAR */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.6rem; border-bottom: 1px solid var(--line);
  background: var(--appbar-bg); backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.section-title { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; flex: 1; }
.appbar-right { display: flex; align-items: center; gap: 0.7rem; }
.user-chip {
  font-size: 0.8rem; color: var(--muted); padding: 0.35rem 0.7rem;
  border: 1px solid var(--line); border-radius: 999px; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.only-narrow { display: none; }

/* PANELS */
main { padding: 1.6rem; max-width: 1320px; margin: 0 auto; width: 100%; }
.panel { display: none; }
.panel.active { display: block; }

/* Responsive: sidebar a scomparsa sotto i 900px */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 260px;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 55;
  }
  .only-narrow { display: inline-flex; }
}
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

.inputs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.inputs h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}
textarea, input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
  font-family: inherit;
}
textarea { resize: vertical; }
.row { display: flex; gap: 0.75rem; }
.row > div { flex: 1; }
.row.checks { margin-top: 1rem; gap: 1.25rem; flex-wrap: wrap; }
.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}
.check input { width: auto; }
.seed-input { margin-top: 0.6rem; }
.label-row { display: flex; align-items: center; justify-content: space-between; margin: 1rem 0 0.4rem; }
.label-row label { margin: 0; }
.mini-btn {
  font-size: 0.72rem; padding: 0.2rem 0.55rem; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--accent); cursor: pointer;
}
.mini-btn:hover { border-color: var(--accent); }

/* BUTTONS */
button {
  font-family: inherit;
  cursor: pointer;
}
button.primary, .login-card button {
  margin-top: 1.25rem;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}
button.primary:hover, .login-card button:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
}
/* Info "i" + callout esplicativo */
.info-btn {
  width: 16px; height: 16px; min-width: 16px; padding: 0; margin-left: 0.4rem;
  border-radius: 50%; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-size: 0.66rem; font-style: italic; font-weight: 700;
  line-height: 1; cursor: pointer; vertical-align: middle;
}
.info-btn:hover { border-color: var(--accent); color: var(--accent); }
.info-callout {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 0.55rem 0.7rem; margin: 0.35rem 0 0.6rem;
  font-size: 0.75rem; color: var(--muted); line-height: 1.45;
}
.info-callout b { color: var(--text); }

button.reset-btn { width: 100%; margin-top: 0.5rem; }
button.reset-btn:hover { border-color: var(--error); color: var(--error); }

/* DROPZONE */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); }
.dz-label { color: var(--muted); font-size: 0.85rem; }
.dz-preview { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.dz-preview img, .dz-preview video {
  width: 72px; height: 72px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line);
}
.dz-preview .chip {
  font-size: 0.75rem; color: var(--accent-2);
  background: rgba(74,214,192,0.1); padding: 0.2rem 0.5rem; border-radius: 6px;
}
/* Pulsante "scegli dalla libreria" sotto le dropzone */
.pick-lib-btn { width: 100%; margin-top: 0.4rem; font-size: 0.78rem; }

/* Modale picker libreria */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.picker-subtabs { margin: 1rem 1.25rem 0; }
.picker-drop {
  margin: 0.8rem 1.25rem 0; border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 0.85rem; text-align: center; cursor: pointer; background: var(--panel-2);
}
.picker-drop:hover, .picker-drop.drag { border-color: var(--accent); }
.picker-drop .dz-label { color: var(--muted); font-size: 0.82rem; }
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem; padding: 1rem 1.25rem; overflow-y: auto;
}
.picker-grid .placeholder { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 2rem; }
.picker-item { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 1; }
.picker-item:hover { border-color: var(--accent); }
.picker-item img, .picker-item video { width: 100%; height: 100%; object-fit: cover; }

/* Tile reference numerate e trascinabili (t2v) */
.ref-tile { position: relative; display: inline-block; }
.ref-tile img, .ref-tile video {
  width: 72px; height: 72px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); display: block; background: #000;
}
.ref-tile[draggable="true"] img { cursor: grab; }
.ref-tile[draggable="true"]:active img { cursor: grabbing; }
.ref-tile .chip { display: inline-block; }
.ref-num {
  position: absolute; left: 4px; bottom: 4px;
  background: rgba(0,0,0,0.75); color: #fff; font-size: 0.62rem; font-weight: 700;
  padding: 0.05rem 0.35rem; border-radius: 4px; pointer-events: none;
}
.ref-x {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; border: none; background: var(--error); color: #fff;
  cursor: pointer; font-size: 0.75rem; line-height: 1; display: flex;
  align-items: center; justify-content: center;
}
.dz-progress {
  display: none; margin-top: 0.6rem; height: 8px; border-radius: 999px;
  background: var(--bg); overflow: hidden;
}
.dz-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.15s ease;
}

/* OUTPUT */
.output {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 300px;
  display: flex;
  flex-direction: column;   /* media sopra, info (scarica/token/costo) sotto */
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}
.output .placeholder { color: var(--muted); }
.output video, .output img { max-width: 100%; border-radius: 8px; }
.output .status {
  text-align: center;
  color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-actions { margin-top: 0.85rem; display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.result-actions a, .result-actions button {
  font-size: 0.8rem; color: var(--accent); text-decoration: none;
  border: 1px solid var(--line); padding: 0.35rem 0.7rem; border-radius: 6px;
  background: transparent;
}
.cost { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }

/* ---------------- LIBRERIA ---------------- */
.lib-toolbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.lib-toolbar h2 { margin: 0; flex: 0 0 auto; }
.lib-filters, .tag-manager { display: flex; gap: 0.5rem; align-items: center; }
.lib-filters select, .tag-manager input[type="text"] { width: auto; }
.tag-manager input[type="color"] {
  width: 36px; height: 36px; padding: 2px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
}
.tag-manager { margin-left: auto; }

.lib-subtabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.lib-subtab {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  padding: 0.45rem 0.9rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem;
}
.lib-subtab:hover { color: var(--text); }
.lib-subtab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.lib-grid .placeholder { grid-column: 1/-1; color: var(--muted); text-align: center; padding: 2rem; }
.asset-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.asset-media { aspect-ratio: 16/9; background: #000; display: flex; align-items: center; justify-content: center; }
.asset-media img, .asset-media video { width: 100%; height: 100%; object-fit: contain; }
.asset-body { padding: 0.6rem 0.7rem; display: flex; flex-direction: column; gap: 0.5rem; }
.asset-prompt { font-size: 0.78rem; color: var(--muted); max-height: 2.6em; overflow: hidden; }
.asset-meta { display: flex; gap: 0.3rem 0.4rem; font-size: 0.7rem; color: var(--muted); align-items: center; flex-wrap: wrap; }
.badge { font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: var(--panel-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.badge.saved { color: var(--accent-2); }
.badge.unsaved { color: #f59e0b; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip-tag {
  font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  cursor: pointer; border: 1.5px solid transparent; user-select: none;
  background: var(--panel-2); color: var(--muted);
}
.chip-tag.active { color: #0e0f13; font-weight: 700; }
.chip-tag .x { margin-left: 0.25rem; opacity: 0.6; }
.asset-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.asset-actions button, .asset-actions a {
  font-size: 0.72rem; padding: 0.25rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  text-decoration: none; cursor: pointer;
}
.asset-actions button:hover { border-color: var(--accent); }
.asset-actions .danger:hover { border-color: var(--error); color: var(--error); }

/* ---------------- MONTAGGIO ---------------- */
.montage-grid {
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 1100px) { .montage-grid { grid-template-columns: 1fr; } }
.montage-source, .montage-timeline {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem;
}
.montage-source h2, .montage-timeline h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.montage-timeline h3 { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; color: var(--muted); }
.mtg-source-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; max-height: 520px; overflow-y: auto; }
.mtg-src-item {
  display: flex; gap: 0.5rem; align-items: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem;
}
.mtg-src-item:hover { border-color: var(--accent); }
.mtg-src-item img, .mtg-src-item video { width: 48px; height: 36px; object-fit: cover; border-radius: 4px; background: #000; }
.mtg-src-item .lbl { font-size: 0.72rem; color: var(--muted); flex: 1; overflow: hidden; }
.mtg-src-item .type { font-size: 0.62rem; padding: 0.05rem 0.3rem; border-radius: 4px; background: var(--bg); }

.mtg-timeline-list { display: flex; flex-direction: column; gap: 0.5rem; min-height: 80px; }
.mtg-timeline-list .placeholder { color: var(--muted); text-align: center; padding: 1rem; font-size: 0.85rem; }
.mtg-clip {
  display: flex; gap: 0.5rem; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.5rem;
}
.mtg-clip img, .mtg-clip video { width: 52px; height: 38px; object-fit: cover; border-radius: 4px; background: #000; }
.mtg-clip .info { flex: 1; font-size: 0.72rem; color: var(--muted); }
.mtg-clip .dur { width: 56px; }
.mtg-clip .dur input { padding: 0.3rem; font-size: 0.75rem; }
.mtg-clip .reorder { display: flex; flex-direction: column; }
.mtg-clip .reorder button, .mtg-clip .rm {
  background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 0 0.2rem;
}
.mtg-clip .rm:hover { color: var(--error); }
input[type="range"] { width: 100%; }
.montage-output { min-height: 240px; }

/* ---------------- CRONOLOGIA ---------------- */
.hist-list { display: flex; flex-direction: column; gap: 0.6rem; }
.hist-list .placeholder { color: var(--muted); text-align: center; padding: 2rem; }
.hist-item {
  display: flex; gap: 0.85rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.85rem;
}
.hist-thumb { width: 80px; height: 56px; border-radius: 6px; object-fit: cover; background: #000; flex: 0 0 auto; }
.hist-main { flex: 1; min-width: 0; }
.hist-meta-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; flex-wrap: wrap; }
.hist-mode { font-size: 0.68rem; padding: 0.1rem 0.45rem; border-radius: 4px; background: var(--accent); color: #fff; }
.hist-params { font-size: 0.7rem; color: var(--muted); }
.hist-date { font-size: 0.68rem; color: var(--muted); margin-left: auto; }
.hist-prompt { font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.hist-actions button {
  font-size: 0.74rem; padding: 0.35rem 0.6rem; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer;
}
.hist-actions .reuse:hover { border-color: var(--accent); color: var(--accent); }
.hist-actions .copy:hover { border-color: var(--accent-2); color: var(--accent-2); }

/* ---------------- CODA ---------------- */
.queue-badge {
  font-size: 0.75rem; padding: 0.3rem 0.6rem; border-radius: 999px;
  background: rgba(245,158,11,0.15); color: #f59e0b; white-space: nowrap;
}
.job-status {
  font-size: 0.68rem; padding: 0.12rem 0.5rem; border-radius: 999px; font-weight: 700; color: #0e0f13;
}
.job-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }

/* ---------------- STATISTICHE token/costo ---------------- */
.stats-bar { display: flex; gap: 0.85rem; flex-wrap: wrap; margin: 0.5rem 0 1.25rem; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.75rem 1.1rem; min-width: 140px;
}
.stat-card .stat-val { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.stat-card .stat-lbl { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }
.stat-card.accent .stat-val { color: var(--accent-2); }
.job-cost { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
.hist-meta-row .hist-user { font-size: 0.68rem; color: var(--accent-2); }
.hist-meta-row .hist-time { font-size: 0.68rem; color: var(--muted); }

/* Countdown scadenza link */
.countdown { font-size: 0.66rem; padding: 0.08rem 0.4rem; border-radius: 999px; background: rgba(245,158,11,0.15); color: #f59e0b; white-space: nowrap; }
.countdown.expired { background: rgba(255,107,107,0.15); color: var(--error); }

/* Admin utenti */
.admin-users { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-row {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.9rem;
}
.admin-row .ad-email { flex: 1; min-width: 180px; font-size: 0.85rem; }
.admin-row .ad-meta { font-size: 0.68rem; color: var(--muted); }
.admin-row.disabled { opacity: 0.55; }
.badge.role-admin { color: #fff; background: var(--accent); }
.badge.seed { color: var(--accent-2); }

/* Preview modal */
.preview-body { padding: 1rem 1.25rem; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.6rem; max-height: 78vh; overflow: hidden; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 62vh; min-height: 0; flex: 1 1 auto; object-fit: contain; border-radius: 8px; }
.asset-media { cursor: zoom-in; }

/* Tabella costi dettaglio */
.cost-row { display: flex; gap: 0.75rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.7rem; font-size: 0.76rem; }
.cost-row .cr-grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.cost-row .cr-amt { font-weight: 700; color: var(--brand); }
.cost-row .badge { font-size: 0.62rem; }

/* ===========================================================================
   RIFINITURE EDITORIALI FRAMEWORKS (override coerenti su tutti i componenti)
   =========================================================================== */
.inputs, .output, .modal-card {
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}
.inputs h2, .lib-toolbar h2 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }

/* Campi: focus magenta con anello morbido */
textarea, input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--surface-2); border-color: var(--line); border-radius: 10px;
  transition: border-color .12s, box-shadow .12s;
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(190,0,255,0.16);
}
label { font-weight: 500; letter-spacing: 0.01em; }

/* Bottoni */
button.primary, .login-card button[type="submit"] {
  background: var(--brand); border-radius: 11px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 6px 18px rgba(190,0,255,0.28);
}
button.primary:hover, .login-card button[type="submit"]:hover { filter: brightness(1.06); box-shadow: 0 8px 24px rgba(190,0,255,0.36); }
button.ghost { border-radius: 10px; }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }
.mini-btn, .info-btn:hover { color: var(--brand); }
.mini-btn:hover, .info-btn:hover { border-color: var(--brand); }

/* Badge / chip / pill in chiave brand */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.dz-preview .chip { background: rgba(190,0,255,0.10); color: var(--brand); }
.queue-badge {
  font-size: 0.6rem; font-weight: 700; padding: 0.06rem 0.4rem; border-radius: 999px;
  background: var(--brand); color: #fff; margin-left: auto;
}

/* Tab interni (sotto-tab libreria, filtri) restano a pillola magenta */
.lib-subtab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Modali più morbide */
.modal { background: rgba(8,8,12,0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-card { border-radius: var(--radius-lg); }

/* Spinner + progress in magenta */
.spinner { border-top-color: var(--brand); }
.dz-bar { background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* Card libreria / item: hover col bordo brand */
.asset-card, .hist-item { border-radius: var(--radius-lg); transition: border-color .12s, transform .12s; }
.asset-card:hover { border-color: var(--line-strong); }

/* Selezione testo on-brand */
::selection { background: rgba(190,0,255,0.22); }

/* Scrollbar sottile */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* ---------------- GHOST MODE ---------------- */
.ico[data-ico="eye"]   { --ico: url(/assets/icons/eye.svg); }
.ico[data-ico="close"] { --ico: url(/assets/icons/close.svg); }
.ghost-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 0.35rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.ghost-toggle .ico { width: 15px; height: 15px; }
.ghost-toggle:hover { border-color: var(--text); color: var(--text); }
.ghost-toggle.on { background: #0b0b0e; color: #fff; border-color: #0b0b0e; }
.ghost-toggle.on:hover { filter: brightness(1.15); }
/* Miniatura nera per i contenuti privati altrui */
.ghost-tile {
  display: flex; align-items: center; justify-content: center;
  background: #0a0a0a; color: rgba(255,255,255,0.55); font-size: 1.1rem;
}
.hist-thumb.ghost-tile { width: 86px; height: 64px; border-radius: 8px; }
.asset-media .ghost-tile, .picker-item .ghost-tile { width: 100%; height: 100%; }
.badge.ghost { background: #0b0b0e; color: #fff; border-color: #0b0b0e; }
.badge.warn { background: rgba(245,158,11,0.15); color: #b45309; border-color: rgba(245,158,11,0.4); }
:root[data-theme="dark"] .badge.warn { color: #fbbf24; }
.cost-row.masked .cr-grow { font-style: italic; }

/* Ghost mode attivo: cornice magenta + etichetta, così non resta acceso per sbaglio */
body.ghost-on::after {
  content: ""; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  border: 3px solid var(--brand);
  box-shadow: inset 0 0 0 1px rgba(190,0,255,0.35), inset 0 0 40px rgba(190,0,255,0.12);
  animation: ghostPulse 2.4s ease-in-out infinite;
}
body.ghost-on::before {
  content: "🔒 GHOST MODE"; position: fixed; z-index: 9999; pointer-events: none;
  left: 50%; bottom: 14px; transform: translateX(-50%);
  background: #0b0b0e; color: #fff; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 0.3rem 0.8rem; border-radius: 999px; border: 1px solid var(--brand);
  box-shadow: 0 6px 20px rgba(190,0,255,0.4);
}
@keyframes ghostPulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(190,0,255,0.35), inset 0 0 40px rgba(190,0,255,0.10); }
  50%      { box-shadow: inset 0 0 0 1px rgba(190,0,255,0.55), inset 0 0 60px rgba(190,0,255,0.22); }
}

/* ---------------- CONFORMITÀ VIDEO ---------------- */
.conform {
  margin-top: 0.6rem; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.7rem 0.85rem; background: var(--surface-2);
}
.conform.has-issues { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.06); }
.conform-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.conform-title { font-size: 0.82rem; font-weight: 600; }
.conform-ok { font-size: 0.72rem; color: var(--ok); font-weight: 600; }
.conform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.9rem; margin-top: 0.55rem; }
.conform-item { font-size: 0.72rem; color: var(--muted); }
.conform-item.ok { color: var(--ok); }
.conform-item.bad { color: #b45309; }
:root[data-theme="dark"] .conform-item.bad { color: #fbbf24; }
.conform-item b { color: var(--text); font-weight: 600; }
.conform-form { margin-top: 0.7rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.conform-form label { margin: 0 0 0.25rem; font-size: 0.72rem; }
@media (max-width: 560px) { .conform-grid { grid-template-columns: 1fr; } }

/* Trim visuale nel conforming */
.trim-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; }
.trim-video { width: 100%; max-height: 220px; border-radius: 8px; background: #000; display: block; }
.trim-controls { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.trim-sliders { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.trim-sliders input[type="range"] { width: 100%; accent-color: var(--brand); }
.trim-readout { font-size: 0.74rem; color: var(--muted); margin-top: 0.4rem; text-align: center; }
.trim-readout b { color: var(--text); font-family: ui-monospace, Menlo, monospace; }
.trim-over { color: var(--error) !important; }

/* Report QA (dedup frame) */
.qa-report {
  width: 100%; margin-top: 0.7rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); padding: 0.75rem 0.95rem; text-align: left;
}
.qa-head { font-size: 0.82rem; margin-bottom: 0.5rem; }
.qa-head b { color: var(--brand); }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 1.2rem; }
.qa-row { display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.74rem; color: var(--muted); }
.qa-row b { color: var(--text); font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.qa-arrow { color: var(--brand); font-weight: 700; }
.qa-note { margin-top: 0.5rem; font-size: 0.68rem; color: var(--muted); }
.qa-dl {
  display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.6rem;
  font-size: 0.78rem; font-weight: 600; text-decoration: none;
  background: var(--brand); color: #fff; padding: 0.45rem 0.9rem; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(190,0,255,0.3);
}
.qa-dl:hover { filter: brightness(1.08); }

/* Pannello di revisione QA (proposta frame + selezione manuale) */
.qa-panel {
  width: 100%; margin-top: 0.7rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); padding: 0.75rem 0.95rem; text-align: left;
}
/* Pagina QA video: player grande + colonna di lavoro */
.qa-page { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); gap: 1.4rem; align-items: start; }
.qa-stage { min-width: 0; }
.qa-stage .placeholder { border: 1.5px dashed var(--line); border-radius: var(--radius-lg); padding: 4rem 2rem; text-align: center; color: var(--muted); line-height: 1.7; }
.qa-workbench {
  position: sticky; top: 84px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 1rem 1.1rem;
  max-height: calc(100vh - 110px); overflow-y: auto;
}
.qa-workbench .qa-panel { border: none; background: transparent; padding: 0; margin-top: 0.8rem; }
.qa-workbench .qa-fchips { max-height: 38vh; }
.qa-workbench .qa-report { margin-top: 0.8rem; }
.qa-src { font-size: 0.78rem; word-break: break-all; }
.st-busy {
  margin-top: 0.5rem; font-size: 0.74rem; font-weight: 600;
  background: rgba(245,158,11,0.12); color: #b45309;
  border: 1px solid rgba(245,158,11,0.4); border-radius: 10px; padding: 0.45rem 0.7rem;
  animation: ghostPulse 2.4s ease-in-out infinite;
}
:root[data-theme="dark"] .st-busy { color: #fbbf24; }
/* Timeline sotto il player: playhead + marker IN + segmenti di taglio */
#st-timeline { margin-top: 0.5rem; }
.stl-bar {
  position: relative; height: 22px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden;
}
.stl-cuts { position: absolute; inset: 0; }
.stl-cut {
  position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(45deg, rgba(209,31,31,0.45), rgba(209,31,31,0.45) 6px, rgba(209,31,31,0.25) 6px, rgba(209,31,31,0.25) 12px);
  border-left: 1px solid rgba(209,31,31,0.8); border-right: 1px solid rgba(209,31,31,0.8);
}
.stl-in {
  position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--brand);
}
.stl-in::before { content: "IN"; position: absolute; top: -1px; left: 3px; font-size: 0.55rem; font-weight: 800; color: var(--brand); }
.stl-play { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); pointer-events: none; }
.stl-fix {
  position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(45deg, rgba(190,0,255,0.4), rgba(190,0,255,0.4) 6px, rgba(0,207,255,0.3) 6px, rgba(0,207,255,0.3) 12px);
  border-left: 1px solid var(--brand); border-right: 1px solid var(--brand);
}
.qa-chip-fix { background: rgba(0,207,255,0.10); border-color: rgba(0,207,255,0.4); color: #0891b2; }
:root[data-theme="dark"] .qa-chip-fix { color: #67e8f9; }
.stl-legend { font-size: 0.68rem; margin-top: 0.3rem; text-align: center; }
.stl-ctrl { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.45rem; justify-content: center; }
.stl-ctrl .mini-btn { font-size: 0.76rem; padding: 0.3rem 0.65rem; }
.stl-chips { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; }
/* Sezioni dello Studio (accordion nativi) */
.st-sec { border-top: 1px solid var(--line); padding: 0.55rem 0; }
.st-sec:first-of-type { border-top: none; }
.st-sec summary {
  cursor: pointer; font-size: 0.85rem; font-weight: 700; letter-spacing: -0.01em;
  list-style: none; display: flex; align-items: center; gap: 0.4rem; user-select: none;
}
.st-sec summary::-webkit-details-marker { display: none; }
.st-sec summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.st-sec:not([open]) summary::after { transform: rotate(-90deg); }
.st-sec > *:not(summary) { margin-top: 0.45rem; }
.st-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.15rem 0.9rem; }
.st-mrow { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.72rem; color: var(--muted); }
.st-mrow b { color: var(--text); font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.st-confbox .conform-grid { grid-template-columns: 1fr; }
@media (max-width: 1000px) { .qa-page { grid-template-columns: 1fr; } .qa-workbench { position: static; max-height: none; } }

.qa-hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.35rem; line-height: 1.5; }
.qa-fchips {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.6rem;
  max-height: 180px; overflow-y: auto; padding: 2px;
}
.qa-fchip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 0.1rem 0.45rem 0.1rem 0.35rem;
  background: var(--surface);
}
.qa-fchip input { margin: 0; accent-color: var(--brand); }
.qa-fchip .qa-fseek {
  border: none; background: none; cursor: pointer; padding: 0;
  font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; color: var(--text);
}
.qa-fchip:hover { border-color: var(--line-strong); }
.qa-fchip.sel { border-color: var(--brand); }
.qa-fchip.sel .qa-fseek { color: var(--brand); font-weight: 700; }
.qa-fchip.showing-prev { background: rgba(190,0,255,0.10); }
.qa-fchip.showing-prev .qa-fseek::after { content: " ◂prev"; font-size: 0.6rem; color: var(--muted); }
.qa-fchip:has(input:not(:checked)) { opacity: 0.45; }
.qa-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.7rem; flex-wrap: wrap; }
.qa-manual-list { margin-top: 0.5rem; display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.qa-mlabel { font-size: 0.7rem; color: var(--muted); }
.qa-chip {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.68rem;
  font-family: ui-monospace, Menlo, monospace;
  background: rgba(190,0,255,0.10); color: var(--brand); border: 1px solid rgba(190,0,255,0.3);
  padding: 0.12rem 0.45rem; border-radius: 999px;
}
.qa-chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 0.8rem; padding: 0; }
/* Pulsante RIFE premium: gradiente brand */
.qa-rife {
  border: none; border-radius: 11px; padding: 0.55rem 0.9rem; font-weight: 600; font-size: 0.82rem;
  color: #fff; cursor: pointer;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(190,0,255,0.3);
}
.qa-rife:hover { filter: brightness(1.08); }
.qa-rife:disabled { opacity: 0.6; cursor: wait; }
.qa-premium {
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(255,255,255,0.25); padding: 0.1rem 0.35rem; border-radius: 999px; margin-left: 0.25rem;
}
@media (max-width: 560px) { .qa-grid { grid-template-columns: 1fr; } }

/* ---------------- PLAYER PRO (Plyr) ---------------- */
#preview-modal .modal-card { width: min(1120px, 96vw); }
.pro-player { width: 100%; }
.plyr { --plyr-color-main: var(--brand); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.plyr__control--overlaid { background: var(--brand); }
.pp-toolbar { display: flex; gap: 0.6rem; align-items: center; justify-content: center; margin-top: 0.6rem; }
.pp-toolbar button {
  font-size: 0.74rem; font-weight: 600; padding: 0.32rem 0.7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.pp-toolbar button:hover { border-color: var(--brand); color: var(--brand); }
.pp-tc { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.74rem; color: var(--muted); min-width: 74px; text-align: center; }

/* Editor audio (tab Acting): selezione e taglio a max 30s per OmniHuman */
.audio-editor {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel-2);
}
.audio-editor .ae-head { display: flex; justify-content: space-between; align-items: baseline; }
.audio-editor audio { width: 100%; }
.audio-editor .ae-slider { flex: 1; min-width: 0; }
.audio-editor input[type="range"] { width: 100%; accent-color: var(--accent); }
.audio-editor .ae-over { color: var(--error); font-weight: 600; }
.audio-editor .ae-wave {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 86px;
  cursor: crosshair;
  overflow: hidden;
}
.audio-editor .ae-segs { display: flex; flex-wrap: wrap; gap: 6px; }
.audio-editor .ae-seg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(168,85,247,0.14);
}
.audio-editor .ae-seg button {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1; padding: 0;
}
.audio-editor .ae-seg button:hover { color: var(--error); }
.audio-editor .ae-hint { font-size: 11.5px; margin: 0; }

/* Selettore progetto (appbar) + gestione progetti (admin) */
.project-select {
  max-width: 220px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: inherit;
  font-size: 13px;
}
.prj-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 8px; vertical-align: baseline;
}
.prj-row { flex-wrap: wrap; }
.prj-members {
  flex-basis: 100%;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  padding: 10px 4px 4px;
  border-top: 1px dashed var(--line);
  margin-top: 8px;
}
.prj-members .prj-save { margin-left: auto; }
.badge.prj { background: rgba(59,130,246,0.18); }
.prj-member-search, #admin-user-search {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: inherit;
  font-size: 13px;
}
.prj-members .prj-member-search { flex-basis: 100%; }

/* Multi-select progetti (tab Costi) */
.multi-select { position: relative; display: inline-block; }
.ms-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 260px; max-height: 320px; overflow: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--panel-solid, #17171f);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
.ms-actions { display: flex; gap: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.ms-panel .check { white-space: nowrap; }
.asset-card { position: relative; }
.asset-prj-panel { position: fixed; z-index: 90; right: auto; top: auto; }
.active-filter { outline: 1px solid var(--accent); }


/* Prompt nell'anteprima: box compatto e scrollabile, non ruba spazio al media */
.preview-prompt {
  flex: 0 0 auto;
  width: 100%;
  display: flex; align-items: flex-start; gap: 0.5rem;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.5rem 0.7rem;
}
.preview-prompt .pp-text {
  flex: 1; font-size: 0.78rem; color: var(--muted);
  max-height: 5.2em; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.preview-prompt .pp-copy { flex: 0 0 auto; }
#preview-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Thumbnail nelle card: overlay ▶ per i video */
.asset-media, .picker-item, .mtg-src-item { position: relative; }
.play-ico {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 8px rgba(0,0,0,0.7); pointer-events: none;
}

/* ---------------- LIBRERIA & PICKER: layout uniforme e stabile ----------------
   I media (thumb o fallback) sono ancorati alla cella con position:absolute:
   qualunque sia la dimensione naturale dell'immagine, la griglia resta allineata. */
.picker-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.6rem; max-height: 52vh; }
.picker-grid .picker-item {
  display: flex; flex-direction: column; overflow: hidden; padding: 0;
}
.picker-item .pk-media {
  position: relative; aspect-ratio: 16/9; overflow: hidden; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; background: #000;
}
.picker-item .pk-media img, .picker-item .pk-media video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.picker-item .pk-media .pk-hoverv { z-index: 2; }
.picker-item .pk-ov {
  position: absolute; right: 4px; bottom: 4px; z-index: 3;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em;
  background: rgba(0,0,0,0.72); color: #fff; padding: 1px 6px; border-radius: 6px;
  pointer-events: none;
}
.picker-item .pk-info { padding: 5px 8px 6px; min-width: 0; }
.picker-item .pk-title {
  font-size: 0.68rem; line-height: 1.25; max-height: 2.5em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.picker-item .pk-meta { font-size: 0.62rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-card .asset-media { position: relative; aspect-ratio: 16/9; overflow: hidden; }
.asset-card .asset-media img, .asset-card .asset-media video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block;
}
.asset-card .asset-media .ghost-tile { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.mtg-src-item img, .mtg-src-item video { flex: 0 0 48px; }

/* Ricerca + paginazione */
.load-more { grid-column: 1/-1; justify-self: center; margin: 0.4rem 0 0.2rem; }
#lib-search, #pick-search {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel-2); color: inherit; font-size: 13px; min-width: 160px;
}
.badge.eng { background: rgba(190,0,255,0.12); }

/* ---------------- TAB FLUIDIFICA: player + lista + coda in pagina ---------------- */
.fluid-list { display: flex; flex-direction: column; gap: 0.35rem; }
.fluid-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-2);
  cursor: pointer; font-size: 0.78rem; transition: border-color 0.15s, background 0.15s;
}
.fluid-item:hover { border-color: var(--brand); }
.fluid-item.sel { border-color: var(--brand); background: rgba(190,0,255,0.08); box-shadow: 0 0 0 1px var(--brand) inset; }
.fluid-item-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fluid-item button {
  flex: 0 0 auto; border: none; background: none; color: var(--muted);
  font-size: 0.9rem; cursor: pointer; padding: 0 2px; line-height: 1;
}
.fluid-item button:hover { color: #ef4444; }
.fluid-cap {
  font-size: 0.74rem; color: var(--muted); margin-bottom: 0.35rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#fluid-stage { display: flex; flex-direction: column; }
#fluid-stage .pro-player { width: 100%; }
#fluid-queue { display: flex; flex-direction: column; gap: 0.35rem; }
.fluid-job {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); font-size: 0.74rem;
}
.fluid-job-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fluid-job .reuse, .fluid-job .del { padding: 2px 7px; font-size: 0.72rem; }

/* Timeline zone nella tab Fluidifica (riusa gli stili .stl-*) */
#fl-timeline { margin-top: 0.5rem; width: 100%; }


/* Fluidifica: selezione esplicita del video in lavorazione */
.fluid-item-play { flex: 0 0 auto; font-size: 0.72rem; color: var(--muted); }
.fluid-item.sel .fluid-item-play { color: var(--brand); }
.fluid-badge {
  flex: 0 0 auto; font-size: 0.58rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--brand); border: 1px solid var(--brand);
  border-radius: 999px; padding: 1px 7px; background: rgba(190,0,255,0.08);
}

/* ---------------- CONFRONTO PRIMA/DOPO (split screen con tendina) ---------------- */
.cmp-wrap { width: 100%; }
.cmp-stage {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #000;
  border-radius: 10px; overflow: hidden; touch-action: none; user-select: none;
}
.cmp-stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
}
.cmp-b { z-index: 2; }
.cmp-divider {
  position: absolute; top: 0; bottom: 0; left: 50%; z-index: 4; width: 2px;
  background: var(--brand); cursor: ew-resize;
  box-shadow: 0 0 8px rgba(190,0,255,0.6);
}
.cmp-divider::before { /* zona di presa più larga della linea */
  content: ""; position: absolute; top: 0; bottom: 0; left: -10px; right: -10px;
}
.cmp-handle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5); pointer-events: none;
}
.cmp-lab {
  position: absolute; top: 8px; z-index: 3; font-size: 0.62rem; font-weight: 800;
  letter-spacing: 0.06em; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.65); color: #fff; pointer-events: none;
}
.cmp-lab-a { left: 8px; }
.cmp-lab-b { right: 8px; z-index: 3; }
.cmp-ctrl {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
}
.cmp-ctrl .cmp-seek { flex: 1; accent-color: var(--brand); }
.cmp-ctrl .cmp-tc { font-size: 0.7rem; font-variant-numeric: tabular-nums; min-width: 62px; text-align: center; }
.cmp-ctrl .cmp-speed { width: auto; padding: 4px 8px; font-size: 0.74rem; }

/* Anteprima: pulsante "Riusa e modifica" accanto al prompt */
.preview-prompt .pp-reuse { flex: 0 0 auto; padding: 6px 12px; font-size: 0.76rem; width: auto; margin: 0; }

/* ==================== WORKFLOW (pipeline di progetto) ==================== */
.wf-topbar { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.wf-topbar select { width: auto; min-width: 180px; }
.wf-topbar .ghost, .wf-viewtoggle button { width: auto; padding: 6px 12px; font-size: 0.78rem; }
.wf-viewtoggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.wf-viewtoggle button { border: none; background: var(--panel-2); cursor: pointer; color: var(--muted); }
.wf-viewtoggle button.active { background: var(--brand); color: #fff; }
.wf-pipeline { display: flex; gap: 0.8rem; align-items: flex-start; overflow-x: auto; padding-bottom: 0.8rem; }
.wf-col {
  flex: 0 0 250px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.55rem; display: flex; flex-direction: column; gap: 0.55rem;
}
.wf-col-head { display: flex; align-items: center; justify-content: space-between; }
.wf-col-title { font-size: 0.8rem; font-weight: 800; cursor: default; }
.wf-col-del { border: none; background: none; color: var(--muted); cursor: pointer; }
.wf-newshot { flex: 0 0 auto; align-self: flex-start; width: auto; }
.wf-add { width: 100%; font-size: 0.74rem; padding: 6px; }
.wf-card { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.wf-card.stale { border-color: #f59e0b; box-shadow: 0 0 0 1px #f59e0b inset; }
.wf-card-media { position: relative; aspect-ratio: 16/9; background: #000; cursor: pointer; }
.wf-card-media img, .wf-card-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wf-nomedia { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--muted); }
.wf-stale-badge {
  position: absolute; top: 5px; left: 5px; z-index: 2; font-size: 0.58rem; font-weight: 800;
  background: #f59e0b; color: #000; padding: 1px 7px; border-radius: 999px;
}
.wf-kind { position: absolute; right: 5px; bottom: 5px; z-index: 2; font-size: 0.58rem; background: rgba(0,0,0,0.7); color: #fff; padding: 1px 6px; border-radius: 6px; }
.wf-card-body { padding: 6px 8px 7px; }
.wf-card-title { font-size: 0.68rem; line-height: 1.25; max-height: 2.5em; overflow: hidden; }
.wf-vpills { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.wf-vpill { border: 1px solid var(--line-strong); background: var(--panel-2); border-radius: 999px; font-size: 0.62rem; padding: 0 7px; cursor: pointer; color: var(--muted); }
.wf-vpill.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 800; }
.wf-card-actions { display: flex; gap: 4px; margin-top: 5px; }
.wf-card-actions button {
  border: 1px solid var(--line-strong); background: var(--panel-2); border-radius: 7px;
  font-size: 0.72rem; padding: 2px 7px; cursor: pointer; color: inherit;
}
.wf-card-actions button:hover { border-color: var(--brand); }
.wf-cbadge { font-style: normal; font-size: 0.6rem; color: var(--brand); }
/* canvas */
.wf-canvas { position: relative; min-height: 60vh; overflow: auto; background:
  radial-gradient(circle, var(--line) 1px, transparent 1px); background-size: 26px 26px;
  border: 1px solid var(--line); border-radius: 12px; }
.wf-cnode { position: absolute; width: 230px; cursor: grab; z-index: 2; }
.wf-cnode:active { cursor: grabbing; z-index: 3; }
.wf-edges { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.wf-edges path { fill: none; stroke: var(--brand); stroke-width: 2; opacity: 0.55; }

/* --- CANVAS A NODI: porte, fili, selezione ------------------------------- */
/* Zona di click generosa e invisibile sotto ogni filo: centrare una curva
   sottile col mouse è frustrante, così bastano ~14px di tolleranza. */
.wf-edges .wf-edge-hit {
  stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer;
}
.wf-edges .wf-edge-hit:hover + .wf-edge { stroke-width: 3.5; opacity: 1; }
/* colori per famiglia di ruolo: si legge a colpo d'occhio cosa entra dove */
.wf-edges .wf-edge.role-first { stroke: #4ade80; opacity: .8; }
.wf-edges .wf-edge.role-last  { stroke: #f472b6; opacity: .8; }
.wf-edges .wf-edge.role-ref   { stroke: var(--brand); opacity: .6; }
.wf-edges .wf-edge.role-vref  { stroke: #38bdf8; opacity: .7; }
.wf-edges .wf-edge.role-src   { stroke: #fbbf24; opacity: .8; }
.wf-edges .wf-edge.role-mask  { stroke: #a78bfa; opacity: .8; stroke-dasharray: 5 4; }
.wf-edges .wf-edge-ghost {
  stroke: var(--brand); stroke-width: 2.5; stroke-dasharray: 6 5; opacity: .9; fill: none;
}

.wf-port { position: absolute; z-index: 5; cursor: crosshair; }
.wf-port-out {
  right: -9px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px rgba(108, 140, 255, .25);
}
.wf-port-out:hover, .wf-port.hot { box-shadow: 0 0 0 5px rgba(108, 140, 255, .45); }
.wf-ports-in {
  position: absolute; left: -10px; top: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 5px;
}
.wf-port-in {
  position: relative; display: flex; align-items: center; gap: 5px;
}
.wf-port-in .wf-port-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px;
  background: var(--panel); border: 2px solid var(--muted);
}
.wf-port-in.filled .wf-port-dot { background: var(--brand); border-color: var(--brand); }
.wf-port-in.over .wf-port-dot { background: var(--warn, #f59e0b); border-color: var(--warn, #f59e0b); }
.wf-port-in.over .wf-port-lbl { color: var(--warn, #f59e0b); border-color: var(--warn, #f59e0b); opacity: 1; }
.wf-port-in.hot .wf-port-dot { box-shadow: 0 0 0 5px rgba(108, 140, 255, .45); }
/* l'etichetta compare all'avvicinarsi: a riposo il grafo resta pulito */
.wf-port-in .wf-port-lbl {
  position: absolute; right: calc(100% + 6px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: .62rem; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 6px; color: var(--muted);
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.wf-cnode:hover .wf-port-lbl, .wf-canvas.linking .wf-port-lbl { opacity: 1; }
.wf-canvas.linking { cursor: crosshair; }
.wf-canvas.linking .wf-port-in .wf-port-dot { border-color: var(--brand); }

.wf-cnode.selected > .wf-card { outline: 2px solid var(--brand); outline-offset: 2px; }
.wf-band {
  position: absolute; z-index: 6; pointer-events: none;
  border: 1px dashed var(--brand); background: rgba(108, 140, 255, .12); border-radius: 4px;
}
.wf-canvas-hint {
  font-size: .68rem; padding: .4rem .2rem 0; opacity: .75;
}
.wf-link-menu { max-height: 60vh; overflow: auto; min-width: 260px; }
.wf-link-port {
  font-size: .66rem; padding: .35rem .5rem .15rem; border-top: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel);
}
.wf-link-port:first-child { border-top: 0; }
.wf-canvas-bar {
  display: flex; justify-content: flex-end; gap: 0.6rem; margin-bottom: 0.55rem;
}
.wf-canvas-btn {
  width: auto !important; margin: 0 !important;
  padding: 10px 22px !important; font-size: 0.88rem !important; font-weight: 700;
}
/* modal regen + note */
#wf-regen-modal .modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(640px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
#wf-regen-modal .modal-body { padding: 0.9rem 1.25rem 1.1rem; overflow: auto; }
.wfr-notes { display: flex; flex-direction: column; margin: 0.2rem 0 0.35rem; }
.wf-notes-body { padding: 0.8rem 1.25rem 1rem; overflow: auto; }
.wf-notes-body h4 { margin: 0 0 0.4rem; font-size: 0.8rem; }
.wf-note, .wf-comment {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; margin-bottom: 0.35rem; font-size: 0.76rem;
}
.wf-note.done span { text-decoration: line-through; opacity: 0.55; }
.wf-comment.done { opacity: 0.55; }
.wf-note .ghost, .wf-comment .ghost { width: auto; padding: 1px 8px; font-size: 0.7rem; flex: 0 0 auto; }
/* copilot */
.cop-btn { width: auto !important; padding: 4px 10px !important; font-size: 0.72rem !important; margin-top: 0.3rem; }
.copilot-out {
  border: 1px solid var(--brand); border-radius: 10px; padding: 0.6rem 0.7rem; margin-top: 0.45rem;
  background: rgba(190,0,255,0.04);
}
.cop-head { font-size: 0.76rem; font-weight: 800; margin-bottom: 0.35rem; }
.cop-text { width: 100%; font-size: 0.78rem; }
.cop-changes { font-size: 0.7rem; color: var(--muted); margin: 0.35rem 0; }
.cop-actions { display: flex; gap: 0.45rem; align-items: center; margin-top: 0.3rem; }
.cop-actions .ghost { width: auto; padding: 5px 10px; font-size: 0.72rem; }
.cop-tips { margin-top: 0.45rem; font-size: 0.72rem; }
.cop-tips summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.cop-tips div { margin-top: 0.25rem; color: var(--muted); }

/* Pulizia scarti */
.cleanup-list { max-height: 46vh; overflow: auto; display: flex; flex-direction: column; gap: 0.3rem; }
.cleanup-item {
  display: flex; align-items: center; gap: 0.55rem; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; font-size: 0.74rem; cursor: pointer;
}
.cleanup-item:hover { border-color: var(--brand); }
.cl-thumb { flex: 0 0 52px; height: 32px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 5px; background: #000; }
.cl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cl-main { min-width: 0; line-height: 1.3; }

/* Workflow come piano di lavoro: banner contesto + menu step successivo */
.wf-pending {
  display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; font-weight: 600;
  background: rgba(190,0,255,0.1); border: 1px solid var(--brand); color: inherit;
  border-radius: 999px; padding: 3px 10px; margin-left: 0.6rem;
}
.wf-pending button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 0.8rem; padding: 0 2px; }
.wf-next-menu {
  position: fixed; z-index: 300; background: var(--panel); border: 1px solid var(--brand);
  border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.35); padding: 0.4rem; width: 290px;
  display: flex; flex-direction: column; gap: 2px;
}
.wf-next-head { font-size: 0.66rem; color: var(--muted); padding: 2px 8px 6px; }
.wf-next-menu button {
  border: none; background: none; text-align: left; padding: 7px 10px; border-radius: 8px;
  font-size: 0.78rem; cursor: pointer; color: inherit;
}
.wf-next-menu button:hover { background: rgba(190,0,255,0.1); }
.wf-next-btn { color: var(--brand) !important; font-weight: 800; }

/* Conferma risultato → workflow + evidenziazione del nuovo nodo */
.wf-confirm-btn { width: auto !important; margin: 0.4rem 0 0 !important; padding: 8px 16px !important; font-size: 0.8rem !important; }
.wf-flash { animation: wfFlash 1.1s ease-in-out 3; }
@keyframes wfFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(190,0,255,0); }
  50% { box-shadow: 0 0 0 4px rgba(190,0,255,0.65); }
}

/* ==================== HOME (dashboard di apertura) ==================== */
/* Canvas: pan libero + pill versione speciali */
.wf-canvas { cursor: grab; }
.wf-canvas.panning { cursor: grabbing; user-select: none; }
.wf-vadd { border-style: dashed !important; color: var(--brand) !important; }

/* Interventi/ricetta sulla card + drag full-card */
.wf-specs { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; cursor: pointer; }
.wf-spec {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.01em;
  background: rgba(190,0,255,0.09); border: 1px solid rgba(190,0,255,0.35);
  color: inherit; border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
.wf-specs:hover .wf-spec { border-color: var(--brand); }
.wf-recipe-table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
.wf-recipe-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.wf-recipe-table td:first-child { color: var(--muted); width: 42%; }
.wf-card { position: relative; }
.wf-card img, .wf-card video { -webkit-user-drag: none; user-select: none; }
/* Maniglia di trascinamento: visibile solo nel canvas, angolo alto-sinistra */
.wf-drag-handle { display: none; }
.wf-cnode .wf-drag-handle {
  display: flex; align-items: center; justify-content: center;
  position: absolute; bottom: -1px; right: -1px; z-index: 5;
  width: 28px; height: 28px; border-radius: 10px 0 10px 0;
  background: var(--brand); color: #fff; font-size: 0.9rem; line-height: 1;
  cursor: grab; box-shadow: 0 1px 6px rgba(0,0,0,0.35);
  touch-action: none;
}
.wf-cnode .wf-drag-handle:active { cursor: grabbing; }
.wf-cnode .wf-card-actions button, .wf-cnode .wf-vpill { cursor: pointer; }

/* Nodo AZIONE: l'intervento come elemento del grafo */
.wf-action-card {
  background: linear-gradient(180deg, rgba(190,0,255,0.10), rgba(190,0,255,0.03));
  border: 1.5px dashed var(--brand) !important;
  padding: 8px 10px 9px; border-radius: 12px;
}
.wf-action-head { font-size: 0.74rem; font-weight: 800; display: flex; align-items: center; gap: 5px; }
.wf-action-ico { color: var(--brand); }
.wf-action-prompt { font-size: 0.66rem; color: var(--muted); margin: 4px 0 2px; line-height: 1.3; max-height: 2.7em; overflow: hidden; font-style: italic; }
.wf-run-btn { color: #fff !important; background: var(--brand) !important; border-color: var(--brand) !important; font-weight: 800; }
.wf-link-on { color: var(--brand); font-weight: 700; }
.wf-run-spin {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--brand); border-top-color: transparent;
  animation: wfspin 0.9s linear infinite; margin-left: 4px;
}
@keyframes wfspin { to { transform: rotate(360deg); } }

/* Colori per famiglia di azione: il grafo si legge a colpo d'occhio */
.wf-action-card { --act: var(--brand); }
.wf-act-img   { --act: #f59e0b; } /* crea immagine — ambra */
.wf-act-t2v   { --act: #BE00FF; } /* text-to-video — viola brand */
.wf-act-cons  { --act: #00CFFF; } /* rendering consistente — ciano */
.wf-act-book  { --act: #22c55e; } /* primo/ultimo frame — verde */
.wf-act-edit  { --act: #f43f5e; } /* modifica video — rosso */
.wf-act-fluid { --act: #3b82f6; } /* fluidifica/QA — blu */
.wf-act-other { --act: #9aa0b4; } /* altro — grigio */
.wf-action-card {
  border-color: var(--act) !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--act) 14%, transparent), color-mix(in srgb, var(--act) 4%, transparent));
}
.wf-action-card .wf-action-ico { color: var(--act); }
.wf-action-card .wf-run-btn { background: var(--act) !important; border-color: var(--act) !important; }
.wf-action-card .wf-run-spin { border-color: var(--act); border-top-color: transparent; }
.wf-action-card .wf-spec { background: color-mix(in srgb, var(--act) 10%, transparent); border-color: color-mix(in srgb, var(--act) 40%, transparent); }
.wf-cnode .wf-action-card .wf-drag-handle { background: var(--act); }

/* ---------------- Annotazioni a penna sulle reference ---------------- */
.annot-body { padding: 0.8rem 1.1rem 1rem; overflow: auto; }
.annot-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.annot-group { display: inline-flex; gap: 4px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; }
.annot-group button {
  border: none; background: none; cursor: pointer; border-radius: 6px;
  width: 32px; height: 30px; font-size: 0.95rem; color: inherit;
}
.annot-group button.active { background: rgba(190,0,255,0.16); outline: 2px solid var(--brand); }
.annot-color { border-radius: 50% !important; width: 22px !important; height: 22px !important; margin: 4px; border: 2px solid transparent !important; }
.annot-color.active { outline: 2px solid var(--text); outline-offset: 2px; }
.annot-stage { display: flex; justify-content: center; background: #000; border-radius: 10px; overflow: hidden; }
#annot-canvas { display: block; touch-action: none; cursor: crosshair; max-width: 100%; }
.annot-tut { margin-top: 0.7rem; font-size: 0.78rem; }
.annot-tut summary { cursor: pointer; font-weight: 800; color: var(--brand); }
.annot-tut-body p { margin: 0.5rem 0; }
.annot-k { font-weight: 800; }
.annot-example {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem; font-size: 0.7rem; white-space: pre-wrap; font-family: ui-monospace, monospace;
}
.ref-pen {
  position: absolute; top: 3px; left: 3px; z-index: 3;
  border: none; border-radius: 6px; background: rgba(0,0,0,0.65); color: #fff;
  font-size: 0.72rem; padding: 2px 5px; cursor: pointer;
}
.ref-pen:hover { background: var(--brand); }
.ref-annot-badge {
  position: absolute; bottom: 3px; left: 3px; z-index: 2;
  font-size: 0.6rem; background: var(--brand); color: #fff; border-radius: 5px; padding: 1px 4px;
}

/* Asset autorizzati ModelArk (asset://) */
.bd-btn { width: auto !important; padding: 5px 12px !important; font-size: 0.74rem !important; margin-top: 0.35rem; }
.bd-list { display: flex; flex-direction: column; gap: 0.35rem; }
.bd-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 9px; font-size: 0.76rem;
}
.bd-ico { font-size: 1.05rem; }
.bd-main { flex: 1; min-width: 0; line-height: 1.3; }
.bd-item .ghost { width: auto; padding: 3px 10px; font-size: 0.72rem; }
.ref-asset { display: inline-flex; align-items: center; }
.ref-asset-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 72px; padding: 0 12px;
  border: 1.5px dashed var(--brand); border-radius: 8px; background: rgba(190,0,255,0.07);
  font-size: 0.72rem; font-weight: 700; max-width: 150px; text-align: center;
}

/* Registro asset: anteprime e barra quota */
.bd-bar { height: 6px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; margin-bottom: 0.7rem; }
.bd-bar-fill { height: 100%; transition: width 0.3s; }
.bd-thumb {
  flex: 0 0 46px; height: 40px; border-radius: 7px; overflow: hidden; background: #000;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.bd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bd-stale { color: #f59e0b; }

/* Ruoli e condivisione workflow */
.wf-role-badge {
  font-size: 0.66rem; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted);
}
.wf-role-badge.viewer { border-color: #f59e0b; color: #f59e0b; background: rgba(245,158,11,0.08); }
.wf-role-badge.editor { border-color: var(--brand); color: var(--brand); background: rgba(190,0,255,0.07); }
.sh-list { display: flex; flex-direction: column; gap: 0.3rem; }
.sh-list select { padding: 3px 8px; font-size: 0.74rem; }
/* Sola lettura: i comandi di modifica restano visibili ma spenti */
body.wf-readonly .wf-card-actions button:not([data-wfnotes]):not([data-wfab]):not([data-wfsib]),
body.wf-readonly .wf-vadd, body.wf-readonly .wf-add, body.wf-readonly #wf-newshot { opacity: 0.4; }

/* Copilot: riga pulsante + flag analisi reference */
.cop-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.3rem; }
.cop-row .cop-btn { margin-top: 0 !important; }
.cop-analyze { margin: 0 !important; font-size: 0.72rem; color: var(--muted); }
.cop-refs { margin: 0.35rem 0; font-size: 0.72rem; }
.cop-refs summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.cop-refs div { margin-top: 0.25rem; color: var(--muted); line-height: 1.35; }

/* ---------------- Gate di apertura: scelta del progetto ---------------- */
.prj-gate { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: rgba(8,8,12,0.7); }
.prj-gate-card {
  width: min(720px, 100%); max-height: 88vh; padding: 1.6rem 1.6rem 1.2rem;
  display: flex; flex-direction: column; gap: 1rem; overflow: auto;
}
.prj-gate-head { text-align: center; }
.prj-gate-head h2 { margin: 0 0 0.35rem; font-size: 1.4rem; }
.prj-gate-head p { margin: 0 auto; max-width: 34rem; font-size: 0.8rem; }
.prj-gate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.7rem; }
.prj-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem;
  padding: 0.9rem 1rem; border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--panel-2); cursor: pointer; text-align: left; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.prj-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.prj-card b { font-size: 0.9rem; }
.prj-card .muted { font-size: 0.68rem; }
.prj-dot { width: 12px; height: 12px; border-radius: 50%; margin-bottom: 0.3rem; }
.prj-card-new { border-style: dashed; border-color: var(--brand); align-items: center; justify-content: center; text-align: center; }
.prj-plus { font-size: 1.3rem; }
.prj-gate-foot { display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.prj-gate-foot .ghost { width: auto; padding: 7px 14px; font-size: 0.78rem; }

/* Gate bloccante: finché non si sceglie un progetto l'app resta chiusa */
body.prj-gated .sidebar,
body.prj-gated main,
body.prj-gated .appbar-right > *:not(#user-email):not(#logout),
body.prj-gated #sidebar-open,
body.prj-gated .section-title { visibility: hidden; }
body.prj-gated { overflow: hidden; }
.prj-gate-logo { display: block; width: 128px; height: 26px; margin: 0 auto 0.7rem; }
.prj-card-all { border-style: dashed; align-items: center; justify-content: center; text-align: center; }
.prj-card.disabled { opacity: 0.45; cursor: not-allowed; }
.prj-card.disabled:hover { border-color: var(--line-strong); transform: none; }

/* Badge sessione riservata */
.private-badge {
  font-size: 0.68rem; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  background: rgba(239,68,68,0.12); border: 1px solid #ef4444; color: #ef4444; white-space: nowrap;
}

/* ======================= GUIDA ======================= */
.guide-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 1.2rem; align-items: start; }
.guide-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: .5rem; }
.guide-nav input[type="search"] { width: 100%; }
.guide-idx {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: .5rem .6rem; cursor: pointer; color: inherit;
}
.guide-idx:hover { background: var(--panel-2, rgba(255,255,255,.04)); }
.guide-idx.active { background: var(--panel-2, rgba(108,140,255,.12)); border-color: var(--brand); }
.guide-idx span:last-of-type { display: flex; flex-direction: column; line-height: 1.25; }
.guide-idx b { font-size: .84rem; font-weight: 600; }
.guide-idx i { font-size: .68rem; opacity: .65; font-style: normal; }
.guide-idx-ico { font-size: 1.05rem; }
.guide-hit { margin-left: auto; font-size: .65rem; opacity: .6; font-style: normal; }
.guide-nav-foot { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.btn-like { display: inline-block; text-align: center; text-decoration: none; }

.guide-body { max-width: 860px; }
.guide-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .4rem; }
.guide-head-ico { font-size: 1.9rem; }
.guide-head h2 { margin: 0; }
.guide-content { line-height: 1.62; font-size: .9rem; }
.guide-content h3 { margin: 1.6rem 0 .5rem; font-size: 1rem; }
.guide-content p, .guide-content li { color: var(--text); }
.guide-content ol, .guide-content ul { padding-left: 1.2rem; }
.guide-content li { margin: .3rem 0; }
.guide-content code {
  background: var(--panel-2, rgba(255,255,255,.06)); padding: .1rem .35rem; border-radius: 5px; font-size: .84em;
}
.g-lead { font-size: .96rem; opacity: .9; border-left: 3px solid var(--brand); padding-left: .8rem; }
.g-tip {
  border: 1px solid var(--line); border-left: 3px solid #fbbf24; border-radius: 8px;
  padding: .65rem .8rem; margin: 1rem 0; font-size: .86rem; background: var(--panel-2, rgba(255,255,255,.03));
}
.g-table { width: 100%; border-collapse: collapse; margin: .8rem 0; font-size: .82rem; }
.g-table th { text-align: left; font-weight: 600; opacity: .7; font-size: .74rem; text-transform: uppercase; letter-spacing: .02em; }
.g-table th, .g-table td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; vertical-align: top; }
.g-table tr:last-child td { border-bottom: 0; }
.g-models td { white-space: nowrap; }
.g-models .g-best { white-space: normal; min-width: 220px; opacity: .8; }
.g-vendor { display: block; font-style: normal; font-size: .68rem; opacity: .55; }
.g-example { margin: .8rem 0; display: flex; flex-direction: column; gap: .4rem; }
.g-bad, .g-good { padding: .5rem .7rem; border-radius: 8px; font-size: .82rem; border: 1px solid var(--line); }
.g-bad { border-left: 3px solid #f87171; }
.g-good { border-left: 3px solid #4ade80; }
.g-prompt { border: 1px solid var(--line); border-radius: 8px; margin: .4rem 0; }
.g-prompt summary { cursor: pointer; padding: .5rem .7rem; font-weight: 600; font-size: .84rem; }
.g-prompt pre {
  margin: 0; padding: .2rem .8rem .8rem; white-space: pre-wrap; font-size: .78rem;
  line-height: 1.55; opacity: .85; font-family: inherit;
}
.g-dyn { min-height: 40px; }
.guide-pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
@media (max-width: 900px) {
  .guide-wrap { grid-template-columns: 1fr; }
  .guide-nav { position: static; }
}

/* ======================= TOUR GUIDATO ======================= */
#tour-layer { position: fixed; inset: 0; z-index: 9000; }
.tour-mask { position: absolute; inset: 0; background: rgba(6, 8, 14, .62); }
/* Il "buco" nella maschera è fatto con un'ombra enorme: così l'elemento
   evidenziato resta perfettamente leggibile senza ritagliare il DOM. */
.tour-ring {
  position: absolute; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(6, 8, 14, .62), 0 0 0 2px var(--brand), 0 0 22px rgba(108,140,255,.6);
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
}
#tour-layer .tour-mask { background: transparent; }
.tour-pop {
  position: absolute; width: 340px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem;
  box-shadow: 0 18px 50px rgba(0,0,0,.5); transition: left .25s, top .25s;
}
.tour-pop h3 { margin: .2rem 0 .4rem; font-size: 1rem; }
.tour-pop p { margin: 0; font-size: .85rem; line-height: 1.55; opacity: .88; }
.tour-count { font-size: .68rem; opacity: .5; letter-spacing: .04em; }
.tour-actions { display: flex; align-items: center; gap: .4rem; margin-top: .9rem; }
.tour-spacer { flex: 1; }
.tour-actions button { font-size: .8rem; padding: .35rem .7rem; }

/* ======================= DIALOGO DI SCELTA ======================= */
.ask-card { width: min(520px, 100%); max-height: none; }
.ask-head { padding: 1.1rem 1.3rem .2rem; }
.ask-head h3 { margin: 0; font-size: 1.05rem; }
.ask-body { padding: .5rem 1.3rem 0; font-size: .86rem; line-height: 1.6; color: var(--text); }
.ask-body ul { padding-left: 1.1rem; margin: .5rem 0; }
.ask-body li { margin: .2rem 0; }
.ask-warn {
  border: 1px solid var(--line); border-left: 3px solid #f59e0b; border-radius: 8px;
  padding: .55rem .75rem; margin: .8rem 0 .2rem; background: rgba(245,158,11,.07); font-size: .82rem;
}
.ask-warn ul { margin: .35rem 0; }
.ask-actions { display: flex; flex-direction: column; gap: .45rem; padding: 1.1rem 1.3rem 1.3rem; }
.ask-actions button {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  text-align: left; padding: .6rem .85rem; width: 100%;
}
.ask-actions button b { font-weight: 600; font-size: .87rem; }
.ask-actions button i { font-style: normal; font-size: .72rem; opacity: .7; }
.ask-actions button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* Cambio progetto: feedback che l'ambiente si sta ricaricando */
body.prj-switching .panel { opacity: .5; pointer-events: none; transition: opacity .15s; }
.prj-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem 1rem; font-size: .84rem; z-index: 9500;
  box-shadow: 0 12px 34px rgba(0,0,0,.45); transition: opacity .4s, transform .4s;
}
.prj-toast.out { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* ======================= VERSIONE ======================= */
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.app-version {
  background: transparent; border: 1px solid var(--line); border-radius: 20px;
  padding: .1rem .5rem; font-size: .66rem; color: var(--muted); cursor: pointer;
}
.app-version:hover { color: var(--text); border-color: var(--brand); }
.guide-ver { font-size: .66rem; line-height: 1.35; padding: .3rem .6rem 0; opacity: .6; }

/* ======================= AIUTO ======================= */
.help-btn {
  font-weight: 700; font-size: .95rem; line-height: 1;
  border-color: var(--brand); color: var(--brand);
}
.help-btn:hover { background: var(--brand); color: #fff; }
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line); z-index: 8500;
  display: flex; flex-direction: column; box-shadow: -18px 0 50px rgba(0,0,0,.35);
}
.help-panel.hidden { display: none; }
.help-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--line);
}
.help-head .muted { font-size: .68rem; margin-left: .4rem; }
.help-head-btns { display: flex; gap: .25rem; }
.help-head-btns button { padding: .25rem .5rem; font-size: .8rem; }
.help-log { flex: 1; overflow-y: auto; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .7rem; }
.help-msg { font-size: .84rem; line-height: 1.55; border-radius: 12px; padding: .6rem .8rem; max-width: 92%; }
.help-msg p { margin: 0 0 .45rem; }
.help-msg p:last-child, .help-msg ul:last-child { margin-bottom: 0; }
.help-msg ul { margin: .3rem 0 .5rem; padding-left: 1.1rem; }
.help-msg li { margin: .2rem 0; }
.help-msg code { background: rgba(255,255,255,.08); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
.help-user { align-self: flex-end; background: var(--brand); color: #fff; }
.help-bot { align-self: flex-start; background: var(--panel-2, rgba(255,255,255,.05)); border: 1px solid var(--line); }
.help-plain { background: transparent; border: 0; padding: 0; max-width: 100%; }
.help-err { border-color: #f87171; color: #fca5a5; }
.help-sugg { display: flex; flex-direction: column; gap: .3rem; }
.help-sugg button, .help-links button {
  text-align: left; font-size: .78rem; padding: .4rem .6rem; width: 100%;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted); cursor: pointer;
}
.help-sugg button:hover, .help-links button:hover { border-color: var(--brand); color: var(--text); }
.help-links { display: flex; flex-direction: column; gap: .3rem; margin-top: .6rem; }
.help-foot { font-size: .66rem; padding: .4rem 1rem .8rem; margin: 0; }
.help-dots { display: inline-flex; gap: 4px; }
.help-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: helpdot 1s infinite; }
.help-dots i:nth-child(2) { animation-delay: .15s; }
.help-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes helpdot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (max-width: 720px) { .help-panel { width: 100vw; } }

/* ===========================================================================
   HOME — struttura a bande. La gerarchia è codificata nella DIMENSIONE e nella
   POSIZIONE, non nell'ordine del markup: le card non sono più tutte uguali
   perché le cose che contengono non sono ugualmente importanti.
   Ordine di scansione (F-pattern): banda di stato in alto, poi colonna
   sinistra dominante (Riprendi), poi il resto a peso decrescente.
   =========================================================================== */
.home { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }

/* BANDA 0 — contesto: chi, dove, cosa è cambiato. Una riga, non un hero. */
.home-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.home-bar-l { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.home-bar h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.home-prj-chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: .28rem .7rem; font-size: .78rem; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem; min-height: 30px;
}
.home-prj-chip:hover { border-color: var(--brand); color: var(--text); }
.home-prj-chip b { color: var(--text); font-weight: 600; }
.home-prj-chip .chev { opacity: .5; font-size: .7rem; }
.home-bar-r { font-size: .78rem; color: var(--muted); }
.hs-err { color: #f87171; }

/* Card di base: meno bordi, più respiro. Sei riquadri identici leggono come un
   modulo da compilare; qui la superficie cambia peso col ruolo. */
.hcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .7rem; min-width: 0;
}
.hcard-h { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.hcard-h h3 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.hlink {
  background: transparent; border: 0; color: var(--brand); font-size: .74rem;
  cursor: pointer; padding: .2rem .1rem; min-height: 24px;
}
.hlink:hover { text-decoration: underline; }

/* BANDA 1 — Riprendi (dominante) + Stato. 2:1 su desktop: la ripresa del
   lavoro è l'azione più frequente all'ingresso, quindi prende più superficie
   e sta a sinistra, dove l'occhio arriva per primo. */
.home-band-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.hcard-resume { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }

.hres-main {
  display: flex; gap: .9rem; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel-2, rgba(255,255,255,.03)); border: 1px solid var(--line);
  border-radius: 12px; padding: .7rem; color: inherit; align-items: stretch;
}
.hres-main:hover { border-color: var(--brand); }
.hres-cover {
  flex: 0 0 132px; height: 88px; border-radius: 9px; overflow: hidden; background: #000;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.hres-cover img { width: 100%; height: 100%; object-fit: cover; }
.hres-meta { display: flex; flex-direction: column; gap: .18rem; min-width: 0; flex: 1; }
.hres-meta > b { font-size: .98rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hres-sub { font-size: .74rem; color: var(--muted); }
.hres-badges { display: flex; gap: .3rem; flex-wrap: wrap; }
.hb { font-size: .66rem; border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; color: var(--muted); }
.hb-warn { border-color: #f59e0b; color: #f59e0b; }
.hb-info { border-color: var(--brand); color: var(--brand); }
.hres-cta { margin-top: auto; font-size: .82rem; font-weight: 600; color: var(--brand); }

.hres-more { display: flex; flex-direction: column; gap: .3rem; }
.hres-item {
  display: flex; align-items: center; gap: .5rem; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: .42rem .55rem; color: inherit; font-size: .8rem; min-height: 34px;
}
.hres-item:hover { border-color: var(--line); background: var(--panel-2, rgba(255,255,255,.03)); }
.hres-item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hres-item .muted { font-size: .7rem; margin-left: auto; white-space: nowrap; }
.hres-all { align-self: flex-start; }
.hres-none { display: flex; flex-direction: column; gap: .6rem; }
.hres-asset {
  display: flex; align-items: center; gap: .7rem; text-align: left; cursor: pointer;
  background: var(--panel-2, rgba(255,255,255,.03)); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem; color: inherit;
}
.hres-asset img { width: 76px; height: 52px; object-fit: cover; border-radius: 7px; background: #000; }
.hres-asset span { display: flex; flex-direction: column; min-width: 0; }
.hres-asset b { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hres-asset i { font-style: normal; font-size: .7rem; color: var(--muted); }

/* Stato: righe compatte, aggiornate da sole. */
.hjob {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  padding: .45rem .6rem; color: inherit; font-size: .78rem; min-height: 38px; cursor: pointer;
}
.hjob + .hjob { margin-top: .35rem; }
.hjob-q, .hjob-q:hover { cursor: default; opacity: .75; }
.hjob:hover { border-color: var(--brand); }
.hjob-err { border-color: rgba(248,113,113,.5); }
.hjob-err:hover { border-color: #f87171; }
.hjob-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hjob-txt i { font-style: normal; font-size: .7rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hjob-t { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hjob-spin {
  width: 13px; height: 13px; flex: 0 0 13px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand); animation: hspin .8s linear infinite;
}
@keyframes hspin { to { transform: rotate(360deg); } }
.hjob-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--muted); margin: 0 3px; }
.hjob-x {
  width: 15px; height: 15px; flex: 0 0 15px; border-radius: 50%; background: #f87171; color: #fff;
  font-size: .68rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}

/* Vuoto ≠ buco: dice cosa comparirà lì. */
.hempty { display: flex; align-items: center; gap: .7rem; font-size: .78rem; padding: .3rem 0; }
.hempty div { display: flex; flex-direction: column; gap: .1rem; }
.hempty .muted { font-size: .72rem; }
.hempty-ico { font-size: 1.3rem; opacity: .55; }
.hempty-big { padding: 1.4rem .3rem; }
.hempty-big .hempty-ico { font-size: 2rem; }

/* BANDA 2 — Crea. UNA azione primaria (Fitts: grande e isolata), i modi rapidi
   come strip secondaria: sono una scelta di secondo livello, non sei pari-grado. */
.hcard-create { gap: .9rem; }
.hcreate-main { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; }
.hcreate-main h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.hcreate-main p { margin: 0; font-size: .8rem; max-width: 62ch; }
.hbtn-xl {
  min-height: 46px; padding: 0 1.4rem; font-size: .92rem; font-weight: 600;
  white-space: nowrap; width: auto; margin: 0;
}
.hcreate-quick { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .8rem; }
.hq-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hq-strip { display: flex; gap: .4rem; flex-wrap: wrap; flex: 1; }
.hq {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 36px;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  padding: .35rem .7rem; font-size: .78rem; color: var(--muted); cursor: pointer;
}
.hq:hover { border-color: var(--brand); color: var(--text); }
.hq .ico { width: 15px; height: 15px; }

/* BANDA 3 — Recenti: è un tool visivo, la home deve mostrare i pixel. */
.hstrip { display: flex; gap: .55rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.hthumb {
  position: relative; flex: 0 0 132px; height: 88px; border-radius: 10px; overflow: hidden;
  background: #000; border: 1px solid var(--line); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--muted);
}
.hthumb:hover { border-color: var(--brand); }
.hthumb img { width: 100%; height: 100%; object-fit: cover; }
.hthumb-play {
  position: absolute; top: 6px; left: 6px; font-size: .6rem; color: #fff;
  background: rgba(0,0,0,.55); border-radius: 4px; padding: 1px 4px;
}
.hthumb-cap {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: .62rem; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); padding: 10px 6px 3px; text-align: left;
}

/* BANDA 4 — destinazioni secondarie: la sidebar le offre già in permanenza,
   qui servono solo alla scoperta, quindi peso minimo. */
.home-util { display: flex; gap: .4rem; flex-wrap: wrap; }
.hu {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 34px;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: .3rem .6rem; font-size: .76rem; color: var(--muted); cursor: pointer;
}
.hu:hover { border-color: var(--line); color: var(--text); background: var(--panel); }
.hu .ico { width: 14px; height: 14px; }

/* Onboarding: temporaneo per definizione, quindi in coda e richiudibile. */
.home-onboard {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border: 1px dashed var(--brand); border-radius: 12px; padding: .7rem 1rem;
  background: color-mix(in srgb, var(--brand) 7%, transparent);
}
.home-onboard .muted { font-size: .76rem; margin-left: .5rem; }
.ho-actions { display: flex; gap: .4rem; }
.ho-actions button { min-height: 34px; padding: .35rem .8rem; font-size: .78rem; width: auto; margin: 0; }

/* Adattamento: sotto i 1080 la colonna dello stato scende sotto, perché
   comprimerla la renderebbe illeggibile; sotto gli 820 tutto in colonna. */
@media (max-width: 1080px) {
  .home-band-1 { grid-template-columns: 1fr; }
  .hcard-status { order: -1; }   /* lo stato resta la prima cosa che si legge */
}
@media (max-width: 820px) {
  .home { gap: .8rem; }
  .hcreate-main { flex-direction: column; align-items: stretch; }
  .hbtn-xl { width: 100%; }
  .hres-cover { flex-basis: 96px; height: 68px; }
  .hthumb { flex-basis: 116px; height: 78px; }
  .home-bar h2 { font-size: 1.15rem; }
}

/* ============ ASSISTENTE: modalità workflow e risultati dell'analisi ============ */
.help-ctx {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.help-ctx.hidden { display: none; }
.help-ctx-btn {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 30px;
  background: transparent; border: 1px solid var(--line); border-radius: 20px;
  padding: .25rem .7rem; font-size: .75rem; color: var(--muted); cursor: pointer;
}
.help-ctx-btn:hover { border-color: var(--brand); color: var(--text); }
.help-ctx-btn.on { border-color: var(--brand); color: var(--text); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.help-ctx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.help-ctx-btn.on .help-ctx-dot { background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.help-ctx-eye { font-size: .7rem; margin: 0; }
.help-note { font-size: .78rem; color: var(--muted); font-style: italic; }

.wfa { display: flex; flex-direction: column; gap: .55rem; }
.wfa-diag { margin: 0 0 .2rem; font-size: .85rem; line-height: 1.55; }
.wfa-item {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 9px;
  padding: .5rem .65rem; font-size: .8rem;
}
.wfa-item.sev-hi { border-left-color: #f87171; }
.wfa-item.sev-md { border-left-color: #f59e0b; }
.wfa-item.sev-lo { border-left-color: var(--brand); }
.wfa-h { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.wfa-sev {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800;
  border: 1px solid currentColor; border-radius: 5px; padding: 0 4px; opacity: .8;
}
.sev-hi .wfa-sev { color: #f87171; }
.sev-md .wfa-sev { color: #f59e0b; }
.sev-lo .wfa-sev { color: var(--brand); }
.wfa-item p { margin: .25rem 0; line-height: 1.5; }
.wfa-do { color: var(--text); }
.wfa-jump {
  background: transparent; border: 0; color: var(--brand); font-size: .75rem;
  cursor: pointer; padding: .25rem 0 0; min-height: 26px;
}
.wfa-jump:hover { text-decoration: underline; }
.wfa-prompt { border: 1px solid var(--line); border-radius: 9px; padding: .55rem .65rem; font-size: .8rem; }
.wfa-prompt pre {
  white-space: pre-wrap; font-family: inherit; font-size: .76rem; line-height: 1.5;
  background: var(--panel-2, rgba(255,255,255,.05)); border-radius: 7px; padding: .5rem .6rem; margin: .35rem 0;
}
.wfa-pbtns { display: flex; gap: .4rem; flex-wrap: wrap; }
.wfa-pbtns button { font-size: .74rem; padding: .3rem .6rem; min-height: 30px; width: auto; margin: 0; }
.wfa-foot { font-size: .68rem; margin: .2rem 0 0; }
.wfa-other { font-size: .76rem; }

/* ============ CANVAS: strumenti, zoom, selezione in blocco ============ */
.wf-cbar-sp { flex: 1; }
.wf-tool {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 32px;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: .3rem .65rem; font-size: .78rem; color: var(--muted); cursor: pointer;
}
.wf-tool:hover { border-color: var(--brand); color: var(--text); }
.wf-tool.on { border-color: var(--brand); color: var(--text); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.wf-zoombox { display: inline-flex; gap: .2rem; align-items: center; }
.wf-zoombox .wf-tool { min-width: 32px; justify-content: center; padding: .3rem .5rem; }
.wf-zoom-lbl { min-width: 56px !important; font-variant-numeric: tabular-nums; }

/* Il livello zoomato: le card e i fili scalano insieme, quindi restano
   allineati per costruzione invece che per calcolo. */
.wf-zoom { position: relative; transform-origin: 0 0; will-change: transform; }
.wf-canvas { min-width: 0; }
.wf-canvas::after {
  content: ""; display: block;
  width: var(--wf-w, 100%); height: var(--wf-h, 100%);
  pointer-events: none;
}
.wf-canvas.picking { cursor: cell; }
.wf-canvas.picking .wf-cnode { cursor: cell; }
.wf-canvas.picking .wf-cnode .wf-card { user-select: none; }

.wf-selbar {
  position: sticky; bottom: .6rem; z-index: 20; margin: .6rem auto 0; width: fit-content;
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--brand); border-radius: 999px;
  padding: .4rem .55rem .4rem .9rem; box-shadow: 0 12px 34px rgba(0,0,0,.4);
}
.wf-selbar.hidden { display: none; }
.wfsb-n { font-size: .78rem; color: var(--muted); margin-right: .3rem; }
.wfsb-n b { color: var(--text); }
.wf-selbar button {
  min-height: 30px; font-size: .76rem; padding: .25rem .7rem; border-radius: 999px;
  background: transparent; border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.wf-selbar button:hover { border-color: var(--brand); }
.wf-selbar button.danger { border-color: rgba(248,113,113,.5); color: #f87171; }
.wf-selbar button.danger:hover { background: #b91c1c; color: #fff; border-color: #b91c1c; }

/* ============ ASSISTENTI: composer e pannello analisi ============ */
.help-form { display: flex; flex-direction: column; align-items: stretch; gap: .45rem; padding: .8rem 1rem 0; }
/* La casella era schiacciata a pochi pixel dal pulsante che prendeva tutta la
   riga: in colonna, con flex disattivato, la larghezza torna piena e l'altezza
   la decide il contenuto. */
.help-form textarea {
  flex: none; width: 100%; box-sizing: border-box;
  resize: none; font-size: .86rem; line-height: 1.5;
  min-height: 68px; max-height: 220px; padding: .6rem .7rem;
  border-radius: 10px; font-family: inherit;
}
.help-form button { flex: none; }
.help-send-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.help-send-row .primary { width: auto; margin: 0; min-height: 36px; padding: .4rem 1rem; font-size: .82rem; }
.help-hint { font-size: .68rem; }
.wfa-eye { font-size: .72rem; margin: 0; }

.wfa-panel { width: min(560px, 100vw); }
.help-ctx { font-size: .74rem; }
.help-ctx-btn { white-space: nowrap; }
@media (max-width: 720px) { .wfa-panel { width: 100vw; } }
