/* ──────────────────────────────────────────────────────────────────
   genaiGraph · Claude-inspired UI
   Warm dark palette, serif brand, bubble-less prose, pill composer.
   ────────────────────────────────────────────────────────────────── */

:root {
  /* warm dark palette (Claude-style) */
  --bg:            #262624;
  --bg-sidebar:    #1f1e1c;
  --surface:       #30302e;
  --surface-hi:    #3a3a37;
  --border:        #3d3d3a;
  --border-subtle: #2e2d2b;

  --text:       #f5f4ee;
  --text-muted: #b7b5ad;
  --text-faint: #86847d;

  --accent:       #c96442;
  --accent-hover: #d97757;
  --accent-soft:  rgba(201, 100, 66, 0.14);
  --accent-dim:   #7a3d28;

  --user-bubble: #30302e;
  --tool-bg:     #1f1e1c;
  --tool-border: #3d3d3a;
  --success:     #4ade80;
  --error:       #f87171;

  --serif: "Source Serif 4", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:  "SF Mono", ui-monospace, "Menlo", Consolas, "Courier New", monospace;

  --radius-sm:  6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow:    0 6px 24px rgba(0,0,0,0.32);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-top {
  padding: 18px 14px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.side-brand {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  padding: 0 4px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s;
  margin: 6px 0 0;
}
.new-chat-btn:hover {
  background: var(--surface);
  border-color: var(--surface-hi);
}
.new-chat-btn:active { transform: scale(0.98); }
.new-chat-btn .plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.side-section {
  padding: 20px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.refresh-btn {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: color 0.15s;
}
.refresh-btn:hover { color: var(--text); }

.sessions {
  list-style: none;
  margin: 0;
  padding: 2px 10px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.sessions li {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  transition: background 0.1s;
  position: relative;
}
.sessions li:hover {
  background: var(--surface);
  color: var(--text);
}
.sessions li.active {
  background: var(--surface);
  color: var(--text);
}
.sessions li.active::before {
  content: "";
  position: absolute;
  left: -4px; top: 9px; bottom: 9px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.sessions .title {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.sessions .meta {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  flex-shrink: 0;
}
.sessions .del {
  opacity: 0;
  background: transparent;
  color: var(--text-faint);
  border: 0;
  padding: 2px 4px;
  font-size: 12px;
  border-radius: 4px;
  transition: color 0.1s, opacity 0.1s;
}
.sessions li:hover .del { opacity: 1; }
.sessions li:hover .meta { display: none; }
.sessions .del:hover { color: var(--error); }

.sessions .empty-list {
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  cursor: default;
  font-style: italic;
}
.sessions .empty-list:hover {
  background: transparent;
  color: var(--text-faint);
}

/* sidebar footer (identity) */
.side-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 14px 14px 16px;
  background: var(--bg-sidebar);
}
.identity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.identity-row:last-child { margin-bottom: 0; }
.identity-row label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 40px;
  flex-shrink: 0;
}
.identity-row select,
.identity-row .id-input input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.identity-row select:hover,
.identity-row select:focus,
.identity-row .id-input input:focus {
  border-color: var(--accent-dim);
  background: var(--surface-hi);
}
.identity-row select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: right 10px top 12px, right 6px top 12px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 22px;
}
.id-input {
  flex: 1;
  display: flex;
  gap: 4px;
  min-width: 0;
}
.id-input input { flex: 1; min-width: 0; }
.id-input button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.id-input button:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.identity-row.tiny {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  justify-content: space-between;
}
#chatSub {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sessionCopyBtn {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-size: 10px;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color 0.15s;
}
#sessionCopyBtn:hover { color: var(--accent-hover); }

/* ── Chat pane ───────────────────────────────────────────────────── */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  position: relative;
}

.chat-head {
  padding: 18px 32px 14px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}
.chat-model {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
.knowledge-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--success);
  background: rgba(74, 222, 128, 0.06);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(74, 222, 128, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.knowledge-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse-glow 2s infinite ease-in-out;
}
@keyframes pulse-glow {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(74, 222, 128, 0);
  }
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
  }
}

