/* RexAPF Remote. Theme tokens copied 1:1 from mockups/mobile-remote-redesign.html (RexAPF Web --chat-* scale).
   theme.js sets html.light from the RexAPF Web theme choice; the frame follows mockups/remote-in-chat-shell.html. */
:root {
  --canvas: #151513; --sidebar: #181816; --surface: #1b1b19; --raised: #22221f; --hover: #2a2a26;
  --line: #33322e; --line-strong: #4c4a44;
  --text: #ece9e3; --msg: #e4e1da; --muted: #a8a49b; --subtle: #8f8a80;
  --accent: #4fc0c5; --accent-soft: #123a3d; --on-accent: #0b2426; --focus: #6fd3d7;
  --ok: #5cc08a; --ok-soft: #173526; --warn: #e0a63f; --warn-soft: #3b2d12;
  --err: #e2755c; --err-soft: #3d1d15; --info: #7fa8f5; --info-soft: #1a2740;
  --code-bg: #10100e; --overlay: rgba(0, 0, 0, .62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 16px 40px rgba(0, 0, 0, .55);
  --font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-prose: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
:root.light {
    --canvas: #fdfbfa; --sidebar: #f7f5f2; --surface: #fdfbfa; --raised: #f7f5f2; --hover: #eeebe5;
    --line: #dedbd4; --line-strong: #b8b3aa;
    --text: #27251e; --msg: #27251e; --muted: #6f6b63; --subtle: #77736b;
    --accent: #016a71; --accent-soft: #ddf6f8; --on-accent: #fff; --focus: #016a71;
    --ok: #2d8a5e; --ok-soft: #e3f4ea; --warn: #b7791f; --warn-soft: #fbf1dc;
    --err: #b4462f; --err-soft: #fbe7e1; --info: #2f5fb3; --info-soft: #e6eefb;
    --code-bg: #f3f1ec; --overlay: rgba(39, 37, 30, .28);
    --shadow-sm: 0 1px 2px rgba(39, 37, 30, .06); --shadow-md: 0 12px 32px rgba(39, 37, 30, .16);
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--text); }
body {
  font: 14px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.shell { display: flex; height: 100vh; height: 100dvh; }
.app { flex: 1; min-width: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; padding-left: var(--safe-left); padding-right: var(--safe-right); }
.app.chat-mode { overflow: hidden; }
.app.chat-mode > .ab, .app.chat-mode > .ban { position: static; flex: none; }
.noscript { padding: 24px; }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-stop { fill: currentColor; }

/* App bar */
.ab {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.ab.with-back { padding-left: 6px; gap: 6px; }
.ab .ttl { flex: 1; min-width: 0; }
.ab h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab .dev { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 1px; min-width: 0; }
.ab .dev span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--subtle); }
.dot.run { background: var(--accent); animation: pulse 1.4s infinite; }
.ib {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: var(--muted);
}
.ib:hover:not(:disabled), .ib:active:not(:disabled) { background: var(--hover); color: var(--text); }
.ib:disabled { opacity: .45; }
.ib .icon { width: 18px; height: 18px; }
.ib.spinning .icon { animation: spin .9s linear infinite; }

/* Connection strip */
.ban { display: flex; gap: 8px; align-items: center; padding: 8px 14px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.ban.warn { background: var(--warn-soft); color: var(--warn); }
.ban.ok { background: var(--ok-soft); color: var(--ok); }
.ban .ban-text { flex: 1; min-width: 0; }
.ban .icon { width: 14px; height: 14px; }
.ban-retry { border: 0; background: transparent; color: inherit; font-weight: 600; font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; padding: 6px 2px; min-height: 32px; flex: none; }
.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
.ban.warn .spin { border-color: color-mix(in srgb, var(--warn) 30%, transparent); border-top-color: var(--warn); }

/* Centered states (scan, rejected) */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 28px calc(30px + var(--safe-bottom)); }
.hero-i { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 0 16px; }
.hero-i .icon { width: 26px; height: 26px; }
.hero-i.err { background: var(--err-soft); color: var(--err); }
.hero-i.acc { background: var(--accent-soft); color: var(--accent); }
.center h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.center p { margin: 0 0 16px; color: var(--muted); font-size: 13px; max-width: 300px; }
.center .info { text-align: left; max-width: 320px; margin-top: 8px; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 550; display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  min-height: 40px; text-align: center;
}
.btn:hover:not(:disabled), .btn:active:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .55; }
.btn .icon { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled), .btn.primary:active:not(:disabled) { background: var(--accent); filter: brightness(1.07); }

