:root {
  --bg: #f6f4ef;
  --ink: #16130f;
  --ink-soft: #5c574f;
  --surface: #ffffff;
  --surface-soft: #f0ede6;
  --border: #ddd8ce;
  --accent: #9b2335;
  --accent-dark: #7d1c2b;
  --accent-soft: #f3dcdf;
  --hero: #070b0a;
  --hero-accent: #e0435a;
  --success: #246b45;
  --shadow: 0 24px 60px rgba(22, 19, 15, .10);
  --radius-lg: 24px;
  --radius-md: 16px;
  --focus: #1769aa;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; }
button, label { touch-action: manipulation; }
a { color: inherit; }
svg { display: block; }
::selection { background: var(--accent); color: white; }

.shell { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  padding: 12px 16px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.site-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  color: white;
}
.header-inner {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header-nav { display: flex; align-items: center; gap: 28px; }
.stradilab-brand .sl-brand { min-height: 44px; align-items: center; }
.nav-link {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.nav-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.nav-link-muted { color: rgba(255, 255, 255, .70); }
.nav-link:hover { color: var(--hero-accent); }

.hero {
  position: relative;
  overflow: hidden;
  background: var(--hero);
  color: white;
  padding: 156px 0 132px;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 25% 100%, 25% 100%;
  pointer-events: none;
}
.hero-glow {
  position: absolute;
  width: 720px;
  height: 300px;
  left: 50%;
  top: -210px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--hero-accent);
  filter: blur(100px);
  opacity: .55;
}
.hero-inner { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 320px; gap: 80px; align-items: center; }
.eyebrow {
  margin: 0 0 16px;
  color: var(--hero-accent);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow-light { color: var(--accent); }
.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(48px, 7.5vw, 88px);
  line-height: .95;
  letter-spacing: -.045em;
}
.hero h1 em, .principles h2 em {
  color: var(--hero-accent);
  font-family: "Instrument Serif", serif;
  font-weight: 400;
}
.hero-lead { max-width: 650px; margin: 28px 0 0; color: rgba(255,255,255,.75); font-size: 18px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.hero-badges span {
  padding: 7px 13px;
  border: 1px solid rgba(255,255,255,.20);
  border-radius: 999px;
  color: rgba(255,255,255,.86);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
}
.hero-mark { display: grid; place-items: center; }
.hero-mark svg { width: min(100%, 260px); fill: none; stroke: rgba(255,255,255,.18); stroke-width: 3; }
.hero-mark circle { fill: var(--hero-accent); stroke: none; }

.assistant-section { padding: 104px 0 112px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 34px; }
.section-heading h2, .principles h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(32px, 4.5vw, 48px);
  line-height: 1.05;
  letter-spacing: -.035em;
}
.section-heading > p { max-width: 460px; margin: 0 0 4px; color: var(--ink-soft); }
.assistant-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 680px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.assistant-sidebar { padding: 28px; border-right: 1px solid var(--border); background: #fbfaf7; }
.profile-fieldset { margin: 0; padding: 0; border: 0; }
.profile-fieldset legend { font-family: "Space Grotesk", sans-serif; font-size: 17px; font-weight: 700; }
.field-help { margin: 3px 0 18px; color: var(--ink-soft); font-size: 13px; }
.profile-option {
  position: relative;
  min-height: 74px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease;
}
.profile-option:hover { border-color: #b9b1a4; }
.profile-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.profile-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.profile-option input { position: absolute; opacity: 0; pointer-events: none; }
.profile-option strong, .profile-option small { display: block; }
.profile-option strong { font-family: "Space Grotesk", sans-serif; font-size: 14px; }
.profile-option small { margin-top: 2px; color: var(--ink-soft); font-size: 11px; line-height: 1.3; }
.profile-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-soft); }
.profile-icon svg, .source-card svg, .auth-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.profile-check { width: 16px; height: 16px; border: 1.5px solid #aaa195; border-radius: 50%; }
.profile-option input:checked ~ .profile-check { border: 5px solid var(--accent); background: white; }
.source-card { margin-top: 25px; padding: 17px; border-radius: 14px; background: var(--hero); color: white; }
.source-card-title { display: flex; align-items: center; gap: 9px; }
.source-card-title svg { color: #7ed3a6; }
.source-card p { margin: 10px 0; color: rgba(255,255,255,.68); font-size: 12px; line-height: 1.5; }
.source-card a { min-height: 44px; display: inline-flex; align-items: center; color: white; font-size: 12px; font-weight: 700; }
.auth-button {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.is-hidden { display: none !important; }

.chat-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(300px, 1fr) auto auto auto; background: var(--surface); }
.chat-topbar { min-height: 80px; display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.assistant-identity { display: flex; align-items: center; gap: 12px; }
.assistant-identity strong, .assistant-identity small { display: block; }
.assistant-identity strong { font-family: "Space Grotesk", sans-serif; }
.assistant-identity small { position: relative; margin-top: 2px; padding-left: 13px; color: var(--ink-soft); font-size: 11px; }
.assistant-identity small::before { content: ""; position: absolute; left: 0; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: #c38724; }
.assistant-identity small.is-connected::before { background: var(--success); }
.assistant-avatar { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: white; }
.assistant-avatar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); color: var(--ink); }
.icon-button svg, .send-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.messages { overflow-y: auto; padding: 28px 26px 10px; scroll-behavior: smooth; }
.message { display: flex; gap: 11px; margin-bottom: 22px; }
.message.user { justify-content: flex-end; }
.message-avatar { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-family: "Space Grotesk", sans-serif; font-size: 11px; font-weight: 700; }
.message-content { max-width: min(620px, 82%); }
.message-bubble { padding: 13px 16px; border-radius: 4px 16px 16px 16px; background: var(--surface-soft); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-bubble { border-radius: 16px 4px 16px 16px; background: var(--accent); color: white; }
.message-bubble p { margin: 0; }
.message-meta { margin: 5px 3px 0; color: #7b746b; font-size: 10px; }
.message.user .message-meta { text-align: right; }
.message-sources { display: grid; gap: 7px; margin-top: 9px; }
.source-link { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--accent-dark); text-decoration: none; font-size: 12px; font-weight: 700; }
.source-link:hover { background: var(--accent-soft); }
.source-link span:last-child { flex: 0 0 auto; }
.typing { display: inline-flex; align-items: center; gap: 4px; min-height: 21px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #7b746b; animation: typing 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .14s; }
.typing i:nth-child(3) { animation-delay: .28s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-3px); opacity: 1; } }
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 8px 22px 12px; scrollbar-width: thin; }
.suggestion-button { flex: 0 0 auto; min-height: 44px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 999px; background: white; color: var(--ink-soft); cursor: pointer; font-size: 12px; font-weight: 600; }
.suggestion-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.composer { margin: 0 22px; display: grid; grid-template-columns: minmax(0, 1fr) 50px; align-items: end; gap: 9px; padding: 8px 8px 8px 16px; border: 1.5px solid var(--border); border-radius: 17px; background: white; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { min-height: 48px; max-height: 150px; resize: none; border: 0; outline: 0; padding: 12px 0 8px; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.45; }
.composer textarea::placeholder { color: #827b72; }
.send-button { width: 50px; height: 50px; display: grid; place-items: center; border: 0; border-radius: 13px; background: var(--accent); color: white; cursor: pointer; }
.send-button:hover { background: var(--accent-dark); }
.send-button:disabled { cursor: not-allowed; opacity: .45; }
.form-status { min-height: 34px; margin: 0; padding: 9px 22px 12px; color: #756e65; font-size: 10px; text-align: center; }
.form-status.is-error { color: #8b1d2d; font-weight: 700; }

.principles { padding: 96px 0; border-top: 1px solid var(--border); background: white; }
.principles-heading { max-width: 680px; }
.principles h2 em { color: var(--accent); }
.principles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 48px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--border); }
.principles article { min-height: 220px; padding: 28px; background: white; }
.principles article > span { color: var(--accent); font-family: "Space Grotesk", sans-serif; font-size: 12px; font-weight: 700; }
.principles h3 { margin: 38px 0 8px; font-family: "Space Grotesk", sans-serif; font-size: 20px; }
.principles article p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.site-footer { padding: 28px 0; background: var(--hero); color: rgba(255,255,255,.68); }
.footer-inner { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 24px; font-size: 12px; }
.footer-inner p { margin: 0; }
.footer-inner div { display: flex; flex-wrap: wrap; gap: 24px; }
.footer-inner a { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.footer-inner a:hover { color: white; }

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-mark { display: none; }
  .assistant-layout { grid-template-columns: 1fr; }
  .assistant-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .profile-fieldset { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .profile-fieldset legend, .field-help { grid-column: 1 / -1; }
  .profile-option { grid-template-columns: 38px minmax(0, 1fr); margin-bottom: 0; }
  .profile-check { display: none; }
  .source-card { display: none; }
  .principles-grid { grid-template-columns: 1fr; }
  .principles article { min-height: auto; }
  .principles h3 { margin-top: 22px; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 32px, 1180px); }
  .header-inner { min-height: 74px; }
  .header-nav { gap: 8px; }
  .nav-link { font-size: 0; }
  .nav-link svg { width: 24px; height: 24px; }
  .nav-link-muted { display: none; }
  .hero { padding: 124px 0 92px; }
  .hero::after { background-size: 50% 100%, 50% 100%; }
  .hero h1 { font-size: clamp(46px, 14vw, 66px); }
  .hero-lead { font-size: 16px; }
  .assistant-section { padding: 72px 0 80px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 14px; }
  .assistant-layout { width: calc(100% + 16px); margin-left: -8px; min-height: 720px; border-radius: 18px; }
  .assistant-sidebar { padding: 20px 16px; }
  .profile-fieldset { grid-template-columns: 1fr; gap: 8px; }
  .profile-option { min-height: 62px; grid-template-columns: 38px minmax(0, 1fr) 18px; padding: 9px 11px; }
  .profile-check { display: block; }
  .profile-icon { width: 38px; height: 38px; }
  .chat-topbar { min-height: 72px; padding-inline: 16px; }
  .messages { padding: 22px 15px 8px; }
  .message-content { max-width: 88%; }
  .suggestions { padding-inline: 15px; }
  .composer { margin-inline: 12px; padding-left: 13px; }
  .form-status { padding-inline: 15px; }
  .principles { padding: 72px 0; }
  .footer-inner { display: block; }
  .footer-inner div { margin-top: 10px; gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Vista incorporata nel pannello del sito: resta una chat immediata, senza
   duplicare l'header, il selettore del profilo o il footer della pagina intera. */
html.is-embedded, html.is-embedded body { height: 100%; overflow: hidden; }
html.is-embedded .skip-link,
html.is-embedded .site-header,
html.is-embedded .hero,
html.is-embedded .assistant-section > .shell > .section-heading,
html.is-embedded .assistant-sidebar,
html.is-embedded .principles,
html.is-embedded .site-footer { display: none; }
html.is-embedded main,
html.is-embedded .assistant-section,
html.is-embedded .assistant-section .shell,
html.is-embedded .assistant-layout { height: 100%; min-height: 100dvh; }
html.is-embedded .assistant-section { padding: 0; }
html.is-embedded .shell { width: 100%; margin: 0; }
html.is-embedded .assistant-layout { display: block; border: 0; border-radius: 0; box-shadow: none; }
html.is-embedded .chat-panel { height: 100%; grid-template-rows: auto minmax(220px, 1fr) auto auto auto; }
html.is-embedded .chat-topbar { min-height: 52px; justify-content: flex-end; padding: 4px 10px; }
html.is-embedded .assistant-identity { display: none; }
html.is-embedded .messages { padding: 20px 16px 8px; }
html.is-embedded .suggestions { padding-inline: 16px; }
html.is-embedded .composer { margin-inline: 12px; }
html.is-embedded .form-status { padding-inline: 14px; }
