/* ═══════════════════════════════════════════════════════════
   M.A.R.T. — interfaccia sci-fi
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #030712;
  --bg2: #06101f;
  --panel: rgba(8, 22, 42, 0.72);
  --panel-solid: #0a1a30;
  --panel2: rgba(14, 34, 60, 0.6);
  --line: rgba(56, 189, 248, 0.16);
  --line2: rgba(56, 189, 248, 0.32);
  --accent: #38bdf8;
  --accent2: #22d3ee;
  --accent3: #818cf8;
  --text: #e3f2ff;
  --muted: #7d9fbf;
  --dim: #4a6a8a;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --glow: 0 0 18px rgba(56, 189, 248, 0.35);
  --radius: 14px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-hud: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --font-title: 'Orbitron', 'Rajdhani', 'Segoe UI', sans-serif;
  --sidebar: 250px;
  --hud: 300px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
::selection { background: rgba(56, 189, 248, 0.35); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.18); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Sfondo ── */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 80%);
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(800px 500px at 50% -10%, rgba(34, 211, 238, 0.12), transparent 70%),
    radial-gradient(600px 400px at 100% 100%, rgba(129, 140, 248, 0.08), transparent 70%),
    radial-gradient(500px 400px at 0% 80%, rgba(56, 189, 248, 0.06), transparent 70%);
}

