/* gpt.me — rendered Markdown, code blocks and message layout (chat app, tool widget, share view), "Graphite".
   The chat's own colour tokens (--cg-*) are defined here with the exact Graphite values, so the chat looks the same
   whatever the site's tokens.css calls things; fonts and motion come from tokens.css (fallbacks below). */

@layer cg-fallback {
  :root {
    --font: "Geist", "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-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --radius-pill: 999px;
  }
}

/* Graphite: dark (default) and light; without data-theme the system preference decides. */
:root, [data-theme="dark"] {
  --cg-bg: #131315; --cg-surface: #1C1C1F; --cg-raised: #232327; --cg-bubble: #26262A;
  --cg-border: #2E2E33; --cg-border-subtle: #232327;
  --cg-text: #F1F1F3; --cg-text-2: #D4D4D8; --cg-muted: #8D8D95; --cg-ph: #6E6E76;
  --cg-brand: #8B9CFF; --cg-pressed: #2A2A2F; --cg-bolt: #F5B301;
  --cg-success: #22A06B; --cg-warning: #F07D26; --cg-danger: #EF4444;
  --cg-backdrop: rgba(0, 0, 0, .6);
  --cg-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  --cg-shadow-pop: 0 12px 40px rgba(0, 0, 0, .45);
  --cg-code-bg: #0F0F11; --cg-code-head: #18181B; --cg-code-text: #E8E8EC;
}
[data-theme="light"] {
  --cg-bg: #FFFFFF; --cg-surface: #F4F4F5; --cg-raised: #FFFFFF; --cg-bubble: #F0F0F2;
  --cg-border: #E4E4E7; --cg-border-subtle: #EDEDF0;
  --cg-text: #18181B; --cg-text-2: #3F3F46; --cg-muted: #6B6B73; --cg-ph: #A1A1AA;
  --cg-brand: #4F5FE8; --cg-pressed: #EBEBEE; --cg-bolt: #D99A00;
  --cg-backdrop: rgba(24, 24, 27, .4);
  --cg-shadow: 0 8px 30px rgba(0, 0, 0, .08);
  --cg-shadow-pop: 0 12px 40px rgba(24, 24, 27, .14);
  --cg-code-bg: #18181B; --cg-code-head: #232327;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --cg-bg: #FFFFFF; --cg-surface: #F4F4F5; --cg-raised: #FFFFFF; --cg-bubble: #F0F0F2;
    --cg-border: #E4E4E7; --cg-border-subtle: #EDEDF0;
    --cg-text: #18181B; --cg-text-2: #3F3F46; --cg-muted: #6B6B73; --cg-ph: #A1A1AA;
    --cg-brand: #4F5FE8; --cg-pressed: #EBEBEE; --cg-bolt: #D99A00;
    --cg-backdrop: rgba(24, 24, 27, .4);
    --cg-shadow: 0 8px 30px rgba(0, 0, 0, .08);
    --cg-shadow-pop: 0 12px 40px rgba(24, 24, 27, .14);
    --cg-code-bg: #18181B; --cg-code-head: #232327;
  }
}
:root { --cg-fs: 16px; --ring: 0 0 0 2px color-mix(in srgb, var(--cg-brand) 60%, transparent); }
:root[data-cg-font="s"] { --cg-fs: 15px; }
:root[data-cg-font="l"] { --cg-fs: 17.5px; }

.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.65; color: var(--cg-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 .9em; }
.cg-md h1, .cg-md h2, .cg-md h3, .cg-md h4, .cg-md h5, .cg-md h6 { font-weight: 600; line-height: 1.3; letter-spacing: -.012em; margin: 1.4em 0 .5em; color: var(--cg-text); }
.cg-md h1 { font-size: 1.45em; }
.cg-md h2 { font-size: 1.25em; }
.cg-md h3 { font-size: 1.12em; }
.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(--cg-muted); }
.cg-md ol > li::marker { font-variant-numeric: tabular-nums; }
.cg-md strong { font-weight: 600; }
.cg-md a { color: var(--cg-brand); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--cg-brand) 40%, transparent); text-underline-offset: 2px; }
.cg-md a:hover { text-decoration-color: currentColor; }
.cg-md hr { border: 0; height: 1px; background: var(--cg-border); margin: 1.6em 0; }
.cg-md blockquote { padding: .1em 0; padding-inline-start: 1em; border-inline-start: 3px solid var(--cg-border); color: var(--cg-text-2); }
.cg-md :not(pre) > code { font-family: var(--font-mono); font-size: .875em; background: var(--cg-surface); border: 1px solid var(--cg-border); border-radius: 6px; padding: .08em .38em; }
.cg-md input[type="checkbox"] { margin-inline-end: .45em; vertical-align: -1px; accent-color: var(--cg-brand); }
.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(--cg-border); border-radius: 14px; -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(--cg-border); }
.cg-md th { background: var(--cg-surface); 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(--cg-border); }

