/* === VARIABLES & FONTS === */
:root {
    /* Surfaces — derived from charcoal-blue (#36454f) and dark-slate-grey (#2f4f4f), heavily darkened */
    --bg: #111518;
    --panel: #171D21;
    --muted: #1E262C;
    --card: #1A2228;
    --text: #ECF0F1;
    --text-dim: #7A8D96;

    /* Brand accent — blue-violet as primary, dodger-blue as secondary */
    --primary: #9623DF;
    --primary-rgb: 150, 35, 223;
    --accent: #228EFF;
    --brand-gradient: linear-gradient(135deg, #3056FC, #9623DF);

    --border: #2A3640;
    --shadow: 0 1px 3px rgba(0,0,0,.5);
    --radius: 12px;
    --grid-dot: #2A3640;

    /* Semantic — colorful, preserved */
    --blue: #228EFF;
    --error: #FFAC1C;
    --green: #2dc937;
    --neullow: #FFD580;
  }

/* === LIGHT THEME === */
[data-theme="light"] {
    --bg: #F4F6F8;
    --panel: #ECEEF2;
    --muted: #E2E5EA;
    --card: #FFFFFF;
    --text: #1A1E2E;
    --text-dim: #5A6478;
    --border: #D0D5DF;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --grid-dot: #C8CDD8;
    --primary: #228EFF;
    --primary-rgb: 34, 142, 255;
}

  .is-chromium-browser * {
      cursor: auto !important;
  }

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-00.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-Bold-01.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-BoldItalic-02.ttf") format("truetype");
  font-weight: bold;
  font-style: italic;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-DemiBold-03.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-DemiBoldItalic-04.ttf") format("truetype");
  font-weight: 600;
  font-style: italic;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-Italic-05.ttf") format("truetype");
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-Medium-06.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-MediumItalic-07.ttf") format("truetype");
  font-weight: 500;
  font-style: italic;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-Regular-08.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-Heavy-09.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-HeavyItalic-10.ttf") format("truetype");
  font-weight: 800;
  font-style: italic;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-UltraLight-11.ttf") format("truetype");
  font-weight: 200;
  font-style: normal;
}

@font-face {
  font-family: "Avenir Next";
  src: url("/font/AvenirNext-UltraLightItalic-12.ttf") format("truetype");
  font-weight: 200;
  font-style: italic;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-thin.otf") format("opentype");
  font-weight: 100;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-semibold.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: "Nekst";
  src: url("/font/Nekst/Fontspring-DEMO-nekst-black.otf") format("opentype");
  font-weight: 800;
  font-style: normal;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* === GLOBAL PAGE LAYOUT === */
body {
    margin: 0;
    font-family: "Avenir Next", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: var(--bg);

    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

img,
button,
select {
  font-family: inherit;
}

.input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; min-height: 120px; width: 100%; background: var(--muted); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s; resize: vertical ; font-family: inherit; }
.textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; width: 100%; background: var(--muted); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s; resize: vertical; font-family: inherit; }
input[type=number].input::-webkit-inner-spin-button,
input[type=number].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number].input { -moz-appearance: textfield; appearance: textfield; }

/* === APP CONTAINER === */
.app, #app { 
  display: flex;       
  flex: 1;             
  width: 100%;
  position: relative;
  overflow: hidden;    
}

/*Buttons*/
.btn { border: 1px solid var(--border); background: transparent; color: var(--text); padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:active { transform: translateY(1px); }
.btn:hover { background: rgba(var(--primary-rgb),0.08); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.15); }
.iconbtn{ background: transparent; border-color: #ffffff00; font-size: 20px; color: var(--text); box-shadow: none; }
.iconbtn:hover{ background: transparent; color: var(--primary); border-color: #ffffff00; }
.iconbtn::selection{ background: transparent; color: var(--primary); border-color: #ffffff00; }
.iconbtn.toggle{ background: transparent; color: var(--primary); border-color: #ffffff00; }

.btn-attach-fab {
    position: absolute;
    bottom: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: white;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s;
}

.btn-attach-fab:hover {
    transform: scale(1.1);
    filter: brightness(0.85); 
}

.btn-attach-fab:active {
    transform: scale(0.95);
}

.pedro-drop-overlay.active {
    z-index: 50;
}

/* Vertical Scrollbar styling */ 
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
/* --- Webkit (Chrome, Edge, Safari) --- */
.scroll-y::-webkit-scrollbar {
  width: 5px;
}
.scroll-y::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-y::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.scroll-y::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-dim);
}
/* --- Firefox --- */
.scroll-y {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Toolbar */
.right { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; height: 100%;}
.toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; flex: 0 0 auto; z-index: 2;}
.toolbar .title { font-family: "Nekst", sans-serif; font-weight: bold; font-size: 36px; color: #ffffff; line-height: 1; }
[data-theme="light"] .toolbar .title { color: #051633; }
.toolbar-tagline { font-family: "Avenir Next", "Avenir", sans-serif; font-weight: bold; font-size: 11px; color: var(--text-dim); }
.toolbar .version { font-weight: 400; position: absolute; left: 50%; transform: translateX(-50%); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); }
#runBtn.running { color: var(--primary); }
#runBtn.running:hover { color: var(--text); }

/* === SIDEBAR === */
/*#sidebar {
  display: flex;
  flex-direction: column;
  height: 100%; 
  
  width: 250px;
  flex: 0 0 250px; 
  
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 11px 5px; 
  overflow: visible !important; 
  transition: width 0.3s ease;
}*/

/* Sidebar internals */
.logo { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.subtle { color: var(--text-dim); font-size: 12px; }
.sidebar.aliases-collapsed .aliases-section { display: none; }
.aliases-section { transition: opacity 160ms ease-out, transform 160ms ease-out; }
.sidebar.aliases-collapsed .aliases-section { opacity: 0; transform: translateY(-4px);}
.sidebar .aliases-section { opacity: 1; transform: translateY(0);}
.wf-title-edit{ font: inherit; font-weight: 700; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; outline: none; }
.wf-title-edit:focus{ border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25); }
#aliasPalette .draggable > div{ flex: 1; min-width: 0px; max-width: 186px; overflow: hidden; }
.alias-help-btn { font-size: 14px; color: var(--text-dim); opacity: 0; transition: opacity 0.15s ease; flex-shrink: 0; }
#aliasPalette .draggable:hover .alias-help-btn { opacity: 1; }
#workflowPalette .draggable{ position: relative !important; overflow: visible !important; display: flex; align-items: center; gap: 10px; }
#workflowPalette .draggable > div{ flex: 1; min-width: 138px; max-width: 138px; overflow: hidden; }
#workflowPalette .rmWorkflowBtn{ margin-left: auto; }

/* Sidebar Header */
.sidebar-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.sidebar-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  color: var(--text);
  padding-left: 4px;
}
.sidebar-toggle {
  margin-left: auto;
}
.sidebar.collapsed {
  height: 132px;
  overflow: hidden !important;
}
.sidebar.collapsed .sidebar-header {
  border-bottom: none;
}

/* Sidebar Body */
.sidebar-content {
  overflow: auto;
  flex: 1;
  padding-bottom: 10px;
}

.sidebar-footer {
  flex: 0 0 52px; 
  height: 52px;
  
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 0; 
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer .palette {
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}

#addWorkflowBtn {
  width: 90%; 
  display: flex; justify-content: center; align-items: center;
}

/* Toolbox Sliding Panel */
.sliding-pane { position: fixed; top: 56px; right: 0; display: flex; flex-direction: column; height: calc(100vh - 56px); width: 0; transition: width 300ms ease-in-out; background: var(--panel); border-left: 1px solid var(--border); cursor: pointer; }
.sliding-pane .toolbox { padding: 18px 16px 16px; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto;}

.toolbox { overflow: hidden; display: flex; flex-direction: column; height: 95%; width: 100%; }

/* Tabs */
.card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); box-shadow:0 1px 2px rgba(0,0,0,.06); }
/* Changed to a dock-like layout for icons */
.tabs { 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    gap: 6px; 
    border-top: 1px solid var(--border); 
    padding: 8px; 
    background: transparent;
}