/* ── Layout ── */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr var(--hud);
  height: 100vh; height: 100dvh;
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ── Sidebar ── */
.sidebar {
  background: linear-gradient(180deg, rgba(6, 16, 31, 0.92), rgba(3, 7, 18, 0.95));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  min-height: 0;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-orb { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; box-shadow: var(--glow); position: relative; }
.brand-orb::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; border: 2px dashed rgba(34, 211, 238, 0.5); animation: spin 12s linear infinite; }
.brand-orb span { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle, #e0f7ff, var(--accent) 60%); box-shadow: 0 0 12px var(--accent); }
.brand-name { font-family: var(--font-title); font-weight: 900; letter-spacing: 3px; font-size: 18px; }
.brand-sub { font-family: var(--font-hud); color: var(--ok); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.brand-sub::before { content: '● '; animation: blink 2s infinite; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; background: none; text-align: left; width: 100%;
  font-family: var(--font-hud); font-weight: 600; font-size: 15.5px; letter-spacing: .4px;
  transition: all .18s;
}
.nav-item:hover { color: var(--text); background: rgba(56, 189, 248, 0.06); }
.nav-item.active { color: var(--text); background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.02)); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active svg { color: var(--accent); filter: drop-shadow(0 0 6px var(--accent)); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--dim); font-family: var(--font); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 10px; }
.quick-capture { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); }
.quick-capture label { display: block; font-family: var(--font-hud); font-weight: 700; font-size: 13px; letter-spacing: 1px; color: var(--accent2); margin-bottom: 6px; text-transform: uppercase; }
.quick-capture form { display: flex; gap: 6px; }
.quick-capture input { flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; outline: none; }
.quick-capture input:focus { border-color: var(--accent); box-shadow: var(--glow); }
.quick-capture button { background: rgba(56, 189, 248, 0.15); border: 1px solid var(--line2); border-radius: 8px; color: var(--accent); cursor: pointer; padding: 0 10px; }
.side-foot { margin-top: 10px; text-align: center; font-size: 11px; color: var(--dim); font-family: var(--font-hud); letter-spacing: 1px; }
.scrim { display: none; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 7, 18, 0.55);
  backdrop-filter: blur(10px);
  padding-top: max(12px, env(safe-area-inset-top));
}
.title-block { flex: 1; text-align: center; min-width: 0; }
.title {
  margin: 0; font-family: var(--font-title); font-weight: 900; font-size: 26px; letter-spacing: 10px;
  background: linear-gradient(180deg, #f0fbff, #7dd3fc 60%, #38bdf8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(56, 189, 248, 0.45));
  padding-left: 10px;
}
.subtitle { font-family: var(--font-hud); color: var(--muted); font-size: 12.5px; letter-spacing: 4px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.clock { font-family: var(--font-hud); font-weight: 600; font-size: 17px; color: var(--accent); letter-spacing: 1.5px; margin-right: 6px; text-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(8, 22, 42, 0.6);
  color: var(--muted); cursor: pointer; transition: all .18s; flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--line2); box-shadow: var(--glow); }
.icon-btn.on { color: var(--accent); border-color: var(--line2); background: rgba(56, 189, 248, 0.12); }
.icon-btn.alert { color: var(--warn); }
.menu-btn { display: none; }

/* ── Chat ── */
.chat-scroll { flex: 1; overflow-y: auto; padding: 24px 20px 12px; position: relative; scroll-behavior: smooth; }
.messages { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }

/* Nucleo con anelli concentrici */
.core { position: sticky; top: 30%; height: 0; display: flex; justify-content: center; pointer-events: none; z-index: 0; }
.core > * { position: absolute; top: 0; left: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
.core .ring { border: 1px solid rgba(56, 189, 248, 0.10); }
.core .r1 { width: 160px; height: 160px; border-style: dashed; animation: spin 40s linear infinite; }
.core .r2 { width: 250px; height: 250px; border-color: rgba(34, 211, 238, 0.07); }
.core .r3 { width: 340px; height: 340px; border-style: dotted; border-width: 2px; border-color: rgba(56, 189, 248, 0.06); animation: spin 90s linear infinite reverse; }
.core .r4 { width: 440px; height: 440px; border-color: rgba(56, 189, 248, 0.04); }
.core-center { width: 70px; height: 70px; background: radial-gradient(circle, rgba(125, 211, 252, 0.12), transparent 70%); }
.core.thinking .ring { animation: pulse-ring 1.6s ease-out infinite; border-color: rgba(56, 189, 248, 0.25); }
.core.thinking .r2 { animation-delay: .25s; }
.core.thinking .r3 { animation-delay: .5s; }
.core.thinking .r4 { animation-delay: .75s; }
.core.thinking .core-center { background: radial-gradient(circle, rgba(125, 211, 252, 0.4), transparent 70%); animation: breathe 1s ease-in-out infinite; }
.core.speaking .r1 { border-color: rgba(34, 211, 238, 0.35); animation: spin 6s linear infinite; }
.core.speaking .core-center { background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 70%); animation: breathe .5s ease-in-out infinite; }

.msg { display: flex; gap: 12px; align-items: flex-start; animation: msg-in .35s cubic-bezier(.2, .8, .2, 1); }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--font-title); font-size: 11px; font-weight: 700; }
.msg.mart .avatar { border: 1px solid var(--line2); background: radial-gradient(circle, rgba(56, 189, 248, 0.25), rgba(3, 7, 18, 0.9) 70%); color: var(--accent); box-shadow: var(--glow); }
.msg.user .avatar { background: linear-gradient(135deg, #1e3a5f, #0f2440); color: var(--muted); border: 1px solid var(--line); }
.bubble { max-width: min(680px, 84%); padding: 11px 15px; border-radius: 16px; position: relative; overflow-wrap: anywhere; }
.msg.mart .bubble { background: var(--panel); border: 1px solid var(--line); border-top-left-radius: 4px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(125, 211, 252, 0.06); backdrop-filter: blur(8px); }
.msg.user .bubble { background: linear-gradient(135deg, rgba(14, 116, 144, 0.55), rgba(30, 64, 175, 0.45)); border: 1px solid rgba(56, 189, 248, 0.3); border-top-right-radius: 4px; }
.bubble .meta { display: block; font-size: 11px; color: var(--dim); margin-top: 4px; font-family: var(--font-hud); letter-spacing: .5px; }
.msg.user .meta { text-align: right; color: rgba(186, 230, 253, 0.55); }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: #fff; }
.msg.mart .bubble strong { color: #bae6fd; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); margin-left: 2px; vertical-align: -2px; animation: blink .8s steps(1) infinite; box-shadow: 0 0 8px var(--accent); }
.speak-btn { position: absolute; right: -36px; top: 4px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--dim); cursor: pointer; display: grid; place-items: center; opacity: 0; transition: .2s; }
.speak-btn svg { width: 16px; height: 16px; }
.msg:hover .speak-btn { opacity: 1; }
.speak-btn:hover { color: var(--accent); border-color: var(--line); }

/* Indicatore "sto pensando" */
.thinking-bubble { display: flex; align-items: center; gap: 12px; color: var(--muted); font-family: var(--font-hud); letter-spacing: 1px; }
.mini-core { width: 26px; height: 26px; position: relative; }
.mini-core i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: pulse-ring 1.4s ease-out infinite; opacity: 0; }
.mini-core i:nth-child(2) { animation-delay: .45s; } .mini-core i:nth-child(3) { animation-delay: .9s; }
.mini-core::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.scan-bar { height: 2px; width: 90px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: scan 1.1s linear infinite; border-radius: 2px; }

/* Card nei messaggi */
.cards { display: grid; gap: 8px; margin-top: 10px; }
.mcard { border: 1px solid var(--line); background: rgba(3, 12, 26, 0.6); border-radius: 12px; padding: 10px 12px; cursor: default; position: relative; overflow: hidden; }
.mcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(var(--accent), var(--accent3)); opacity: .7; }
.mcard-head { display: flex; align-items: center; gap: 10px; }
.mcard-head svg { color: var(--accent); width: 18px; height: 18px; }
.mcard-title { font-weight: 600; flex: 1; min-width: 0; }
.mcard-sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.mcard-lines { margin-top: 6px; font-size: 13.5px; color: #c7def3; display: grid; gap: 2px; }
.mcard-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mcard img.thumb { max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 8px; display: block; border: 1px solid var(--line); }
.mcard .md { margin-top: 6px; font-size: 13.5px; color: #c7def3; max-height: 260px; overflow: auto; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(251, 191, 36, 0.15); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.3); font-family: var(--font-hud); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; white-space: nowrap; }
.badge.danger { background: rgba(248, 113, 113, 0.14); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.badge.ok { background: rgba(52, 211, 153, 0.12); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.badge.info { background: rgba(56, 189, 248, 0.12); color: var(--accent); border-color: var(--line2); }
.secret { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; background: rgba(0, 0, 0, 0.35); padding: 6px 10px; border-radius: 8px; border: 1px dashed var(--line2); }
.secret span { flex: 1; overflow-wrap: anywhere; }
.chip-btn { font-size: 12.5px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line2); background: rgba(56, 189, 248, 0.08); color: var(--accent); cursor: pointer; text-decoration: none; font-family: var(--font-hud); font-weight: 700; letter-spacing: .5px; transition: .15s; display: inline-flex; align-items: center; gap: 5px; }
.chip-btn:hover { background: rgba(56, 189, 248, 0.2); box-shadow: var(--glow); }
.progress { height: 6px; background: rgba(56, 189, 248, 0.1); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; box-shadow: 0 0 10px var(--accent); transition: width .6s; }
.chart-bars { display: grid; gap: 6px; margin-top: 10px; }
.chart-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.chart-row .bar { height: 8px; border-radius: 99px; background: rgba(56, 189, 248, 0.08); overflow: hidden; }
.chart-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent3), var(--accent)); border-radius: 99px; animation: grow .8s ease-out; }
.chart-row .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-row .val { font-family: var(--font-hud); font-weight: 700; color: var(--text); }

