:root {
  color-scheme: dark;
  --background: #070b14;
  --surface: #0d1320;
  --surface-elevated: #121a2a;
  --surface-soft: #182235;
  --border: #263247;
  --text: #f6f8fc;
  --muted: #95a3ba;
  --primary: #1288ff;
  --primary-hover: #2b98ff;
  --ink: var(--text);
  --line: var(--border);
  --panel: var(--surface-elevated);
  --accent: var(--primary);
  --danger: #ffb7bd;
  --success: #a5e5bd;
  --success-bg: rgba(44, 151, 88, 0.18);
  --overlay: rgba(2, 6, 13, 0.62);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --sidebar-width: 272px;
  --sidebar-collapsed: 84px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f7f9fc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-soft: #edf2f8;
  --border: #dce3ed;
  --text: #10213f;
  --muted: #607089;
  --primary: #087df0;
  --primary-hover: #006fdc;
  --danger: #a91e2c;
  --success: #176f3b;
  --success-bg: #eaf8ef;
  --overlay: rgba(28, 42, 64, 0.38);
  --shadow: 0 24px 70px rgba(20, 37, 63, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button {
  color: inherit;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  transition: grid-template-columns 180ms ease;
}

.sidebar-is-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  min-width: 0;
  max-height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  padding: 22px 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.sidebar-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  text-decoration: none;
}

.brand-image {
  display: block;
  object-fit: contain;
  object-position: left center;
}

.brand-image-full {
  width: 168px;
  max-height: 52px;
}

.brand-image-symbol {
  display: none !important;
  width: 48px;
  height: 48px;
}

.brand-light,
:root[data-theme="light"] .brand-dark {
  display: none;
}

:root[data-theme="light"] .brand-light {
  display: block;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--border);
  background: var(--surface-soft);
  outline: 0;
}

.navigation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  margin-top: 34px;
}