/* Base style for icon buttons */
.tab { 
    appearance: none; 
    border: none; 
    background: transparent; 
    color: var(--text-dim); 
    padding: 10px 16px; 
    border-radius: 12px; 
    cursor: pointer; 
    font-weight: 600; 
    position: relative; 
    display: grid;
    place-items: center;
    transition: all 0.2s ease;
}

/* Hover and active states for icons */
.tab:hover { 
    background: var(--muted); 
    color: var(--primary); 
}
.tab[aria-selected="true"] {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.15);
}

.panels { padding:0px; height: 100%; min-height: 0; overflow-y: hidden; }
.panel[hidden] { display:none; }
.panel { line-height:1.6; color:var(--text); height:100%; min-height: 0; overflow-y:auto; }
.muted { color:var(--text-dim); }

#aioTabs.card { 
    display: flex; flex-direction: column; height: 100%; min-height: 0; 
    border: none; border-radius: 0; box-shadow: none; background: transparent;
}
#aioTabs .panels { 
    flex: 1;
    min-height: 0; overflow: hidden; padding: 0; 
    display: flex; flex-direction: column;
}
#aioTabs .panel { 
    flex: 1; 
    min-height: 0; 
    overflow: hidden;
    display: flex; 
    flex-direction: column; 
    width: 100%; 
}

#panel-semantic, #panel-files, #panel-parameters {
    overflow-y: auto;
    overflow-x: hidden;
}

#panel-conversational > div {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.palette { overflow: visible !important; display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
.alias-palette { background: var(--muted); border: 1px solid var(--border); padding: 8px; }
.swim { color: var(--text-dim); font-size: 12px; margin-top: 18px; text-transform: uppercase; letter-spacing: .12em; display: flex; align-items: center; justify-content: space-between; }
.swim .iconbtn { font-size: 14px; padding: 0 2px; min-width: unset; }
.deck-search-bubble { max-height: 0; opacity: 0; overflow: hidden; transform: translateY(-4px); pointer-events: none; transition: max-height .2s ease, opacity .2s ease, transform .2s ease; margin-top: 0; }
.deck-search-bubble.is-open { max-height: 44px; opacity: 1; transform: translateY(0); pointer-events: auto; margin-top: 6px; }
.deck-search-bubble input { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 12px; box-sizing: border-box; box-shadow: var(--shadow); }
.deck-search-bubble input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15); }
.draggable {position: relative !important; overflow: visible !important; background: var(--card); border: 1px solid var(--border); padding: 10px; border-radius: 14px; box-shadow: var(--shadow); cursor: grab; user-select: none; display: flex; align-items: center; gap: 10px; }
.draggable:active { cursor: grabbing; }
.draggable.disabled { opacity: 0.4; cursor: not-allowed !important; filter: grayscale(100%);}
.draggable.disabled .iconbtn, .draggable.disabled strong { cursor: pointer; }
.color-dot { font-size: 18px; background: var(--card)}
.drag-hint { font-size: 11px; color: var(--text-dim); margin-top: 8px; }
.noselect {
  -webkit-user-select: none; /* Safari */
  user-select: none; 
}

/* === CANVAS & WORKSPACE LAYOUT  */

#workspace.right, #workspace {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    min-height: 0; 
    flex: 1;          
    min-width: 0;     
    overflow: hidden; 
}

.workspace-shell { display: flex; flex-direction: column; height: 100%; min-width: 0; }

/*  VIEWPORT */
.workspace-viewport { 
  flex: 1; 
  position: relative; 
  min-height: 0; 
  overflow: hidden;
  background: var(--card);
  cursor: grab;
}
.workspace-viewport.is-panning { cursor: grabbing; }

/* 2. INSTANCE */
.workspace-instance { 
  position: absolute; 
  top: 0; left: 0; 
  width: 100%; height: 100%; 
  transform-origin: 0 0; 
  will-change: transform;

  background: transparent;
  pointer-events: none; 

  --tx: 0px; 
  --ty: 0px; 
  --scale: 1;
}

.workspace-instance.show-grid {
  background-image: radial-gradient(var(--grid-dot) 1.5px, transparent 1.5px);
  background-size: calc(20px * var(--scale, 1)) calc(20px * var(--scale, 1));
  background-position: var(--tx, 0px) var(--ty, 0px);
  background-repeat: repeat; 
}

.workspace-instance:not(.active) { display: none;}
.workspace-instance.active { display: block;}

.workspace-instance.show-grid {
  background-image: radial-gradient(var(--grid-dot) 1.5px, transparent 1.5px);
  background-size: calc(20px * var(--scale, 1)) calc(20px * var(--scale, 1));
  background-position: var(--tx, 0px) var(--ty, 0px);
  background-repeat: repeat; 
}

/* 3. CANVAS (Contenitore Items) */
.canvas { 
  position: absolute; 
  inset: 0; 
  border: none; 
  background: transparent; 
  box-shadow: none;
  pointer-events: none; 
  outline: none !important;
}
.canvas .item, 
.canvas .wires {
    pointer-events: auto; 
}
.canvas.empty::after { display: none; }
.canvas-wrap { padding: 0; overflow: visible; width: 100%; height: 100%; transform-origin: 0 0 !important;}
.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: auto; overflow: visible; }

.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    height: calc(100% - 105px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.15),
        0 20px 25px -5px rgba(0, 0, 0, 0.05);
    opacity: 1;
    display: flex;
    flex-direction: column;
    width: 260px;
    flex: 0 0 250px;
    padding: 11px 5px;
    overflow: visible !important;
    transition: height 0.3s ease;
}

.minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.15),
        0 20px 25px -5px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    opacity: 1;
}

.minimap-nodes {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* A single miniature node */
.mini-node {
    position: absolute;
    background: var(--primary);
    border-radius: 2px;
    transform-origin: 0 0; 
}

/* The viewport indicator */
.minimap-viewport {
    position: absolute;
    border: 2px solid var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    /* box-shadow: 0 0 0 9999px rgba(0,0,0,0.3); ??? */
    pointer-events: none; 
    transition: all 0.05s linear;
}

/* Workspace Tabs (Footer) */
.workspace-tabs { 
  display: flex; 
  align-items: center; 
  gap: 4px; 
  border-top: 1px solid var(--border); 
  background: var(--bg);

  flex: 0 0 63px; 
  height: 63px; 
  min-height: 63px;
  
  box-sizing: border-box; 
  padding: 0 12px; 
  font-size: 18px; 
  color: var(--text);
  overflow-x: auto;       
  overflow-y: hidden;     
  white-space: nowrap;    
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.workspace-tabs::-webkit-scrollbar { height: 4px; }
.workspace-tabs::-webkit-scrollbar-track { background: transparent; }
.workspace-tabs::-webkit-scrollbar-thumb { background-color: transparent; border-radius: 4px; }
.workspace-tabs:hover::-webkit-scrollbar-thumb { background-color: var(--border); }
.workspace-tabs::-webkit-scrollbar-thumb:hover { background-color: var(--text-dim); }

.ws-tab { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px; 
  height: 32px; 
  padding: 0 12px; 
  margin-right: 4px; 
  cursor: pointer; 
  background: var(--panel); 
  color: var(--text-dim); 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  font-size: 13px; 
  transition: all 0.2s ease;
  flex-shrink: 0; 
}
.ws-tab.active { background: var(--primary); color: var(--bg); border-color: var(--primary); font-weight: 500; }

.ws-tab-close { font-size: 12px; border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; color: var(--text-dim); }
.ws-tab-close:hover { background-color: rgba(0,0,0,0.05); color: var(--primary); }
.ws-tab.active .ws-tab-close { color: var(--bg); opacity: 0.8; }
.ws-tab.active .ws-tab-close:hover { background-color: rgba(255,255,255, 0.2); color: var(--bg); opacity: 1; }


/* === ZOOM CONTROLS === */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 300px;
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--card);
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.15),
        0 20px 25px -5px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    /* z-index: 100; */
    display: flex;
}

