/* css/chat.css: the /chat app. Thinkrr's research-lab look (css/site.css tokens only): misty paper grounds, a fine
   grid, mono uppercase labels, square 4px corners, ink buttons, and the logo's one green bar as the accent and the
   thinking indicator. */

.chat-app {
  --cx-rail-w: 264px;
  --cx-drawer-w: 300px;
  --cx-ease: var(--ease, cubic-bezier(.2, .7, .2, 1));
  position: fixed; left: 0; right: 0;
  top: calc(var(--cx-top, 0px) + var(--cx-vtop, 0px));
  height: var(--cx-h, 100dvh);
  display: grid; grid-template-columns: var(--cx-rail-w) minmax(0, 1fr) var(--cx-drawer-w);
  background: var(--paper); color: var(--ink); font-family: var(--sans);
  z-index: 20; overflow: hidden;
}
html.cx-mode, html.cx-mode body { overflow: hidden; overscroll-behavior: none; }
html.cx-mode body { background: var(--paper); }
html.cx-mode .site-footer { display: none; }
.chat-app *, .chat-app *::before, .chat-app *::after { box-sizing: border-box; }
:where(.chat-app) :where(button, input, textarea) { font: inherit; color: inherit; }
.chat-app button, .chat-app a, .chat-app summary { -webkit-tap-highlight-color: transparent; }
.chat-app [hidden] { display: none !important; }
.cx-flex { flex: 1 1 auto; }
.cx-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.cx-label { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cx-label-gap { margin: 20px 0 8px; }
.cx-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cx-dot { display: inline-block; width: 7px; height: 7px; background: var(--green); flex: none; }
.cx-dot.is-off { background: var(--fog); }
.cx-muted { color: var(--ink-3); font-size: 13px; margin: 8px 0; display: flex; align-items: center; gap: 8px; }
.cx-err { color: var(--red); font-size: 13px; margin: 6px 0 0; }
.cx-err:empty { display: none; }
.cx-note { font-size: 12.5px; line-height: 1.5; color: var(--ink-3); margin: 8px 0 0; }

/* the logo's bar: a green fill on a grey track. At rest it sits at the logo's 62%; while Claude works it fills. */
.cx-bar { position: relative; display: inline-block; width: 30px; height: 4px; background: var(--track); overflow: hidden; vertical-align: middle; flex: none; }
.cx-bar i { position: absolute; inset: 0 auto 0 0; width: 62%; background: var(--green); }
.cx-bar-sm { width: 16px; height: 3px; }
.cx-wait .cx-bar i, .cx-step.is-run .cx-bar i, .chat-app.is-busy .cx-logo .cx-bar i, .chat-app[data-gate='boot'] .cx-gate .cx-bar i, .cx-muted .cx-bar i {
  width: 100%; transform-origin: left center; animation: cx-fill 1.5s var(--cx-ease) infinite;
}
@keyframes cx-fill { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: .25; } }

/* ----------------------------------------------------------------------------------------------- buttons */
.cx-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r); border: 1px solid transparent; background: transparent; cursor: pointer; flex: none; color: var(--ink-2); }
.cx-icon:hover { background: var(--paper-3); color: var(--ink); }
.cx-icon svg, .cx-btn svg, .cx-link svg, .cx-new svg, .cx-send svg { width: 17px; height: 17px; flex: none; }
.cx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 10px 16px;
  border-radius: var(--r); border: 1px solid var(--line-2); background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.cx-btn:hover { background: var(--card); border-color: var(--ink-3); }
.cx-btn:active { transform: translateY(1px); }
.cx-btn:disabled { opacity: .5; cursor: default; }
.cx-btn-go { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cx-btn-go:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--paper); }
.cx-btn-lg { min-height: 48px; padding: 14px 24px; font-size: 12.5px; }
.cx-btn-sm { min-height: 40px; padding: 8px 12px; font-size: 11.5px; }
.cx-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0; background: none; border: 0; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); cursor: pointer; text-decoration: none; }
.cx-link:hover { color: var(--green-ink); }
.cx-link svg { width: 14px; height: 14px; }
.cx-chip { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--card); font-size: 13.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s; }
.cx-chip:hover { border-color: var(--ink-3); color: var(--ink); }