/* log area */
.log {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 28px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
/* When the only child is the empty state, center it vertically. */
.log:has(> .empty:only-child) {
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

/* ── Messages ───────────────────────────────────────────────────── */
.msg {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
  animation: fadeIn 0.25s ease-out;
  flex-shrink: 0;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg .role { display: none; }

.msg.user {
  display: flex;
  justify-content: flex-end;
}
.msg.user .body {
  background: var(--user-bubble);
  padding: 12px 18px;
  border-radius: 18px;
  max-width: 85%;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
}

.msg.assistant .body {
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.68;
  word-wrap: break-word;
}

/* markdown inside assistant body */
.msg.assistant .body h1,
.msg.assistant .body h2,
.msg.assistant .body h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 18px 0 8px;
  line-height: 1.3;
}
.msg.assistant .body h1 { font-size: 22px; }
.msg.assistant .body h2 { font-size: 18px; }
.msg.assistant .body h3 { font-size: 16px; }
.msg.assistant .body p  { margin: 10px 0; }
.msg.assistant .body strong { color: var(--text); font-weight: 600; }
.msg.assistant .body em     { color: var(--text); font-style: italic; }
.msg.assistant .body ul,
.msg.assistant .body ol {
  margin: 10px 0;
  padding-left: 22px;
}
.msg.assistant .body li { margin: 4px 0; }
.msg.assistant .body code.inline-code {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-hover);
}
.msg.assistant .body pre.code-block {
  background: #1a1918;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.msg.assistant .body pre.code-block code { background: none; border: 0; padding: 0; color: inherit; }
.msg.assistant .body blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 2px 14px;
  margin: 12px 0;
  color: var(--text-muted);
  font-style: italic;
}
.msg.assistant .body hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 18px 0;
}
.msg.assistant .body table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.msg.assistant .body th,
.msg.assistant .body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg.assistant .body th {
  background: var(--surface);
  font-weight: 600;
}
.msg.assistant .body a { color: var(--accent-hover); }
.msg.assistant .body > *:first-child { margin-top: 0; }
.msg.assistant .body > *:last-child  { margin-bottom: 0; }