.zoom-controls span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    min-width: 45px;
    text-align: center;
    user-select: none;
}
.zoom-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: none; border-bottom: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: all 0.2s ease; font-size: 14px;
}
.zoom-btn:last-child { border-bottom: none; }
.zoom-btn:hover { background: var(--muted); color: var(--text); }
.zoom-btn:active { background: var(--muted); }


/* === ITEMS === */
.item { position: absolute; padding: 10px 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); box-shadow: var(--shadow); cursor: grab; user-select: none; min-width: 120px; overflow: visible; transition: width height 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);}
.item .tag {  padding: 4px; font-size: 16px; color: var(--text); display: block; margin-bottom: 2px; text-align: center;}

/*.item:focus,.item:focus-within {outline: 2px solid var(--primary); outline-offset: 2px; z-index: 9999}
.item.selected { box-shadow: 0 0 0 2px var(--primary), var(--shadow);}*/
.item:focus, .item:focus-within { outline: none;  z-index: 9999}
.item.selected { box-shadow: var(--shadow); }

.item:focus .tag,
.item:focus-within .tag,
.item.selected .tag {
    color: var(--primary);
}

.item--wf {border-radius: 25%}
.item--alias {border-radius: 12px; --accent: #60a5fa; border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent), var(--shadow); }
.item .icon { position: absolute; inset: 0;display: grid; place-items: center; font-size: 48px; pointer-events: none; opacity: 0.10; color:var(--accent, currentColor); z-index: 0; }
.item--alias.expand .icon,
.item--wf.expand .icon { font-size: 280px; opacity: 0.05; z-index: -1; }

.item .icon::before { font-family: "Font Awesome 6 Free"; font-weight: 900; line-height: 1; }
.item--alias.expand { margin: -273px -175px; width: 470px; height: 600px; padding: 0; overflow: visible; display: flex; flex-direction: column;}
.item--wf.expand { margin: -273px -175px; width: 470px; height: 600px; padding: 0; overflow: visible; display: flex; flex-direction: column; border-radius: 12px; }

/* --- NODE RENAME & ORIGINAL INFO OVERLAY --- */
.node-title-edit {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: bold;
    text-align: center;
    padding: 0 4px;
    outline: none;
    
}

.node-title-edit:focus {
    background: var(--bg);
}

.item .node-original-info {
    position: absolute;
    top: -25px; 
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none; 
    box-shadow: var(--shadow);
    transition: opacity 0.2s ease, top 0.2s ease;
}

.item:focus .node-original-info,
.item:focus-within .node-original-info {
    opacity: 1;
    top: -35px; 
}

/* === NODE TOOLBAR (Menu Satellite) === */

.node-toolbar {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px); 
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.node-toolbar.selected  {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}

/* STYLE CONTAINER */
.node-toolbar::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  
  width: 48px;     
  height: 150px;   
  
  background: transparent;
  border: 1px solid var(--border);
  
  border-top-left-radius: 100px;
  border-bottom-left-radius: 100px;
  border-right: none;
  
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}

/* STYLE BUTTONS */
.node-toolbar .menuitem {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  
  top: 50%; left: 0; 
  margin-top: -16px; 
  margin-left: -16px; 
  
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
}

.node-toolbar .menuitem:hover {
  transform: scale(1.15);
  color: var(--text);
  background-color: var(--panel); 
  border-color: var(--border);
}

.node-toolbar .menuitem:disabled {
  opacity: 1;
  cursor: default;
  background: var(--muted);
  box-shadow: none;
  pointer-events: none; 
}

/* 1. Scroll UP  */
.node-toolbar .menu-up {
  transform: translate(-20px, -72px) !important;
}
.node-toolbar .menu-up:hover {
  transform: translate(-20px, -72px) scale(1.15) !important; 
}

/* 2. Action A */
.node-menu .menuitem[style*="order: 0"] {
  transform: translate(-42px, -38px) !important; 
}
.node-menu .menuitem[style*="order: 0"]:hover {
  transform: translate(-42px, -38px) scale(1.15) !important; 
}

/* 3. Action B  */
.node-menu .menuitem[style*="order: 1"] {
  transform: translate(-48px, 0px) !important; 
  width: 38px !important; 
  height: 38px !important; 
  margin-top: -19px !important; 
  margin-left: -19px !important; 
  font-size: 15px !important;
}
.node-menu .menuitem[style*="order: 1"]:hover {
  transform: translate(-48px, 0px) scale(1.15) !important; 
}

/* 4. Action C */
.node-menu .menuitem[style*="order: 2"] {
  transform: translate(-42px, 38px) !important; 
}
.node-menu .menuitem[style*="order: 2"]:hover {
  transform: translate(-42px, 38px) scale(1.15) !important; 
}

/* 5. Scroll DOWN  */
.node-toolbar .menu-down {
  transform: translate(-20px, 72px) !important;
}
.node-toolbar .menu-down:hover {
  transform: translate(-20px, 72px) scale(1.15) !important; 
}

/* Everything else is hidden */
.node-menu .menuitem:not([style*="order: 0"]):not([style*="order: 1"]):not([style*="order: 2"]) {
  display: none;
}

.wf-toolbar {
    position: absolute;
    top: 50%;
    left: 100%; /* Si posiziona sul bordo destro esatto della card */
    
    width: 0;
    height: 0;
    
    /* Spostiamolo un po' più a destra (margin) e animiamo l'entrata */
    margin-left: 1px; 
    transform: translateY(-50%) translateX(-20px); 
    
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wf-toolbar.selected {
    opacity: 1;
    pointer-events: all;
    transform: translateY(-50%) translateX(0);
}

/* 3. Lo sfondo "a pillola" (Parentesi graffa chiusa) */
.wf-toolbar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0; /* Parte dall'origine della toolbar */
    transform: translateY(-50%);
    
    width: 45px;
    height: 160px;
    
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: none;
    
    /* Arrotondato solo a destra */
    border-radius: 0 100px 100px 0;
    
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
}
.wf-toolbar.has-error::before { border-color: var(--error); }

.wf-toolbar .menuitem {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  
  top: 50%; left: 0; 
  margin-top: -16px; 
  margin-left: -16px; 
  
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
}

.wf-toolbar .menuitem:hover {
  transform: scale(1.15);
  color: var(--text);
  background-color: var(--panel); 
  border-color: var(--border);
}

.wf-toolbar .menuitem:disabled {
  opacity: 1;
  cursor: default;
  background: var(--muted);
  box-shadow: none;
  pointer-events: none; 
}

/* 1. Scroll UP  */
.wf-toolbar .menu-up {
  transform: translate(20px, -72px) !important;
}
.wf-toolbar .menu-up:hover {
  transform: translate(20px, -72px) scale(1.15) !important; 
}

/* 2. Action A */
.wf-menu .menuitem[style*="order: 0"] {
  transform: translate(42px, -38px) !important; 
}
.wf-menu .menuitem[style*="order: 0"]:hover {
  transform: translate(42px, -38px) scale(1.15) !important; 
}

/* 3. Action B  */
.wf-menu .menuitem[style*="order: 1"] {
  transform: translate(48px, 0px) !important; 
  width: 38px !important; 
  height: 38px !important; 
  margin-top: -19px !important; 
  margin-left: -19px !important; 
  font-size: 15px !important;
}
.wf-menu .menuitem[style*="order: 1"]:hover {
  transform: translate(48px, 0px) scale(1.15) !important; 
}