/* --------------------------------------------------------------------------------------- rail and drawer */
.cx-rail, .cx-drawer { display: flex; flex-direction: column; min-height: 0; background: var(--paper-2); padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
.cx-rail { border-right: 1px solid var(--line); }
.cx-drawer { border-left: 1px solid var(--line); }
.cx-grab { display: none; }
.cx-rail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; min-height: 40px; }
.cx-close { display: none; }
.cx-new { flex: 1; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.cx-new:hover { background: var(--ink-2); }
.cx-list { display: flex; flex-direction: column; gap: 2px; margin: 8px -4px 0; min-height: 60px; flex: 1 1 auto; overflow-y: auto; }
.cx-empty-list { color: var(--ink-3); font-size: 13px; padding: 6px 4px; margin: 0; }
.cx-item { display: flex; align-items: center; border-radius: var(--r); }
.cx-item:hover { background: var(--paper-3); }
.cx-item.is-on { background: var(--card); box-shadow: inset 2px 0 0 var(--green); }
.cx-item-open { flex: 1; min-width: 0; min-height: 40px; text-align: left; background: none; border: 0; padding: 6px 10px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.cx-item.is-on .cx-item-open { color: var(--ink); }
.cx-item-open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-item-del { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; border-radius: var(--r); opacity: 0; cursor: pointer; color: var(--ink-3); flex: none; }
.cx-item-del svg { width: 15px; height: 15px; }
.cx-item:hover .cx-item-del, .cx-item.is-on .cx-item-del, .cx-item-del:focus-visible { opacity: 1; }
@media (hover: none) { .cx-item-del { opacity: .7; } }
.cx-rail-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cx-links { display: flex; flex-wrap: wrap; gap: 0 14px; }
.cx-links a { font-size: 12.5px; color: var(--ink-2); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.cx-links a:hover { color: var(--ink); text-decoration: underline; }
.cx-legal { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 8px 0 0; }

.cx-tot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0 8px; }
.cx-tot b { font-family: var(--mono); font-size: 22px; font-weight: 400; letter-spacing: -.02em; color: var(--ink); }
.cx-hold { list-style: none; margin: 0 0 4px; padding: 0; }
.cx-hold li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.cx-claude-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }

/* ----------------------------------------------------------------------------------------------- main */
.cx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--paper); }
.cx-top { display: flex; align-items: center; gap: 8px; padding: 8px 16px; min-height: 56px; border-bottom: 1px solid var(--line); background: var(--paper); }
#cx-open-rail, #cx-open-drawer, .cx-wallet { display: none; }
.cx-logo { display: inline-flex; flex-direction: column; justify-content: center; gap: 3px; min-height: 40px; padding: 0 4px; text-decoration: none; color: var(--ink); flex: none; }
.cx-logo b { font-family: var(--sans); font-size: 17px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.cx-logo .cx-bar { width: 22px; height: 3px; }
.cx-logo-lg { min-height: 0; gap: 6px; margin-bottom: 14px; align-items: flex-start; }
.cx-logo-lg b { font-size: 34px; }
.cx-logo-lg .cx-bar { width: 44px; height: 5px; }
.cx-model-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: transparent; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); cursor: pointer; white-space: nowrap; flex: none; }
.cx-model-chip:hover { border-color: var(--line-2); color: var(--ink); }

.cx-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-padding-bottom: 24px;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px; background-position: -1px -1px;
}
.cx-thread { max-width: 780px; margin: 0 auto; padding: 28px 24px 32px; display: flex; flex-direction: column; gap: 14px; }