/* streaming cursor */
.typing .body::after {
  content: "▊";
  color: var(--accent);
  margin-left: 2px;
  font-size: 14px;
  vertical-align: baseline;
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ── Tool call card ─────────────────────────────────────────────── */
.tool {
  max-width: 760px;
  width: calc(100% - 64px);
  margin: 0 auto;
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
  flex-shrink: 0;
}
.tool.done { border-color: rgba(74, 222, 128, 0.28); }
.tool.err  { border-color: rgba(248, 113, 113, 0.40); }

.tool-head {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.tool-head:hover { background: rgba(255,255,255,0.02); }

.tool-status {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.3s ease-in-out infinite;
  flex-shrink: 0;
}
.tool.done .tool-status { background: var(--success); animation: none; }
.tool.err  .tool-status { background: var(--error);   animation: none; }

.tool-label {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tool-name {
  color: var(--accent-hover);
  font-weight: 600;
}
.tool-args {
  color: var(--text-faint);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tool-toggle {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-size: 11px;
  padding: 0 4px;
  transition: color 0.15s, transform 0.15s;
}
.tool.open .tool-toggle { transform: rotate(90deg); color: var(--text); }

.tool-body {
  border-top: 1px solid var(--tool-border);
  padding: 12px 14px;
  background: rgba(0,0,0,0.28);
  max-height: 360px;
  overflow: auto;
  display: none;
}
.tool.open .tool-body { display: block; }
.tool-body pre {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
}
.tool-body .label {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}
.tool-body .label:not(:first-child) { margin-top: 14px; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.78); }
}

/* ── Composer ───────────────────────────────────────────────────── */
.composer-wrap {
  padding: 14px 32px 22px;
  background: linear-gradient(to bottom, transparent, var(--bg) 28%);
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 10px 10px 20px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.composer:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
.composer textarea {
  flex: 1;
  background: transparent;
  border: 0;
  resize: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  padding: 9px 0;
  min-height: 24px;
  max-height: 220px;
  font-family: var(--sans);
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.send-btn {
  background: var(--accent);
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled {
  background: var(--surface-hi);
  color: var(--text-faint);
  cursor: not-allowed;
}

.composer-hint {
  max-width: 760px;
  margin: 9px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

/* ── Empty state ────────────────────────────────────────────────── */
.empty {
  margin: 0 auto;
  text-align: center;
  padding: 32px 32px 20px;
  max-width: 640px;
  width: 100%;
  animation: fadeIn 0.4s ease-out;
  flex-shrink: 0;
}
.empty h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.15;
}
.empty .sub {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0 0 24px;
  line-height: 1.55;
}
.empty .suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
  text-align: left;
}
.empty .suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.05s;
  font-family: var(--sans);
}
.empty .suggestion:hover {
  border-color: var(--accent-dim);
  color: var(--text);
  background: var(--surface-hi);
}
.empty .suggestion:active { transform: scale(0.99); }
.empty .suggestion .s-title {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 13px;
}

/* ── Scrollbars ─────────────────────────────────────────────────── */
.log::-webkit-scrollbar,
.sessions::-webkit-scrollbar,
.tool-body::-webkit-scrollbar {
  width: 8px;
}
.log::-webkit-scrollbar-thumb,
.sessions::-webkit-scrollbar-thumb,
.tool-body::-webkit-scrollbar-thumb {
  background: var(--surface);
  border-radius: 4px;
}
.log::-webkit-scrollbar-thumb:hover,
.sessions::-webkit-scrollbar-thumb:hover {
  background: var(--surface-hi);
}
.log::-webkit-scrollbar-track,
.sessions::-webkit-scrollbar-track,
.tool-body::-webkit-scrollbar-track { background: transparent; }

/* ── Narrow screens ─────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .msg, .composer-wrap { padding-left: 16px; padding-right: 16px; }
  .tool { width: calc(100% - 32px); }
  .chat-head { padding: 14px 18px; }
  .empty h1 { font-size: 30px; }
  .empty .suggestions { grid-template-columns: 1fr; }
}

/* ── Thinking & Tool dropdowns inside assistant messages ────────── */
.thinking-container {
  max-width: 760px;
  width: 100%;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0 18px;
  overflow: hidden;
  font-size: 13px;
  transition: border-color 0.2s;
}
.thinking-container[open] {
  border-color: var(--accent-dim);
}
.thinking-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: var(--text-muted);
  outline: none;
  list-style: none;
}
.thinking-header::-webkit-details-marker {
  display: none;
}
.thinking-icon {
  font-size: 14px;
}
.thinking-title {
  flex: 1;
}
.thinking-chevron {
  font-size: 12px;
  color: var(--text-faint);
  transition: transform 0.25s ease;
  font-family: var(--mono);
}
.thinking-container[open] .thinking-chevron {
  transform: rotate(180deg);
}
.thinking-content {
  border-top: 1px solid var(--border);
  padding: 14px;
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reasoning-block {
  font-style: italic;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
  border-left: 2px solid var(--accent-dim);
  padding-left: 10px;
  margin: 0 0 6px;
  white-space: pre-wrap;
}
.thinking-content .tool {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

/* ── Transient Tool Status (Come and Vanish) ─────────────────── */
.transient-tool-status {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-hover);
  font-family: var(--mono);
  font-size: 12.5px;
  animation: fadeIn 0.2s ease-out;
}
.transient-tool-status code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: var(--text);
}
.tool-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Markdown Tables ─────────────────────────────────────────── */
.msg .body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.msg .body th, .msg .body td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg .body th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.msg .body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.msg .body tr:hover {
  background: rgba(201, 100, 66, 0.05);
}

/* ── LaTeX Math Elements (KaTeX) ─────────────────────────────── */
.math-block {
  margin: 18px 0;
  padding: 14px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.math-inline {
  padding: 1px 3px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
  font-size: 1.05em;
  vertical-align: middle;
}
.math-error {
  color: var(--error);
  font-family: var(--mono);
  background: rgba(248, 113, 113, 0.08);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Fenced code block enhancements */
.msg .body pre.code-block {
  background: #1e1e1c !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 14px 0;
  overflow-x: auto;
}
.hljs {
  background: transparent !important;
  padding: 0 !important;
}
