:root {
  --prose: #dedfd8;
  --prose-bright: #f4f4ee;
  --prose-muted: #9a9d93;
  --prose-line: #363a31;
  --code-surface: #11130f;
  --code-top: #1b1e18;
  --aqua: #7ee8d2;
  --violet: #c6a7ff;
}

.message > div:last-child { min-width: 0; }
.message.assistant .message-content {
  position: relative;
  max-width: 820px;
  color: var(--prose);
  font-size: 15px;
  line-height: 1.78;
  letter-spacing: .006em;
  overflow-wrap: anywhere;
}
.message.assistant .message-content:before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -22px -28px;
  border-radius: 18px;
  background: radial-gradient(80% 100% at 0 0, #c8f55b08, transparent 62%);
  pointer-events: none;
}
.message-content > :first-child { margin-top: 0 !important; }
.message-content > :last-child { margin-bottom: 0 !important; }
.message-content p { margin: 0 0 1em; }
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  color: var(--prose-bright);
  font-weight: 680;
  line-height: 1.28;
  text-wrap: balance;
}
.message-content h1 { margin: 1.8em 0 .7em; font-size: 1.72em; letter-spacing: -.035em; }
.message-content h2 { margin: 1.65em 0 .65em; padding-bottom: .45em; border-bottom: 1px solid var(--prose-line); font-size: 1.38em; letter-spacing: -.025em; }
.message-content h3 { margin: 1.45em 0 .55em; font-size: 1.14em; }
.message-content h4 { margin: 1.3em 0 .5em; font-size: 1em; color: #d5dfa9; }
.message-content strong { color: var(--prose-bright); font-weight: 680; }
.message-content em { color: #d7e6b4; }
.message-content s { color: #797d73; text-decoration-color: #8d5d59; }
.message-content a {
  color: var(--acid);
  text-decoration: none;
  background: linear-gradient(var(--acid), var(--acid)) 0 100% / 100% 1px no-repeat;
  transition: color .16s ease, background-size .16s ease;
}
.message-content a:hover { color: #e1ff91; background-size: 100% 2px; }
.message-content ul,
.message-content ol { margin: .7em 0 1.1em; padding-left: 1.55em; }
.message-content li { margin: .38em 0; padding-left: .2em; }
.message-content li::marker { color: var(--acid-dim); font: 600 .9em ui-monospace, monospace; }
.message-content li > ul,
.message-content li > ol { margin: .3em 0; }
.message-content .task-list-item { list-style: none; margin-left: -1.35em; }
.task-checkbox {
  width: 15px;
  height: 15px;
  margin: 0 .55em 0 0;
  vertical-align: -.15em;
  accent-color: var(--acid);
}
.message-content blockquote {
  position: relative;
  margin: 1.25em 0;
  padding: .9em 1.1em .9em 1.25em;
  border: 1px solid #353b2d;
  border-left: 3px solid var(--acid-dim);
  border-radius: 0 10px 10px 0;
  background: linear-gradient(90deg, #c8f55b0a, #181a170f);
  color: #bec2b5;
}
.message-content blockquote p:last-child { margin-bottom: 0; }
.message-content hr { height: 1px; margin: 2em 0; border: 0; background: linear-gradient(90deg, transparent, #44493c 18%, #44493c 82%, transparent); }
.message-content :not(pre) > code {
  padding: .17em .42em;
  border: 1px solid #3b4036;
  border-radius: 5px;
  background: #20231d;
  color: #d8ef9d;
  font: .88em/1.4 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.code-block {
  margin: 1.35em 0;
  overflow: hidden;
  border: 1px solid #34392f;
  border-radius: 12px;
  background: var(--code-surface);
  box-shadow: 0 14px 35px #0003, inset 0 1px #ffffff05;
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px 0 15px;
  border-bottom: 1px solid #30342c;
  background: linear-gradient(180deg, #20231d, var(--code-top));
}
.code-toolbar span { color: #8d9384; font: 600 10px ui-monospace, monospace; letter-spacing: .13em; text-transform: uppercase; }
.copy-code {
  min-width: 54px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #989e8e;
  font: 11px ui-monospace, monospace;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.copy-code:hover { border-color: #444b3b; background: #282c23; color: var(--acid); }
.code-block pre { max-height: 620px; margin: 0; padding: 17px 19px 20px; overflow: auto; background: transparent; tab-size: 2; }
.code-block pre::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.math-block::-webkit-scrollbar { width: 8px; height: 8px; }
.code-block pre::-webkit-scrollbar-thumb,
.math-block::-webkit-scrollbar-thumb { border-radius: 8px; background: #3b4036; }
.code-block code { display: block; min-width: max-content; padding: 0; border: 0; background: none; color: #d5d8ce; font: 12.5px/1.68 "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.hljs-comment,.hljs-quote { color: #747a6c; font-style: italic; }
.hljs-keyword,.hljs-selector-tag,.hljs-literal { color: var(--violet); }
.hljs-string,.hljs-attr,.hljs-template-tag { color: #b9dc7d; }
.hljs-number,.hljs-symbol,.hljs-bullet { color: #f1b77c; }
.hljs-title,.hljs-section,.hljs-function .hljs-title { color: var(--aqua); }
.hljs-variable,.hljs-template-variable,.hljs-params { color: #e2d6aa; }
.hljs-type,.hljs-built_in { color: #efcf76; }
.hljs-meta,.hljs-meta .hljs-keyword { color: #8bc4ef; }
.hljs-deletion { color: #ff8c84; background: #ff746c0d; }
.hljs-addition { color: #bde87e; background: #c8f55b0a; }
.message-content table {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 1.35em 0;
  overflow-x: auto;
  border: 1px solid #363a31;
  border-spacing: 0;
  border-radius: 10px;
  background: #171914;
  font-size: .91em;
}
.message-content th,
.message-content td { min-width: 110px; padding: 10px 14px; border-right: 1px solid #30342c; border-bottom: 1px solid #30342c; text-align: left; }
.message-content th { position: sticky; top: 0; background: #20231d; color: #e8eadf; font: 650 11px ui-monospace, monospace; letter-spacing: .04em; }
.message-content tr:last-child td { border-bottom: 0; }
.message-content th:last-child,
.message-content td:last-child { border-right: 0; }
.message-content tbody tr:hover { background: #c8f55b05; }
.math-inline { display: inline-block; max-width: 100%; padding: 0 .08em; vertical-align: -.08em; color: #eef6d6; }
.math-block {
  position: relative;
  margin: 1.4em 0;
  padding: 20px 24px;
  overflow-x: auto;
  border: 1px solid #363c2f;
  border-radius: 12px;
  background: radial-gradient(100% 140% at 0 0, #c8f55b0a, transparent 55%), #151713;
  color: #f0f7de;
  text-align: center;
  box-shadow: inset 3px 0 var(--acid-dim), 0 12px 32px #0002;
}
.math-block .katex-display { margin: 0; }
.math-block .katex { font-size: 1.12em; }
.math-error { color: #ff9d95; font: .9em ui-monospace, monospace; }

@media (max-width: 760px) {
  .message.assistant .message-content { font-size: 14px; line-height: 1.72; }
  .message.assistant .message-content:before { inset: -15px -12px; }
  .message-content h1 { font-size: 1.5em; }
  .message-content h2 { font-size: 1.26em; }
  .code-block { margin-right: -4px; border-radius: 9px; }
  .code-block pre { padding: 15px; }
  .code-block code { font-size: 12px; }
  .math-block { margin-right: -4px; padding: 17px 14px; text-align: left; }
  .message-content th,
  .message-content td { min-width: 96px; padding: 9px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .message-content a,
  .copy-code { transition: none; }
}