/* Markdown */
.md h1, .md h2, .md h3 { font-family: var(--font-hud); margin: 8px 0 4px; color: #bae6fd; letter-spacing: .5px; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md li.task { list-style: none; margin-left: -18px; }
.md code { background: rgba(0, 0, 0, 0.4); padding: 1px 5px; border-radius: 5px; font-size: 90%; font-family: ui-monospace, Consolas, monospace; color: #a5f3fc; }
.md pre { background: rgba(0, 0, 0, 0.45); padding: 10px; border-radius: 8px; overflow: auto; border: 1px solid var(--line); }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); margin: 6px 0; padding: 2px 10px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md table { border-collapse: collapse; margin: 6px 0; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }

/* Suggerimenti e composer */
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px 8px; max-width: 900px; margin: 0 auto; width: 100%; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.suggestions .chip-btn { white-space: nowrap; flex: none; }
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 860px; width: calc(100% - 32px); margin: 0 auto 16px;
  padding: 8px; border-radius: 18px;
  background: rgba(8, 22, 42, 0.85); border: 1px solid var(--line2);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.04), 0 10px 40px rgba(0, 0, 0, 0.45), var(--glow);
  backdrop-filter: blur(12px);
  margin-bottom: max(16px, env(safe-area-inset-bottom));
}
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: none; padding: 9px 6px; max-height: 160px; font-size: 15.5px; line-height: 1.4; }
.composer textarea::placeholder { color: var(--dim); }
.composer .icon-btn { border-color: transparent; background: none; }
.send-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; cursor: pointer; display: grid; place-items: center; color: #031321; background: linear-gradient(135deg, #7dd3fc, var(--accent) 50%, var(--accent2)); box-shadow: 0 0 16px rgba(56, 189, 248, 0.5); transition: .15s; flex: none; }
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(56, 189, 248, 0.75); }
.send-btn:disabled { opacity: .5; cursor: default; transform: none; }
#micBtn.listening { color: #fff; background: rgba(248, 113, 113, 0.25); border-color: rgba(248, 113, 113, 0.5); box-shadow: 0 0 18px rgba(248, 113, 113, 0.5); animation: breathe 1s infinite; }
.drop-overlay { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 20px; background: rgba(3, 12, 26, 0.85); display: none; place-items: center; font-family: var(--font-hud); font-size: 22px; letter-spacing: 1px; color: var(--accent); z-index: 20; }
.drop-overlay.show { display: grid; }