/* Home */
.home { padding: 14px 14px calc(24px + var(--safe-bottom)); }
.info { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.info .icon { color: var(--accent); margin-top: 2px; }
.lh { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; }
.lh h2 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.lh .ib { margin: -6px -8px -6px 0; }
.lsub { color: var(--muted); font-size: 12px; margin: 0 0 12px; min-height: 18px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 11px; color: var(--subtle); margin: 0 0 14px; }
.search:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 9px 0; font-size: 16px; color: var(--text); }
.search input::placeholder { color: var(--subtle); }
.search input::-webkit-search-cancel-button { display: none; }
.search .ib { width: 32px; height: 32px; margin-right: -6px; }
.grp { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--subtle); margin: 14px 2px 6px; font-weight: 500; }
.grp .icon { width: 13px; height: 13px; }
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; margin: 0 0 12px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li .row { border-top: 1px solid var(--line); }
.row {
  width: 100%; min-height: 54px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  padding: 10px 12px; border: 0; background: transparent; text-align: left;
}
.row:hover, .row:active { background: var(--hover); }
.row b { font-weight: 550; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--text); }
.row small { grid-column: 1; color: var(--subtle); font-size: 11.5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .bd { grid-row: 1 / 3; grid-column: 2; }
.bd { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.bd.run { background: var(--accent-soft); color: var(--accent); }
.bd.warn { background: var(--warn-soft); color: var(--warn); }
.bd.off { background: var(--hover); color: var(--muted); }
.bd.run i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.cnt { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1b1b19; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; }
.wh { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; background: var(--raised); }
.wh.has-rows { border-bottom: 1px solid var(--line); }
.wh-toggle { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 11px 4px 11px 12px; border: 0; background: transparent; text-align: left; min-width: 0; }
.wh .fi { width: 34px; height: 34px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.wh-text { min-width: 0; display: block; }
.wh-name { display: flex; gap: 6px; align-items: center; font-size: 14px; font-weight: 650; min-width: 0; }
.wh-name > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wh-name .icon { width: 14px; height: 14px; color: var(--subtle); transition: transform .15s; }
.wh-toggle[aria-expanded="false"] .wh-name .icon { transform: rotate(-90deg); }
.wh .path { font: 11.5px var(--font-mono); color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.wh .meta { font-size: 11.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; flex: none; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.wh .acts { display: flex; gap: 2px; padding-right: 6px; }
.more { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 11px 9px; font-size: 12.5px; color: var(--muted); min-height: 40px; }
.more:hover, .more:active { background: var(--hover); color: var(--text); }
.ws-empty { margin: 0; padding: 10px 12px; color: var(--subtle); font-size: 12.5px; }
.empty-note { color: var(--subtle); font-size: 13px; text-align: center; padding: 24px 0; margin: 0; }
.skeleton { height: 56px; border-radius: 12px; margin: 0 0 12px; background: linear-gradient(90deg, var(--surface) 0%, var(--raised) 50%, var(--surface) 100%); background-size: 200% 100%; border: 1px solid var(--line); animation: shimmer 1.4s linear infinite; }
.skeleton.tall { height: 132px; }
.skeleton.short { width: 60%; }

/* Chat */
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 10px; overscroll-behavior: contain; }
.messages > .skeleton { margin-bottom: 14px; }
.hint { color: var(--subtle); font-size: 12px; text-align: center; margin: 0 0 14px; }
/* User turn: bubble hugs its text and sits on the right, with extra air around it. */
.um-wrap { display: flex; flex-direction: column; align-items: flex-end; margin: 26px 0 26px 15%; }
.um-wrap:first-child { margin-top: 4px; }
.um { max-width: 100%; background: var(--hover); padding: 10px 14px; border-radius: 14px 14px 4px 14px; font-size: 14.5px; color: var(--msg); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-error { color: var(--err); font-size: 12.5px; margin: 4px 0 12px; overflow-wrap: anywhere; }
.um-wrap .msg-error { text-align: right; margin-bottom: 0; }
.prose { font: 15px/1.68 var(--font-prose); color: var(--msg); margin: 0 0 6px; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 10px; }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin: 0 0 4px; }
.prose strong { font-weight: 650; }
.prose h3, .prose h4, .prose h5, .prose h6 { font-family: var(--font-ui); margin: 14px 0 6px; line-height: 1.3; font-weight: 650; }
.prose h3 { font-size: 17px; } .prose h4 { font-size: 15.5px; } .prose h5, .prose h6 { font-size: 14.5px; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose code { font: 12.5px var(--font-mono); background: var(--hover); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.prose blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.code-block { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--code-bg); font-family: var(--font-ui); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 3px 12px; background: var(--raised); border-bottom: 1px solid var(--line); }
.code-lang { font-size: 11.5px; color: var(--subtle); }
.copy-code { min-height: 30px; padding: 0 10px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.copy-code:hover, .copy-code:active { background: var(--hover); color: var(--text); }
.code-block pre { margin: 0; padding: 10px 12px; overflow-x: auto; }
.prose .code-block code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; white-space: pre; color: var(--text); overflow-wrap: normal; }
.table-wrap { overflow-x: auto; margin: 0 0 10px; }
.prose table { border-collapse: collapse; font: 13px/1.5 var(--font-ui); }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.prose th { background: var(--raised); }
.cur { display: inline-block; width: 2px; height: 1em; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: pulse .9s steps(2) infinite; }

/* Reasoning ("worked") */
.worked { margin: 0 0 10px; }
.worked > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--subtle); font-size: 12.5px; cursor: pointer; min-height: 30px; }
.worked > summary::-webkit-details-marker { display: none; }
.worked > summary .icon { width: 14px; height: 14px; transition: transform .15s; }
.worked[open] > summary .icon { transform: rotate(90deg); }
.worked-body { border-left: 2px solid var(--line); padding: 2px 0 2px 11px; margin: 2px 0 6px 6px; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow-y: auto; }

/* Tool activity */
.act { border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); padding-left: 11px; margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.act-i > summary { list-style: none; display: flex; gap: 8px; align-items: center; min-height: 28px; cursor: pointer; min-width: 0; }
.act-i > summary::-webkit-details-marker { display: none; }
.act-i > summary > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.act-i .ok { color: var(--ok); }
.act-i .icon { width: 14px; height: 14px; }
.act-i .spin { width: 12px; height: 12px; }
.act code { font: 11.5px var(--font-mono); color: var(--text); }
.act-i pre { margin: 2px 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--code-bg); border: 1px solid var(--line); font: 11.5px/1.5 var(--font-mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; }
.act-label { font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--subtle); margin: 4px 0 2px; }
.stream-tool { margin: 0 0 12px; padding: 0 0 0 11px; border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); font: 11.5px/1.5 var(--font-mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: hidden; }

/* Assistant footer */
.fa { display: flex; gap: 2px; margin: 0 0 18px -8px; color: var(--subtle); align-items: center; }
.fa .ib { width: 32px; height: 32px; }
.fa .ib .icon { width: 15px; height: 15px; }
.fa time { margin-left: auto; font-size: 11.5px; }

/* Approval / question cards */
.apv { border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); border-radius: 12px; background: var(--surface); overflow: hidden; margin: 0 0 14px; }
.apv.qcard { border-color: color-mix(in srgb, var(--info) 45%, var(--line)); }
.apv.busy { opacity: .6; }
.apv .h { display: flex; gap: 8px; align-items: center; padding: 9px 12px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 600; }
.apv.qcard .h { background: var(--info-soft); color: var(--info); }
.apv-tool { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.apv-tool code { font: 12px var(--font-mono); color: var(--text); }
.apv pre { margin: 0; padding: 10px 12px; font: 12px/1.55 var(--font-mono); background: var(--code-bg); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); max-height: 240px; overflow: auto; }
.apv .b { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; }
.apv .b.one { grid-template-columns: 1fr; }
.apv .b .full { grid-column: 1 / -1; }
.apv .b .btn { white-space: normal; }
.qa { padding: 10px 12px 0; border: 0; margin: 0; min-width: 0; }
.qa + .qa { border-top: 1px solid var(--line); margin-top: 10px; }
.qa legend { padding: 0; margin: 0 0 8px; float: left; width: 100%; }
.qa legend + * { clear: both; }
.q-header { display: block; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--subtle); margin-bottom: 2px; }
.q-text { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); }
.q-detail.prose { font: 13px/1.55 var(--font-ui); color: var(--muted); margin: 0 0 8px; }
.q-opts { display: grid; gap: 8px; }
.btn.opt { flex-direction: column; align-items: stretch; text-align: left; gap: 1px; padding: 9px 12px; }
.btn.opt small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.qopt { display: flex; gap: 10px; align-items: flex-start; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13px; }
.qopt:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--accent-soft); }
.qopt input { accent-color: var(--accent); width: 18px; height: 18px; margin: 1px 0 0; flex: none; }
.qopt > span { display: flex; flex-direction: column; min-width: 0; }
.qopt small { color: var(--muted); font-size: 11.5px; }
.other-text { width: 100%; min-height: 40px; margin-top: 8px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--canvas); font-size: 16px; color: var(--text); }
.other-text:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }

