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

:root {
  --bg: #02040a;
  --surface: #060d1a;
  --surface2: #0a1428;
  --accent: #00d4ff;
  --accent2: #7b4fff;
  --accent3: #00ff88;
  --warning: #ffb800;
  --danger: #ff3c5a;
  --text: #e8edf8;
  --muted: #2a3a5c;
  --muted2: #4a6080;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 200; letter-spacing: 0.05em;
  -webkit-font-smoothing: antialiased;
}

/* ── BACKGROUND ── */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(0,212,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(123,79,255,0.05) 0%, transparent 60%),
    var(--bg);
}

.grid-layer {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,212,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── SCREENS ── */
.app { position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column; }
.screen { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.screen.active { display: flex; }

/* ══ SETUP SCREEN ══ */
.setup-screen {
  align-items: center; justify-content: flex-start;
  padding: 12px 20px 24px; gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: var(--bg);
}

.logo-block { text-align: center; }

.logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 36px; font-weight: 300; letter-spacing: 0.4em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1;
}

.tagline {
  font-size: 8px; letter-spacing: 0.6em;
  color: var(--muted2); text-transform: uppercase; margin-top: 4px;
}

.version-tag {
  display: inline-block; margin-top: 10px;
  font-size: 9px; letter-spacing: 0.4em;
  color: var(--accent3); border: 1px solid rgba(0,255,136,0.3);
  padding: 3px 12px;
}

.setup-card {
  width: 100%; max-width: 420px;
  background: rgba(6,13,26,0.95);
  border: 1px solid rgba(0,212,255,0.1);
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 14px;
}

.card-title {
  font-size: 9px; letter-spacing: 0.5em;
  color: var(--accent); text-transform: uppercase;
  border-bottom: 1px solid rgba(0,212,255,0.1);
  padding-bottom: 10px; margin-bottom: 4px;
}

.field-label {
  font-size: 8px; letter-spacing: 0.5em;
  color: rgba(255,255,255,0.75); text-transform: uppercase; margin-bottom: 5px;
}

.field-input {
  width: 100%; background: rgba(0,212,255,0.03);
  border: 1px solid rgba(0,212,255,0.1);
  color: var(--text); padding: 11px 13px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px; outline: none;
  transition: border-color 0.3s; border-radius: 0;
  -webkit-appearance: none;
}
.field-input:focus { border-color: rgba(0,212,255,0.4); }

.info-box {
  background: rgba(0,212,255,0.04);
  border: 1px solid rgba(0,212,255,0.1);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 4px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: rgba(255,255,255,0.4); letter-spacing: 0.05em; }
.info-row span:last-child  { color: rgba(0,212,255,0.8); font-family: 'Josefin Sans', sans-serif; }
.field-hint {
  font-size: 10px; color: var(--muted2);
  line-height: 1.7; letter-spacing: 0.03em;
}
.field-hint a { color: var(--accent); text-decoration: none; }

.btn-secondary {
  background: transparent; border: 1px solid rgba(0,212,255,0.3);
  color: var(--accent); padding: 14px; font-family: 'Josefin Sans', sans-serif;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  cursor: pointer; transition: all 0.3s; -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: rgba(0,212,255,0.1); }
.btn-primary {
  padding: 14px;
  background: linear-gradient(135deg, rgba(0,212,255,0.1), rgba(123,79,255,0.08));
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--accent);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.6em; text-transform: uppercase;
  cursor: pointer; transition: all 0.3s;
  border-radius: 0; -webkit-appearance: none;
}
.btn-primary:active {
  background: linear-gradient(135deg, rgba(0,212,255,0.2), rgba(123,79,255,0.15));
}

/* ══ MAIN SCREEN ══ */
.main-screen { padding: 0; }

/* Header */
.main-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  border-bottom: 1px solid rgba(0,212,255,0.07);
  background: rgba(2,4,10,0.8); backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.header-left { display: flex; flex-direction: column; align-items: flex-start; gap: 0px; }

.logo-wrapper {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0px;
}
.main-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 300; letter-spacing: 0.4em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.main-version {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; font-weight: 400; letter-spacing: 0.15em;
  color: rgba(0,212,255,0.4);
  margin-left: 2px;
}

