/* "Chiedi ai report" — stile Apple: vetro traslucido, fumetti stile Messaggi, invio con freccia circolare. */
.nxc-root {
  --nxc-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  --nxc-accent: #0a84ff; --nxc-accent-2: #5ac8fa;
  --nxc-glass: rgba(255, 255, 255, .78); --nxc-solid: #ffffff;
  --nxc-text: #1d1d1f; --nxc-muted: #6e6e73; --nxc-line: rgba(0, 0, 0, .09);
  --nxc-fill: rgba(120, 120, 128, .13); --nxc-fill-2: rgba(120, 120, 128, .2);
  --nxc-shadow: 0 30px 80px rgba(0, 0, 0, .22), 0 2px 10px rgba(0, 0, 0, .08);
  --nxc-ease: cubic-bezier(.2, .9, .25, 1);
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 9000;
  font: 15px/1.45 var(--nxc-font); color: var(--nxc-text); letter-spacing: -.011em; -webkit-font-smoothing: antialiased;
}
:root[data-theme=dark] .nxc-root {
  --nxc-glass: rgba(30, 30, 32, .78); --nxc-solid: #1c1c1e;
  --nxc-text: #f5f5f7; --nxc-muted: #a1a1a6; --nxc-line: rgba(255, 255, 255, .12);
  --nxc-fill: rgba(120, 120, 128, .28); --nxc-fill-2: rgba(120, 120, 128, .4);
  --nxc-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 2px 10px rgba(0, 0, 0, .35);
}
.nxc-root *, .nxc-root *::before, .nxc-root *::after { box-sizing: border-box; }
.nxc-root button, .nxc-root textarea { font-family: inherit; letter-spacing: inherit; }
.nxc-root button { -webkit-tap-highlight-color: transparent; }
.nxc-root :focus-visible { outline: 3px solid color-mix(in srgb, var(--nxc-accent) 55%, transparent); outline-offset: 2px; }

/* ───────── pulsante ───────── */
.nxc-launcher {
  display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 22px 0 16px; cursor: pointer;
  color: var(--nxc-text); font-weight: 600; font-size: 15px; line-height: 1;
  border: 1.5px solid transparent; border-radius: 980px;
  background:
    linear-gradient(var(--nxc-glass), var(--nxc-glass)) padding-box,
    linear-gradient(120deg, #ff9f0a, #ff375f 35%, #bf5af2 65%, #0a84ff) border-box;
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .1);
  transition: transform .35s var(--nxc-ease), box-shadow .35s var(--nxc-ease);
}
.nxc-launcher:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 18px 40px rgba(0, 0, 0, .24), 0 1px 3px rgba(0, 0, 0, .1); }
.nxc-launcher:active { transform: scale(.98); }
.nxc-spark { flex-shrink: 0; }
.nxc-open .nxc-launcher { display: none; }

/* ───────── pannello ───────── */
.nxc-panel {
  display: flex; flex-direction: column; width: min(420px, calc(100vw - 24px)); height: min(680px, calc(100dvh - 40px));
  background: var(--nxc-glass); border: 1px solid var(--nxc-line); border-radius: 30px; overflow: hidden;
  -webkit-backdrop-filter: saturate(190%) blur(34px); backdrop-filter: saturate(190%) blur(34px);
  box-shadow: var(--nxc-shadow); transform-origin: 100% 100%;
}
.nxc-panel[hidden] { display: none; }
.nxc-open .nxc-panel { animation: nxc-pop .42s var(--nxc-ease); }
@keyframes nxc-pop { from { opacity: 0; transform: translateY(18px) scale(.9); } to { opacity: 1; transform: none; } }