/* Dock + composer */
.dock { flex: none; padding: 8px 12px calc(12px + var(--safe-bottom)); background: linear-gradient(to top, var(--canvas) 75%, transparent); }
.dock-cards { max-height: 52dvh; overflow-y: auto; margin: 0 0 4px; }
.dock-cards:empty { display: none; }
.mode { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin: 0 4px 8px; font-size: 12px; color: var(--muted); }
.mode > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); flex: none; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; font-size: 11.5px; color: var(--muted); min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.composer {
  /* RexAPF Desktop composer card (ui-conversation InputBar): 20px radius, hairline stroke + soft elevation,
     8px top pad, 12px between the text and the control row, 14/24 text. */
  display: flex; flex-direction: column; gap: 12px; padding-top: 8px; border: 0; border-radius: 20px; background: var(--surface);
  box-shadow: 0 0 0 .5px var(--line), 0 4px 16px rgba(0, 0, 0, .03), 0 0 24px rgba(0, 0, 0, .03);
}
:root:not(.light) .composer { background: var(--raised); box-shadow: 0 0 0 .5px var(--line), 0 4px 16px rgba(0, 0, 0, .25); }
.composer-input {
  display: block; width: 100%; min-height: 36px; max-height: 336px; resize: none; border: 0; outline: none; background: transparent;
  padding: 4px 12px 0 14px; font-size: 14px; line-height: 24px; color: var(--text); caret-color: var(--accent);
}
.composer-input::placeholder { color: var(--subtle); }
.cb { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; padding: 2px 8px 6px; }
/* Left half of the Desktop control row: the "+" circle (files, commands, skills) and the access-mode chip. */
.cb .cb-gap { flex: 1 1 auto; min-width: 0; }
.cb .plus { width: 28px; height: 28px; border-radius: 50%; border: 0; margin-right: -8px; background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; }
.cb .plus:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.cb .plus:disabled { opacity: .55; }
.cb .plus .icon { width: 16px; height: 16px; stroke-width: 2; }
.mtrig.perm { max-width: min(220px, 40%); padding-left: 6px; }
.mtrig.perm .icon:first-child { width: 14px; height: 14px; }
.mtrig.perm.danger { color: var(--err); }
.composer-wrap { position: relative; }
.composer.drop { box-shadow: 0 0 0 1.5px var(--accent), 0 4px 16px rgba(0, 0, 0, .06); }
/* Attachment chips above the text, as in the Desktop InputBar. */
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 12px 0; }
.att { position: relative; display: flex; align-items: center; gap: 8px; max-width: 220px; height: 44px; padding: 4px 28px 4px 4px; border-radius: 10px; background: var(--hover); overflow: hidden; }
.att-thumb, .att-ic { width: 36px; height: 36px; border-radius: 7px; flex: none; object-fit: cover; }
.att-ic { display: grid; place-items: center; background: var(--surface); color: var(--muted); }
.att-ic .icon { width: 18px; height: 18px; }
.att-t { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.att-t b { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-t small { font-size: 11px; color: var(--subtle); }
.att-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); transition: width .15s; }
.att.uploading .att-thumb { opacity: .6; }
.att-x { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.att-x:hover { background: var(--surface); color: var(--text); }
.att-x .icon { width: 12px; height: 12px; stroke-width: 2.2; }
/* Slash menu: commands and skills that match the typed /token, floating above the composer. */
.slash-pop {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30; max-height: min(320px, 45dvh); overflow-y: auto; padding: 6px;
  border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 .5px var(--line), 0 8px 28px rgba(0, 0, 0, .12);
}
:root:not(.light) .slash-pop { background: var(--raised); }
.slash-pop .opt-m, .sheet .opt-m:has(.pi) { grid-template-columns: 28px minmax(0, 1fr) auto; }
.slash-pop .opt-m { min-height: 44px; padding: 7px 10px; }
.pi { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--hover); color: var(--muted); }
.pi .icon { width: 15px; height: 15px; }
.pi.danger { color: var(--err); }
.opt-m .tag { font-size: 10.5px; color: var(--subtle); }
.sheet-note { color: var(--subtle); font-size: 12px; margin: 8px 10px 0; }
.ack { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 4px; font-size: 13px; cursor: pointer; }
.ack input { margin-top: 2px; accent-color: var(--accent); }
.mtrig {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: min(360px, 70%); height: 28px; padding: 0 4px 0 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; line-height: 20px; font-weight: 500; white-space: nowrap;
}
.mtrig:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.mtrig:disabled { opacity: .55; }
.mtrig .mt-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mtrig .mt-e { flex-shrink: 1000; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--subtle); font-weight: 400; }
.mtrig .icon { width: 12px; height: 12px; flex: none; stroke-width: 2; }
.mi { width: 12px; height: 12px; border-radius: 3px; flex: none; background: var(--subtle); }
.send { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 0; display: grid; place-items: center; flex: none; transform: translateY(-2px); transition: background-color .1s; }
.send .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.send.stop { background: var(--accent); }
.send:disabled { opacity: .4; }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet {
  width: 100%; max-width: 720px; max-height: 82dvh; background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-md); display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom); animation: rise .2s ease-out;
}
.grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 4px; flex: none; }
.sh { display: flex; align-items: center; padding: 2px 8px 6px 16px; border-bottom: 1px solid var(--line); flex: none; }
.sh h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 650; }
.sheet .search { margin: 10px 14px 0; flex: none; }
.sb2 { overflow-y: auto; padding: 6px 8px 12px; overscroll-behavior: contain; flex: 1 1 auto; min-height: 80px; }
.pg { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--subtle); padding: 12px 10px 4px; }
.opt-m { width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; min-height: 48px; }
.opt-m:hover, .opt-m:active { background: var(--hover); }
.opt-m .mi { width: 18px; height: 18px; border-radius: 5px; }
.mi.is-logo, .mi.is-initial { display: grid; place-items: center; background: transparent; border-radius: 0; color: var(--text); }
.mi.is-logo svg { width: 100%; height: 100%; display: block; }
.mi.is-initial { font-style: normal; font-size: 11px; font-weight: 650; color: var(--muted); }
.opt-m .mi.is-initial { font-size: 12px; }
.opt-m b { font-size: 13.5px; font-weight: 550; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-m small { color: var(--muted); font-size: 11.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-m[aria-selected="true"] { background: var(--accent-soft); }
.opt-m .ck { color: transparent; }
.opt-m[aria-selected="true"] .ck { color: var(--accent); }
.eff { padding: 4px 16px 16px; border-top: 1px solid var(--line); flex: none; }
.eff .lbl { font-size: 12px; color: var(--muted); margin: 12px 0 8px; display: flex; justify-content: space-between; gap: 10px; }
.eseg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); }
.eseg button { border: 0; background: transparent; border-radius: 8px; padding: 7px 2px; min-height: 36px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eseg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }
.eff p { margin: 8px 0 0; font-size: 11.5px; color: var(--subtle); }
.sheet-empty { color: var(--subtle); font-size: 13px; text-align: center; padding: 20px 10px; margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(130px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text); font-size: 13px; box-shadow: var(--shadow-md);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ── Desktop-style transcript: tool rows, activity line, to-do and goal panels ── */
.msg { margin: 0 0 6px; }
.msg > .prose { margin: 6px 0 8px; }
.worked > summary { flex-direction: row; }
.worked > summary .icon { width: 13px; height: 13px; }
.tr { margin: 0; font: 13.5px/1.4 var(--font-ui); color: var(--muted); }
.tr > summary, .trh { list-style: none; display: flex; align-items: center; gap: 7px; min-height: 30px; min-width: 0; cursor: pointer; }
.tr > summary::-webkit-details-marker { display: none; }
.tr > summary:active { background: var(--hover); border-radius: 6px; }
.ti { flex: none; display: inline-flex; width: 16px; justify-content: center; color: var(--subtle); }
.ti .icon { width: 15px; height: 15px; }
.ti.err { color: var(--err); }
.ti.stop { opacity: .6; }
.ti .spin { width: 12px; height: 12px; }
.tt { flex: none; color: var(--muted); }
.tr.run .tt { background: linear-gradient(90deg, var(--muted) 35%, var(--text) 50%, var(--muted) 65%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: textshine 1.6s linear infinite; }
.sep { flex: none; color: var(--subtle); }
.ts { min-width: 0; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.ts.path { text-decoration: underline dotted var(--line-strong); text-underline-offset: 3px; }
.fb { flex: none; display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 2px; border-radius: 3px; font: 700 8.5px/1 var(--font-ui); color: #fff; }
.tb { flex: none; color: var(--subtle); font-size: 12.5px; }
.add, .del { flex: none; font: 12px var(--font-mono); }
.add { color: var(--ok); }
.del { color: var(--err); }
.tr[open] > summary { color: var(--text); }
.tr > .act-label { margin: 6px 0 2px 23px; }
.tr > pre { margin: 0 0 8px 23px; padding: 8px 10px; border-radius: 8px; background: var(--code-bg); border: 1px solid var(--line); font: 11.5px/1.5 var(--font-mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; }
.tr > pre.err { color: var(--err); }
.activity { display: flex; align-items: center; gap: 7px; margin: 10px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--accent); }
.activity[hidden] { display: none; }
.activity .icon { width: 16px; height: 16px; }
.activity .el { color: var(--accent); font-weight: 600; }
.activity .dots { color: var(--subtle); letter-spacing: 1px; }
.panels { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; }
.panels:empty { display: none; }
.pn { background: var(--raised); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); }
.pn > summary, .pn.goal { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 12px; min-width: 0; }
.pn > summary { cursor: pointer; }
.pn > summary::-webkit-details-marker { display: none; }
.pn .icon { width: 15px; height: 15px; flex: none; }
.pn b { flex: none; color: var(--text); font-weight: 600; }
.pn .pc { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn > summary > .icon:last-child { transition: transform .15s; }
.pn[open] > summary > .icon:last-child { transform: rotate(180deg); }
.pn ul { list-style: none; margin: 0; padding: 0 12px 10px; max-height: 32dvh; overflow-y: auto; }
.pn li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; color: var(--text); line-height: 1.4; }
.pn li.completed span:last-child { color: var(--subtle); text-decoration: line-through; }
.td { flex: none; display: inline-flex; margin-top: 1px; color: var(--subtle); }
.td.done { color: var(--ok); }
.td.doing { color: var(--accent); }
.pn.goal .go { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn.goal.blocked .icon { color: var(--err); }
.pn.goal.active .icon { color: var(--accent); }
@keyframes textshine { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .tr.run .tt { animation: none; color: var(--muted); background: none; } }

/* Machine list ("Máy của tôi"), machine sheets and PIN entry */
.ab h1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ab h1 > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ab .dev .icon { width: 12px; height: 12px; }
.kt { display: inline-flex; flex: none; padding: 0 6px; border-radius: 5px; font-size: 10px; font-weight: 600; letter-spacing: .2px; line-height: 17px; }
.kt.d { color: var(--info); background: var(--info-soft); }
.kt.c { color: var(--accent); background: var(--accent-soft); }
.grp .gc { margin-left: auto; text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 400; color: var(--subtle); }
.mr { width: 100%; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: transparent; text-align: left; }
.rows li + li .mr { border-top: 1px solid var(--line); }
.mr .btn { width: auto; flex: none; padding: 0 14px; min-height: 36px; }
.mr.opt { border-radius: 10px; min-height: 56px; }
.mr.opt:hover, .mr.opt:active { background: var(--hover); }
.mr.opt[aria-current="true"] { background: var(--accent-soft); }
.mi2 { position: relative; width: 36px; height: 36px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.mi2 .icon { width: 18px; height: 18px; }
.mi2 .dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--surface); }
.mi2 .dot.unk { display: none; }
.mt { min-width: 0; }
.mt b { display: flex; gap: 6px; align-items: center; font-size: 13.5px; font-weight: 600; min-width: 0; }
.mt b > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mt small { display: block; color: var(--subtle); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ck2 { color: var(--accent); display: inline-flex; }
.chv { color: var(--subtle); display: inline-flex; }
.card.soft { background: var(--raised); }
.cta { display: flex; gap: 10px; padding: 12px; color: var(--muted); }
.cta .icon { width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.cta b { display: block; color: var(--text); font-size: 13.5px; }
.cta small { font-size: 12px; }
.ctab { display: flex; padding: 0 12px 12px; }
.btn.grow { flex: 1; }
a.btn { text-decoration: none; }
.cta-note { margin: 0; padding: 12px; color: var(--muted); font-size: 12.5px; }
.cmd { margin: 8px 0 0; padding: 8px 10px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; font: 12px/1.6 var(--font-mono); color: var(--text); white-space: pre; overflow-x: auto; }
.card.soft .cmd { margin: 0 12px 12px; }
.add-m { width: 100%; display: flex; gap: 8px; align-items: center; justify-content: center; padding: 11px; border: 1px dashed var(--line-strong); border-radius: 12px; background: transparent; color: var(--muted); font-size: 13px; margin-top: 4px; }
.add-m:hover, .add-m:active { background: var(--hover); color: var(--text); }
.btn.full { width: 100%; margin-top: 6px; }
.btn.ghost { border-color: transparent; background: transparent; }
.center .btn + .btn { margin-top: 8px; }
.opt2 { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; padding: 12px 10px; }
.opt2 + .opt2 { border-top: 1px solid var(--line); }
.opt2 .btn { margin-top: 10px; }
.oi { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.oi .icon { width: 18px; height: 18px; }
.opt2 b { font-size: 14px; }
.opt2 small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.hint2 { font-size: 12.5px; color: var(--text) !important; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.rej-pin { flex: 1; display: flex; flex-direction: column; }
.center-text { text-align: center; margin: 18px 24px 0; }
.pin-form .pin-input { width: 100%; max-width: 220px; margin: 4px 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--input-bg, transparent); color: var(--text); font: 600 26px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 6px; text-align: center; }
.pin-form .pin-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pin-form .b { display: flex; gap: 8px; width: 100%; max-width: 320px; margin-bottom: 14px; }
.pin-form .b .btn { flex: 1; }
.pin-form .b .btn + .btn { margin-top: 0; }
.ic { font: 11.5px var(--font-mono); background: var(--hover); padding: 1px 5px; border-radius: 4px; color: var(--text); }

/* ── RexAPF Web frame: sidebar (shell.js), 52px header, 760px content column ── */
.side {
  width: 275px; flex: none; display: flex; flex-direction: column; gap: 7px; padding: calc(12px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
  background: var(--sidebar); border-right: 1px solid var(--line); overflow: hidden; font-size: 14px;
}
.side-top { display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 4px 6px 10px; color: var(--text); font-size: 15px; font-weight: 620; letter-spacing: -.02em; text-decoration: none; flex: 1; }
.brand-mark { width: 20px; height: 20px; fill: currentColor; flex: none; }
.side-close { display: none; margin-top: -8px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nl { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; white-space: nowrap; }
.nl:hover, .nl:focus-visible { background: var(--hover); }
.nl .nav-i { width: 18px; height: 18px; color: var(--muted); stroke-width: 1.65; }
.nl[aria-current="page"] { background: var(--hover); font-weight: 560; }
.nl[aria-current="page"] .nav-i { color: var(--accent); }
.side-m { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.side-h { display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin-bottom: 4px; }
.side-h h2 { display: flex; align-items: center; gap: 9px; margin: 0; padding-inline: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.side-h h2 .nav-i { width: 18px; height: 18px; }
.side-h .ib { width: 28px; height: 28px; border-radius: 999px; }
.side-h .ib .icon { width: 15px; height: 15px; }
.side-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.mrow { width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 13.5px; }
.mrow:hover, .trow:hover { background: var(--hover); }
.mrow[aria-current="true"], .trow[aria-current="true"] { background: var(--hover); font-weight: 560; }
.mrow small { font-size: 11px; color: var(--subtle); }
.mrow-i { position: relative; display: grid; place-items: center; color: var(--muted); }
.mrow-i .icon { width: 16px; height: 16px; }
.mrow-n, .trow span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd { position: absolute; right: -2px; bottom: -2px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--sidebar); background: var(--line-strong); }
.pd.on { background: var(--ok); }
.side-tasks { list-style: none; margin: 0 0 4px 21px; padding: 0 0 0 6px; border-left: 1px solid var(--line); }
.trow { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 30px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 12.5px; color: var(--muted); }
.trow[aria-current="true"] { color: var(--text); }
.trow small { font-size: 11px; color: var(--subtle); white-space: nowrap; }
.side-empty { margin: 0; padding: 6px 10px; color: var(--subtle); font-size: 12.5px; }
/* Account block = /chat .chat-account: upgrade pill, then the account row that opens the account menu. */
.side-acct { flex: none; display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-upgrade { align-self: center; display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 5px 13px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); font-size: 13px; font-weight: 550; text-decoration: none; }
.side-upgrade:hover, .side-upgrade:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.up-i { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%; }
.up-i .nav-i { width: 11px; height: 11px; stroke-width: 1.8; color: currentColor; }
.acct-row { display: flex; align-items: center; gap: 10px; width: calc(100% + 8px); min-width: 0; min-height: 52px; margin-inline: -4px; padding: 9px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.acct-row:hover, .acct-row:focus-visible, .acct-row[aria-expanded="true"] { background: var(--hover); }
.acct-row .acct-t { flex: 1; }
.acct-chev { width: 16px; height: 16px; flex: none; color: var(--subtle); }
.acct-menu { position: fixed; z-index: 60; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); animation: fade .12s ease-out; }
.am-p { display: flex; align-items: center; gap: 10px; padding: 14px; }
.am-p .acct-t b { font-weight: 650; }
.am-g { padding: 5px 7px; border-top: 1px solid var(--line); }
.am-i { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; text-align: left; }
.am-i:hover, .am-i:focus-visible { background: var(--hover); outline: none; }
.am-i .nav-i { width: 16px; height: 16px; flex: none; color: var(--muted); }
.am-i small { margin-left: auto; color: var(--subtle); font-size: 12px; }
.am-i.danger:hover, .am-i.danger:focus-visible { background: var(--err-soft); color: var(--err); }
.am-i.danger:hover .nav-i, .am-i.danger:focus-visible .nav-i { color: currentColor; }
.av { width: 32px; height: 32px; flex: none; border-radius: 50%; background: #7c5cc4; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.acct-t { min-width: 0; }
.acct-t b, .acct-t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-t b { font-size: 13px; font-weight: 600; }
.acct-t small { font-size: 12px; color: var(--muted); }
.side-scrim { position: fixed; inset: 0; z-index: 30; background: var(--overlay); animation: fade .15s ease-out; }

.ib.menu { display: none; }
.narrow-only { display: none; }
.page { padding: 26px 28px 32px; }
.col { max-width: 760px; margin: 0 auto; }
.ph { display: flex; align-items: flex-end; gap: 12px; margin: 0 0 18px; }
.ph > div:first-child { flex: 1; min-width: 0; }
.ph h2 { margin: 0; font: 500 26px/1.25 var(--font-prose); letter-spacing: -.3px; }
.ph p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ph-a { display: flex; gap: 8px; flex: none; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: 12.5px; }
.mgrid { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mc { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.mc:hover { border-color: var(--line-strong); }
.mc .mi2 { width: 40px; height: 40px; }
.mc .mi2 .icon { width: 20px; height: 20px; }
.mc .mt b { font-size: 14px; }
.mc .mt small { font-size: 12px; color: var(--muted); }
.mc-f { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--subtle); }
.mc-f span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mgrid .add-m { height: 100%; min-height: 118px; margin: 0; }
.btn.danger { color: var(--muted); font-weight: 500; }
.btn.danger:hover:not(:disabled), .btn.danger:focus-visible { background: var(--err-soft); color: var(--err); }
.btn.danger-fill { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger-fill:hover:not(:disabled) { filter: brightness(1.07); background: var(--err); }
.steps { margin: 4px 0 14px; padding: 0 4px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.steps li + li { margin-top: 6px; }
.pair-link { padding: 0 4px; }
.lbl2 { display: block; margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.link-input { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); color: var(--text); font: 13px var(--font-mono); }
.link-input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.sb2 .info { margin: 14px 4px 0; }
.confirm { padding: 14px 16px 16px; }
.confirm p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.confirm .b { display: flex; justify-content: flex-end; gap: 8px; }
.note-m { margin: 8px 2px 0; color: var(--subtle); font-size: 12.5px; }
.page .pin-form { margin: 0 auto; }

@media (min-width: 800px) {
  .ab { min-height: 52px; padding: 0 22px; background: var(--canvas); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .ab.with-back { padding-left: 14px; }
  .ab h1 { font-size: 15px; }
  .wide-only { display: flex; }
  .messages { padding-inline: max(16px, calc((100% - 760px) / 2)); }
  .dock { padding-inline: max(12px, calc((100% - 784px) / 2)); }
  .scrim { align-items: center; }
  .sheet { max-width: 480px; border: 1px solid var(--line); border-radius: 14px; animation: fade .15s ease-out; }
  .sheet .grab { display: none; }
  .sheet .sh { padding-top: 8px; }
}
@media (max-width: 799px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 31; width: min(85vw, 320px); transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s; box-shadow: var(--shadow-md); }
  .side.open { transform: none; visibility: visible; }
  .side-close { display: grid; }
  .nl, .mrow { min-height: 44px; }
  .ib.menu { display: grid; }
  .narrow-only { display: grid; }
  .wide-only { display: none; }
  .page { padding: 14px 14px calc(24px + var(--safe-bottom)); }
  .ph h2 { font-size: 22px; }
  .mgrid { grid-template-columns: 1fr; gap: 8px; }
  .mgrid .add-m { min-height: 48px; }
  .lbl-wide { display: none; }
  .composer-input { font-size: 16px; }
}

/* Narrow screens: the access-mode chip keeps its glyph only; the full name is in its menu and aria-label. */
@media (max-width: 520px) { .mtrig.perm .mt-n { display: none; } .mtrig.perm { padding: 0 4px; } }
.name-input { font: 14px var(--font-ui); margin-bottom: 4px; }
.confirm .b .btn.ghost { margin-right: auto; }
.btn.sm.icon-only { padding-left: 8px; padding-right: 8px; }

/* Queued messages (Desktop queue dock) */
.queue { margin: 0 0 8px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.queue[hidden] { display: none; }
.qd-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; text-align: left; }
.qd-head .icon { width: 15px; height: 15px; flex: none; }
.qd-head b { color: var(--text); font-weight: 600; }
.qd-head .qd-count { flex: 1; min-width: 0; }
.qd-head > .icon:last-child { transition: transform .15s; }
.queue.open .qd-head > .icon:last-child { transform: rotate(180deg); }
.qd-list { list-style: none; margin: 0; padding: 0 6px 6px; max-height: 32dvh; overflow-y: auto; }
.qd-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 6px 6px 8px; border-top: 1px solid var(--line); }
.qd-row:first-child { border-top: 0; }
.qd-row.busy { opacity: .6; }
.qd-n { flex: none; min-width: 18px; height: 18px; margin-top: 6px; border-radius: 9px; background: var(--hover); color: var(--muted); font-size: 11px; line-height: 18px; text-align: center; }
.qd-body { flex: 1; min-width: 0; padding-top: 5px; }
.qd-text { margin: 0; color: var(--text); font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qd-atts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.qd-att { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 1px 7px; border-radius: 6px; background: var(--hover); color: var(--muted); font-size: 11.5px; }
.qd-att span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qd-att .icon { width: 12px; height: 12px; flex: none; }
.qd-actions { flex: none; display: flex; gap: 2px; }
.ib.sm { width: 30px; height: 30px; border-radius: 8px; }
.ib.sm .icon { width: 15px; height: 15px; }
.ib.danger:hover:not(:disabled) { color: var(--err); background: var(--err-soft); }
.qd-edit { width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 8px; background: var(--canvas); color: var(--text); font: inherit; line-height: 1.45; resize: none; }
.qd-edit:focus { outline: none; }
.qd-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.qd-row.editing .qd-body { padding-top: 0; }