/* ── HUD destro ── */
.hud { border-left: 1px solid var(--line); background: linear-gradient(180deg, rgba(6, 16, 31, 0.85), rgba(3, 7, 18, 0.9)); overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(12px); }
.hud-clock { text-align: center; padding: 10px 0 4px; }
.hud-clock .t { font-family: var(--font-title); font-size: 34px; font-weight: 700; letter-spacing: 3px; color: #e0f7ff; text-shadow: 0 0 18px rgba(56, 189, 248, 0.6); }
.hud-clock .d { font-family: var(--font-hud); color: var(--muted); letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.hud-box { border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--panel2); position: relative; }
.hud-box::after { content: ''; position: absolute; top: -1px; left: 14px; width: 36px; height: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.hud-box h4 { margin: 0 0 8px; font-family: var(--font-hud); font-size: 12.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent2); display: flex; align-items: center; gap: 6px; }
.hud-box h4 a { margin-left: auto; font-size: 11px; color: var(--dim); cursor: pointer; text-decoration: none; }
.hud-box h4 a:hover { color: var(--accent); }
.hud-item { font-size: 13.5px; padding: 4px 0; display: flex; gap: 8px; border-bottom: 1px dashed rgba(56, 189, 248, 0.07); align-items: baseline; }
.hud-item:last-child { border-bottom: 0; }
.hud-item .when { color: var(--accent); font-family: var(--font-hud); font-weight: 700; min-width: 44px; font-size: 13px; }
.hud-item .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hud-empty { color: var(--dim); font-size: 13px; font-style: italic; }
.kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi div { background: rgba(0, 0, 0, 0.22); border-radius: 10px; padding: 7px 9px; }
.kpi small { display: block; color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-family: var(--font-hud); }
.kpi b { font-family: var(--font-hud); font-size: 19px; }
.kpi .neg { color: #fca5a5; } .kpi .pos { color: #6ee7b7; }
.hud-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; padding: 3px 0; }
.hud-check input { margin-top: 3px; accent-color: var(--accent); }

/* ── Viste modulo ── */
#view-module { overflow-y: auto; }
.mod { padding: 22px 24px 40px; max-width: 1180px; width: 100%; margin: 0 auto; }
.mod-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.mod-head h2 { margin: 0; font-family: var(--font-hud); font-weight: 700; font-size: 26px; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
.mod-head h2 svg { width: 26px; height: 26px; color: var(--accent); filter: drop-shadow(0 0 8px var(--accent)); }
.mod-head .sp { flex: 1; }
.search { position: relative; }
.search input { background: rgba(8, 22, 42, 0.7); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 8px 34px; width: 230px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: var(--glow); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--dim); }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(56, 189, 248, 0.1); color: var(--accent); cursor: pointer; font-family: var(--font-hud); font-weight: 700; font-size: 14.5px; letter-spacing: .6px; transition: .15s; text-decoration: none; white-space: nowrap; }
.btn:hover { background: rgba(56, 189, 248, 0.2); box-shadow: var(--glow); }
.btn.primary { background: linear-gradient(135deg, #7dd3fc, var(--accent)); color: #021220; border-color: transparent; box-shadow: 0 0 14px rgba(56, 189, 248, 0.4); }
.btn.primary:hover { box-shadow: 0 0 22px rgba(56, 189, 248, 0.7); }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }
.btn.ghost { background: none; border-color: var(--line); color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 17px; height: 17px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 5px 13px; border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; font-family: var(--font-hud); font-weight: 600; font-size: 14px; }
.chip.active, .chip:hover { color: var(--text); border-color: var(--accent); background: rgba(56, 189, 248, 0.1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel);
  cursor: pointer; transition: .18s; position: relative; overflow: hidden; backdrop-filter: blur(8px);
}
.card:hover { border-color: var(--line2); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), var(--glow); }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card .body { margin-top: 8px; font-size: 13.5px; color: #c7def3; }
.card .body.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--dim); }
.card.pinned::after { content: '📌'; position: absolute; top: 10px; right: 12px; font-size: 13px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { display: block; font-family: var(--font-hud); font-size: 20px; color: var(--text); margin-bottom: 4px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-family: var(--font-hud); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: rgba(0, 0, 0, 0.2); }
table.data td { padding: 9px 12px; border-bottom: 1px solid rgba(56, 189, 248, 0.06); vertical-align: middle; }
table.data tr:hover td { background: rgba(56, 189, 248, 0.04); }
table.data tr { cursor: pointer; }
.num { font-family: var(--font-hud); font-weight: 700; font-size: 15px; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: rgba(56, 189, 248, 0.08); color: var(--accent); cursor: pointer; font-weight: 700; }
.qty button:hover { box-shadow: var(--glow); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); backdrop-filter: blur(8px); }
.panel h3 { margin: 0 0 12px; font-family: var(--font-hud); letter-spacing: 1.5px; text-transform: uppercase; font-size: 14px; color: var(--accent2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); }
.tile small { color: var(--muted); font-family: var(--font-hud); letter-spacing: 1.5px; text-transform: uppercase; font-size: 12px; }
.tile b { display: block; font-family: var(--font-hud); font-size: 30px; line-height: 1.2; }
.tile.neg b { color: #fca5a5; } .tile.pos b { color: #6ee7b7; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.trend { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.trend .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.trend .bars i { width: 40%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; animation: rise .8s ease-out; transform-origin: bottom; }
.trend .bars i.o { background: linear-gradient(180deg, #fca5a5, #b91c1c); }
.trend .bars i.n { background: linear-gradient(180deg, #6ee7b7, #047857); }
.trend small { color: var(--muted); font-size: 11px; font-family: var(--font-hud); letter-spacing: 1px; text-transform: uppercase; }

/* Calendario */
.cal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 12px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head b { flex: 1; text-align: center; font-family: var(--font-hud); font-size: 18px; letter-spacing: 1px; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-family: var(--font-hud); font-size: 12px; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; padding: 4px 0; }
.cal-day { aspect-ratio: 1 / .82; border-radius: 10px; border: 1px solid transparent; background: rgba(0, 0, 0, 0.18); cursor: pointer; padding: 5px; display: flex; flex-direction: column; font-size: 13px; position: relative; transition: .15s; min-height: 44px; }
.cal-day:hover { border-color: var(--line2); }
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.25); }
.cal-day.today .n { color: var(--accent); font-weight: 700; }
.cal-day.sel { background: rgba(56, 189, 248, 0.18); border-color: var(--accent); }
.cal-day .dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.cal-day .dots i.r { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.cal-day .dots i.s { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.agenda-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; transition: .15s; }
.li:hover { border-color: var(--line2); }
.li .time { font-family: var(--font-hud); font-weight: 700; color: var(--accent); min-width: 52px; }
.li .grow { flex: 1; min-width: 0; }
.li .grow .s { color: var(--muted); font-size: 12.5px; }
.li.done .grow > div:first-child { text-decoration: line-through; color: var(--dim); }
.li input[type=checkbox], .check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex: none; }
.li .x { opacity: .4; } .li:hover .x { opacity: 1; }
.section-title { font-family: var(--font-hud); letter-spacing: 2px; text-transform: uppercase; color: var(--accent2); font-size: 13px; margin: 18px 0 8px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Cassaforte */
.vault-lock { max-width: 420px; margin: 40px auto; text-align: center; }
.vault-lock .lock-icon { width: 92px; height: 92px; margin: 0 auto 16px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; box-shadow: var(--glow), inset 0 0 30px rgba(56, 189, 248, 0.15); position: relative; }
.vault-lock .lock-icon::before { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 1px dashed rgba(56, 189, 248, 0.3); animation: spin 20s linear infinite; }
.vault-lock .lock-icon svg { width: 40px; height: 40px; color: var(--accent); }
.vault-lock h3 { font-family: var(--font-hud); font-size: 24px; margin: 0 0 4px; }
.vault-lock p { color: var(--muted); margin: 0 0 18px; }

/* Documenti */
.dropzone { border: 2px dashed var(--line2); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: .2s; margin-bottom: 16px; background: rgba(56, 189, 248, 0.03); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); background: rgba(56, 189, 248, 0.08); box-shadow: var(--glow); }
.doc-thumb { height: 120px; border-radius: 10px; margin: -4px -4px 10px; background: rgba(0, 0, 0, 0.3) center / cover no-repeat; display: grid; place-items: center; color: var(--accent); font-family: var(--font-hud); font-size: 26px; font-weight: 700; letter-spacing: 2px; border: 1px solid var(--line); }

/* ── Modale ── */
.modal-back { position: fixed; inset: 0; background: rgba(1, 4, 10, 0.72); backdrop-filter: blur(6px); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: linear-gradient(180deg, #0b1d35, #071325); border: 1px solid var(--line2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), var(--glow); animation: pop .25s cubic-bezier(.2, .8, .2, 1); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #0b1d35; z-index: 1; }
.modal-head h3 { margin: 0; flex: 1; font-family: var(--font-hud); font-size: 20px; letter-spacing: .5px; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: #081729; }
.modal-foot .left { margin-right: auto; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-family: var(--font-hud); font-weight: 700; font-size: 12.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea, .field select { background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; width: 100%; }
.field textarea { min-height: 110px; resize: vertical; font-family: var(--font); line-height: 1.5; }
.field textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; min-height: 220px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: var(--glow); }
.field select option { background: #0b1d35; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pw-wrap { display: flex; gap: 6px; } .pw-wrap input { flex: 1; }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.checklist .item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; background: rgba(0, 0, 0, 0.22); }
.checklist .item.done span { text-decoration: line-through; color: var(--dim); }
.checklist .item span { flex: 1; }
.checklist .item button { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 2px 6px; }
.checklist .item button:hover { color: var(--danger); }
.inline-add { display: flex; gap: 6px; margin-top: 8px; }
.inline-add input { flex: 1; background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; outline: none; }
.inline-add input:focus { border-color: var(--accent); }
.preview-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 220px; background: rgba(0, 0, 0, 0.25); overflow: auto; }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #0b1d35; border: 1px solid var(--line2); padding: 11px 15px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), var(--glow); animation: toast-in .3s cubic-bezier(.2, .8, .2, 1); max-width: 380px; display: flex; gap: 10px; align-items: flex-start; }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }
.toast.rem { border-color: var(--warn); box-shadow: 0 0 24px rgba(251, 191, 36, 0.35); }
.toast b { display: block; font-family: var(--font-hud); letter-spacing: .5px; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.settings-grid .panel p { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; } .kv span { color: var(--muted); } .kv code { overflow-wrap: anywhere; }
input[type=range] { accent-color: var(--accent); width: 100%; }

/* Login PIN */
.pin-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 20px; }

/* ── Animazioni ── */
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.brand-orb::before { animation-name: spin-plain; }
@keyframes spin-plain { to { transform: rotate(360deg); } }
.vault-lock .lock-icon::before { animation-name: spin-plain; }
@keyframes pulse-ring { 0% { transform: translate(-50%, -50%) scale(.6); opacity: .9; } 100% { transform: translate(-50%, -50%) scale(1.25); opacity: 0; } }
.mini-core i { animation-name: pulse-mini; }
@keyframes pulse-mini { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes breathe { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
.core.thinking .core-center, .core.speaking .core-center { animation-name: breathe-c; }
@keyframes breathe-c { 0%, 100% { transform: translate(-50%, -50%) scale(.8); } 50% { transform: translate(-50%, -50%) scale(1.25); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes scan { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(10px); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes grow { from { width: 0; } }
@keyframes rise { from { transform: scaleY(0); } }

/* ── Responsive ── */
@media (max-width: 1280px) {
  .app { grid-template-columns: var(--sidebar) 1fr; }
  .hud { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); padding-top: max(16px, env(safe-area-inset-top)); }
  .app.nav-open .sidebar { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, 0.55); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; }
  .title { font-size: 20px; letter-spacing: 6px; }
  .subtitle { font-size: 9.5px; letter-spacing: 2px; }
  .clock { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .icon-btn { width: 34px; height: 34px; }
  #notifBtn { display: none; }
  .chat-scroll { padding: 16px 10px 8px; }
  .bubble { max-width: 86%; }
  .avatar { width: 28px; height: 28px; font-size: 9px; }
  .msg { gap: 8px; }
  .speak-btn { display: none; }
  .suggestions { padding: 4px 10px 6px; }
  .composer { width: calc(100% - 16px); margin: 0 auto 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); border-radius: 16px; }
  .composer textarea { font-size: 16px; }
  .mod { padding: 16px 12px 40px; }
  .mod-head h2 { font-size: 22px; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; order: 5; }
  .agenda-layout, .two-col { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .tile b { font-size: 24px; }
  .core .r3, .core .r4 { display: none; }
  .modal-back { padding: 0; place-items: end center; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92dvh; }
  table.data .hide-m { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* fix: checkbox dentro i campi form */
.field input[type=checkbox], .checklist input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); cursor: pointer; padding: 0; }
.checklist .item span { text-align: left; }

/* ═════════════ MAPPA OLOGRAFICA ═════════════ */
.app.map-mode { grid-template-columns: var(--sidebar) 1fr 0; }
.app.map-mode .hud { display: none; }
#view-map { overflow: hidden; background: radial-gradient(ellipse at center, #071a30 0%, var(--bg) 70%); }
.map-stage { position: absolute; inset: 0; }
.map-stage canvas { display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map-top { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; z-index: 3; }
.map-top > * { pointer-events: auto; }
.map-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; background: rgba(3, 12, 26, .72); border: 1px solid var(--line); border-radius: 12px; padding: 4px; backdrop-filter: blur(10px); }
.map-crumbs::-webkit-scrollbar { display: none; }
.map-crumbs button { background: none; border: 0; color: var(--muted); font: 600 14px var(--font-hud); letter-spacing: .04em; padding: 6px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.map-crumbs button:hover { color: var(--text); background: var(--panel2); }
.map-crumbs button.cur { color: var(--accent2); text-shadow: 0 0 10px rgba(34, 211, 238, .5); }
.map-crumbs span { color: var(--dim); font-size: 13px; }
.map-tools { display: flex; gap: 6px; align-items: center; }
.map-tools .icon-btn { background: rgba(3, 12, 26, .72); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.map-search { position: relative; display: flex; align-items: center; gap: 6px; background: rgba(3, 12, 26, .72); border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; height: 40px; backdrop-filter: blur(10px); }
.map-search svg { width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.map-search input { background: none; border: 0; outline: 0; color: var(--text); font: 14px var(--font); width: 190px; }
.map-results { position: absolute; top: 46px; right: 0; width: min(380px, calc(100vw - 24px)); max-height: 60vh; overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line2); border-radius: 12px; padding: 6px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.map-results button { display: grid; grid-template-columns: 10px 1fr; gap: 2px 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px; border-radius: 8px; cursor: pointer; font: 14px var(--font); }
.map-results button:hover { background: var(--panel2); }
.map-results i { width: 8px; height: 8px; border-radius: 50%; grid-row: span 2; box-shadow: 0 0 8px currentColor; }
.map-results small { color: var(--dim); font-size: 11.5px; grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.map-panel { position: absolute; top: 62px; right: 12px; bottom: 12px; width: 360px; z-index: 2; background: rgba(5, 15, 30, .86); border: 1px solid var(--line2); border-radius: 16px; backdrop-filter: blur(14px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 40px rgba(56, 189, 248, .08); transition: transform .3s ease, opacity .3s; }
.map-panel > * { flex: none; }
.map-panel .mp-body { flex: 1 1 auto; overflow-y: auto; padding: 0 16px 8px; font-size: 14px; min-height: 40px; }
.mp-handle { display: none; }
.mp-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 16px; }
.mp-head > div { flex: 1; min-width: 0; }
.mp-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; }
.mp-title { font: 700 19px var(--font-hud); letter-spacing: .03em; line-height: 1.15; }
.mp-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.map-panel .progress { margin: 0 16px 10px; }
.mp-sum { color: var(--accent2); font-weight: 500; }
.mp-rel { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; }
.mp-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); }
.mp-kids-h { padding: 8px 16px 4px; font: 600 12px var(--font-hud); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); border-top: 1px solid var(--line); }
.mp-kids { max-height: 34%; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.mp-kids button { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--text); text-align: left; padding: 7px 8px; border-radius: 8px; cursor: pointer; font: 13.5px var(--font); }
.mp-kids button:hover { background: var(--panel2); }
.mp-kids button i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.mp-kids button small { margin-left: auto; color: var(--dim); font-size: 11.5px; padding-left: 8px; white-space: nowrap; }
.map-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1; color: var(--muted); font: 500 13px var(--font-hud); letter-spacing: .05em; background: rgba(3, 12, 26, .7); border: 1px solid var(--line); padding: 6px 14px; border-radius: 20px; pointer-events: none; transition: opacity 1.2s; white-space: nowrap; margin-right: 180px; }
.map-hint.fade { opacity: 0; }
.map-chip svg { width: 15px; height: 15px; }
@media (max-width: 1280px) { .app.map-mode { grid-template-columns: var(--sidebar) 1fr; } }
@media (max-width: 860px) {
  .app.map-mode { grid-template-columns: 1fr; }
  .map-top { flex-direction: column-reverse; gap: 6px; top: 8px; left: 8px; right: 8px; }
  .map-crumbs { width: 100%; flex: none; }
  .map-tools { width: 100%; }
  .map-search { flex: 1; }
  .map-search input { width: 100%; }
  .map-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 52%; border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .map-panel.min { transform: translateY(calc(100% - 64px)); }
  .mp-handle { display: block; height: 18px; cursor: pointer; position: relative; }
  .mp-handle::after { content: ''; position: absolute; left: 50%; top: 7px; width: 42px; height: 4px; margin-left: -21px; border-radius: 3px; background: var(--line2); }
  .mp-head { padding-top: 0; }
  .map-hint { display: none; }
}

/* card del sapere e tabelle */
.mcard-more { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.mcard-more summary { cursor: pointer; color: var(--accent); font: 600 13px var(--font-hud); letter-spacing: .08em; text-transform: uppercase; list-style: none; padding: 4px 0; }
.mcard-more summary::-webkit-details-marker { display: none; }
.mcard-more summary::before { content: '▸ '; }
.mcard-more[open] summary::before { content: '▾ '; }
.tbl-wrap { overflow-x: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; }
.md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md-table th, .md-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md-table th { background: rgba(56, 189, 248, .08); color: var(--accent2); font-weight: 600; white-space: nowrap; }
.md-table tr:last-child td { border-bottom: 0; }
.md code { background: rgba(56, 189, 248, .1); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.qr-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0; }
.qr { margin: 0; padding: 10px; background: rgba(56, 189, 248, .06); border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.qr img { display: block; width: 150px; height: 150px; image-rendering: pixelated; }
.qr figcaption { margin-top: 6px; font-size: 12px; }
.steps { margin: 8px 0; padding-left: 20px; line-height: 1.7; }
.muted-s { color: var(--muted); font-size: 13px; }
.learned { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.learned-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
.learned-row span { flex: 1; }
@media (max-width: 860px) {
  .map-panel { overflow-y: auto; display: block; }
  .map-panel .mp-body { overflow: visible; }
  .mp-kids { max-height: none; }
  .map-panel .mp-head { position: sticky; top: 0; background: rgba(5, 15, 30, .96); z-index: 1; padding-top: 4px; }
  .mp-handle { position: sticky; top: 0; background: rgba(5, 15, 30, .96); z-index: 2; }
}
.map-tools .map-mode { font: 700 13px var(--font-title); letter-spacing: .05em; color: var(--accent2); width: auto; min-width: 40px; padding: 0 10px; }

/* ── Sempre in ascolto ── */
#earBtn.on { color: #34d399; border-color: rgba(52, 211, 153, 0.5); box-shadow: 0 0 12px rgba(52, 211, 153, 0.35); }
#earBtn.awake { color: #fff; background: rgba(52, 211, 153, 0.25); animation: breathe 1s infinite; }
.ear-pill { position: fixed; z-index: 60; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); max-width: min(90vw, 560px); display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-radius: 999px; background: rgba(6, 20, 30, 0.92); border: 1px solid rgba(52, 211, 153, 0.5); color: #d1fae5; font-size: 14px; box-shadow: 0 0 24px rgba(52, 211, 153, 0.3); pointer-events: none; animation: fade .2s; }
.ear-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ear-dot { width: 10px; height: 10px; border-radius: 50%; background: #34d399; box-shadow: 0 0 10px #34d399; flex: none; animation: breathe 1s infinite; }
.ear-pill[hidden] { display: none; }
.neural { border: 1px solid var(--line, rgba(56,189,248,.25)); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; background: rgba(56, 189, 248, 0.06); }
.neural.ok { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.07); }
.neural p { margin: 6px 0 0; }
