:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #263042;
  --muted: #707d8f;
  --accent: #4a6785;
  --accent-tint: #e4ebf2;
  --accent-contrast: #ffffff;
  --danger: #b3474f;
  --danger-tint: #f4e3e4;
  --ok: #3f8767;
  --warn: #b3852f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(38, 48, 66, 0.05), 0 1px 8px rgba(38, 48, 66, 0.04);
}

* { box-sizing: border-box; }

/* Any author rule that sets display on an element (e.g. `label { display:
   flex }`) otherwise silently wins over the browser's built-in `[hidden] {
   display: none }` UA rule, regardless of specificity — so the hidden
   attribute alone stops working as soon as a type selector touches
   display. This restores it globally. */
[hidden] { display: none !important; }

html { font-size: 14px; height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-width: 0;
}

.topbar .brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
  white-space: nowrap;
}

.section-title {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.98rem;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.session-user { white-space: nowrap; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  padding: 0;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { background: var(--bg); color: var(--accent); }
.icon-btn.active { background: var(--accent-tint); color: var(--accent); }
.icon-btn-danger:hover { background: var(--danger-tint); color: var(--danger); }

/* Wins over the generic button[type="submit"] rule (the logout icon is a
   submit button so it doesn't turn into a filled accent button like every
   other submit button in the app). */
button.icon-btn[type="submit"] {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
button.icon-btn[type="submit"]:hover { background: var(--bg); color: var(--accent); }
button.icon-btn-danger[type="submit"]:hover { background: var(--danger-tint); color: var(--danger); }

.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 130%;
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  background: var(--text);
  color: var(--surface);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}
.icon-btn[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container-wide {
  max-width: none;
  padding-bottom: 1.5rem;
}

h1 { font-size: 1.5rem; font-weight: 600; margin: 0.2rem 0 1rem; letter-spacing: -0.005em; }
h2 { font-size: 1.08rem; font-weight: 600; margin: 0 0 0.75rem; }
h3 { font-size: 0.92rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--muted); }

a { color: var(--accent); }

.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  margin: 1.1rem 0;
}

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.list li:last-child { border-bottom: none; }

.domain-item {
  display: block !important;
  padding: 1rem 0 !important;
}
.domain-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.domain-item-header strong { font-size: 1rem; }
.domain-item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.domain-item-description {
  color: var(--muted);
  margin: 0.35rem 0 0.8rem;
  max-width: 68ch;
}
.domain-item-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.domain-item-actions .btn-ghost { white-space: nowrap; }
.domain-delete-form { margin: 0 0 0 auto; }
.domain-delete-form .link-danger {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  text-decoration: none;
}
.domain-edit { position: relative; }
.domain-edit summary { list-style: none; cursor: pointer; }
.domain-edit summary::-webkit-details-marker { display: none; }
.domain-edit[open] form {
  position: absolute;
  z-index: 2;
  right: 0;
  top: calc(100% + 0.45rem);
  width: min(360px, calc(100vw - 4rem));
  padding: 0.9rem;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
form.inline-form { display: inline-flex; margin-top: 0.75rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="text"], input[type="file"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}

textarea { resize: vertical; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  align-self: flex-start;
}

.btn-ghost {
  display: inline-block;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
  padding: 0.35rem 0.65rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

button[type="submit"], button.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

button.danger, .link-danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger);
}

.link-danger {
  border: none;
  padding: 0;
  text-decoration: underline;
  font-size: 0.85rem;
  margin-left: auto;
}

.link {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-size: 0.85rem;
}

.badge-danger { color: var(--danger); border-color: var(--danger); }
.badge-warn { color: var(--warn); border-color: var(--warn); }
.badge-ok { color: var(--ok); border-color: var(--ok); }

.scout-snippet {
  margin: 0 0 1rem;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
}
.scout-checklist .badge { margin: 0 0.15rem; }

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.list-header h2 { margin: 0; }

.search-form {
  flex-direction: row;
  align-items: center;
  margin: 0;
  gap: 0.5rem;
}
.search-form input[type="text"] { min-width: 260px; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-tile {
  flex: 1 1 110px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stat-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }

.matrix-table th, .matrix-table td { min-width: 150px; }
.matrix-cell > * { margin-bottom: 0.3rem; }
.matrix-cell > *:last-child { margin-bottom: 0; }

.button-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  color: var(--muted);
}

.status {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.status-pending, .status-running { color: var(--warn); }
.status-completed, .status-accepted { color: var(--ok); }
.status-failed { color: var(--danger); }

.error-box {
  background: #f7ecee;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }

.compare-table { table-layout: fixed; }
.compare-table th:first-child { color: var(--muted); font-weight: 600; white-space: normal; word-wrap: break-word; }
.compare-output { font-size: 0.82rem; max-height: 260px; overflow-y: auto; word-wrap: break-word; }
.skeleton-list { margin: 0; padding-left: 1.1rem; }
.likert-row { display: flex; flex-direction: column; gap: 0.5rem; }
.likert-row select { width: 100%; }

.analysis-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  margin: 0 0 1.25rem;
  box-shadow: var(--shadow);
}
.analysis-toolbar-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.analysis-toolbar-nav a:not(.btn-ghost) {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
}
.analysis-toolbar-nav a:not(.btn-ghost):hover { background: var(--bg); }
.analysis-toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 0.2rem; }

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.trace-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.6rem;
}
.trace-step summary {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.trace-step .latency { color: var(--muted); font-weight: 400; font-size: 0.82rem; margin-left: auto; }
.trace-step pre { margin-top: 0.6rem; }
.trace-step .markdown-body { margin-top: 0.6rem; }

/* Level 1: fixed meta-level workflow stepper */

.stepper { display: flex; flex-direction: column; gap: 0.5rem; }

.step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}
.step summary {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  list-style: none;
}
.step summary::-webkit-details-marker { display: none; }
.step .step-label { font-weight: 600; }
.step .latency { color: var(--muted); font-weight: 400; font-size: 0.82rem; margin-left: auto; }
.step pre { margin-top: 0.6rem; }
.step .markdown-body { margin-top: 0.6rem; }