/* hello + gate */
.cx-hello { padding: 9vh 0 8px; }
.cx-hello h1, .cx-gate h1 { font-size: clamp(32px, 4.4vw, 48px); line-height: 1.04; letter-spacing: -.03em; font-weight: 300; margin: 14px 0 12px; }
.cx-hello h1 em, .cx-gate h1 em { font-family: var(--serif); font-style: italic; font-weight: 700; letter-spacing: -.03em; }
.cx-hello p { color: var(--ink-2); font-size: 16px; line-height: 1.6; max-width: 540px; margin: 0; }
.cx-gate { margin: 6vh auto 0; width: 100%; max-width: 480px; padding: 30px 28px 28px; border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.cx-gate-sub { color: var(--ink-2); font-size: 15px; line-height: 1.55; margin: 0 0 16px; }
.cx-deeplinks { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* messages */
.cx-msg { max-width: 100%; min-width: 0; }
.cx-user { align-self: flex-end; max-width: min(86%, 620px); }
.cx-bubble { padding: 11px 15px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line-2); font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.cx-ai { align-self: stretch; font-size: 16px; line-height: 1.68; color: var(--ink); overflow-wrap: anywhere; }
.cx-md > :first-child { margin-top: 0; }
.cx-md > :last-child { margin-bottom: 0; }
.cx-md p, .cx-read p { margin: 0 0 10px; }
.cx-md ul, .cx-md ol { margin: 0 0 10px; padding-left: 22px; }
.cx-md li { margin: 3px 0; }
.cx-md h3, .cx-md h4 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 16px 0 6px; }
.cx-md h5, .cx-md h6 { font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.cx-md a { color: var(--green-ink); text-decoration: underline; text-decoration-color: var(--sage); text-underline-offset: 3px; }
.cx-md code, .cx-cmd code, .cx-hint code { font-family: var(--mono); font-size: .86em; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1px 5px; }
.cx-md blockquote { margin: 0 0 10px; padding: 4px 0 4px 14px; border-left: 2px solid var(--green); color: var(--ink-2); }
.cx-md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md-code { border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; margin: 0 0 12px; background: var(--night); color: var(--on-night); }
.md-code-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 0 12px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--on-night-2); border-bottom: 1px solid var(--grid-night); }
.md-copy { background: none; border: 0; color: var(--on-night); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; min-height: 40px; padding: 0 10px; cursor: pointer; }
.md-code pre { margin: 0; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.md-code pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.md-table { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card); -webkit-overflow-scrolling: touch; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md-table th { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--paper); }
.md-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.md-table tr:last-child td { border-bottom: 0; }
.cx-gap { margin-top: 10px; }

/* sources a web search answer used */
.cx-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.cx-sources a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; max-width: 100%; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); text-decoration: none; }
.cx-sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-sources a:hover { color: var(--green-ink); }
.cx-sources svg { width: 13px; height: 13px; flex: none; }

