/* uplevate-ai chat UI. Colours come from styles/theme.css tokens (dark by default,
   [data-theme="light"] swaps them). */

/* ── layout ─────────────────────────────────────────────────────────────── */
.chat-app { display: grid; grid-template-columns: 264px minmax(0, 1fr) auto; height: calc(100dvh - var(--nav-h, 49px)); position: relative; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.main-head { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; border-bottom: 1px solid var(--border); min-height: 48px; }
.main-title { flex: 1; font-size: .95rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.files-btn.on { color: var(--brand-strong); border-color: var(--brand); background: var(--brand-soft); }
.only-mobile { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-faint); font-size: .85rem; }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .8rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .88rem; text-decoration: none; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--border-strong); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; border: 0; background: transparent;
  color: var(--text-soft); cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ico { flex: none; }
.ico.good { color: var(--accent); }
.ico.bad { color: var(--danger); }

/* ── sidebar ────────────────────────────────────────────────────────────── */
.side { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); min-height: 0; }
.new-chat { margin: .75rem; padding: .55rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: .4rem; transition: border-color .15s, box-shadow .15s; }
.new-chat:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.side-list { flex: 1; overflow-y: auto; padding: 0 .5rem 1rem; }
.side-group h4 { margin: .9rem .5rem .3rem; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.side-item { display: flex; align-items: center; border-radius: 8px; position: relative; }
.side-item:hover { background: var(--surface-2); }
.side-item.on { background: var(--brand-soft); }
.side-item.on .side-link { color: var(--text); font-weight: 500; }
.side-link { flex: 1; min-width: 0; padding: .45rem .6rem; color: var(--text-soft); text-decoration: none; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-acts { display: none; padding-right: .2rem; }
.side-item:hover .side-acts, .side-item:focus-within .side-acts { display: flex; }
.side-rename input { width: 100%; padding: .4rem .55rem; border-radius: 8px; border: 1px solid var(--brand); background: var(--bg); color: var(--text); font: inherit; font-size: .9rem; }
.side-empty { padding: .5rem .6rem; }
.side-skel span { display: block; height: 14px; margin: .7rem .6rem; border-radius: 6px; background: var(--surface-2); animation: pulse-bg 1.4s ease-in-out infinite; }
.side-skel span:nth-child(2) { width: 70%; } .side-skel span:nth-child(3) { width: 85%; } .side-skel span:nth-child(4) { width: 55%; }
.side-scrim { display: none; }

/* ── feed ───────────────────────────────────────────────────────────────── */
.feed-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.feed { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 2rem; }
.feed-inner { max-width: 48rem; margin: 0 auto; padding: 1.5rem 1.25rem 2rem; }
.turn { margin-bottom: 1.8rem; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; margin-bottom: 1rem; }
.msg-user .bubble { max-width: min(78%, 36rem); padding: .65rem .95rem; border-radius: 18px 18px 6px 18px; background: var(--surface-2);
  border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg-agent { line-height: 1.65; }
.agent-text + .agent-text, .steps + .agent-text, .agent-text + .steps { margin-top: .6rem; }
.note { color: var(--text-faint); font-size: .85rem; font-style: italic; margin: .5rem 0; }
.note.err { color: var(--danger); font-style: normal; background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 10px; padding: .6rem .8rem; }
.msg-actions { display: flex; gap: .15rem; margin-top: .35rem; opacity: 0; transition: opacity .15s; }
.turn:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.working { display: flex; align-items: center; gap: .55rem; color: var(--text-soft); font-size: .9rem; margin-top: .5rem; }

.jump { position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%); display: inline-flex; align-items: center; gap: .3rem;
  padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); cursor: pointer; font-size: .85rem; animation: rise .2s ease-out; z-index: 3; }

/* attachments shown on a sent message */
.att-row { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; max-width: 78%; }
.att { display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.att:hover { border-color: var(--brand); }
.att-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.att-text b { font-weight: 500; font-size: .85rem; max-width: 14rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-text small { color: var(--text-faint); font-size: .72rem; }
.att-img { padding: 0; overflow: hidden; }
.att-img img { display: block; height: 96px; max-width: 200px; object-fit: cover; }

/* ── the orb ────────────────────────────────────────────────────────────── */
@property --orb-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.orb { --orb-size: 28px; --c1: #4c6ef5; --c2: #20c997; --c3: #7c5cff; --c4: #22b8cf; --spin: 6s;
  position: relative; display: inline-block; flex: none; width: var(--orb-size); height: var(--orb-size); isolation: isolate; }
.orb-core, .orb::before { position: absolute; inset: 0; border-radius: 50%; }
.orb-core { background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), transparent 42%),
    conic-gradient(from var(--orb-a), var(--c1), var(--c3), var(--c2), var(--c4), var(--c1));
  animation: orb-spin var(--spin) linear infinite; box-shadow: inset 0 0 calc(var(--orb-size) * .18) rgba(0,0,0,.25); }
.orb::before { content: ''; z-index: -1; inset: -35%; background: conic-gradient(from var(--orb-a), var(--c1), var(--c2), var(--c3), var(--c1));
  filter: blur(calc(var(--orb-size) * .35)); opacity: .55; animation: orb-spin var(--spin) linear infinite reverse, orb-breathe 3.2s ease-in-out infinite; }
.orb-glint { position: absolute; inset: 18% 22% auto auto; width: 22%; height: 22%; border-radius: 50%; background: rgba(255,255,255,.7); filter: blur(1px); opacity: .7; }
.orb[data-state="idle"] { --spin: 18s; }
.orb[data-state="idle"]::before { opacity: .35; }
.orb[data-state="asleep"] { --spin: 40s; filter: saturate(.25) brightness(.8); }
.orb[data-state="asleep"]::before { opacity: .12; animation: none; }
.orb[data-state="waking"] { --spin: 4.5s; }
.orb[data-state="connecting"] { --spin: 2.6s; --c3: #5c7cfa; }
.orb[data-state="thinking"] { --spin: 1.8s; --c1: #7c5cff; --c3: #e64980; --c2: #4c6ef5; --c4: #20c997; }
.orb[data-state="error"] { --c1: #f03e3e; --c2: #ff8787; --c3: #c92a2a; --c4: #ffa8a8; --spin: 10s; }
@keyframes orb-spin { to { --orb-a: 360deg; } }
@keyframes orb-breathe { 0%, 100% { transform: scale(.92); } 50% { transform: scale(1.12); } }

.phase-line { display: flex; align-items: center; gap: .9rem; padding: .4rem 0; animation: rise .25s ease-out; }
.phase-text { display: flex; flex-direction: column; gap: .15rem; }
.phase-main { font-weight: 500; }
.phase-sub { font-size: .82rem; color: var(--text-faint); }

/* text that is still happening */
.shimmer { background: linear-gradient(90deg, var(--text-soft) 0%, var(--text) 45%, var(--text-soft) 90%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2.2s linear infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pulse-bg { 50% { opacity: .5; } }
.spin { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── steps ──────────────────────────────────────────────────────────────── */
.steps { border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 70%, transparent); margin: .3rem 0 .6rem; }
.steps > summary { display: flex; align-items: center; gap: .55rem; padding: .5rem .75rem; cursor: pointer; list-style: none; color: var(--text-soft); font-size: .88rem; user-select: none; }
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s; opacity: .6; }
.steps[open] > summary::after { transform: rotate(45deg); }
.steps.live { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.steps-count { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--text-faint); }
.step-list { list-style: none; margin: 0; padding: .1rem .5rem .5rem 1.05rem; position: relative; }
.step-list::before { content: ''; position: absolute; left: 1.35rem; top: .2rem; bottom: .9rem; width: 1px; background: var(--border); }
.step { position: relative; font-size: .87rem; }
.step > details > summary, .step-head { display: flex; align-items: center; gap: .5rem; padding: .32rem .35rem; border-radius: 7px; color: var(--text-soft); list-style: none; }
.step > details > summary { cursor: pointer; }
.step > details > summary::-webkit-details-marker { display: none; }
.step > details > summary:hover { background: var(--surface-2); color: var(--text); }
.step .ico { background: var(--surface); border-radius: 4px; }
.step-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-meta { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-faint); font-size: .78rem; }
.step[data-status="running"] .step-label { color: var(--text); }
.step[data-status="failed"] .step-label { color: var(--danger); }
.step-body { margin: .15rem 0 .5rem 1.75rem; display: flex; flex-direction: column; gap: .4rem; animation: rise .15s ease-out; }
.step-body pre { margin: 0; max-height: 18rem; overflow: auto; font-size: .78rem; line-height: 1.45; padding: .55rem .7rem; border-radius: 8px;
  background: var(--code-bg); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; }
.step-cmd .prompt { color: var(--accent-text); user-select: none; }
.step-diff { display: flex; flex-direction: column; gap: 2px; }
.step-diff pre.del { background: color-mix(in srgb, var(--danger) 12%, var(--code-bg)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.step-diff pre.add { background: color-mix(in srgb, var(--accent) 12%, var(--code-bg)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.step-open, .step-link { align-self: flex-start; display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; padding: .25rem .6rem; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-open:hover, .step-link:hover { border-color: var(--brand); color: var(--text); }
.step-thought .reason-text { margin: .1rem 0 .5rem 1.75rem; padding-left: .7rem; border-left: 2px solid var(--border); color: var(--text-faint);
  font-size: .84rem; white-space: pre-wrap; max-height: 22rem; overflow: auto; }

/* ── cards that need the user ───────────────────────────────────────────── */
.card-cb { border: 1px solid color-mix(in srgb, var(--brand) 55%, var(--border)); background: var(--surface); border-radius: 14px; padding: .9rem 1rem;
  margin: .6rem 0; box-shadow: 0 0 0 4px var(--brand-soft); animation: rise .2s ease-out; }
.card-cb.done { box-shadow: none; opacity: .65; border-color: var(--border); }
.card-cb:focus { outline: none; }
.cb-title { display: flex; align-items: center; gap: .4rem; font-weight: 600; margin-bottom: .55rem; }
.cb-what { margin: 0 0 .7rem; padding: .55rem .7rem; border-radius: 8px; background: var(--code-bg); font-size: .82rem; white-space: pre-wrap; word-break: break-word; max-height: 12rem; overflow: auto; }
.cb-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.cb-free { display: flex; gap: .45rem; margin-top: .6rem; }
.cb-free input { flex: 1; padding: .45rem .65rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.cb-done { color: var(--text-faint); font-size: .85rem; }

/* ── empty state ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 12vh 1rem 2rem; display: flex; flex-direction: column; align-items: center; animation: rise .35s ease-out; }
.empty h2 { margin: 1.4rem 0 .4rem; font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; }
.empty p { margin: 0 0 1.6rem; color: var(--text-soft); max-width: 30rem; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 15rem)); gap: .6rem; }
.chip { text-align: left; padding: .75rem .9rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font: inherit; font-size: .9rem; transition: border-color .15s, transform .15s, box-shadow .15s; }
.chip:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: 0 4px 16px var(--brand-soft); }
.skel { padding-top: 2rem; }
.skel span { display: block; height: 14px; margin: 1rem 0; border-radius: 6px; background: var(--surface-2); animation: pulse-bg 1.4s ease-in-out infinite; }
.skel span.short { width: 60%; }

.banner { display: flex; align-items: center; gap: .5rem; margin: .6rem auto 0; max-width: 48rem; width: calc(100% - 2.5rem); padding: .5rem .8rem; border-radius: 10px; font-size: .88rem; }
.banner.err { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--text); }
.banner .icon-btn { margin-left: auto; }

/* ── composer ───────────────────────────────────────────────────────────── */
.composer { padding: .4rem 1.25rem 1rem; }
.composer-box { max-width: 48rem; margin: 0 auto; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface);
  box-shadow: 0 6px 24px rgba(0,0,0,.12); transition: border-color .15s, box-shadow .15s; padding: .35rem .45rem .35rem .75rem; }
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft), 0 6px 24px rgba(0,0,0,.12); }
.composer textarea { display: block; width: 100%; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font: inherit;
  font-size: .98rem; line-height: 1.5; padding: .45rem .1rem .2rem; field-sizing: content; min-height: 1.5em; max-height: 40vh; overflow-y: auto; }
.composer textarea:focus-visible { outline: none; }
.composer-bar { display: flex; align-items: center; gap: .4rem; }
.composer-hint { flex: 1; font-size: .78rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #4c6ef5, #20c997); transition: transform .12s, opacity .15s; }
.send:hover:not(:disabled) { transform: scale(1.06); }
.send:disabled { opacity: .35; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.chips-row { display: flex; flex-wrap: wrap; gap: .45rem; padding: .3rem 0 .35rem; }
.fchip { position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .45rem .35rem .45rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); max-width: 16rem; overflow: hidden; }
.fchip img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.fchip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.fchip-text b { font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fchip-text small { font-size: .7rem; color: var(--text-faint); }
.fchip.bad { border-color: var(--danger); } .fchip.bad small { color: var(--danger); }
.fchip-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--brand); transition: width .2s; }
.fchip-x { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text-soft); cursor: pointer; flex: none; }
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(3px); pointer-events: none; animation: rise .15s ease-out; }
.drop-overlay > div { text-align: center; padding: 2.2rem 3rem; border: 2px dashed var(--brand); border-radius: 20px; background: var(--surface); color: var(--text); }
.drop-overlay p { margin: .6rem 0 0; }

/* ── rendered markdown ──────────────────────────────────────────────────── */
.md { word-wrap: break-word; }
.md-block > :first-child { margin-top: 0; }
.md-block > :last-child { margin-bottom: 0; }
.md-block + .md-block { margin-top: .85em; }
.md p { margin: .6em 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 1.1em 0 .45em; letter-spacing: -.01em; }
.md h1 { font-size: 1.4rem; } .md h2 { font-size: 1.22rem; } .md h3 { font-size: 1.06rem; } .md h4 { font-size: 1rem; }
.md ul, .md ol { padding-left: 1.4rem; margin: .5em 0; }
.md li + li { margin-top: .2em; }
.md li > p { margin: .2em 0; }
.md blockquote { margin: .6em 0; padding: .1em 0 .1em 1em; border-left: 3px solid var(--border-strong); color: var(--text-soft); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md a { color: var(--brand-strong); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent); text-underline-offset: 2px; }
.md a[data-file]::before { content: '📎 '; font-size: .85em; }
.md :not(pre) > code { font-size: .86em; padding: .12em .38em; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }
.md-streaming .md-block:last-child > :last-child::after { content: ''; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -.12em;
  background: var(--brand); border-radius: 2px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.md-code { margin: .8em 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.md-code-bar { display: flex; align-items: center; justify-content: space-between; padding: .3rem .5rem .3rem .8rem; font-size: .75rem; color: var(--text-faint);
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.md-code-bar button, .md-table-bar button { border: 0; background: transparent; color: var(--text-soft); cursor: pointer; font-size: .75rem; padding: .2rem .45rem; border-radius: 6px; }
.md-code-bar button:hover, .md-table-bar button:hover { background: var(--surface-2); color: var(--text); }
.md-code pre { margin: 0; padding: .8rem 1rem; overflow-x: auto; font-size: .83rem; line-height: 1.55; background: transparent; border: 0; border-radius: 0; }
.md-code code { font-family: var(--mono); background: none; }

.md-table { margin: .9em 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.md-table-bar { display: flex; align-items: center; justify-content: space-between; padding: .25rem .5rem .25rem .8rem; font-size: .72rem; color: var(--text-faint);
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.md-table-scroll { overflow: auto; max-height: 32rem; }
.md table { border-collapse: collapse; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
.md th, .md td, .grid th, .grid td { padding: .5rem .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th, .grid th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--text); z-index: 1; box-shadow: 0 1px 0 var(--border); }
.md tbody tr:nth-child(even), .grid tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.md tbody tr:hover, .grid tbody tr:hover { background: var(--brand-soft); }
.md tr:last-child td { border-bottom: 0; }

.md-fig { display: block; margin: .9em 0; }
.md-fig img { display: block; max-width: 100%; max-height: 32rem; border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in; background: #fff; }
.md-cap { display: block; margin-top: .35rem; font-size: .8rem; color: var(--text-faint); }
.md-math-block { margin: .9em 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.md-mermaid { margin: .9em 0; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow-x: auto; text-align: center; }
.md-mermaid[data-done] > pre { display: none; }
.md-mermaid svg { max-width: 100%; height: auto; }

.md-lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible; }
.md-lightbox::backdrop { background: rgba(8, 10, 14, .82); backdrop-filter: blur(4px); }
.md-lightbox img { display: block; max-width: 94vw; max-height: 86vh; border-radius: 12px; background: #fff; }
.md-lightbox p { color: #e9ecef; text-align: center; margin: .6rem 0 0; font-size: .9rem; }
.md-lb-close { position: absolute; top: -.9rem; right: -.9rem; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #fff; color: #111; font-size: 1.3rem; cursor: pointer; }

/* highlight.js tokens on the fineupp palette */
.hljs-comment, .hljs-quote { color: var(--text-faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: #b197fc; }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-addition { color: #63e6be; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable, .hljs-template-variable { color: #ffc078; }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: #74c0fc; }
.hljs-type, .hljs-class .hljs-title, .hljs-params { color: #ffd8a8; }
.hljs-meta, .hljs-tag { color: #91a7ff; }
.hljs-deletion { color: #ff8787; }
[data-theme="light"] .hljs-keyword, [data-theme="light"] .hljs-built_in, [data-theme="light"] .hljs-literal { color: #7048e8; }
[data-theme="light"] .hljs-string, [data-theme="light"] .hljs-attr, [data-theme="light"] .hljs-addition { color: #087f5b; }
[data-theme="light"] .hljs-number, [data-theme="light"] .hljs-variable { color: #d9480f; }
[data-theme="light"] .hljs-title, [data-theme="light"] .hljs-section, [data-theme="light"] .hljs-name { color: #1c7ed6; }
[data-theme="light"] .hljs-type, [data-theme="light"] .hljs-params { color: #a35c00; }
[data-theme="light"] .hljs-meta, [data-theme="light"] .hljs-tag { color: #4263eb; }

/* ── files panel ────────────────────────────────────────────────────────── */
.files-col { position: relative; width: var(--files-w, 440px); border-left: 1px solid var(--border); background: var(--surface); display: flex; min-height: 0; animation: slide-in .2s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.files-grip { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.files-grip:hover { background: var(--brand-soft); }
.files-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.fp-head { display: flex; align-items: center; gap: .45rem; padding: .55rem .6rem .55rem .9rem; border-bottom: 1px solid var(--border); min-height: 48px; }
.fp-head b { font-size: .92rem; } .fp-head .muted { flex: 1; }
.fp-tree { overflow-y: auto; padding: .35rem; flex: 1; min-height: 5rem; }
.fp-tree.compact { flex: 0 1 34%; border-bottom: 1px solid var(--border); }
.fp-dirname, .fp-file { display: flex; align-items: center; gap: .45rem; width: 100%; border: 0; background: transparent; color: var(--text-soft); text-align: left;
  font: inherit; font-size: .85rem; padding: .32rem .5rem; border-radius: 7px; cursor: pointer; }
.fp-dirname { color: var(--text-faint); font-size: .78rem; margin-top: .3rem; }
.fp-dir .fp-file { padding-left: 1rem; }
.fp-dir:first-child .fp-file { padding-left: .5rem; }
.fp-file:hover { background: var(--surface-2); color: var(--text); }
.fp-file.on { background: var(--brand-soft); color: var(--text); }
.fp-fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-empty { padding: 1rem; }
.pv { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pv-bar { display: flex; align-items: center; gap: .45rem; padding: .4rem .5rem .4rem .8rem; border-bottom: 1px solid var(--border); }
.pv-name { flex: 1; min-width: 0; font-size: .85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-trunc { margin: .4rem .8rem 0; }
.pv-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.pv-img { display: grid; place-items: center; padding: 1rem; background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px; min-height: 100%; }
.pv-img img { max-width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); }
.pv-frame { flex: 1; width: 100%; min-height: 60vh; border: 0; background: #fff; }
.pv-doc { padding: .9rem 1rem; }
.pv-doc .md-code { margin: 0; }
.pv-docx { padding: .5rem; background: var(--surface-2); flex: 1; }
.pv-docx .docx-wrapper { background: transparent !important; padding: .5rem !important; }
.pv-docx .docx-wrapper > section.docx { box-shadow: var(--shadow); margin-bottom: 1rem !important; max-width: 100%; }
.pv-loading { display: flex; align-items: center; gap: .5rem; padding: 1rem; color: var(--text-faint); font-size: .88rem; }
.pv-none { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 3rem 1rem; color: var(--text-faint); text-align: center; }
.grid { margin: .6rem; border: 1px solid var(--border); border-radius: 10px; max-height: none; }
.grid table { border-collapse: collapse; width: 100%; font-size: .82rem; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: .25rem; padding: .5rem .6rem 0; overflow-x: auto; }
.tab { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 8px; padding: .25rem .6rem; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.tab.on { border-color: var(--brand); color: var(--text); background: var(--brand-soft); }

/* ── small screens ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .chat-app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-grid; }
  .side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .side-open .side { transform: none; }
  .side-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.45); }
  .files-col { position: fixed; inset: 0; z-index: 45; width: auto; border-left: 0; }
  .files-grip { display: none; }
  .feed-inner { padding: 1rem .9rem 1.5rem; }
  .composer { padding: .3rem .6rem .7rem; }
  .msg-user .bubble { max-width: 88%; }
  .chips { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 22rem; }
  .files-btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .orb-core, .orb::before { animation: none !important; }
  .shimmer { animation: none; color: var(--text-soft); background: none; }
}