.system-status {
  display: flex; gap: 6px; align-items: center;
}

.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent3);
  box-shadow: 0 0 8px var(--accent3);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-label {
  font-size: 8px; letter-spacing: 0.3em;
  color: var(--accent3); text-transform: uppercase;
}

.header-center {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}

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

/* ── DARK/LIGHT MODE SWITCH ── */
.theme-switch {
  position: relative; width: 36px; height: 20px; cursor: pointer;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider {
  position: absolute; inset: 0; border-radius: 20px;
  background: rgba(0,212,255,0.15);
  border: 1px solid rgba(0,212,255,0.25);
  transition: all 0.3s;
}
.theme-slider:before {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  left: 2px; top: 2px;
  background: var(--accent);
  transition: all 0.3s;
}
.theme-switch input:checked + .theme-slider { background: rgba(255,255,255,0.9); border-color: rgba(0,0,0,0.2); }
.theme-switch input:checked + .theme-slider:before { transform: translateX(16px); background: #02040a; }



.settings-btn {
  background: none; border: none;
  color: var(--muted2); font-size: 16px;
  cursor: pointer; padding: 8px 14px 8px 8px;
  transition: color 0.3s;
}
.settings-btn:active { color: var(--accent); }

.mode-badge {
  font-size: 15px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(0,212,255,0.2);
  color: var(--muted2); cursor: pointer;
  transition: all 0.3s; border-radius: 50%;
  background: transparent; padding: 0;
}
.mode-badge:active { border-color: var(--accent); color: var(--accent); }
.mode-badge.text-mode {
  color: var(--accent3);
  border-color: rgba(0,255,136,0.3);
  background: rgba(0,255,136,0.05);
  box-shadow: 0 0 8px rgba(0,255,136,0.15);
}

/* ── MAIN BODY ── */
.main-body {
  display: flex; flex-direction: column;
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 0;
}

/* ── ORB SECTION ── */
.orb-section {
  display: flex; flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 4px 6px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Colonne laterali agenti e servizi — larghezza fissa */
.dock-left {
  display: flex; flex-direction: column; gap: 5px;
  flex-shrink: 0;
  width: 115px;
}

.dock-right {
  display: flex; flex-direction: column; gap: 5px;
  flex-shrink: 0;
  width: 80px;
}

.dock-center {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  flex: 1;
  flex-shrink: 0;
  min-width: 0;
  justify-content: space-between;
}

.dock-label {
  font-size: 8px; letter-spacing: 0.3em;
  color: rgba(255,255,255,0.9);
  font-weight: bold;
  text-transform: uppercase;
  text-align: center; margin-bottom: 2px;
}

/* Agenti di sistema — bordo ciano più marcato */
.dock-agent-card.system-agent {
  border-color: rgba(0,212,255,0.2);
  background: rgba(0,212,255,0.04);
}

/* Barra progetti orizzontale */
.projects-section {
  display: flex; flex-direction: column;
  align-items: flex-start;
  padding: 4px 4px 2px 12px; flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  margin-top: 30px;
}
.projects-label {
  text-align: left; margin-bottom: 4px;
  padding-left: 0px;
}

/* FIX M-32: overflow-x da hidden ad auto per permettere lo scroll orizzontale dei progetti */
.projects-bar {
  display: flex; flex-direction: row;
  align-items: center; justify-content: flex-start;
  gap: 5px; padding: 0 0;
  flex-shrink: 0; width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* nasconde scrollbar su Firefox */
}
.projects-bar::-webkit-scrollbar { display: none; } /* nasconde scrollbar su Chrome/Safari */
.project-chip {
  background: rgba(6,13,26,0.8);
  border: 1px solid rgba(0,212,255,0.06);
  padding: 5px 4px; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  transition: all 0.3s;
  width: 52px; flex-shrink: 0;
}
.project-chip:active { border-color: rgba(0,212,255,0.4); }
.proj-icon { font-size: 16px; }
.proj-name {
  font-size: 6px; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.85); text-transform: uppercase;
  text-align: center; font-family: 'Josefin Sans', sans-serif;
}
.proj-status {
  font-size: 6px; letter-spacing: 0.05em;
  text-transform: uppercase; font-family: 'Share Tech Mono', monospace;
  padding: 1px 4px; border-radius: 2px;
  background: rgba(0,212,255,0.08); color: var(--accent);
}
.proj-status.realizzazione { color: var(--warning); background: rgba(255,184,0,0.1); }
.proj-status.beta { color: var(--accent3); background: rgba(0,255,136,0.1); }
.proj-status.completo { color: var(--accent3); background: rgba(0,255,136,0.15); }

/* 🫀 Orb cuore — appare durante esecuzione */
.orb-container.thinking .orb-outer,
.orb-container.coordinating .orb-outer,
.orb-container.executing .orb-outer { opacity: 0 !important; transition: opacity 0.3s; }

@keyframes heartbeat {
  0%   { transform: scale(1); }
  14%  { transform: scale(1.15); }
  28%  { transform: scale(1); }
  42%  { transform: scale(1.1); }
  70%  { transform: scale(1); }
}
.orb-container.thinking .orb-symbol,
.orb-container.coordinating .orb-symbol,
.orb-container.executing .orb-symbol {
  animation: heartbeat 1.2s ease-in-out infinite;
  font-size: 38px;
  filter: drop-shadow(0 0 12px rgba(255,80,80,0.7));
  z-index: 10;
}

/* 🆘 Orb timeout — quando bloccato */
.orb-container.timeout .orb-outer { opacity: 0 !important; transition: opacity 0.3s; }
@keyframes sos-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(0.9); }
}
.orb-container.timeout .orb-symbol {
  animation: sos-blink 0.8s ease-in-out infinite;
  font-size: 38px;
  filter: drop-shadow(0 0 14px rgba(255,60,60,0.9));
  z-index: 10;
}

