/* NormDocs — Design System v2 */

/* ── Google Fonts (Playfair Display для логотипа) ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&display=swap');

/* ── CSS Variables ─────────────────────────────── */
:root {
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --bg-hover: #f3f6fc;
  --bg-code: #f1f5f9;
  --text: #2d3748;
  --text-muted: #718096;
  --text-light: #a0aec0;
  --accent: #2563eb;
  --accent-bg: #eff4ff;
  --accent-hover: #1d4ed8;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 52px;

  --params-bg: #f0fdf4;
  --params-border: #86efac;
  --exceptions-bg: #fffbeb;
  --exceptions-border: #fcd34d;
  --related-bg: #eff4ff;
  --related-border: #93c5fd;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f1629;
  --bg-hover: #1e2a4a;
  --bg-code: #0f1629;
  --text: #e0e0e0;
  --text-muted: #8892a4;
  --text-light: #5a6a82;
  --accent: #4f8cff;
  --accent-bg: #1e3a6e;
  --accent-hover: #6ba3ff;
  --border: #2a3a5c;
  --border-light: #1e2a4a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.4);

  --params-bg: #0f2a1a;
  --params-border: #2d6a4f;
  --exceptions-bg: #2a2410;
  --exceptions-border: #92400e;
  --related-bg: #1e3a6e;
  --related-border: #3b82f6;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: inherit; }
textarea, input { font-family: inherit; }

/* ── Chat layout (full-height, no page scroll) ── */
body.layout-chat {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.layout-chat .page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Standard layout (library, document pages) ── */
body.layout-page .page-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  width: 100%;
}

/* ── Header ─────────────────────────────────── */
.site-header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: relative;
  flex-shrink: 0;
  z-index: 50;
}

/* ── Logo ───────────────────────────────────── */
.site-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent-hover); }

/* ── Nav ────────────────────────────────────── */
.site-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.nav-btn {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 16px;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-block;
}
.nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.nav-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Header right ───────────────────────────── */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 1rem;
  transition: all 0.15s;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── Empty state (hero) ─────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px 80px;
  text-align: center;
}

.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
  letter-spacing: -1px;
}

.hero-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 36px;
}

.hero-input-wrap {
  width: 100%;
  max-width: 640px;
  position: relative;
  margin-bottom: 20px;
}

.hero-textarea {
  width: 100%;
  padding: 16px 56px 16px 20px;
  font-size: 1rem;
  line-height: 1.5;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text);
  resize: none;
  overflow: hidden;
  outline: none;
  min-height: 56px;
  max-height: 160px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hero-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
[data-theme="dark"] .hero-textarea:focus {
  box-shadow: 0 0 0 3px rgba(79,140,255,0.15);
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}
.send-btn:disabled { opacity: 0.35; cursor: default; }
.send-btn:not(:disabled):hover { background: var(--accent-hover); }

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 640px;
}

.chip {
  font-size: 0.8rem;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── Messages area ──────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 20px;
  min-height: 0;
}

.message {
  max-width: 900px;
  margin: 0 auto 32px;
  padding: 0 20px;
}

.message-question {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px;
  line-height: 1.5;
}

.message-body {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 14px;
  align-items: start;
}

/* ── Answer card ─────────────────────────────── */
.answer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.answer-brief {
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 16px;
}
.answer-brief:last-child { margin-bottom: 0; }

.clause-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed var(--accent);
  transition: border-bottom-style 0.1s;
}
.clause-link:hover { border-bottom-style: solid; }

/* ── Sections (params / exceptions / related) ── */
.answer-section {
  border-top: 1px solid var(--border-light);
  margin-top: 12px;
  padding-top: 10px;
}

.section-toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 2px 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.1s;
}
.section-toggle:hover { color: var(--text); }

.toggle-chevron {
  font-size: 0.65rem;
  flex-shrink: 0;
}

.section-body {
  padding-top: 10px;
}