/* thinking, steps, notes */
.cx-wait { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; min-height: 28px; }
.cx-step { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 12px 4px 6px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); max-width: 100%; }
.cx-step-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-step-ic { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 2px; background: var(--paper-2); flex: none; }
.cx-step-ic svg { width: 12px; height: 12px; }
.cx-step.is-ok .cx-step-ic { background: var(--green-soft); color: var(--green-ink); }
.cx-step.is-bad .cx-step-ic { background: var(--red-soft); color: var(--red); }
.cx-note-line { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); padding: 10px 12px; border-radius: var(--r); background: var(--paper-2); border: 1px solid var(--line); line-height: 1.5; }
.cx-note-line svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.cx-note-line.bad { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 25%, transparent); color: var(--ink); }
.cx-note-line.bad svg { color: var(--red); }
.cx-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.cx-total span { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cx-total b { font-family: var(--mono); font-size: 24px; font-weight: 400; letter-spacing: -.02em; }
.cx-json { font-family: var(--mono); font-size: 12px; background: var(--paper-2); padding: 12px; border-radius: var(--r); overflow-x: auto; max-height: 280px; }
.cx-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cx-cmd-group .cx-label-gap { margin: 14px 0 8px; }
.cx-cmd-group:first-of-type .cx-label-gap { margin-top: 4px; }
.cx-cmds { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.cx-cmd { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 10px 12px; min-height: 44px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 13px; color: var(--ink-2); }
.cx-cmd:hover { border-color: var(--ink-3); }

/* action card */
.cx-card { min-width: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; width: 100%; }
.cx-card[data-state='confirmed'] { box-shadow: inset 3px 0 0 var(--green), var(--shadow); }
.cx-card[data-state='failed'] { box-shadow: inset 3px 0 0 var(--red), var(--shadow); }
.cx-card[data-state='cancelled'] { opacity: .85; box-shadow: none; }
.cx-card:not([data-state]) .cx-head .cx-dot, .cx-card[data-state='running'] .cx-head .cx-dot { animation: cx-blink 1.6s ease-in-out infinite; }
.cx-card[data-state='cancelled'] .cx-head .cx-dot { background: var(--fog); }
.cx-card[data-state='failed'] .cx-head .cx-dot { background: var(--red); }
@keyframes cx-blink { 50% { opacity: .3; } }
.cx-head h3 { margin: 8px 0 4px; font-size: 20px; font-weight: 400; letter-spacing: -.02em; line-height: 1.2; }
.cx-sum { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.cx-rows { margin: 0; display: grid; border-top: 1px solid var(--line); }
.cx-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cx-row dt { color: var(--ink-3); flex: none; }
.cx-row dd { margin: 0; font-family: var(--mono); font-size: 12.5px; text-align: right; overflow-wrap: anywhere; min-width: 0; font-variant-numeric: tabular-nums; }
.cx-warn { list-style: none; margin: 0; padding: 10px 12px; border-radius: var(--r); background: var(--paper-2); border: 1px solid var(--line); display: grid; gap: 6px; }
.cx-warn li { display: flex; gap: 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.cx-warn svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--pine); }
.cx-txs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cx-tx { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.cx-tx-n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 2px; border: 1px solid var(--line-2); font-family: var(--mono); font-size: 11px; flex: none; }
.cx-tx-l { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cx-tx-s { font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-align: right; flex: none; max-width: 55%; overflow-wrap: anywhere; }
.cx-tx-s a { color: var(--green-ink); }
.cx-tx[data-s='signing'] .cx-tx-n, .cx-tx[data-s='pending'] .cx-tx-n { background: var(--green-soft); border-color: var(--green); animation: cx-blink 1.2s infinite; }
.cx-tx[data-s='confirmed'] .cx-tx-n, .cx-tx[data-s='skipped'] .cx-tx-n { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cx-tx[data-s='failed'] .cx-tx-n { background: var(--red-soft); color: var(--red); }
.cx-status { margin: 0; font-size: 13px; color: var(--ink-2); }
.cx-status:empty { display: none; }
.cx-card[data-state='failed'] .cx-status { color: var(--red); }
.cx-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cx-actions-start { justify-content: flex-start; }

/* Claude not connected: the calm card, and the visitor's own key */
.cx-keycard { max-width: 620px; }
.cx-keycard.is-inline { box-shadow: none; padding: 14px; }
.cx-drawer .cx-keycard { max-width: none; background: var(--paper); }
.cx-drawer .cx-keycard .cx-head h3 { font-size: 16px; }
.cx-keybox summary { cursor: pointer; display: flex; align-items: center; min-height: 40px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); list-style: none; }
.cx-keybox summary::-webkit-details-marker { display: none; }
.cx-keybox summary::before { content: '+'; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 8px; border: 1px solid var(--line-2); font-size: 13px; }
.cx-keybox[open] summary::before { content: '-'; }
.cx-key-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.cx-key-in { flex: 1 1 200px; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card); font-family: var(--mono); font-size: 16px; outline: none; }
.cx-key-in:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--green-soft); }