/* 🧠 Brain sotto l'orb — quando agente lavora */
.brain-indicator {
  font-size: 22px; opacity: 0; transition: opacity 0.4s;
  text-align: center; height: 28px;
  display: flex; align-items: center; justify-content: center;
}
.brain-indicator.active { opacity: 1; }

@keyframes neural-pulse {
  0%   { filter: drop-shadow(0 0 2px rgba(123,79,255,0.3)); transform: scale(1); }
  25%  { filter: drop-shadow(0 0 8px rgba(0,212,255,0.8)); transform: scale(1.08); }
  50%  { filter: drop-shadow(0 0 12px rgba(123,79,255,0.9)); transform: scale(1.05); }
  75%  { filter: drop-shadow(0 0 6px rgba(0,255,136,0.7)); transform: scale(1.1); }
  100% { filter: drop-shadow(0 0 2px rgba(123,79,255,0.3)); transform: scale(1); }
}
.brain-indicator.active {
  animation: neural-pulse 1.5s ease-in-out infinite;
}

/* Card agente nella dock */
.dock-agent-card {
  background: rgba(6,13,26,0.8);
  border: 1px solid rgba(0,212,255,0.06);
  padding: 5px 4px;
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  cursor: pointer; transition: all 0.3s;
  width: 52px;
}
.dock-agent-card:active { border-color: rgba(0,212,255,0.4); }
.dock-agent-card .agent-icon { font-size: 16px; }
.dock-agent-card .agent-name {
  font-size: 6px; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.85);
  text-align: center;
}
.dock-agent-card .agent-status-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(0,212,255,0.3);
}
.dock-agent-card.busy { border-color: rgba(255,184,0,0.4); }
.dock-agent-card.busy .agent-status-dot { background: var(--warning); }

/* Card servizio nella dock */
.dock-service-card {
  background: rgba(6,13,26,0.8);
  border: 1px solid rgba(0,212,255,0.06);
  padding: 5px 6px;
  display: flex; flex-direction: row;
  align-items: center; gap: 4px;
  width: 76px;
}
.dock-service-card .svc-icon { font-size: 12px; }
.dock-service-card .svc-name {
  font-size: 6px; letter-spacing: 0.05em;
  text-transform: uppercase; color: rgba(255,255,255,0.7);
}
.dock-service-card .svc-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,60,90,0.6); margin-left: auto; flex-shrink: 0;
}
.dock-service-card.active .svc-dot { background: var(--accent3); }

