/* Legale Offline — UI per studi legali */

:root {
  --navy-950: #071525;
  --navy-900: #0c1f33;
  --navy-800: #152d4a;
  --navy-700: #1e3d63;
  --gold: #b8954a;
  --gold-light: #e8d9b0;
  --gold-muted: #f4eedc;

  --bg: #f4f1eb;
  --bg-elev: #ffffff;
  --bg-soft: #ebe6dc;
  --paper: #faf8f5;
  --text: #152232;
  --text-muted: #5a6778;
  --border: #d4dce6;
  --accent: var(--gold);
  --primary: var(--navy-800);
  --primary-dark: var(--navy-900);
  --danger: #b42318;
  --warn: #b45309;

  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-ui: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-legal: "Iowan Old Style", "Times New Roman", Georgia, serif;

  --header-h: 72px;
  --strip-h: 88px;
  --toolbar-h: 56px;
  --footer-h: 36px;
  --chrome-top: calc(var(--header-h) + var(--strip-h));

  --shadow-sm: 0 1px 2px rgba(12, 31, 51, 0.06);
  --shadow-md: 0 8px 24px rgba(12, 31, 51, 0.08);
  --radius: 10px;

  --color-PERSON:    #fce4ec;
  --color-ADDRESS:   #e3f2fd;
  --color-CITY:      #e8eaf6;
  --color-ORG:       #fff8e1;
  --color-EMAIL:     #e8f5e9;
  --color-PHONE:     #e0f2f1;
  --color-IBAN:      #ede7f6;
  --color-CF:        #fbe9e7;
  --color-VAT:       #fbe9e7;
  --color-CASE_ID:   #f3e5f5;
  --color-PLATE:     #e0f7fa;
  --color-DATE:      #f5f5dc;
  --color-DOC_ID:    #eceff1;
  --color-OTHER:     #f5f5f5;
  --color-CUSTOM:    #ede0ff;
  --color-REDACT:    #2c3e50;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- header -------------------------------------------------------------- */

.site-header {
  height: var(--header-h);
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 55%, #1a3a5c 100%);
  color: #fff;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(184, 149, 74, 0.45);
  border-radius: 10px;
  color: var(--gold-light);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-name em {
  font-style: italic;
  color: var(--gold-light);
  font-weight: 600;
}

.brand-tagline {
  font-size: 0.78rem;
  opacity: 0.82;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.server-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
}

.server-status .msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.server-status.ok .dot {
  background: #6ee7a0;
  box-shadow: 0 0 8px rgba(110, 231, 160, 0.6);
}
.server-status.err .dot {
  background: #fca5a5;
}

.engine-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border-radius: 20px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  font-family: inherit;
}
.engine-badge::after {
  content: "▾";
  font-size: 9px;
  margin-left: 6px;
  opacity: 0.7;
}
.engine-badge:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--gold);
}
.engine-badge[data-engine="local"] {
  background: rgba(184, 149, 74, 0.25);
  border-color: var(--gold);
  color: var(--gold-light);
}
.engine-badge[data-engine="server"] {
  background: rgba(147, 197, 253, 0.15);
  border-color: rgba(147, 197, 253, 0.4);
}

.btn-icon {
  padding: 6px 10px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  border-color: transparent;
  background: transparent;
}
.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ---- value strip --------------------------------------------------------- */

.value-strip {
  min-height: var(--strip-h);
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}

.value-card {
  background: var(--paper);
  padding: 14px 22px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.value-num {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy-900);
  color: var(--gold-light);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
}

.value-body strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: 2px;
}

.value-body p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---- workspace ----------------------------------------------------------- */