.nxc-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 18px; border-bottom: 1px solid var(--nxc-line); }
.nxc-badge {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 29%; display: grid; place-items: center;
  background: linear-gradient(145deg, #ff9f0a, #ff375f 40%, #bf5af2 70%, #0a84ff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 8px 18px rgba(191, 90, 242, .35);
}
.nxc-headtext { min-width: 0; flex: 1; }
.nxc-title { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.nxc-sub { display: block; color: var(--nxc-muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.nxc-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nxc-reset {
  border: 0; border-radius: 980px; padding: 7px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--nxc-fill); color: var(--nxc-text); transition: background .2s;
}
.nxc-reset:hover { background: var(--nxc-fill-2); }
.nxc-close {
  width: 30px; height: 30px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--nxc-fill); color: var(--nxc-muted); transition: background .2s, color .2s, transform .2s;
}
.nxc-close:hover { background: var(--nxc-fill-2); color: var(--nxc-text); transform: scale(1.06); }

/* ───────── conversazione ───────── */
.nxc-log { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; scroll-behavior: smooth; }
.nxc-msg { max-width: 88%; padding: 10px 15px; border-radius: 22px; overflow-wrap: anywhere; font-size: 15px; animation: nxc-in .35s var(--nxc-ease); }
@keyframes nxc-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.nxc-bot { align-self: flex-start; background: var(--nxc-fill); border-bottom-left-radius: 7px; }
.nxc-user {
  align-self: flex-end; color: #fff; border-bottom-right-radius: 7px;
  background: linear-gradient(180deg, #38a0ff, #0a84ff);
  box-shadow: 0 6px 16px rgba(10, 132, 255, .28);
}
.nxc-msg p { margin: 0; }
.nxc-msg p + p, .nxc-msg p + ul, .nxc-msg p + ol, .nxc-msg ul + p, .nxc-msg ol + p, .nxc-msg p + .nxc-table, .nxc-msg .nxc-table + p { margin-top: 9px; }
.nxc-msg ul, .nxc-msg ol { margin: 0; padding-left: 20px; }
.nxc-msg li + li { margin-top: 4px; }
.nxc-msg strong { font-weight: 650; }
.nxc-msg code { font-size: .88em; background: var(--nxc-fill); padding: 1px 6px; border-radius: 6px; }
.nxc-table { overflow-x: auto; margin-top: 9px; border-radius: 12px; background: var(--nxc-solid); }
.nxc-table table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.nxc-table th, .nxc-table td { border-bottom: 1px solid var(--nxc-line); padding: 7px 10px; text-align: left; white-space: nowrap; }
.nxc-table th { color: var(--nxc-muted); font-weight: 600; font-size: 12px; }

/* citazioni */
.nxc-cite {
  display: inline-block; max-width: 100%; vertical-align: baseline; margin: 1px 2px; padding: 1px 9px; border-radius: 980px;
  background: color-mix(in srgb, var(--nxc-accent) 14%, transparent); color: var(--nxc-accent); border: 0;
  font-size: 12px; font-weight: 600; line-height: 1.7; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .2s, color .2s;
}
.nxc-cite:hover { background: var(--nxc-accent); color: #fff; }

/* indicatore di scrittura */
.nxc-dots { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 2px; }
.nxc-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--nxc-muted); opacity: .45; animation: nxc-dot 1.2s infinite ease-in-out; }
.nxc-dots i:nth-child(2) { animation-delay: .16s; } .nxc-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes nxc-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* suggerimenti */
.nxc-suggest { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 6px; }
.nxc-suggest button {
  max-width: 100%; text-align: left; font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--nxc-text); cursor: pointer;
  background: var(--nxc-fill); border: 0; border-radius: 18px; padding: 11px 15px;
  transition: background .25s, color .25s, transform .25s var(--nxc-ease);
}
.nxc-suggest button:hover { background: color-mix(in srgb, var(--nxc-accent) 16%, transparent); color: var(--nxc-accent); transform: translateX(3px); }

.nxc-retry {
  display: inline-block; margin-top: 10px; border: 0; border-radius: 980px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--nxc-accent); color: #fff; transition: filter .2s, transform .2s;
}
.nxc-retry:hover { filter: brightness(1.1); transform: scale(1.04); }

/* ───────── campo di scrittura ───────── */
.nxc-form {
  display: flex; align-items: flex-end; gap: 6px; margin: 4px 14px 6px; padding: 5px 5px 5px 16px;
  background: var(--nxc-fill); border-radius: 26px; transition: box-shadow .25s;
}
.nxc-form:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--nxc-accent) 35%, transparent); }
.nxc-form textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent; color: var(--nxc-text);
  font-size: 15px; line-height: 1.4; padding: 8px 0; max-height: 120px;
}
.nxc-form textarea::placeholder { color: var(--nxc-muted); }
.nxc-send {
  flex-shrink: 0; width: 36px; height: 36px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(180deg, #38a0ff, #0a84ff); color: #fff; box-shadow: 0 4px 12px rgba(10, 132, 255, .4);
  transition: transform .25s var(--nxc-ease), filter .2s, background .2s;
}
.nxc-send:hover { transform: scale(1.08); filter: brightness(1.08); }
.nxc-send:active { transform: scale(.94); }
.nxc-send.nxc-stop { background: var(--nxc-text); color: var(--nxc-solid); box-shadow: none; }
.nxc-note { margin: 0; padding: 4px 22px 14px; text-align: center; color: var(--nxc-muted); font-size: 11px; line-height: 1.4; }

/* ───────── mobile ───────── */
@media (max-width: 560px) {
  .nxc-root { right: 12px; bottom: 12px; }
  .nxc-panel { position: fixed; inset: auto 0 0 0; width: 100%; height: min(88dvh, 740px); border-radius: 30px 30px 0 0; border-bottom: 0; transform-origin: 50% 100%; }
  .nxc-form textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .nxc-open .nxc-panel, .nxc-msg { animation: none; }
  .nxc-launcher, .nxc-send, .nxc-suggest button { transition: none; }
  .nxc-dots i { animation: none; opacity: .7; }
}
@media print { .nxc-root { display: none; } }

@media (max-width: 700px) {
  .nxc-root { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .nxc-launcher { width: 54px; height: 54px; min-height: 0; padding: 0; justify-content: center; gap: 0; border-radius: 50%; }
  .nxc-launcher > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nxc-spark { width: 24px; height: 24px; }
  .nxc-sub { display: none; }
  .nxc-title { font-size: 16px; white-space: nowrap; }
  .nxc-head { padding: 14px 12px 12px 14px; gap: 10px; }
  .nxc-reset { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
}