/* 4. Action C */
.wf-menu .menuitem[style*="order: 2"] {
  transform: translate(42px, 38px) !important; 
}
.wf-menu .menuitem[style*="order: 2"]:hover {
  transform: translate(42px, 38px) scale(1.15) !important; 
}

/* 5. Scroll DOWN  */
.wf-toolbar .menu-down {
  transform: translate(20px, 72px) !important;
}
.wf-toolbar .menu-down:hover {
  transform: translate(20px, 72px) scale(1.15) !important; 
}

/* Everything else is hidden */
.wf-menu .menuitem:not([style*="order: 0"]):not([style*="order: 1"]):not([style*="order: 2"]) {
  display: none;
}

/* Connection handles */
.handle { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; transform: translateY(-50%); background: #0b1220; border: 2px solid var(--border); box-shadow: 0 0 0 2px rgba(0,0,0,.25); pointer-events: auto; cursor: crosshair; }
.handle.left  { left: -7px; }
.handle.right { right: -7px; }
.handle.hot { border-color: var(--primary); }

/* --- WIRE INTERACTION --- */

/* Fat transparent hit area — handles all pointer events */
.wire-hitarea {
    fill: none;
    stroke: transparent;
    stroke-width: 20;
    stroke-linecap: round;
    pointer-events: stroke;
    cursor: pointer;
}

/* Visible wire — purely decorative, no pointer events */
.wire {
    pointer-events: none;
    stroke-width: 3;
    stroke-opacity: 0.6;
    transition: stroke-width .15s ease, stroke-opacity .15s ease;
}
.wire.hovered {
    stroke-width: 5;
    stroke-opacity: 1;
}
.wire.selected {
    stroke-width: 5;
    stroke-opacity: 1;
    filter: drop-shadow(0 0 6px rgba(96,165,250,.45));
}

/* Midpoint handle group (contains del + plug sub-groups) */
.wire-mid {
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.wire-mid-del,
.wire-mid-plug {
    pointer-events: auto;
    cursor: pointer;
}
.wire-mid-del circle,
.wire-mid-plug circle {
    fill: var(--card);
    stroke: var(--border);
    stroke-width: 1.5;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12));
}
.wire-mid-del:hover circle,
.wire-mid-plug:hover circle { fill: var(--panel); stroke: #d1d5db; }

.wire-icon-content {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 12px;
    pointer-events: none;
}
.wire-mid-del:hover .wire-icon-content,
.wire-mid-plug:hover .wire-icon-content { color: var(--text); }



/* Unplugged wire: grey + dashed */
.wire.unplugged { stroke: var(--text-dim); }

/* CHAT */
.chat-card {
    margin: 0;
    height: 517px;
    border: none;
    border-radius: 0;
    overflow: hidden;
    background: var(--card);
    display: block;
    min-height: 0;
}
.chat-header { background: var(--card); border-bottom:1px solid var(--border); padding:10px 12px; font-weight:700; display:flex; gap:8px; align-items:center; }

/* Apply the fade-out mask to the top of the chat */
.chat {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 100%);
    transition: -webkit-mask-image 0.3s ease, mask-image 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.chat::-webkit-scrollbar { width: 5px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
.chat::-webkit-scrollbar-thumb:hover { background-color: var(--text-dim); }

.chat.is-scrolled {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
}

.chat-viewport {
    flex: 1 1 auto !important;
    max-height: 426px !important; 
    min-height: 218px !important; 
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.chat-box {
    display: flex !important;
    flex-direction: column !important;
    height: 516px !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* Sticky composer INSIDE the chat card */
.chat-input { align-content: center; font-size: 18px; flex: 1; border: 0; min-width: 0; min-height: 24px; line-height: 24px; max-height: 91px; background: transparent; padding: 0; color: var(--text); font-size: 16px; font-family: inherit; resize: none; outline: none; overflow-y: hidden; scrollbar-width: none; }

.chat-input::-webkit-scrollbar { display: none; }
.chat-footer{flex: 0 0 auto !important; 
    min-height: 0 !important;
    background: var(--card) !important;
    border-top: 1px solid var(--border) !important;
    padding: 0px 10px 10px 10px!important;
    max-height: calc(100% - 218px) !important; 
    overflow-y: auto !important;
  }

.chat-files { display:flex; flex-wrap: nowrap; width: 100%; gap:8px; padding:8px 12px 4px 12px; overflow-x: auto; }

.msg{display:flex;gap:8px;margin-bottom:10px;align-items:flex-end}
.msg.bot{justify-content:flex-start}.msg.user{justify-content:flex-end;justify-self: flex-end; min-width: 0; max-width: 80%;}
.msg-text{white-space: pre-wrap;overflow-wrap: anywhere;word-break: break-word;word-wrap: break-word; margin: 0; line-height: 1.4; text-align: left; -webkit-user-select: text !important; user-select: text !important; cursor: text !important;}

.bubble{max-width:68ch;padding:10px 12px;border:1px solid var(--border);border-radius:12px;}
.bot .bubble{background:var(--panel)}.user .bubble{background:rgba(var(--primary-rgb),0.12);border-color:rgba(var(--primary-rgb),0.3)}
.meta{font-size:12px;color:var(--text-dim);margin-top:4px}
.chips{margin-top:6px;display:flex;flex-wrap:wrap;gap:6px}
.chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--muted);border:1px solid var(--border);border-radius:999px;font-size:12px;color:var(--text-dim)}
.chip button{border:0;background:transparent;color:var(--text-dim);cursor:pointer}

.conversational { display: flex; flex-direction: column; min-height: 0; flex: 1; width: 100%; height: 100%; }
.conversational > h2, .conversational > p { flex: 0 0 auto; }

/* La card che contiene chat e footer */
.conversational .chat-card { 
    flex: 1; min-height: 0; margin: 0; border: none; border-radius: 0; 
    overflow: hidden; background: var(--card); display: flex; flex-direction: column;
}
/* Bot typewriter effect */
.msg.bot .bubble.streaming { position: relative; }
.bot-type-line { white-space: pre-wrap; }
.bot-type-caret { display: inline-block; width: 8px; margin-left: 2px; animation: bot-caret-blink 900ms steps(1) infinite; }
@keyframes bot-caret-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; }}

/* Thinking indicator */
.msg.bot.thinking-msg .bubble { padding: 8px 10px;}
.thinking-indicator {display: flex; gap: 4px; align-items: center; }
.thinking-dot {width: 8px; height: 8px; border-radius: 999px; background: var(--text); animation: thinking-bounce 1.2s infinite ease-in-out; }
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinking-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 0.8; } }
.thinking-text { margin-left: 8px; font-size: 0.82em; opacity: 0; color: var(--text); transition: opacity 0.35s ease; }
.thinking-text.visible { opacity: 0.55; }

/* Chat responses */

.msg.model-response {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    margin: 20px 0;
    padding: 0 10px;
    min-width: 0;
}

.model-header {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Forces left alignment */
    gap: 10px;
    margin-bottom: 12px;
    width: 100%;
    text-align: left; /* Prevents text centering */
}

.model-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 14px;
}

.model-text {
    line-height: 1.6; /* Slightly increased for better justified readability */
    overflow-wrap: break-word;
    word-wrap: break-word;
    color: var(--text);
    max-width: 100%;
    min-width: 0;
    text-align: justify; /* Justify text */
    text-justify: inter-word; /* Improves spacing between words */
    user-select: text;
    -webkit-user-select: text; 
    -moz-user-select: text;
    cursor: text;
}

.model-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.model-body {
    padding-left: 38px;
    min-width: 0; 
    width: 100%;
}