.workspace {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.workspace-tabs {
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 2px 4px;
  padding: 8px 12px 0;
  background: linear-gradient(180deg, var(--navy-900) 0%, #152a42 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.workspace-tabs-ready .workspace-tab--tool {
  animation: workspace-tab-in 0.2s ease;
}
@keyframes workspace-tab-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.workspace-tabs-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 2px;
}
.workspace-tabs-divider {
  width: 1px;
  height: 26px;
  margin: 0 6px 10px;
  background: rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}
.workspace-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  margin-bottom: -1px;
  position: relative;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.workspace-tab-label {
  display: block;
  white-space: nowrap;
}
.workspace-tab:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.workspace-tab.active {
  color: var(--navy-900);
  background: var(--paper);
  border-color: var(--border);
  border-bottom-color: var(--paper);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.14);
  z-index: 2;
}
.workspace-tab--primary.active {
  border-top: 3px solid var(--gold);
  padding-top: 8px;
}
.workspace-tab--tool {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px 10px;
}
.workspace-tab--tool.active {
  border-top: 3px solid var(--navy-700);
  padding-top: 6px;
}
.workspace-tab--llm.active {
  border-top-color: var(--gold);
}
.workspace-tab--ai.active {
  border-top: 3px solid var(--gold);
  padding-top: 8px;
}
.workspace-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.workspace-view-document,
.workspace-view-tools,
.workspace-view-assistant {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.workspace-view-assistant,
.workspace-view-tools {
  background: var(--bg-elev);
}
.workspace-view-document[hidden],
.workspace-view-tools[hidden],
.workspace-view-assistant[hidden] {
  display: none !important;
}

#assistantRoot.assistant-shell {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.activity-report {
  flex: 0 1 auto;
  max-height: min(42vh, 360px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.workspace-view-tools .activity-report--workspace {
  flex: 1 1 auto;
  max-height: none;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.activity-report-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.activity-report-header strong {
  font-size: 13px;
}
.activity-report .activity-result-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  padding: 8px 12px 0;
  margin: 0;
}
.activity-report .activity-result-body {
  flex: 1 1 auto;
  min-height: 80px;
  max-height: none;
  margin: 8px 12px 12px;
  overflow-y: auto;
}

.assistant-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.assistant-top {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}
.assistant-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.assistant-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-empty {
  color: var(--text-muted);
  font-size: 13px;
  margin: auto;
  text-align: center;
  max-width: 28em;
}
.assistant-form {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--paper);
}
.assistant-form textarea {
  width: 100%;
  min-height: 72px;
  max-height: 22vh;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  box-sizing: border-box;
}
.assistant-form .btn-primary {
  align-self: flex-end;
  min-width: 100px;
}

@media (max-width: 900px) {
  .workspace-tabs {
    padding: 6px 6px 0;
    gap: 2px;
  }
  .workspace-tab--primary {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px 10px;
    font-size: 12px;
  }
  .workspace-tab--tool {
    padding: 7px 8px 9px;
    font-size: 11px;
  }
  .workspace-tabs-divider {
    display: none;
  }
  .workspace-tabs-tools {
    width: 100%;
    order: 3;
    padding-bottom: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 4px;
  }
  .workspace-tab--ai {
    margin-left: auto;
  }
}

.toolbar {
  flex: 0 0 auto;
  background: var(--bg-elev);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.toolbar-primary,
.toolbar-export {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 4px;
}

.pdf-diagnostic {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}
.diag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--border, #d8e0d2);
  background: var(--surface-muted, #f6faf1);
  color: var(--text-muted, #4a5544);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}
.diag-chip-ok {
  background: #eef9e0;
  color: #3a7a17;
  border-color: #5bac26;
}
#forceOcrBtn { margin-top: 4px; }

.toolbar .stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.panes-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 0;
  background: var(--border);
}

.pane {
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.pane-anon .pane-header {
  background: linear-gradient(90deg, var(--gold-muted) 0%, var(--bg-soft) 100%);
}

.pane-header {
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-700);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.pane-title { flex: 0 0 auto; }

.pane-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--navy-900);
  color: var(--gold-light);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.pane-meta {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.pane-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 28px 32px;
  font-family: var(--font-legal);
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--paper);
}

.pane-body.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 14px;
  text-align: center;
}

.drop-hint {
  border: 2px dashed var(--border);
  padding: 40px 36px;
  border-radius: var(--radius);
  max-width: 420px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

.drop-hint-muted {
  border-style: solid;
  border-color: var(--bg-soft);
  background: transparent;
  box-shadow: none;
}

.drop-icon {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--navy-800);
  opacity: 0.35;
  margin-bottom: 12px;
  line-height: 1;
}

.drop-hint p { margin: 0 0 8px; }
.drop-hint p:last-child { margin-bottom: 0; }
.drop-formats { font-size: 12px; color: var(--text-muted); }

.drop-hint code {
  font-size: 12px;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- buttons ------------------------------------------------------------- */

.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: #b8c4d0;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-primary {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-900);
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-900);
}
.btn-accent {
  background: var(--bg-elev);
  border-color: var(--navy-700);
  color: var(--navy-800);
}
.btn-accent:hover:not(:disabled) {
  background: var(--gold-muted);
  border-color: var(--gold);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}

