/* llama.online — rendered Markdown, code blocks and message layout (chat app, tool widget, share view). Needs tokens.css. */

/* Fallback copy of the site tokens (assets/css/tokens.css, same names). Layered, so the unlayered tokens.css always wins;
   only tokens it lacks fall through to these values. */
@layer cg-fallback {
  :root {
    color-scheme: light;
    --espresso: #1D1713; --marigold: #F2A93B; --teal: #0E6B66; --terracotta: #D45D3A; --coral: #B4472A;
    --coral-soft: #F8E0D6; --teal-soft: #DCEFEC;
    --bg: #F7F2EA; --bg-soft: #F1EADF; --surface: #FFFDF9; --surface-2: #F4EEE4;
    --border: #E6DCCD; --border-strong: #D3C5B1;
    --text: #1D1713; --text-soft: #3C332C; --muted: #6B6159;
    --accent: #F2A93B; --accent-hover: #E89A26; --accent-2: #D45D3A; --accent-ink: #0E6B66; --accent-soft: #FCEBCB;
    --accent-grad: linear-gradient(135deg, #F6B957 0%, #F2A93B 55%, #EA9631 100%); --on-accent: #1D1713;
    --success: #2E7D4F; --danger: #B93A26;
    --radius-sm: 10px; --radius: 16px; --radius-lg: 22px; --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(60, 40, 20, .06);
    --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 8px 24px -10px rgba(60, 40, 20, .16);
    --shadow-lg: 0 2px 6px rgba(60, 40, 20, .05), 0 26px 60px -20px rgba(60, 40, 20, .28);
    --ring: 0 0 0 3px rgba(14, 107, 102, .32);
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-display: "Bricolage Grotesque", var(--font);
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --ease: cubic-bezier(.2, .7, .2, 1);
  }
  [data-theme="dark"] {
    color-scheme: dark;
    --marigold: #F5B44E; --teal: #3FB8AE; --terracotta: #E07A57; --coral: #EE8F6C;
    --coral-soft: rgba(224, 122, 87, .16); --teal-soft: rgba(63, 184, 174, .14);
    --bg: #14110F; --bg-soft: #191512; --surface: #1E1A17; --surface-2: #26211D;
    --border: #332C26; --border-strong: #463D35;
    --text: #F3ECE2; --text-soft: #DCD2C5; --muted: #A69A8D;
    --accent: #F5B44E; --accent-hover: #F8C36D; --accent-2: #E07A57; --accent-ink: #3FB8AE; --accent-soft: rgba(245, 180, 78, .14);
    --accent-grad: linear-gradient(135deg, #F8C46A 0%, #F5B44E 55%, #EDA03E 100%); --on-accent: #1D1713;
    --success: #5CC98C; --danger: #F07A63;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .55);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 30px 70px -20px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(63, 184, 174, .45);
  }
}

:root { --cg-fs: 16px; --cg-code-bg: #1C1713; --cg-code-head: #261F1A; --cg-code-text: #F1E8DC; }
:root[data-cg-font="s"] { --cg-fs: 15px; }
:root[data-cg-font="l"] { --cg-fs: 17.5px; }
[data-theme="dark"] { --cg-code-bg: #0F0C0A; --cg-code-head: #191411; }

.cg-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- markdown ---------- */
.cg-md { font-size: var(--cg-fs); line-height: 1.72; color: var(--text); overflow-wrap: anywhere; min-width: 0; }
.cg-md > :first-child { margin-top: 0; }
.cg-md > :last-child { margin-bottom: 0; }
.cg-md p, .cg-md ul, .cg-md ol, .cg-md blockquote, .cg-md .cg-table, .cg-md .cg-code { margin: 0 0 .95em; }
.cg-md h1, .cg-md h2, .cg-md h3, .cg-md h4, .cg-md h5, .cg-md h6 { font-weight: 650; line-height: 1.3; letter-spacing: -.012em; margin: 1.5em 0 .55em; color: var(--text); }
.cg-md h1 { font-size: 1.5em; }
.cg-md h2 { font-size: 1.3em; }
.cg-md h3 { font-size: 1.14em; }
.cg-md h4, .cg-md h5, .cg-md h6 { font-size: 1em; }
.cg-md ul, .cg-md ol { padding-inline-start: 1.5em; }
.cg-md li { margin: .3em 0; }
.cg-md li > p { margin: .3em 0; }
.cg-md li > ul, .cg-md li > ol { margin: .25em 0; }
.cg-md li::marker { color: var(--muted); }
.cg-md ol > li::marker { font-variant-numeric: tabular-nums; }
.cg-md strong { font-weight: 650; }
.cg-md a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent-ink) 35%, transparent); text-underline-offset: 2px; }
.cg-md a:hover { text-decoration-color: currentColor; }
.cg-md hr { border: 0; height: 1px; background: var(--border); margin: 1.6em 0; }
.cg-md blockquote { padding: .1em 0; padding-inline-start: 1em; border-inline-start: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); color: var(--text-soft); }
.cg-md :not(pre) > code { font-family: var(--font-mono); font-size: .875em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .08em .38em; }
.cg-md input[type="checkbox"] { margin-inline-end: .45em; vertical-align: -1px; accent-color: var(--accent); }
.cg-md li:has(> input[type="checkbox"]) { list-style: none; margin-inline-start: -1.3em; }
.cg-md-raw { white-space: pre-wrap; }