.model-text ul, 
.model-text ol,
.model-text pre, 
.model-text code,
.model-text h1, 
.model-text h2, 
.model-text h3, 
.model-text h4 {
    text-align: left; 
}

.model-text pre,
.model-text code {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    overflow-x: auto;
}

.model-text pre {
    background-color: var(--panel);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 8px;
    margin-bottom: 12px;
    
    /* Force horizontal scrollbar strictly inside the box */
    max-width: 100%;
    overflow-x: auto;
    white-space: pre; 
}

.model-text code {
    font-family: monospace;
    background-color: var(--muted);
    color: var(--text);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
    
    /* Force inline code to wrap to the next line if needed */
    white-space: pre-wrap;
    word-break: break-word;
}

.model-text pre code {
    background-color: transparent;
    color: var(--text);
    padding: 0;
    border-radius: 0;
    font-size: 13px;
    
    /* Revert to no-wrap so the pre block handles the scroll */
    white-space: inherit;
    word-break: normal;
}

.model-body .file-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--muted);
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    font-size: 12px;
}

.model-response .msg-text {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: var(--text);
    max-width: 100%;
}

.model-text table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin-top: 15px;
    margin-bottom: 15px;
    
    /* Reset justify from parent: tables must be left-aligned */
    text-align: left; 
    
    /* Smooth scrolling on mobile */
    -webkit-overflow-scrolling: touch;
}

.model-text th, 
.model-text td {
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
}