/* ---- PII highlights ------------------------------------------------------ */

.pii {
  border-radius: 3px;
  padding: 1px 3px;
  cursor: pointer;
  transition: outline-color 0.1s;
  outline: 2px solid transparent;
}
.pii:hover { outline-color: rgba(21, 45, 74, 0.35); }
.pii.excluded {
  background: transparent !important;
  text-decoration: line-through;
  color: var(--text-muted);
}
.pii.selected { outline-color: var(--navy-900); }

.pii-PERSON   { background: var(--color-PERSON); }
.pii-ADDRESS  { background: var(--color-ADDRESS); }
.pii-CITY     { background: var(--color-CITY); }
.pii-ORG      { background: var(--color-ORG); }
.pii-EMAIL    { background: var(--color-EMAIL); }
.pii-PHONE    { background: var(--color-PHONE); }
.pii-IBAN     { background: var(--color-IBAN); }
.pii-CF       { background: var(--color-CF); }
.pii-VAT      { background: var(--color-VAT); }
.pii-CASE_ID  { background: var(--color-CASE_ID); }
.pii-PLATE    { background: var(--color-PLATE); }
.pii-DATE     { background: var(--color-DATE); }
.pii-DOC_ID   { background: var(--color-DOC_ID); }
.pii-OTHER    { background: var(--color-OTHER); }
.pii-CUSTOM   {
  background: var(--color-CUSTOM);
  border: 1px dashed #8a6cd6;
}
.pii-REDACT {
  background: repeating-linear-gradient(
    -45deg,
    var(--color-REDACT),
    var(--color-REDACT) 4px,
    #4a6075 4px,
    #4a6075 8px
  );
  color: #fff;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.pii.manual {
  box-shadow: inset 0 -2px 0 0 rgba(138, 108, 214, 0.6);
}

.pseudo.redacted {
  background: var(--color-REDACT);
  color: #fff;
}

.pseudo {
  background: var(--navy-900);
  color: var(--gold-light);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
}

.pseudo-off {
  text-decoration: underline dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  border-radius: 2px;
  padding: 0 1px;
  cursor: help;
  opacity: 0.95;
}

/* ---- review drawer ------------------------------------------------------- */

.review-drawer {
  position: fixed;
  top: var(--chrome-top);
  right: 0;
  bottom: var(--footer-h);
  width: 340px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(12, 31, 51, 0.1);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.review-drawer.open { transform: translateX(0); }

.review-drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-900);
  color: #fff;
}
.review-drawer-header strong {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}
.review-drawer-header .btn-ghost {
  color: rgba(255, 255, 255, 0.8);
}
.review-drawer-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.review-drawer-body .field { margin-bottom: 14px; }
.review-drawer-body .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.review-drawer-body .value { font-size: 14px; }
.review-drawer-body code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: var(--gold-muted);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--navy-900);
}
.review-drawer-actions {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--paper);
}

/* ---- legend -------------------------------------------------------------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}
.legend-item {
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  font-weight: 500;
}
.legend-item.disabled {
  opacity: 0.4;
  text-decoration: line-through;
}
.legend-item:hover { border-color: var(--border); }
.legend-item.legend-CUSTOM {
  background: var(--color-CUSTOM);
  border: 1px dashed #8a6cd6;
}
.legend-item.legend-REDACT {
  background: var(--color-REDACT);
  color: #fff;
}

/* ---- progress & toast ---------------------------------------------------- */

.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 21, 37, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.progress-overlay.show { display: flex; }

.progress-card {
  background: var(--bg-elev);
  padding: 32px 40px;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 280px;
  border: 1px solid var(--border);
}

.progress-overlay .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-overlay .msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-900);
}
.progress-overlay .msg-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.progress-overlay .progress-bar {
  width: min(360px, 60vw);
  height: 8px;
  appearance: none;
  border: none;
  border-radius: 4px;
  background: var(--border);
}
.progress-overlay .progress-bar::-webkit-progress-value {
  background: var(--navy-800);
  border-radius: 4px;
}

#toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--gold);
}
#toast.show { opacity: 1; }
#toast.err {
  background: var(--danger);
  border-left-color: #fff;
}

/* ---- footer -------------------------------------------------------------- */

.site-footer {
  flex: 0 0 auto;
  height: var(--footer-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

.footer-sep { opacity: 0.4; }

/* ---- settings dialog ----------------------------------------------------- */

.settings-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  background: var(--bg-elev);
  color: var(--text);
  max-width: 560px;
  width: 92%;
  box-shadow: 0 20px 50px rgba(12, 31, 51, 0.2);
}
.settings-dialog::backdrop {
  background: rgba(7, 21, 37, 0.5);
  backdrop-filter: blur(3px);
}
.settings-form {
  margin: 0;
  padding: 26px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-form h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy-900);
}
.settings-lead {
  margin: -8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.settings-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-group legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--navy-800);
}
.settings-group small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 2px;
}
.settings-group input[type="url"],
.settings-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--paper);
}
.settings-radio {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.settings-radio:hover { background: var(--paper); }
.settings-radio input { margin-top: 3px; }
.settings-radio-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-radio-text strong { font-size: 13px; }
.settings-local-model-static {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.settings-radio:has(input:checked) {
  border-color: var(--navy-700);
  background: var(--gold-muted);
}
.settings-model-status { font-style: italic; margin-top: 4px !important; }
.settings-model-status[data-state="cached"],
.settings-model-status[data-state="loaded"] { color: var(--navy-700); }
.settings-model-status[data-state="missing"] { color: var(--warn); }
.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- manual redact toolbar ---------------------------------------------- */
/* Toolbar fluttuante che appare quando l'utente seleziona del testo nel
   pannello "Originale" per anonimizzare/eliminare manualmente porzioni di
   testo che il NER non ha identificato (o che vuole forzare). */

.manual-toolbar {
  position: fixed;
  z-index: 25;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--navy-900);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(7, 21, 37, 0.35);
  font-size: 12px;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s ease;
  white-space: nowrap;
}
.manual-toolbar.visible { display: inline-flex; }
.manual-toolbar::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--navy-900);
}

.manual-toolbar .mt-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: inherit;
  font: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.manual-toolbar .mt-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}