.orb-container {
  position: relative; width: 55px; height: 55px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

.pulse-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.06);
  animation: pulse-idle 3s ease-out infinite;
  pointer-events: none;
}
.pulse-ring:nth-child(1) { inset: -8px; animation-delay: 0s; }
.pulse-ring:nth-child(2) { inset: -16px; animation-delay: 1s; }
.pulse-ring:nth-child(3) { inset: -24px; animation-delay: 2s; }

@keyframes pulse-idle {
  0% { opacity: 0; transform: scale(0.93); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}

.orb-container.listening .pulse-ring { border-color: rgba(0,212,255,0.2); animation: pulse-active 1s ease-out infinite; }
.orb-container.speaking .pulse-ring { border-color: rgba(123,79,255,0.2); animation: pulse-active 0.8s ease-out infinite; }
.orb-container.approval .pulse-ring { border-color: rgba(255,184,0,0.3); animation: pulse-active 0.6s ease-out infinite; }
.orb-container.executing .pulse-ring { border-color: rgba(0,255,136,0.2); animation: pulse-active 1.2s ease-out infinite; }
.orb-container.coordinating .pulse-ring { border-color: rgba(0,212,255,0.15); animation: pulse-active 0.5s ease-out infinite; }

@keyframes pulse-active {
  0% { opacity: 0; transform: scale(0.88); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.1); }
}

.orb-outer {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    rgba(0,212,255,0.15) 0%, rgba(123,79,255,0.06) 50%, rgba(2,4,10,0.7) 100%
  );
  border: 1px solid rgba(0,212,255,0.12);
  transition: all 0.5s ease;
}

.orb-container.listening .orb-outer {
  background: radial-gradient(circle at 30% 30%, rgba(0,212,255,0.35) 0%, rgba(0,212,255,0.1) 50%, rgba(2,4,10,0.5) 100%);
  border-color: rgba(0,212,255,0.4);
  box-shadow: 0 0 50px rgba(0,212,255,0.2), inset 0 0 30px rgba(0,212,255,0.08);
}
.orb-container.speaking .orb-outer {
  background: radial-gradient(circle at 30% 30%, rgba(123,79,255,0.4) 0%, rgba(123,79,255,0.12) 50%, rgba(2,4,10,0.5) 100%);
  border-color: rgba(123,79,255,0.4);
  box-shadow: 0 0 50px rgba(123,79,255,0.2), inset 0 0 30px rgba(123,79,255,0.08);
}
.orb-container.approval .orb-outer {
  background: radial-gradient(circle at 30% 30%, rgba(255,184,0,0.4) 0%, rgba(255,184,0,0.12) 50%, rgba(2,4,10,0.5) 100%);
  border-color: rgba(255,184,0,0.5);
  box-shadow: 0 0 60px rgba(255,184,0,0.25), inset 0 0 30px rgba(255,184,0,0.1);
}
.orb-container.executing .orb-outer {
  background: radial-gradient(circle at 30% 30%, rgba(0,255,136,0.25) 0%, rgba(0,255,136,0.08) 50%, rgba(2,4,10,0.5) 100%);
  border-color: rgba(0,255,136,0.35);
  box-shadow: 0 0 40px rgba(0,255,136,0.15);
}
.orb-container.coordinating .orb-outer {
  background: radial-gradient(circle at 30% 30%, rgba(0,212,255,0.2) 0%, rgba(123,79,255,0.1) 50%, rgba(2,4,10,0.5) 100%);
  border-color: rgba(0,212,255,0.25);
  box-shadow: 0 0 40px rgba(0,212,255,0.1), 0 0 40px rgba(123,79,255,0.1);
}

/* FIX M-33: orb-inner centrato correttamente con flexbox */
.orb-inner {
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0,212,255,0.08), var(--surface) 70%);
  border: 1px solid rgba(0,212,255,0.08);
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1; transition: all 0.5s ease;
}