/* ── Params table ─────────────────────────────── */
.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  background: var(--params-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--params-border);
}
.params-table th {
  text-align: left;
  padding: 7px 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0,0,0,0.03);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
[data-theme="dark"] .params-table th { background: rgba(255,255,255,0.04); }
.params-table td {
  padding: 7px 12px;
  border-top: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: top;
}
.value-cell {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.source-ref-cell {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Exception / Related boxes ────────────────── */
.exception-box {
  background: var(--exceptions-bg);
  border-left: 3px solid var(--exceptions-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 0.87rem;
  line-height: 1.65;
  color: var(--text);
}
.related-box {
  background: var(--related-bg);
  border-left: 3px solid var(--related-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 0.87rem;
  line-height: 1.65;
  color: var(--text);
}

/* ── Sources panel ────────────────────────────── */
.sources-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sources-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sources-count {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Source cards ─────────────────────────────── */
.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.source-card:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.source-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
}

.source-ref {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.source-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-muted);
  margin-bottom: 5px;
}

.source-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mobile sources toggle */
.mobile-sources-toggle {
  display: none;
  margin-top: 10px;
}
.mobile-sources-btn {
  font-size: 0.82rem;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.mobile-sources-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Loading dots ──────────────────────────────── */
.message-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 14px 0;
}
.loading-dots {
  display: flex;
  gap: 4px;
}
.loading-dots span {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Irrelevant / Error ──────────────────────── */
.irrelevant-notice {
  background: var(--exceptions-bg);
  border-left: 3px solid var(--exceptions-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 0.87rem;
  color: var(--text);
}
.error-notice {
  background: #fef2f2;
  border-left: 3px solid #f87171;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 0.87rem;
  color: #b91c1c;
}
[data-theme="dark"] .error-notice {
  background: #2a1010;
  color: #fca5a5;
}

/* ── Chat input bar ─────────────────────────── */
.chat-input-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 10px 20px 12px;
}

.chat-input-inner {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-input-inner .chat-textarea { flex: 1; }
.chat-input-inner .send-btn {
  position: static;
  flex-shrink: 0;
  margin-bottom: 0;
}

.chat-textarea {
  width: 100%;
  padding: 10px 48px 10px 16px;
  font-size: 0.93rem;
  line-height: 1.5;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat-textarea:focus { border-color: var(--accent); }

/* new chat button inside input bar */
.new-chat-btn {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 2px 6px;
  margin-top: 4px;
  cursor: pointer;
  float: right;
  transition: color 0.1s;
}
.new-chat-btn:hover { color: var(--text); }

/* ── Slide-in source panel ───────────────────── */
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
}
.panel-overlay.active {
  display: block;
  opacity: 1;
}

.source-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.source-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.panel-close {
  width: 28px; height: 28px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.panel-close:hover { border-color: var(--accent); color: var(--accent); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}
.panel-text {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 16px;
}
.panel-related {
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
  margin-bottom: 14px;
}
.panel-related-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.panel-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.panel-related-links .clause-link {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}
.panel-lib-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  transition: border-bottom-style 0.1s;
}
.panel-lib-link:hover { border-bottom-style: solid; }

/* ── Library page ─────────────────────────────── */
.lib-page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 4px;
}
.lib-page-meta {
  font-size: 0.87rem;
  color: var(--text-muted);
  margin: 0 0 32px;
}
.lib-category {
  margin-bottom: 32px;
}
.lib-cat-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.lib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
.lib-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  background: var(--bg);
}
.lib-row { cursor: pointer; }
.lib-row:hover td { background: var(--accent-bg); }
.lib-row td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
.lib-row-num { color: var(--text-light); font-size: 0.8rem; width: 40px; }
.lib-row-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  width: 110px;
}
.lib-row-title { line-height: 1.4; }
.lib-row-clauses {
  color: var(--text-muted);
  text-align: right;
  width: 80px;
  font-size: 0.82rem;
}
.lib-row-status { width: 120px; text-align: center; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.status-active {
  background: #dcfce7;
  color: #166534;
}
.status-inactive {
  background: #fee2e2;
  color: #991b1b;
}
[data-theme="dark"] .status-active { background: #14532d; color: #86efac; }
[data-theme="dark"] .status-inactive { background: #450a0a; color: #fca5a5; }

/* ── Document page ─────────────────────────── */
.doc-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.doc-back {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  text-decoration: none;
  transition: color 0.1s;
}
.doc-back:hover { color: var(--accent); }
.doc-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.doc-category {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 6px;
}
.doc-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin: 0 0 10px;
}
.doc-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.doc-meta-sep { color: var(--border); }

/* TOC */
.doc-toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 32px;
}
.doc-toc-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.doc-toc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.doc-toc-link {
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  text-decoration: none;
  transition: all 0.1s;
  white-space: nowrap;
}
.doc-toc-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* Section */
.doc-section {
  margin-bottom: 48px;
  scroll-margin-top: 20px;
}
.doc-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 18px;
  padding: 10px 16px;
  background: var(--bg-input);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.doc-section-num {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.doc-clause {
  display: flex;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.doc-clause:last-child { border-bottom: none; }
.doc-clause-num {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  min-width: 72px;
  padding-top: 2px;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.doc-clause-text {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  flex: 1;
}

/* Back-to-top button */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px; height: 40px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover { background: var(--accent-hover); }

/* ── Clause detail page (existing) ─────────── */
.clause-page { display: flex; flex-direction: column; gap: 20px; }
.back-link-row { display: flex; gap: 12px; }
.back-link { color: var(--text-muted); font-size: 0.875rem; }
.back-link:hover { color: var(--accent); }
.clause-page-title { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin: 0; }
.clause-full-text {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
}
.clause-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.clause-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.params-list { margin: 4px 0 0; padding-left: 16px; }
.params-list li { margin-bottom: 2px; font-size: 0.83rem; }
.ref-link { color: var(--accent); font-size: 0.83rem; border-bottom: 1px dashed var(--accent); }
.ref-link:hover { border-bottom-style: solid; }
.refs-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.refs-list li { font-size: 0.83rem; line-height: 1.5; }
.ref-preview { color: var(--text-muted); }
.not-found { text-align: center; padding: 48px 0; color: var(--text-muted); }
.btn {
  display: inline-block;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  margin-top: 14px;
}
.btn:hover { background: var(--accent-hover); }
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.clause-number {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 4px;
}
.clause-text {
  font-size: 0.87rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}
.clause-meta {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.meta-label { font-weight: 600; color: var(--text); white-space: nowrap; }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  .site-nav { gap: 4px; }
  .nav-btn { padding: 4px 11px; font-size: 0.8rem; }

  .message-body {
    grid-template-columns: 1fr;
  }
  .sources-panel {
    display: none;
  }
  .sources-panel.mobile-open {
    display: flex;
  }
  .mobile-sources-toggle {
    display: block;
  }

  .source-panel {
    width: 100%;
  }

  .hero-title { font-size: 2rem; }
  .hero-sub { font-size: 0.9rem; margin-bottom: 24px; }
  .chips-row { gap: 6px; }
  .chip { font-size: 0.75rem; padding: 4px 10px; }

  .chat-input-bar { padding: 8px 12px 10px; }

  .lib-row-num { display: none; }
  .lib-table th:nth-child(1) { display: none; }

  .doc-toc-links { gap: 5px; }
  .doc-toc-link { font-size: 0.75rem; padding: 3px 8px; }

  .back-to-top { bottom: 16px; right: 16px; }
}

@media (max-width: 480px) {
  .message { padding: 0 12px; }
  .answer-card { padding: 14px 16px; }
  .hero-title { font-size: 1.75rem; }
  .params-table { font-size: 0.78rem; }
  .params-table th, .params-table td { padding: 5px 8px; }
  .lib-table { font-size: 0.82rem; }
  .lib-row td { padding: 9px 8px; }
}