/* --------------------------------------------------------------------------------------------- composer */
.cx-composer { flex: none; padding: 8px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--paper); border-top: 1px solid var(--line); position: relative; }
.cx-composer > * { max-width: 780px; margin-left: auto; margin-right: auto; }
.cx-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.cx-chips::-webkit-scrollbar { display: none; }
.cx-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--card); padding: 6px 6px 6px 14px; transition: border-color .15s, box-shadow .2s; }
.cx-box:focus-within { border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--green-soft); }
.cx-box textarea { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; resize: none; font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--ink); max-height: 200px; min-height: 40px; padding: 8px 0; display: block; }
.cx-box textarea::placeholder { color: var(--ink-3); }
.cx-send { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; flex: none; }
.cx-send:hover { background: var(--ink-2); }
.cx-send.is-stop { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.cx-fine { font-size: 11.5px; color: var(--ink-3); text-align: center; margin: 6px auto 0; }
.cx-hints { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; z-index: 5; }
.cx-hint { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 40px; padding: 6px 10px; border-radius: var(--r); border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.cx-hint:hover, .cx-hint:focus-visible { background: var(--paper-2); }

.cx-scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--night) 38%, transparent); opacity: 0; transition: opacity .25s; z-index: 40; }
.cx-scrim.open { opacity: 1; }

/* toasts sit under the chat's top bar, never over the composer or a card's buttons; only their links take taps */
.page-chat .toasts { top: var(--cx-toast-t, calc(72px + env(safe-area-inset-top, 0px))); bottom: auto; }
.page-chat .toast { pointer-events: none; }
.page-chat .toast a { pointer-events: auto; }

/* ------------------------------------------------------------------------------------------ breakpoints */
@media (max-width: 1179px) {
  .chat-app { grid-template-columns: var(--cx-rail-w) minmax(0, 1fr); }
  #cx-open-drawer { display: inline-grid; }
  .cx-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 50; transform: translateX(105%); transition: transform .3s var(--cx-ease); box-shadow: var(--shadow-lg); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .cx-drawer.open { transform: none; }
  .cx-drawer .cx-close { display: inline-grid; }
}
@media (max-width: 1023px) { .chat-app { --cx-rail-w: 228px; } }
@media (max-width: 760px) {
  html.cx-mode .site-header, html.cx-mode .sheet, html.cx-mode .sheet-back { display: none !important; }
  .chat-app { grid-template-columns: minmax(0, 1fr); top: var(--cx-vtop, 0px); height: var(--cx-h, 100dvh); }
  #cx-open-rail { display: inline-grid; }
  .cx-wallet { display: inline-flex; min-height: 40px; padding: 0 12px; font-size: 11px; max-width: 150px; }
  .cx-wallet .wl { white-space: nowrap; }
  .cx-top { padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px; gap: 6px; min-height: 54px; }
  .cx-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 82vh; z-index: 50; border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translateY(105%); transition: transform .32s var(--cx-ease); box-shadow: var(--shadow-lg); padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .cx-sheet.open { transform: none; }
  .cx-drawer { width: auto; top: auto; padding-top: 8px; }
  .cx-grab { display: block; width: 40px; height: 4px; background: var(--line-2); margin: 2px auto 10px; flex: none; }
  .cx-close { display: inline-grid; }
  .cx-links a { min-height: 40px; }
  .cx-thread { padding: 18px 16px 24px; gap: 12px; }
  .cx-composer { padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .cx-hints { left: 12px; right: 12px; }
  .cx-ai { font-size: 15.5px; }
  .cx-bubble { font-size: 15.5px; }
  .cx-hello { padding: 4vh 0 4px; }
  .cx-gate { margin-top: 3vh; padding: 22px 18px; }
  .cx-card { padding: 16px; }
  .cx-actions .cx-btn { flex: 1 1 auto; }
  .cx-fine { display: none; }
}
@media (max-width: 480px) {
  .cx-wallet .addr, .cx-wallet .wl { display: none; }
  .cx-wallet { padding: 0; width: 40px; justify-content: center; }
  .cx-top { gap: 4px; }
  .cx-hint { flex-direction: column; align-items: flex-start; gap: 2px; }
  .cx-row { flex-wrap: wrap; gap: 2px 12px; }
  .cx-row dd { text-align: left; }
}
@media (max-width: 360px) {
  .cx-model-chip { padding: 0 8px; font-size: 10.5px; }
  .cx-thread { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .cx-sheet, .cx-drawer, .cx-scrim { transition: none; }
  .cx-bar i, .cx-tx-n, .cx-head .cx-dot { animation: none !important; }
}