.orb-spin {
  position: absolute; inset: -1px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, rgba(0,212,255,0.5) 25%, transparent 50%, rgba(123,79,255,0.5) 75%, transparent 100%);
  opacity: 0; animation: spin 3s linear infinite; transition: opacity 0.4s;
}
.orb-container.listening .orb-spin,
.orb-container.speaking .orb-spin,
.orb-container.approval .orb-spin { opacity: 1; }
/* orb-spin nascosto durante 🫀 */
.orb-container.thinking .orb-spin { opacity: 0 !important; }
.orb-container.executing .orb-spin,
.orb-container.coordinating .orb-spin { opacity: 0 !important; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.orb-symbol {
  font-size: 32px; transition: all 0.4s;
  filter: drop-shadow(0 0 10px rgba(0,212,255,0.5));
}
.orb-container.speaking .orb-symbol { filter: drop-shadow(0 0 10px rgba(123,79,255,0.6)); }
.orb-container.approval .orb-symbol { filter: drop-shadow(0 0 14px rgba(255,184,0,0.8)); }
.orb-container.executing .orb-symbol { filter: drop-shadow(0 0 10px rgba(0,255,136,0.6)); }
.orb-container.coordinating .orb-symbol { filter: drop-shadow(0 0 10px rgba(0,212,255,0.4)) drop-shadow(0 0 20px rgba(123,79,255,0.4)); }

.status-area {
  display: flex; align-items: center; justify-content: center;
  height: 18px; flex-shrink: 0;
  overflow: hidden;
  margin: 2px 0 6px 0;
}

.status-text {
  font-size: 9px; letter-spacing: 0.5em;
  text-transform: uppercase; color: rgba(255,255,255,0.55);
  transition: color 0.4s; text-align: center;
  margin-top: 6px;
}
.status-text.listening { color: var(--accent); }
.status-text.thinking { color: rgba(0,212,255,0.5); }
.status-text.speaking { color: var(--accent2); }
.status-text.error { color: var(--danger); }
.status-text.approval { color: var(--warning); }
.status-text.executing { color: var(--accent3); }
.status-text.coordinating { color: var(--accent); }

.waveform {
  display: flex; gap: 3px; align-items: center;
  height: 20px; opacity: 0; transition: opacity 0.3s;
}
.waveform.active { opacity: 1; }
.waveform span {
  display: block; width: 2px; border-radius: 2px;
  background: var(--accent2);
  animation: wave 0.9s ease-in-out infinite;
}
.waveform span:nth-child(1) { height: 5px; animation-delay: 0s; }
.waveform span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.waveform span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.waveform span:nth-child(4) { height: 12px; animation-delay: 0.1s; }
.waveform span:nth-child(5) { height: 5px; animation-delay: 0s; }
.waveform span:nth-child(6) { height: 16px; animation-delay: 0.15s; }
.waveform span:nth-child(7) { height: 8px; animation-delay: 0.05s; }
/* FIX C-03: aggiunta regole mancanti per waveform span 8-10 */
.waveform span:nth-child(8) { height: 14px; animation-delay: 0.12s; }
.waveform span:nth-child(9) { height: 6px; animation-delay: 0.03s; }
.waveform span:nth-child(10) { height: 10px; animation-delay: 0.08s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); opacity: 0.4; }
  50% { transform: scaleY(1.3); opacity: 1; }
}

/* ── AGENTS GRID ── */
.agents-section { display: none; } /* dock integrata nell'orb-section */

.agent-card {
  background: rgba(6,13,26,0.8);
  border: 1px solid rgba(0,212,255,0.06);
  padding: 8px 6px;
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  cursor: pointer; transition: all 0.3s;
  position: relative; overflow: hidden;
}
.agent-card:active { border-color: rgba(0,212,255,0.25); }
.agent-card.active-agent {
  border-color: rgba(0,255,136,0.3);
  background: rgba(0,255,136,0.04);
}
.agent-card.busy-agent {
  border-color: rgba(255,184,0,0.3);
  background: rgba(255,184,0,0.03);
}

.agent-icon { font-size: 16px; }

.agent-name {
  font-size: 7px; letter-spacing: 0.15em;
  text-transform: uppercase; color: rgba(255,255,255,0.85);
  text-align: center; line-height: 1.3;
}

.agent-status-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--muted);
  transition: all 0.3s;
}
.agent-card.active-agent .agent-status-dot {
  background: var(--accent3);
  box-shadow: 0 0 6px var(--accent3);
  animation: blink 1.5s infinite;
}
.agent-card.busy-agent .agent-status-dot {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
  animation: blink 0.8s infinite;
}

