
  /* =====================================================================
     Desk - one file, no framework, no webfonts, no CDN, no build step.
     Dark only. One accent; colour is reserved for meaning (risk, status).
     Spacing follows an 8pt scale (--s1 4px is the half step).
     ===================================================================== */

  :root {
    /* surfaces */
    --bg: #08090d;
    --bg-2: #0b0d12;
    --panel: #10131a;
    --panel-2: #151a23;
    --panel-3: #1a202b;
    --border: #232a38;
    --border-soft: #1a2029;
    --border-strong: #2f3949;
    --text: #e7e9f0;
    --muted: #8b93a6;
    --dim: #5e6678;
    /* meaning */
    --accent: #e5e5e5;
    --accent-2: #ffffff;
    --accent-soft: rgba(255, 255, 255, 0.08);
    --green: #2fbf71;
    --amber: #f0a72c;
    --red: #ef5350;
    --cyan: #38bdf8;
    /* type */
    --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    /* 8pt scale */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;
    /* shape */
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --touch: 44px;
    --topbar-h: 56px;
    --nav-h: 58px;
    --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 18px 48px rgba(0, 0, 0, 0.55);
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
  }

  * { box-sizing: border-box; }
  /* the UA rule loses to class-level display rules; honour the attribute */
  [hidden] { display: none !important; }
  html, body { height: 100%; margin: 0; }
  body {
    background: radial-gradient(1200px 600px at 20% -10%, #141414 0%, var(--bg) 55%) fixed;
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    overscroll-behavior: none;
  }

  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: #262d3b; border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: #333c4d; background-clip: content-box; }

  button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
  input, textarea, select { font: inherit; color: inherit; }
  a { color: var(--accent-2); }
  ::selection { background: rgba(163, 163, 163, 0.35); }
  :focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

  /* ---------------------------------------------------------------------
     shell
     --------------------------------------------------------------------- */
  .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }
  /* iPhone home-screen app (iOS 26+): the page starts at the top edge of the
     screen, under the clock, and ends one status bar short of the bottom; iOS
     paints that bottom strip itself (it holds the home bar), so nothing of the
     page can show there. Keep the page where it is, never let it scroll, and
     do not reserve room for the home bar a second time. */
  html.ios-standalone .app {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--app-height, 100dvh);
  }
  html.ios-standalone, html.ios-standalone body { overflow: hidden; }
  html.ios-short-vp { --safe-b: 0px; }
  /* iPhone zooms the page in when a text box under 16px gets focus, pushing
     the right edge off the screen: text boxes are 16px there. */
  html.ios input:not([type=checkbox]):not([type=radio]):not([type=range]),
  html.ios textarea, html.ios select {
    font-size: 16px !important;
  }
  .app.is-hidden { display: none; }

  .topbar {
    position: relative;
    z-index: 40;
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--s2);
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) calc(var(--s4) + var(--safe-r)) 0 calc(var(--s4) + var(--safe-l));
    border-bottom: 1px solid var(--border-soft);
    background: rgba(10, 12, 17, 0.86);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .topbar .spacer { flex: 1; }

  .brand {
    display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em;
    min-width: 0; flex: 0 1 auto; overflow: hidden;
  }
  .brand-mark {
    width: 26px; height: 26px; border-radius: 9px; flex: none;
    background: conic-gradient(from 210deg, var(--accent), #4c7dff, #22c1c3, var(--accent));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  }
  .brand > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand small {
    color: var(--dim); font-weight: 500; font-size: 12px; letter-spacing: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 0 1 auto; min-width: 0;
  }

  .icon-btn {
    flex: none;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 16px;
    transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
  }
  .icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
  .icon-btn:active { transform: scale(0.96); }
  .icon-btn.sm { width: 30px; height: 30px; font-size: 13px; }
  #nav-toggle { display: none; }

  .pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted); font-size: 12px;
    white-space: nowrap; max-width: 46vw;
  }
  .pill > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .pill.warn { border-color: rgba(240, 167, 44, 0.34); color: #e6c48b; }
  .pill b { color: var(--text); font-weight: 600; }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
  .dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(47, 191, 113, 0.7); }
  .dot.warn { background: var(--amber); }
  .dot.bad { background: var(--red); }

  .main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: var(--side-w, clamp(256px, 21vw, 312px)) minmax(0, 1fr) var(--panel-w, clamp(288px, 27vw, 384px));
  }
  /* Grok-Bot-like default: sidebar + conversation only. The work panel is a
     drawer you open when you actually want to watch the machinery. */
  body.panel-hidden .main {
    grid-template-columns: var(--side-w, clamp(256px, 21vw, 312px)) minmax(0, 1fr);
  }
  body.panel-hidden #panel { display: none; }
  @media (max-width: 860px) {
    body.panel-hidden #panel { display: flex; }   /* mobile keeps its bottom sheet */
  }

  /* ---------------------------------------------------------------------
     left: bots
     --------------------------------------------------------------------- */
  .sidebar {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border-soft);
    background: rgba(10, 12, 17, 0.55);
    display: flex; flex-direction: column;
  }
  .drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s2); padding: var(--s4) var(--s4) var(--s2);
  }
  .drawer-title {
    display: flex; align-items: center; gap: 6px; white-space: nowrap;
    font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--dim); font-weight: 700;
  }
  .drawer-title .mono { letter-spacing: 0; color: var(--muted); }
  #sidebar-close { display: none; }

  .bot-list { padding: var(--s1) var(--s2) var(--s3); display: flex; flex-direction: column; gap: 4px; }
  .bot {
    display: flex; align-items: center; gap: var(--s3);
    width: 100%; padding: 10px;
    border-radius: 14px; text-align: left; cursor: pointer;
    border: 1px solid transparent;
    transition: background 120ms var(--ease), border-color 120ms var(--ease);
  }
  .bot:hover { background: rgba(255, 255, 255, 0.04); }
  .bot.active {
    background: linear-gradient(90deg, rgba(163, 163, 163, 0.20), rgba(163, 163, 163, 0.08));
    border-color: rgba(163, 163, 163, 0.34);
  }
  .bot:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
  .bot-av { cursor: pointer; transition: filter 120ms var(--ease); }
  .bot-av:hover { filter: brightness(1.1); }
  .bot-text { min-width: 0; flex: 1; }
  .bot-name {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700; font-size: 15.5px; letter-spacing: -0.01em;
  }
  .bot-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bot-preview {
    color: var(--dim); font-size: 12.5px; margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ---------------------------------------------------------------------
     avatar: ONE css mask per shape (see AVATAR_SHAPES in the script), shared
     by the sidebar row, the chat header, the customizer preview and its grid.
     --------------------------------------------------------------------- */
  .av {
    position: relative; flex: none;
    width: var(--av-size, 52px); height: var(--av-size, 52px);
    display: grid; place-items: center; overflow: hidden;
    background: var(--av-color, #7c6cf0);
    -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    color: #fff; font-weight: 700; line-height: 1;
    user-select: none;
    padding: 0; border: 0; border-radius: 0;
  }
  .av-face {
    position: absolute; inset: 0;
    background-repeat: no-repeat; background-size: 100% 100%;
    pointer-events: none;
  }
  .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  .av.has-image .av-face { display: none; }
  button.chat-avatar { cursor: pointer; transition: filter 120ms var(--ease); }
  button.chat-avatar:hover { filter: brightness(1.1); }
  .badge {
    font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
    padding: 1px 6px; border-radius: 5px;
    background: var(--accent-soft); color: var(--accent-2);
    border: 1px solid rgba(163, 163, 163, 0.3);
  }

  .new-bot { padding: 0 var(--s3) var(--s5); }
  .ghost-btn {
    width: 100%; min-height: 38px; padding: var(--s2) 10px; border-radius: 9px;
    border: 1px dashed var(--border);
    color: var(--muted); font-size: 12.5px; text-align: center;
    transition: border-color 120ms var(--ease), color 120ms var(--ease);
  }
  .ghost-btn:hover { border-color: var(--accent); color: var(--text); }

  .bot-form { display: none; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }
  .bot-form.open { display: flex; }
  .field {
    width: 100%; min-height: 38px; padding: 8px 10px; border-radius: var(--r-sm);
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text); font-size: 13px; outline: none;
    transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
  }
  .field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(163, 163, 163, 0.10); }
  .field::placeholder { color: var(--dim); }
  select.field { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

  .sidebar-foot {
    margin-top: auto; padding: var(--s3) var(--s4);
    border-top: 1px solid var(--border-soft);
    color: var(--dim); font-size: 11px; line-height: 1.6;
    font-family: var(--mono);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ---------------------------------------------------------------------
     center: chat
     --------------------------------------------------------------------- */
  .chat { min-height: 0; display: flex; flex-direction: column; min-width: 0; }

  .chat-head {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border-soft);
    flex: none; min-height: 64px;
  }
  .chat-head .title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
  .chat-head .sub {
    color: var(--dim); font-size: 12px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw;
  }
  .chat-head .spacer { flex: 1; }

  .messages {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: var(--s5) var(--s5) var(--s3);
    display: flex; flex-direction: column; gap: var(--s4);
    -webkit-overflow-scrolling: touch;
  }
  /* Never let the column compress a message: <details class="chip"> has
     overflow:hidden, so its automatic minimum size is 0 and flex would
     otherwise squash every tool chip into a 16px sliver. */
  .messages > * { flex: 0 0 auto; min-width: 0; }

  /* centred day marker: "11月5日周三 18:05" */
  .day-sep {
    align-self: center;
    margin: var(--s1) 0 0;
    color: var(--dim); font-size: 11.5px; font-weight: 500;
    letter-spacing: 0.02em; text-align: center;
  }

  /* empty state / onboarding */
  .empty { margin: auto; max-width: 470px; width: 100%; text-align: center; padding: var(--s4) var(--s2); }
  .empty h2 { font-size: 17px; margin: 0 0 var(--s1); letter-spacing: -0.01em; }
  .empty p { color: var(--muted); margin: 0 0 var(--s4); font-size: 13px; }

  .onboard {
    text-align: left;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(163, 163, 163, 0.10), rgba(163, 163, 163, 0.03) 55%, transparent);
    border-radius: var(--r-lg);
    padding: var(--s5);
    margin-bottom: var(--s5);
  }
  .onboard-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s2); }
  .onboard-mark {
    width: 34px; height: 34px; border-radius: 11px; flex: none;
    display: grid; place-items: center;
    background: var(--accent-soft); border: 1px solid rgba(163, 163, 163, 0.34);
    color: var(--accent-2); font-size: 15px; font-weight: 700;
  }
  .onboard h2 { font-size: 15.5px; margin: 0; }
  .onboard p { margin: 0 0 var(--s2); font-size: 13px; color: var(--muted); }
  .onboard p:last-of-type { margin-bottom: var(--s4); }
  .onboard-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

  .suggestions { display: flex; flex-direction: column; gap: var(--s2); }
  .suggestion {
    text-align: left; min-height: 40px; padding: 10px 13px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--panel);
    color: var(--muted); font-size: 12.5px;
    transition: border-color 120ms var(--ease), color 120ms var(--ease), transform 120ms var(--ease);
  }
  .suggestion:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }

  .row { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
  .row.user { justify-content: flex-end; }

  .bubble {
    max-width: min(680px, 84%);
    padding: 10px 14px; border-radius: 14px;
    white-space: pre-wrap; overflow-wrap: anywhere;
    border: 1px solid var(--border-soft);
    background: var(--panel);
    font-size: 14px; line-height: 1.55;
  }
  /* rendered markdown inside an assistant bubble */
  .bubble.md { white-space: normal; }
  .bubble.md > *:first-child { margin-top: 0; }
  .bubble.md > *:last-child { margin-bottom: 0; }
  .bubble.md .md-p { margin: 0 0 8px; }
  .bubble.md .md-h { margin: 10px 0 6px; font-size: 14.5px; line-height: 1.35; }
  .bubble.md .md-list { margin: 0 0 8px; padding-left: 20px; }
  .bubble.md .md-list li { margin: 2px 0; }
  .bubble.md code {
    font-family: var(--mono); font-size: 12.5px;
    background: var(--accent-soft); color: var(--text);
    padding: 1px 5px; border-radius: 5px;
  }
  .bubble.md .md-code {
    margin: 8px 0; padding: 10px 12px; border-radius: 10px;
    background: #0d1017; border: 1px solid var(--border-soft);
    overflow-x: auto; white-space: pre; max-width: 100%;
  }
  .bubble.md .md-code code { background: none; padding: 0; font-size: 12px; line-height: 1.5; }
  /* On a phone the bubble is ~330px wide: a 4-column table cannot fit, so let it
     take its natural width and scroll sideways instead of squeezing every cell
     into two characters ("Rock|y"). */
  .bubble.md .md-table {
    margin: 8px 0; overflow-x: auto; overscroll-behavior-x: contain;
    max-width: 100%; -webkit-overflow-scrolling: touch;
  }
  .bubble.md .md-table table { border-collapse: collapse; font-size: 13px; width: max-content; min-width: 100%; }
  .bubble.md .md-table th,
  .bubble.md .md-table td {
    border: 1px solid var(--border-soft); padding: 5px 9px; text-align: left; vertical-align: top;
    max-width: 22em; overflow-wrap: anywhere;
  }
  .bubble.md .md-table th { background: rgba(255,255,255,.04); font-weight: 650; white-space: nowrap; }
  .bubble.md .md-quote {
    margin: 8px 0; padding: 2px 0 2px 10px;
    border-left: 2px solid var(--border); color: var(--muted);
  }
  .bubble.md .md-rule { border: 0; border-top: 1px solid var(--border-soft); margin: 10px 0; }
  .bubble.md a { color: var(--accent-2); text-decoration: none; }
  .bubble.md a:hover { text-decoration: underline; }

  .row.user .bubble {    background: linear-gradient(180deg, rgba(163, 163, 163, 0.22), rgba(163, 163, 163, 0.13));
    border-color: rgba(163, 163, 163, 0.32);
    border-bottom-right-radius: 6px;
  }
  .row.assistant .bubble { background: var(--panel); border-bottom-left-radius: 6px; }
  .bubble.system {
    background: rgba(240, 167, 44, 0.08); border-color: rgba(240, 167, 44, 0.28);
    color: #f3d9a4;
  }

  .streaming::after {
    content: ""; display: inline-block; width: 7px; height: 14px;
    margin-left: 2px; vertical-align: -2px;
    background: var(--accent-2);
    animation: blink 1s steps(2, start) infinite;
  }
  @keyframes blink { 50% { opacity: 0; } }

  /* tool chips */
  .chip {
    max-width: min(680px, 100%);
    border: 1px solid var(--border-soft); border-radius: 10px;
    background: var(--bg-2); font-family: var(--mono); font-size: 11.5px;
    overflow: hidden;
  }
  .chip summary {
    list-style: none; cursor: pointer; min-height: 38px;
    padding: 9px 12px;
    display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
    color: var(--muted);
    transition: color 120ms var(--ease), background 120ms var(--ease);
  }
  .chip summary::-webkit-details-marker { display: none; }
  .chip summary:hover { color: var(--text); background: rgba(255, 255, 255, 0.02); }
  .chip-icon { font-weight: 700; width: 12px; flex: none; text-align: center; }
  .chip-icon.ok { color: var(--green); }
  .chip-icon.fail { color: var(--red); }
  .chip-icon.pending { color: var(--accent-2); animation: blink 1s steps(2, start) infinite; }
  .chip-name { color: var(--text); font-weight: 600; }
  .chip-time { color: var(--dim); font-size: 10.5px; margin-left: auto; }
  .chip-more { color: var(--dim); font-size: 10.5px; flex: none; }
  .chip-more .when-open { display: none; }
  .chip[open] .chip-more .when-open { display: inline; }
  .chip[open] .chip-more .when-closed { display: none; }
  .chip .body { border-top: 1px solid var(--border-soft); padding: 10px 12px; display: flex; flex-direction: column; gap: var(--s2); }
  .block { position: relative; min-width: 0; }
  .block-label { color: var(--dim); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 3px; }
  .block-pre {
    margin: 0; white-space: pre-wrap; overflow-wrap: anywhere;
    color: var(--muted); max-height: 260px; overflow: auto;
  }
  .block.clamped .block-pre {
    max-height: 132px; overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  }
  .block-expand { margin-top: 6px; }
  .chip .fail-mark { color: var(--red); }
  .chip .ok-mark { color: var(--green); }

  .risk {
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em;
    padding: 1px 5px; border-radius: 4px; font-family: var(--sans);
  }
  .risk.LOW { background: rgba(47, 191, 113, 0.14); color: #6ee7a8; }
  .risk.MEDIUM { background: rgba(240, 167, 44, 0.15); color: #f4c273; }
  .risk.HIGH { background: rgba(239, 83, 80, 0.16); color: #ff8f8c; }

  /* approval card */
  .approval {
    max-width: min(680px, 100%);
    border: 1px solid rgba(240, 167, 44, 0.38);
    background: linear-gradient(180deg, rgba(240, 167, 44, 0.10), rgba(240, 167, 44, 0.035));
    border-radius: var(--r); padding: var(--s3) var(--s4);
    box-shadow: 0 0 0 1px rgba(240, 167, 44, 0.05) inset;
  }
  .approval.resolved { border-color: var(--border); background: var(--panel); opacity: 0.85; }
  /* Landed here from a notification: make it obvious which card asked. */
  .approval.is-focus {
    border-color: rgba(240, 167, 44, 0.9);
    box-shadow: 0 0 0 3px rgba(240, 167, 44, 0.16), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
  /* Reached from "N 个操作等你确认": the card lights up twice. */
  .flash { border-color: rgba(240, 167, 44, 0.9); animation: card-flash 0.9s ease-in-out 2; }
  @keyframes card-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240, 167, 44, 0); }
    50% { box-shadow: 0 0 0 5px rgba(240, 167, 44, 0.32); }
  }
  @media (prefers-reduced-motion: reduce) { .flash { animation: none; box-shadow: 0 0 0 3px rgba(240, 167, 44, 0.3); } }
  .approval-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: 6px; flex-wrap: wrap; }
  .approval-title { font-weight: 650; font-size: 13px; }
  .approval-wait {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10.5px; color: #f4c273; letter-spacing: 0.03em;
  }
  .approval-wait .dot { background: var(--amber); animation: pulse 1.8s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.35; } }
  .approval-why { color: var(--muted); font-size: 12px; margin-bottom: var(--s2); }
  .approval-args {
    font-family: var(--mono); font-size: 11px; color: var(--muted);
    background: rgba(0, 0, 0, 0.32); border: 1px solid var(--border-soft);
    border-radius: var(--r-sm); padding: 8px 10px; max-height: 150px; overflow: auto;
    white-space: pre-wrap; overflow-wrap: anywhere;
  }
  .approval-args.clamped { max-height: 96px; overflow: hidden; }
  .approval-actions { display: flex; gap: var(--s2); margin-top: var(--s3); align-items: center; flex-wrap: wrap; }
  .approval-actions .field { flex: 1 1 160px; min-width: 0; }

  .btn {
    min-height: 36px; padding: 7px 14px; border-radius: var(--r-sm);
    font-size: 12.5px; font-weight: 600;
    border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
    transition: border-color 120ms var(--ease), background 120ms var(--ease), transform 80ms var(--ease);
    white-space: nowrap;
  }
  .btn:hover { border-color: var(--dim); }
  .btn:active { transform: translateY(1px); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
  .btn.ghost { background: transparent; color: var(--muted); }
  .btn.ghost:hover { color: var(--text); border-color: var(--dim); }
  .btn.danger { border-color: rgba(239, 83, 80, 0.42); color: #ff9d9a; }
  .btn.danger:hover { background: rgba(239, 83, 80, 0.12); }
  .btn.tiny { min-height: 28px; padding: 3px 9px; font-size: 11.5px; font-weight: 500; }
  .btn.block { width: 100%; }
  .btn:disabled { opacity: 0.5; cursor: default; }
  .btn:disabled:hover { border-color: var(--border); }

  .status-line {
    display: flex; align-items: center; gap: 7px;
    color: var(--dim); font-size: 11.5px; padding-left: 2px;
  }

  /* composer */
  .notice {
    flex: none;
    display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
    margin: 0 var(--s5);
    padding: 8px 12px;
    border: 1px solid rgba(240, 167, 44, 0.28);
    background: rgba(240, 167, 44, 0.08);
    border-radius: var(--r-sm);
    color: #e6c48b; font-size: 12px;
  }
  .notice .btn { margin-left: auto; }
  .notice[hidden] { display: none; }

  .composer {
    flex: none;
    padding: var(--s3) var(--s5) calc(var(--s4) + var(--safe-b));
    border-top: 1px solid var(--border-soft);
    background: linear-gradient(180deg, transparent, rgba(8, 9, 13, 0.6));
  }
  .composer-box {
    display: flex; gap: 10px; align-items: flex-end;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 8px 10px 8px 14px;
    transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
  }
  .composer-box:focus-within { border-color: rgba(163, 163, 163, 0.6); box-shadow: 0 0 0 3px rgba(163, 163, 163, 0.10); }
  .composer textarea {
    flex: 1; resize: none; border: none; outline: none; background: none;
    max-height: 160px; min-height: 24px; line-height: 1.5; padding: 3px 0;
    font-size: 14px;
  }
  .composer textarea::placeholder { color: var(--dim); }
  .composer textarea:disabled { color: var(--dim); cursor: not-allowed; }
  .send-btn {
    width: 36px; height: 36px; border-radius: 10px; flex: none;
    background: var(--accent); color: #fff; display: grid; place-items: center;
    font-size: 16px; transition: background 120ms var(--ease), opacity 120ms var(--ease);
  }
  .send-btn:hover { background: var(--accent-2); }
  .send-btn:disabled { background: var(--panel-3); color: var(--dim); }
  .composer-hint { color: var(--dim); font-size: 11px; margin-top: 7px; padding-left: 3px; }

  /* ---------------------------------------------------------------------
     right: panel
     --------------------------------------------------------------------- */
  .panel {
    min-height: 0; display: flex; flex-direction: column;
    position: relative;
    border-left: 1px solid var(--border-soft);
    background: rgba(10, 12, 17, 0.5);
  }
  .grip { display: none; }

  /* Drag either divider to resize: sidebar (left) and work panel (right).
     Widths are remembered in localStorage; double-click restores the default. */
  .edge-resizer {
    position: absolute; top: 0; bottom: 0; width: 10px;
    cursor: col-resize; z-index: 6; background: transparent; touch-action: none;
  }
  .edge-resizer::after {
    content: ''; position: absolute; top: 0; bottom: 0; width: 2px;
    background: rgba(255, 255, 255, 0.06);
    transition: background 120ms var(--ease);
  }
  .edge-resizer:hover::after, body.resizing .edge-resizer::after { background: var(--accent); }
  .panel-resizer { left: -5px; }
  .panel-resizer::after { left: 4px; }
  .sidebar-resizer { right: -5px; }
  .sidebar-resizer::after { right: 4px; }
  body.resizing { cursor: col-resize; user-select: none; }
  body.resizing iframe { pointer-events: none; }

  /* "Whole window" mode for the desktop tab (Grok-Bot style): the work panel
     covers the window and only the single desktop card remains. */
  body.panel-max #sidebar,
  body.panel-max .main > .chat,
  body.panel-max .scrim { display: none !important; }
  body.panel-max .main { grid-template-columns: minmax(0, 1fr) !important; }
  body.panel-max #panel {
    position: static; border-left: 0; background: var(--bg);
    width: 100%; height: 100%;
  }
  body.panel-max #panel .tabs,
  body.panel-max #pane-computer > .section-head,
  body.panel-max #pc-stats,
  body.panel-max #pc-procs { display: none !important; }
  body.panel-max #panel .panel-body {
    display: flex; flex-direction: column; overflow: hidden; padding: 0; min-height: 0;
  }
  body.panel-max #pane-computer.active { flex: 1; min-height: 0; display: block; }
  /* The card itself goes full-window; a screenshot stays contain-fitted so
     nothing is cropped, and a live VNC session fills the same surface. */
  body.panel-max #pc-screen-wrap {
    position: fixed; inset: 0; z-index: 90; margin: 0; border: 0; border-radius: 0;
    background: #05070b; display: flex; align-items: center; justify-content: center;
  }
  body.panel-max #pc-screen { width: 100%; height: 100%; object-fit: contain; }
  body.panel-max #pc-vnc-wrap {
    position: absolute; inset: 0; width: auto; height: auto; aspect-ratio: auto;
  }
  body.panel-max #pc-exit { display: inline-flex; }
  .pc-done {
    display: none;
    position: fixed; right: calc(150px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); z-index: 95;
    border-radius: 10px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
    /* The fullscreen surface is always black, so these never follow the theme. */
    background: #fff; color: #0a0a0a; border: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  }
  body.panel-max .pc-done.show { display: inline-flex; }
  .conn-banner {
    display: flex; align-items: center; gap: 10px; margin: 8px 16px 0; padding: 8px 12px;
    border-radius: 10px; font-size: 12.5px; color: #fde68a;
    background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35);
  }
  .conn-banner[hidden] { display: none; }
  .conn-banner span { flex: 1; min-width: 0; }
  .machine-dot.off { background: var(--red, #ef4444); }
  #machine-menu .mm-att.off { color: var(--dim); font-weight: 500; }
  .pc-exit {
    display: none;
    position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); z-index: 95;
    background: rgba(0, 0, 0, 0.55); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    border-radius: 10px; padding: 8px 14px; font-size: 12.5px; cursor: pointer;
  }
  .pc-exit:hover { background: var(--accent); color: #fff; }
  /* Phones: over the remote picture a blurred see-through button came out as
     dark text on dark (seen on Android). Solid, bigger, easy to hit. */
  @media (pointer: coarse) {
    .pc-exit {
      backdrop-filter: none; background: #232a38; border-color: rgba(255, 255, 255, 0.32);
      color: #fff; font-size: 14px; font-weight: 600; padding: 11px 18px; border-radius: 12px;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    }
  }

  .key-link { color: var(--accent-2); text-decoration: none; display: inline-block; margin-top: 4px; }
  .key-link:hover { text-decoration: underline; }
  .tabs { display: flex; align-items: center; gap: 2px; padding: 10px 10px 0; flex: none; }
  .tab {
    flex: 1; min-height: 36px; padding: 7px 4px; text-align: center;
    font-size: 12px; font-weight: 600; color: var(--dim);
    border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
    transition: color 120ms var(--ease), background 120ms var(--ease), border-color 120ms var(--ease);
  }
  .tab:hover { color: var(--muted); background: rgba(255, 255, 255, 0.03); }
  .tab.active { color: var(--text); border-bottom-color: var(--accent); }
  .panel-close { display: none; }

  .panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s3) var(--s4) var(--s5); }
  .pane { display: none; flex-direction: column; gap: var(--s2); }
  .pane.active { display: flex; }

  .section-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
    font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--dim); font-weight: 700; margin: var(--s1) 0 var(--s2);
  }
  .muted { color: var(--muted); }
  .tiny { font-size: 11.5px; }

  /* "show the machinery" switch in the Activity pane */
  .switch-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--muted); margin: 0 0 var(--s3); cursor: pointer;
    user-select: none;
  }
  .switch-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
  .icon-btn.on { color: var(--accent-2); background: var(--accent-soft); }

  /* 电脑 tab: a screen you can watch + the vitals of the hub box */
  .pc-screen {
    position: relative; border: 1px solid var(--border-soft); border-radius: 10px;
    background: #0a0c11; overflow: hidden; margin-bottom: var(--s3);
  }
  .pc-screen img { display: block; width: 100%; height: auto; }
  .pc-screen-note {
    padding: 26px 14px; text-align: center; color: var(--dim); font-size: 12px; line-height: 1.6;
  }
  .pc-stats { display: grid; gap: 2px; }
  .pc-row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 12.5px;
  }
  .pc-row span { color: var(--muted); }
  .pc-row b { font-weight: 600; color: var(--text); text-align: right; }

  /* The single desktop card: a live screenshot by default, and the same
     surface becomes a noVNC viewer when the user takes over. */
  .pc-screen.takeover #pc-screen,
  .pc-screen.takeover #pc-screen-note,
  .pc-screen.viewer #pc-screen,
  .pc-screen.viewer #pc-screen-note { display: none !important; }
  .pc-vnc-layer {
    position: relative; width: 100%; aspect-ratio: 16 / 10; background: #000;
  }
  .pc-vnc-layer iframe {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block;
  }
  .pc-screen.preview .pc-vnc-layer { cursor: default; }
  .pc-screen.preview .pc-vnc-layer iframe { pointer-events: none; }
  .pc-vnc-shield {
    position: absolute; inset: 0; z-index: 4; display: flex;
    flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 0 0 18px; pointer-events: auto;
    background: linear-gradient(180deg, rgba(5,7,11,0) 55%, rgba(5,7,11,0.55) 100%);
  }
  .pc-shield-hint { display: none; color: #cfd4e2; font-size: 11px; letter-spacing: .02em; }
  @media (max-width: 860px) { .pc-shield-hint { display: block; } }
  .pc-vnc-shield[hidden] { display: none; }
  /* Already full screen: "点按画面进全屏" would only confuse. */
  body.panel-max .pc-shield-hint { display: none !important; }
  /* Light (openbox) and kiosk (cage) screens are empty until a bot opens a
     window. The note sits under the screen: on top of it, it covered the
     browser once one was open (the page cannot tell an empty screen apart). */
  .pc-light-hint {
    margin: 8px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.6;
  }
  .pc-light-hint[hidden] { display: none; }
  .pc-preview-badge {
    position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.14);
    background: rgba(10, 12, 18, 0.72); backdrop-filter: blur(8px);
    color: #d8dbe5; font-size: 10.5px; letter-spacing: 0.02em;
  }
  .pc-preview-badge i {
    width: 6px; height: 6px; border-radius: 50%; background: #35d07f;
    box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.14);
  }
  .pc-vnc-shield .btn {
    position: relative; z-index: 1; pointer-events: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  }
  body.panel-max .pc-vnc-shield { padding-bottom: 54px; }
  /* Touch takeover: the noVNC control bar is a desktop affordance, so phones
     get a permanent strip of the keys a remote session actually needs. */
  .pc-mobile-bar {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0;
  }
  .pc-mobile-bar button {
    flex: 1 1 auto; min-width: 54px; padding: 10px 6px; border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(0, 0, 0, 0.55);
    color: #fff; font: 600 12px/1 var(--sans);
    backdrop-filter: blur(8px);
  }
  .pc-mobile-bar button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  body.panel-max .pc-mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
    background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.08);
  }
  /* Phone takeover: our own touch layer turns fingers into a mouse (the
     picture never sees the touches, so it cannot pop the keyboard up). */
  .pc-touch { position: absolute; inset: 0; z-index: 3; touch-action: none; }
  .pc-touch[hidden] { display: none; }
  /* A ring on the spot a tap will click: the remote machine draws its own
     pointer, so a second arrow next to it only confused (seen on a phone). */
  .pc-cursor {
    position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; pointer-events: none;
    border-radius: 50%; border: 2px solid #fff; box-sizing: border-box;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.55), inset 0 0 0 1.5px rgba(0, 0, 0, 0.35);
  }
  .pc-touch.direct .pc-cursor { display: none; }
  #pc-vnc-wrap { transform-origin: 0 0; }
  body.pc-touching .pc-exit { display: none !important; }
  .pcm-handle { display: none; }
  /* The keyboard is up during a phone takeover: the bar sits right on top of
     it (inside the sheet it ended up under the keyboard, 键盘 included). */
  body.pc-touching.kb-open .pc-mobile-bar {
    position: fixed; left: 0; right: 0; bottom: var(--kb-bottom, 0px); z-index: 120;
    padding: 6px calc(8px + var(--safe-r)) 6px calc(8px + var(--safe-l));
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(10px);
  }
  body.pcm-collapsed .pc-mobile-bar { display: none !important; }
  body.pcm-collapsed.pc-touching .pcm-handle {
    display: block; position: fixed; z-index: 96;
    right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b));
    padding: 10px 14px; border-radius: 999px; font: 600 12px/1 var(--sans); color: #fff;
    background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.18); backdrop-filter: blur(8px);
  }
  /* User-controlled rotation: the picture turns, the controls stay upright.
     No orientation lock — the same button turns it back. */
  body.panel-max.pc-rotated #pc-screen-wrap {
    inset: auto; left: 50%; top: 50%;
    width: 100vh; height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
  /* Real landscape (native lock or browser fullscreen): fill the viewport and
     keep the controls on the right edge, upright, 44px touch targets. */
  /* The 76px column is for the touch keys of a takeover; only looking, there is
     no column, and keeping the space left a white strip (seen on a phone). */
  body.panel-max.pc-native-landscape.pc-touching #pc-screen-wrap { right: 76px; }
  body.panel-max.pc-landscape .pc-mobile-bar {
    left: auto; right: 0; top: 0; bottom: 0; width: 76px;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start;
    overflow-y: auto; overscroll-behavior: contain;
    padding: calc(10px + var(--safe-t)) 8px calc(10px + var(--safe-b));
    border-top: 0; border-left: 1px solid rgba(255, 255, 255, 0.08);
  }
  body.panel-max.pc-landscape .pc-mobile-bar button { width: 100%; min-width: 0; min-height: 40px; flex: none; }
  /* Clipboard drawer: explicit paste in, explicit copy out. Works on plain
     http where navigator.clipboard does not exist. */
  .clip-drawer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 97;
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--panel); border-top: 1px solid var(--border-soft);
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.4);
  }
  .clip-drawer[hidden] { display: none; }
  .clip-head { display: flex; align-items: center; justify-content: space-between; }
  .clip-drawer textarea {
    width: 100%; min-height: 84px; resize: vertical; border-radius: 10px;
    border: 1px solid var(--border-soft); background: var(--panel-2);
    color: var(--text); font: 13px/1.5 var(--sans); padding: 9px 10px; outline: none;
  }
  .clip-drawer textarea:focus { border-color: var(--accent); }
  .clip-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .clip-row .btn { flex: 1 1 auto; }
  #clip-scrim { z-index: 96; }
  .pc-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
  .pc-monitor { width: auto; min-width: 0; height: 26px; padding: 0 6px; font-size: 12px; border-radius: 6px; }

  /* author display rules below would otherwise beat the UA [hidden] style */
  #pane-computer [hidden] { display: none !important; }

  /* The panel is a screen viewer, not a dashboard: host stats, process list and
     the redundant hint line stay out of the way. */
  #pc-stats,
  #pc-procs,
  #pc-procs-head { display: none !important; }

  /* "working…" row */
  .typing-row {
    display: flex; align-items: center; gap: 8px; padding: 8px 2px; color: var(--muted); font-size: 12.5px;
  }
  .typing-dots { display: inline-flex; gap: 3px; }
  .typing-dots i {
    width: 5px; height: 5px; border-radius: 50%; background: var(--muted);
    animation: typingPulse 1.1s infinite ease-in-out;
  }
  .typing-dots i:nth-child(2) { animation-delay: .15s; }
  .typing-dots i:nth-child(3) { animation-delay: .3s; }
  @keyframes typingPulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

  .pill.warn {
    background: rgba(251, 191, 36, .14); color: #fbbf24;
    border-color: rgba(251, 191, 36, .38); cursor: pointer;
  }
  .pill.warn[hidden] { display: none; }

  /* Frameless desktop shell: the page is the title bar. Everything in the
     topbar drags the window except the actual controls. Hidden in a browser. */
  body.shell .topbar { -webkit-app-region: drag; user-select: none; }
  body.shell .topbar button,
  body.shell .topbar .pill,
  body.shell .topbar a,
  body.shell .topbar input { -webkit-app-region: no-drag; }
  .winbtns { display: none; }
  body.shell .winbtns { display: inline-flex; gap: 2px; margin-left: 6px; }
  .winbtns button {
    width: 36px; height: 28px; border: 0; border-radius: 7px;
    background: transparent; color: var(--muted);
    font-size: 13px; line-height: 1; cursor: default;
    display: grid; place-items: center;
  }
  .winbtns button:hover { background: rgba(255,255,255,.07); color: var(--text); }
  .winbtns .win-close:hover { background: #e11d48; color: #fff; }

  /* account & devices popover */
  .account-btn { border-radius: 50% !important; font-weight: 700; font-size: 12.5px; }
  .account-menu {
    position: fixed; top: 52px; right: 12px; z-index: 60; width: 292px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: 12px; box-shadow: 0 18px 48px rgba(0,0,0,.5);
  }
  .account-menu[hidden] { display: none; }
  .am-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
  .am-avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  }
  .am-name { font-size: 13.5px; font-weight: 650; }
  .am-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
  .am-row {
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 12px; color: var(--muted); padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,.04);
  }
  .am-row b { color: var(--text); font-weight: 600; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .am-actions { display: flex; gap: 8px; margin: 10px 0 6px; }
  .am-actions .btn { flex: 1; }
  .am-note { font-size: 11px; color: var(--dim); line-height: 1.5; }
  .mono { font-family: var(--mono); }

  .card {
    border: 1px solid var(--border-soft); border-radius: 10px;
    background: var(--panel); padding: var(--s3);
  }
  .card-title { font-weight: 650; font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
  .card-sub { color: var(--dim); font-size: 11.5px; margin-top: 2px; }

  .activity-item {
    display: flex; gap: var(--s2); padding: 7px 2px;
    border-bottom: 1px solid var(--border-soft); font-size: 12px;
  }
  .activity-item:last-child { border-bottom: none; }
  .activity-when { color: var(--dim); font-family: var(--mono); font-size: 10.5px; flex: none; width: 40px; padding-top: 1px; }
  .activity-kind { flex: none; font-weight: 700; font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; padding-top: 2px; width: 60px; }
  .activity-text { color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
  .k-turn { color: var(--accent-2); }
  .k-tool { color: var(--cyan); }
  .k-approval { color: var(--amber); }
  .k-error { color: var(--red); }
  .k-message { color: var(--green); }

  .skill-steps { margin: var(--s2) 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
  .skill-steps li { margin-bottom: 3px; }
  .skill-body { margin-top: var(--s2); font-size: 12px; color: var(--muted); white-space: pre-wrap; }

  .routine-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
  .tag {
    font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
    background: var(--panel-3); color: var(--muted); border: 1px solid var(--border-soft);
    white-space: nowrap;
  }
  .tag.good { color: #7fe0a8; border-color: rgba(47, 191, 113, 0.3); background: rgba(47, 191, 113, 0.1); }
  .tag.bad { color: #ff9d9a; border-color: rgba(239, 83, 80, 0.3); background: rgba(239, 83, 80, 0.1); }
  .tag.warn { color: #f4c273; border-color: rgba(240, 167, 44, 0.3); background: rgba(240, 167, 44, 0.1); }

  .mem-pre {
    margin: 0; font-family: var(--mono); font-size: 11px; color: var(--muted);
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 340px; overflow: auto;
    background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--r-sm); padding: 10px;
  }

  .form-grid { display: flex; flex-direction: column; gap: var(--s2); }
  .form-grid .row-2 { display: flex; gap: var(--s2); }
  .form-grid .row-2 > * { flex: 1; min-width: 0; }
  label.lbl { font-size: 11px; color: var(--dim); }

  /* ---------------------------------------------------------------------
     toast
     --------------------------------------------------------------------- */
  .toast {
    position: fixed; left: 50%; top: calc(76px + var(--safe-t));
    transform: translateX(-50%) translateY(-10px);
    background: var(--panel-3); border: 1px solid var(--border);
    color: var(--text); padding: 9px 15px; border-radius: 16px;
    font-size: 12.5px; line-height: 1.55; opacity: 0; pointer-events: none;
    transition: opacity 160ms var(--ease), transform 160ms var(--ease);
    z-index: 120; max-width: min(92vw, 480px); text-align: center;
    box-shadow: var(--shadow-2);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.error { border-color: rgba(239, 83, 80, 0.5); }

  /* ---------------------------------------------------------------------
     scrim + slide-over surfaces
     --------------------------------------------------------------------- */
  .scrim {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(4, 5, 8, 0.62);
    backdrop-filter: blur(1.5px);
    opacity: 0; pointer-events: none; visibility: hidden;
    transition: opacity 200ms var(--ease), visibility 0s linear 200ms;
  }
  .scrim.show { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity 200ms var(--ease); }

  /* At desktop widths the sidebar and the panel are static columns: their
     scrims must never paint, whatever classes the DOM happens to carry. */
  @media (min-width: 861px) {
    #sidebar-scrim, #panel-scrim { display: none !important; }
  }

  /* settings drawer */
  .drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
    width: min(448px, 100vw);
    display: flex; flex-direction: column;
    background: var(--panel);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    transform: translateX(102%);
    transition: transform 260ms var(--ease);
    padding-top: var(--safe-t);
  }
  .drawer.open { transform: translateX(0); }
  .drawer .drawer-head {
    padding: var(--s4) var(--s4) var(--s3);
    border-bottom: 1px solid var(--border-soft);
    flex: none;
  }
  .drawer .drawer-title { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); font-weight: 650; }
  .drawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s4) var(--s4) calc(var(--s7) + var(--safe-b)); }

  .dsec { padding: var(--s4) 0; border-bottom: 1px solid var(--border-soft); }
  .dsec:first-child { padding-top: 0; }
  .dsec:last-child { border-bottom: none; }
  .dsec-head { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--text); margin-bottom: var(--s1); }
  .dsec-sub { color: var(--dim); font-size: 11.5px; margin: 0 0 var(--s3); }
  .dsec .lbl { display: block; margin: var(--s3) 0 5px; }
  .dsec .lbl:first-of-type { margin-top: 0; }
  .btn-row { display: flex; gap: var(--s2); margin-top: var(--s4); flex-wrap: wrap; }
  .btn-row .btn { flex: 1 1 auto; }
  .row-note { font-size: 11px; color: var(--dim); margin-top: 6px; }

  .set-status {
    margin-top: var(--s3); padding: 9px 11px; border-radius: var(--r-sm);
    font-size: 12px; border: 1px solid var(--border); background: var(--bg-2); color: var(--muted);
    overflow-wrap: anywhere;
  }
  .set-status.ok { border-color: rgba(47, 191, 113, 0.34); color: #8ee8b6; background: rgba(47, 191, 113, 0.08); }
  .set-status.bad { border-color: rgba(239, 83, 80, 0.36); color: #ff9d9a; background: rgba(239, 83, 80, 0.08); }
  .set-status.busy { border-color: rgba(163, 163, 163, 0.36); color: var(--accent-2); }
  .set-status[hidden] { display: none; }

  .notice-inline {
    border: 1px solid rgba(240, 167, 44, 0.3); background: rgba(240, 167, 44, 0.08);
    color: #e6c48b; border-radius: var(--r-sm); padding: 10px 12px;
    font-size: 11.5px; margin-bottom: var(--s4);
  }
  .notice-inline[hidden] { display: none; }

  .pair-card {
    border: 1px solid var(--border); border-radius: var(--r);
    background: linear-gradient(180deg, rgba(163, 163, 163, 0.08), transparent 70%), var(--bg-2);
    padding: var(--s4);
  }
  .pair-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
  .pair-row { display: flex; align-items: center; gap: var(--s2); margin-top: 4px; }
  .pair-value {
    flex: 1; min-width: 0; font-size: 13px; color: var(--text);
    overflow-wrap: anywhere; user-select: all;
  }
  .pair-code {
    font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: 0.14em;
    color: var(--text); line-height: 1.2; user-select: all; margin-top: 4px;
  }
  .pair-code.empty { font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--dim); padding: 6px 0; }
  .pair-hint { color: var(--muted); font-size: 12px; margin-top: var(--s3); line-height: 1.5; }
  .pair-empty { color: var(--dim); font-size: 12px; line-height: 1.6; }

  /* the QR a phone scans */
  .qr-box {
    margin-top: var(--s3); padding: 12px; border-radius: var(--r-sm);
    background: #fff; display: flex; align-items: center; justify-content: center;
    min-height: 220px; overflow: hidden;
  }
  .qr-box svg { width: 100%; max-width: 260px; height: auto; display: block; }
  .qr-hint { color: #666; font-size: 12px; text-align: center; padding: 12px; }
  .qr-url { margin-top: var(--s3); font-size: 11.5px; color: var(--dim); overflow-wrap: anywhere; word-break: break-all; }
  .qr-count { margin-top: 6px; font-size: 12px; color: var(--muted); }
  .pair-tabs { display: flex; gap: 6px; margin-bottom: var(--s2); flex-wrap: wrap; }
  .pair-tabs .btn.active { border-color: var(--accent); color: var(--text); }

  /* the paired phones */
  .device-list { display: flex; flex-direction: column; gap: 8px; margin-top: var(--s2); }
  .device-item {
    display: flex; align-items: center; gap: var(--s2);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 10px 12px; background: var(--bg-2);
  }
  .device-main { flex: 1; min-width: 0; }
  .device-name { font-size: 13px; color: var(--text); }
  .device-meta { font-size: 11.5px; color: var(--dim); margin-top: 2px; overflow-wrap: anywhere; }

  .kv { display: flex; justify-content: space-between; gap: var(--s3); font-size: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border-soft); }
  .kv:last-child { border-bottom: none; }
  .kv .k { color: var(--dim); }
  .kv .v { color: var(--muted); text-align: right; overflow-wrap: anywhere; }

  /* ---------------------------------------------------------------------
     avatar customizer (slide-over on desktop, bottom sheet on phones)
     --------------------------------------------------------------------- */
  #avatar-scrim { z-index: 92; }
  .avatar-sheet .drawer-title { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); font-weight: 650; }
  .avatar-sheet {
    position: fixed; z-index: 95;
    top: 0; right: 0; bottom: 0;
    width: min(404px, 100vw);
    display: flex; flex-direction: column;
    background: var(--panel-2);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    transform: translateX(102%);
    transition: transform 260ms var(--ease);
    padding-top: var(--safe-t);
    will-change: transform;
  }
  .avatar-sheet.open { transform: translateX(0); }
  .avatar-body {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: var(--s4) var(--s5) calc(var(--s6) + var(--safe-b));
  }
  .avatar-preview {
    display: grid; place-items: center;
    padding: var(--s5) 0;
    border-radius: var(--r-lg);
    background: radial-gradient(260px 130px at 50% 35%, rgba(163, 163, 163, 0.18), transparent 72%), var(--bg-2);
    border: 1px solid var(--border-soft);
  }
  .avatar-hint { text-align: center; color: var(--dim); font-size: 11.5px; margin-top: var(--s3); }
  .avatar-note {
    margin-top: var(--s3); padding: 9px 11px; border-radius: var(--r-sm);
    border: 1px solid rgba(240, 167, 44, 0.28); background: rgba(240, 167, 44, 0.08);
    color: #e6c48b; font-size: 11.5px; line-height: 1.5;
  }
  .avatar-note[hidden] { display: none; }
  .avatar-section { margin-top: var(--s5); }
  .section-label {
    font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--dim); font-weight: 700; margin-bottom: var(--s3);
  }
  .shape-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s2); }
  .shape-btn {
    display: grid; place-items: center; aspect-ratio: 1;
    border-radius: 12px; border: 1px solid var(--border-soft);
    background: var(--panel);
    transition: border-color 120ms var(--ease), background 120ms var(--ease), transform 80ms var(--ease);
  }
  .shape-btn:hover { border-color: var(--border-strong); }
  .shape-btn:active { transform: scale(0.96); }
  .shape-btn.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px rgba(163, 163, 163, 0.35) inset; }
  .shape-btn .av { width: 34px; height: 34px; font-size: 0; }
  .color-row { display: flex; flex-wrap: wrap; gap: 10px; }
  .swatch {
    width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid transparent; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    transition: transform 80ms var(--ease), border-color 120ms var(--ease);
  }
  .swatch:hover { transform: scale(1.08); }
  .swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45) inset; }
  .avatar-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
  .avatar-actions .btn { flex: 1 1 auto; }

  /* ---------------------------------------------------------------------
     auth screen
     --------------------------------------------------------------------- */
  .auth {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: calc(var(--s5) + var(--safe-t)) var(--s4) calc(var(--s5) + var(--safe-b));
    background: radial-gradient(900px 520px at 50% -20%, #1b1440 0%, var(--bg) 62%);
    overflow-y: auto;
  }
  .auth[hidden] { display: none; }
  .auth-card {
    width: min(420px, 100%);
    border: 1px solid var(--border); border-radius: var(--r-lg);
    background: rgba(16, 19, 26, 0.9);
    box-shadow: var(--shadow-2);
    padding: var(--s6) var(--s5) var(--s5);
  }
  .auth-top { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s5); }
  .auth-top .brand-mark { width: 30px; height: 30px; border-radius: 10px; }
  .auth-top .name { font-weight: 650; letter-spacing: -0.01em; }
  .auth h1 { font-size: 22px; margin: 0 0 var(--s2); letter-spacing: -0.02em; }
  .auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 var(--s5); line-height: 1.6; }
  .auth .lbl { display: block; margin: var(--s3) 0 6px; font-size: 11.5px; color: var(--dim); }
  .auth .field { min-height: 44px; font-size: 14px; }
  .auth .field.code { font-family: var(--mono); letter-spacing: 0.18em; font-size: 18px; text-align: center; text-transform: uppercase; }
  .auth .field.code::placeholder { font-family: var(--sans); letter-spacing: 0; text-transform: none; font-size: 13.5px; }
  .auth .field.code:not(:placeholder-shown) { background: rgba(163, 163, 163, 0.06); }
  .auth .btn { margin-top: var(--s5); min-height: 46px; font-size: 14px; }
  .auth-msg { margin-top: var(--s3); font-size: 12px; color: #ff9d9a; min-height: 18px; }
  .auth-msg.ok { color: #8ee8b6; }
  .auth-foot { color: var(--dim); font-size: 11.5px; margin: var(--s4) 0 0; line-height: 1.6; }
  .auth-foot code { font-family: var(--mono); color: var(--muted); }

  /* ---------------------------------------------------------------------
     mobile bottom nav
     --------------------------------------------------------------------- */
  .mobilenav {
    display: none;
    flex: none;
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    border-top: 1px solid var(--border-soft);
    background: rgba(10, 12, 17, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 50;
  }
  .navitem {
    flex: 1; min-height: var(--touch);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--dim); font-size: 10.5px; font-weight: 600;
    transition: color 120ms var(--ease);
  }
  .navitem .navglyph { font-size: 16px; line-height: 1; }
  .navitem.active { color: var(--accent-2); }
  .navitem:active { background: rgba(255, 255, 255, 0.03); }

  /* ---------------------------------------------------------------------
     responsive
     --------------------------------------------------------------------- */
  @media (max-width: 1100px) {
    .main { grid-template-columns: clamp(232px, 19vw, 272px) minmax(0, 1fr) clamp(276px, 26vw, 330px); }
    .messages { padding-left: var(--s4); padding-right: var(--s4); }
    .composer { padding-left: var(--s4); padding-right: var(--s4); }
    .notice { margin-left: var(--s4); margin-right: var(--s4); }
    .chat-head { padding-left: var(--s4); padding-right: var(--s4); }
  }

  /* ---------------------------------------------------------------------
     groups + bot management
     --------------------------------------------------------------------- */
  .side-section { padding: 0 var(--s2) var(--s3); }
  .side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s3) var(--s2) var(--s2);
    font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--dim); font-weight: 700;
  }
  .side-head .mono { letter-spacing: 0; color: var(--muted); }
  .side-hint { padding: 2px var(--s2) 6px; color: var(--dim); font-size: 11px; line-height: 1.5; }
  .group-list { display: flex; flex-direction: column; gap: 4px; }
  .group {
    display: flex; align-items: center; gap: var(--s3);
    width: 100%; padding: 9px 10px; border-radius: 14px;
    text-align: left; cursor: pointer; border: 1px solid transparent;
    transition: background 120ms var(--ease), border-color 120ms var(--ease);
  }
  .group:hover { background: rgba(255, 255, 255, 0.04); }
  .group.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(163, 163, 163, 0.10));
    border-color: rgba(56, 189, 248, 0.34);
  }
  /* stacked member avatars — the ring lives on the parent, the mask clips the child */
  .stack { display: flex; align-items: center; flex: none; }
  .stack-cell {
    display: grid; place-items: center; border-radius: 50%;
    background: var(--bg-2); padding: 2px; margin-left: -11px;
  }
  .stack-cell:first-child { margin-left: 0; }
  .group .stack-cell .av { --av-size: 30px; }
  .chat-stack .stack-cell { background: var(--panel); }
  .chat-stack .stack-cell .av { --av-size: 30px; cursor: pointer; }

  .menu {
    position: absolute; z-index: 32; min-width: 156px;
    display: flex; flex-direction: column; gap: 2px; padding: 4px;
    background: var(--panel-2); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow-2);
  }
  .menu[hidden] { display: none; }
  .menu button {
    text-align: left; min-height: 32px; padding: 7px 10px; border-radius: 7px;
    font-size: 12.5px; color: var(--text); white-space: nowrap;
  }
  .menu button:hover { background: rgba(255, 255, 255, 0.07); }
  .menu button.danger { color: #ff9d9a; }
  .menu button:disabled { opacity: 0.45; cursor: default; }
  .menu button:disabled:hover { background: none; }
  .menu .menu-sep { height: 1px; background: var(--border-soft); margin: 3px 2px; }

  .new-bot { position: relative; padding: 0 var(--s3) var(--s4); }
  #new-menu { left: var(--s3); right: var(--s3); bottom: calc(100% - var(--s4)); }

  /* bot row kebab */
  .bot { position: relative; }
  .bot-more {
    flex: none; width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center; color: var(--dim); font-size: 15px;
    opacity: 0; transition: opacity 120ms var(--ease), background 120ms var(--ease);
  }
  .bot:hover .bot-more, .bot:focus-within .bot-more,
  .group:hover .bot-more, .group:focus-within .bot-more, .bot-more[aria-expanded="true"] { opacity: 1; }
  .group { position: relative; }
  /* sidebar status: needs you > working > new result */
  .att { flex: none; display: grid; place-items: center; min-width: 18px; height: 18px; }
  .att i { display: block; width: 8px; height: 8px; border-radius: 50%; font-style: normal; }
  .att.needs i { width: auto; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #f59e0b; color: #1a1205; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
  .att.working i { background: var(--accent-2, #8b7bff); animation: att-pulse 1.2s ease-in-out infinite; }
  .att.unread i { background: #3b82f6; }
  @keyframes att-pulse { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.1); } }
  @media (prefers-reduced-motion: reduce) { .att.working i { animation: none; } }
  .bot:hover .att, .group:hover .att, .bot:focus-within .att, .group:focus-within .att { display: none; }
  @media (hover: none) { .bot:hover .att, .group:hover .att { display: grid; } }
  .machine-badge { position: absolute; top: -2px; left: 16px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; color: #fff; background: #3b82f6; box-shadow: 0 0 0 2px var(--bg-2, #16171b); }
  .machine-badge.needs { background: #f59e0b; color: #1a1205; }
  #machine-menu .mm-att { font-size: 11px; font-weight: 600; color: #3b82f6; }
  #machine-menu .mm-att.needs { color: #f59e0b; }
  .bot-more:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
  .bot-menu { right: var(--s2); top: calc(100% - 6px); }
  @media (hover: none) {
    .bot-more { opacity: 1; }
  }

  /* group transcript: sender attribution */
  .row.gbot { align-items: flex-start; gap: 10px; }
  .g-block { min-width: 0; display: flex; flex-direction: column; gap: 4px; max-width: min(680px, 86%); }
  .g-name { font-size: 11.5px; font-weight: 650; color: var(--muted); padding-left: 2px; }
  .g-block .bubble { max-width: 100%; }
  /* A hand-off from another bot in a 1:1 chat: its face and "文案 → 质检", a quieter bubble. */
  .row.from-bot .bubble { background: var(--panel); border: 1px solid var(--border-soft); }
  /* "@质检": a small chip with the bot's face. */
  .mention {
    display: inline-flex; align-items: center; gap: 4px; vertical-align: -3px;
    padding: 1px 7px 1px 2px; border-radius: 999px; background: var(--panel-2);
    font-weight: 550; line-height: 1.5; white-space: nowrap;
  }
  .mention .av { flex: none; }
  /* In a group, "正在…" starts with the face of the bot at work. */
  .typing-row .typing-who { flex: none; margin-right: 2px; }
  .g-block .chip, .g-block .approval { max-width: 100%; }

  /* modal (create group) */
  #group-scrim, #vnc-scrim, #confirm-scrim, #pair-scrim { z-index: 96; }
  .modal {
    position: fixed; z-index: 97; left: 50%; top: 50%;
    transform: translate(-50%, -48%) scale(0.98);
    width: min(560px, calc(100vw - 32px));
    max-height: min(86dvh, 720px);
    display: flex; flex-direction: column;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-2);
    opacity: 0; pointer-events: none;
    transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  }
  .modal-sm { width: min(420px, calc(100vw - 32px)); }
  .modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
  .modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
    padding: var(--s4) var(--s4) var(--s3);
    border-bottom: 1px solid var(--border-soft); flex: none;
  }
  .modal-title { font-size: 14px; font-weight: 650; }
  .modal-body {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: var(--s4);
    display: flex; flex-direction: column; gap: var(--s2);
  }
  .modal-foot {
    display: flex; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4);
    border-top: 1px solid var(--border-soft); flex: none;
  }
  .modal-foot .btn { flex: 1; }
  .prov-progress { margin: 10px 0 6px; }
  .prov-bar {
    height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden;
  }
  .prov-bar > i {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 300ms var(--ease);
  }
  .prov-bar.indeterminate > i { width: 35% !important; animation: provSlide 1.2s infinite ease-in-out; }
  @keyframes provSlide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
  .prov-step { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
  .modal-note {
    padding: 9px 11px; border-radius: var(--r-sm); font-size: 11.5px; line-height: 1.5;
    border: 1px solid rgba(240, 167, 44, 0.3); background: rgba(240, 167, 44, 0.08); color: #e6c48b;
  }
  .modal-note[hidden] { display: none; }
  .modal-note.ok { border-color: rgba(34, 197, 94, 0.32); background: rgba(34, 197, 94, 0.09); color: #9ee6b5; }
  .modal-note.bad { border-color: rgba(239, 68, 68, 0.34); background: rgba(239, 68, 68, 0.09); color: #f3a6a6; }
  .modal-sep { height: 1px; background: var(--border-soft); margin: 6px 0 2px; }
  .modal-section-title { font-size: 12.5px; font-weight: 650; color: var(--text); }
  .modal.modal-sm { width: min(380px, calc(100vw - 32px)); }
  .confirm-text { font-size: 13px; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }
  .member-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .member-grid > * { min-width: 0; }
  .member-card {
    display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0;
    padding: 9px 10px; border-radius: 12px; border: 1px solid var(--border-soft);
    background: var(--panel-2); color: var(--text);
    transition: border-color 120ms var(--ease), background 120ms var(--ease);
  }
  .member-card:hover { border-color: var(--border-strong); }
  .member-card.on { border-color: var(--accent); background: var(--accent-soft); }
  .member-card:disabled { opacity: 0.42; cursor: not-allowed; }
  .member-card .mc-text { min-width: 0; }
  .member-card .mc-name { font-size: 13px; font-weight: 650; }
  .member-card .mc-role {
    font-size: 11px; color: var(--dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .coord-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
  #group-machine-filter { margin-bottom: var(--s2); }
  .plan-moved-foot { display: flex; justify-content: flex-end; margin-top: var(--s2); }
  .coord-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 10px 5px 6px; border-radius: 999px;
    border: 1px solid var(--border-soft); background: var(--panel-2);
    font-size: 12px; color: var(--muted);
  }
  .coord-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
  .coord-chip .av { --av-size: 22px; }
  .form-label { font-size: 11px; color: var(--dim); margin-top: var(--s1); }
  .form-label:first-child { margin-top: 0; }

  /* bot editor sheet reuses the avatar sheet shell */
  #botedit-sheet { z-index: 95; width: min(400px, 100vw); }
  #botedit-scrim { z-index: 92; }
  .sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4) var(--s4) calc(var(--s6) + var(--safe-b)); }
  .danger-zone { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--border-soft); }

  /* ---- phone / small tablet: drawers + bottom sheet ---- */
  @media (max-width: 860px) {
    :root { --topbar-h: 52px; --nav-h: 56px; }

    #nav-toggle { display: grid; }
    .tz { display: none; }
    /* One compact row: hamburger · mark · Desk · model pill · gear.
       The tagline never competes for space on a phone. */
    .brand small { display: none !important; }

    .main { display: flex; flex-direction: column; }
    .chat { flex: 1; min-height: 0; }

    .mobilenav { display: flex; }

    .sidebar {
      position: fixed; z-index: 60;
      top: calc(var(--topbar-h) + var(--safe-t));
      bottom: 0; left: 0;
      width: min(84vw, 320px);
      height: auto;
      padding-bottom: var(--safe-b);
      background: var(--panel);
      border-right: 1px solid var(--border);
      box-shadow: var(--shadow-2);
      transform: translateX(-102%);
      transition: transform 260ms var(--ease);
      will-change: transform;
    }
    .sidebar.open { transform: translateX(0); }
    #sidebar-close { display: grid; }
    .sidebar .drawer-head { padding: var(--s4) var(--s4) var(--s2); }

    .panel {
      position: fixed; z-index: 70;
      left: 0; right: 0; bottom: 0;
      height: min(76dvh, 620px);
      border: 1px solid var(--border);
      border-bottom: none;
      border-radius: 18px 18px 0 0;
      background: var(--panel);
      box-shadow: var(--shadow-2);
      transform: translateY(104%);
      transition: transform 280ms var(--ease);
      will-change: transform;
    }
    .panel.open { transform: translateY(0); }
    /* Full screen: a transform here would make the sheet, not the screen, the
       box the fixed desktop fills (seen on a phone: a white strip on the right). */
    body.panel-max .panel, body.panel-max .panel.open { transform: none; will-change: auto; transition: none; }
    .grip {
      display: flex; align-items: center; justify-content: center;
      height: 22px; flex: none; padding-top: 8px;
      cursor: grab;
    }
    .grip span { width: 40px; height: 4px; border-radius: 99px; background: #333c4d; }
    .tabs { padding: 4px var(--s2) 0; }
    .tab { min-height: var(--touch); }
    .panel-close { display: grid; margin-left: var(--s1); }
    .panel-body { padding: var(--s2) var(--s4) calc(var(--s5) + var(--safe-b)); }

    /* The top of a phone screen is the clock / Dynamic Island when the page
       runs edge to edge (home-screen app, app shell): start below it, or taps
       there land on the status bar. Zero in a normal browser tab. */
    .chat-head { padding: calc(var(--s2) + var(--safe-t)) var(--s4) var(--s2); min-height: calc(56px + var(--safe-t)); background: var(--bg); }
    /* home-screen app: iOS frosts a band under the clock; keep a little air below it */
    html.ios-standalone .chat-head { padding-top: calc(var(--s2) + var(--safe-t) + 14px); min-height: calc(70px + var(--safe-t)); }
    .chat-head .sub { max-width: 52vw; }
    .messages { padding: var(--s4) var(--s4) var(--s2); gap: var(--s3); }
    .composer { padding: var(--s2) var(--s4) calc(var(--s3) + var(--safe-b)); }
    .notice { margin: 0 var(--s4) var(--s2); }
    .composer-hint { display: none; }
    .toast { bottom: calc(var(--nav-h) + 96px + var(--safe-b)); }

    /* touch targets */
    .icon-btn { width: var(--touch); height: var(--touch); }
    .send-btn { width: var(--touch); height: var(--touch); border-radius: 12px; }
    .btn, .ghost-btn, .suggestion, .icon-btn, .field, .tab, .navitem { min-height: var(--touch); }
    .btn.tiny { min-height: var(--touch); padding-left: var(--s3); padding-right: var(--s3); }
    .icon-btn.sm { min-width: var(--touch); min-height: var(--touch); }
    .chip summary { min-height: var(--touch); padding: 11px 12px; }
    .bot { min-height: 76px; padding: 10px; }
    .approval-actions { flex-wrap: wrap; }
    .approval-actions .field { flex: 1 1 100%; }
    .approval-actions .btn { flex: 1 1 0; min-height: var(--touch); }
    .bubble { max-width: 92%; }
    .chip, .approval { max-width: 100%; }
    .messages, .panel-body, .drawer-body { -webkit-overflow-scrolling: touch; }
    .dsec .field { min-height: var(--touch); }

    .drawer { width: 100vw; border-left: none; }

    /* group dialog + bot editor become bottom sheets */
    .modal {
      left: 0; right: 0; bottom: 0; top: auto;
      width: 100%; max-height: 90dvh;
      border-radius: 18px 18px 0 0; border-bottom: none;
      transform: translateY(102%);
    }
    .modal.open { transform: translateY(0); }
    .member-grid { grid-template-columns: 1fr; }
    .member-card { min-height: 56px; }
    .coord-chip { min-height: 44px; }
    .menu button { min-height: 44px; }
    .bot-more { opacity: 1; width: 34px; height: 34px; }
    #botedit-sheet {
      top: auto; left: 0; right: 0; bottom: 0;
      width: 100%; height: min(82dvh, 600px);
      border-radius: 18px 18px 0 0; border-left: none;
      padding-top: 0; transform: translateY(102%);
    }
    #botedit-sheet.open { transform: translateY(0); }
    .group { min-height: 64px; }

    /* avatar customizer becomes a bottom sheet on phones */
    .avatar-sheet {
      top: auto; left: 0; right: 0; bottom: 0;
      width: 100%; height: min(88dvh, 720px);
      border-left: none; border-radius: 18px 18px 0 0;
      padding-top: 0;
      transform: translateY(102%);
    }
    .avatar-sheet.open { transform: translateY(0); }
    .avatar-body { padding: var(--s3) var(--s4) calc(var(--s5) + var(--safe-b)); }
    .shape-btn { min-height: 52px; }
    .swatch { width: 44px; height: 44px; }
    .color-row { display: grid; grid-template-columns: repeat(5, 44px); gap: var(--s2); }
    .avatar-preview { padding: var(--s4) 0; }
  }

  @media (max-width: 480px) {
    /* Hard guarantee: at phone widths the topbar is one row and nothing
       from the brand block may wrap into the chat header. */
    .brand small { display: none !important; }
    #model-pill { max-width: 40vw; flex: 0 1 auto; }
  }

  @media (max-width: 420px) {
    .messages { padding-left: var(--s3); padding-right: var(--s3); }
    .composer { padding-left: var(--s3); padding-right: var(--s3); }
    .notice { margin-left: var(--s3); margin-right: var(--s3); }
    .chat-head { padding-left: var(--s3); padding-right: var(--s3); }
    .chat-head .sub { max-width: 44vw; }
    .brand > span { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
    .pair-code { font-size: 26px; letter-spacing: 0.16em; }
    .auth h1 { font-size: 20px; }
    .onboard { padding: var(--s4); }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  }

  /* =====================================================================
     v2 chrome: the sidebar is a positioned flex column so its divider can be
     dragged, its content scrolls on its own, and the account/settings block
     is pinned to the bottom-left corner.
     ===================================================================== */
  .sidebar {
    position: relative;
    overflow: hidden;
  }
  @media (max-width: 860px) {
    .sidebar { position: fixed; }
  }
  .sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sidebar-resizer { right: 0; width: 8px; }
  .sidebar-resizer::after { right: 0; }
  .panel-resizer::after { left: 0; }
  .edge-resizer::after { background: var(--border); }
  .edge-resizer::before {
    content: ''; position: absolute; top: 50%; width: 4px; height: 42px;
    margin-top: -21px; border-radius: 99px;
    background: var(--border-strong); opacity: 0;
    transition: opacity 120ms var(--ease), background 120ms var(--ease);
  }
  .sidebar-resizer::before { right: 2px; }
  .panel-resizer::before { left: 2px; }
  .edge-resizer:hover::before, body.resizing .edge-resizer::before { opacity: 1; background: var(--accent); }
  .edge-resizer:hover::after, body.resizing .edge-resizer::after { background: var(--accent); }

  .sidebar-bottom {
    flex: none;
    display: flex; flex-direction: column; gap: 8px;
    padding: 8px 10px calc(10px + var(--safe-b));
    border-top: 1px solid var(--border-soft);
    background: var(--bg-2);
  }
  .side-account {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-width: 0; padding: 7px 8px;
    border: 1px solid transparent; border-radius: 11px;
    text-align: left; transition: background 120ms var(--ease), border-color 120ms var(--ease);
  }
  .side-account:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-soft); }
  .side-account .am-avatar { width: 34px; height: 34px; flex: none; }
  .side-account-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
  .side-account-text b { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-account-text small { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
  .side-account-more { flex: none; color: var(--dim); font-size: 16px; line-height: 1; }
  .side-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .side-meta .pill { min-width: 0; max-width: 100%; font-size: 11px; padding: 4px 8px; }
  .side-meta #model-pill { flex: 0 1 auto; }
  .side-meta .tz { flex: none; }
  .side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .side-action {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 0; min-height: 34px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--muted); font-size: 12px; font-weight: 500;
    transition: color 120ms var(--ease), border-color 120ms var(--ease), background 120ms var(--ease);
  }
  .side-action:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
  .side-action span:first-child { font-size: 13px; }

  /* the account popover now lives above the bottom-left card */
  .account-menu {
    top: auto; right: auto;
    left: 12px; bottom: calc(166px + var(--safe-b));
    width: min(292px, calc(var(--side-w, 280px) - 24px));
    min-width: 232px;
    /* above the mobile sidebar (60), below the settings drawer (90) */
    z-index: 80;
  }

  /* theme picker in settings */
  .seg {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
    padding: 4px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--panel);
  }
  .seg-btn {
    min-width: 0; min-height: 34px; padding: 6px 4px; border-radius: 7px;
    color: var(--muted); font-size: 12px; font-weight: 600;
    transition: background 120ms var(--ease), color 120ms var(--ease);
  }
  .seg-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
  .seg-btn.active { background: var(--accent); color: #fff; }
  .seg-btn.active:hover { background: var(--accent-2); }

  @media (max-width: 860px) {
    .edge-resizer { display: none; }
    .sidebar { padding-bottom: 0; }
    .account-menu { left: 12px; bottom: calc(166px + var(--safe-b)); width: min(292px, calc(100vw - 24px)); min-width: 0; }
  }

  /* =====================================================================
     light theme - the same components, a daylight surface. The accent and
     the meaning colours (green/amber/red) stay recognisable.
     ===================================================================== */
  html[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5f9;
    --bg-2: #eceef5;
    --panel: #ffffff;
    --panel-2: #f6f7fb;
    --panel-3: #e9ecf3;
    --border: #dde1ea;
    --border-soft: #e8ebf2;
    --border-strong: #c7cdda;
    --text: #161a23;
    --muted: #5b6376;
    --dim: #8b93a5;
    --accent: #0a0a0a;
    --accent-2: #262626;
    --accent-soft: rgba(0, 0, 0, 0.05);
    --green: #149a57;
    --amber: #b26a00;
    --red: #d13232;
    --cyan: #0b7aa8;
    --shadow-1: 0 8px 24px rgba(20, 28, 50, 0.10);
    --shadow-2: 0 18px 48px rgba(20, 28, 50, 0.18);
  }
  html[data-theme="light"] body {
    background: radial-gradient(1200px 600px at 20% -10%, #f2f2f2 0%, var(--bg) 55%) fixed;
  }
  html[data-theme="light"] ::selection { background: rgba(82, 82, 82, 0.22); }
  html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9cfdd; background-clip: content-box; }
  html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #b4bccd; background-clip: content-box; }
  html[data-theme="light"] .topbar { background: rgba(250, 251, 254, 0.88); }
  html[data-theme="light"] .sidebar { background: rgba(248, 249, 253, 0.72); }
  html[data-theme="light"] .panel { background: rgba(248, 249, 253, 0.66); }
  html[data-theme="light"] .mobilenav { background: rgba(250, 251, 254, 0.94); }
  html[data-theme="light"] .composer { background: linear-gradient(180deg, transparent, rgba(244, 245, 249, 0.78)); }
  html[data-theme="light"] .icon-btn:hover,
  html[data-theme="light"] .bot:hover,
  html[data-theme="light"] .group:hover,
  html[data-theme="light"] .chip summary:hover,
  html[data-theme="light"] .menu button:hover,
  html[data-theme="light"] .bot-more:hover,
  html[data-theme="light"] .tab:hover,
  html[data-theme="light"] .navitem:active,
  html[data-theme="light"] .winbtns button:hover { background: rgba(20, 28, 50, 0.06); }
  html[data-theme="light"] .side-account:hover,
  html[data-theme="light"] .side-action:hover,
  html[data-theme="light"] .seg-btn:hover { background: rgba(20, 28, 50, 0.05); }
  html[data-theme="light"] .am-row { border-bottom-color: var(--border-soft); }
  html[data-theme="light"] .bubble.md .md-code { background: #f2f4f9; }
  html[data-theme="light"] .bubble.md .md-table th { background: rgba(20, 28, 50, 0.04); }
  html[data-theme="light"] .bubble.system { color: #7a4c00; }
  html[data-theme="light"] .row.user .bubble {
    background: linear-gradient(180deg, rgba(82, 82, 82, 0.15), rgba(82, 82, 82, 0.08));
    border-color: rgba(82, 82, 82, 0.28);
  }
  html[data-theme="light"] .risk.LOW { color: #0c7a45; }
  html[data-theme="light"] .risk.MEDIUM { color: #945c00; }
  html[data-theme="light"] .risk.HIGH { color: #b3261e; }
  html[data-theme="light"] .approval-args { background: rgba(20, 28, 50, 0.04); }
  html[data-theme="light"] .approval-wait { color: #8a5600; }
  html[data-theme="light"] .btn.danger { color: #b3261e; }
  html[data-theme="light"] .btn.danger:hover { background: rgba(209, 50, 50, 0.08); }
  html[data-theme="light"] .notice,
  html[data-theme="light"] .notice-inline,
  html[data-theme="light"] .modal-note,
  html[data-theme="light"] .avatar-note { color: #7a4c00; }
  html[data-theme="light"] .set-status.ok { color: #0c7a45; }
  html[data-theme="light"] .set-status.bad { color: #b3261e; }
  html[data-theme="light"] .tag.good { color: #0c7a45; }
  html[data-theme="light"] .tag.bad { color: #b3261e; }
  html[data-theme="light"] .tag.warn { color: #8a5600; }
  html[data-theme="light"] .menu button.danger { color: #b3261e; }
  html[data-theme="light"] .pill.warn { color: #8a5600; }
  html[data-theme="light"] .pc-screen { background: #e9ecf3; }
  html[data-theme="light"] .grip span { background: #c2c8d6; }
  html[data-theme="light"] .swatch { box-shadow: 0 0 0 1px rgba(20, 28, 50, 0.16) inset; }
  html[data-theme="light"] .swatch.active { border-color: #161a23; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7) inset; }
  html[data-theme="light"] .scrim { background: rgba(20, 28, 50, 0.35); }
  html[data-theme="light"] .auth {
    background: radial-gradient(900px 520px at 50% -20%, #e2dcff 0%, var(--bg) 62%);
  }
  html[data-theme="light"] .auth-card { background: rgba(255, 255, 255, 0.92); }
  html[data-theme="light"] .auth-msg { color: #b3261e; }
  html[data-theme="light"] .auth-msg.ok { color: #0c7a45; }
  html[data-theme="light"] .theme-glyph { color: inherit; }

  /* =====================================================================
     v3 · Grok-style shell
     One neutral scale, no decorative gradients. Colour only where it means
     something (a warning, a failure, an avatar). Conversation first.
     ===================================================================== */
  :root {
    --bg: #0b0b0c;
    --bg-2: #111112;
    --panel: #151516;
    --panel-2: #1c1c1e;
    --panel-3: #262628;
    --border: #2a2a2d;
    --border-soft: #202023;
    --border-strong: #3d3d42;
    --text: #f2f2f3;
    --muted: #a3a3aa;
    --dim: #6d6d74;
    --accent: #f2f2f3;
    --accent-2: #d8d8dc;
    --accent-soft: rgba(255, 255, 255, 0.08);
    --green: #4cc38a;
    --amber: #d9a85c;
    --red: #e06c75;
    --cyan: #56b6c2;
    --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 24px 64px rgba(0, 0, 0, 0.55);
    --side-w: 272px;
  }

  body {
    background: var(--bg);
    font-size: 14px;
  }
  ::selection { background: rgba(255, 255, 255, 0.18); }
  :focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
  a { color: var(--text); text-decoration-color: var(--dim); }
  html[data-theme="light"] ::selection { background: rgba(0, 0, 0, 0.12); }

  /* frameless shell ---------------------------------------------------- */
  .drag-strip { display: none; }
  body.shell .drag-strip {
    display: block; position: fixed; top: 0; left: 0; right: 0; height: 30px;
    z-index: 65; -webkit-app-region: drag; user-select: none;
  }
  body.shell .winbtns {
    display: flex; position: fixed; top: 0; right: 8px; z-index: 70;
    height: 30px; align-items: center; -webkit-app-region: no-drag;
  }
  body.shell .main { padding-top: 30px; }
  body.shell .winbtns button { width: 34px; height: 24px; border-radius: 6px; cursor: pointer; }

  /* sidebar ------------------------------------------------------------ */
  .main { grid-template-columns: var(--side-w, 272px) minmax(0, 1fr) var(--panel-w, 340px); }
  body.panel-hidden .main { grid-template-columns: var(--side-w, 272px) minmax(0, 1fr); }
  .sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--border-soft);
  }
  .side-top {
    display: flex; align-items: center; gap: 6px;
    padding: 14px 10px 8px 14px; flex: none;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
  /* the machine switcher: the brand row IS the current machine */
  .machine-switch {
    position: relative; padding: 4px 6px; margin: -4px -6px; border-radius: 9px;
    border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer;
  }
  .machine-switch:hover, .machine-switch[aria-expanded="true"] { background: var(--panel-2); }
  .machine-caret { flex: none; color: var(--dim); font-size: 10px; margin-left: auto; }
  .machine-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #34d399; margin-right: 5px; vertical-align: 1px; }
  #machine-menu { left: 10px; right: 10px; top: 54px; min-width: 0; }
  #machine-menu .mm-item { display: flex; align-items: center; gap: 8px; }
  #machine-menu .mm-item b { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; }
  #machine-menu .mm-item small { color: var(--dim); font-size: 11px; }
  #machine-menu .mm-item.current b::after { content: '  ✓'; color: var(--dim); font-weight: 400; }
  .machine-list { display: flex; flex-direction: column; gap: 6px; }
  .machine-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    border: 1px solid var(--border-soft); border-radius: 10px;
  }
  .machine-row.current { border-color: var(--border-strong); }
  .machine-avatar {
    flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
    background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700;
  }
  .machine-meta { flex: 1; min-width: 0; }
  .machine-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .machine-sub { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .machine-tag { font-size: 11px; color: var(--dim); }
  .machine-actions { display: flex; gap: 4px; flex: none; }
  .machine-empty { font-size: 12px; color: var(--dim); padding: 6px 2px; }
  .phone-box { margin-top: var(--s4); display: grid; gap: var(--s2); }
  .phone-shot { max-width: 220px; max-height: 420px; border-radius: 12px; border: 1px solid var(--border); }
  #phone-adb-row .btn-row .field { flex: 1; min-width: 0; }
  .brand-mark {
    width: 24px; height: 24px; border-radius: 7px;
    background: linear-gradient(145deg, #ffffff, #9d9da6);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  }
  .side-brand-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .side-brand-text b { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-brand-text small { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
  .new-bot { position: relative; padding: 0; flex: none; }
  .round-btn {
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    border: 1px solid var(--border); color: var(--muted); background: transparent;
    transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
  }
  .round-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--border-strong); }
  .round-btn[aria-expanded="true"] { background: var(--panel-2); color: var(--text); }
  #new-menu {
    left: auto; right: 0; top: calc(100% + 8px); bottom: auto;
    min-width: 168px; padding: 5px; border-radius: 12px; background: var(--panel-2);
  }
  .side-close { display: none; }

  .bot-form {
    margin: 2px 10px 10px; padding: 12px; gap: 8px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--panel);
  }
  .bot-form-head { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }

  .sidebar-scroll { padding: 4px 8px 12px; }
  .side-section { padding: 0 0 14px; }
  .side-head {
    padding: 10px 8px 6px;
    font-size: 11px; letter-spacing: 0.02em; text-transform: none;
    color: var(--dim); font-weight: 500;
  }
  .side-head .count { color: var(--dim); font-weight: 400; font-size: 11px; }
  .side-head .mono { color: var(--dim); }
  .side-hint { padding: 2px 8px 6px; font-size: 11.5px; line-height: 1.55; }

  .bot-list, .group-list { gap: 1px; padding: 0; }
  .bot, .group {
    gap: 10px; padding: 6px 8px; border-radius: 9px; min-height: 46px;
    border: 1px solid transparent;
  }
  .bot:hover, .group:hover { background: rgba(255, 255, 255, 0.045); }
  .bot.active, .group.active { background: var(--panel-2); border-color: transparent; }
  .bot-name { font-size: 13px; font-weight: 500; gap: 6px; }
  .bot-preview { font-size: 11.5px; color: var(--dim); margin-top: 1px; }
  .group .bot-name, .bot .bot-name { line-height: 1.3; }
  .badge {
    font-size: 9px; padding: 0 5px; border-radius: 4px; letter-spacing: 0.04em;
    background: transparent; color: var(--dim); border: 1px solid var(--border);
    font-weight: 600;
  }
  .stack-cell, .group .stack-cell { background: var(--bg-2); }
  .group .stack-cell .av { --av-size: 24px; }

  .sidebar-bottom {
    gap: 6px; padding: 8px 8px calc(10px + var(--safe-b));
    background: var(--bg-2); border-top: 1px solid var(--border-soft);
  }
  .side-account { padding: 6px 7px; gap: 9px; border-radius: 9px; }
  .side-account:hover { background: var(--panel-2); border-color: transparent; }
  .side-account .am-avatar { width: 28px; height: 28px; font-size: 11.5px; }
  .side-account-text b { font-size: 12.5px; font-weight: 500; }
  .side-account-text small { font-size: 10.5px; }
  .am-avatar {
    background: var(--panel-3); color: var(--text);
    border: 1px solid var(--border); font-weight: 600;
  }
  .side-account-more { font-size: 15px; }
  .side-meta { padding: 0 7px; }
  .side-meta .pill { border: 0; background: transparent; padding: 0; font-size: 10.5px; color: var(--dim); gap: 5px; }
  .side-meta #model-pill #model-label { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .side-actions { display: flex; gap: 2px; }
  .side-action {
    flex: 1; min-height: 30px; padding: 4px 8px; gap: 6px;
    border: 0; border-radius: 8px; background: transparent;
    justify-content: flex-start; font-size: 11.5px; font-weight: 400; color: var(--dim);
  }
  .side-action:hover { background: var(--panel-2); border-color: transparent; color: var(--text); }
  .side-action svg { opacity: 0.8; }
  .edge-resizer::after { background: transparent; }
  .edge-resizer:hover::after, body.resizing .edge-resizer::after { background: var(--border-strong); }
  .edge-resizer::before { background: var(--border-strong); }
  .edge-resizer:hover::before, body.resizing .edge-resizer::before { background: var(--muted); }

  /* chat header -------------------------------------------------------- */
  .chat { background: var(--bg); }
  .chat-head {
    gap: 10px; padding: 10px 20px; min-height: 56px;
    border-bottom: 1px solid var(--border-soft);
  }
  .chat-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
  .chat-title-text { min-width: 0; }
  .chat-head .title { font-size: 14px; font-weight: 600; line-height: 1.25; }
  .chat-head .sub { font-size: 11.5px; color: var(--dim); max-width: 46vw; line-height: 1.3; margin-top: 1px; }
  .chat-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
  .chat-head .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
  .pill.soft { border-color: transparent; background: var(--panel-2); color: var(--dim); font-size: 11px; padding: 3px 9px; }
  .pill.warn {
    border-color: rgba(217, 168, 92, 0.32); background: rgba(217, 168, 92, 0.10);
    color: #e3c38b; font-size: 11px; padding: 3px 9px;
  }
  .chat-avatar { filter: none; }

  /* conversation ------------------------------------------------------- */
  .messages {
    padding: 26px 24px 10px; gap: 18px;
    scroll-behavior: smooth;
  }
  .messages > .row,
  .messages > .chip,
  .messages > .approval,
  .messages > .status-line,
  .messages > .typing-row {
    width: 100%; max-width: 760px; margin-left: auto; margin-right: auto;
  }
  .messages > .empty { margin: auto; }
  .day-sep { color: var(--dim); font-size: 11px; font-weight: 400; margin: 2px 0; }
  .row { gap: 0; }
  .row.user { justify-content: flex-end; }

  .bubble { max-width: 100%; }
  .row.user .bubble {
    background: var(--panel-2); border-color: transparent; color: var(--text);
    border-radius: 18px; padding: 9px 14px;
    max-width: min(560px, 82%); font-size: 14px; line-height: 1.55;
  }
  .row.assistant .bubble {
    background: var(--panel); border-color: var(--border-soft);
    border-radius: 16px; border-bottom-left-radius: 6px;
    padding: 10px 14px; max-width: min(680px, 92%);
    font-size: 14px; line-height: 1.65;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
  }
  .bubble.system { background: transparent; border-color: transparent; color: var(--dim); font-size: 12.5px; padding: 0 1px; }
  .row.assistant .bubble.system {
    background: transparent; border-color: transparent; padding: 0 1px;
    color: var(--dim); box-shadow: none;
  }
  .bubble.md .md-code { background: var(--bg-2); border-radius: 10px; }
  .bubble.md code { background: var(--accent-soft); }
  .bubble.md a { color: var(--text); text-decoration: underline; text-decoration-color: var(--dim); }
  .streaming::after { background: var(--muted); }

  .status-line { color: var(--dim); font-size: 11.5px; }
  .typing-row { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; }
  .typing-dots { display: inline-flex; gap: 3px; }
  .typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite; }
  .typing-dots i:nth-child(2) { animation-delay: 0.15s; }
  .typing-dots i:nth-child(3) { animation-delay: 0.3s; }

  /* empty state / choice cards ---------------------------------------- */
  .empty {
    max-width: 560px; text-align: left; padding: 16px 4px 24px;
  }
  .empty-mark {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px;
    margin-bottom: 16px;
  }
  .empty h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }
  .empty p { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 0 0 20px; }
  .empty-foot { color: var(--dim); font-size: 11.5px; margin-top: 16px; }
  .choice-list { display: flex; flex-direction: column; gap: 8px; }

  .choice {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 11px 12px; text-align: left;
    border: 1px solid var(--border); border-radius: 13px; background: var(--bg-2);
    transition: background 120ms var(--ease), border-color 120ms var(--ease), transform 80ms var(--ease);
  }
  .choice:hover { background: var(--panel-2); border-color: var(--border-strong); }
  .choice:active { transform: scale(0.995); }
  .choice:disabled { opacity: 0.5; cursor: default; }
  .choice-key {
    width: 24px; height: 24px; flex: none; display: grid; place-items: center;
    border: 1px solid var(--border); border-radius: 7px; background: var(--panel);
    font-family: var(--mono); font-size: 11px; color: var(--muted);
  }
  .choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
  .choice-title { font-size: 13px; font-weight: 500; color: var(--text); }
  .choice-desc { font-size: 11.5px; color: var(--dim); line-height: 1.45; }
  .choice-go { color: var(--dim); font-size: 16px; margin-left: 4px; flex: none; }

  /* tool chips --------------------------------------------------------- */
  .chip {
    max-width: 760px; border: 1px solid var(--border-soft); border-radius: 12px;
    background: var(--bg-2); font-family: var(--sans); font-size: 12px;
  }
  .chip summary { min-height: 36px; padding: 7px 12px; gap: 8px; flex-wrap: nowrap; color: var(--muted); }
  .chip summary:hover { background: rgba(255, 255, 255, 0.025); }
  .chip-icon { width: 13px; font-size: 11px; }
  .chip-icon.pending { color: var(--muted); }
  .chip-icon.ok { color: var(--green); }
  .chip-icon.fail { color: var(--red); }
  .chip-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
  .chip-name { font-weight: 500; font-size: 12.5px; color: var(--text); white-space: nowrap; }
  .chip-detail {
    font-family: var(--mono); font-size: 11px; color: var(--dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }
  .chip-state { font-size: 10.5px; color: var(--dim); flex: none; }
  .chip-state.warn { color: var(--amber); }
  .chip-state.bad { color: var(--red); }
  .chip-more { font-size: 11px; color: var(--dim); flex: none; margin-left: 2px; }
  .chip .body { padding: 10px 12px 12px; gap: 8px; }
  .chip-impact { color: var(--muted); font-size: 12px; line-height: 1.55; }
  .chip-fact { display: flex; gap: 10px; font-size: 12px; align-items: baseline; }
  .chip-fact-k { color: var(--dim); flex: none; min-width: 52px; }
  .chip-fact-v { color: var(--text); overflow-wrap: anywhere; }
  .tech summary { cursor: pointer; color: var(--dim); font-size: 11px; }
  .tech-pre {
    margin: 6px 0 0; padding: 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-soft); color: var(--muted);
    font-family: var(--mono); font-size: 11px; line-height: 1.5;
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto;
  }

  /* approvals ---------------------------------------------------------- */
  .approval {
    max-width: 760px; padding: 18px;
    border: 1px solid var(--border); border-radius: 18px;
    background: var(--panel); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  }
  .approval.resolved { background: var(--bg-2); border-color: var(--border-soft); box-shadow: none; opacity: 0.9; }
  .approval-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .approval-kicker {
    font-size: 10.5px; letter-spacing: 0.08em; color: var(--dim);
    font-weight: 600; text-transform: uppercase;
  }
  .approval-wait { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--amber); }
  .approval-wait .dot { background: var(--amber); width: 5px; height: 5px; animation: pulse 1.8s ease-in-out infinite; }
  .approval-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; margin-bottom: 10px; }
  .approval-detail {
    margin: 0 0 10px; padding: 9px 11px; border-radius: 10px;
    background: var(--bg-2); border: 1px solid var(--border-soft);
  }
  .approval-detail-k { font-size: 10.5px; color: var(--dim); margin-bottom: 3px; }
  .approval-detail code {
    display: block; font-family: var(--mono); font-size: 12px; line-height: 1.55;
    color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 132px; overflow: auto;
  }
  .approval-fact { display: flex; gap: 10px; font-size: 12.5px; padding: 4px 0; align-items: baseline; }
  .approval-fact-k { color: var(--dim); min-width: 64px; flex: none; }
  .approval-fact-v { color: var(--text); overflow-wrap: anywhere; }
  .approval-impact { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 8px 0 0; }
  .approval-why { color: var(--dim); font-size: 11.5px; line-height: 1.55; margin: 6px 0 0; }
  .approval-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; align-items: stretch; }
  .approval-actions .field { flex: 0 0 auto; }
  .approval-choose { display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .approval-note { min-height: 38px; font-size: 12.5px; margin-top: 0; }
  .approval-done { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .approval-pill {
    font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--muted);
  }
  .approval-pill.ok { color: var(--green); border-color: rgba(76, 195, 138, 0.32); }
  .approval-pill.no { color: var(--red); border-color: rgba(224, 108, 117, 0.32); }
  .approval-tech { margin-top: 12px; }

  /* composer ----------------------------------------------------------- */
  .composer {
    padding: 8px 24px calc(14px + var(--safe-b));
    border-top: 0; background: transparent;
  }
  .composer-box {
    max-width: 760px; margin: 0 auto;
    padding: 7px 8px 7px 16px; border-radius: 22px;
    background: var(--panel); border: 1px solid var(--border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  }
  .composer-box:focus-within { border-color: var(--border-strong); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22); }
  .composer textarea { font-size: 14px; padding: 5px 0; color: var(--text); }
  .send-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--text); color: var(--bg);
  }
  .send-btn:hover { background: var(--text); opacity: 0.86; }
  .send-btn:disabled { background: var(--panel-3); color: var(--dim); opacity: 1; }
  .composer-hint { max-width: 760px; margin: 7px auto 0; padding: 0; text-align: center; font-size: 10.5px; }
  .notice.slim {
    max-width: 760px; width: calc(100% - 48px); margin: 0 auto 8px;
    padding: 6px 12px; border-radius: 10px; gap: 8px;
    border-color: var(--border-soft); background: var(--bg-2); color: var(--dim);
    font-size: 11.5px;
  }
  .notice.slim .link-btn { margin-left: auto; color: var(--text); font-size: 11.5px; text-decoration: underline; text-underline-offset: 3px; }
  .notice.slim .link-btn:hover { color: var(--muted); }

  /* buttons + fields --------------------------------------------------- */
  .btn { border-radius: 9px; background: var(--panel-2); border-color: var(--border); min-height: 34px; font-weight: 500; }
  .btn:hover { border-color: var(--border-strong); }
  .btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
  .btn.primary:hover { background: var(--text); border-color: var(--text); opacity: 0.88; }
  .btn.ghost { background: transparent; color: var(--muted); }
  .btn.tiny { min-height: 27px; border-radius: 7px; }
  .field {
    min-height: 36px; border-radius: 9px; background: var(--bg-2);
    border-color: var(--border); font-size: 13px;
  }
  .field:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05); }
  .switch-row input { accent-color: var(--text); }
  .seg { background: var(--bg-2); border-color: var(--border); padding: 3px; border-radius: 10px; }
  .seg-btn { min-height: 31px; border-radius: 7px; }
  .seg-btn:hover { background: var(--panel-2); }
  .seg-btn.active { background: var(--panel-3); color: var(--text); }
  .seg-btn.active:hover { background: var(--panel-3); }

  /* right panel -------------------------------------------------------- */
  .panel { background: var(--bg-2); border-left: 1px solid var(--border-soft); }
  .tab { border-radius: 7px; border-bottom-width: 0; }
  .tab.active { color: var(--text); background: var(--panel-2); border-bottom-color: transparent; }
  .tab:hover { background: var(--panel-2); }
  .panel-body { padding: 14px 16px 28px; }
  .section-head { letter-spacing: 0.04em; text-transform: none; font-weight: 600; }
  .card { background: var(--panel); border-color: var(--border-soft); border-radius: 12px; }

  /* account popover ---------------------------------------------------- */
  .account-menu {
    left: 10px; bottom: calc(112px + var(--safe-b));
    width: min(272px, calc(var(--side-w, 272px) - 20px));
    padding: 8px; border-radius: 14px;
    background: var(--panel); border-color: var(--border);
    box-shadow: var(--shadow-2);
  }
  .am-head { padding: 8px; gap: 9px; margin-bottom: 4px; }
  .am-head .am-avatar { width: 30px; height: 30px; font-size: 12px; }
  .am-name { font-size: 13px; font-weight: 500; }
  .am-sub { font-size: 11px; }
  .am-actions { display: flex; flex-direction: column; gap: 1px; margin: 0; padding-top: 5px; border-top: 1px solid var(--border-soft); }
  .am-action {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 8px; border-radius: 8px;
    font-size: 12.5px; color: var(--text); text-align: left;
  }
  .am-action:hover { background: var(--panel-2); }
  .am-action span { color: var(--dim); }
  .am-note { padding: 8px 8px 4px; font-size: 10.5px; line-height: 1.55; }

  /* settings modal ----------------------------------------------------- */
  .settings-modal {
    position: fixed; inset: 0; margin: auto; z-index: 90;
    width: min(860px, calc(100vw - 40px));
    height: min(660px, calc(100vh - 48px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
    box-shadow: var(--shadow-2);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(10px) scale(0.985);
    transition: opacity 160ms var(--ease), transform 160ms var(--ease), visibility 0s linear 160ms;
  }
  .settings-modal.open {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  }
  .settings-top {
    flex: none; display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 12px 20px; border-bottom: 1px solid var(--border-soft);
  }
  .settings-heading { font-size: 14px; font-weight: 600; }
  .set-back { display: none; }
  .setnav-icon { display: none; }
  .settings-body { flex: 1; min-height: 0; display: flex; }
  .settings-nav {
    flex: none; width: 176px; padding: 10px; border-right: 1px solid var(--border-soft);
    display: flex; flex-direction: column; gap: 1px;
  }
  .setnav {
    text-align: left; padding: 8px 10px; border-radius: 8px;
    font-size: 12.5px; color: var(--muted); min-height: 34px;
  }
  .setnav:hover { background: var(--panel-2); color: var(--text); }
  .setnav.active { background: var(--panel-2); color: var(--text); font-weight: 500; }
  /* On a computer the settings list has the phone's icons too. */
  @media (min-width: 861px) {
    .setnav { display: flex; align-items: center; gap: 9px; }
    .setnav-icon { display: block; width: 16px; height: 16px; flex: none; opacity: 0.85; }
  }
  .settings-scroll {
    flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 22px 28px 40px; scroll-behavior: smooth;
  }
  /* Settings groups (design 6.2): 助理 / 安全 / 连接 / 通用, each with a small title. */
  .setnav-sec { display: flex; flex-direction: column; gap: 1px; }
  .setnav-sec + .setnav-sec { margin-top: 14px; }
  .setnav-group {
    padding: 4px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--dim);
  }
  .settings-scroll > .dsec { max-width: 640px; }
  /* On a computer settings is a page over the chat area; the sidebar stays, so a chat is one click away. */
  @media (min-width: 861px) {
    .settings-modal.page-mode {
      inset: 0 0 0 auto; left: var(--side-w); margin: 0;
      width: auto; height: auto; border: 0; border-left: 1px solid var(--border); border-radius: 0;
      box-shadow: none; background: var(--bg); transform: none;
    }
    html[data-theme="light"] .settings-modal.page-mode { box-shadow: none; }
    .settings-modal.page-mode .settings-nav { width: 208px; padding: 14px 12px; overflow-y: auto; }
    .settings-modal.page-mode .settings-scroll { padding: 28px 40px 48px; }
    .settings-modal.page-mode .dsec-head:first-child { font-size: 18px; margin-bottom: 6px; }
    /* no backdrop: it would swallow the click on a chat in the sidebar */
    #settings-scrim { display: none; }
  }
  .dsec {
    padding: 0 0 24px; margin: 0 0 24px;
    border-bottom: 1px solid var(--border-soft);
    scroll-margin-top: 12px;
  }
  .dsec:last-child { border-bottom: 0; margin-bottom: 0; }
  .dsec-head { font-size: 13px; font-weight: 600; margin-bottom: 4px; letter-spacing: 0; }
  .dsec-sub { font-size: 12px; line-height: 1.6; margin-bottom: 14px; color: var(--dim); }
  .dsec .lbl { font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
  .btn-row { margin-top: 18px; }
  .settings-scroll .btn-row .btn { flex: 0 0 auto; min-width: 112px; }
  .pair-card { background: var(--bg-2); border-radius: 12px; border-color: var(--border-soft); background-image: none; }
  .kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
  .kv:last-child { border-bottom: 0; }
  .kv .k { color: var(--dim); flex: none; }
  .kv .v { color: var(--text); text-align: right; overflow-wrap: anywhere; }
  .row-note { color: var(--dim); font-size: 11px; }
  .set-status { background: var(--bg-2); border-color: var(--border); }
  .notice-inline { border-color: rgba(217, 168, 92, 0.26); background: rgba(217, 168, 92, 0.07); color: #dfc191; }

  /* light theme -------------------------------------------------------- */
  html[data-theme="light"] {
    --bg: #ffffff;
    --bg-2: #f7f7f8;
    --panel: #ffffff;
    --panel-2: #f1f1f2;
    --panel-3: #e7e7e9;
    --border: #e4e4e7;
    --border-soft: #ededf0;
    --border-strong: #c9c9cf;
    --text: #17171a;
    --muted: #616168;
    --dim: #909097;
    --accent: #17171a;
    --accent-2: #3a3a40;
    --accent-soft: rgba(0, 0, 0, 0.05);
    --green: #128a58;
    --amber: #96660f;
    --red: #c2383f;
  }
  html[data-theme="light"] body { background: var(--bg); }
  html[data-theme="light"] .sidebar { background: var(--bg-2); }
  html[data-theme="light"] .brand-mark { background: linear-gradient(145deg, #202024, #6b6b74); }
  html[data-theme="light"] .bot:hover,
  html[data-theme="light"] .group:hover { background: rgba(0, 0, 0, 0.045); }
  html[data-theme="light"] .bot.active,
  html[data-theme="light"] .group.active { background: var(--panel-3); }
  html[data-theme="light"] .chip summary:hover { background: rgba(0, 0, 0, 0.025); }
  html[data-theme="light"] .choice:hover { background: var(--panel-2); border-color: var(--border-strong); }
  html[data-theme="light"] .row.user .bubble {
    background: var(--panel-2); border-color: transparent;
  }
  html[data-theme="light"] .row.assistant .bubble {
    background: var(--panel); border-color: var(--border-soft);
    box-shadow: 0 1px 2px rgba(20, 28, 50, 0.04);
  }
  html[data-theme="light"] .row.assistant .bubble.system {
    background: transparent; border-color: transparent; box-shadow: none;
  }
  html[data-theme="light"] .tech-pre { background: rgba(0, 0, 0, 0.035); }
  html[data-theme="light"] .composer-box { box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06); }
  html[data-theme="light"] .approval { box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08); }
  html[data-theme="light"] .field:focus { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05); }
  html[data-theme="light"] .bubble.md .md-code { background: var(--bg-2); }
  html[data-theme="light"] .bubble.md .md-table th { background: rgba(0, 0, 0, 0.04); }
  html[data-theme="light"] .pc-screen { background: #f0f0f2; }
  html[data-theme="light"] .scrim { background: rgba(24, 24, 27, 0.28); }
  html[data-theme="light"] .account-menu { box-shadow: 0 24px 64px rgba(0, 0, 0, 0.16); }
  html[data-theme="light"] .settings-modal { box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18); }
  html[data-theme="light"] .select.field { background-color: var(--bg-2); }

  /* phone -------------------------------------------------------------- */
  @media (max-width: 860px) {
    .sidebar {
      top: 0; background: var(--bg-2);
      width: min(86vw, 320px);
      padding-top: var(--safe-t);
      z-index: 60;
    }
    .side-top { padding-top: 12px; }
    .side-close { display: grid; }
    .new-bot { margin-left: auto; }
    .side-account .am-avatar { width: 32px; height: 32px; }
    .account-menu { left: 10px; bottom: calc(168px + var(--safe-b)); width: min(272px, calc(100vw - 20px)); }
    /* The panel has its own top-right button; a second dock here is clutter. */
    .mobilenav { display: none; }
    .toast { top: calc(64px + var(--safe-t)); bottom: auto; }

    .chat-head { padding: 8px 12px; min-height: 54px; gap: 8px; }
    #nav-toggle { display: grid; }
    .chat-head .sub { max-width: 42vw; }
    .chat-head .icon-btn { width: var(--touch); height: var(--touch); }
    #nav-toggle, #panel-toggle { width: 36px; height: 36px; }
    .chat-head-actions { gap: 2px; }
    .pill.soft { display: none; }

    .messages { padding: 16px 14px 6px; gap: 14px; }
    .row.user .bubble { max-width: 88%; }
    .empty { padding: 8px 2px 20px; }
    .empty h2 { font-size: 19px; }
    .empty-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
    .choice { padding: 10px; }
    .choice-key { width: 22px; height: 22px; }

    .composer { padding: 6px 12px calc(10px + var(--safe-b)); }
    .composer-box { border-radius: 20px; padding: 6px 7px 6px 14px; }
    .composer-hint { display: none; }
    .notice.slim { width: calc(100% - 24px); margin-bottom: 6px; }
    .send-btn { width: 34px; height: 34px; }

    .approval { padding: 14px; border-radius: 16px; }
    .approval-title { font-size: 15px; }
    .chip summary { min-height: 40px; padding: 9px 11px; }
    .settings-scroll .btn-row .btn { flex: 1 1 0; min-width: 0; }

    .settings-modal {
      width: 100%; height: 100%; max-height: none;
      border: 0; border-radius: 0;
      /* full screen: its back arrow goes below the clock, like the chat header */
      padding-top: var(--safe-t);
    }
    .page-viewer { padding-top: var(--safe-t); }
    .settings-body { flex-direction: column; }
    .settings-nav {
      width: auto; flex-direction: row; overflow-x: auto; flex: none;
      padding: 7px 10px; gap: 2px;
      border-right: 0; border-bottom: 1px solid var(--border-soft);
    }
    .setnav { white-space: nowrap; min-height: 33px; padding: 6px 10px; }
    .settings-scroll { padding: 16px 16px calc(32px + var(--safe-b)); }
    .dsec { padding-bottom: 20px; margin-bottom: 20px; }
  }
  @media (max-width: 420px) {
    .messages { padding-left: 12px; padding-right: 12px; }
    .composer { padding-left: 10px; padding-right: 10px; }
    .chat-head .sub { display: none; }
  }

  /* =====================================================================
     v5: quieter chrome
     - sidebar footer is one settings button
     - assistant replies read like a document (no bubble); the human's own
       messages are the only bubbles, in a soft violet so the turn-taking
       is obvious at a glance
     ===================================================================== */
  :root {
    --bubble-user: #2a2640;
    --bubble-user-border: rgba(160, 140, 255, 0.18);
    --bubble-user-text: #eeebff;
  }
  html[data-theme="light"] {
    --bubble-user: #eeeaff;
    --bubble-user-border: rgba(82, 82, 82, 0.14);
    --bubble-user-text: #221a4d;
  }

  .sidebar-bottom { padding: 8px 10px calc(10px + var(--safe-b)); border-top: 0; }
  .side-actions { display: block; }
  #settings-btn {
    width: 100%; min-height: 34px; padding: 6px 10px; gap: 9px;
    font-size: 13px; color: var(--muted); border-radius: 9px;
  }
  #settings-btn:hover { color: var(--text); }
  #settings-btn .dot { margin-left: auto; width: 6px; height: 6px; }
  #settings-btn .dot.ok { opacity: 0; }          /* healthy is the normal state: say nothing */

  .row.user .bubble,
  html[data-theme="light"] .row.user .bubble {
    background: var(--bubble-user); color: var(--bubble-user-text);
    border: 1px solid var(--bubble-user-border);
    border-radius: 18px 18px 6px 18px; padding: 9px 15px;
    box-shadow: none;
  }
  .row.assistant .bubble,
  html[data-theme="light"] .row.assistant .bubble {
    background: var(--bubble-bot); color: var(--text);
    border: 1px solid var(--bubble-bot-border);
    border-radius: 18px 18px 18px 6px; padding: 10px 15px;
    max-width: min(680px, 86%); box-shadow: var(--bubble-shadow);
  }
  .row.assistant .bubble.system,
  html[data-theme="light"] .row.assistant .bubble.system {
    background: transparent; border-color: transparent; box-shadow: none; padding: 0 1px;
  }

  .tabs { gap: 2px; }
  .tabs .tab { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
  .tabs .panel-close { margin-left: auto; }
  #sec-skills .section-head, #sec-memory .section-head { margin-top: 4px; }

  /* =====================================================================
     v6: softer surfaces, framed conversation, settings as pages
     Dark is a deep graphite, not black; light is a soft grey paper, not
     white. Both bubble sides are framed, like a messaging app.
     ===================================================================== */
  :root {
    --bg: #16171b;
    --bg-2: #1b1c21;
    --panel: #212228;
    --panel-2: #282930;
    --panel-3: #31323a;
    --border: #34353d;
    --border-soft: #2a2b32;
    --border-strong: #474953;
    --text: #ececf1;
    --muted: #a8a9b3;
    --dim: #777985;
    --accent: #ececf1;
    --accent-2: #d6d6de;
    --bubble-bot: #23242b;
    --bubble-bot-border: #2f3038;
    --bubble-user: #34305a;
    --bubble-user-border: rgba(170, 155, 255, 0.22);
    --bubble-user-text: #f0eeff;
    --bubble-shadow: none;
  }
  html[data-theme="light"] {
    --bg: #f2f3f5;
    --bg-2: #eaecef;
    --panel: #f8f9fa;
    --panel-2: #e6e8ec;
    --panel-3: #dcdfe4;
    --border: #d8dbe0;
    --border-soft: #e1e4e8;
    --border-strong: #c2c6cd;
    --text: #1d1e22;
    --muted: #5b5e67;
    --dim: #888b94;
    --accent: #1d1e22;
    --accent-2: #3a3c43;
    --bubble-bot: #fbfbfc;
    --bubble-bot-border: #e0e3e8;
    --bubble-user: #e5e0fb;
    --bubble-user-border: rgba(82, 82, 82, 0.16);
    --bubble-user-text: #241c50;
    --bubble-shadow: 0 1px 2px rgba(20, 24, 40, 0.04);
  }

  /* settings: one page at a time */
  #settings-scroll > .dsec { display: none; border-top: 0; margin-top: 0; padding-top: 0; }
  #settings-scroll > .dsec.active { display: block; }
  #settings-scroll > .dsec > .dsec-head:first-child { font-size: 16px; margin-bottom: 14px; }

  /* the chat name opens its details */
  .chat-title-text { cursor: pointer; border-radius: 8px; padding: 2px 6px; margin: -2px -6px; }
  .chat-title-text:hover { background: var(--panel-2); }

  /* avatars: calmer picker */
  .avatar-preview { background: var(--bg-2); }
  .shape-btn { background: var(--bg-2); border-color: transparent; }
  .shape-btn.active { background: var(--panel-2); border-color: var(--border-strong); box-shadow: none; }
  .swatch { width: 30px; height: 30px; box-shadow: none; }
  .swatch.active { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg) inset; }

  /* brand mark = the app icon (crescent with the bots' eyes) */
  .brand-mark,
  html[data-theme="light"] .brand-mark {
    background: url("../icons/icon-64.png") center / cover no-repeat;
    box-shadow: none; border-radius: 7px;
  }

  /* the empty chat shows who you are talking to */
  .empty-avatar { width: 54px; height: 54px; margin-bottom: 18px; border-radius: 14px; }

  /* takeover card ----------------------------------------------------- */
  .takeover-card { border: 1px solid var(--accent, #8b7cf6); border-radius: 14px; padding: 14px 16px; margin: 8px 0; background: var(--panel); max-width: 560px; }
  .takeover-title { font-weight: 600; margin-bottom: 4px; }
  .takeover-reason { color: var(--text); margin-bottom: 10px; }
  .takeover-card .btn-row { margin: 0 0 6px; }
  .row.card-row .takeover-card { margin: 0; width: 100%; }
  .specialist-welcome { padding-top: 12px; }
  .pw-wrap { position: relative; display: block; }
  .warn-note { color: #fbbf24; }
  .ts-install .btn-row { display: flex; gap: 8px; align-items: center; }
  .ts-install .btn-row .pw-wrap { flex: 1; }
  .pw-wrap > input { width: 100%; padding-right: 58px; box-sizing: border-box; }
  .pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--dim); font-size: 12px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
  .pw-eye:hover { color: var(--text); background: var(--border-soft); }
  .video-jobs { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
  .video-job { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
  .specialist-welcome .muted { margin-top: 6px; font-size: 13px; color: var(--dim); }
  .start-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

  /* whose screen, in a group --------------------------------------------- */
  .pc-who { display: inline-flex; gap: 4px; margin: 0 auto 0 10px; align-items: center; }
  .pc-who button { padding: 2px; border-radius: 50%; border: 2px solid transparent; background: none; line-height: 0; opacity: 0.55; }
  .pc-who button.on { border-color: var(--accent, #8b7cf6); opacity: 1; }
  .pc-who button:hover { opacity: 1; }
  .pc-who .av { --av-size: 22px; }

  /* generated videos in chat */
  .att-video { display: flex; flex-direction: column; gap: 8px; max-width: min(520px, 100%); }
  .att-video video { width: 100%; border-radius: 12px; background: #000; display: block; }
  .att-video-bar { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .att-video-name { flex: 1; min-width: 0; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .att-act {
    display: inline-flex; align-items: center; gap: 5px; flex: none;
    height: 28px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--border-soft); background: var(--panel-2); color: var(--muted);
    font: inherit; font-size: 12px; text-decoration: none; cursor: pointer;
    transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
  }
  .att-act:hover { background: var(--panel-3); color: var(--text); border-color: var(--border); }
  .att-act svg { flex: none; }

  .folder-write { white-space: nowrap; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; align-self: center; margin: 0; }

  /* feishu ------------------------------------------------------------ */
  .feishu-status { margin: 8px 0; font-size: 13px; }
  .feishu-status.ok { color: #50c878; }
  .feishu-status.bad { color: var(--red); }
  .feishu-steps { margin: 6px 0 4px 18px; padding: 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
  .feishu-code { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
  .feishu-code b { font-size: 22px; letter-spacing: 4px; font-variant-numeric: tabular-nums; }

  /* other models ------------------------------------------------------ */
  .models-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }

  /* read aloud ---------------------------------------------------------- */
  .speak-btn { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 2px 8px; border: 1px solid var(--border-soft); border-radius: 999px; background: transparent; color: var(--dim); font-size: 12px; cursor: pointer; }
  .speak-btn:hover { color: var(--text); border-color: var(--accent); }
  .speak-btn.playing { color: var(--accent); border-color: var(--accent); }
  .bubble.system .speak-btn { display: none; }
  .speak-bar { display: flex; align-items: center; gap: 10px; width: max-content; margin: 0 auto 8px; padding: 4px 6px 4px 12px; border: 1px solid var(--accent); border-radius: 999px; background: var(--panel, var(--bg)); color: var(--text); font-size: 13px; }
  .speak-bar[hidden] { display: none; }
  /* pages (page library) ---------------------------------------------- */
  .att-page { display: flex; align-items: center; gap: 10px; max-width: 320px; padding: 9px 12px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg-soft, transparent); color: inherit; cursor: pointer; text-align: left; font: inherit; }
  .att-page:hover { border-color: var(--accent); }
  .att-page .att-icon { font-size: 20px; }
  .att-page .att-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
  .att-page .att-size { color: var(--dim); font-size: 12px; }
  .page-viewer { position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column; background: rgba(0,0,0,.55); }
  .page-viewer.show { display: flex; }
  .page-viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel, #fff); border-bottom: 1px solid var(--border-soft); }
  .page-viewer-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
  /* vault ------------------------------------------------------------- */
  .vault-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
  .vault-row { border: 1px solid var(--border-soft); border-radius: 12px; padding: 9px 11px; }
  /* 连接应用: the catalog */
  .mcp-catalog { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
  .mcp-cat { font-weight: 600; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
  .mcp-app { border: 1px solid var(--border-soft); border-radius: 12px; padding: 10px 12px; }
  .mcp-app-head { display: flex; align-items: center; gap: 12px; }
  .mcp-badge { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
  .mcp-app-meta { flex: 1; min-width: 0; }
  .mcp-app-meta b { display: block; }
  .mcp-app-meta small { display: block; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .mcp-ok { color: var(--green); font-size: 13px; white-space: nowrap; background: none; border: 0; cursor: pointer; padding: 6px 4px; }
  .mcp-warn { color: var(--amber); }
  .mcp-app-body { margin-top: 10px; }
  .mcp-app-body .field { margin-top: 6px; }
  .mcp-mailboxes { margin-top: 10px; }
  .mcp-mailbox { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .mcp-mailbox span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mcp-more summary { cursor: pointer; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
  .vault-head { display: flex; align-items: center; gap: 8px; }
  .vault-title { flex: 1; min-width: 0; }
  .vault-title b { display: block; }
  .vault-title small { color: var(--dim); font-size: 11px; }
  .vault-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
  .vault-edit .field { margin: 0; }
  .vault-add summary { cursor: pointer; color: var(--muted); margin: 6px 0; }
  .login-card .field { margin: 6px 0; }
  .login-saved { color: #50c878; margin: 6px 0; }

  /* activity log -------------------------------------------------------- */
  .audit-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
  .chip-btn { border: 1px solid var(--border-soft); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 11px; font-size: 12px; }
  .chip-btn.on { border-color: var(--accent, #8b7cf6); color: var(--text); background: var(--panel-2); }
  .audit-list { display: flex; flex-direction: column; }
  .audit-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
  .audit-time { color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; padding-top: 1px; }
  .audit-icon { width: 18px; text-align: center; }
  .audit-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .audit-text small { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
  .audit-tag, .audit-risk { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
  .audit-risk.r-HIGH { color: #f07060; }
  .audit-risk.r-MEDIUM { color: #f0a03c; }
  .audit-row.bad .audit-tag { color: #f07060; }

  /* bot abilities ------------------------------------------------------- */
  /* group task board */
  .plan-card { width: min(560px, 100%); border: 1px solid var(--border-soft); border-radius: 14px; background: var(--panel); padding: 12px 12px 6px; }
  .plan-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .plan-title { font-weight: 650; font-size: 14px; }
  .plan-progress { margin-left: auto; font-size: 12px; color: var(--dim); }
  .plan-progress.live { color: var(--accent-2, var(--accent)); }
  .plan-fallback { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; }
  .plan-bar { height: 3px; border-radius: 3px; background: var(--panel-3); overflow: hidden; margin-bottom: 6px; }
  .plan-bar i { display: block; height: 100%; background: var(--accent); transition: width 300ms var(--ease); }
  .plan-task { border-top: 1px solid var(--border-soft); }
  .plan-task:first-of-type { border-top: 0; }
  .plan-task summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 2px; cursor: pointer; }
  .plan-task summary::-webkit-details-marker { display: none; }
  .plan-task-text { flex: 1; min-width: 0; }
  .plan-task-text b { display: block; font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plan-task-text small { display: block; font-size: 11.5px; color: var(--dim); margin-top: 1px; }
  .plan-chip { flex: none; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
  .plan-task.st-doing .plan-chip { background: rgba(163, 163, 163, .16); color: var(--accent-2, #a996ff); }
  .plan-task.st-done .plan-chip { background: rgba(46, 204, 113, .14); color: #3ddc84; }
  .plan-task.st-ask .plan-chip { background: rgba(240, 167, 44, .16); color: #f0a72c; }
  .plan-task.st-fail .plan-chip { background: rgba(239, 83, 80, .14); color: #ff8a87; }
  .plan-task-body { padding: 0 2px 10px 32px; font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; white-space: pre-wrap; line-height: 1.5; }
  .plan-result { color: var(--text); }
  .plan-q { color: #f0a72c; }

  /* phone home page (Grok-style): the bot list is a page of its own */
  .bot-time, .home-search, .nav-back-ico { display: none; }
  @media (max-width: 860px) {
    .nav-menu-ico { display: none; }
    .nav-back-ico { display: block; }
    /* home and chat are two pages: switch at once, no drawer slide */
    .sidebar { transition: none; }
    body.m-home #sidebar-scrim { display: none; }
    .sidebar.open {
      left: 0; right: 0; top: 0; bottom: 0; width: 100%; max-width: none;
      border-right: 0; box-shadow: none; background: var(--bg);
      padding-top: calc(var(--safe-t) + 6px); padding-bottom: 0;
      transition: none;
    }
    body.m-home .chat, body.m-home .panel { visibility: hidden; }
    .sidebar.open .sidebar-resizer, .sidebar.open #sidebar-close { display: none; }
    .sidebar.open .side-top { padding: 6px 16px 4px; gap: 10px; border-bottom: 0; }
    .sidebar.open .side-brand { flex: 0 1 auto; width: auto; max-width: 72%; border-radius: 999px; padding: 6px 14px 6px 6px; background: var(--panel); }
    .sidebar.open .new-bot { margin-left: auto; }
    .sidebar.open #new-bot-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--panel); border: 1px solid var(--border-soft); }
    .sidebar.open #new-bot-btn svg { width: 22px; height: 22px; }
    .sidebar.open .side-head { display: none; }
    .sidebar.open #groups-section .side-head { display: flex; padding: 14px 20px 4px; }
    .sidebar.open .sidebar-scroll { padding-bottom: calc(96px + var(--safe-b)); }
    .sidebar.open .bot-list { padding: 0; gap: 0; }
    .sidebar.open .bot, .sidebar.open .group {
      min-height: 78px; padding: 12px 20px; gap: 14px; border-radius: 0; border: 0; background: transparent;
    }
    .sidebar.open .bot.active { background: transparent; border: 0; }
    .sidebar.open .bot:active, .sidebar.open .group:active { background: var(--panel); }
    .sidebar.open .bot .av { --av-size: 54px !important; }
    .sidebar.open .bot-name { font-size: 17px; font-weight: 650; }
    .sidebar.open .bot-name .badge { display: none; }
    .sidebar.open .bot-preview { font-size: 14.5px; color: var(--muted); margin-top: 4px; }
    .sidebar.open .bot-time { display: block; align-self: flex-start; margin-top: 4px; flex: none; color: var(--dim); font-size: 13px; }
    .sidebar.open .bot-more { opacity: .45; }
    /* the main bot: big and centred at the top */
    .sidebar.open .bot.is-primary { flex-direction: column; gap: 10px; padding: 18px 20px 26px; min-height: 0; }
    .sidebar.open .bot.is-primary .av { --av-size: 104px !important; }
    .sidebar.open .bot.is-primary .bot-text { flex: none; text-align: center; }
    .sidebar.open .bot.is-primary .bot-name { justify-content: center; font-size: 15px; font-weight: 500; }
    .sidebar.open .bot.is-primary .bot-preview, .sidebar.open .bot.is-primary .bot-time, .sidebar.open .bot.is-primary .bot-more { display: none; }
    /* bottom: settings and a search pill, floating */
    .sidebar.open .sidebar-bottom {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
      display: flex; flex-direction: row; align-items: center; gap: 12px; border-top: 0;
      padding: 12px 16px calc(12px + var(--safe-b));
      background: linear-gradient(to top, var(--bg) 60%, transparent);
    }
    .sidebar.open .side-actions { order: -1; padding: 0; width: auto; flex: none; margin: 0; }
    .sidebar.open #settings-btn { width: 54px; height: 54px; border-radius: 50%; justify-content: center; padding: 0; background: var(--panel); border: 1px solid var(--border-soft); }
    .sidebar.open #settings-btn span:not(.dot) { display: none; }
    .sidebar.open #settings-btn svg { width: 22px; height: 22px; margin: 0; }
    .sidebar.open #settings-btn .dot { position: absolute; top: 10px; right: 10px; }
    .sidebar.open .home-search {
      flex: 1; display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 18px;
      border-radius: 999px; background: var(--panel); border: 1px solid var(--border-soft); color: var(--dim);
    }
    .sidebar.open .home-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
  }

  /* bot settings: a calm list - who it is, its model, what it may do, approvals */
  #botedit-sheet { display: flex; flex-direction: column; }
  .be-body { padding: var(--s5); }
  .be-hero { display: flex; align-items: center; gap: 16px; padding-bottom: var(--s5); border-bottom: 1px solid var(--border-soft); }
  .be-avatar { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 20px; cursor: pointer; }
  .be-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  .be-avatar-edit {
    position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; color: var(--text);
    background: var(--panel-3); border: 2px solid var(--panel-2); box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: background 150ms var(--ease), color 150ms var(--ease);
  }
  .be-avatar:hover .be-avatar-edit { background: var(--accent); color: var(--on-accent, #fff); }
  .be-hero-fields { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .be-name, .be-role {
    width: 100%; margin-left: -8px; padding: 4px 8px; border-radius: 8px;
    border: 1px solid transparent; background: transparent; color: var(--text); font: inherit;
    transition: border-color 150ms var(--ease), background 150ms var(--ease);
  }
  .be-name { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
  .be-role { font-size: 13px; color: var(--muted); line-height: 1.45; resize: none; overflow: hidden; }
  .be-name:hover, .be-role:hover { border-color: var(--border-soft); }
  .be-name:focus, .be-role:focus { outline: none; border-color: var(--accent); background: var(--panel); color: var(--text); }
  .be-section { margin-top: var(--s5); }
  .be-section-title { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; color: var(--dim); margin: 0 0 8px 2px; }
  .be-inline { display: flex; gap: 8px; align-items: center; }
  .be-inline .field { flex: 1; min-width: 0; }
  .be-inline .btn { flex: none; }
  .be-hint { font-size: 11.5px; color: var(--dim); margin: 6px 2px 0; line-height: 1.5; }
  .be-group { border: 1px solid var(--border-soft); border-radius: 12px; background: var(--panel); overflow: hidden; }
  .be-row { display: flex; align-items: center; gap: 14px; padding: 11px 14px; cursor: pointer; transition: background 120ms var(--ease); }
  .be-row + .be-row { border-top: 1px solid var(--border-soft); }
  .be-row:hover { background: var(--panel-2); }
  .be-row-text { flex: 1; min-width: 0; }
  .be-row-text b { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); }
  .be-row-text small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--dim); line-height: 1.45; }
  .be-switch {
    appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
    width: 34px; height: 20px; border-radius: 999px; cursor: pointer;
    background: var(--panel-3); border: 1px solid var(--border);
    transition: background 160ms var(--ease), border-color 160ms var(--ease);
  }
  .be-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--muted); transition: transform 160ms var(--ease), background 160ms var(--ease);
  }
  .be-switch:checked { background: var(--accent); border-color: var(--accent); }
  .be-switch:checked::after { transform: translateX(14px); background: var(--on-accent, #fff); }
  .be-switch:indeterminate { border-color: var(--accent); }
  .be-switch:indeterminate::after { transform: translateX(7px); background: var(--accent); }
  .be-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .be-danger { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border-soft); }
  .be-delete { padding: 0; border: 0; background: none; color: var(--red); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
  .be-delete:hover { text-decoration: underline; }
  .be-delete:disabled { color: var(--dim); cursor: default; text-decoration: none; }
  .be-foot { flex: none; padding: 12px var(--s5) calc(12px + var(--safe-b)); border-top: 1px solid var(--border-soft); background: var(--panel-2); }
  .ability-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 0 10px; }
  .ability { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border: 1px solid var(--border-soft); border-radius: 10px; cursor: pointer; font-size: 13px; }
  .ability:has(input:checked) { border-color: var(--accent, #8b7cf6); }
  .ability input { margin-top: 2px; }
  .ability b { display: block; font-weight: 600; }
  .ability small { display: block; color: var(--muted); font-size: 11px; }
  .ability-trust { margin-bottom: 8px; font-size: 13px; }

  /* permissions --------------------------------------------------------- */
  .level-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
  .perm-card {
    border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px;
    background: var(--panel-2); margin: 8px 0 4px;
  }
  .perm-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
  .perm-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
    border-radius: 999px; border: 1px solid var(--border-soft);
    font-size: 11.5px; color: var(--muted); background: var(--bg);
  }
  .perm-chip b { color: var(--text); font-weight: 600; }
  .perm-chip.warn { border-color: rgba(240, 167, 44, .4); color: #e6c48b; }
  .perm-table-wrap { overflow-x: auto; }
  .perm-table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 12px; }
  .perm-table th, .perm-table td {
    border-bottom: 1px solid var(--border-soft); padding: 7px 8px;
    text-align: center; white-space: nowrap;
  }
  .perm-table th:first-child, .perm-table td:first-child {
    text-align: left; position: sticky; left: 0; background: var(--panel-2);
  }
  .perm-table th { color: var(--dim); font-weight: 600; font-size: 11px; }
  .perm-table td.on { color: var(--green, #2fbf71); font-weight: 700; }
  .perm-table td.ask { color: var(--amber, #f0a72c); font-weight: 700; }
  .perm-table td.off { color: var(--dim); }
  .perm-legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; }
  .perm-key { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
  .perm-key.on { color: var(--green, #2fbf71); }
  .perm-key.ask { color: var(--amber, #f0a72c); }
  .perm-key.off { color: var(--dim); }
  .usage-range { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
  .usage-range button {
    padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-soft);
    background: var(--panel-2); color: var(--muted); font: 600 12px/1 var(--sans);
  }
  .usage-range button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .usage-table { min-width: 0; table-layout: fixed; }
  .usage-table th, .usage-table td { white-space: normal; overflow-wrap: anywhere; }
  .usage-table th:first-child, .usage-table td:first-child { position: static; }
  .usage-price-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
  .usage-price-row .name-input { flex: 1; min-width: 130px; font-family: var(--mono); font-size: 12px; }
  .usage-price-row input.field { width: 92px; }
  .usage-price-row .tag { font-size: 11px; color: var(--amber, #f0a72c); }
  .perm-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
  .level-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 12px; cursor: pointer; }
  .level-opt:has(input:checked) { border-color: var(--accent, #8b7cf6); background: var(--panel-2); }
  .level-opt input { margin-top: 3px; }
  .level-opt b { display: block; font-weight: 600; }
  .level-opt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
  .deny-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
  .rule-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
  .rule-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border-soft); border-radius: 10px; }
  .rule-text { flex: 1; }
  .rule-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
  .rule-badge.ask { background: rgba(240, 160, 60, 0.18); color: #f0a03c; }
  .rule-badge.allow { background: rgba(80, 200, 120, 0.16); color: #50c878; }
  .rule-action { width: auto; flex: none; margin: 0; }
  .deny-item { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1px solid var(--border-soft); border-radius: 8px; }
  .deny-add { display: flex; gap: 8px; }
  .deny-add .field { flex: 1; margin: 0; }

  /* @mention picker --------------------------------------------------- */
  .composer { position: relative; }
  .mention-pop { left: 0; right: auto; bottom: calc(100% + 6px); top: auto; min-width: 220px; max-width: 320px; max-height: 260px; overflow: auto; }
  .mention-pop .mp-item { display: flex; align-items: center; gap: 10px; width: 100%; }
  .mention-pop .mp-item.on { background: var(--panel-2); color: var(--text); }
  .mention-pop .mp-item small { color: var(--dim); margin-left: auto; font-size: 11px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mention-pop .mp-item .av { --av-size: 22px; }
  .mention-pop .mp-all { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); font-size: 12px; }

  /* voice input ------------------------------------------------------ */
  .mic-btn {
    flex: none; align-self: flex-end; width: 34px; height: 34px; margin: 0 4px 2px 0;
    display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--dim);
  }
  .mic-btn:hover { background: var(--panel-2); color: var(--text); }
  .mic-btn.rec { background: var(--red); color: #fff; animation: mic-pulse 1.4s ease-in-out infinite; }
  .mic-btn.busy { opacity: 0.6; pointer-events: none; }
  @keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.45); } 50% { box-shadow: 0 0 0 6px rgba(229, 83, 75, 0); } }
  .composer-box.recording textarea::placeholder { color: var(--red); opacity: 1; }

  /* attachments ------------------------------------------------------ */
  .attach-btn {
    flex: none; align-self: flex-end; width: 34px; height: 34px; margin: 0 2px 2px 0;
    display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--dim);
  }
  .attach-btn:hover { background: var(--panel-2); color: var(--text); }
  .attach-strip { display: flex; flex-wrap: wrap; gap: 6px; max-width: 760px; margin: 0 auto 8px; width: 100%; }
  .att-chip {
    display: flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 6px 4px 4px;
    border: 1px solid var(--border-soft); border-radius: 10px; background: var(--panel); font-size: 12px; color: var(--muted);
  }
  .att-chip img { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; }
  .att-chip .att-icon { width: 30px; text-align: center; }
  .att-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .att-chip.busy { opacity: 0.7; }
  .att-chip.bad { border-color: var(--red); color: var(--red); }
  .att-x { border: 0; background: transparent; color: var(--dim); font-size: 11px; padding: 2px 4px; border-radius: 6px; }
  .att-x:hover { color: var(--text); background: var(--panel-2); }
  .att-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .bubble.only-att .att-list { margin-top: 0; }
  .att-img img { display: block; max-width: 220px; max-height: 180px; border-radius: 10px; object-fit: cover; cursor: zoom-in; }
  .att-file { max-width: 260px; }
  .att-file .att-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
  .bubble .att-list { margin-top: 10px; }
  .lightbox { position: fixed; inset: 0; z-index: 9999; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; background: rgba(0, 0, 0, 0.82); cursor: zoom-out; }
  .lightbox.show { display: flex; }
  .lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
  .lightbox-bar { display: flex; align-items: center; gap: 12px; color: #ddd; font-size: 13px; cursor: default; }
  .att-file {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
    background: rgba(255, 255, 255, 0.06); color: inherit; text-decoration: none; max-width: 260px;
  }
  html[data-theme="light"] .att-file { background: rgba(0, 0, 0, 0.05); }
  .att-meta { display: flex; flex-direction: column; min-width: 0; }
  .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
  .att-size { font-size: 11px; opacity: 0.7; }
  .chat.dragging .composer-box { outline: 2px dashed var(--border-strong); outline-offset: 4px; }
  /* =====================================================================
     v7 · design v2 (Notion §97.5): black / white / grey, one brand colour
     used only for the logo, focus and links. Surfaces instead of outlines.
     Colours apply everywhere; shapes below change only at phone width.
     ===================================================================== */
  :root {
    --bg: #0A0A0A; --bg-2: #111111;
    --panel: #141414; --panel-2: #1C1C1C; --panel-3: #262626;
    --border: rgba(255, 255, 255, 0.08); --border-soft: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #F5F5F5; --muted: #A3A3A3; --dim: #737373;
    --accent: #F5F5F5; --accent-2: #FFFFFF; --accent-soft: rgba(255, 255, 255, 0.08);
    --on-accent: #0A0A0A;
    --brand: #A3A3A3; --link: #E5E5E5;
    --green: #22C55E; --amber: #F59E0B; --red: #EF4444;
    --bubble-user: #333333; --bubble-user-border: transparent; --bubble-user-text: #F5F5F5;
    --bubble-bot: #181818; --bubble-bot-border: transparent; --bubble-shadow: none;
    --float-shadow: none;
  }
  html[data-theme="light"] {
    --bg: #FFFFFF; --bg-2: #F0F0F0;
    --panel: #F5F5F5; --panel-2: #EDEDED; --panel-3: #E3E3E3;
    --border: rgba(0, 0, 0, 0.08); --border-soft: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.16);
    --text: #0A0A0A; --muted: #525252; --dim: #8A8A8A;
    --accent: #0A0A0A; --accent-2: #262626; --accent-soft: rgba(0, 0, 0, 0.05);
    --on-accent: #FFFFFF;
    --brand: #525252; --link: #0A0A0A;
    --green: #16A34A; --amber: #B45309; --red: #DC2626;
    --bubble-user: #E3E3E3; --bubble-user-border: transparent; --bubble-user-text: #0A0A0A;
    --bubble-bot: #F4F4F4; --bubble-bot-border: transparent; --bubble-shadow: none;
    --float-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }
  body { background: var(--bg); }
  a, .bubble.md a, .key-link { color: var(--link); text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 2px; }
  :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
  .composer-box:focus-within { border-color: var(--brand); box-shadow: var(--float-shadow); }
  .btn.primary, .btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .usage-range button.on, .pc-mobile-bar button.on { color: var(--on-accent); }
  .send-btn, .send-btn:hover { background: var(--accent); color: var(--on-accent); }
  .bubble.md code { background: var(--panel-2); }
  html[data-theme="light"] .bubble.md .md-code, .bubble.md .md-code { background: var(--panel); border-color: transparent; }
  .composer-box { box-shadow: var(--float-shadow); }
  .sidebar, html[data-theme="light"] .sidebar { border-right: 1px solid var(--border); }
  .row.user .bubble,
  html[data-theme="light"] .row.user .bubble { border: 0; border-radius: 20px 20px 6px 20px; }
  .row.assistant .bubble,
  html[data-theme="light"] .row.assistant .bubble { border: 0; border-radius: 20px 20px 20px 6px; }
  .row.user .bubble a { color: inherit; text-decoration: underline; }
  .row.user .bubble code { background: rgba(127, 127, 127, 0.22); color: inherit; }
  .approval { box-shadow: none; }
  html[data-theme="light"] .approval { box-shadow: none; }
  html[data-theme="light"] .composer-box { box-shadow: var(--float-shadow); }
  @media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0ms !important; animation-duration: 0ms !important; }
  }

  /* ---- phone width: the mockup's shapes ---------------------------- */
  @media (max-width: 860px) {
    body { font-size: 15px; line-height: 1.55; }
    .chat-head { min-height: 56px; padding: 8px 12px 8px 16px; border-bottom: 0; }
    .chat-head .title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
    .chat-head .sub { font-size: 12px; color: var(--muted); }
    .messages { padding-left: 20px; padding-right: 20px; }
    .row.user .bubble,
    html[data-theme="light"] .row.user .bubble {
      background: var(--bubble-user); color: var(--bubble-user-text); border: 0;
      border-radius: 20px 20px 6px 20px; padding: 10px 16px; max-width: 80%; font-size: 15px;
    }
    .row.assistant .bubble,
    html[data-theme="light"] .row.assistant .bubble {
      background: var(--bubble-bot); border: 0; box-shadow: none; padding: 10px 16px;
      max-width: 88%; border-radius: 20px 20px 20px 6px; font-size: 15px; line-height: 1.6;
    }
    .bubble.md .md-h { font-size: 17px; }
    .chip, html[data-theme="light"] .chip { border: 0; background: transparent; border-radius: 12px; font-size: 13px; }
    .chip[open] { background: var(--panel); }
    .chip summary { min-height: 40px; padding: 8px 0; color: var(--muted); }
    .chip[open] summary { padding: 8px 12px; }
    .chip summary:hover, html[data-theme="light"] .chip summary:hover { background: transparent; }
    .chip-name { font-size: 13px; font-weight: 500; color: var(--muted); }
    .approval, .approval.resolved { border: 0; border-radius: 16px; background: var(--panel); padding: 16px; }
    .approval-title { font-size: 15px; font-weight: 600; }
    .approval-detail { background: var(--bg); border: 0; border-radius: 12px; }
    .approval-impact { font-size: 13px; }
    .approval-actions .btn { min-height: 44px; border-radius: 12px; font-size: 15px; }
    .approval-actions .btn:not(.primary) { background: transparent; border: 1px solid var(--border); color: var(--text); }
    .composer { padding: 10px 16px calc(12px + var(--safe-b)); }
    .composer-box, html[data-theme="light"] .composer-box {
      min-height: 52px; border-radius: 26px; border: 0; background: var(--panel);
      padding: 8px 8px 8px 14px; align-items: center;
    }
    .composer textarea { font-size: 15px; }
    .send-btn { width: 36px; height: 36px; }
    .btn { border-radius: 12px; }
    .speak-btn { border: 0; padding: 2px 0; }
    .choice, html[data-theme="light"] .choice { border: 0; background: var(--panel); border-radius: 16px; padding: 14px 16px; }
    .approval .choice, html[data-theme="light"] .approval .choice { background: var(--bg); border-radius: 12px; }
    .choice-key { border: 0; background: var(--panel-2); border-radius: 999px; }
    .choice-title { font-size: 15px; }
    .choice-desc { font-size: 13px; color: var(--muted); }
    .notice.slim { border: 0; background: transparent; }

    /* settings: a grouped list first, then one page with a back arrow */
    .settings-top { border-bottom: 0; padding: 10px 12px; min-height: 56px; }
    .settings-heading { font-size: 17px; font-weight: 600; }
    .set-back { display: inline-flex; }
    .settings-modal, html[data-theme="light"] .settings-modal { background: var(--bg); }
    .settings-modal.set-home .set-back { display: none; }
    /* The top bar already names the page: the page's own first heading would say it twice. */
    .settings-modal:not(.set-home) #settings-scroll > .dsec > .dsec-head:first-child { display: none; }
    .settings-modal.set-home .settings-top { padding: 14px 12px 6px 20px; }
    .settings-heading { flex: 1; min-width: 0; }
    .settings-modal:not(.set-home) .settings-nav { display: none; }
    .settings-modal.set-home .settings-scroll { display: none; }
    .settings-modal.set-home .settings-heading { font-size: 28px; letter-spacing: -0.01em; }
    .settings-modal.set-home .settings-nav {
      flex: 1; flex-direction: column; overflow-y: auto; overflow-x: hidden;
      padding: 8px 20px calc(24px + var(--safe-b)); gap: 0; border: 0;
    }
    .settings-modal.set-home .setnav {
      display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px;
      background: var(--panel); border-radius: 0; color: var(--text); font-size: 15px; font-weight: 400;
      box-shadow: inset 0 1px 0 var(--border);
    }
    .settings-modal.set-home .setnav.active { background: var(--panel); font-weight: 400; }
    .settings-modal.set-home .setnav::after {
      content: ""; margin-left: auto; width: 7px; height: 7px; flex: none;
      border-right: 1.75px solid var(--dim); border-top: 1.75px solid var(--dim); transform: rotate(45deg);
    }
    .settings-modal.set-home .setnav svg { display: block; width: 20px; height: 20px; flex: none; color: var(--muted); }
    /* each group is one rounded card with its title above it */
    .settings-modal.set-home .setnav-sec { gap: 0; margin: 0 0 20px; }
    .settings-modal.set-home .setnav-group { padding: 0 16px 8px; font-size: 13px; font-weight: 500; }
    .settings-modal.set-home .setnav-sec .setnav:first-of-type { border-radius: 16px 16px 0 0; box-shadow: none; }
    .settings-modal.set-home .setnav-sec .setnav:last-of-type { border-radius: 0 0 16px 16px; }
    .settings-modal:not(.set-home) .setnav-group { display: none; }
    .settings-scroll { padding: 8px 20px calc(32px + var(--safe-b)); }
    .dsec-head { font-size: 17px; }
    .dsec-sub { font-size: 13px; color: var(--muted); }
  }

  /* =====================================================================
     design v3 (交付/设计方案.html), in the black / white / gray palette:
     radii 10 / 14 / 18, thin lines, no shadows on desktop.
     ===================================================================== */
  /* approval: the one card that stands out - title, why, the command, one row of buttons */
  .approval.pending, html[data-theme="light"] .approval.pending {
    border: 1px solid var(--border-strong); border-radius: 14px; padding: 16px 18px;
    background: linear-gradient(180deg, var(--accent-soft), transparent 72%), var(--panel);
  }
  .approval .approval-top { margin-bottom: 4px; }
  .approval-kicker { font-size: 11.5px; color: var(--dim); }
  .approval-title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
  .approval-why, .approval-impact { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }
  .approval-detail, html[data-theme="light"] .approval-detail { margin: 10px 0 4px; padding: 9px 12px; border: 0; border-radius: 10px; background: var(--bg); }
  .approval-detail code { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .approval-actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: 14px; }
  .approval-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
  .approval-buttons .btn { min-height: 36px; padding: 0 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; }
  .approval-buttons .btn:not(.primary) { background: transparent; border: 1px solid var(--border-strong); color: var(--text); font-weight: 500; }
  .approval-buttons .btn:not(.primary):hover { background: var(--panel-2); }
  .approval-note, html[data-theme="light"] .approval-note { min-height: 34px; font-size: 12.5px; border-radius: 10px; background: transparent; }
  .approval-tech { margin-top: 10px; }
  .approval-tech > summary { font-size: 12px; color: var(--dim); }
  .approval.pending .approval-tech > summary { display: none; } /* the 看详情 button opens it */
  .composer-box { border-radius: 18px; }

  @media (max-width: 860px) {
    /* phone: a pending approval sits at the bottom of the chat, in reach of a thumb */
    .messages .approval.pending {
      position: sticky; bottom: 8px; z-index: 3; border-radius: 22px; padding: 18px;
      box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
    }
    html[data-theme="light"] .messages .approval.pending { box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.10); }
    .approval-buttons .btn { flex: 1 1 0; min-height: 44px; border-radius: 12px; font-size: 15px; }
    .approval-buttons .approval-more { flex: 1 1 100%; min-height: 40px; font-size: 14px; }

    /* phone home: a list of conversations, the main assistant first like the rest */
    .sidebar.open .bot, .sidebar.open .group {
      min-height: 64px; margin: 2px 10px; padding: 10px 12px; gap: 12px; border-radius: 16px; width: auto; max-width: calc(100% - 20px); box-sizing: border-box;
    }
    .sidebar.open .bot.active { background: transparent; }
    .sidebar.open .bot:active, .sidebar.open .group:active { background: var(--panel); }
    .sidebar.open .bot .av, .sidebar.open .bot.is-primary .av { --av-size: 44px !important; }
    .sidebar.open .bot.is-primary { flex-direction: row; gap: 12px; padding: 10px 12px; min-height: 64px; background: var(--panel); }
    .sidebar.open .bot.is-primary .bot-text { flex: 1; text-align: left; }
    .sidebar.open .bot.is-primary .bot-name { justify-content: flex-start; }
    .sidebar.open .bot-name, .sidebar.open .bot.is-primary .bot-name { font-size: 15.5px; font-weight: 650; }
    .sidebar.open .bot.is-primary .bot-preview, .sidebar.open .bot.is-primary .bot-time { display: block; }
    .sidebar.open .bot.is-primary .bot-more { display: grid; }
    .sidebar.open .bot-preview { font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sidebar.open .bot-time { font-size: 12px; }

    /* bottom bar: settings + search stay inside the screen */
    .sidebar.open .sidebar-bottom { box-sizing: border-box; width: 100%; max-width: 100vw; }
    .sidebar.open .home-search { min-width: 0; flex: 1 1 0; height: 48px; }
    .sidebar.open #settings-btn { width: 48px; height: 48px; }
  }

/* 已记住的权限 (1.2.164) */
.be-allowed { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.be-allowed-title { font-size: 12px; color: var(--muted); }
.be-allowed-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--panel-2, rgba(127,127,127,.08)); }
.be-allowed-label { font-size: 13px; overflow-wrap: anywhere; }
/* A hand-off between two bots in a group: "数据匠 → 图表师", quieter than a reply */
.row.handoff .bubble { opacity: .9; border-style: dashed; }

/* 需要你拍板 on top of the chat (1.2.165) */
.decision-strip { display: flex; gap: 10px; align-items: baseline; margin: 8px 16px 0; padding: 9px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--warn, #d79b3a) 45%, transparent); background: color-mix(in srgb, var(--warn, #d79b3a) 12%, transparent); color: var(--text); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.decision-strip[hidden] { display: none; }
.decision-strip b { flex: none; color: var(--warn, #d79b3a); }
.decision-strip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rt-head-actions { display: inline-flex; gap: 8px; align-items: center; }

/* 有新版本 (1.2.166) */
.update-banner { margin: 8px 16px 0; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.update-banner[hidden] { display: none; }
/* The list screen's copy (1.5.0) is for the phone; on a wide window the chat's copy is in view. */
.update-banner.side { margin: 4px 10px 8px; }
@media (min-width: 861px) { .update-banner.side { display: none; } }
/* the phone's screen, live (1.5.0) */
.modal.phone-live { width: min(420px, calc(100vw - 32px)); }
.phone-live-body { padding: 12px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.phone-live-img { max-width: 100%; max-height: calc(100vh - 170px); border-radius: 14px; border: 1px solid var(--border); background: #000; }
.phone-live-state { font-size: 12px; color: var(--muted); text-align: center; }
.update-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.update-notes summary { cursor: pointer; color: var(--muted); }
.update-notes ul { margin: 6px 0 0; padding-left: 18px; }
.update-actions { display: flex; gap: 8px; flex-wrap: wrap; }