.manual-toolbar .mt-btn.primary {
  background: var(--gold);
  color: var(--navy-900);
  border-color: var(--gold);
  font-weight: 600;
}
.manual-toolbar .mt-btn.primary:hover {
  background: var(--gold-light, #f0d57a);
}
.manual-toolbar .mt-btn.danger {
  background: var(--danger, #b71c1c);
  border-color: var(--danger, #b71c1c);
  font-weight: 600;
}
.manual-toolbar .mt-btn.danger:hover {
  filter: brightness(1.1);
}

.manual-toolbar select.manual-cat {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font: inherit;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.manual-toolbar select.manual-cat option {
  color: var(--text);
  background: var(--bg-elev);
}

.manual-toolbar .manual-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding-left: 6px;
  border-left: 1px solid rgba(255,255,255,0.2);
  margin-left: 2px;
}
.manual-toolbar .manual-all input { margin: 0; cursor: pointer; }
.manual-toolbar .manual-all .count { font-weight: 600; color: var(--gold-light, #f0d57a); }

/* Hint sopra il pannello Originale dopo la prima analisi */
.manual-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: var(--gold-muted);
  border-radius: 4px;
  border-left: 3px solid var(--gold);
  margin-left: 8px;
  font-style: italic;
}

/* Drawer: badge per entita' manuali */
.manual-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.manual-anon-badge {
  background: var(--color-CUSTOM);
  color: #4321a0;
  border: 1px dashed #8a6cd6;
}
.manual-redact-badge {
  background: var(--color-REDACT);
  color: #fff;
}

/* Stile bottone "rimuovi marcatura manuale" nel drawer */
.btn-manual-remove {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-manual-remove:hover {
  background: var(--danger);
  color: #fff;
}

/* In modalità "selezionabile" il cursore del pannello e' ben visibile */
#originalPane.selectable {
  cursor: text;
}
#originalPane .raw {
  cursor: text;
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1100px) {
  .value-strip {
    grid-template-columns: 1fr;
    --strip-h: auto;
  }
  .value-card { padding: 12px 18px; }
  :root { --chrome-top: calc(var(--header-h) + 220px); }
}

@media (max-width: 900px) {
  .brand-tagline { display: none; }
  .panes-grid { grid-template-columns: 1fr; }
  .server-status { display: none; }
}

@media (max-width: 640px) {
  .site-header { padding: 0 14px; }
  .brand-name { font-size: 1.35rem; }
  .toolbar-export .toolbar-label { display: none; }
}

/* ===== Modale "Deanonimizza" ============================================ */

.deanon-dialog {
  max-width: 720px;
}
.deanon-dialog .settings-form {
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.btn-deanon {
  background: linear-gradient(180deg, #f0f9ff, #e0f2fe);
  border-color: #7dd3fc;
  color: #075985;
  font-weight: 600;
}
.btn-deanon:hover { background: #e0f2fe; border-color: #38bdf8; }

.deanon-section {
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
}
.deanon-section legend {
  padding: 0 8px;
  font-weight: 600;
  color: var(--accent, #0f5d9c);
  font-size: 0.95rem;
}

.deanon-source-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.deanon-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.deanon-radio:hover { background: rgba(15, 93, 156, 0.06); }
.deanon-radio input[type="radio"]:disabled + span {
  opacity: 0.55;
  cursor: not-allowed;
}
.deanon-radio span small { color: var(--muted, #6b7a8c); margin-left: 6px; }

.deanon-source-body {
  padding: 8px 10px;
  margin-top: 6px;
  background: rgba(15, 93, 156, 0.04);
  border-radius: 8px;
}
.deanon-source-body[hidden] { display: none; }

.deanon-info { display: block; margin-top: 6px; color: var(--muted, #6b7a8c); font-size: 0.85rem; }
.deanon-info.err { color: #b42318; }
.deanon-warn { color: #92400e; }

.deanon-recent-list {
  list-style: none;
  margin: 0 0 8px 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 8px;
  background: #fff;
}
.deanon-recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef2f7;
}
.deanon-recent-item:last-child { border-bottom: none; }
.deanon-recent-item:hover { background: rgba(15, 93, 156, 0.04); }
.deanon-recent-item.selected {
  background: rgba(56, 189, 248, 0.12);
  border-left: 3px solid #38bdf8;
}
.deanon-recent-meta strong { display: block; color: var(--text); }
.deanon-recent-meta small { color: var(--muted, #6b7a8c); font-size: 0.82rem; }
.deanon-recent-actions { display: flex; gap: 6px; flex-shrink: 0; }

.deanon-details { margin-top: 10px; }
.deanon-details summary {
  cursor: pointer;
  color: var(--accent, #0f5d9c);
  font-size: 0.9rem;
  user-select: none;
}
.deanon-details textarea {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.deanon-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.deanon-output {
  background: #fbfdff;
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 8px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.deanon-stats {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text);
}
.deanon-stat-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 2px;
}

.deanon-privacy {
  background: rgba(255, 247, 226, 0.5);
  border-color: #f5d894;
}
.deanon-privacy legend { color: #92400e; }

input[type="file"]#deanonDictFile,
input[type="file"]#deanonDocFile {
  display: block;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .deanon-dialog { max-width: 100%; }
  .deanon-recent-item { flex-direction: column; align-items: flex-start; }
}

/* ===== "Come funziona" — modale + pagina autonoma ====================== */

/* Bottone in header con icona + testo "Come funziona" (visibile, scopribile). */
.btn-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-help:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.55);
}
.btn-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: #0c1f33;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}
.btn-help-text { white-space: nowrap; }

/* Evidenziazione primo accesso: pulsazione + callout con freccia */
.help-btn-wrap {
  position: relative;
}
.btn-help.help-intro-highlight {
  animation: help-btn-pulse 1.8s ease-in-out infinite;
  border-color: #b8e08a;
  background: rgba(91, 172, 38, 0.22);
}
@keyframes help-btn-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(184, 224, 138, 0.75);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(184, 224, 138, 0);
  }
}
.help-intro-callout {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 220px;
  max-width: 280px;
  padding: 10px 12px 10px 14px;
  background: #fff;
  color: var(--navy-900, #0c1f33);
  border: 2px solid #5bac26;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(12, 31, 51, 0.25);
  font-size: 0.88rem;
  line-height: 1.4;
  pointer-events: auto;
}
.help-intro-callout[hidden] {
  display: none !important;
}
.help-intro-arrow {
  position: absolute;
  top: -9px;
  right: 28px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid #5bac26;
}
.help-intro-arrow::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 2px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid #fff;
}
.help-intro-text strong {
  color: #2d6a1e;
}
.help-intro-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  border-radius: 4px;
}
.help-intro-dismiss:hover {
  color: var(--navy-900, #0c1f33);
  background: #f1f5f9;
}

/* Link inline nello stato vuoto del pannello documento. */
.drop-help {
  margin-top: 16px;
  font-size: 0.92rem;
  color: var(--muted, #6b7a8c);
}
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #0f5d9c);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.link-btn:hover { color: #0a4475; }

@media (max-width: 720px) {
  .btn-help-text { display: none; }
  .btn-help { padding: 6px; }
  .help-intro-callout {
    right: -8px;
    min-width: 200px;
    max-width: min(260px, calc(100vw - 24px));
  }
  .help-intro-arrow { right: 18px; }
}

/* NON usare display:flex sul selettore base: sovrascrive display:none del
   <dialog> chiuso e la modale resta visibile senza overlay (bug "Chiudi"). */
.help-dialog {
  max-width: 880px;
  padding: 0;
  border: none;
}
.help-dialog:not([open]) {
  display: none !important;
}
.help-dialog[open] {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 60px);
  overflow: hidden;
}
.help-dialog-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  max-height: calc(100vh - 60px);
}
.help-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border, #d8e1ec);
  background: var(--bg-elev);
  flex: 0 0 auto;
}
.help-dialog-header h2 { margin: 0; font-size: 1.4rem; }
.help-dialog-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.help-dialog-x {
  font-size: 1.35rem;
  line-height: 1;
  padding: 4px 10px;
  min-width: 36px;
}
.help-dialog-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.help-dialog-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border, #d8e1ec);
  text-align: right;
  background: var(--bg-elev);
  flex: 0 0 auto;
}
.help-dialog-footer .btn { position: relative; }
.help-loading {
  text-align: center;
  color: var(--muted, #6b7a8c);
  padding: 24px 0;
}
.help-fallback {
  padding: 24px;
  border: 1px dashed #f5d894;
  background: #fffaeb;
  border-radius: 10px;
}

/* Sezioni del contenuto (sia modale sia pagina) */
.help-section {
  margin: 0 0 28px;
}
.help-section h2 {
  font-size: 1.25rem;
  color: var(--accent, #0f5d9c);
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e0f2fe;
}
.help-section h3 { font-size: 1.05rem; margin: 14px 0 6px; }
.help-section p { line-height: 1.55; }

/* Box privacy evidenziato */
.help-privacy-box {
  background: linear-gradient(180deg, #ecfdf5 0%, #f0fdfa 100%);
  border: 1px solid #6ee7b7;
  border-radius: 12px;
  padding: 16px 20px;
}
.help-privacy-box h2 {
  color: #047857;
  border-bottom-color: #6ee7b7;
}
.help-privacy-list {
  margin: 8px 0;
  padding-left: 22px;
  line-height: 1.6;
}
.help-privacy-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.6);
  border-left: 3px solid #047857;
  border-radius: 6px;
  font-size: 0.95rem;
}

/* Diagramma del flusso */
.help-figure {
  margin: 12px 0;
  text-align: center;
}
.help-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

/* Steps numerati */
.help-steps {
  list-style: none;
  counter-reset: helpstep;
  padding: 0;
  margin: 12px 0;
}
.help-steps > li {
  counter-increment: helpstep;
  position: relative;
  padding: 10px 12px 10px 52px;
  margin-bottom: 8px;
  background: #fbfdff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  line-height: 1.55;
}
.help-steps > li::before {
  content: counter(helpstep);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent, #0f5d9c);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Due modalità a confronto */
.help-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}
.help-mode {
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
}
.help-mode h3 { margin-top: 0; color: var(--accent, #0f5d9c); }
.help-mode-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #0f5d9c;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.help-mode-recommended {
  background: #fef9ed;
  border-color: #f5d894;
}
.help-mode-recommended h3 { color: #92400e; }
.help-mode-recommended .help-mode-tag {
  background: #fde68a;
  color: #78350f;
}
.help-mode ul { margin: 6px 0 0; padding-left: 22px; line-height: 1.55; }

/* Tabella comparativa */
.help-compare {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.92rem;
}
.help-compare th,
.help-compare td {
  padding: 8px 10px;
  border: 1px solid var(--border, #d8e1ec);
  text-align: left;
  vertical-align: top;
}
.help-compare thead th {
  background: var(--accent, #0f5d9c);
  color: #fff;
  font-weight: 600;
}
.help-compare tbody th {
  background: #f1f5f9;
  font-weight: 600;
  width: 28%;
}

.help-cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 8px;
  flex-wrap: wrap;
}
.help-cta-hint { color: var(--muted, #6b7a8c); font-size: 0.9rem; }

.help-future-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fffaeb;
  border-left: 3px solid #f5d894;
  border-radius: 6px;
  font-size: 0.95rem;
}

/* Definitions list (anonimizzazione manuale) */
.help-defs { margin: 10px 0; }
.help-defs dt {
  font-weight: 700;
  color: var(--accent, #0f5d9c);
  margin-top: 8px;
}
.help-defs dd {
  margin: 2px 0 8px 0;
  padding-left: 14px;
  border-left: 2px solid #cbd5e1;
  line-height: 1.55;
}

.help-tip {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f0f9ff;
  border-left: 3px solid #38bdf8;
  border-radius: 6px;
}

/* FAQ */
.help-faq details {
  border: 1px solid var(--border, #d8e1ec);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 8px;
  background: #fff;
}
.help-faq details[open] { background: #fbfdff; }
.help-faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent, #0f5d9c);
  list-style: none;
  padding: 4px 0;
}
.help-faq summary::-webkit-details-marker { display: none; }
.help-faq summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
.help-faq details[open] > summary::before {
  content: "▾ ";
}
.help-faq details p { margin: 8px 0 4px; line-height: 1.55; }

/* Approfondimento tecnico */
.help-tech {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 8px 14px;
  background: #f8fafc;
}
.help-tech summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted, #6b7a8c);
}
.help-tech-body { padding: 8px 0; line-height: 1.55; }
.help-tech-body ul { padding-left: 22px; }

/* ===== Pagina autonoma aiuto.html ====================================== */

.help-page {
  background: #f8fafc;
  margin: 0;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: var(--text, #0f172a);
}
.help-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-elev, #0c1f33);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.help-page-header .brand { color: #fff; text-decoration: none; }
.help-page-header .brand-text {
  display: flex;
  flex-direction: column;
  margin-left: 10px;
}
.help-page-header .brand-name { font-size: 1.2rem; font-weight: 700; }
.help-page-header .brand-tagline { font-size: 0.85rem; opacity: 0.75; }
.help-page-actions { display: flex; gap: 8px; }
.help-page-actions .btn { color: #fff; border-color: rgba(255,255,255,0.3); }
.help-page-actions .btn:hover { background: rgba(255,255,255,0.1); }

.help-page-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.help-page-body { background: transparent; }

.help-page-footer {
  margin-top: 32px;
  padding: 16px 0;
  text-align: center;
  color: var(--muted, #6b7a8c);
  border-top: 1px solid var(--border, #d8e1ec);
  font-size: 0.9rem;
}

/* Stampa */
@media print {
  .help-page-header,
  .help-page-actions,
  .help-page-footer {
    display: none !important;
  }
  body.help-page { background: #fff; }
  .help-page-main { max-width: 100%; padding: 0; }
  .help-section { page-break-inside: avoid; }
  .help-modes { grid-template-columns: 1fr 1fr; }
  .help-faq details { break-inside: avoid; }
  .help-faq details:not([open]) > *:not(summary) { display: none; }
  /* In stampa apriamo tutte le FAQ per averle leggibili */
  .help-faq details:not([open]) { /* manteniamo le scelte dell'utente */ }
}

@media (max-width: 640px) {
  .help-dialog { max-width: 100%; }
  .help-modes { grid-template-columns: 1fr; }
  .help-compare { font-size: 0.85rem; }
  .help-page-main { padding: 16px; }
  .help-page-header { padding: 10px 16px; }
}

/* ---- activities drawer (sinistro) ---------------------------------------- */

.btn-assistant {
  border-color: var(--navy-700);
  color: var(--navy-800);
}
.btn-assistant:hover {
  background: rgba(12, 31, 51, 0.06);
}
.btn-assistant.btn-assistant-ready {
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--navy-700);
}

.btn-activities {
  border-color: var(--gold);
  color: var(--navy-800);
}
.btn-activities:hover {
  background: var(--gold-muted);
}
.btn-activities.btn-activities-ready {
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--gold);
}

.app-version {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.activities-drawer {
  position: fixed;
  top: var(--chrome-top);
  left: 0;
  bottom: var(--footer-h);
  width: min(420px, 92vw);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 32px rgba(12, 31, 51, 0.1);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 11;
  display: flex;
  flex-direction: column;
}
.activities-drawer.open { transform: translateX(0); }

.activities-drawer--assistant {
  width: min(680px, 52vw);
}
@media (max-width: 900px) {
  .activities-drawer--assistant {
    width: 100%;
    max-width: 100%;
  }
}

.activities-drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-900);
  color: #fff;
}
.activities-drawer-header strong {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}
.activities-drawer-header .btn-ghost { color: rgba(255, 255, 255, 0.85); }

.activities-drawer-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.activities-drawer-body--assistant {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.activities-drawer-back {
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
}

.activity-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.activity-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.activity-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-sm);
}
.activity-card-icon { font-size: 18px; line-height: 1; }
.activity-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.activity-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.activity-result-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.activity-result-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.activity-result-body {
  font-size: 13px;
  line-height: 1.55;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: 40vh;
  overflow-y: auto;
}
.activity-result-body ul {
  margin: 8px 0;
  padding-left: 1.2em;
}
.activity-result-placeholder,
.activity-loading {
  color: var(--text-muted);
  margin: 0;
}
.activity-error { color: var(--danger); margin: 0; }

.activity-card-llm {
  border-color: var(--navy-700);
  grid-column: 1 / -1;
}
.activity-view-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.activity-view-btn.active {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
}
.activity-privacy-note {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.activity-chat-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-elev);
}
.activity-chat-panel:not([hidden]) {
  display: flex;
}
.activity-chat-top {
  flex-shrink: 0;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}
.activity-chat-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.activity-chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.activity-chat-deanon-toggle {
  margin-bottom: 0;
}
.activity-chat-auto-deanon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.activity-chat-auto-deanon input {
  margin: 0;
}
.activity-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}
.activity-chat-bubble {
  font-size: 14px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 92%;
}
.activity-chat-bubble p {
  margin: 0 0 0.5em;
}
.activity-chat-bubble p:last-child {
  margin-bottom: 0;
}
.activity-chat-user {
  align-self: flex-end;
  background: var(--navy-800);
  color: #fff;
}
.activity-chat-assistant {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
}
.activity-chat-form {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--paper);
}
.activity-chat-form textarea {
  width: 100%;
  min-height: 72px;
  max-height: 28vh;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  box-sizing: border-box;
}
.activity-chat-form .btn-primary {
  align-self: flex-end;
  min-width: 100px;
}

/* ---- settings: giudice LLM ------------------------------------------------ */
.settings-judge-group small { display: block; margin-bottom: 10px; }
.settings-judge-toggle { margin-top: 8px; }
.settings-judge-url-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.settings-judge-group input[type="url"],
.settings-judge-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
.settings-judge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.settings-judge-status { font-size: 12px; color: var(--text-muted); }
.settings-judge-progress {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.settings-judge-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.settings-judge-progress-bar > div {
  height: 100%;
  width: 0%;
  background: var(--navy-700);
  transition: width 0.2s;
}
.settings-judge-info {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  background: var(--paper);
  border-left: 3px solid var(--navy-700);
  border-radius: var(--radius);
}

@media (max-width: 900px) {
  .activities-drawer {
    width: 100%;
    max-width: 100%;
  }
  .activities-drawer.open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(7, 21, 37, 0.45);
    z-index: -1;
  }
}