/* ── APPROVAL PANEL ── */
.approval-panel {
  display: none; flex-shrink: 0;
  background: rgba(6,13,26,0.98);
  border: 1px solid rgba(255,184,0,0.3);
  padding: 14px 16px; margin-bottom: 8px;
  animation: slideUp 0.3s ease;
}
.approval-panel.visible { display: block; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.approval-header {
  font-size: 8px; letter-spacing: 0.5em;
  color: var(--warning); text-transform: uppercase;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}

.approval-action {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; color: var(--text);
  line-height: 1.5; margin-bottom: 12px;
}

.approval-meta {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--muted2);
  margin-bottom: 12px;
}

.approval-buttons { display: flex; gap: 8px; }

/* FIX C-02 / M-10: inversione colori — APPROVA = verde, RIFIUTA = rosso (logica corretta) */
.btn-approve {
  flex: 1; padding: 10px;
  background: rgba(0,255,136,0.08);
  border: 1px solid rgba(0,255,136,0.3);
  color: var(--accent3);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; letter-spacing: 0.4em;
  text-transform: uppercase; cursor: pointer;
  border-radius: 0; transition: all 0.25s;
}
.btn-approve:active { background: rgba(0,255,136,0.18); }

.btn-reject {
  flex: 1; padding: 10px;
  background: rgba(255,60,90,0.07);
  border: 1px solid rgba(255,60,90,0.25);
  color: var(--danger);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; letter-spacing: 0.4em;
  text-transform: uppercase; cursor: pointer;
  border-radius: 0; transition: all 0.25s;
}
.btn-reject:active { background: rgba(255,60,90,0.16); }

/* ── ACTIVITY LOG ── */
/* ── LOG ROW ── */
.log-row {
  display: flex; flex-direction: row;
  flex: 1; min-height: 0; gap: 0;
}
.log-left {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  min-height: 0;
}
.log-right {
  width: 48px; flex-shrink: 0;
  display: flex; align-items: flex-end;
  padding-bottom: 8px;
}

/* ── INPUT ROW ── */
.input-row {
  display: flex; flex-direction: row;
  flex-shrink: 0; gap: 0;
}
.input-left {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.input-right {
  width: 48px; flex-shrink: 0;
  display: flex; flex-direction: column;
  gap: 4px; justify-content: flex-end;
  padding-bottom: 4px;
}
.activity-log {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  min-height: calc(100% + 15px);
  margin-bottom: 4px;
  background: rgba(6,13,26,0.6);
  border: 1px solid rgba(0,212,255,0.06);
  padding: 10px 12px;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
}

.log-empty {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; color: var(--muted);
  font-style: italic; text-align: center;
  padding: 20px 0;
}

.log-entry {
  display: flex; gap: 8px; margin-bottom: 10px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.log-source {
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px; letter-spacing: 0.1em;
  text-transform: uppercase; min-width: 52px;
  padding-top: 2px; flex-shrink: 0;
}
.log-source.boss { color: rgba(0,212,255,0.6); }
.log-source.suimi { color: rgba(123,79,255,0.6); }
.log-source.agent { color: rgba(0,255,136,0.5); }
.log-source.system { color: rgba(255,184,0,0.5); }

.log-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 300;
  color: rgba(232,237,248,0.85); line-height: 1.5; flex: 1;
}
.log-text.boss { color: rgba(0,212,255,0.9); font-family: 'Josefin Sans', sans-serif; font-size: 13px; }
.log-text.system { color: rgba(255,184,0,0.7); font-family: 'Share Tech Mono', monospace; font-size: 11px; }

/* ── BOTTOM CONTROLS ── */
.bottom-controls {
  display: flex; gap: 6px;
  padding: 8px 0 calc(var(--safe-bottom) + 10px);
  flex-shrink: 0;
}

.ctrl-btn {
  flex: 1; background: transparent;
  border: 1px solid rgba(0,212,255,0.08);
  color: rgba(255,255,255,0.8); padding: 9px 6px;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 8px; font-weight: 200;
  letter-spacing: 0.3em; text-transform: uppercase;
  cursor: pointer; transition: all 0.3s;
  border-radius: 0; -webkit-appearance: none;
}
.ctrl-btn:active { border-color: var(--accent); color: var(--accent); }
.ctrl-btn.danger:active { border-color: var(--danger); color: var(--danger); }

/* ── FILE PREVIEW BAR ── */
.file-preview-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 4px 0 4px; flex-shrink: 0; min-height: 0;
}