/* code blocks (dark surface in both themes) */
.cg-code { background: var(--cg-code-bg); border-radius: 14px; overflow: hidden; border: 1px solid var(--cg-border); direction: ltr; text-align: left; }
.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: #A1A1AA; 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: #C4C4CC; 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: #4ADE80; }
.cg-code-copy:focus-visible { outline: 2px solid #8B9CFF; 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 */
.hljs-comment, .hljs-quote { color: #7A7A85; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section, .hljs-name { color: #A5B4FF; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: #A8DDA0; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: #F5C078; }
.hljs-title, .hljs-title.function_, .hljs-selector-id { color: #E8ECFF; }
.hljs-title.class_, .hljs-type, .hljs-built_in, .hljs-class .hljs-title { color: #D2B8FF; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-selector-class, .hljs-property { color: #92D2E8; }
.hljs-params { color: #E4E4E7; }
.hljs-meta, .hljs-meta .hljs-keyword { color: #A1A1AA; }
.hljs-deletion { color: #FF8A8F; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- messages (shared by chat + share view): answers are plain text, the user's messages are bubbles ---------- */
.cg-thread { display: flex; flex-direction: column; gap: 28px; }
.cg-msg { position: relative; }
.cg-msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.cg-bubble { max-width: 82%; padding: 11px 15px; border-radius: 22px 22px 6px 22px; background: var(--cg-bubble); color: var(--cg-text); font-size: var(--cg-fs); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
[dir="rtl"] .cg-bubble { border-radius: 22px 22px 22px 6px; }
.cg-uimg { margin: 0 0 6px; max-width: min(82%, 300px); }
.cg-uimg img { display: block; max-width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--cg-border); background: var(--cg-surface); }
.cg-actions-static { opacity: 1; }
.cg-msg-ai { display: block; }
.cg-msg-body { min-width: 0; }
.cg-share-thread { max-width: 768px; margin: 0 auto; }
.cg-share-thread .cg-mlabel { color: var(--cg-muted); font-size: 12px; }

/* Promo panels shared by the chat dialogs and the tool widget (core.js limitPanel / imageCard): text, promo 'modal'
   blocks (promo.js draws them), the bonus button with its countdown. */
.cg-lim-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--cg-text); }
.cg-lim-title .cg-i { color: var(--cg-text-2); }
.cg-lim-text { margin: 0 0 14px; font-size: 14.5px; line-height: 1.55; color: var(--cg-text-2); }
.cg-lim-promos { display: grid; gap: 10px; }
.cg-lim-promos:empty { display: none; }
.cg-lim-promo { min-width: 0; }
.cg-lim-promo > * { max-width: 100%; }
.cg-lim-acts { display: flex; justify-content: center; margin-top: 16px; }
.cg-lim-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 24px; border: 0; border-radius: var(--radius-pill, 999px); background: var(--cg-text); color: var(--cg-bg); font: inherit; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; transition: opacity .15s; }
.cg-lim-btn:disabled { opacity: .45; cursor: default; }
.cg-lim-btn.is-busy { opacity: .7; cursor: progress; }
.cg-lim-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.cg-lim-err { margin: 10px 0 0; text-align: center; font-size: 13.5px; color: var(--cg-danger); }
.cg-imgno { display: grid; gap: 10px; max-width: 560px; }
.cg-imgno-text { display: flex; align-items: flex-start; gap: 9px; margin: 0; font-size: var(--cg-fs, 15px); line-height: 1.6; color: var(--cg-text); }
.cg-imgno-text .cg-i { flex: none; margin-top: 3px; color: var(--cg-muted); }
@media (max-width: 640px) { .cg-lim-btn { width: 100%; } }