.nav-item {
  display: flex;
  min-height: 46px;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav-item:hover,
.nav-item:focus-visible {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
  outline: 0;
}

.sidebar-history-note {
  display: grid;
  gap: 4px;
  margin: 12px 13px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.sidebar-history-note strong {
  color: var(--text);
  font-size: 12px;
}

.nav-item svg {
  flex: 0 0 auto;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: nowrap;
}

.sidebar-meta-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  object-fit: contain;
}

.sidebar-is-collapsed .sidebar {
  align-items: center;
  padding-right: 14px;
  padding-left: 14px;
}

.sidebar-is-collapsed .brand {
  justify-content: center;
}

.sidebar-is-collapsed .brand-image-full,
.sidebar-is-collapsed .nav-item span,
.sidebar-is-collapsed .sidebar-history-note,
.sidebar-is-collapsed .sidebar-meta {
  display: none;
}

.sidebar-is-collapsed .brand-image-symbol.brand-dark {
  display: block !important;
}

:root[data-theme="light"].sidebar-is-collapsed .brand-image-symbol.brand-dark {
  display: none !important;
}

:root[data-theme="light"].sidebar-is-collapsed .brand-image-symbol.brand-light {
  display: block !important;
}

.sidebar-is-collapsed .sidebar-header {
  flex-direction: column;
}

.sidebar-is-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-is-collapsed .nav-item {
  justify-content: center;
  width: 48px;
  padding: 0;
}

.main-content {
  display: flex;
  min-width: 0;
  min-height: 0;
  max-height: 100dvh;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(18px);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.mobile-menu-toggle {
  display: none;
}

.mobile-brand {
  display: none;
  min-width: 0;
  flex: 1;
}

.mobile-brand img {
  width: 148px;
  max-height: 46px;
  object-fit: contain;
  object-position: left center;
}

.topbar-title {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.topbar-title strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sun-icon {
  display: none;
}

:root[data-theme="light"] .moon-icon {
  display: none;
}

:root[data-theme="light"] .sun-icon {
  display: block;
}

.laboratorio-content {
  display: flex;
  min-height: 0;
  flex: 1;
  justify-content: center;
  overflow: auto;
  padding: 18px 28px 24px;
}

.conversation {
  display: flex;
  width: min(960px, 100%);
  min-height: 0;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  align-self: stretch;
  padding: 10px 0 0;
}

.conversation.has-messages {
  justify-content: flex-start;
}

.demo-intro {
  width: 100%;
  max-width: min(960px, 100%);
  margin: 0 auto 14px;
  padding: 0 10px;
  text-align: center;
}

.demo-intro[hidden] {
  display: none;
}

.demo-intro p {
  max-width: 760px;
  margin: 0 auto 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.starter-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.starter-actions button {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;
}

.quick-icon {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.starter-actions button:hover,
.starter-actions button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
  background: var(--surface-soft);
  outline: 0;
}

.message-list {
  min-height: 0;
  flex: 0 1 auto;
  max-height: 260px;
  padding: 0 10px 18px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}

.conversation.has-messages .message-list {
  flex: 1;
  max-height: none;
  padding: 18px 10px 30px;
}

.message-list[hidden] {
  display: none;
}

.message-row {
  display: flex;
  margin: 0 0 16px;
}

.message-user {
  justify-content: flex-end;
}

.message-assistant {
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
}

.conversation-tools {
  position: relative;
  display: none;
  flex: 0 0 auto;
  justify-content: flex-end;
  padding: 0 10px 3px;
}

.conversation.has-messages .conversation-tools {
  display: flex;
}

.conversation-tools-trigger {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10.5px;
}

.conversation-tools-trigger:hover,
.conversation-tools-trigger:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
  outline: 0;
}

.conversation-tools-trigger svg {
  width: 17px;
  height: 17px;
}

.conversation-tools-menu,
.attachment-menu {
  position: absolute;
  z-index: 35;
  display: grid;
  min-width: 220px;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
}

.conversation-tools-menu {
  top: 34px;
  right: 10px;
}

.conversation-tools-menu[hidden],
.attachment-menu[hidden] {
  display: none;
}

.conversation-tools-menu button,
.attachment-menu button {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 11.5px;
}

.conversation-tools-menu button:hover,
.conversation-tools-menu button:focus-visible,
.attachment-menu button:hover,
.attachment-menu button:focus-visible {
  background: var(--surface-soft);
  outline: 0;
}

.conversation-tools-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.message-bubble {
  max-width: min(82%, 900px);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-user .message-bubble {
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 18px 18px 5px 18px;
  background: var(--surface-soft);
}

.message-assistant .message-bubble {
  padding: 5px 2px;
}

.message-assistant .message-bubble strong {
  font-weight: 750;
}

.message-assistant .message-bubble code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.message-assistant .assistant-code-block {
  width: min(100%, 980px);
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-soft) 72%, #000 28%);
  white-space: normal;
}

.message-assistant .assistant-code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 6px 9px 6px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-assistant .assistant-code-copy {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.message-assistant .assistant-code-copy:hover,
.message-assistant .assistant-code-copy:focus-visible {
  border-color: var(--primary);
  outline: 0;
}

.message-assistant .assistant-code-block pre {
  margin: 0;
  padding: 15px 16px 17px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

.message-assistant .assistant-code-block code {
  display: block;
  min-width: max-content;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

.message-assistant .message-bubble a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-assistant .message-bubble a:hover,
.message-assistant .message-bubble a:focus-visible {
  color: color-mix(in srgb, var(--primary) 78%, white);
  outline: 0;
}

.message-bubble.is-pending {
  color: var(--muted);
}

.dalila-loader {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.dalila-loader-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.dalila-loader-mark::after {
  position: absolute;
  inset: -4px;
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 15px;
  animation: dalila-loader-pulse 900ms infinite alternate;
  content: "";
}

.dalila-loader-image {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.message-bubble.is-error {
  color: var(--danger);
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.message-actions button {
  padding: 4px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
}

.message-actions button:hover,
.message-actions button:focus-visible,
.message-actions button.is-selected {
  background: var(--surface-soft);
  color: var(--primary);
  outline: 0;
}

.message-sources {
  display: flex;
  width: min(100%, 760px);
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  margin-top: 7px;
}

.message-sources > strong {
  width: 100%;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.message-sources a {
  display: inline-flex;
  width: auto;
  min-height: 24px;
  max-width: 180px;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  text-decoration: none;
  opacity: 0.68;
  transition: opacity 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.message-sources a:hover,
.message-sources a:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: var(--surface-soft);
  opacity: 1;
  outline: 0;
}

.message-sources img {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 4px;
}

.message-sources a.has-fallback {
  padding-inline: 8px;
}

.message-sources a > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-domain-fallback {
  max-width: 138px;
  overflow: hidden;
  color: var(--primary);
  font-size: 9px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes dalila-pulse {
  from {
    opacity: 0.25;
    transform: translateY(0);
  }

  to {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes dalila-loader-pulse {
  from {
    opacity: 0.25;
    transform: scale(0.94);
  }

  to {
    opacity: 1;
    transform: scale(1.04);
  }
}

.composer {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 8px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-elevated);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.14);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-context-actions { display: flex; align-items: center; gap: 3px; }

.attachment-actions {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 1px;
  padding-bottom: 0;
}

.project-composer-tag {
  display: inline-flex;
  align-items: center;
  align-self: center;
  min-width: 0;
  max-width: 128px;
  height: 18px;
  margin-left: 1px;
  padding: 0 5px 0 4px;
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--primary) 12%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-soft) 94%, var(--primary) 6%);
  color: color-mix(in srgb, var(--muted) 90%, transparent 10%);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.project-composer-tag[hidden] {
  display: none;
}

.project-composer-tag svg {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-right: 3px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.project-composer-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-menu {
  bottom: 38px;
  left: 0;
}

.attachment-menu button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
}

.attachment-menu button[hidden] {
  display: none;
}

.attachment-button,
.voice-button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.attachment-button:hover,
.voice-button:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.attachment-button:disabled,
.voice-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.attachment-button[hidden] {
  display: none;
}

.attachment-button svg,
.voice-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.attachment-camera-icon { display: none; }

.municipality-context { position: relative; }
.municipality-selector {
  display: flex; align-items: center; gap: 6px; max-width: 235px; min-height: 30px;
  padding: 4px 7px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); cursor: pointer; font: inherit; font-size: 12px;
}
.municipality-selector:hover, .municipality-selector[aria-expanded="true"] { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text); }
.municipality-selector svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.municipality-selector span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.municipality-selector .municipality-chevron { width: 13px; height: 13px; }
.municipality-menu {
  position: absolute; right: 0; bottom: calc(100% + 9px); z-index: 45; width: 292px;
  padding: 8px; border: 1px solid var(--border); border-radius: 13px;
  background: var(--surface-elevated); box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}
.municipality-menu p { margin: 3px 6px 8px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.municipality-menu .context-menu-title { margin-top: 5px; margin-bottom: 4px; color: var(--text); font-size: 11px; font-weight: 750; letter-spacing: .01em; }
.municipality-menu .specialization-option svg { margin-top: 1px; }
.municipality-menu button { width: 100%; padding: 8px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
.municipality-menu button:hover { background: var(--surface-soft); }
.municipality-menu .is-danger, .profile-municipality-actions .is-danger { color: var(--danger); }
.municipality-menu button[hidden] { display: none; }
.municipality-menu .scope-option { display: flex; align-items: center; gap: 8px; }
.municipality-menu .scope-option.specialization-option { align-items: flex-start; }
.municipality-menu .scope-option svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.municipality-menu .scope-option > span:nth-child(2) { flex: 1; }
.municipality-menu .scope-check { visibility: hidden; color: var(--primary); font-weight: 800; }
.municipality-menu .scope-option[aria-checked="true"] { background: var(--surface-soft); }
.municipality-menu .scope-option[aria-checked="true"] .scope-check { visibility: visible; }
.municipality-menu-separator { height: 1px; margin: 6px 3px; background: var(--border); }

.voice-button.is-recording {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  animation: dalila-recording 900ms infinite alternate;
}

.voice-button .voice-icon-stop {
  display: none;
  fill: currentColor;
  stroke: none;
}

.voice-button.is-recording .voice-icon-mic {
  display: none;
}

.voice-button.is-recording .voice-icon-stop {
  display: block;
}

.voice-button.is-transcribing {
  color: var(--primary);
  animation: dalila-loader-pulse 700ms infinite alternate;
}

.voice-waveform {
  width: 112px;
  height: 38px;
  flex: 0 1 112px;
  overflow: hidden;
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.voice-waveform[hidden] {
}

.voice-waveform canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.selected-images {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
  padding: 0 4px 10px;
  overflow-x: auto;
}

.selected-images[hidden] {
  display: none;
}

.selected-image {
  position: relative;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-elevated);
}

.selected-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selected-document {
  position: relative;
  display: flex;
  width: 220px;
  height: 74px;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 10px 34px 10px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-elevated);
}

.selected-document-icon {
  display: grid;
  width: 40px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface-soft));
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
}

.selected-document > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.selected-document strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-document small {
  color: var(--muted);
  font-size: 9px;
}

.selected-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: rgba(7, 11, 20, 0.82);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.install-pwa-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.install-pwa-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.install-pwa-button[hidden] {
  display: none;
}

@keyframes dalila-recording {
  from { opacity: 0.65; }
  to { opacity: 1; }
}

.conversation.has-messages .composer {
  flex: 0 0 auto;
}

.composer:focus-within {
  border-color: rgba(18, 136, 255, 0.65);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 160px;
  resize: none;
  padding: 3px 7px 6px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.send-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
}

.send-button:hover {
  background: var(--primary-hover);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.composer-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.question-quota {
  color: var(--primary);
  font-weight: 750;
}

.lab-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lab-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.lab-card h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.lab-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-history-note {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.sidebar-history-note:hover span,
.sidebar-history-note:focus-visible span {
  color: var(--primary);
}

.sidebar-history {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  margin: 12px 3px 0;
  overflow: hidden;
}

.sidebar-history > strong {
  padding: 0 10px;
  font-size: 12px;
}

.history-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.history-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.history-entry {
  position: relative;
}

.history-controls {
  display: none;
  gap: 3px;
  padding: 0 9px 6px;
}

.history-entry:hover .history-controls,
.history-entry:focus-within .history-controls {
  display: flex;
}

.history-controls button {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
}

.history-controls button + button::before {
  margin: 0 5px;
  color: var(--border-strong);
  content: "·";
}

.history-controls button:hover,
.history-controls button:focus-visible {
  color: var(--primary);
  outline: 0;
}

.history-item:hover,
.history-item:focus-visible,
.history-item.is-active {
  border-color: var(--border);
  background: var(--surface-soft);
  outline: 0;
}

.history-item span {
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small,
.history-empty {
  color: var(--muted);
  font-size: 10px;
}

.history-empty {
  padding: 7px 10px;
  line-height: 1.45;
}

.sidebar-is-collapsed .sidebar-history {
  display: none;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.registration-banner {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  background: color-mix(in srgb, var(--primary) 7%, var(--background));
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.registration-banner button {
  padding: 4px 9px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 760;
}

.account-login-trigger,
.user-account-trigger {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.account-login-trigger:hover,
.account-login-trigger:focus-visible,
.user-account-trigger:hover,
.user-account-trigger:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
  outline: 0;
}

.account-login-trigger svg {
  width: 24px;
  height: 24px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-soft);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.account-login-trigger span {
  font-size: 11px;
  font-weight: 760;
}

.unlock-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 48%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
}

.unlock-button:hover,
.unlock-button:focus-visible {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  outline: 0;
}

.unlock-button[hidden],
.login-biometric-button[hidden] {
  display: none !important;
}

.unlock-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.unlock-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.user-account-menu {
  position: relative;
}

.user-account-trigger > img,
.user-account-initial {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
  object-fit: cover;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.user-account-trigger strong {
  max-width: 120px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.user-account-trigger[aria-expanded="true"] .account-chevron {
  transform: rotate(180deg);
}

.account-dropdown {
  position: absolute;
  z-index: 90;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 210px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

.account-dropdown[hidden] {
  display: none;
}

.account-dropdown button {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-align: left;
}

.account-dropdown button:hover,
.account-dropdown button:focus-visible {
  background: var(--surface-soft);
  outline: 0;
}

.account-dropdown .is-danger {
  color: var(--danger);
}

.account-dropdown form {
  margin: 5px 0 0;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

.account-dialog {
  width: min(92vw, 460px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.account-dialog::backdrop {
  background: rgba(4, 7, 13, 0.76);
  backdrop-filter: blur(8px);
}

.account-dialog h2 {
  margin: 0 34px 16px 0;
  font-size: 21px;
}

.account-dialog p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.image-generation-dialog form {
  display: grid;
  gap: 12px;
}

.image-generation-dialog label {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.image-generation-dialog textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  line-height: 1.5;
}

.image-generation-dialog textarea:focus {
  border-color: var(--primary);
}

.image-generation-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-generation-footer small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.image-generation-footer button,
.image-generation-login {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.image-generation-footer button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.image-generation-status {
  min-height: 18px;
  margin: 0 !important;
}

.image-generation-status.is-error {
  color: var(--danger);
}

.image-generation-login[hidden] {
  display: none;
}

.generated-image {
  display: grid;
  width: min(560px, 100%);
  gap: 9px;
  margin: 0;
}

.generated-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
}

.generated-image figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.generated-image a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.generated-image small {
  color: var(--muted);
  font-size: 10px;
}

.account-dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 25px;
  font-weight: 300;
  line-height: 1;
}

.account-dialog-close:hover,
.account-dialog-close:focus-visible {
  color: var(--text);
  outline: 0;
}

.account-profile-data {
  display: grid;
  gap: 10px;
  margin: 0;
}

.account-profile-data div {
  padding: 12px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.account-profile-data dt {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.account-profile-data dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.profile-municipality-actions { display: flex; gap: 8px; margin-top: 9px; }
.profile-municipality-actions button { padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--primary); cursor: pointer; font: inherit; font-size: 11px; }
.improvement-consent-control { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; cursor: pointer; }
.improvement-consent-control span { display: grid; gap: 5px; }
.improvement-consent-control strong { color: var(--text); font-size: 13px; }
.improvement-consent-control small, .improvement-consent-note { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; }
.improvement-consent-control input { appearance: none; flex: 0 0 auto; width: 38px; height: 22px; margin: 0; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; transition: 160ms ease; }
.improvement-consent-control input::before { content: ''; display: block; width: 16px; height: 16px; margin: 2px; border-radius: 50%; background: var(--muted); transition: 160ms ease; }
.improvement-consent-control input:checked { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 28%, var(--surface)); }
.improvement-consent-control input:checked::before { transform: translateX(16px); background: var(--primary); }
.improvement-consent-control input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.improvement-consent-control input:disabled { cursor: wait; opacity: .65; }
.improvement-consent-note { margin-top: 9px; }
.improvement-consent-status { display: block; min-height: 15px; margin-top: 6px; color: var(--primary); font-size: 10px; }
.municipality-dialog label { display: block; margin: 17px 0 7px; color: var(--text); font-size: 12px; font-weight: 700; }
.municipality-dialog input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; outline: 0; background: var(--surface-soft); color: var(--text); font: inherit; }
.municipality-dialog input:focus { border-color: var(--primary); }
.municipality-results { display: grid; gap: 4px; max-height: 280px; margin-top: 8px; overflow-y: auto; }
.municipality-results button { display: grid; gap: 3px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.municipality-results button:hover, .municipality-results button:focus-visible { background: var(--surface-soft); outline: 0; }
.municipality-results strong { font-size: 13px; }
.municipality-results span, .municipality-search-status { color: var(--muted); font-size: 10px; }

.biometric-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.biometric-state-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 15%, transparent);
}

.biometric-state-dot.is-active {
  background: #22c55e;
  box-shadow: 0 0 0 4px color-mix(in srgb, #22c55e 17%, transparent);
}

.biometric-state-dot.is-warning {
  background: #eab308;
  box-shadow: 0 0 0 4px color-mix(in srgb, #eab308 17%, transparent);
}

.biometric-state > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.biometric-state strong {
  font-size: 13px;
}

.biometric-state small,
.biometric-privacy {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.biometric-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin: 16px 0 13px;
}

.biometric-actions button {
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 48%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
}

.biometric-actions button.is-danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.biometric-actions button:disabled {
  cursor: wait;
  opacity: .62;
}


.passkey-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 4px;
}

.passkey-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.passkey-item-copy {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 3px;
}

.passkey-item-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.passkey-item-copy small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.passkey-item button {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
}

.passkey-item button:disabled {
  cursor: wait;
  opacity: .55;
}

.biometric-dialog-status {
  display: block;
  min-height: 16px;
  margin-top: 8px;
  color: var(--primary);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.biometric-dialog-status.is-error {
  color: var(--danger);
}

.account-delete-dialog form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.account-delete-dialog label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.account-delete-dialog form button {
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 760;
}

.login-dialog {
  width: min(92vw, 430px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.login-dialog::backdrop {
  background: rgba(4, 7, 13, 0.76);
  backdrop-filter: blur(8px);
}

.login-dialog > img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.login-dialog h2 {
  margin: 18px 0 7px;
  font-size: 24px;
}

.login-dialog p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.login-biometric-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 9px;
  margin: -5px 0 12px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 48%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 780;
}

.login-biometric-button:hover,
.login-biometric-button:focus-visible {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  outline: 0;
}

.login-biometric-button:disabled,
.unlock-button:disabled {
  cursor: wait;
  opacity: .62;
}

.login-biometric-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.biometric-login-status {
  display: block;
  min-height: 0;
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.biometric-login-status:empty {
  display: none;
}

.login-dialog-close {
  position: absolute;
  top: 13px;
  right: 15px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 27px;
}

.social-login {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.social-login:hover,
.social-login:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: var(--surface-soft);
  outline: 0;
}

.social-login span {
  font-size: 18px;
  font-weight: 850;
}

.google-login span {
  color: #4285f4;
}

.meta-login span {
  color: #1877f2;
}

.login-dialog small {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
}

.auth-toast {
  position: fixed;
  z-index: 80;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 11px 11px 16px;
  border: 1px solid color-mix(in srgb, #22c55e 55%, var(--border));
  border-radius: 13px;
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 12px;
  cursor: pointer;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.auth-toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
}

.auth-toast.is-closing {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.auth-toast-close {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.auth-toast-close:hover,
.auth-toast-close:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    height: var(--dalila-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .composer {
    gap: 3px;
    padding: 9px;
  }

  .attachment-actions {
    gap: 0;
  }

  .attachment-button.has-camera .attachment-paperclip-icon { display: none; }
  .attachment-button.has-camera .attachment-camera-icon { display: block; }

  .attachment-button,
  .voice-button {
    width: 30px;
    height: 30px;
  }

  .voice-waveform {
    width: 76px;
    flex-basis: 76px;
  }

  .install-pwa-button {
    padding: 8px;
  }

  .install-pwa-button span {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .unlock-button {
    max-width: 132px;
    min-height: 34px;
    padding: 5px 8px;
    font-size: 9.5px;
    line-height: 1.15;
  }

  .user-account-trigger strong,
  .account-chevron {
    display: none;
  }

  .user-account-trigger {
    padding: 2px;
    border: 0;
    background: transparent;
  }

  .account-login-trigger {
    padding-right: 7px;
  }

  .sidebar-is-collapsed .sidebar-history {
    display: flex;
  }

  .sidebar-is-collapsed .sidebar-history-note {
    display: grid;
  }

  .history-controls {
    display: flex;
  }

  .app-shell,
  .sidebar-is-collapsed .app-shell {
    position: absolute;
    top: var(--dalila-viewport-offset-top, 0px);
    right: 0;
    left: 0;
    display: block;
    height: var(--dalila-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    z-index: 45;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    height: var(--dalila-viewport-height, 100dvh);
    max-height: var(--dalila-viewport-height, 100dvh);
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-open .sidebar-backdrop {
    position: fixed;
    z-index: 44;
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    background: var(--overlay);
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-is-collapsed .sidebar {
    align-items: stretch;
    padding-right: 18px;
    padding-left: 18px;
  }

  .sidebar-is-collapsed .brand-image-full {
    display: block;
  }

  .sidebar-is-collapsed .brand-image-full.brand-light {
    display: none;
  }

  :root[data-theme="light"].sidebar-is-collapsed .brand-image-full.brand-dark {
    display: none;
  }

  :root[data-theme="light"].sidebar-is-collapsed .brand-image-full.brand-light {
    display: block;
  }

  .sidebar-is-collapsed .brand-image-symbol {
    display: none !important;
  }

  .sidebar-is-collapsed .nav-item span,
  .sidebar-is-collapsed .sidebar-meta {
    display: inline;
  }

  .sidebar-is-collapsed .sidebar-header {
    flex-direction: row;
  }

  .sidebar-is-collapsed .nav-item {
    justify-content: flex-start;
    width: auto;
    padding: 0 13px;
  }

  .main-content {
    height: var(--dalila-viewport-height, 100dvh);
    min-height: 0;
    max-height: var(--dalila-viewport-height, 100dvh);
  }

  .topbar {
    position: relative;
    z-index: 40;
    top: 0;
    min-height: 66px;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  }

  .mobile-menu-toggle {
    display: grid;
  }

  .mobile-brand {
    display: flex;
  }

  .topbar-title {
    display: grid;
  }

  .topbar-title strong {
    font-size: 16px;
  }

  .topbar-title span {
    font-size: 10px;
  }

  .laboratorio-content {
    min-height: 0;
    overflow: hidden;
    padding: 10px max(12px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .conversation {
    height: 100%;
    min-height: 0;
    padding-top: 6px;
  }

  .demo-intro {
    margin-bottom: 10px;
  }

  .demo-intro p {
    font-size: 12px;
    line-height: 1.35;
  }

  .demo-intro.is-returning {
    margin-bottom: 5px;
  }

  .demo-intro.is-returning p:not(:first-child) {
    display: none;
  }

  .demo-intro.is-returning .starter-actions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .demo-intro.is-returning .starter-actions::-webkit-scrollbar {
    display: none;
  }

  .demo-intro.is-returning .starter-actions button {
    min-width: 190px;
    flex: 0 0 auto;
  }

  .starter-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
  }

  .starter-actions button {
    min-height: 42px;
    justify-content: flex-start;
    padding: 0 10px;
    font-size: 10.5px;
  }

  .message-list {
    min-height: 0;
    flex: 1;
    max-height: none;
    padding-bottom: 12px;
    overscroll-behavior: contain;
  }

  .conversation.has-messages .message-list {
    min-height: 0;
    padding-top: 8px;
    padding-bottom: 24px;
    scroll-padding-bottom: 24px;
  }

  .mobile-keyboard-open .topbar {
    min-height: 54px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .mobile-keyboard-open .registration-banner {
    display: none;
  }

  .mobile-keyboard-open .laboratorio-content {
    padding-top: 4px;
  }

  .conversation-tools {
    padding-right: 2px;
  }

  .conversation-tools-menu {
    right: 2px;
  }

  .message-bubble {
    max-width: 94%;
    font-size: 13px;
    line-height: 1.45;
  }

  .composer {
    position: relative;
    z-index: 20;
    flex: 0 0 auto;
    margin-top: auto;
    padding: 9px;
    border-radius: 20px;
  }

  .municipality-selector { max-width: 180px; }
  .municipality-menu { position: fixed; right: 12px; bottom: calc(112px + env(safe-area-inset-bottom)); width: min(310px, calc(100vw - 24px)); }

  .composer-caption {
    flex: 0 0 auto;
    margin: 5px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    font-size: 10px;
  }

  .composer-caption span:not(.question-quota) {
    display: none;
  }

  .image-generation-dialog {
    width: calc(100vw - 24px);
    max-height: calc(var(--dalila-viewport-height, 100dvh) - 24px);
    padding: 22px 18px;
  }

  .image-generation-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .image-generation-footer button {
    width: 100%;
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }
}

/* Manager surface */
.manager-page { overflow: hidden; background: var(--surface); color: var(--ink); }
.manager-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100dvh; min-height: 0; }
.manager-sidebar { display: flex; min-height: 0; flex-direction: column; gap: 30px; padding: 26px 16px 18px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.manager-brand { display: block; padding: 4px 12px 18px; border-bottom: 1px solid var(--line); }
.manager-brand img { width: 142px; height: auto; }
.manager-nav { display: grid; gap: 5px; }
.manager-nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; transition: background 160ms ease, color 160ms ease; }
.manager-nav-item span { width: 20px; color: var(--accent); text-align: center; font-size: 17px; }
.manager-nav-item:hover, .manager-nav-item.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); }
.manager-sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.manager-sidebar-footer button { padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; }
.manager-main { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.manager-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 88px; padding: 18px clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line); background: var(--surface); }
.manager-topbar h1, .manager-heading h2 { margin: 2px 0 0; font-size: 23px; letter-spacing: 0; }
.manager-topbar-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.manager-theme-toggle { width: 36px; height: 36px; margin-left: 14px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; }
.manager-content { max-width: 1480px; margin: 0 auto; padding: 34px clamp(20px, 4vw, 56px) 56px; }
.manager-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.manager-kicker, .eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.manager-muted, .manager-note, .manager-date { color: var(--muted); font-size: 12px; }
.manager-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.manager-metric, .manager-panel, .config-row { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.manager-metric { min-height: 108px; padding: 17px; }
.manager-metric span { display: block; color: var(--muted); font-size: 11px; }
.manager-metric strong { display: block; margin-top: 17px; color: var(--ink); font-size: 22px; }
.manager-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.manager-grid-health { grid-template-columns: .8fr 1.2fr; }
.manager-grid-two { grid-template-columns: 1fr 1fr; }
.manager-panel { min-width: 0; padding: 20px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-heading h3 { margin: 0; font-size: 14px; }
.panel-heading span { color: var(--muted); font-size: 11px; }
.health-row, .config-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.health-row:last-child { border-bottom: 0; }
.health-row strong { color: var(--ink); font-size: 12px; font-weight: 650; text-align: right; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #39d98a; box-shadow: 0 0 0 4px color-mix(in srgb, #39d98a 14%, transparent); }
.status-dot.is-off { background: #f59e0b; box-shadow: 0 0 0 4px color-mix(in srgb, #f59e0b 14%, transparent); }
.bar-chart { display: flex; align-items: end; gap: 5px; height: 180px; padding-top: 20px; }
.bar-column { display: flex; min-width: 0; flex: 1; height: 100%; flex-direction: column; align-items: center; justify-content: end; gap: 7px; }
.bar-column i { width: 100%; min-height: 3px; border-radius: 4px 4px 1px 1px; background: var(--accent); opacity: .82; }
.blue-bars .bar-column i { background: #49a4ff; }
.cost-bars .bar-column i { background: #e879f9; }
.bar-column small { color: var(--muted); font-size: 8px; }
.manager-login-form input { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--panel); color: var(--ink); font: inherit; }
.manager-login-form input:focus { border-color: var(--accent); }
.manager-primary-button { min-height: 40px; padding: 0 18px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-weight: 700; }
.manager-table-wrap { overflow-x: auto; }
.manager-table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 12px; }
.manager-table th { padding: 0 12px 12px; color: var(--muted); font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; }
.manager-table td { padding: 14px 12px; border-top: 1px solid var(--line); color: var(--ink); }
.manager-table code, .log-view { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.badge-success { background: color-mix(in srgb, #39d98a 18%, transparent); color: #39d98a; }
.badge-muted { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }
.empty-state { padding: 42px 12px !important; color: var(--muted) !important; text-align: center; }
.manager-pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding-top: 20px; color: var(--muted); font-size: 12px; }
.manager-pagination a { color: var(--accent); text-decoration: none; }
.log-view { overflow: auto; margin: 0; padding: 15px; border-radius: 7px; background: color-mix(in srgb, #000 16%, var(--panel)); color: var(--muted); font-size: 11px; line-height: 1.6; white-space: pre-wrap; }
.config-row { min-height: 60px; margin-bottom: 9px; padding: 14px 18px; }.config-row span { color: var(--muted); font-size: 12px; }.config-row strong { font-size: 13px; }
.manager-login-page { display: grid; min-height: 100dvh; place-items: center; background: var(--surface); }
.manager-login { width: min(92vw, 390px); padding: 34px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.manager-login-mark { display: grid; width: 44px; height: 44px; margin-bottom: 24px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 22px; font-weight: 800; }
.manager-login h1 { margin: 5px 0; font-size: 27px; }.manager-login-form { display: grid; gap: 15px; margin-top: 25px; }.manager-login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }.manager-login-form input { width: 100%; }.form-error { margin: -4px 0 0; color: #fb7185; font-size: 11px; }
.manager-secondary-button, .manager-danger-button { min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; font-weight: 700; }
.manager-danger-button { border-color: color-mix(in srgb, #fb7185 45%, var(--line)); color: #fb7185; }
.manager-alert { margin: 0 0 18px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.manager-alert-success { border-color: color-mix(in srgb, #39d98a 40%, var(--line)); color: #39d98a; }
.manager-alert-error { border-color: color-mix(in srgb, #fb7185 40%, var(--line)); color: #fb7185; }
.knowledge-create-panel { margin-bottom: 18px; }
.knowledge-list { display: grid; gap: 10px; }
.knowledge-document { border: 1px solid var(--line); border-radius: 8px; }
.knowledge-document summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px; cursor: pointer; }
.knowledge-document summary span { color: var(--muted); font-size: 11px; }
.knowledge-form { display: grid; gap: 14px; padding: 0 15px 15px; }
.knowledge-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.knowledge-form input, .knowledge-form textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--surface); color: var(--ink); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.knowledge-form textarea { resize: vertical; }
.knowledge-form input:focus, .knowledge-form textarea:focus { border-color: var(--accent); }
.knowledge-actions { display: flex; justify-content: flex-end; gap: 9px; }
.knowledge-document > form:last-child { padding: 0 15px 15px; text-align: right; }
@media (max-width: 1050px) { .manager-metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .manager-page { overflow: auto; }.manager-shell { display: block; height: auto; min-height: 100dvh; }.manager-sidebar { position: static; gap: 14px; padding: 15px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }.manager-main { overflow: visible; }.manager-brand { padding-bottom: 12px; }.manager-nav { grid-template-columns: repeat(4, 1fr); }.manager-nav-item { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 10px; text-align: center; }.manager-nav-item span { width: auto; }.manager-sidebar-footer { display: none; }.manager-topbar { min-height: 68px; padding: 14px 16px; }.manager-topbar h1 { font-size: 18px; }.manager-content { padding: 22px 14px 35px; }.manager-metrics, .manager-grid-health, .manager-grid-two { grid-template-columns: 1fr; }.manager-metric { min-height: 88px; }.manager-metric strong { margin-top: 12px; }.manager-heading { align-items: start; flex-direction: column; }.manager-table { font-size: 11px; } }

/* Storage account */
.account-profile-storage dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.account-profile-storage button {
  margin-left: auto;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.account-profile-storage small {
  flex-basis: 100%;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.storage-dialog {
  width: min(94vw, 760px);
  max-height: min(86dvh, 820px);
  overflow: auto;
}

.storage-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 10px;
}

.storage-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.storage-summary span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.storage-summary strong {
  font-size: 15px;
}

.storage-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.storage-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.storage-file-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.storage-file-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.storage-file-preview {
  display: grid;
  min-height: 132px;
  place-items: center;
  overflow: hidden;
  background: var(--surface);
  color: var(--muted);
}

.storage-file-preview img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
}

.storage-file-preview span {
  padding: 18px;
  font-size: 34px;
}

.storage-file-body {
  display: grid;
  gap: 5px;
  padding: 11px;
}

.storage-file-body strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-file-body small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.storage-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 5px;
}

.storage-file-actions a,
.storage-file-actions button,
.storage-footer button {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.storage-file-actions button {
  color: var(--danger);
}

.storage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.storage-status {
  min-height: 18px;
  margin: 0 !important;
}

.storage-empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.message-attachment-link {
  display: inline-flex;
  max-width: 240px;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: 10px;
  text-decoration: none;
}

.message-attachment-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .storage-summary,
  .storage-file-list {
    grid-template-columns: 1fr;
  }

  .storage-file-preview img {
    height: 210px;
  }
}


/* Anteprima immagini interna alla chat */
.image-lightbox[hidden] {
  display: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  place-items: center;
  overflow: hidden;
  border: 0;
  background: transparent;
}

.image-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.image-lightbox-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  gap: 10px;
  place-items: center;
}

.image-lightbox-image {
  display: block;
  max-width: 94vw;
  max-height: 84vh;
  width: auto;
  height: auto;
  border-radius: 14px;
  background: #05070b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.image-lightbox-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.image-lightbox-close:hover {
  opacity: 0.78;
}

.image-lightbox-caption {
  max-width: 90vw;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  text-align: center;
}

.image-lightbox-open {
  overflow: hidden;
}

.generated-image img,
.message-attachment-link[type="button"] {
  cursor: zoom-in;
}

button.message-attachment-link {
  font: inherit;
  text-align: left;
}

@media (max-width: 620px) {
  .image-lightbox {
    padding: 12px;
  }

  .image-lightbox-image {
    max-width: 96vw;
    max-height: 82vh;
  }

  .image-lightbox-close {
    top: 8px;
    right: 8px;
  }
}

.message-actions button[data-message-action="finance_pdf"],
.message-actions button[data-message-action="finance_monitor"] {
  color: var(--primary);
}

.message-actions button[data-message-action="finance_monitor"]:disabled {
  cursor: wait;
  opacity: 0.55;
}

/* Specializzazioni chat */
.specialization-lock-note {
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-size: 10px !important;
}

.specialization-suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.specialization-suggestion-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.specialization-suggestion-actions button:hover,
.specialization-suggestion-actions button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  outline: 0;
}

.specialization-suggestion-actions .specialization-suggestion-primary {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  color: var(--primary);
}

.history-group {
  display: grid;
  gap: 3px;
  margin: 0 0 9px;
}

.history-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 4px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 760;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.history-group-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-group + .history-group {
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

/* Avviso Storage nella top bar */
.storage-warning-trigger {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  font-weight: 750;
  white-space: nowrap;
}

.storage-warning-trigger[hidden] {
  display: none;
}

.storage-warning-trigger:hover,
.storage-warning-trigger:focus-visible {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  outline: 0;
}

.storage-warning-mark {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
}

/* Selezione multipla nella galleria immagini generate */
.image-library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.image-library-select-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.image-library-select-all input,
.image-collection-select input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.image-library-selection-count {
  color: var(--muted);
  font-size: 10.5px;
}

.image-library-delete-selected {
  margin-left: auto;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
}

.image-library-delete-selected:hover,
.image-library-delete-selected:focus-visible {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  outline: 0;
}

.image-library-delete-selected:disabled {
  cursor: default;
  opacity: .4;
}

.image-collection-select {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid color-mix(in srgb, #fff 34%, transparent);
  border-radius: 8px;
  background: rgba(5, 7, 11, .7);
  backdrop-filter: blur(5px);
}

.image-collection-select input {
  accent-color: #fff;
}

/* Esperienza immagini: formato, galleria e risorse */
.image-format-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 11px;
}

.image-format-hint {
  display: block;
  margin-top: -5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.generated-image-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.generated-image-primary-actions,
.image-collection-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.generated-image-primary-actions a,
.generated-image-primary-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.generated-image-primary-actions a:hover,
.generated-image-primary-actions a:focus-visible,
.generated-image-primary-actions button:hover,
.generated-image-primary-actions button:focus-visible {
  background: var(--surface-soft);
  color: var(--primary);
  outline: 0;
}

.image-collection-actions button,
.image-collection-actions a {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.image-collection-actions button:hover,
.image-collection-actions a:hover {
  text-decoration: underline;
}

.image-library-dialog,
.image-assets-dialog {
  width: min(1000px, calc(100vw - 32px));
}

.image-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  max-height: min(62vh, 680px);
  overflow: auto;
  padding: 2px;
}

.image-collection-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.image-collection-card > img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  cursor: zoom-in;
  background: var(--surface);
}

.image-collection-card-body {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.image-collection-card-body > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.image-collection-card-body > small {
  color: var(--muted);
  font-size: 10px;
}

.image-collection-actions {
  gap: 8px;
}

.image-collection-actions .is-danger {
  color: var(--danger);
}

.image-asset-upload {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.image-asset-upload label {
  display: none;
}

.image-asset-upload input[type="text"],
.image-asset-upload input[type="file"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
}

.image-asset-upload input[type="file"] {
  padding: 4px 6px;
  cursor: pointer;
}

.image-asset-upload input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 6px 11px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-elevated));
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
}

.image-asset-upload input[type="file"]::file-selector-button:hover {
  background: color-mix(in srgb, var(--primary) 24%, var(--surface-elevated));
}

.image-asset-upload button {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.image-asset-upload button:hover,
.image-asset-upload button:focus-visible {
  filter: brightness(1.08);
  outline: 0;
}

.image-asset-upload button:disabled {
  cursor: wait;
  opacity: .6;
}

@media (max-width: 700px) {
  .image-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-asset-upload {
    grid-template-columns: 1fr;
  }
}

/* UX refresh 23/08/2026 */
:root {
  --border-strong: color-mix(in srgb, var(--text) 16%, var(--border));
  --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);
  --primary-soft-strong: color-mix(in srgb, var(--primary) 20%, transparent);
  --surface-glass: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
  --surface-hover: color-mix(in srgb, var(--surface-soft) 78%, var(--surface-elevated));
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
  --soft-shadow: 0 14px 34px rgba(0, 0, 0, .14);
}

:root[data-theme="light"] {
  --soft-shadow: 0 14px 34px rgba(31, 52, 84, .09);
}

.main-content {
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 34%),
    var(--background);
}

.topbar {
  min-height: 68px;
  padding: 12px 20px;
  border-bottom-color: color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--background) 82%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 2%, transparent);
  backdrop-filter: blur(22px) saturate(135%);
}

.topbar-title {
  gap: 0;
}

.topbar-title strong {
  font-size: 16px;
  letter-spacing: -.015em;
}

.topbar-title span {
  margin-top: 1px;
  font-size: 10.5px;
  letter-spacing: .02em;
}

.topbar-actions {
  gap: 7px;
}

.icon-button,
.install-pwa-button,
.account-login-trigger,
.user-account-trigger,
.storage-warning-trigger {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.icon-button:hover,
.install-pwa-button:hover,
.account-login-trigger:hover,
.user-account-trigger:hover,
.storage-warning-trigger:hover {
  transform: translateY(-1px);
}

.icon-button:active,
.install-pwa-button:active,
.account-login-trigger:active,
.user-account-trigger:active,
.storage-warning-trigger:active {
  transform: translateY(0);
}

.sidebar {
  padding: 18px 14px 16px;
  border-right-color: color-mix(in srgb, var(--border) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 96%, var(--background));
}

.sidebar-header {
  min-height: 50px;
  padding: 0 4px;
}

.brand-image-full {
  width: 158px;
}

.navigation {
  gap: 10px;
  margin-top: 24px;
}

.nav-item {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-item.new-conversation {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  color: var(--text);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 4%, transparent);
}

.nav-item.new-conversation svg {
  color: var(--primary);
}

.nav-item.new-conversation:hover,
.nav-item.new-conversation:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  transform: translateY(-1px);
}

.sidebar-history {
  margin-top: 15px;
}

.sidebar-history > strong {
  padding: 0 11px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .065em;
  text-transform: uppercase;
}

.history-list {
  gap: 2px;
  padding-right: 2px;
}

.history-group {
  gap: 2px;
  margin-bottom: 7px;
}

.history-group-title {
  padding: 8px 10px 4px;
  font-size: 9px;
}

.history-item {
  position: relative;
  min-height: 44px;
  gap: 2px;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.history-item:hover,
.history-item:focus-visible {
  transform: translateX(1px);
}

.history-item.is-active {
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface-soft));
}

.history-item.is-active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: var(--primary);
  content: "";
}

.history-controls {
  padding-left: 12px;
}

.sidebar-footer {
  padding: 12px 5px 0;
}

.sidebar-meta {
  opacity: .78;
}

.laboratorio-content {
  padding: 20px 30px 22px;
}

.conversation {
  width: min(980px, 100%);
  padding-top: 8px;
}

.demo-intro {
  max-width: 900px;
  margin-bottom: 18px;
  padding: 8px 14px 0;
}

.demo-intro-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 17px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-elevated));
  box-shadow: var(--soft-shadow);
}

.demo-intro-mark img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.demo-intro h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 720;
  letter-spacing: -.035em;
  line-height: 1.08;
}

.demo-intro p {
  margin-bottom: 0;
}

.demo-intro .demo-intro-lead {
  max-width: 680px;
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
  font-size: 14px;
  line-height: 1.55;
}

.demo-intro .demo-intro-account {
  display: inline-flex;
  margin-top: 9px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.demo-intro .demo-intro-context {
  max-width: 690px;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.starter-actions {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  max-width: 900px;
  margin: 18px auto 0;
}

.starter-actions button {
  position: relative;
  min-height: 72px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 11px 12px;
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface-elevated) 88%, var(--background));
  box-shadow: 0 8px 22px rgba(0, 0, 0, .07);
  font-size: 11px;
  line-height: 1.28;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

:root[data-theme="light"] .starter-actions button {
  box-shadow: 0 8px 20px rgba(29, 50, 79, .05);
}

.starter-actions button:hover,
.starter-actions button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-elevated));
  box-shadow: 0 12px 28px rgba(0, 0, 0, .1);
  transform: translateY(-2px);
}

.starter-actions button:active {
  transform: translateY(0);
}

.quick-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  font-size: 15px;
}

.message-list {
  padding-inline: 14px;
  scrollbar-gutter: stable;
}

.conversation.has-messages .message-list {
  padding-top: 16px;
  padding-bottom: 28px;
}

.message-row {
  margin-bottom: 18px;
}

.message-bubble {
  max-width: min(86%, 820px);
  font-size: 14px;
  line-height: 1.58;
}

.message-user .message-bubble {
  padding: 11px 15px;
  border-color: color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: 18px 18px 6px 18px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-soft));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 3%, transparent);
}

.message-assistant .message-bubble {
  padding: 3px 0;
}

.message-actions {
  gap: 2px;
  margin-top: 6px;
}

.message-actions button {
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 7px;
  font-size: 10px;
  transition: background-color 140ms ease, color 140ms ease;
}

.message-sources {
  margin-top: 9px;
}

.message-assistant .assistant-code-block {
  margin: 14px 0;
  border-radius: 13px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 3%, transparent);
}

.message-assistant .assistant-code-block-header {
  min-height: 40px;
  padding-inline: 14px 8px;
}

.message-assistant .assistant-code-copy {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.message-assistant .assistant-code-copy:hover,
.message-assistant .assistant-code-copy:focus-visible {
  background: var(--surface-hover);
  color: var(--primary);
}

.conversation-tools {
  padding: 0 14px 3px;
}

.conversation-tools-trigger {
  min-height: 32px;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 9px;
  font-size: 10px;
}

.conversation-tools-menu,
.attachment-menu,
.account-dropdown,
.municipality-menu {
  border-color: color-mix(in srgb, var(--border) 86%, transparent);
  background: var(--surface-glass);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
  backdrop-filter: blur(20px) saturate(135%);
}

.account-dropdown {
  width: 232px;
  gap: 2px;
  padding: 7px;
  border-radius: 14px;
}

.account-dropdown button {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 11.5px;
}

.account-dropdown button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--muted);
  stroke-width: 1.75;
}

.account-dropdown button:hover svg,
.account-dropdown button:focus-visible svg {
  color: var(--primary);
}

.account-dropdown .is-danger:hover svg,
.account-dropdown .is-danger:focus-visible svg {
  color: var(--danger);
}

.account-dropdown-separator {
  height: 1px;
  margin: 4px 5px;
  background: color-mix(in srgb, var(--border) 82%, transparent);
}

.account-dropdown form {
  margin-top: 3px;
  padding-top: 4px;
}

.account-login-trigger,
.user-account-trigger {
  min-height: 40px;
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-elevated) 88%, transparent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
}

.user-account-trigger > img,
.user-account-initial {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 13%, var(--surface-soft));
}

.user-account-trigger strong {
  font-size: 10.5px;
  font-weight: 700;
}

.install-pwa-button {
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 10.5px;
}

.storage-warning-trigger {
  min-height: 38px;
  padding-inline: 9px;
  border-radius: 10px;
}

.storage-warning-mark {
  width: 16px;
  height: 16px;
  font-size: 10px;
}

.composer {
  gap: 6px;
  padding: 11px 12px 9px;
  border-color: color-mix(in srgb, var(--border) 90%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface-elevated) 96%, transparent);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .15), inset 0 1px 0 color-mix(in srgb, #fff 3%, transparent);
  backdrop-filter: blur(16px);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

:root[data-theme="light"] .composer {
  box-shadow: 0 14px 34px rgba(31, 52, 84, .1), inset 0 1px 0 rgba(255, 255, 255, .8);
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--primary) 52%, var(--border));
  box-shadow: 0 18px 42px rgba(0, 0, 0, .17), var(--focus-ring);
}

.composer textarea {
  min-height: 46px;
  max-height: 180px;
  padding: 5px 7px 4px;
  font-size: 15px;
  line-height: 1.5;
}

.composer-toolbar {
  min-height: 34px;
}

.attachment-button,
.voice-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.attachment-button svg,
.voice-button svg {
  width: 18px;
  height: 18px;
}

.municipality-selector {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-soft) 58%, transparent);
  font-size: 11px;
}

.municipality-selector:hover,
.municipality-selector[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface-soft));
}

.send-button {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 24%, transparent);
  transition: background-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.send-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 22px color-mix(in srgb, var(--primary) 30%, transparent);
}

.send-button:not(:disabled):active {
  transform: translateY(0);
}

.send-button:disabled {
  box-shadow: none;
  opacity: .32;
}

.composer-caption {
  gap: 6px 12px;
  margin-top: 9px;
  font-size: 9.5px;
  line-height: 1.35;
  opacity: .84;
}

.question-quota {
  font-size: 9.5px;
}

.selected-images {
  gap: 8px;
  padding: 0 5px 9px;
}

.selected-image,
.selected-document {
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
}

.selected-image-remove {
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 7px;
  background: rgba(7, 11, 20, .72);
  backdrop-filter: blur(7px);
  font-size: 16px;
}

.account-dialog,
.login-dialog {
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
  background: color-mix(in srgb, var(--surface-elevated) 98%, var(--background));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .38);
}

.account-dialog {
  width: min(92vw, 500px);
  max-height: min(88dvh, 860px);
  padding: 26px 28px 28px;
  overflow: auto;
  border-radius: 22px;
}

.account-dialog::backdrop,
.login-dialog::backdrop {
  background: color-mix(in srgb, #02050b 72%, transparent);
  backdrop-filter: blur(10px) saturate(90%);
}

.account-dialog h2 {
  margin: 0 42px 8px 0;
  background: transparent;
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -.025em;
}

.account-dialog > p:first-of-type {
  margin-top: 0;
}

.account-dialog p {
  font-size: 12px;
  line-height: 1.55;
}

.account-dialog-close,
.login-dialog-close {
  top: 15px;
  right: 17px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
  transition: color 140ms ease, background-color 140ms ease;
}

.account-dialog-close:hover,
.account-dialog-close:focus-visible,
.login-dialog-close:hover,
.login-dialog-close:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
  outline: 0;
}

.account-profile-data {
  gap: 8px;
  margin-top: 16px;
}

.account-profile-data div {
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
}

.account-profile-data dt {
  font-size: 9px;
  letter-spacing: .055em;
}

.account-profile-data dd {
  margin-top: 5px;
}

.profile-municipality-actions button,
.account-profile-storage button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
}

.profile-municipality-actions button:hover,
.account-profile-storage button:hover {
  text-decoration: underline;
}

.improvement-consent-control input {
  width: 42px;
  height: 24px;
}

.improvement-consent-control input::before {
  width: 18px;
  height: 18px;
}

.improvement-consent-control input:checked::before {
  transform: translateX(18px);
}

.storage-dialog,
.image-library-dialog,
.image-assets-dialog {
  width: min(1040px, calc(100vw - 38px));
  max-height: min(90dvh, 880px);
}

.storage-summary {
  gap: 9px;
  margin-top: 17px;
}

.storage-summary div {
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--border) 68%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 66%, transparent);
}

.storage-summary span {
  font-size: 9px;
  letter-spacing: .06em;
}

.storage-summary strong {
  font-size: 16px;
}

.storage-progress {
  height: 8px;
  margin-top: 4px;
  background: color-mix(in srgb, var(--surface-soft) 88%, var(--background));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .12);
}

.storage-progress i {
  box-shadow: 0 0 16px color-mix(in srgb, var(--primary) 30%, transparent);
}

.storage-file-list {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.storage-file-card,
.image-collection-card {
  border-color: color-mix(in srgb, var(--border) 85%, transparent);
  background: color-mix(in srgb, var(--surface-soft) 74%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .07);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.storage-file-card:hover,
.image-collection-card:hover {
  border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
  box-shadow: 0 13px 30px rgba(0, 0, 0, .11);
  transform: translateY(-2px);
}

.storage-file-preview {
  min-height: 146px;
  background: color-mix(in srgb, var(--surface) 92%, var(--background));
}

.storage-file-preview img {
  height: 178px;
  transition: transform 180ms ease;
}

.storage-file-card:hover .storage-file-preview img,
.image-collection-card:hover > img {
  transform: scale(1.015);
}

.storage-file-body,
.image-collection-card-body {
  gap: 5px;
  padding: 11px 12px 12px;
}

.storage-file-actions {
  gap: 10px;
  padding-top: 4px;
}

.storage-file-actions a,
.storage-file-actions button {
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.storage-file-actions a:hover,
.storage-file-actions a:focus-visible,
.storage-file-actions button:hover,
.storage-file-actions button:focus-visible {
  color: var(--primary);
  text-decoration: none;
  outline: 0;
}

.storage-file-actions button:hover,
.storage-file-actions button:focus-visible {
  color: var(--danger);
}

.storage-footer {
  min-height: 34px;
  margin-top: 13px;
}

.storage-footer > button {
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 10px;
}

.storage-empty {
  padding: 36px 24px;
  border-style: dashed;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-soft) 42%, transparent);
}

.image-library-toolbar {
  position: sticky;
  z-index: 3;
  top: -26px;
  gap: 10px;
  margin: 14px 0 14px;
  padding: 10px 11px;
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-elevated) 94%, transparent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  backdrop-filter: blur(16px);
}

.image-library-select-all {
  font-size: 10.5px;
}

.image-library-selection-count {
  padding-left: 2px;
  font-size: 10px;
}

.image-library-delete-selected {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 10px;
}

.image-library-grid {
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 12px;
  max-height: min(64vh, 690px);
  padding: 2px 4px 6px 2px;
}

.image-collection-card {
  border-radius: 14px;
}

.image-collection-card > img {
  background: color-mix(in srgb, var(--surface) 94%, var(--background));
  transition: transform 180ms ease;
}

.image-collection-card-body > strong {
  font-size: 11.5px;
}

.image-collection-card-body > small {
  font-size: 9.5px;
}

.image-collection-actions {
  gap: 10px;
  padding-top: 2px;
}

.image-collection-actions button,
.image-collection-actions a {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.image-collection-actions button:hover,
.image-collection-actions button:focus-visible,
.image-collection-actions a:hover,
.image-collection-actions a:focus-visible {
  color: var(--primary);
  text-decoration: none;
  outline: 0;
}

.image-collection-actions .is-danger:hover,
.image-collection-actions .is-danger:focus-visible {
  color: var(--danger);
}

.image-collection-select {
  top: 9px;
  left: 9px;
  width: 30px;
  height: 30px;
  border-color: rgba(255, 255, 255, .34);
  border-radius: 9px;
  background: rgba(5, 7, 11, .62);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  backdrop-filter: blur(8px);
}

.image-asset-upload {
  grid-template-columns: minmax(180px, .9fr) minmax(250px, 1.35fr) auto;
  gap: 10px 12px;
  margin: 16px 0 18px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-soft) 54%, transparent);
}

.image-asset-upload label {
  display: block;
  margin: 0 0 -4px 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.image-asset-upload label:nth-of-type(1) {
  grid-column: 1;
  grid-row: 1;
}

.image-asset-upload input[type="text"] {
  grid-column: 1;
  grid-row: 2;
}

.image-asset-upload label:nth-of-type(2) {
  grid-column: 2;
  grid-row: 1;
}

.image-asset-upload input[type="file"] {
  grid-column: 2;
  grid-row: 2;
}

.image-asset-upload button {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: end;
  min-height: 42px;
  border-radius: 10px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 18%, transparent);
}

.image-asset-upload input[type="text"],
.image-asset-upload input[type="file"],
.image-format-select,
.image-generation-dialog textarea,
.municipality-dialog input {
  border-color: color-mix(in srgb, var(--border) 90%, transparent);
  background: color-mix(in srgb, var(--surface) 52%, var(--surface-soft));
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.image-asset-upload input[type="text"]:focus,
.image-asset-upload input[type="file"]:focus,
.image-format-select:focus,
.image-generation-dialog textarea:focus,
.municipality-dialog input:focus {
  border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
  box-shadow: var(--focus-ring);
  outline: 0;
}

.image-asset-upload input[type="file"]::file-selector-button {
  min-height: 31px;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface-elevated));
  font-size: 10px;
}

.image-generation-footer button,
.image-generation-login,
.image-asset-upload button,
.account-delete-dialog form button {
  transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.image-generation-footer button:not(:disabled):hover,
.image-generation-login:hover,
.image-asset-upload button:not(:disabled):hover {
  filter: none;
  transform: translateY(-1px);
}

.login-dialog {
  padding: 30px;
  border-radius: 22px;
}

.login-dialog h2 {
  letter-spacing: -.03em;
}

.social-login {
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
  background: color-mix(in srgb, var(--surface-soft) 32%, transparent);
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.social-login:hover,
.social-login:focus-visible {
  transform: translateY(-1px);
}

.registration-banner {
  min-height: 36px;
  border-bottom-color: color-mix(in srgb, var(--primary) 15%, var(--border));
  background: color-mix(in srgb, var(--primary) 5%, var(--background));
  font-size: 10px;
}

.auth-toast {
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .24);
}

.image-lightbox-image {
  border-radius: 16px;
  box-shadow: 0 32px 100px rgba(0, 0, 0, .62);
}

.image-lightbox-close {
  top: -2px;
  right: -4px;
  width: 38px;
  height: 38px;
  font-size: 30px;
}

/* Consistenza dei focus senza aggiungere bordi visivi permanenti */
.nav-item:focus-visible,
.history-item:focus-visible,
.starter-actions button:focus-visible,
.send-button:focus-visible,
.attachment-button:focus-visible,
.voice-button:focus-visible,
.municipality-selector:focus-visible,
.account-dropdown button:focus-visible,
.storage-file-actions a:focus-visible,
.storage-file-actions button:focus-visible,
.image-collection-actions a:focus-visible,
.image-collection-actions button:focus-visible {
  box-shadow: var(--focus-ring);
  outline: 0;
}

@media (max-width: 1100px) {
  .starter-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 62px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .topbar-title strong {
    font-size: 14px;
  }

  .topbar-title span {
    font-size: 9px;
  }

  .laboratorio-content {
    padding: 8px max(10px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .demo-intro {
    margin-bottom: 8px;
    padding-inline: 5px;
  }

  .demo-intro-mark {
    width: 46px;
    height: 46px;
    margin-bottom: 10px;
    border-radius: 14px;
  }

  .demo-intro-mark img {
    width: 29px;
    height: 29px;
  }

  .demo-intro h1 {
    margin-bottom: 6px;
    font-size: 24px;
  }

  .demo-intro .demo-intro-lead {
    font-size: 12px;
    line-height: 1.45;
  }

  .demo-intro .demo-intro-account {
    margin-top: 7px;
    font-size: 9px;
  }

  .demo-intro .demo-intro-context {
    margin-top: 6px;
    font-size: 10px;
  }

  .demo-intro.is-returning .demo-intro-mark,
  .demo-intro.is-returning h1,
  .demo-intro.is-returning .demo-intro-account,
  .demo-intro.is-returning .demo-intro-context {
    display: none;
  }

  .demo-intro.is-returning .demo-intro-lead {
    display: block !important;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10.5px;
  }

  .starter-actions,
  .demo-intro.is-returning .starter-actions {
    display: flex;
    grid-template-columns: none;
    gap: 7px;
    margin-top: 11px;
    overflow-x: auto;
    padding: 1px 2px 5px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .starter-actions::-webkit-scrollbar {
    display: none;
  }

  .starter-actions button,
  .demo-intro.is-returning .starter-actions button {
    min-width: 154px;
    min-height: 64px;
    flex: 0 0 154px;
    scroll-snap-align: start;
    padding: 9px 10px;
    font-size: 10px;
  }

  .quick-icon {
    width: 25px;
    height: 25px;
    font-size: 13px;
  }

  .message-list,
  .conversation.has-messages .message-list {
    padding-inline: 4px;
  }

  .message-bubble {
    max-width: 94%;
    font-size: 13px;
    line-height: 1.52;
  }

  .message-user .message-bubble {
    padding: 10px 13px;
  }

  .conversation-tools {
    padding-right: 0;
  }

  .composer {
    gap: 5px;
    padding: 9px 10px 8px;
    border-radius: 18px;
  }

  .composer textarea {
    min-height: 42px;
    max-height: 140px;
    font-size: 16px;
  }

  .attachment-button,
  .voice-button {
    width: 32px;
    height: 32px;
  }

  .municipality-selector {
    max-width: 148px;
    min-height: 32px;
    font-size: 10px;
  }

  .send-button {
    width: 34px;
    height: 34px;
  }

  .composer-caption {
    margin-top: 4px;
    font-size: 9px;
  }

  .storage-warning-trigger {
    min-height: 34px;
    padding-inline: 7px;
  }

  .storage-warning-trigger span:last-child {
    font-size: 9px;
  }

  .account-dialog,
  .login-dialog,
  .image-generation-dialog {
    width: 100vw;
    max-width: none;
    max-height: min(90dvh, calc(var(--dalila-viewport-height, 100dvh) - 18px));
    margin: auto 0 0;
    padding: 24px 18px max(22px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .account-dialog h2 {
    font-size: 20px;
  }

  .account-dialog-close,
  .login-dialog-close {
    top: 12px;
    right: 14px;
  }

  .storage-summary {
    grid-template-columns: 1fr 1fr;
  }

  .storage-file-list {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .storage-file-preview img {
    height: 145px;
  }

  .image-library-toolbar {
    top: -24px;
    margin-top: 12px;
  }

  .image-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    max-height: none;
    overflow: visible;
  }

  .image-collection-card-body,
  .storage-file-body {
    padding: 9px;
  }

  .image-collection-actions,
  .storage-file-actions {
    gap: 8px;
  }

  .image-asset-upload {
    grid-template-columns: 1fr;
    padding: 11px;
  }

  .image-asset-upload label:nth-of-type(1),
  .image-asset-upload input[type="text"],
  .image-asset-upload label:nth-of-type(2),
  .image-asset-upload input[type="file"],
  .image-asset-upload button {
    grid-column: 1;
    grid-row: auto;
  }

  .image-asset-upload button {
    width: 100%;
    margin-top: 2px;
  }
}

@media (max-width: 460px) {
  .topbar-actions {
    gap: 3px;
  }

  .install-pwa-button {
    display: none;
  }

  .storage-warning-trigger span:last-child {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .storage-file-list {
    grid-template-columns: 1fr;
  }

  .storage-file-preview img {
    height: 205px;
  }

  .image-library-toolbar {
    align-items: flex-start;
  }

  .image-library-selection-count {
    width: 100%;
    order: 3;
  }

  .image-library-delete-selected {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-item,
  .history-item,
  .starter-actions button,
  .storage-file-card,
  .image-collection-card,
  .send-button,
  .icon-button,
  .install-pwa-button,
  .account-login-trigger,
  .user-account-trigger,
  .storage-warning-trigger,
  .social-login,
  .image-generation-footer button,
  .image-generation-login,
  .image-asset-upload button {
    transition: none !important;
  }
}


/* Fluidita delle risposte e reveal immagini */
.message-assistant .message-bubble.is-fluid-streaming::after {
  display: inline-block;
  width: 2px;
  height: .9em;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--primary);
  content: "";
  vertical-align: -.08em;
  animation: dalila-writing-caret 680ms steps(1, end) infinite;
}

.message-assistant .message-bubble.is-fluid-streaming .assistant-code-copy {
  pointer-events: none;
  opacity: .45;
}

.generated-image-stage {
  position: relative;
  width: 100%;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 16px;
  background:
    linear-gradient(110deg, transparent 24%, color-mix(in srgb, var(--text) 7%, transparent) 42%, transparent 60%),
    color-mix(in srgb, var(--surface-soft) 78%, var(--surface));
  background-size: 240% 100%, 100% 100%;
}

.generated-image-stage.is-square {
  aspect-ratio: 1 / 1;
}

.generated-image-stage.is-landscape {
  aspect-ratio: 16 / 9;
}

.generated-image-stage.is-portrait {
  aspect-ratio: 4 / 5;
}

.generated-image.is-image-loading .generated-image-stage {
  animation: dalila-image-shimmer 1.1s linear infinite;
}

.generated-image-stage img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  border-radius: 0;
  object-fit: cover;
  opacity: 0;
  filter: blur(14px) saturate(.82);
  transform: scale(1.025);
  transition: opacity 420ms ease, filter 520ms ease, transform 520ms ease;
}

.generated-image.is-image-ready .generated-image-stage {
  min-height: 0;
  animation: none;
  background: var(--surface-soft);
}

.generated-image.is-image-ready .generated-image-stage img {
  height: auto;
  min-height: 0;
  opacity: 1;
  filter: none;
  transform: scale(1);
}

@keyframes dalila-writing-caret {
  0%, 46% { opacity: 1; }
  47%, 100% { opacity: .15; }
}

@keyframes dalila-image-shimmer {
  from { background-position: 145% 0, 0 0; }
  to { background-position: -85% 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .message-assistant .message-bubble.is-fluid-streaming::after {
    animation: none;
  }

  .generated-image.is-image-loading .generated-image-stage {
    animation: none;
  }

  .generated-image-stage img {
    transition: none;
  }
}

/* Email pronta: oggetto e corpo separati, copiabili senza perdere formattazione. */
.assistant-email-card {
  display: grid;
  width: min(100%, 900px);
  gap: 10px;
  margin: 2px 0;
}

.assistant-email-card-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.assistant-email-field {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
}

.assistant-email-field-header {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px 7px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.assistant-email-field-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.assistant-email-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.assistant-email-copy:hover,
.assistant-email-copy:focus-visible {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  outline: none;
}

.assistant-email-copy-icon {
  font-size: 15px;
  line-height: 1;
}

.assistant-email-field pre {
  max-width: 100%;
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  background: transparent;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: normal;
  tab-size: 4;
}

.assistant-email-field code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: inherit;
}

/* Sovrascrive lo stile globale degli inline code dentro i messaggi assistente.
   Il testo della mail deve apparire pulito, senza evidenziazione riga per riga. */
.message-assistant .message-bubble .assistant-email-field code {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.65;
  white-space: inherit;
}

.assistant-email-field-subject pre {
  padding-top: 11px;
  padding-bottom: 11px;
}

.assistant-email-field-subject code {
  font-weight: 650;
}

@media (max-width: 700px) {
  .assistant-email-card {
    width: 100%;
  }

  .assistant-email-field pre {
    padding: 12px;
  }
}

/* Finanza personale: workspace patrimoniale persistente */
.finance-workspace {
  flex: 0 0 auto;
  width: calc(100% - 20px);
  margin: 4px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  overflow: hidden;
}

.finance-workspace[hidden],
.finance-workspace-body[hidden] {
  display: none;
}

.finance-workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.finance-workspace-header h2,
.finance-dialog-header h2 {
  margin: 2px 0 3px;
  font-size: 18px;
  line-height: 1.15;
}

.finance-workspace-header p,
.finance-dialog-header p,
.finance-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.finance-eyebrow {
  display: block;
  color: var(--primary);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.finance-workspace-toggle,
.finance-workspace button,
.finance-portfolio-dialog button,
.finance-management-dialog button {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.finance-workspace-toggle {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 10.5px;
}

.finance-workspace-body {
  max-height: min(72vh, 820px);
  padding: 12px;
  overflow: auto;
}

.finance-loading {
  padding: 24px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.finance-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
}

.finance-empty strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.finance-empty-actions,
.finance-workspace-actions,
.finance-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.finance-empty-actions button,
.finance-workspace-actions button,
.finance-dialog-actions button,
.finance-import-picker button,
.finance-add-position {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 700;
}

.finance-primary-action {
  border-color: color-mix(in srgb, var(--primary) 60%, var(--border)) !important;
  background: color-mix(in srgb, var(--primary) 15%, var(--surface)) !important;
}

.finance-primary-action:disabled {
  opacity: 0.52;
  cursor: wait;
}

.finance-danger-action {
  color: var(--danger, #dc5c5c) !important;
}

.finance-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.finance-metric,
.finance-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.finance-metric {
  min-width: 0;
  padding: 10px 11px;
}

.finance-metric span,
.finance-metric small {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.3;
}

.finance-metric strong {
  display: block;
  margin: 3px 0 2px;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.finance-card {
  padding: 11px;
}

.finance-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}

.finance-card-heading span {
  color: var(--muted);
  font-size: 9.5px;
}

.finance-allocation {
  display: grid;
  gap: 7px;
}

.finance-allocation-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 2fr auto;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
}

.finance-allocation-track {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  overflow: hidden;
}

.finance-allocation-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.finance-sparkline {
  min-height: 58px;
}

.finance-sparkline svg {
  display: block;
  width: 100%;
  height: 58px;
}

.finance-sparkline polyline {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.finance-history {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.finance-history-item {
  min-width: 0;
  padding: 6px 7px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.finance-history-item span,
.finance-history-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-history-item span {
  color: var(--muted);
  font-size: 8.5px;
}

.finance-history-item strong {
  margin-top: 2px;
  font-size: 10px;
}

.finance-position-list {
  display: grid;
  gap: 4px;
  max-height: 145px;
  overflow: auto;
}

.finance-position-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(70px, .8fr) minmax(75px, .8fr) minmax(55px, .6fr);
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  font-size: 10px;
}

.finance-position-row strong,
.finance-position-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-position-row span {
  color: var(--muted);
}

.finance-workspace-actions {
  margin-top: 9px;
}

.finance-portfolio-dialog {
  width: min(1180px, calc(100vw - 28px));
  max-width: 1180px;
  height: min(900px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
}

.finance-portfolio-dialog::backdrop {
  background: rgb(0 0 0 / .55);
  backdrop-filter: blur(4px);
}

.finance-dialog-shell {
  display: flex;
  height: 100%;
  max-height: calc(100dvh - 34px);
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.finance-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.finance-dialog-close {
  display: grid;
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  place-items: center;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text);
  font-size: 24px !important;
  line-height: 1 !important;
}

.finance-dialog-close:hover,
.finance-dialog-close:focus-visible {
  background: transparent !important;
}

.finance-import-picker {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.finance-file-drop {
  display: flex;
  min-height: 64px;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, var(--border));
  border-radius: 13px;
  background: var(--surface-soft);
  cursor: pointer;
}

.finance-file-drop span {
  font-size: 12px;
  font-weight: 750;
}

.finance-file-drop small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
}

.finance-import-status {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10.5px;
}

.finance-import-status.is-error {
  color: var(--danger, #dc5c5c);
}

.finance-review {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin-top: 12px;
  overflow: hidden;
}

.finance-review[hidden] {
  display: none;
}

.finance-review-meta {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px;
  gap: 8px;
  margin-bottom: 8px;
}

.finance-review-meta label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9.5px;
}

.finance-review-meta input,
.finance-review-meta select,
.finance-review-table input,
.finance-review-table select {
  min-height: 32px;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.finance-review-summary-row {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.finance-review-summary {
  color: var(--muted);
  font-size: 10.5px;
}

.finance-refresh-quotes {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 9px !important;
  font-size: 9.5px !important;
}

.finance-review-table-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.finance-review-table {
  width: 100%;
  min-width: 860px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 10px;
}

.finance-review-table th,
.finance-review-table td {
  padding: 5px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.finance-review-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: .02em;
}

.finance-review-table th:nth-child(1),
.finance-review-table td:nth-child(1) { width: 205px; }
.finance-review-table th:nth-child(2),
.finance-review-table td:nth-child(2) { width: 165px; }
.finance-review-table th:nth-child(3),
.finance-review-table td:nth-child(3) { width: 84px; }
.finance-review-table th:nth-child(4),
.finance-review-table td:nth-child(4) { width: 88px; }
.finance-review-table th:nth-child(5),
.finance-review-table td:nth-child(5) { width: 104px; }
.finance-review-table th:nth-child(6),
.finance-review-table td:nth-child(6) { width: 76px; }
.finance-review-table th:nth-child(7),
.finance-review-table td:nth-child(7) { width: 132px; }
.finance-review-table th:nth-child(8),
.finance-review-table td:nth-child(8) { width: 34px; }

.finance-review-table input {
  min-width: 0;
}

.finance-class-combo {
  position: relative;
  display: flex;
  align-items: stretch;
}

.finance-class-combo input {
  padding-right: 30px;
}

.finance-class-toggle {
  position: absolute;
  top: 0;
  right: 3px;
  bottom: 0;
  display: grid;
  width: 22px !important;
  min-width: 22px !important;
  height: auto !important;
  place-items: center;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--muted);
  font-size: 13px !important;
  line-height: 1 !important;
}

.finance-class-toggle:hover,
.finance-class-toggle:focus-visible {
  background: transparent !important;
  color: var(--text);
}

.finance-class-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 8;
  display: grid;
  width: max(160px, 100%);
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(0 0 0 / .28);
}

.finance-class-menu[hidden] {
  display: none;
}

.finance-class-menu button {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  text-align: left;
  font-size: 10px !important;
}

.finance-class-menu button:hover,
.finance-class-menu button:focus-visible {
  background: var(--surface-soft) !important;
}

.finance-review-table .finance-row-remove {
  width: 30px;
  height: 30px;
  padding: 0;
}

.finance-confidence {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.finance-identity-status {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.25;
}

.finance-identity-status.is-loading {
  opacity: .8;
}

.finance-identity-status.is-valid {
  color: var(--success, #3f9f6f);
}

.finance-identity-status.is-error {
  color: var(--danger, #d86666);
}

.finance-quote-status {
  display: block;
  min-height: 10px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
}

.finance-quote-status.is-loading {
  opacity: .82;
}

.finance-quote-status.is-valid {
  color: var(--success, #3f9f6f);
}

.finance-quote-status.is-error {
  color: var(--danger, #d86666);
}

.finance-add-position {
  margin-top: 8px;
}

.finance-draft-warnings {
  margin-top: 8px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

.finance-draft-warnings p {
  margin: 3px 0;
}

.finance-dialog-actions {
  justify-content: flex-end;
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}


/* Finanza personale: pianificazione e monitoraggio patrimoniale */
.finance-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.finance-advisor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.finance-plan-card,
.finance-health-card,
.finance-insights-card,
.finance-monitor-card {
  min-width: 0;
}

.finance-card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.42;
}

.finance-card-action,
.finance-inline-action,
.finance-muted-action {
  min-height: 29px !important;
  padding: 4px 8px !important;
  font-size: 9.5px !important;
}

.finance-plan-card > .finance-card-action,
.finance-insights-card > .finance-card-action {
  margin-top: 9px;
}

.finance-inline-action {
  border: 0 !important;
  background: transparent !important;
  color: var(--primary) !important;
}

.finance-muted-action {
  color: var(--muted) !important;
}

.finance-progress-track,
.finance-health-track {
  display: block;
  height: 6px;
  margin-top: 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  overflow: hidden;
}

.finance-progress-track > span,
.finance-health-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.finance-plan-preview {
  display: grid;
  gap: 5px;
}

.finance-preview-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 7px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  font-size: 9.5px;
}

.finance-preview-row > span {
  min-width: 0;
}

.finance-preview-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-preview-row > span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.finance-preview-row strong,
.finance-preview-row small {
  display: block;
}

.finance-preview-row small {
  color: var(--muted);
  font-size: 8px;
}

.finance-preview-row.is-warning small {
  color: var(--danger, #d86666);
}

.finance-health-overview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.finance-health-overview > strong {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  font-size: 19px;
}

.finance-health-overview span,
.finance-health-overview small {
  display: block;
}

.finance-health-overview span {
  font-size: 11px;
  font-weight: 750;
}

.finance-health-overview small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8.5px;
}

.finance-health-dimensions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.finance-health-dimension > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 8.8px;
}

.finance-health-dimension strong {
  font-size: 8.5px;
}

.finance-health-dimension .finance-health-track {
  height: 4px;
  margin-top: 3px;
}

.finance-insight-list {
  display: grid;
  gap: 6px;
}

.finance-insight-list-full {
  gap: 9px;
}

.finance-insight-item {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.finance-insight-item.severity-critical {
  border-color: color-mix(in srgb, var(--danger, #d86666) 55%, var(--border));
}

.finance-insight-item.severity-warning {
  border-color: color-mix(in srgb, #c99538 48%, var(--border));
}

.finance-insight-heading {
  display: flex;
  align-items: center;
  gap: 7px;
}

.finance-insight-heading span {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 7.5px;
  text-transform: uppercase;
}

.finance-insight-heading strong {
  min-width: 0;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-insight-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.finance-insight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.finance-monitor-card {
  margin-bottom: 8px;
}

.finance-monitor-controls {
  display: grid;
  grid-template-columns: auto minmax(130px, 180px) minmax(190px, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.finance-monitor-controls label,
.finance-monitor-thresholds label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 8.8px;
}

.finance-monitor-controls select,
.finance-monitor-thresholds input,
.finance-management-dialog input,
.finance-management-dialog select,
.finance-management-dialog textarea {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.finance-switch-label {
  display: flex !important;
  min-height: 32px;
  align-items: center;
  gap: 7px !important;
  color: var(--text) !important;
}

.finance-switch-label input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
}

.finance-monitor-thresholds {
  margin-top: 9px;
}

.finance-monitor-thresholds summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
}

.finance-monitor-thresholds > div {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.finance-monitor-detail {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 8.8px;
  line-height: 1.4;
}

.finance-management-dialog {
  width: min(920px, calc(100vw - 28px));
  max-width: 920px;
  height: min(780px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
}

.finance-management-dialog::backdrop {
  background: rgb(0 0 0 / .55);
  backdrop-filter: blur(4px);
}

.finance-management-shell {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.finance-management-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 14px;
  overflow: auto;
  padding-right: 3px;
}

.finance-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.finance-form-grid label {
  display: grid;
  align-content: start;
  gap: 4px;
  color: var(--muted);
  font-size: 9.5px;
}

.finance-form-wide {
  grid-column: 1 / -1;
}

.finance-management-dialog textarea {
  resize: vertical;
}

.finance-form-status {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9.5px;
}

.finance-form-status[hidden] {
  display: none;
}

.finance-form-status.is-error {
  color: var(--danger, #d86666);
}

.finance-goals-manager {
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(0, 1.4fr);
  gap: 12px;
  overflow: hidden;
}

.finance-manager-list,
.finance-goal-form {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.finance-goal-manager-item {
  padding: 9px;
  border-radius: 10px;
  background: var(--surface);
}

.finance-goal-manager-item + .finance-goal-manager-item {
  margin-top: 7px;
}

.finance-goal-manager-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.finance-goal-manager-heading strong {
  min-width: 0;
  overflow: hidden;
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-goal-manager-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 8px;
}

.finance-goal-manager-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 8.8px;
  line-height: 1.35;
}

.finance-goal-manager-actions {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

.finance-goal-form > .finance-primary-action {
  margin-top: 10px;
}

.finance-target-head,
.finance-target-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 110px 110px 34px;
  gap: 7px;
  align-items: center;
}

.finance-target-head {
  padding: 0 4px 5px;
  color: var(--muted);
  font-size: 8.5px;
}

.finance-target-rows {
  display: grid;
  gap: 6px;
}

.finance-target-row .finance-row-remove {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.finance-target-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.finance-target-toolbar strong {
  font-size: 10px;
}

.finance-target-toolbar .is-invalid {
  color: var(--danger, #d86666);
}


@media (max-width: 760px) {
  .finance-plan-grid,
  .finance-advisor-grid {
    grid-template-columns: 1fr;
  }

  .finance-monitor-controls,
  .finance-monitor-thresholds > div {
    grid-template-columns: 1fr;
  }

  .finance-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .finance-goals-manager {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .finance-manager-list,
  .finance-goal-form {
    overflow: visible;
  }

  .finance-target-head,
  .finance-target-row {
    grid-template-columns: minmax(120px, 1fr) 82px 82px 32px;
  }

  .finance-management-dialog {
    width: calc(100vw - 14px);
    height: calc(100dvh - 14px);
    max-height: calc(100dvh - 14px);
  }

  .finance-management-shell {
    padding: 12px;
  }

  .finance-workspace {
    width: calc(100% - 12px);
    margin: 2px 6px 8px;
    border-radius: 16px;
  }

  .finance-workspace-header {
    padding: 11px 12px 10px;
  }

  .finance-workspace-header h2 {
    font-size: 16px;
  }

  .finance-workspace-body {
    max-height: 64vh;
    padding: 8px;
  }

  .finance-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .finance-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .finance-position-row {
    grid-template-columns: minmax(0, 1.7fr) minmax(70px, .8fr) minmax(55px, .6fr);
  }

  .finance-position-row span:nth-child(3) {
    display: none;
  }

  .finance-empty {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-import-picker,
  .finance-review-meta {
    grid-template-columns: 1fr;
  }

  .finance-dialog-shell {
    padding: 12px;
  }

  .finance-portfolio-dialog {
    width: calc(100vw - 14px);
    height: calc(100dvh - 14px);
    max-height: calc(100dvh - 14px);
  }

  .finance-review-summary-row {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-form-grid {
    grid-template-columns: 1fr;
  }

  .finance-health-dimensions {
    grid-template-columns: 1fr;
  }

  .finance-target-head {
    display: none;
  }

  .finance-target-row {
    grid-template-columns: minmax(0, 1fr) 70px 70px 32px;
  }
}

/* Landing compatta su viewport bassi - 24/08/2026 */
/* Il messaggio di benvenuto storico resta nella conversazione, ma non deve
   occupare spazio mentre e' visibile la home iniziale. */
.conversation:not(.has-messages) .message-list {
  display: none;
}

@media (min-width: 761px) and (max-height: 760px) {
  .topbar {
    min-height: 58px;
    padding: 9px 18px;
  }

  .registration-banner {
    min-height: 30px;
    padding: 4px 16px;
    font-size: 9.5px;
  }

  .laboratorio-content {
    padding: 8px 24px 10px;
  }

  .conversation:not(.has-messages) {
    justify-content: center;
    padding-top: 0;
  }

  .conversation:not(.has-messages) .demo-intro {
    margin-bottom: 8px;
    padding-top: 0;
  }

  .conversation:not(.has-messages) .demo-intro-mark {
    width: 42px;
    height: 42px;
    margin-bottom: 8px;
    border-radius: 13px;
  }

  .conversation:not(.has-messages) .demo-intro-mark img {
    width: 27px;
    height: 27px;
  }

  .conversation:not(.has-messages) .demo-intro h1 {
    margin-bottom: 4px;
    font-size: 28px;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-lead {
    max-width: 760px;
    font-size: 12.5px;
    line-height: 1.35;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-account {
    margin-top: 5px;
    padding: 3px 7px;
    font-size: 9px;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-context {
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.3;
  }

  .conversation:not(.has-messages) .starter-actions {
    gap: 7px;
    margin-top: 9px;
  }

  .conversation:not(.has-messages) .starter-actions button {
    min-height: 58px;
    gap: 5px;
    padding: 8px 10px;
  }

  .conversation:not(.has-messages) .quick-icon {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .conversation:not(.has-messages) .composer {
    gap: 4px;
    padding: 8px 10px 7px;
    border-radius: 17px;
  }

  .conversation:not(.has-messages) .composer textarea {
    min-height: 36px;
    padding-top: 3px;
    padding-bottom: 3px;
    font-size: 14px;
  }

  .conversation:not(.has-messages) .composer-toolbar {
    min-height: 30px;
  }

  .conversation:not(.has-messages) .attachment-button,
  .conversation:not(.has-messages) .voice-button {
    width: 30px;
    height: 30px;
  }

  .conversation:not(.has-messages) .municipality-selector {
    min-height: 30px;
  }

  .conversation:not(.has-messages) .send-button {
    width: 32px;
    height: 32px;
  }

  .conversation:not(.has-messages) .composer-caption {
    margin-top: 4px;
    font-size: 8.8px;
    line-height: 1.2;
  }
}

@media (min-width: 761px) and (max-height: 660px) {
  .topbar {
    min-height: 52px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .registration-banner {
    min-height: 26px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .laboratorio-content {
    padding-top: 5px;
    padding-bottom: 6px;
  }

  .conversation:not(.has-messages) .demo-intro {
    margin-bottom: 5px;
  }

  .conversation:not(.has-messages) .demo-intro-mark {
    width: 34px;
    height: 34px;
    margin-bottom: 5px;
    border-radius: 11px;
  }

  .conversation:not(.has-messages) .demo-intro-mark img {
    width: 22px;
    height: 22px;
  }

  .conversation:not(.has-messages) .demo-intro h1 {
    margin-bottom: 3px;
    font-size: 24px;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-lead {
    font-size: 11.5px;
    line-height: 1.25;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-account {
    margin-top: 3px;
    padding-block: 2px;
  }

  .conversation:not(.has-messages) .demo-intro .demo-intro-context {
    margin-top: 3px;
    font-size: 9.5px;
    line-height: 1.2;
  }

  .conversation:not(.has-messages) .starter-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .conversation:not(.has-messages) .starter-actions button {
    min-height: 50px;
    gap: 4px;
    padding-block: 6px;
    font-size: 10px;
  }

  .conversation:not(.has-messages) .quick-icon {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .conversation:not(.has-messages) .composer textarea {
    min-height: 32px;
  }

  .conversation:not(.has-messages) .composer-caption {
    margin-top: 3px;
    font-size: 8px;
  }
}

/* Nuova chat centrata - 24/08/2026 */
@media (min-width: 761px) {
  .conversation:not(.has-messages) {
    justify-content: center;
    padding-top: 0;
  }

  .conversation:not(.has-messages) .demo-intro {
    flex: 0 0 auto;
  }

  .conversation:not(.has-messages) .composer {
    flex: 0 0 auto;
    width: 100%;
  }

  .conversation:not(.has-messages) .composer-caption {
    flex: 0 0 auto;
  }
}


/* Home iniziale pulita - 24/08/2026 */
/* Le azioni rapide vivono sotto il composer e restano su una sola riga. */
.conversation.has-messages > .starter-actions {
  display: none;
}

.conversation:not(.has-messages) > .starter-actions {
  display: flex;
  width: 100%;
  max-width: 900px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px auto 0;
  padding: 0 2px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.conversation:not(.has-messages) > .starter-actions::-webkit-scrollbar {
  display: none;
}

.conversation:not(.has-messages) > .starter-actions button {
  min-width: max-content;
  min-height: 34px;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  box-shadow: none;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.conversation:not(.has-messages) > .starter-actions button:hover,
.conversation:not(.has-messages) > .starter-actions button:focus-visible {
  transform: none;
  box-shadow: none;
}

.conversation:not(.has-messages) > .starter-actions .quick-icon {
  display: inline-grid;
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  place-items: center;
  border-radius: 7px;
  font-size: 12px;
}

.composer-login-hint {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.composer-login-hint:hover,
.composer-login-hint:focus-visible {
  text-decoration: underline;
  outline: 0;
}

@media (min-width: 761px) and (max-height: 760px) {
  .conversation:not(.has-messages) > .starter-actions {
    gap: 6px;
    margin-top: 7px;
  }

  .conversation:not(.has-messages) > .starter-actions button {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10px;
  }

  .conversation:not(.has-messages) > .starter-actions .quick-icon {
    width: 19px;
    height: 19px;
    flex-basis: 19px;
    font-size: 11px;
  }
}

@media (max-width: 760px) {
  .conversation:not(.has-messages) > .starter-actions {
    justify-content: flex-start;
    margin-top: 8px;
    padding-inline: 2px;
  }

  .conversation:not(.has-messages) > .starter-actions button {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 10.5px;
  }

  .composer-caption .composer-login-hint {
    display: inline;
  }
}


/* Logo sidebar compatto basato sulla larghezza reale, non solo sullo stato salvato. */
.sidebar.sidebar-visual-compact .brand {
  justify-content: center;
}

.sidebar.sidebar-visual-compact .brand-image-full {
  display: none !important;
}

.sidebar.sidebar-visual-compact .brand-image-symbol.brand-dark {
  display: block !important;
}

:root[data-theme="light"] .sidebar.sidebar-visual-compact .brand-image-symbol.brand-dark {
  display: none !important;
}

:root[data-theme="light"] .sidebar.sidebar-visual-compact .brand-image-symbol.brand-light {
  display: block !important;
}

/* Progetti */
.new-project {
  min-height: 40px;
  margin-top: -3px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 400;
}

.new-project svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.project-history-group {
  display: grid;
  gap: 3px;
  margin: 0 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

.project-history-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 6px 7px 4px 9px;
}

.project-history-heading > svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.project-history-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--text);
  font-size: 10.5px;
  font-weight: 760;
  letter-spacing: .015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-history-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.project-history-actions button {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.project-history-actions button:hover,
.project-history-actions button:focus-visible {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--primary);
  outline: 0;
}

.project-history-actions svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.project-history-empty {
  padding: 5px 10px 7px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.45;
}

.project-history-more {
  justify-self: start;
  margin: 2px 10px 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
}

.project-history-more:hover,
.project-history-more:focus-visible {
  color: var(--primary);
  outline: 0;
}

.project-dialog {
  width: min(94vw, 640px);
}

.project-dialog form {
  display: grid;
  gap: 10px;
}

.project-dialog label {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.project-dialog input[type="text"],
.project-dialog textarea,
.project-dialog select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
}

.project-dialog input[type="text"],
.project-dialog select {
  min-height: 42px;
  padding: 0 12px;
}

.project-dialog textarea {
  min-height: 210px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.project-dialog input:focus,
.project-dialog textarea:focus,
.project-dialog select:focus {
  border-color: var(--primary);
}

.project-dialog small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.project-instructions-label,
.project-instructions-tools,
.project-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-voice-button,
.project-instructions-tools button,
.project-dialog-actions button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
}

.project-voice-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.project-voice-button.is-recording {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  color: var(--danger);
}

.project-instructions-tools > span {
  color: var(--muted);
  font-size: 9.5px;
}

.project-instructions-tools > div {
  display: flex;
  gap: 6px;
}

.project-instructions-tools button:hover,
.project-instructions-tools button:focus-visible,
.project-dialog-actions button:hover,
.project-dialog-actions button:focus-visible,
.project-voice-button:hover,
.project-voice-button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary);
  outline: 0;
}

.project-dialog-actions {
  margin-top: 3px;
}

.project-dialog-actions [data-project-save],
.project-dialog-actions .project-delete-confirm {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

/*
 * Fix: la regola generica ".project-dialog-actions button:hover" (piu'
 * specifica perche' combina classe + selettore di tipo "button") vinceva su
 * questa e riportava il testo a var(--primary), cioe' blu su sfondo blu con
 * tema chiaro. Qui alziamo la specificita' (classe + attributo/classe +
 * pseudo-classe) cosi' il pulsante "Salva modifiche" e la conferma di
 * eliminazione restano leggibili anche in hover/focus.
 */
.project-dialog-actions [data-project-save]:hover,
.project-dialog-actions [data-project-save]:focus-visible,
.project-dialog-actions .project-delete-confirm:hover,
.project-dialog-actions .project-delete-confirm:focus-visible {
  color: #fff;
  border-color: transparent;
}

.project-dialog-actions .project-delete-button,
.project-dialog-actions .project-delete-confirm {
  color: #fff;
}

.project-dialog-actions .project-delete-button {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-soft));
  color: var(--danger);
}

.project-dialog-actions button:disabled,
.project-instructions-tools button:disabled,
.project-voice-button:disabled {
  cursor: wait;
  opacity: .58;
}

.project-status {
  min-height: 18px;
  margin: 0 !important;
  font-size: 11px !important;
}

.project-status.is-error {
  color: var(--danger) !important;
}

.project-delete-dialog {
  width: min(92vw, 520px);
}

.project-delete-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.project-delete-choice input {
  margin-top: 3px;
}

.project-delete-choice span {
  display: grid;
  gap: 4px;
}

.project-delete-choice strong {
  color: var(--text);
  font-size: 12px;
}

.project-delete-choice small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .project-dialog {
    padding: 22px 18px;
  }

  .project-dialog textarea {
    min-height: 180px;
  }

  .project-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .project-dialog-actions > span {
    display: none;
  }

  .project-dialog-actions button {
    width: 100%;
  }

  .project-dialog-actions .project-delete-button {
    grid-column: 1 / -1;
  }
}


@media (max-width: 640px) {
  .project-composer-tag {
    max-width: 92px;
  }
}

/* Condivisione progetti */

.project-collaborator-note {
  color: var(--muted);
  font-size: 10.5px;
  text-align: right;
}

.project-share-dialog,
.project-redeem-dialog {
  width: min(92vw, 560px);
}

.project-share-dialog h3 {
  margin: 16px 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.project-share-code-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.project-share-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--muted);
}

.project-share-code.is-active {
  color: var(--primary);
}

.project-share-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-share-code-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

.project-share-code-actions button:hover,
.project-share-code-actions button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary);
  outline: 0;
}

.project-share-code-actions .project-delete-button {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-soft));
  color: var(--danger);
}

.project-share-code-block small {
  color: var(--muted);
  font-size: 10.5px;
}

.project-share-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.project-share-empty {
  color: var(--muted);
  font-size: 11px;
}

.project-share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.project-share-row-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.project-share-row-info strong {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-share-row-info small {
  color: var(--muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-share-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.project-share-row-actions select,
.project-share-row-actions button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
}

.project-share-row-actions .project-delete-button {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-soft));
  color: var(--danger);
}

.history-author-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  vertical-align: middle;
}

.project-history-owner-tag {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.conversation-read-only-banner {
  margin: 0 0 10px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 760px) {
  .project-share-row {
    flex-direction: column;
    align-items: stretch;
  }

  .project-share-row-actions {
    justify-content: flex-start;
  }
}

/* Progetti, rifinitura UI 26/08/2026 */

/* L'invito resta collegato a Nuovo progetto ma con gerarchia da voce figlia. */
.new-project-redeem {
  position: relative;
  min-height: 24px;
  margin-top: -9px;
  padding: 0 10px 0 48px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 10.25px;
  font-weight: 500;
  opacity: .9;
}

.new-project-redeem::before {
  position: absolute;
  left: 21.5px;
  top: -7px;
  width: 19.5px;
  height: 19px;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  border-bottom-left-radius: 6px;
  content: "";
  pointer-events: none;
}

.new-project-redeem svg {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.new-project-redeem:hover,
.new-project-redeem:focus-visible {
  border-color: transparent;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  color: var(--text);
  transform: none;
}

/* I controlli di modifica esistono solo nel progetto gia' salvato. */
.project-dialog [hidden],
.project-redeem-dialog [hidden] {
  display: none !important;
}

.project-dialog-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.project-edit-actions {
  display: grid;
  min-width: 0;
  gap: 12px;
  align-self: stretch;
}

.project-share-action {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.project-edit-actions .project-share-button {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 650;
}

.project-edit-actions .project-share-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.project-edit-actions .project-share-button:hover,
.project-edit-actions .project-share-button:focus-visible {
  background: var(--surface-soft);
  color: var(--primary);
  outline: 0;
}

.project-edit-actions .project-collaborator-note {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-danger-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: auto;
}

.project-danger-actions .project-delete-button {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--border));
  border-radius: 7px;
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  color: color-mix(in srgb, var(--danger) 88%, var(--text));
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  font-weight: 650;
}

.project-danger-actions .project-delete-button:hover,
.project-danger-actions .project-delete-button:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  outline: 0;
}

.project-dialog-primary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin: 0;
}

.project-dialog-primary-actions button {
  min-width: 76px;
}

/* Finestra codice invito, allineata ai controlli del progetto. */
.project-redeem-dialog {
  width: min(92vw, 460px);
}

.project-redeem-dialog > p {
  margin-bottom: 16px;
}

.project-redeem-form {
  display: grid;
  gap: 9px;
}

.project-redeem-form label {
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
}

.project-redeem-form input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.project-redeem-form input[type="text"]::placeholder {
  color: var(--muted);
  font-family: inherit;
  font-weight: 500;
  letter-spacing: .04em;
  opacity: .72;
}

.project-redeem-form input[type="text"]:focus {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}

.project-redeem-actions {
  justify-content: flex-end;
  gap: 7px;
  margin-top: 1px;
}

.project-redeem-actions [data-project-redeem-submit] {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.project-redeem-actions [data-project-redeem-submit]:hover,
.project-redeem-actions [data-project-redeem-submit]:focus-visible {
  border-color: transparent;
  color: #fff;
}

@media (max-width: 760px) {
  .project-dialog-footer {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .project-edit-actions {
    gap: 9px;
  }

  .project-share-action {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .project-edit-actions .project-collaborator-note {
    max-width: 100%;
    white-space: normal;
  }

  .project-dialog-primary-actions {
    display: flex;
    justify-content: flex-end;
  }

  .project-dialog-primary-actions button {
    width: auto;
  }

  .project-redeem-actions {
    display: flex;
    justify-content: flex-end;
  }

  .project-redeem-actions button {
    width: auto;
  }
}

.sidebar-is-collapsed .new-project-redeem,
.sidebar.sidebar-visual-compact .new-project-redeem {
  display: none;
}

/* Progetti, ramo comprimibile della sidebar 26/08/2026 */
.new-project-tree {
  position: relative;
  width: 100%;
}

.new-project-root-row {
  position: relative;
  width: 100%;
}

.new-project-root-row .new-project {
  padding-right: 39px;
}

.new-project-tree-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.new-project-tree-toggle-control {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: 8px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color 150ms ease, color 150ms ease;
}

.new-project-tree-toggle-control:hover {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  color: var(--text);
}

.new-project-tree-toggle:focus-visible + .new-project-root-row .new-project-tree-toggle-control {
  box-shadow: var(--focus-ring);
}

.new-project-tree-toggle-control svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 150ms ease;
}

.new-project-tree-toggle:not(:checked) + .new-project-root-row .new-project-tree-toggle-control svg {
  transform: rotate(-90deg);
}

.new-project-tree-toggle:not(:checked) ~ .new-project-tree-children {
  display: none;
}

.new-project-tree-children {
  width: 100%;
}

.sidebar-is-collapsed .new-project-tree-toggle-control,
.sidebar.sidebar-visual-compact .new-project-tree-toggle-control {
  display: none;
}

.sidebar-is-collapsed .new-project-root-row .new-project,
.sidebar.sidebar-visual-compact .new-project-root-row .new-project {
  padding-right: 0;
}

/* ==========================================================================
   Fonti di progetto
   ========================================================================== */

/* Nelle chat di progetto vuote le azioni rapide generiche lasciano spazio
   al selettore Chat / Fonti. Le chat generiche restano invariate. */
.conversation:not(.has-messages).is-project-chat > .starter-actions {
  display: none;
}

.project-tabs {
  display: flex;
  width: fit-content;
  max-width: calc(100% - 20px);
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin: 10px auto 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 24px color-mix(in srgb, #000 6%, transparent);
}

.project-tabs[hidden] {
  display: none;
}

.project-tab {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  transition: background .16s ease, color .16s ease;
}

.project-tab:hover,
.project-tab:focus-visible {
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: var(--text);
  outline: 0;
}

.project-tab.is-active {
  background: var(--surface-soft);
  color: var(--text);
}

.project-tab-count {
  display: inline-flex;
  min-width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
}

.project-tab-count[hidden] {
  display: none;
}

/* La vista Fonti occupa l'area della chat. Il selettore rimane in basso,
   nello stesso punto in cui si trova sotto il composer nella chat vuota. */
.conversation.showing-sources {
  width: 100%;
  max-width: none;
}

.conversation.showing-sources > *:not(.project-tabs):not(.project-sources-view) {
  display: none !important;
}

.conversation.showing-sources .project-tabs {
  margin-top: 8px;
  margin-bottom: 8px;
}

.project-sources-view {
  display: none;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 18px;
  margin: 0;
  padding: 24px 28px 12px;
  overflow: auto;
}

.conversation.showing-sources .project-sources-view {
  display: flex;
}

.project-sources-view[hidden] {
  display: none;
}

.project-sources-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 2px;
}

.project-sources-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.project-sources-header h2 {
  margin: 3px 0 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.project-sources-header p {
  max-width: 920px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.project-sources-usage {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.project-sources-add-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
}

.project-source-option {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 28px color-mix(in srgb, #000 4%, transparent);
}

.project-source-option-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.project-source-option-heading > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.project-source-option-heading strong {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.2;
}

.project-source-option-heading small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.project-source-option-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-soft));
  color: var(--primary);
}

.project-source-option-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-sources-choice {
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-sources-choice span {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.project-sources-dropzone {
  display: flex;
  min-height: 168px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 22%, var(--border));
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color .16s ease, background .16s ease;
}

.project-sources-dropzone:hover,
.project-sources-dropzone:focus-visible,
.project-sources-dropzone.is-dragover {
  border-color: color-mix(in srgb, var(--primary) 68%, var(--border));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-soft));
  outline: 0;
}

.project-sources-dropzone > svg {
  width: 25px;
  height: 25px;
  margin-bottom: 2px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-sources-dropzone strong {
  color: var(--text);
  font-size: 13px;
}

.project-sources-dropzone > span {
  font-size: 10.5px;
}

.project-sources-dropzone button {
  min-height: 31px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
}

.project-sources-dropzone small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.project-sources-text-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-sources-text-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

.project-sources-text-form input,
.project-sources-text-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.project-sources-text-form textarea {
  min-height: 88px;
  resize: vertical;
}

.project-sources-text-form input:focus,
.project-sources-text-form textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}

.project-sources-text-form button {
  align-self: flex-end;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
}

.project-sources-text-form button:hover,
.project-sources-text-form button:focus-visible {
  border-color: var(--primary);
  outline: 0;
}

.project-sources-text-form button:disabled {
  cursor: wait;
  opacity: .55;
}

.project-sources-status {
  min-height: 14px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.project-sources-status:empty {
  display: none;
}

.project-sources-status.is-error {
  color: var(--danger);
}

.project-sources-library {
  min-height: 160px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.project-sources-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 56%, var(--surface));
}

.project-sources-library-heading > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-sources-library-heading strong {
  color: var(--text);
  font-size: 12.5px;
}

.project-sources-library-heading span {
  color: var(--muted);
  font-size: 10.5px;
}

.project-sources-table-wrap {
  overflow: auto;
}

.project-sources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.project-sources-table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.project-sources-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.project-sources-table tr:last-child td {
  border-bottom: none;
}

.project-source-name {
  display: flex;
  max-width: 360px;
  flex-direction: column;
  gap: 2px;
}

.project-source-name strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-source-name small {
  color: var(--danger);
  font-size: 10px;
}

.project-source-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.project-source-status.is-indexed {
  background: var(--success-bg);
  color: var(--success);
}

.project-source-status.is-processing,
.project-source-status.is-pending {
  background: var(--surface-soft);
  color: var(--muted);
}

.project-source-status.is-failed {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

.project-source-delete {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}

.project-source-delete:hover,
.project-source-delete:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
  outline: 0;
}

.project-source-delete svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.project-sources-empty {
  padding: 30px 14px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

.project-sources-empty[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .project-sources-view {
    padding-inline: 18px;
  }

  .project-sources-add-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .project-sources-choice {
    height: 22px;
  }
}

@media (max-width: 760px) {
  .project-sources-view {
    gap: 14px;
    padding: 16px 10px 8px;
  }

  .project-sources-header {
    flex-direction: column;
    gap: 10px;
  }

  .project-sources-usage {
    margin-top: 0;
  }

  .project-source-option {
    padding: 13px;
    border-radius: 15px;
  }

  .project-sources-dropzone {
    min-height: 145px;
  }

  .project-source-name {
    max-width: 46vw;
  }

  .project-sources-table th,
  .project-sources-table td {
    padding-inline: 9px;
  }
}

/* Project chat empty state: keep only the project heading. */
.conversation.is-project-chat .demo-intro .demo-intro-lead {
  display: none;
}

.conversation.is-project-chat .demo-intro h1 {
  margin-bottom: 0;
}

/* Project sources: use one vertical scroll only, the Fonti view itself.
   The library expands to all rows, avoiding the nested scrollbar that clipped sources. */
.project-sources-library {
  flex: 0 0 auto;
}

.project-sources-table-wrap {
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
}

.project-sources-table thead th {
  position: static;
}

/* Compact rows: keep more project sources visible without wasting vertical space. */
.project-sources-table th {
  padding-top: 6px;
  padding-bottom: 6px;
}

.project-sources-table td {
  padding-top: 6px;
  padding-bottom: 6px;
}

.project-source-delete {
  width: 24px;
  height: 24px;
  border-radius: 8px;
}

.project-source-delete svg {
  width: 12px;
  height: 12px;
}

.project-source-status {
  padding: 2px 7px;
}


/* UX condivisione progetti, 26/08/2026 */
.project-approval-trigger {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, #f59e0b 45%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, #f59e0b 9%, var(--surface));
  color: color-mix(in srgb, #f59e0b 82%, var(--text));
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.project-approval-trigger[hidden] { display: none !important; }
.project-approval-trigger:hover,
.project-approval-trigger:focus-visible {
  border-color: color-mix(in srgb, #f59e0b 72%, var(--border));
  background: color-mix(in srgb, #f59e0b 14%, var(--surface));
  outline: 0;
}
.project-approval-trigger svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.project-approval-count {
  display: grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: #f59e0b;
  color: #111827;
  font-size: 8.5px;
  font-weight: 850;
}
.project-approval-count[hidden] { display: none !important; }

.project-share-dialog .project-status,
.project-redeem-dialog .project-status {
  display: none;
  min-height: 0;
  margin: 8px 0 10px !important;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-soft));
  color: var(--text);
  font-size: 10.5px !important;
  font-weight: 600;
  line-height: 1.4;
}
.project-share-dialog .project-status.has-message,
.project-redeem-dialog .project-status.has-message { display: block; }
.project-share-dialog .project-status.is-success,
.project-redeem-dialog .project-status.is-success {
  border-color: color-mix(in srgb, #22c55e 42%, var(--border));
  background: color-mix(in srgb, #22c55e 9%, var(--surface-soft));
  color: color-mix(in srgb, #22c55e 78%, var(--text));
}
.project-share-dialog .project-status.is-error,
.project-redeem-dialog .project-status.is-error {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface-soft));
  color: var(--danger) !important;
}
.project-share-row.is-pending {
  border-color: color-mix(in srgb, #f59e0b 28%, var(--border));
  background: color-mix(in srgb, #f59e0b 5%, var(--surface-soft));
}

.history-item small {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.history-author-badge {
  --history-author-color: hsl(var(--history-author-hue, 210) 66% 43%);
  display: inline-flex;
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  margin-left: 1px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--history-author-color) 34%, var(--border));
  border-radius: 4px;
  background: color-mix(in srgb, var(--history-author-color) 11%, var(--surface-soft));
  color: var(--history-author-color);
  font-size: 0;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  vertical-align: middle;
}

:root:not([data-theme="light"]) .history-author-badge {
  --history-author-color: hsl(var(--history-author-hue, 210) 72% 72%);
}

.history-author-badge > .history-author-initial {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 7.25px;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
}

@media (max-width: 760px) {
  .project-approval-trigger {
    position: relative;
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  .project-approval-trigger > span[data-project-approval-label] { display: none; }
  .project-approval-count {
    position: absolute;
    top: -5px;
    right: -5px;
  }
}

/* PWA install: il controllo deve restare disponibile anche sugli smartphone. */
@media (max-width: 460px) {
  .install-pwa-button:not([hidden]) {
    display: inline-flex;
  }
}

/* Sidebar, sezioni Progetti e Chat Generali comprimibili 27/08/2026 */
.history-section {
  display: grid;
  min-width: 0;
  gap: 3px;
  margin: 0 0 9px;
}

.history-section + .history-section,
.history-section + .history-group,
.history-group + .history-section {
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

.history-section-toggle {
  display: flex;
  width: 100%;
  min-height: 29px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 9.5px;
  font-weight: 760;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
  transition: background-color 140ms ease, color 140ms ease;
}

.history-section-toggle:hover,
.history-section-toggle:focus-visible {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  color: var(--text);
  outline: 0;
}

.history-section-toggle:focus-visible {
  box-shadow: var(--focus-ring);
}

.history-section-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.history-section-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-section-chevron {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  transition: transform 150ms ease;
}

.history-section.is-collapsed .history-section-chevron {
  transform: rotate(-90deg);
}

.history-section-body {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.history-section-body[hidden] {
  display: none !important;
}

.sidebar-history > strong {
  display: none;
}

/* Sidebar: separazione pulita tra Progetti e Chat Generali 27/08/2026 */
.history-section[data-history-section="projects"] .project-history-group:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.history-section[data-history-section="projects"] + .history-section[data-history-section="general"] {
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

/* Report composer and reusable document templates */
.prompt-improve-row { display:flex; justify-content:flex-end; margin-top:.45rem; }
.secondary-action,.report-template-link { border:0; background:transparent; color:var(--accent,#2563eb); font:inherit; font-size:.88rem; cursor:pointer; padding:.35rem .2rem; }
.secondary-action:disabled { opacity:.45; cursor:default; }
.report-generation-dialog { width:min(720px,calc(100vw - 28px)); }
.report-generation-dialog textarea { min-height:150px; resize:vertical; }
.report-option-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; margin-top:14px; }
.report-option-grid label { display:grid; gap:7px; }
.report-option-grid select,.document-template-upload input[type="text"],.document-template-upload input[type="file"] { width:100%; }
.report-research-option { display:flex!important; align-items:center; gap:9px; margin-top:15px; }
.report-research-option input { width:auto!important; }
.report-template-link { display:block; margin-top:6px; }
.report-generation-actions { display:flex; justify-content:center; margin-top:18px; }
.report-generation-actions button { min-width:190px; }
.document-templates-dialog { width:min(760px,calc(100vw - 28px)); }
.document-template-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; max-height:420px; overflow:auto; padding:2px 3px 6px 0; margin:18px 0; }
.document-template-card { display:grid; grid-template-columns:92px minmax(0,1fr); gap:12px; border:1px solid var(--border-color,rgba(127,127,127,.22)); border-radius:13px; padding:10px; background:var(--panel-bg,rgba(127,127,127,.06)); }
.document-template-card>img { width:92px; aspect-ratio:210/297; object-fit:cover; border-radius:7px; border:1px solid var(--border-color,rgba(127,127,127,.2)); background:#fff; }
.document-template-card-body { min-width:0; display:flex; flex-direction:column; gap:4px; }
.document-template-card-body strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.document-template-card-body small { opacity:.72; }
.document-template-card-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:auto; padding-top:8px; }
.document-template-card-actions button { font-size:.78rem; padding:.38rem .55rem; }
.document-template-card-actions .is-danger { color:#b42318; }
.document-template-empty { grid-column:1/-1; text-align:center; opacity:.7; padding:24px 10px; }
.document-template-upload { border-top:1px solid var(--border-color,rgba(127,127,127,.2)); padding-top:16px; }
.document-template-upload h3 { margin:0 0 12px; }
.document-template-upload>label:not(.report-research-option) { display:grid; gap:6px; margin-bottom:10px; }
.document-template-upload small { display:block; opacity:.7; margin:8px 0 12px; }
@media (max-width:620px) { .report-option-grid,.document-template-list { grid-template-columns:1fr; } .document-template-card { grid-template-columns:76px minmax(0,1fr); } .document-template-card>img { width:76px; } }
.template-margin-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin:12px 0; }
.template-margin-grid>span { grid-column:1/-1; font-size:.86rem; opacity:.72; }
.template-margin-grid label { display:grid; gap:5px; font-size:.8rem; }
.template-margin-grid input { width:100%; }
@media(max-width:620px){.template-margin-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}

/* Report generator + report templates UX refinement v24 */
.report-generation-dialog,
.document-templates-dialog {
  max-height: min(88dvh, 860px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.report-generation-dialog form,
.document-template-upload {
  display: grid;
  gap: 14px;
}

.report-generation-dialog form > label,
.document-template-upload > label:not(.report-research-option),
.report-option-grid label,
.template-margin-grid label {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.report-generation-dialog textarea,
.report-generation-dialog select,
.document-template-upload input[type="text"],
.document-template-upload input[type="number"],
.document-template-upload input[type="file"] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.report-generation-dialog textarea {
  display: block;
  min-height: 156px;
  padding: 13px 14px;
  line-height: 1.55;
  resize: vertical;
}

.report-generation-dialog select,
.document-template-upload input[type="text"],
.document-template-upload input[type="number"] {
  min-height: 42px;
  padding: 9px 11px;
}

.report-generation-dialog textarea:focus,
.report-generation-dialog select:focus,
.document-template-upload input[type="text"]:focus,
.document-template-upload input[type="number"]:focus,
.document-template-upload input[type="file"]:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.report-generation-dialog textarea::placeholder,
.document-template-upload input::placeholder {
  color: var(--muted);
  opacity: .82;
}

.prompt-improve-row {
  min-height: 32px;
  align-items: center;
}

.secondary-action,
.report-template-link {
  border-radius: 9px;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.secondary-action:not(:disabled):hover,
.secondary-action:not(:disabled):focus-visible,
.report-template-link:hover,
.report-template-link:focus-visible {
  background: var(--surface-soft);
  outline: 0;
}

.report-option-grid {
  padding-top: 2px;
}

.report-option-grid label {
  align-content: start;
}

.report-research-option {
  width: fit-content;
  min-height: 34px;
  margin-top: 2px;
  padding: 7px 9px;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.report-research-option:hover {
  background: var(--surface-soft);
}

.report-research-option input[type="checkbox"] {
  width: 16px !important;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.report-generation-actions {
  padding-top: 4px;
}

.report-generation-actions button,
.document-template-upload > button[type="submit"] {
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 780;
  box-shadow: 0 7px 18px rgba(0, 0, 0, .12);
  transition: transform 120ms ease, opacity 120ms ease, filter 120ms ease;
}

.report-generation-actions button:hover,
.document-template-upload > button[type="submit"]:hover {
  filter: brightness(1.05);
}

.report-generation-actions button:active,
.document-template-upload > button[type="submit"]:active {
  transform: translateY(1px);
}

.report-generation-actions button:disabled,
.document-template-upload > button[type="submit"]:disabled {
  cursor: wait;
  opacity: .58;
}

.document-templates-dialog > p:first-of-type {
  margin-bottom: 8px;
}

.document-template-list {
  margin: 8px 0 2px;
  padding: 4px 4px 8px 0;
}

.document-template-empty {
  margin: 8px 0 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
}

.document-template-upload {
  margin-top: 10px;
  padding-top: 22px;
}

.document-template-upload h3 {
  font-size: 17px;
}

.document-template-upload input[type="file"] {
  min-height: 44px;
  padding: 6px;
}

.document-template-upload input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.template-margin-grid {
  margin: 2px 0 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.template-margin-grid > span {
  color: var(--muted);
  font-weight: 700;
}

.document-template-upload > button[type="submit"] {
  justify-self: center;
  min-width: 180px;
  margin-top: 2px;
}

.document-template-card-actions button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.document-template-card-actions button:hover,
.document-template-card-actions button:focus-visible {
  background: var(--surface-soft);
  outline: 0;
}

@media (max-width: 620px) {
  .report-generation-dialog,
  .document-templates-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 22px 18px;
    border-radius: 18px;
  }

  .report-generation-dialog textarea {
    min-height: 138px;
  }

  .report-option-grid {
    gap: 11px;
  }

  .report-research-option {
    width: 100%;
    box-sizing: border-box;
  }

  .report-generation-actions button,
  .document-template-upload > button[type="submit"] {
    width: 100%;
  }
}