/* tables */
.cg-table { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.cg-md table { border-collapse: collapse; width: 100%; font-size: .93em; line-height: 1.5; }
.cg-md th, .cg-md td { padding: 9px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); }
.cg-md th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
.cg-md tr:last-child td { border-bottom: 0; }
.cg-md td + td, .cg-md th + th { border-inline-start: 1px solid var(--border); }

/* code blocks */
.cg-code { background: var(--cg-code-bg); border-radius: 14px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .06); direction: ltr; text-align: left; }
[data-theme="dark"] .cg-code { border-color: var(--border-strong); }
.cg-code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 5px 14px; background: var(--cg-code-head); color: #B9AA99; font: 500 12px/1.4 var(--font-mono); }
.cg-code-lang { text-transform: lowercase; }
.cg-code-copy { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: #CDBFAF; font: 500 12px var(--font); cursor: pointer; }
.cg-code-copy:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.cg-code-copy.is-done { color: #3DD68C; }
.cg-code-copy:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.cg-code pre { margin: 0; padding: 14px 16px 16px; overflow-x: auto; font: 13.5px/1.65 var(--font-mono); color: var(--cg-code-text); tab-size: 4; -webkit-overflow-scrolling: touch; }
.cg-code pre code { font: inherit; background: none; border: 0; padding: 0; white-space: pre; }

/* highlight.js tokens (dark code surface in both themes) */
.hljs-comment, .hljs-quote { color: #8E8072; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section, .hljs-name { color: #F5B44E; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: #7FD1C7; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: #F0906E; }
.hljs-title, .hljs-title.function_, .hljs-selector-id { color: #F2D492; }
.hljs-title.class_, .hljs-type, .hljs-built_in, .hljs-class .hljs-title { color: #E8B86B; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-selector-class, .hljs-property { color: #E59A7F; }
.hljs-params { color: #E3D9CC; }
.hljs-meta, .hljs-meta .hljs-keyword { color: #9CC9C2; }
.hljs-deletion { color: #FF8A8F; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- messages (shared by chat + share view) ---------- */
.cg-thread { display: flex; flex-direction: column; gap: 30px; }
.cg-msg { position: relative; }
.cg-msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.cg-bubble { max-width: min(85%, 640px); padding: 10px 17px; border-radius: 22px; background: color-mix(in srgb, var(--accent) 17%, var(--surface)); color: var(--text); font-size: var(--cg-fs); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-theme="dark"] .cg-bubble { background: #2E2721; }
.cg-uimg { margin: 0 0 6px; max-width: min(85%, 300px); }
.cg-uimg img { display: block; max-width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--border); background: var(--surface-2); }
.cg-actions-static { opacity: 1; }
.cg-msg-ai { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; align-items: start; }
.cg-msg-ai:not(:has(.cg-avatar)) { grid-template-columns: minmax(0, 1fr); }
.cg-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-top: 1px; }
.cg-msg-body { min-width: 0; }
.cg-share-thread { max-width: 760px; margin: 0 auto; }