.file-chip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.15);
  padding: 4px 8px; max-width: 130px;
  animation: fadeIn 0.2s ease;
}

.file-chip-thumb {
  width: 24px; height: 24px; object-fit: cover;
  border: 1px solid rgba(0,212,255,0.1); flex-shrink: 0;
}

.file-chip-icon { font-size: 14px; flex-shrink: 0; }

.file-chip-name {
  font-size: 9px; letter-spacing: 0.04em;
  color: var(--accent); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
}

.file-chip-remove {
  background: none; border: none;
  color: var(--muted2); font-size: 12px;
  cursor: pointer; padding: 0; flex-shrink: 0; line-height: 1;
}
.file-chip-remove:active { color: var(--danger); }

/* FIX C-01 / M-09: rimosso !important da display:none per permettere a .visible di funzionare */
.file-send-bar {
  display: none; gap: 8px; align-items: center;
  padding: 4px 0; flex-shrink: 0;
}
.file-send-bar.visible { display: flex; }

.file-send-input {
  flex: 1; background: rgba(0,212,255,0.03);
  border: 1px solid rgba(0,212,255,0.1);
  color: var(--text); padding: 9px 12px;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 12px; outline: none; border-radius: 0;
  -webkit-appearance: none;
}
.file-send-input::placeholder { color: var(--muted2); }
.file-send-input:focus { border-color: rgba(0,212,255,0.3); }

.file-send-btn {
  padding: 9px 14px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--accent);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; letter-spacing: 0.3em;
  text-transform: uppercase; cursor: pointer; border-radius: 0;
}
.file-send-btn:active { background: rgba(0,212,255,0.18); }

.log-image {
  max-width: 120px; max-height: 80px;
  border: 1px solid rgba(0,212,255,0.15);
  margin-top: 4px; display: block;
}

/* ── TEXT INPUT BAR ── */
.text-input-bar {
  display: flex; flex-shrink: 0;
  border-top: 1px solid rgba(0,212,255,0.06);
}

.text-input {
  flex: 1; background: rgba(0,212,255,0.03);
  border: 1px solid rgba(0,212,255,0.1);
  color: var(--text); padding: 12px 14px;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 14px; font-weight: 200;
  letter-spacing: 0.03em;
  outline: none; border-radius: 0;
  resize: none; line-height: 1.6;
  min-height: 72px;
  -webkit-appearance: none;
  transition: border-color 0.3s;
}
.text-input::placeholder { color: rgba(255,255,255,0.4); }
.text-input:focus { border-color: rgba(0,212,255,0.3); }



.attach-btn {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--muted2); padding: 8px 10px;
  font-size: 15px; cursor: pointer; border-radius: 0;
  transition: all 0.2s; line-height: 1;
}
.attach-btn:active { border-color: var(--accent); color: var(--accent); }

.send-btn {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--accent); padding: 8px 10px;
  font-size: 15px; cursor: pointer; border-radius: 0;
  transition: all 0.2s; line-height: 1;
}
.send-btn:active { background: rgba(0,212,255,0.25); }

.log-copy-fixed {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--accent); padding: 8px 10px;
  font-size: 15px; cursor: pointer; border-radius: 0;
  transition: all 0.2s; line-height: 1;
}
.log-copy-fixed:active { background: rgba(0,212,255,0.25); }

/* ── MEMORY PANEL ── */
.memory-panel {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(2,4,10,0.97);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
}

.memory-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; letter-spacing: 0.3em;
  color: var(--accent); text-transform: uppercase;
  border-bottom: 1px solid rgba(0,212,255,0.1);
  padding-bottom: 12px; margin-bottom: 12px;
}

.memory-close-btn {
  background: none; border: none;
  color: var(--muted2); font-size: 20px;
  cursor: pointer; padding: 0; line-height: 1;
}