/* Header style */
.model-text th {
    background-color: var(--panel);
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

/* Zebra striping for readability */
.model-text tr:nth-child(even) {
    background-color: var(--muted);
}

/* Hover effect on rows */
.model-text tr:hover {
    background-color: var(--border);
}

/* Usage chip */
.usage-chip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.usage-item { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); background: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 2px 8px; line-height: 1.4; }
.usage-item i { font-size: 10px; }
.usage-thinking { color: #a78bfa; border-color: #a78bfa44; }
.usage-cached { color: #34d399; border-color: #34d39944; }
.usage-cost { font-weight: 600; color: var(--text); }

/* Error Messages */
.msg.error { justify-content: flex-start; }
.msg.error .bubble {background:var(--card); border-color:var(--border); color:var(--primary); display: flex; align-items: flex-start; gap: 8px; }
.msg-error-icon {font-weight: 500; font-size: 14px; line-height: 1; margin-top: 4px; flex: 0 0 auto; }
.msg-error-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px;}
.msg-error-header {font-weight: 500; letter-spacing: .02em; }
.msg-error-text { white-space: pre-wrap;}

.composer{display:flex;gap:8px;align-items:flex-end; padding: 8px 10px; border-radius: 16px; border: 1px solid var(--border);background:var(--card)}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25); }
.sendbtn{ background: transparent; border-color: #ffffff00; font-size: 20px; color: var(--text); box-shadow: none; }
.sendbtn:hover{ background: transparent; color: var(--primary); border-color: #ffffff00; }
.sendbtn::selection{ background: transparent; color: var(--primary); border-color: #ffffff00; }

/* ACCORDIONS */
.viewport{ height: 560px; overflow-y: auto; border:1px solid var(--border); border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); }
.controls{ position: sticky; top: 0; background:var(--card); border-bottom:1px solid var(--border); display:flex; gap:8px; align-items:center; padding:10px 12px; }
.controls .spacer{ flex:1; }
.accordion { border-top:1px solid var(--border); }
.ac-item { border-bottom:1px solid var(--border); }
.ac-trigger{width:100%; text-align:left; padding:14px 16px; background:var(--card); border:0; cursor:pointer; font-weight:700; display:flex; align-items:center; gap:10px; }
.ac-trigger:focus{ outline:2px solid var(--primary); outline-offset:-2px; }
.ac-trigger .chev{ margin-left:auto; color:var(--text-dim); transition:transform .15s; font-weight:700; }
.ac-trigger[aria-expanded="true"] .chev{ transform:rotate(90deg); }
.ac-panel{ padding:16px; }

/* FILE MANAGEMENT */
/*.files h2 { margin: 16px 16px 4px; }*/
/*.files .muted { margin: 0 16px 10px; }*/
.files {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.files .controls {
  flex: 0 0 auto !important;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.files .card {display: block; height:469px; overflow:hidden; border: none;}

.file-viewport {
  flex: 1 1 auto !important;
  min-height: 0 !important; 
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border: none;
}

.file-list {
  flex: 1 1 auto !important;
  overflow-y: auto !important; 
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  max-height: 464px;
}
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
.file-row:hover { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25); }
.file-main { min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.file-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.file-side { display: flex; align-items: center; gap: 8px; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: var(--muted); color: var(--text-dim); }
.badge-success { padding: 4px 8px; background: rgba(45,201,55,0.12); border-color: rgba(45,201,55,0.3); color: var(--green); }
.badge-info { padding: 4px 8px; background: rgba(34,142,255,0.12); border-color: rgba(34,142,255,0.3); color: var(--blue); }
.badge-warn { padding: 4px 8px; background: rgba(255,172,28,0.12); border-color: rgba(255,172,28,0.3); color: var(--error); }
.btn-xs{ background: transparent; border-color: #ffffff00; font-size: 20px; color: var(--text); box-shadow: none; }
.btn-xs:hover{ background: transparent; color: var(--primary); border-color: #ffffff00; }
.files .files-filters { display: inline-flex; gap: 6px; align-items: center; }
.files .filter-option { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--muted); font-size: 12px; cursor: pointer; }
.files .filter-option input[type="radio"] { accent-color: var(--primary); margin: 0; }

@media (max-width: 768px) {
  .file-row { flex-direction: column; align-items: flex-start;}
  .file-side {align-self: stretch; justify-content: flex-end;}
}

/* File inside the chat */
.bubble.file-bubble{ display:flex; gap:10px; align-items:flex-start; cursor:pointer;}
.file-bubble-icon{ font-size:20px; display:grid; place-items:center; border:1px solid var(--border); border-radius:10px; flex:0 0 auto; box-shadow: 0 0 0 0px rgba(255, 255, 255, 0); }
.file-bubble-title{ font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:52ch;}
.file-bubble-sub{ font-size:12px; color:var(--text-dim); margin-top:2px; text-transform:lowercase; }
.file-row.is-focused{ outline:2px solid var(--accent); border-radius:12px; animation:filePulse 1.2s ease-out; }
@keyframes filePulse{
  0%   { box-shadow: 0 0 0 rgba(0,0,0,0); }
  30%  { box-shadow: 0 10px 28px rgba(0,0,0,.12); }
  100% { box-shadow: 0 0 0 rgba(0,0,0,0); }
}

/* Parameters */
/*.parameters h2 { margin: 16px 16px 4px; }*/
/*.parameters .muted { margin: 0 16px 10px; }*/

.parameters {display: block; height: 516px; border: none;}
.parameters .card { background: var(--card); border-bottom: none; border-left: none; border-right: none; border-top: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); display: flex; height: 100%; flex-direction: column; overflow-y: auto;}

.parameters .parameters-filters { display: inline-flex; gap: 6px; align-items: center; }
.parameters .filter-option { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--muted); font-size: 12px; cursor: pointer; }
.parameters .filter-option input[type="radio"] { accent-color: var(--primary); margin: 0; }


/* Settings */
/*.settings-overlay{
  position: fixed;
  left: 0; right: 0;
  top: 68px;
  bottom: 0;
  background: rgba(0,0,0,.35);
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 1000;
}

.settings-overlay.open{ display:flex; }

.settings-window{
  width:min(1100px, 96vw);
  height:min(760px, 92vh);
  margin: 4vh auto;
  background: var(--bg);
  border:1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.settings-header{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 12px 14px;
  border-bottom:1px solid var(--border);
  background: var(--card);
}

.settings-header h2{ margin:0; }

.settings-header-right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}

.settings-search-inline{
  display:flex;
  align-items:center;
  overflow:hidden;

  max-width: 0;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;

  transition: max-width .18s ease, opacity .18s ease, transform .18s ease;
}

.settings-search-inline.is-open{
  max-width: 280px;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.settings-search-inline input{
  width: 280px;
  padding: 10px 12px;
  border:1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.settings-search-inline input:focus{
  outline:none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.settings-body{
  display:grid;
  grid-template-columns: 260px 1fr;
  min-height:0;
  flex:1;
}

.settings-nav{
  background: var(--panel);
  border-right:1px solid var(--border);
  padding: 10px;
  overflow:auto;
}

.nav-item{
  width:100%;
  text-align:left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  font-weight: 600;
}

.nav-item:hover{background: var(--card); border-color: var(--primary); box-shadow: var(--shadow); }
.nav-item.active{
  background: var(--card);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.settings-content{
  padding: 14px;
  overflow:auto;
  background: var(--bg);
}

.settings-section{ padding-bottom: 18px; }
.settings-section h2{
  margin: 10px 0 10px;
  font-size: 18px;
}

.settings-card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.row{ display:flex; align-items:center; justify-content:space-between; gap: 16px; }
.label{ font-weight: 700; }
.hint{ color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.input.input-line {
  min-height: 42px;
  resize: none;
}*/

/* Settings - Full Screen Page */
.settings-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-header{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 12px 14px;
  border-bottom:1px solid var(--border);
  background: var(--card);
}

.settings-header h2{ margin:0; }

.settings-header-right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}

.settings-search-inline{
  display:flex;
  align-items:center;
  overflow:hidden;

  max-width: 0;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;

  transition: max-width .18s ease, opacity .18s ease, transform .18s ease;
}

.settings-search-inline.is-open{
  max-width: 280px;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.settings-search-inline input{
  width: 280px;
  padding: 10px 12px;
  border:1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.settings-search-inline input:focus{
  outline:none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.settings-body{
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.settings-nav{
  background: var(--panel);
  border-right:1px solid var(--border);
  padding: 10px;
  overflow:auto;
}

.nav-item{
  width:100%;
  text-align:left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  font-weight: 600;
}

.nav-item:hover{background: var(--card); border-color: var(--primary); box-shadow: var(--shadow); }
.nav-item.active{
  background: var(--card);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.settings-content{
  padding: 14px;
  overflow:auto;
  background: var(--bg);
}

.settings-section{ padding-bottom: 18px; }
.settings-section h2{
  margin: 10px 0 10px;
  font-size: 18px;
}

.settings-card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.row{ display:flex; align-items:center; justify-content:space-between; gap: 16px; }
.label{ font-weight: 700; }
.hint{ color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.input.input-line {
  min-height: 42px;
  resize: none;
}


/* API key layout */
.api-input-wrap{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.api-input-row{
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.api-input{
  flex: 1 1 auto;
  min-width: 0;
}

.api-status{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding-left: 4px;
}

.api-status .ok{
  color: var(--green);
}

.api-status .err{
  color: var(--primary);
}

.api-status .api-err-text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60ch;
}

/* Change password */
.psw-row > div:first-child{
  min-width: 220px;
}

.psw-field{
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.psw-input{
  flex: 1 1 auto;
  min-width: 0;
}

.psw-status{
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.psw-status .ok{ color: var(--green); }
.psw-status .err{ color: var(--primary); }


/* Users */
.users-row > div:first-child{
  min-width: 220px;
}

.users-field{
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.users-input{
  flex: 1 1 auto;
  min-width: 0;
}

.role-pills { display:flex; flex-wrap:wrap; gap:6px; }
.role-pills input[type="radio"]{
  accent-color: var(--primary);
}

.user-action-btns { display:flex; align-items:center; gap:4px; flex-shrink:0; max-width:0; overflow:hidden; padding-right:0; pointer-events:none; transition:max-width .15s ease, padding-right .15s ease; }
.file-row:hover .user-action-btns { max-width:80px; padding-right:6px; pointer-events:auto; }
.user-edit-btn { font-size:14px; flex-shrink:0; }

.users-status{
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.users-status .status-line{ display:flex; gap:8px; align-items:flex-start; }

.users-status.ok{ color: var(--green); }

.users-status.err{ color: var(--primary); }

/* THINKING STATE red border rotation */

.item.node-thinking::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(
    from var(--spin-angle, 0deg),
    var(--bg),
    var(--primary)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: node-spin 2s linear infinite;
  pointer-events: none;
}

.item.node-thinking {
  border: var(--primary);
}

@property --spin-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes node-spin {
  from { --spin-angle: 0deg; }
  to { --spin-angle: 360deg; }
}

/* MESSAGE RECEIVED blinking 101010 (3 blink) */
.item.node-received {
  animation: node-flash 4s ease-out forwards;
}
/*.item.node-error{
  animation: node-error 4s ease-out forwards;
}*/

@keyframes node-flash {
  /* 1° blink ON */
  0%, 10% {
    box-shadow:
      0 0 0 1px var(--blue),
      0 0 25px var(--blue),
      var(--shadow);
      filter: brightness(1.02);
  }
  /* 1° OFF */
  20%, 30% {
    box-shadow: 0 0 0 1px var(--blue), var(--shadow);
    filter: brightness(1);
  }
  /* 2° blink ON */
  35%, 45% {
    box-shadow:
      0 0 0 1px var(--blue),
      0 0 25px var(--blue),
      var(--shadow);
    filter: brightness(1.02);
  }
  /* 2° OFF */
  55%, 65% {
    box-shadow: 0 0 0 1px var(--blue), var(--shadow);
    filter: brightness(1);
  }
  /* 3° blink ON */
  70%, 80% {
    box-shadow:
      0 0 0 1px var(--blue),
      0 0 25px var(--blue),
      var(--shadow);
    filter: brightness(1.02);
  }
  /* 3° OFF - final state */
  90%, 100% {
    box-shadow: 0 0 0 1px var(--blue), var(--shadow);
    filter: brightness(1);
  }
}


/* ERROR RECEIVED blinking 110110110 (3 blink) */
.item.node-error{
  animation: node-error 4s ease-out forwards;
}
/*.item.node-received {
  animation: node-flash 4s ease-out forwards;
}*/

@keyframes node-error {
  /* 1° : blink-blink */
  0%, 5% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  8% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
  11%, 16% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  /* off */
  22%, 32% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
  /* 2° : blink-blink */
  35%, 40% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  43% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
  46%, 51% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  /* off */
  57%, 67% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
  /* 3° : blink-blink */
  70%, 75% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  78% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
  81%, 86% {
    box-shadow: 0 0 0 1px var(--primary), 0 0 25px var(--primary), var(--shadow);
    filter: brightness(1.02);
  }
  /* off - the end */
  92%, 100% {
    box-shadow: 0 0 0 1px var(--primary), var(--shadow);
    filter: brightness(1);
  }
}

/* User menu */
.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    /*min-width: 80px;*/
}

.menu-item i {
    font-size: 22px;
}

.menu-item span {
    font-size: 12px;
    font-weight: 500;
}


.iconbtn.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  border-radius: 20px;
  border: 1.7px solid var(--text);
}
.iconbtn.user-pill:hover {
  border-color: var(--primary);
}
.iconbtn.user-pill.menu-open {
  color: var(--primary);
  border-color: var(--primary);
}

.user-pill-label {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}

.user-pill-initial {
  flex-shrink: 0;
}

.user-pill-dot {
  flex-shrink: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 300ms ease-in-out, opacity 300ms ease-in-out;
}

.user-pill-suffix {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: max-width 300ms ease-in-out, opacity 300ms ease-in-out, transform 300ms ease-in-out;
}

.iconbtn.user-pill.menu-open .user-pill-suffix {
  max-width: 120px;
  opacity: 1;
  transform: translateX(0);
}

.iconbtn.user-pill.menu-open .user-pill-dot {
  max-width: 12px;
  opacity: 1;
}

/* Badge notifica - nascosto di default */
.node-notif {
  margin-left: 6px;
  font-size: 14px;
  color: var(--blue);
  pointer-events: none;
  display: none;  /* nascosto di default */
}

.node-notif.visible {
  display: block;
}

/* Variante errore */
.node-notif--error {
  font-size: 16px;
  color: var(--primary);
}

/* Pedro */

/* Covers the entire section with a blurred glass effect */
.pedro-drop-overlay {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--card) 85%, transparent);
    backdrop-filter: blur(3px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none; /* Ignore mouse events when hidden */
    transition: opacity 0.2s ease;
    border-radius: inherit;
}

/* Active state triggered by Datastar signal */
.pedro-drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Inner dashed container */
.pedro-drop-overlay .overlay-content {
    border: 3px dashed var(--neullow);
    border-radius: 12px;
    padding: 30px;
    width: 85%;
    height: 85%;
    background: color-mix(in srgb, var(--neullow) 10%, transparent);
    color: var(--neullow);
    font-size: 16px;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    pointer-events: none; /* Prevent flickering during drag */
}

.pedro-drop-overlay i {
    font-size: 42px;
}

/* --- REORDERABLE FILE ROWS (INTERNAL DRAG & DROP) --- */
.file-row {
    position: relative;
    /* Use a transparent border instead of margin. This keeps the hitbox 
       stable and prevents the element from escaping the mouse cursor */
    transition: border-width 0.05s ease, opacity 0.05s ease;
}

/* State when the user is actively dragging THIS specific row */
.file-row.is-dragging {
    opacity: 0.3;
}

/* State when another row is hovering OVER this row */
.file-row.drag-over {
    /* Thick border creates the 45px visual gap WITHOUT moving the top edge of the hitbox */
    border-top: 45px solid color-mix(in srgb, var(--neullow) 15%, transparent);
}

/* The dashed line that appears at the top of the gap */
.file-row.drag-over::before {
    content: "";
    position: absolute;
    top: -45px; /* Pin it to the very top of the new thick border */
    left: 0;
    right: 0;
    border-top: 2px dashed var(--neullow);
}

/* CRITICAL: Prevent child elements (text, icons) from stealing the hover state 
   and triggering accidental dragleave events */
.file-row.drag-over * {
    pointer-events: none;
}

.drop-zone-end {
    margin-top: 0;
    min-height: 50px;
    flex-grow: 1; 
    border-radius: 6px;
    border: 2px solid transparent;
    transition: background-color 0.05s ease, border 0.05s ease;
}

/* Active state for the end of list drop zone */
.drop-zone-end.drag-over-end {
    background-color: color-mix(in srgb, var(--neullow) 15%, transparent);
    border: 2px dashed var(--neullow);
}

/* Prevent child interference */
.drop-zone-end.drag-over-end * {
    pointer-events: none;
}

@keyframes slideOutAndCollapse {
    0% {
        transform: translateX(0);
        opacity: 1;
        max-height: 100px; /* Adjust if your rows are taller */
        padding-top: 10px; /* Match your existing row padding */
        padding-bottom: 10px;
        margin-bottom: 8px; /* Match your existing gap */
        border-width: 1px;
    }
    50% {
        /* Halfway: fully slid to the right and invisible, but space is still held */
        transform: translateX(120%);
        opacity: 0;
        max-height: 100px;
        padding-top: 10px;
        padding-bottom: 10px;
        margin-bottom: 8px;
        border-width: 1px;
    }
    100% {
        /* End: element is gone and all physical space is collapsed to 0 */
        transform: translateX(120%);
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 0;
        border-width: 0;
        overflow: hidden; /* Prevent content from spilling during collapse */
    }
}

.file-row.is-processing {
    /* 'forwards' ensures it stays hidden at the end of the animation */
    animation: slideOutAndCollapse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none; /* Prevent accidental clicks or drag interactions while it slides out */
    border-color: transparent; /* Optional: hides the border cleanly as it slides */
}

/* WAITING STATE - slow green pulse (ready to receive) */
.item.node-waiting::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--spin-angle, 0deg),
    var(--bg),
    var(--green)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: node-spin 33s linear infinite;
  pointer-events: none;
  z-index: -1;
}

.item.node-waiting {
  border: var(--green);
}

@property --spin-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes node-spin {
  from { --spin-angle: 0deg; }
  to { --spin-angle: 360deg; }
}

/* COLLECTING STATE - aura pulling inward */
.item.node-collecting::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 20px 20px var(--neullow);
  animation: node-collect 0.7s ease-in infinite;
  pointer-events: none;
}

@keyframes node-collect {
  0% {
    opacity: 0.3;
    box-shadow: 0 0 20px 20px var(--neullow);
    transform: scale(1.15);
  }
  90% {
    opacity: 0.8;
    box-shadow: 0 0 8px 4px var(--error);
    transform: scale(1.0);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 8px 4px var(--error);
    transform: scale(0.97);
  }
}

/* READY TO PUB opposite - aura pulling inward */
.item.node-pubtricio::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:inset 0 0 20px 20px var(--neullow);
  animation: node-pubtricio 0.7s ease-in infinite;
  pointer-events: none;
}

@keyframes node-pubtricio {
  0% {
    opacity: 0;
    box-shadow:inset 0 0 8px 4px var(--error);
    transform: scale(0.7);
  }
  10% {
    opacity: 0.8;
    box-shadow:inset 0 0 8px 4px var(--error);
    transform: scale(1.0);
  }
  100% {
    opacity: 0.3;
    box-shadow:inset 0 0 20px 20px var(--neullow);
    transform: scale(1.15);
  }
}

/* -- OVERLAY BLOCCANTE OFFLINE -- */
.offline-banner {
    width: 100%;
    background-color: #dc2626; /* Rosso avviso */
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    z-index: 9900; /* Assicurati che sia sopra al workspace */
    
    /* Effetto a tendina */
    max-height: 50px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.offline-banner.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border: none;
}

.offline-banner .spinner-icon {
    font-size: 12px;
    margin-left: 8px;
    color: #fca5a5; /* Rosso più chiaro per il caricamento */
}

/* Il box centrale del messaggio */
.offline-modal {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-top: 4px solid #dc2626;
    border-radius: 8px;
    padding: 32px 40px;
    text-align: center;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.offline-icon {
    font-size: 40px;
    color: #ef4444;
    margin-bottom: 16px;
}

.offline-title {
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.offline-text {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 24px 0;
}

/* -- ERROR PANEL OVERLAY -- */

.error-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 340px;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* Un'ombra leggermente più marcata per staccarlo dal workspace sottostante */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); 
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    
    /* Magia CSS: scompare se vuoto */
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.error-panel:not(:has(.error-pill)) {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* Header del pannello */
.error-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--panel);
    border-bottom: 1px solid var(--border);
}

.error-panel-title {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.error-panel-clear {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.error-panel-clear:hover {
    color: var(--primary); /* Diventa rosso al passaggio del mouse */
}

/* Contenitore della lista scrollabile */
.error-panel-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--bg);
}

/* Scrollbar minimale per il tema chiaro */
.error-panel-list::-webkit-scrollbar {
    width: 6px;
}
.error-panel-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}
.error-panel-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-dim);
}

/* -- ERROR PILL COMPONENT -- */

.error-pill {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--error); /* Usa il rosso primario di default */
    padding: 12px;
    border-radius: 8px; /* Un po' più squadrato rispetto al pannello esterno */
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

/* Varianti basate sulla tua palette */
.error-pill.warning { 
    border-left-color: var(--error); /* Usa l'arancione FFAC1C per i warning */
}
.error-pill.warning .pill-icon { 
    color: var(--error); 
}

.error-pill.info { 
    border-left-color: var(--blue); /* Usa l'arancione FFAC1C per i warning */
}
.error-pill.info .pill-icon { 
    color: var(--blue); 
}

.error-pill.success { 
    border-left-color: var(--green); 
}
.error-pill.success .pill-icon { 
    color: var(--green); 
}

.pill-icon {
    color: var(--accent);
    font-size: 16px;
    margin-top: 2px;
}

.pill-content {
    flex-grow: 1;
    min-width: 0;
}

.pill-title {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.pill-desc {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.4;

    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

.pill-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.pill-close:hover {
    color: var(--text);
    background-color: var(--muted);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* TAGS */

.tag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  border: 1px solid transparent;
  position: relative;
/*  z-index: 1;*/
  transition: box-shadow .15s, z-index 0s .22s;
}

.tags-chip-grid .tag-chip {
  flex-shrink: 0;
}

.tag-chip--locked {
  color: var(--text);
  border-color: var(--green);
  cursor: default;
}

.tag-chip--locked-custom {
  opacity: 1;
  cursor: default;
}

.tag-chip--unlocked {
  color: var(--text-dim);
  border-color: var(--border);
  cursor: pointer;
  opacity: 0.5;
  transition: background .13s, color .13s, border-color .13s;
}
.tag-chip--unlocked:hover { color: var(--text); opacity: 1; box-shadow: 0 2px 10px rgba(0,0,0,.15);}

.tag-chip--custom {
  color: var(--text-dim);
  border-color: var(--border);
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
  opacity: 0.5;
}
.tag-chip--custom:hover { color: var(--text); opacity: 1; box-shadow: 0 2px 10px rgba(0,0,0,.15);}

.tag-chip--unlocked.inc,
.tag-chip--custom.inc {
  background: rgba(45,201,55,0.15) !important;
  color: var(--green) !important;
  border-color: var(--green) !important;
  opacity: 1 !important;
}
.tag-chip--unlocked.inc:hover,
.tag-chip--custom.inc:hover { color: var(--text); opacity: 1; box-shadow: 0 2px 10px rgba(0,0,0,.15);}

.tag-chip--unlocked.exc,
.tag-chip--custom.exc {
  background: rgba(var(--primary-rgb),0.12);
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  text-decoration: line-through !important;
  opacity: 1 !important;
}
.tag-chip--unlocked.exc:hover,
.tag-chip--custom.exc:hover { color: var(--text); opacity: 1; box-shadow: 0 2px 10px rgba(0,0,0,.15);}

.tag-chip-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 8px;
  cursor: pointer;
  opacity: .5;
  flex-shrink: 0;
  transition: opacity .12s, background .12s;
  padding: 0;
}
.tag-chip-del:hover { opacity: 1; background: rgba(0,0,0,.12); box-shadow: 0 2px 10px rgba(0,0,0,.15);}

.tag-chip-add-wrap { display: contents; }
.tag-chip-input {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  font-size: 12px;
  color: var(--text-dim);
  font-family: inherit;
  outline: none;
  width: 72px;
  transition: border-color .15s, width .2s, color .15s;
  opacity: 1;
}
.tag-chip-input:focus {
  width: 108px;
  border-color: var(--primary);
  border-style: solid;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.tag-chip-input::placeholder { color: var(--text-dim); opacity: .65; }

.tags-panel {
  display: flex;
  flex-direction: column;
  height: 516px;
  overflow: hidden;
}

.tags-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* border-bottom: 1px solid var(--border); */
}
.tags-section:last-of-type { border-bottom: none; }

.tags-section-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tags-sec-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 7px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.tags-sec-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align-last: left;
}
.tags-sec-icon {
  font-size: 12px;
  color: var(--text-dim);
  padding-bottom: 3px;
}

.tags-sec-divider {
  height: 6px;
  background: var(--muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tags-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px 14px;
  align-content: flex-start;
}

.tag-logic-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.tlt-opt {
  padding: 3px 7px;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background .12s, color .12s;
}
.tlt-opt.active {
  background: var(--primary);
  color: var(--bg);
}
.tlt-opt--disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}
.tlt-sep { width: 1px; background: var(--border); }

.tags-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 14px 10px;
  flex-shrink: 0;
}
.tags-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.tags-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* PLAY STATE OVERLAY icon inside node-original-info */
.item .node-original-info.overlay-active {
  opacity: 1;
  top: -35px;
  transition: none;
  animation: node-overlay-show 2s ease-out forwards;
}

@keyframes node-overlay-show {
  0%   { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* === WF-CREATE SPLASH DIALOG === */

.splash-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: splash-fade-in .15s ease both;
}

@keyframes splash-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.splash-window {
  width: min(880px, 100%);
  max-height: min(680px, 94vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  animation: splash-slide-up .22s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes splash-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.splash-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

.splash-body .swim:first-of-type { margin-top: 0; }

.splash-blank-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 20px;
}

.splash-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.splash-wf-card {
  display: block;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  padding: 16px;
  cursor: pointer;
}

.splash-wf-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.10), var(--shadow);
}

.splash-wf-card:active { transform: translateY(1px); }

.splash-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 4px 0 0;
}

.splash-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}
.splash-card-tags:empty { display: none; }

@media (max-width: 600px) {
  .splash-blank-row { grid-template-columns: 1fr; }
  .splash-template-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .splash-template-grid { grid-template-columns: 1fr; }
}

/* === WF-CONFIG OVERLAY === */
.wf-config-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; z-index: 50; animation: splash-fade-in .15s ease both; }
.wf-config-panel { width: min(520px, 90%); max-height: min(580px, 90%); display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.18); animation: splash-slide-up .22s cubic-bezier(0.22,1,0.36,1) both; }
.wf-config-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; justify-content: flex-start; align-items: stretch; }
.wf-config-body .row { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 6px; width: 100%; }
.wf-config-body label { text-align: left; font-size: 13px; font-weight: 600; }
.wf-config-body input.input { min-height: unset; width: 100%; box-sizing: border-box; }
.wf-config-body textarea.input { min-height: 72px; width: 100%; box-sizing: border-box; }
.wf-tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.wf-tag { display: inline-flex; align-items: center; gap: 3px; }
.wf-tag-rm { background: none; border: none; cursor: pointer; color: inherit; padding: 0 0 0 2px; line-height: 1; font-size: 12px; opacity: .65; }
.wf-tag-rm:hover { opacity: 1; }
.wf-tag-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.wf-tag-add .input { flex: 1; }

/* === FEATURE TIP TOOLTIP === */
.feature-tip-wrap {
  position: fixed;
  z-index: 10000;
  width: 420px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28), 0 2px 10px rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.08);
}
/* left-pointing caret (popup appears to the right of the trigger) */
.feature-tip-wrap::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 17px;
  border-width: 7px 8px 7px 0;
  border-style: solid;
  border-color: transparent var(--border) transparent transparent;
}
.feature-tip-header {
  background: var(--card);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 12px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.feature-tip-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}
.feature-tip-close {
  font-size: 11px;
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.feature-tip-close:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--muted);
}
.feature-tip-image {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 252px;
  background: var(--muted);
}
.feature-tip-desc {
  flex: 1;
  overflow-y: auto;
  min-height: 54px;
  max-height: 160px;
  padding: 12px 14px 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  background: var(--card);
}
.feature-tip-footer {
  padding: 8px 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.feature-tip-dots {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.feature-tip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.feature-tip-dot.active {
  background: var(--primary);
  transform: scale(1.25);
}
.feature-tip-dot:hover:not(.active) {
  background: var(--text-dim);
}
.feature-tip-nav {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.feature-tip-nav:hover {
  background: var(--muted);
  color: var(--text);
}