.step-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex: none;
}
.step.status-done .step-dot { background: var(--ok); }
.step.status-pending .step-dot { background: var(--warn); opacity: 0.6; }

/* Level 2: dynamic CoA topology graph */

.graph-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 1rem;
  padding: 0.5rem;
}

#coa-graph { display: block; }

.coa-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

.coa-node rect {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.25;
}
.coa-node text {
  font-size: 12px;
  fill: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.coa-node { cursor: pointer; }
.coa-node:hover rect { stroke: var(--accent); }

.coa-node.status-pending .coa-node-dot { fill: var(--border); }
.coa-node.status-done .coa-node-dot { fill: var(--ok); }
.coa-node.status-done rect { stroke: var(--ok); }
.coa-node.status-running .coa-node-dot {
  fill: var(--warn);
  animation: coa-pulse 1.1s ease-in-out infinite;
}
.coa-node.status-running rect { stroke: var(--warn); }

@keyframes coa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Three-column browser (list / metadata / items), one per toolbar entry */

.browser {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(340px, 1.6fr) minmax(300px, 1fr);
  align-items: stretch;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

@media (max-width: 900px) {
  .browser { grid-template-columns: 1fr; }
  .browser-col + .browser-col { border-left: none; border-top: 1px solid var(--border); }
}

.browser-2col { grid-template-columns: minmax(280px, 1fr) minmax(420px, 2.2fr); }

.browser-col {
  background: transparent;
  padding: 1rem 1.1rem;
  align-self: stretch;
  overflow-y: auto;
}
.browser-col + .browser-col { border-left: 1px solid var(--border); }

.browser-col h2 {
  margin-top: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.browser-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  min-height: 3.5rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.browser-col-header h2 { margin: 0; }

.col-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.btn-ghost-danger {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}
.btn-ghost-danger:hover { background: var(--bg); }

/* Same specificity fix as button.icon-btn[type="submit"] above: these
   ghost buttons are often <button type="submit"> (Save/Archive/Delete in
   a column header), and button[type="submit"] would otherwise win and
   paint them as filled accent buttons. */
button.btn-ghost[type="submit"] {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
button.btn-ghost[type="submit"]:hover { border-color: var(--accent); color: var(--accent); }

button.btn-ghost.btn-ghost-danger[type="submit"] {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
button.btn-ghost.btn-ghost-danger[type="submit"]:hover { background: var(--bg); border-color: var(--danger); }

.browser-list { list-style: none; margin: 0; padding: 0; }
.browser-list li { border-bottom: 1px solid var(--border); }
.browser-list li:last-child { border-bottom: none; }

a.browser-row {
  display: block;
  padding: 0.6rem 0.5rem;
  text-decoration: none;
  color: var(--text);
  border-radius: 8px;
}
a.browser-row:hover { background: var(--bg); }
a.browser-row.selected { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
a.browser-row .muted { display: block; font-size: 0.8rem; font-weight: 400; }

/* Case/configuration/ontology names: same bold weight as the column
   headers, but not the small caps treatment — soft (muted color), not a
   heavy black bold. */
.browser-col strong {
  font-weight: 700;
  color: var(--muted);
}
a.browser-row.selected strong { color: var(--accent); }

/* Document thumbnails (Cases, column 3) */

.doc-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.7rem;
}

.doc-thumb {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.doc-thumb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-thumb-view,
button.doc-thumb-delete[type="submit"] {
  width: 1.3rem;
  height: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  padding: 0;
  text-decoration: none;
  cursor: pointer;
}

.doc-thumb-view { color: var(--accent); }
.doc-thumb-view svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.doc-thumb-view:hover { background: var(--accent-tint); }

.doc-thumb-media {
  width: 100%;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.doc-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.doc-thumb-caption {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

form.doc-thumb-delete-form { margin: 0; }

form.doc-thumb-category-form { margin: 0; }
form.doc-thumb-category-form select {
  width: 100%;
  font-size: 0.68rem;
  padding: 0.15rem 0.3rem;
  border-radius: 5px;
}

button.doc-thumb-delete[type="submit"] {
  color: var(--danger);
  font-size: 0.9rem;
  line-height: 1;
}
button.doc-thumb-delete[type="submit"]:hover { background: var(--surface); }

.browser-empty { color: var(--muted); font-size: 0.9rem; }

/* Generic modal, opened via static/ui.js */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 38, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.4rem 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-box.modal-wide { max-width: 700px; }
.modal-box.modal-xwide { max-width: 900px; }

.modal-box .list li { flex-wrap: wrap; }

.modal-close-x {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
}
.modal-close-x:hover { color: var(--text); }

/* Landing / login page */
.landing-body {
  min-height: 100vh;
}

.landing {
  min-height: 100vh;
  display: flex;
}

.landing-hero {
  flex: 1.3;
  display: flex;
  align-items: center;
  background: linear-gradient(160deg, #2f3f56 0%, var(--accent) 100%);
  padding: 3rem;
}

.landing-hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.landing-title {
  color: #ffffff;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 1rem;
}

.landing-subtitle {
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 300;
  line-height: 1.4;
  margin: 0;
}

.landing-auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 3rem 2rem;
}

.landing-auth-inner {
  width: 100%;
  max-width: 340px;
}

.landing-login-card {
  margin: 0;
}

@media (max-width: 820px) {
  .landing { flex-direction: column; }
  .landing-hero { flex: none; padding: 2.5rem 1.75rem; }
  .landing-auth { flex: none; padding: 2.5rem 1.75rem 3rem; }
}

/* Rendered markdown for LLM-generated output (run trace, final recommendations) —
   same visual language as .manual-content below, tighter scale since it sits
   nested inside cards/steps rather than filling a page. */
.markdown-body { line-height: 1.6; font-size: 0.9rem; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 700;
  color: var(--text);
  margin: 1rem 0 0.4rem;
}
.markdown-body h1 { font-size: 1.1rem; }
.markdown-body h2 { font-size: 1.02rem; }
.markdown-body h3 { font-size: 0.95rem; }
.markdown-body h4 { font-size: 0.9rem; color: var(--muted); }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body table,
.markdown-body blockquote {
  margin: 0 0 0.7rem;
}
.markdown-body ul, .markdown-body ol { padding-left: 1.3rem; }
.markdown-body li { margin-bottom: 0.25rem; }
.markdown-body li > p { margin-bottom: 0.25rem; }

.markdown-body table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.markdown-body th, .markdown-body td {
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.markdown-body thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.markdown-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown-body pre code { background: none; border: none; padding: 0; }

.markdown-body blockquote {
  padding: 0.35rem 0.9rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* User manual (rendered from docs/MANUALE_UTENTE.md) */
.manual-content { line-height: 1.65; }

.manual-content h1 {
  font-size: 1.7rem;
  margin: 0 0 1.25rem;
}

.manual-content h2 {
  font-size: 1.2rem;
  color: var(--text);
  margin: 2.2rem 0 0.9rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.manual-content h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

.manual-content h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  margin: 1.4rem 0 0.5rem;
}

.manual-content h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  margin: 1.1rem 0 0.4rem;
}

.manual-content p,
.manual-content ul,
.manual-content ol,
.manual-content table,
.manual-content blockquote {
  margin: 0 0 0.9rem;
}

.manual-content ul, .manual-content ol { padding-left: 1.4rem; }
.manual-content li { margin-bottom: 0.3rem; }
.manual-content li > p { margin-bottom: 0.3rem; }

.manual-content table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.manual-content th, .manual-content td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.manual-content thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.manual-content code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.manual-content pre code { background: none; border: none; padding: 0; }

.manual-content blockquote {
  padding: 0.4rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.manual-content hr { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }

/* Meta-level prompts (read-only, extracted live from n8n/build_workflows.py) */
.prompts-content { max-width: 780px; }

.prompts-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}
.prompts-intro code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }

.prompt-phase {
  margin: 2rem 0;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.prompt-phase-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}
.prompt-phase-head h2 { margin: 0; }

.prompt-phase-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 999px;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.prompt-block {
  margin: 0.9rem 0 0.5rem;
  font-size: 0.82rem;
}

.prompt-cite {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