.memory-content {
  flex: 1; overflow-y: auto;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; color: rgba(232,237,248,0.7);
  line-height: 1.8; padding: 8px 0;
  white-space: pre-wrap; word-break: break-word;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
}

.memory-actions {
  display: flex; gap: 8px; padding-top: 12px;
  border-top: 1px solid rgba(0,212,255,0.08);
  flex-wrap: wrap;
}

.memory-btn {
  flex: 1; padding: 10px 8px;
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.15);
  color: var(--accent);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; letter-spacing: 0.3em;
  text-transform: uppercase; cursor: pointer; border-radius: 0;
  min-width: 80px;
}
.memory-btn:active { background: rgba(0,212,255,0.15); }
.memory-btn.danger-btn { color: var(--danger); border-color: rgba(255,60,90,0.2); background: rgba(255,60,90,0.05); }
.memory-btn.danger-btn:active { background: rgba(255,60,90,0.15); }

.hidden { display: none !important; }

/* Install banner */
.install-banner {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 10px);
  left: 12px; right: 12px;
  background: rgba(6,13,26,0.97);
  border: 1px solid rgba(0,212,255,0.2);
  padding: 12px 16px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
  z-index: 100;
}
.install-banner p { font-size: 11px; color: rgba(232,237,248,0.7); line-height: 1.5; }
.install-banner p strong { color: var(--accent); font-weight: 300; }
.install-btn {
  flex-shrink: 0;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--accent); padding: 7px 14px;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 9px; letter-spacing: 0.3em;
  text-transform: uppercase; cursor: pointer; border-radius: 0;
}
.dismiss-btn { background: none; border: none; color: var(--muted2); font-size: 18px; cursor: pointer; }
/* ── LIGHT MODE ── */
/* FIX M-36/M-37: refactoring light-mode con variabili CSS.
   Tutti i componenti che usano var(--bg), var(--surface), var(--text) etc.
   si adattano automaticamente senza regole duplicate. */
body.light-mode {
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface2: #f0f4fb;
  --text: #0a0f1e;
  --muted: rgba(10,15,30,0.35);
  --muted2: rgba(10,15,30,0.55);
  --accent: #0055bb;
  --accent2: #5500bb;
  --accent3: #007a3d;
  --warning: #bb5500;
  --danger: #bb0000;
}
/* Override specifici dove le variabili non bastano (gradienti, backdrop-filter) */
body.light-mode .bg-layer {
  background: radial-gradient(ellipse at 20% 20%, rgba(0,80,180,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(80,0,180,0.04) 0%, transparent 60%), #eef1f7;
}
body.light-mode .grid-layer { opacity: 0.04; filter: invert(1); }
body.light-mode .main-header { background: rgba(238,241,247,0.95); border-color: rgba(0,80,180,0.1); }
body.light-mode .activity-log { background: rgba(255,255,255,0.85); border-color: rgba(0,80,180,0.12); }
body.light-mode .dock-agent-card,
body.light-mode .project-chip,
body.light-mode .dock-service-card { background: rgba(255,255,255,0.9); border-color: rgba(0,80,180,0.12); }
body.light-mode .text-input { background: rgba(255,255,255,0.9); border-color: rgba(0,80,180,0.15); color: var(--text); }
body.light-mode .text-input-bar { border-color: rgba(0,80,180,0.1); }
body.light-mode .bottom-controls { border-color: rgba(0,80,180,0.1); }
body.light-mode .orb-outer { background: radial-gradient(circle at 30% 30%, rgba(0,80,180,0.15) 0%, rgba(80,40,180,0.06) 50%, rgba(238,241,247,0.7) 100%); }
body.light-mode .log-source { color: rgba(10,15,30,0.5); }
body.light-mode .log-text { color: rgba(10,15,30,0.85); }
body.light-mode .log-text.suimi { color: var(--text); }
/* Override aggiuntivi per componenti non coperti in precedenza */
body.light-mode .approval-panel { background: rgba(238,241,247,0.98); border-color: rgba(0,80,180,0.2); }
body.light-mode .file-chip { background: rgba(255,255,255,0.9); border-color: rgba(0,80,180,0.15); }
body.light-mode .file-chip-name { color: var(--accent); }
body.light-mode .setup-screen { background: var(--bg); }
