    :root {
      color-scheme: dark;
      --bg: #111719;
      --panel: #172023;
      --panel-2: #1e292d;
      --line: #2d3a3f;
      --text: #edf2f0;
      --muted: #94a19f;
      --accent: #77c7b1;
      --accent-2: #4d9d89;
      --bubble-in: #263236;
      --bubble-out: #365d52;
      --danger: #d37b72;
      --mono: "Maple Mono NF CN", "Maple Mono NF", "Maple Mono", "JetBrains Mono", "CaskaydiaCove Nerd Font", "Cascadia Mono", "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      --app-font-size: 14px;
      --app-mobile-font-size: clamp(14px, 4.8vw, 18px);
    }
    * { box-sizing: border-box; }
    html {
      /* Stop Android Chrome from auto-inflating ("boosting") text larger than
         our CSS specifies — that inflation widens buttons/bubbles past the
         screen edge (Close/Send cut off) and forces a manual pinch-zoom. With
         this, the page renders at exactly the adaptive sizes we set, fit to the
         phone, no zoom needed. (Desktop emulators never boost, which is why this
         only ever showed up on the real phone.) */
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
    }
    body {
      margin: 0;
      height: 100vh;
      height: 100dvh;
      font: var(--app-font-size)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--text);
      background: var(--bg);
      overflow: hidden;
      overflow-x: hidden;
      max-width: 100vw;
    }
    button, textarea, input { font: inherit; }
    .app {
      display: grid;
      grid-template-columns: var(--sidebar-w, 320px) 1fr;
      height: 100vh;
      height: 100dvh;
      min-width: 780px;
      min-height: 0;
      position: relative;
    }
    .app.sidebar-collapsed {
      grid-template-columns: 150px 1fr;
    }
    .app.sidebar-hidden {
      grid-template-columns: 0 minmax(0, 1fr);
    }
    .sidebar-resize-handle {
      position: absolute;
      top: 0;
      left: var(--sidebar-w, 320px);
      transform: translateX(-3px);
      width: 6px;
      height: 100%;
      cursor: col-resize;
      z-index: 40;
      background: transparent;
      transition: background 0.12s ease;
    }
    .sidebar-resize-handle::after {
      content: "";
      position: absolute;
      top: 0; left: 2px;
      width: 2px; height: 100%;
      background: transparent;
    }
    .sidebar-resize-handle:hover::after,
    .sidebar-resize-handle.dragging::after {
      background: var(--accent, #2f6f63);
    }
    .app.sidebar-collapsed .sidebar-resize-handle,
    .app.sidebar-hidden .sidebar-resize-handle {
      display: none;
    }
    .sidebar {
      grid-column: 1;
      grid-row: 1;
      border-right: 1px solid var(--line);
      background: var(--panel);
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
    }
    .app.sidebar-hidden .sidebar {
      display: none;
    }
    .sidebar-restore-btn {
      display: none;
      position: fixed;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      z-index: 90;
      width: 24px;
      height: 76px;
      min-width: 24px;
      padding: 0;
      place-items: center;
      color: #fff;
      border-color: rgba(255,255,255,.5);
      border-left: 0;
      border-radius: 0 8px 8px 0;
      background: rgba(16, 24, 26, .92);
      font-size: 19px;
      line-height: 1;
      box-shadow: 0 8px 20px rgba(0,0,0,.42);
    }
    .sidebar-restore-btn:hover {
      border-color: rgba(255,255,255,.82);
      background: rgba(30, 44, 48, .96);
    }
    .sidebar-restore-btn.visible {
      display: inline-grid;
    }
    .side-head {
      position: relative;
      padding: 16px 16px 12px;
      border-bottom: 1px solid var(--line);
    }
    .title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }
    .side-title-actions {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex: 0 0 auto;
    }
    .side-actions-toggle,
    .side-actions {
      display: none;
    }
    .sidebar-collapse-btn {
      display: inline-grid;
      place-items: center;
      color: #fff;
      font-size: 19px;
      line-height: 1;
      min-width: 30px;
      padding: 0;
      border-color: rgba(255,255,255,.45);
      background: rgba(237, 242, 240, .08);
    }
    .sidebar-hide-btn {
      min-width: 30px;
    }
    .sidebar-collapse-btn:hover:not(:disabled) {
      color: #fff;
      border-color: rgba(255,255,255,.88);
      background: rgba(237, 242, 240, .16);
    }
    .sidebar-toggle-glyph {
      transform: translateY(-1px);
    }
    .app.sidebar-collapsed .side-head {
      padding: 8px;
    }
    .app.sidebar-collapsed .title {
      justify-content: flex-end;
      margin-bottom: 4px;
    }
    .app.sidebar-collapsed .search,
    .app.sidebar-collapsed .status,
    .app.sidebar-collapsed .quota-bar,
    .app.sidebar-collapsed .workspace-panel,
    .app.sidebar-collapsed .workspace-note,
    .app.sidebar-collapsed .section-label,
    .app.sidebar-collapsed .topic-kind,
    .app.sidebar-collapsed .topic-animal,
    .app.sidebar-collapsed .topic-aititle,
    .app.sidebar-collapsed .topic-status,
    .app.sidebar-collapsed .topic-time,
    .app.sidebar-collapsed .topic-preview,
    .app.sidebar-collapsed .topic-runtime,
    .app.sidebar-collapsed .wait-badge,
    .app.sidebar-collapsed .badge {
      display: none;
    }
    .app.sidebar-collapsed .title h1 {
      display: none;
    }
    .app.sidebar-collapsed #refreshBtn {
      display: inline-grid;
      place-items: center;
      width: 30px;
      min-width: 30px;
      padding: 0;
      color: #fff;
      border-color: rgba(255,255,255,.45);
      background: rgba(237, 242, 240, .08);
    }
    .app.sidebar-collapsed .side-scroll {
      padding: 5px 6px 8px;
    }
    .collapsed-quota-bar {
      display: none;
    }
    .app.sidebar-collapsed .collapsed-quota-bar {
      display: none;
      gap: 4px;
      padding: 0 6px 7px;
      border-bottom: 1px solid rgba(45, 58, 63, .7);
    }
    .quota-compact-line {
      display: flex;
      align-items: center;
      gap: 4px;
      min-width: 0;
      height: 19px;
      padding: 0 5px;
      border: 1px solid rgba(237, 242, 240, .14);
      border-radius: 5px;
      background: rgba(237, 242, 240, .045);
      color: var(--text);
      font-size: 11px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .quota-compact-line.warn {
      border-color: rgba(216, 170, 58, .55);
      background: rgba(216, 170, 58, .1);
    }
    .quota-compact-line.danger {
      border-color: rgba(255, 90, 79, .68);
      background: rgba(216, 61, 53, .18);
    }
    .quota-compact-line.muted { opacity: .58; }
    .quota-compact-id {
      flex: 0 0 auto;
      min-width: 22px;
      height: 14px;
      display: inline-grid;
      place-items: center;
      border-radius: 999px;
      color: #071113;
      background: #edf2f0;
      font-size: 9px;
      font-weight: 900;
    }
    .quota-compact-sub {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      color: var(--muted);
    }
    .app.sidebar-collapsed .topic {
      display: grid;
      grid-template-columns: 28px minmax(0, 1fr);
      gap: 6px;
      align-items: center;
      min-height: 0;
      padding: 8px 7px;
      margin-bottom: 4px;
      border-color: rgba(237, 242, 240, .08);
      background: rgba(237, 242, 240, .025);
    }
    .app.sidebar-collapsed .avatar {
      width: 28px;
      height: 28px;
      font-size: 15px;
      border-radius: 6px;
    }
    .app.sidebar-collapsed .avatar-num {
      right: -4px;
      bottom: -4px;
      min-width: 13px;
      height: 13px;
      font-size: 7.5px;
    }
    .app.sidebar-collapsed .topic.active {
      border-color: var(--accent-2);
      background: #233333;
    }
    .topic-collapsed-card,
    .topic-collapsed-title,
    .topic-collapsed-preview {
      display: none;
    }
    .app.sidebar-collapsed .topic-collapsed-card {
      display: grid;
      gap: 3px;
      min-width: 0;
    }
    .topic-collapsed-head {
      display: flex;
      align-items: center;
      gap: 5px;
      min-width: 0;
    }
    .topic-collapsed-status {
      flex: 0 0 auto;
      display: inline-grid;
      place-items: center;
      line-height: 1;
    }
    .topic-collapsed-dot {
      position: relative;
      width: 9px;
      height: 9px;
      border-radius: 999px;
      border: 1px solid #101618;
      box-shadow: 0 0 0 1px rgba(0,0,0,.18);
    }
    .topic-collapsed-dot::after {
      content: "";
      position: absolute;
      inset: -5px;
      border-radius: 999px;
      border: 1px solid currentColor;
      opacity: .28;
      animation: waitPulse 2.2s ease-in-out infinite;
      pointer-events: none;
    }
    .topic-collapsed-dot.idle {
      background: #2f8cff;
      border-color: #081a28;
      color: #2f8cff;
      box-shadow: 0 0 0 1px rgba(47,140,255,.46), 0 0 10px rgba(47,140,255,.42);
    }
    .topic-collapsed-dot.ok {
      background: #58bf7a;
      color: #58bf7a;
      box-shadow: 0 0 0 1px rgba(88,191,122,.42), 0 0 10px rgba(88,191,122,.34);
    }
    .topic-collapsed-dot.quiet {
      background: #d8e2df;
      border-color: #344044;
      color: #d8e2df;
      box-shadow: 0 0 0 1px rgba(216,226,223,.34), 0 0 8px rgba(216,226,223,.22);
    }
    .topic-collapsed-dot.warn {
      background: #d8aa3a;
      color: #d8aa3a;
      box-shadow: 0 0 0 1px rgba(216,170,58,.44), 0 0 10px rgba(216,170,58,.34);
    }
    .topic-collapsed-dot.danger {
      background: #d76d5c;
      color: #d76d5c;
      box-shadow: 0 0 0 1px rgba(215,109,92,.48), 0 0 12px rgba(215,109,92,.42);
    }
    .topic-collapsed-dot.capacity {
      width: 14px;
      height: 14px;
      border-radius: 4px;
      border-color: rgba(255, 176, 170, .78);
      background: #ff5a4f;
      color: #2a0705;
      font-size: 10px;
      font-weight: 950;
      box-shadow: 0 0 0 1px rgba(255,90,79,.46), 0 0 12px rgba(255,90,79,.34);
    }
    .topic-collapsed-dot.capacity::before {
      content: "!";
    }
    .topic-collapsed-dot.capacity::after {
      display: none;
    }
    .topic-collapsed-badge {
      min-width: 18px;
      height: 18px;
      padding: 0 5px;
      display: inline-grid;
      place-items: center;
      border-radius: 999px;
      color: #062018;
      background: var(--accent);
      font-size: 10px;
      font-weight: 900;
      font-variant-numeric: tabular-nums;
    }
    .app.sidebar-collapsed .topic-collapsed-title {
      display: block;
      color: var(--text);
      font-size: 12px;
      font-weight: 800;
      line-height: 1.25;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .app.sidebar-collapsed .topic-collapsed-preview {
      display: block;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.25;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .app.sidebar-collapsed .topic-main,
    .app.sidebar-collapsed .topic-top,
    .app.sidebar-collapsed .topic-name-row {
      display: block;
      min-width: 0;
    }
    .title h1 {
      font-size: 18px;
      margin: 0;
      font-weight: 700;
    }
    .status {
      font-size: 12px;
      color: var(--muted);
      min-height: 18px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding: 5px 11px;
      margin: 4px 0 8px;
      box-sizing: border-box;
      background: rgba(237, 242, 240, .05);
      border: 1px solid rgba(237, 242, 240, .12);
      border-radius: 999px;
    }
    .side-head .quota-bar {
      margin-top: 8px;
    }
    .side-scroll > .workspace-panel,
    .side-scroll > .workspace-note {
      display: none;
    }
    .workspace-panel {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin: 0 0 6px;
      padding: 9px;
      border: 1px solid rgba(45, 58, 63, .78);
      border-radius: 6px;
      background: linear-gradient(180deg, #121a1d, #0f1719);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
    }
    .workspace-toggle {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      width: 100%; padding: 2px 8px; margin: 0;
      border: none; background: transparent;
      color: var(--muted); font: inherit; font-size: 11px; font-weight: 800;
      letter-spacing: .05em; cursor: pointer; user-select: none;
    }
    .workspace-toggle:hover { color: var(--text); }
    .workspace-body { display: flex; flex-direction: column; gap: 8px; }
    .workspace-toggle .ws-chevron { font-size: 0.9em; transition: transform .15s ease; }
    .workspace-panel.ws-collapsed { gap: 0; padding: 3px 9px; }
    .workspace-panel.ws-collapsed .workspace-body { display: none; }
    .workspace-panel.ws-collapsed .ws-chevron { transform: rotate(-90deg); }
    .workspace-group {
      display: grid;
      gap: 6px;
    }
    .workspace-launch {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .workspace-tools {
      padding-top: 7px;
      border-top: 1px solid rgba(45, 58, 63, .65);
      display: grid;
      gap: 6px;
    }
    .workspace-state {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .workspace-layout {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .workspace-custom {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: center;
    }
    .workspace-label {
      font-size: 10.5px;
      font-weight: 700;
      color: var(--muted);
      letter-spacing: .04em;
      margin: 2px 0 1px;
      text-align: center;
    }
    .workspace-fill-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 8px; margin: 0 0 5px; padding-bottom: 6px;
      border-bottom: 1px solid rgba(45, 58, 63, .55);
    }
    .fill-select {
      appearance: none; -webkit-appearance: none;
      width: 100%; height: 30px;
      border: 1px solid rgba(52, 67, 72, .86);
      border-radius: 6px;
      background-color: #141d20;
      color: #c5d0cd;
      font: inherit; font-size: 12px; font-weight: 750;
      text-align: center; text-align-last: center;
      padding: 0 10px;
      cursor: pointer;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23c5d0cd'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: 68% center;
      background-size: 8px 5px;
    }
    .layout-grid-input {
      width: 100%;
      height: 30px;
      border: 1px solid rgba(52, 67, 72, .86);
      border-radius: 6px;
      background: #141d20;
      color: #c5d0cd;
      font: inherit;
      font-size: 12px;
      font-weight: 750;
      text-align: center;
      padding: 0 6px;
    }
    .layout-menu {
      display: grid;
      gap: 6px;
      padding: 7px;
      border: 1px solid rgba(52, 67, 72, .86);
      border-radius: 6px;
      background: #101719;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    }
    .layout-menu.hidden,
    .layout-custom-body.hidden {
      display: none;
    }
    .layout-menu-head {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 30px;
      align-items: center;
      gap: 6px;
    }
    .layout-menu-title {
      color: #c5d0cd;
      font-size: 11px;
      font-weight: 800;
      text-align: center;
    }
    .layout-close {
      height: 28px;
      padding: 0;
    }
    .layout-custom-body {
      display: grid;
      gap: 6px;
    }
    .workspace-panel .icon-btn {
      min-width: 0;
      width: 100%;
      height: 30px;
      padding: 0 8px;
      font-size: 11px;
      font-weight: 750;
      line-height: 1;
      white-space: nowrap;
    }
    .workspace-launch .icon-btn {
      height: 36px;
      font-size: 12px;
      letter-spacing: 0;
    }
    .workspace-panel .workspace-primary {
      border-color: rgba(111, 213, 183, .62);
      background: #183d35;
      color: #effffb;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    }
    .workspace-panel .workspace-quiet {
      border-color: rgba(52, 67, 72, .86);
      background: #141d20;
      color: #c5d0cd;
    }
    .workspace-panel .workspace-quiet:hover,
    .workspace-panel .workspace-primary:hover {
      transform: translateY(-1px);
    }
    .workspace-panel .workspace-state .icon-btn {
      height: 28px;
    }
    .workspace-note {
      margin: 6px 1px 8px;
      min-height: 16px;
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .workspace-note.error { color: var(--danger); }
    .icon-btn {
      border: 1px solid var(--line);
      color: var(--text);
      background: linear-gradient(180deg, #233034, #1b2529);
      height: 30px;
      min-width: 34px;
      padding: 0 10px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 12px;
      font-weight: 750;
      white-space: nowrap;
      transition: border-color .14s ease, background .14s ease, color .14s ease, opacity .14s ease, transform .08s ease;
    }
    .icon-btn:hover:not(:disabled) {
      border-color: var(--accent);
      background: #26383c;
    }
    .icon-btn:active:not(:disabled) { transform: translateY(1px); }
    .icon-btn:disabled {
      opacity: .38;
      cursor: default;
    }
    .search {
      display: none;  /* 隐藏顶部"搜索主题/窗口"框（用户要求去掉；topic 就那几个 slot，不需要搜索）。DOM 留着保证 $("search") JS 不报错，q 恒为空=显示全部 */
      width: 100%;
      height: 36px;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 0 10px;
      color: var(--text);
      background: #101618;
      outline: none;
    }
    .side-scroll {
      overflow: auto;
      min-height: 0;
      flex: 1 1 auto;
      padding: 8px;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: transparent transparent;
      scrollbar-gutter: stable;
    }
    .messages,
    .download-list,
    .terminal-live-text,
    .msg-body pre {
      scrollbar-width: thin;
      scrollbar-color: transparent transparent;
      scrollbar-gutter: stable;
    }
    .side-scroll:hover,
    .messages:hover,
    .download-list:hover,
    .terminal-live-text:hover,
    .msg-body pre:hover {
      scrollbar-width: thin;
      scrollbar-color: rgba(237, 242, 240, .35) transparent;
    }
    .side-scroll::-webkit-scrollbar,
    .messages::-webkit-scrollbar,
    .download-list::-webkit-scrollbar,
    .terminal-live-text::-webkit-scrollbar,
    .msg-body pre::-webkit-scrollbar { width: 8px; height: 8px; }
    .side-scroll:hover::-webkit-scrollbar,
    .messages:hover::-webkit-scrollbar,
    .download-list:hover::-webkit-scrollbar,
    .terminal-live-text:hover::-webkit-scrollbar,
    .msg-body pre:hover::-webkit-scrollbar { width: 8px; height: 8px; }
    .side-scroll::-webkit-scrollbar-thumb,
    .messages::-webkit-scrollbar-thumb,
    .download-list::-webkit-scrollbar-thumb,
    .terminal-live-text::-webkit-scrollbar-thumb,
    .msg-body pre::-webkit-scrollbar-thumb {
      background: transparent;
      border-radius: 999px;
    }
    .side-scroll:hover::-webkit-scrollbar-thumb,
    .messages:hover::-webkit-scrollbar-thumb,
    .download-list:hover::-webkit-scrollbar-thumb,
    .terminal-live-text:hover::-webkit-scrollbar-thumb,
    .msg-body pre:hover::-webkit-scrollbar-thumb {
      background: rgba(237, 242, 240, .28);
      border-radius: 999px;
    }
    .topics {
      min-height: 0;
    }
    .topic {
      width: 100%;
      position: relative;
      display: grid;
      grid-template-columns: 34px 1fr auto;
      gap: 8px;
      align-items: center;
      border: 1px solid transparent;
      border-radius: 6px;
      padding: 9px 10px;
      color: inherit;
      background: transparent;
      text-align: left;
      cursor: pointer;
      min-height: 66px;
      will-change: transform;
    }
    .topic:hover { background: #202b2f; }
    .topic.active {
      background: #233333;
      border-color: var(--accent-2);
    }
    .topic.pinned {
      border-color: rgba(119, 199, 177, .32);
    }
    .topic.temp-idle {
      opacity: .84;
      background: rgba(237, 242, 240, .025);
    }
    .topic.dragging {
      opacity: .45;
      transform: scale(.99);
    }
    .topic.drag-over {
      border-color: rgba(47, 140, 255, .72);
      background: rgba(47, 140, 255, .08);
    }
    .mobile-order-controls {
      display: none;
      align-items: center;
      justify-content: center;
    }
    .mobile-order-toggle {
      display: none;
      color: #fff;
      font-size: 15px;
      font-weight: 900;
    }
    .mobile-order-toggle.active {
      border-color: rgba(255, 255, 255, .58);
      background: rgba(237, 242, 240, .10);
      color: #fff;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
    }
    .topic-order-handle {
      width: 32px;
      height: 32px;
      display: inline-grid;
      place-items: center;
      border: 1px solid rgba(237, 242, 240, .22);
      border-radius: 6px;
      background: rgba(237, 242, 240, .055);
      color: var(--text);
      font-size: 20px;
      font-weight: 900;
      line-height: 1;
      letter-spacing: -2px;
      cursor: grab;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
    }
    .topic-order-handle:active,
    .topic.mobile-order-armed .topic-order-handle {
      cursor: grabbing;
      transform: translateY(1px);
      background: rgba(119, 199, 177, .18);
      border-color: rgba(119, 199, 177, .62);
    }
    .topic.multi-selected {
      border-color: rgba(119, 199, 177, .78);
      background: rgba(119, 199, 177, .10);
      box-shadow: inset 3px 0 0 rgba(119, 199, 177, .9);
    }
    .topic.closing {
      opacity: .58;
      border-color: rgba(216,170,58,.44);
    }
    .avatar {
      position: relative;
      height: 32px;
      width: 32px;
      border-radius: 6px;
      display: grid;
      place-items: center;
      color: #06120f;
      background: var(--accent);
      font-size: 18px;
      font-weight: 800;
      line-height: 1;
      overflow: visible;
    }
    .avatar.cx {
      color: #effffb;
      background: #1f614f;
      border: 1px solid rgba(119, 199, 177, .46);
    }
    .avatar.cc {
      color: #e9f5ff;
      background: #245078;
      border: 1px solid rgba(135, 190, 233, .45);
    }
    .avatar.glm {
      color: #fff4c2;
      background: #7a4f08;
      border: 1px solid rgba(231, 188, 85, .52);
    }
    .avatar.mac,
    .avatar.local {
      color: #f1e9ff;
      background: #4a3a73;
      border: 1px solid rgba(184, 158, 230, .45);
    }
    .avatar.term {
      color: #d8e2df;
      background: #2f3d42;
      border: 1px solid rgba(216, 226, 223, .22);
    }
    .avatar-icon {
      display: inline-grid;
      place-items: center;
      line-height: 1;
      transform: translateY(1px);
    }
    .avatar-num {
      position: absolute;
      right: -5px;
      bottom: -5px;
      min-width: 15px;
      height: 15px;
      padding: 0 3px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #101618;
      border-radius: 999px;
      background: #edf2f0;
      color: #071113;
      font-size: 8.5px;
      font-weight: 900;
      line-height: 1;
      font-variant-numeric: tabular-nums;
      box-shadow: 0 0 0 1px rgba(0,0,0,.18);
    }
    .avatar.idle {
      color: var(--muted);
      background: #2b363a;
    }
    .avatar.idle .avatar-num {
      color: #edf2f0;
      background: #58676b;
    }
    .topic.unbound .avatar {
      color: #241900;
      background: #d8aa3a;
    }
    .topic.unbound .avatar.glm {
      color: #fff4c2;
      background: #7a4f08;
    }
    .topic.unbound .avatar-num {
      color: #241900;
      background: #fff1b6;
    }
    .topic-status {
      display: inline-flex;
      align-items: center;
      height: 18px;
      padding: 0 5px;
      border-radius: 4px;
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0;
      text-transform: uppercase;
      white-space: nowrap;
    }
    .topic-status.unbound {
      color: #241900;
      background: #d8aa3a;
    }
    .topic-status.capacity {
      color: #2a0705;
      background: #ff7c6b;
    }
    .section-label {
      padding: 2px 10px 6px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0;
    }
    .section-label.topic-drop-target {
      box-sizing: border-box;
      width: calc(100% - 8px);
      max-width: none;
      margin: 6px 4px 6px;
      padding: 5px 10px;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 6px;
      background: rgba(237, 242, 240, .035);
      cursor: grab;
    }
    .section-label.topic-drop-target.drag-over {
      color: var(--text);
      border-color: rgba(47, 140, 255, .75);
      background: rgba(47, 140, 255, .10);
    }
    .section-label.topic-drop-target.closed.drag-over {
      border-color: rgba(255, 90, 79, .75);
      background: rgba(216, 61, 53, .14);
    }
    .section-label.collapsible {
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      user-select: none;
      -webkit-user-select: none;
    }
    .section-label.collapsible:hover { color: var(--text); }
    .section-label.collapsible .sec-chevron {
      display: inline-block;
      font-size: 0.9em;
      opacity: 0.7;
      transition: transform 0.15s ease;
    }
    .section-label.collapsible.open .sec-chevron { transform: rotate(90deg); }
    .topic-main { min-width: 0; }
    .topic-top {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: baseline;
      min-width: 0;
    }
    .topic-name-row {
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .topic-preview {
      margin-top: 3px;
      color: var(--muted);
      font-size: 0.88em;
      line-height: 1.35;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      word-break: break-word;
    }
    .topic-runtime {
      margin-top: 3px;
      min-width: 0;
      color: rgba(216, 226, 223, .72);
      font-size: 0.78em;
      font-weight: 800;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      letter-spacing: 0;
    }
    .topic-runtime.working {
      color: #77c7b1;
    }
    /* Sub-agent tail after "Your turn": green = still working in this UI. */
    .topic-runtime .topic-runtime-sub {
      color: #77c7b1;
    }
    .topic-runtime.waiting,
    .topic-runtime.wait-model {
      color: rgba(225, 212, 174, .74);
    }
    .topic-runtime.wait-user {
      color: #8ab4ff;
    }
    .topic-runtime.session-start {
      color: #c7a8ff;
    }
    .topic-runtime.capacity {
      color: #ffb0aa;
    }
    .topic-runtime.error {
      color: #ff8f88;
    }
    .topic-runtime.idle,
    .topic-runtime.unknown {
      color: rgba(174, 188, 184, .68);
    }
    .topic-name {
      min-width: 0;
      flex: 1 1 auto;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topic-kind {
      flex: 0 0 auto;
      height: 16px;
      width: 24px;
      padding: 0 4px;
      display: inline-grid;
      place-items: center;
      border-radius: 4px;
      font-size: 9.5px;
      font-weight: 900;
      line-height: 1;
      letter-spacing: 0;
    }
    .topic-animal {
      flex: 0 0 auto;
      font-size: 13px;
      line-height: 1;
    }
    .topic-aititle {
      flex: 0 1 auto;
      min-width: 0;
      max-width: none;
      font-size: 0.95em;
      font-weight: 700;
      line-height: 1;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topic-kind.cc {
      color: #e9f5ff;
      background: #245078;
      border: 1px solid rgba(135, 190, 233, .45);
    }
    .topic-kind.cx {
      color: #effffb;
      background: #1f614f;
      border: 1px solid rgba(119, 199, 177, .46);
    }
    .topic-kind.mac {
      width: auto;
      padding: 0 6px;
      color: #f1e9ff;
      background: #4a3a73;
      border: 1px solid rgba(180, 160, 230, .45);
    }
    .pending-files {
      display: none;
      grid-column: 1 / -1;   /* span the whole composer width, sit above the input */
      gap: 8px;
      flex-wrap: wrap;
      padding: 0 0 2px;
    }
    .pending-files.show { display: flex; }
    .composer-status {
      display: none;
      grid-column: 1 / -1;
      min-height: 20px;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 0 2px 1px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.2;
      overflow: hidden;
    }
    .composer-status.show { display: flex; }
    .quick-phrases {
      order: 18;
      position: relative;
      flex: 0 0 auto;
      display: inline-flex;
      align-items: center;
      min-width: 0;
    }
    .quick-phrase-toggle,
    .quick-phrase-add,
    .quick-phrase-save,
    .quick-phrase-edit,
    .quick-phrase-delete {
      border: 1px solid rgba(237, 242, 240, .26);
      border-radius: 6px;
      color: #d9e5e2;
      background: rgba(237, 242, 240, .06);
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      cursor: pointer;
      white-space: nowrap;
      letter-spacing: 0;
    }
    .quick-phrase-toggle {
      flex: 0 0 auto;
      width: 25px;
      height: 25px;
      min-width: 25px;
      padding: 0;
    }
    .quick-phrase-chips {
      grid-column: 1 / -1;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      min-width: 0;
      max-height: 82px;
      overflow: auto;
    }
    .quick-phrase-item {
      max-width: 100%;
      height: 28px;
      display: inline-flex;
      align-items: center;
      border: 1px solid rgba(237, 242, 240, .14);
      border-radius: 999px;
      background: rgba(237, 242, 240, .06);
      overflow: hidden;
    }
    .quick-phrase-chip {
      flex: 1 1 auto;
      min-width: 0;
      max-width: 220px;
      height: 28px;
      padding: 0 9px;
      border: 0;
      border-radius: 0;
      color: #d9e5e2;
      background: transparent;
      font-size: 12px;
      line-height: 1;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .quick-phrase-edit,
    .quick-phrase-delete {
      flex: 0 0 auto;
      width: 28px;
      height: 28px;
      min-width: 28px;
      padding: 0;
      border: 0;
      border-left: 1px solid rgba(237, 242, 240, .12);
      border-radius: 0;
      color: #f0bbb6;
      background: transparent;
      font-size: 13px;
      line-height: 1;
      cursor: pointer;
    }
    .quick-phrase-edit {
      color: #8ab4ff;
    }
    .quick-phrase-item.editing {
      border-color: var(--accent);
      background: rgba(119, 199, 177, .12);
    }
    .quick-phrase-toggle:hover,
    .quick-phrase-toggle:focus-visible,
    .quick-phrase-add:hover,
    .quick-phrase-add:focus-visible,
    .quick-phrase-save:hover,
    .quick-phrase-save:focus-visible,
    .quick-phrase-item:hover,
    .quick-phrase-item:focus-within {
      border-color: var(--accent-2);
      outline: none;
    }
    .quick-phrase-delete:hover,
    .quick-phrase-delete:focus-visible {
      color: #fff;
      background: rgba(216, 61, 53, .45);
      outline: none;
    }
    .quick-phrase-edit:hover,
    .quick-phrase-edit:focus-visible {
      color: #fff;
      background: rgba(138, 180, 255, .32);
      outline: none;
    }
    .quick-phrase-toggle.active {
      color: #06120f;
      border-color: var(--accent);
      background: var(--accent);
    }
    .quick-phrase-panel {
      display: none;
      position: absolute;
      top: calc(100% + 8px);
      right: 0;
      width: min(320px, calc(100vw - 24px));
      grid-template-columns: minmax(0, 1fr);
      gap: 6px;
      align-items: stretch;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      box-shadow: 0 12px 30px rgba(0, 0, 0, .42);
      z-index: 35;
    }
    .quick-phrases.open .quick-phrase-panel { display: grid; }
    .quick-phrase-panel textarea {
      grid-column: 1 / -1;
      min-height: 34px;
      max-height: 34px;
      resize: none;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 7px 12px;
      color: var(--text);
      background: #101618;
      outline: none;
      overflow: hidden;
      white-space: nowrap;
    }
    .quick-phrase-panel textarea:focus {
      border-color: var(--accent-2);
    }
    .quick-phrase-actions {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 5px;
      align-self: stretch;
    }
    .quick-phrase-add,
    .quick-phrase-save {
      height: 30px;
      min-width: 58px;
      padding: 0 9px;
    }
    .composer-terminal-status {
      min-width: 0;
      flex: 1 1 auto;
      display: none;
      align-items: center;
      gap: 6px;
      max-width: 100%;
      border: 0;
      padding: 0;
      color: inherit;
      background: transparent;
      cursor: pointer;
      text-align: left;
      overflow: hidden;
    }
    .composer-terminal-status.show { display: inline-flex; }
    .composer-working {
      flex: 0 0 auto;
      color: var(--accent);
      font-weight: 900;
      white-space: nowrap;
    }
    .composer-terminal-status.is-working .composer-working {
      color: var(--accent);
    }
    .composer-terminal-status.is-idle .composer-working {
      color: #8ab4ff;
      opacity: 1;
    }
    .composer-terminal-status.is-error .composer-working {
      color: #ff8f88;
      opacity: 1;
    }
    .composer-status-segment {
      min-width: 0;
      flex: 0 0 auto;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .composer-status-segment.is-extra {
      flex: 0 1 auto;
    }
    .composer-status-sep {
      flex: 0 0 auto;
      color: #767676;
      font-weight: 650;
    }
    .composer-preview {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .composer-meter {
      flex: 0 0 auto;
      color: var(--text);
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .composer-model {
      flex: 0 0 auto;
      color: var(--bright);
      font-weight: 850;
      white-space: nowrap;
    }
    .composer-context {
      flex: 0 0 auto;
      color: var(--text);
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .composer-status-extra {
      min-width: 0;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    /* Mirror the actual terminal status-line palettes.
       CC: ~/.config/ccstatusline/settings.json
       CX: live ANSI colors from the Codex footer. */
    .composer-terminal-status.kind-cc .composer-model,
    .composer-terminal-status.kind-cc .composer-status-extra {
      color: #ffaa90;
    }
    .composer-terminal-status.kind-cc .composer-context {
      color: #ffb8d0;
    }
    .composer-terminal-status.kind-cx .composer-model,
    .composer-terminal-status.kind-cx .composer-status-extra.extra-2 {
      color: #f6e2b7;
    }
    .composer-terminal-status.kind-cx .composer-context {
      color: #f2b590;
    }
    .composer-terminal-status.kind-cx .composer-status-extra.extra-1 {
      color: #c8a9ee;
    }
    .composer-quota {
      flex: 0 0 auto;
      display: none;
      align-items: center;
      gap: 5px;
      color: var(--text);
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .composer-quota.show { display: inline-flex; }
    .composer-quota .model {
      color: #071113;
      background: var(--accent);
      border-radius: 999px;
      padding: 1px 6px;
      font-size: 10px;
      line-height: 1.25;
    }
    .composer-quota.warn .model { background: #d8aa3a; }
    .composer-quota.danger .model { background: var(--danger); color: #fff; }
    .composer-quota.muted {
      color: var(--muted);
      opacity: .68;
    }
    .composer-quota.muted .model {
      color: #071113;
      background: #9aa5a2;
    }
    .pending-chip {
      display: flex;
      align-items: center;
      gap: 6px;
      max-width: 220px;
      padding: 4px 6px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
    }
    .pending-thumb {
      width: 36px;
      height: 36px;
      object-fit: cover;
      border-radius: 5px;
      flex: 0 0 auto;
    }
    .pending-name {
      font-size: 12px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .pending-x {
      flex: 0 0 auto;
      border: none;
      background: transparent;
      color: var(--muted);
      font-size: 17px;
      line-height: 1;
      cursor: pointer;
      padding: 0 2px;
    }
    .pending-x:hover { color: var(--text); }
    .topic-time {
      width: 42px;
      text-align: right;
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
    }
    .topic-sub {
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topic-meta {
      color: #6f7f7c;
      font-size: 11px;
      margin-top: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .pin-mark {
      color: var(--accent);
      font-size: 10px;
      font-weight: 900;
      margin-right: 4px;
    }
    .badge {
      min-width: 20px;
      height: 20px;
      padding: 0 6px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      background: var(--accent);
      color: #06120f;
      font-size: 12px;
      font-weight: 800;
    }
    .wait-badge {
      position: absolute;
      top: 7px;
      right: 7px;
      width: 9px;
      height: 9px;
      border-radius: 999px;
      border: 1px solid #101618;
      box-shadow: 0 0 0 1px rgba(0,0,0,.18);
    }
    .wait-badge::after {
      content: "";
      position: absolute;
      inset: -5px;
      border-radius: 999px;
      border: 1px solid currentColor;
      opacity: .28;
      animation: waitPulse 2.2s ease-in-out infinite;
      pointer-events: none;
    }
    .wait-badge.idle {
      background: #2f8cff;
      border-color: #081a28;
      color: #2f8cff;
      box-shadow: 0 0 0 1px rgba(47,140,255,.46), 0 0 10px rgba(47,140,255,.42);
    }
    .wait-badge.ok {
      background: #58bf7a;
      color: #58bf7a;
      box-shadow: 0 0 0 1px rgba(88,191,122,.42), 0 0 10px rgba(88,191,122,.34);
    }
    .wait-badge.quiet {
      background: #d8e2df;
      border-color: #344044;
      color: #d8e2df;
      box-shadow: 0 0 0 1px rgba(216,226,223,.34), 0 0 8px rgba(216,226,223,.22);
    }
    .wait-badge.warn {
      background: #d8aa3a;
      color: #d8aa3a;
      box-shadow: 0 0 0 1px rgba(216,170,58,.44), 0 0 10px rgba(216,170,58,.34);
    }
    .wait-badge.danger {
      background: #d76d5c;
      color: #d76d5c;
      box-shadow: 0 0 0 1px rgba(215,109,92,.48), 0 0 12px rgba(215,109,92,.42);
    }
    .wait-badge.capacity {
      top: 4px;
      right: 4px;
      width: 16px;
      height: 16px;
      display: grid;
      place-items: center;
      border-radius: 5px;
      border-color: rgba(255, 176, 170, .78);
      background: #ff5a4f;
      color: #2a0705;
      font-size: 11px;
      font-weight: 950;
      line-height: 1;
      box-shadow: 0 0 0 1px rgba(255,90,79,.56), 0 0 13px rgba(255,90,79,.48);
    }
    .wait-badge.capacity::before {
      content: "!";
    }
    .wait-badge.capacity::after {
      display: none;
    }

    @keyframes waitPulse {
      0%, 100% { transform: scale(.78); opacity: .18; }
      50% { transform: scale(1.18); opacity: .42; }
    }
    @media (prefers-reduced-motion: reduce) {
      .wait-badge::after { animation: none; }
    }
    .chat {
      grid-column: 2;
      grid-row: 1;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto minmax(0, 1fr) auto;
      min-width: 0;
      min-height: 0;
      background: #101618;
      position: relative;
    }
    .chat.tool-panel-open {
      grid-template-columns: minmax(0, 1fr) minmax(280px, var(--terminal-panel-width, 380px));
    }
    .chat-head {
      grid-column: 1 / -1;
      grid-row: 1;
      padding: 13px 18px;
      border-bottom: 1px solid var(--line);
      background: var(--panel);
      display: flex;
      justify-content: space-between;
      gap: 14px;
      align-items: center;
      position: relative;
    }
    /* In the native app shell the OS insets are applied natively (MainActivity), so the
       header must NOT also add env(safe-area-inset-top): that double-counted the status
       bar and left a big empty gap above the title. Keep just a small breathing space. */
    .app-shell .chat-head { padding-top: 0.3em; }
    .app-shell .side-head { padding-top: 0.5em; }
    .head-avatar {
      flex: 0 0 auto;
      font-size: 1.28em;
      line-height: 1;
    }
    .head-avatar:empty { display: none; }
    .msg-sent-badge {
      flex: 0 0 auto;
      min-width: 1.2em;
      padding: 1px 7px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.07);
      border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
      color: var(--muted, #9aa7a3);
      font-size: 15px;
      font-weight: 700;
      line-height: 1;
      letter-spacing: 0;
      cursor: default;
      user-select: none;
    }
    .msg-sent-badge.lvl-green {
      background: rgba(95, 191, 138, 0.16);
      border-color: rgba(95, 191, 138, 0.5);
      color: #74c79b;
    }
    .msg-sent-badge.lvl-yellow {
      background: rgba(214, 178, 74, 0.16);
      border-color: rgba(214, 178, 74, 0.5);
      color: #e0c061;
    }
    .msg-sent-badge.lvl-red {
      background: rgba(224, 114, 106, 0.16);
      border-color: rgba(224, 114, 106, 0.55);
      color: #ec8079;
    }
    .title-head-btn {
      flex: 0 0 auto;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      padding: 0;
      border-radius: 6px;
      background: rgba(214, 178, 74, 0.14);
      border: 1px solid rgba(214, 178, 74, 0.42);
      color: #e6b34a;
      cursor: pointer;
      transition: background .15s, border-color .15s, transform .12s;
    }
    .title-head-btn:hover {
      background: rgba(214, 178, 74, 0.26);
      border-color: rgba(214, 178, 74, 0.7);
      transform: translateY(-1px);
    }
    .title-head-btn svg {
      width: 13px;
      height: 13px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .title-panel:not(.manual) .title-sync-term { display: none; }
    .title-autosync {
      display: flex;
      align-items: center;
      gap: 7px;
      margin-top: 6px;
      font-size: 13px;
      color: var(--muted, #9aa7a3);
      cursor: pointer;
      user-select: none;
    }
    .title-autosync input { cursor: pointer; }
    .quickname-overlay {
      position: fixed;
      inset: 0;
      z-index: 4000;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, .55);
      padding: 20px;
    }
    .quickname-overlay.hidden { display: none; }
    .quickname-box {
      width: min(340px, 88vw);
      display: flex;
      flex-direction: column;
      gap: 14px;
      padding: 18px;
      border-radius: 14px;
      background: var(--panel-2, #1e292d);
      border: 1px solid var(--line, #2d3a3f);
      box-shadow: 0 16px 48px rgba(0, 0, 0, .55);
    }
    .quickname-title { font-size: 15px; font-weight: 800; color: var(--text, #edf2f0); }
    .quickname-input {
      width: 100%;
      box-sizing: border-box;
      padding: 11px 13px;
      border-radius: 9px;
      border: 1px solid var(--line, #2d3a3f);
      background: rgba(237, 242, 240, .05);
      color: var(--text, #edf2f0);
      font-size: 16px;
      outline: none;
    }
    .quickname-input:focus { border-color: var(--accent, #77c7b1); }
    .quickname-actions { display: flex; justify-content: flex-end; gap: 10px; }
    .quickname-actions button {
      padding: 9px 18px;
      border-radius: 9px;
      font-size: 13px;
      font-weight: 800;
      cursor: pointer;
      border: 1px solid var(--line, #2d3a3f);
      background: rgba(237, 242, 240, .06);
      color: var(--muted, #94a19f);
    }
    .quickname-actions .quickname-ok {
      color: #06120f;
      background: var(--accent, #77c7b1);
      border-color: var(--accent-2, #4d9d89);
    }
    .chat-title {
      min-width: 0;
      flex: 1 1 auto;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .quota-bar {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-end;
      gap: 5px;
      flex: 0 0 auto;
      min-width: 0;
    }
    .quota-pill {
      height: 30px;
      display: grid;
      grid-template-columns: 34px 4ch 6.4ch 4ch 6.4ch 4ch 6.4ch;
      align-items: center;
      justify-content: flex-start;
      column-gap: 6px;
      padding: 0 7px;
      box-sizing: border-box;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 999px;
      color: var(--text);
      background: rgba(237, 242, 240, .06);
      font-size: 12px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      text-align: left;
      white-space: nowrap;
    }
    .quota-pill .quota-id {
      color: #071113;
      background: #edf2f0;
      border-radius: 999px;
      min-width: 23px;
      height: 16px;
      display: inline-grid;
      place-items: center;
      font-size: 9.5px;
      font-weight: 900;
    }
    .quota-pill .quota-pct {
      width: 4ch;
      text-align: left;
      font-variant-numeric: tabular-nums;
    }
    .quota-pill .quota-sub {
      color: var(--muted);
      font-weight: 750;
      width: 6.4ch;
      text-align: left;
      font-variant-numeric: tabular-nums;
    }
    .quota-pill.warn {
      border-color: rgba(216, 170, 58, .72);
      background: rgba(216, 170, 58, .12);
    }
    .quota-pill.warn .quota-id {
      background: #d8aa3a;
      color: #171005;
    }
    .quota-pill.danger {
      border-color: rgba(255, 90, 79, .82);
      background: rgba(216, 61, 53, .24);
    }
    .quota-pill.danger .quota-id {
      background: #f14b42;
      color: #fff;
    }
    .quota-pill.muted {
      opacity: .58;
    }
    .quota-collapse-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      width: 100%;
      box-sizing: border-box;
      padding: 3px 9px;
      margin: 0;
      border: 1px solid rgba(237, 242, 240, .14);
      border-radius: 999px;
      background: rgba(237, 242, 240, .05);
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    .quota-collapse-btn:hover { background: rgba(237, 242, 240, .1); }
    .quota-collapse-btn .qc-chevron {
      margin-left: auto;
      transition: transform .15s ease;
      font-size: 10px;
    }
    .quota-collapse-btn.collapsed .qc-chevron { transform: rotate(-90deg); }
    .quota-collapse-btn .quota-alert-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #f14b42;
      display: none;
      flex: 0 0 auto;
      box-shadow: 0 0 0 2px rgba(241, 75, 66, .28);
    }
    .quota-collapse-btn.collapsed .quota-alert-dot.on { display: inline-block; }
    .quota-balance-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 5px;
    }
    .quota-pill.balance {
      grid-template-columns: 34px minmax(0, 1fr);
      column-gap: 6px;
      height: 30px;
    }
    .quota-pill.balance .quota-bal {
      text-align: center;
      font-variant-numeric: tabular-nums;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    /* Multi-account balance pill (e.g. DeepSeek deepseek/deepseek2/…): spans the
       full width of the 2-col balance grid and lays its N number blocks out with
       flex, up to 5 per row then wrapping, font auto-shrinking as accounts grow. */
    .quota-pill.balance.multi {
      grid-column: 1 / -1;
      grid-template-columns: 34px minmax(0, 1fr);
      height: auto;
      min-height: 30px;
      padding-top: 3px;
      padding-bottom: 3px;
      align-items: center;
    }
    /* Multi-account balances are value-only blocks. Keep equal flexible slots
       with a real gap; the old amount+serial grid becomes cramped when the
       serials are hidden. A 4th/5th account wraps to the next row. */
    .quota-pill.balance .quota-bal-multi {
      display: flex;
      flex: 1 1 auto;
      flex-wrap: wrap;
      justify-content: space-between;
      column-gap: 10px;
      row-gap: 3px;
      align-items: center;
      min-width: 0;
    }
    .quota-pill.balance .quota-bal-multi .quota-bal {
      flex: 1 1 0;
      min-width: 0;
      width: auto;
      text-align: center;
      font-variant-numeric: tabular-nums;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .quota-pill.balance .quota-bal-multi .quota-bal-idx {
      width: 4ch;
      text-align: left;
      color: var(--muted, #8fa3a0);
      font-weight: 750;
      font-variant-numeric: tabular-nums;
    }
    .chat-actions {
      display: none;
      position: absolute;
      order: 10;
      flex: 0 0 auto;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: center;
      gap: 4px;
      top: 50%;
      right: 170px;
      transform: translateY(-50%);
      z-index: 95;
      padding: 3px 5px;
      width: max-content;
      max-width: min(560px, calc(100vw - 2em - 170px));
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 7px;
      box-shadow: 0 8px 24px rgba(0,0,0,.5);
    }
    .app.actions-open .chat-actions { display: flex; }
    .chat-actions .icon-btn {
      width: 23px;
      height: 23px;
      min-width: 23px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      color: #edf2f0;
      border-color: rgba(237, 242, 240, .36);
      background: rgba(237, 242, 240, .07);
      font-size: 12px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    }
    .chat-actions .icon-btn.font-step-btn {
      width: 32px;
      min-width: 32px;
      font-size: 11px;
      font-weight: 850;
      letter-spacing: 0;
    }
    .chat-actions .icon-btn.mobile-menu-tool { display: none; }
    .chat-actions .tool-gap {
      flex: 0 0 auto;
      width: 1px;
      height: 16px;
      margin: 0 3px;
      background: rgba(237, 242, 240, .22);
      border-radius: 1px;
    }
    .chat-actions .icon-btn svg {
      width: 13px;
      height: 13px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .push-tool {
      position: relative;
    }
    .push-tool svg {
      width: 15px;
      height: 15px;
    }
    .push-tool::after {
      content: "";
      position: absolute;
      top: 3px;
      right: 3px;
      width: 5px;
      height: 5px;
      border-radius: 999px;
      background: #8b9694;
      box-shadow: 0 0 0 1px rgba(16, 22, 24, .95);
    }
    .push-tool.push-enabled::after {
      background: #58bf7a;
    }
    .push-tool.push-loading::after {
      background: #d8aa3a;
    }
    .push-tool.push-unavailable {
      opacity: .58;
    }
    .chat-actions .icon-btn:hover:not(:disabled) {
      color: #ffffff;
      border-color: rgba(255,255,255,.82);
      background: rgba(237, 242, 240, .14);
    }
    .chat-actions .icon-btn.primary {
      color: #06120f;
      border-color: var(--accent-2);
      background: var(--accent);
    }
    .chat-actions .icon-btn.active {
      color: #071113;
      border-color: #ffffff;
      background: #edf2f0;
      box-shadow: 0 0 0 1px rgba(255,255,255,.16), inset 0 1px 0 rgba(255,255,255,.75);
    }
    .chat-actions .icon-btn.danger {
      color: #ffffff;
      border-color: #ff5a4f;
      background: rgba(216, 61, 53, .72);
      box-shadow: 0 0 0 1px rgba(255, 90, 79, .18), inset 0 1px 0 rgba(255,255,255,.18);
    }
    .chat-actions .icon-btn.danger:hover:not(:disabled) {
      color: #ffffff;
      border-color: #ff8a80;
      background: #f14b42;
    }
    .chat-title strong {
      display: block;
      flex: 0 1 auto;
      min-width: 0;
      font-size: 15px;
      line-height: 1.12;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .chat-title > span {
      display: none;
      gap: 1px;
      margin-top: 0;
      color: var(--muted);
      font-size: 10.5px;
      line-height: 1.15;
      white-space: normal;
      overflow: hidden;
      max-height: 1.2em;
    }
    .chat-subline {
      display: block;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .chat-subline:empty {
      display: none;
    }
    .toast-stack {
      position: absolute;
      top: 72px;
      left: 18px;
      right: 18px;
      max-width: calc(100% - 36px);
      /* 60 = 高于本地应用视图(审计台等)所在的聊天区,开着应用也能看见哪个窗口来消息 */
      z-index: 60;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
      /* 卡片超过屏幕就地滚动(不再把多出来的排进看不见的队列):最多占视口高的 45% */
      max-height: 45vh;
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      padding-right: 2px;
    }
    .toast-stack::-webkit-scrollbar { width: 6px; }
    .toast-stack::-webkit-scrollbar-thumb { background: rgba(237,242,240,.22); border-radius: 3px; }
    /* 卡片栈工具条:条数 + 停留时长切换 + 清空 */
    .toast-bar {
      pointer-events: auto;
      position: sticky;
      top: 0;
      z-index: 1;
      align-self: stretch;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 3px 8px;
      border: 1px solid rgba(237,242,240,.18);
      border-radius: 6px;
      background: rgba(24,33,36,.97);
      color: #9aa5a2;
      font-size: 12px;
      line-height: 1.6;
    }
    .toast-bar-count { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .toast-bar-btn {
      flex: 0 0 auto;
      padding: 1px 8px;
      border: 1px solid rgba(237,242,240,.22);
      border-radius: 5px;
      background: rgba(30,41,45,.95);
      color: #9aa5a2;
      font-size: 12px;
      cursor: pointer;
    }
    .toast-bar-btn:hover { color: var(--text); border-color: rgba(237,242,240,.42); }
    .toast-count {
      margin-left: 6px;
      padding: 0 6px;
      border-radius: 999px;
      background: var(--accent);
      color: #06120f;
      font-size: 11px;
      font-weight: 800;
    }
    .toast-clear-all {
      pointer-events: auto;
      align-self: flex-end;
      padding: 3px 11px;
      border: 1px solid rgba(237,242,240,.22);
      border-radius: 6px;
      background: rgba(30,41,45,.95);
      color: #9aa5a2;
      font-size: 12px;
      line-height: 1.6;
      cursor: pointer;
    }
    .toast-clear-all:hover { color: var(--text); border-color: rgba(237,242,240,.4); }
    .toast {
      position: relative;
      pointer-events: auto;
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      min-height: 46px;
      padding: 9px 12px;
      border: 1px solid rgba(237, 242, 240, .26);
      border-radius: 7px;
      color: var(--text);
      background: rgba(30, 41, 45, .98);
      box-shadow: 0 12px 28px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.06);
      cursor: pointer;
      overflow: hidden;
      text-align: left;
    }
    .toast.show {
      display: flex;
    }
    .toast-kind {
      flex: 0 0 auto;
      height: 22px;
      min-width: 30px;
      padding: 0 6px;
      display: inline-grid;
      place-items: center;
      border-radius: 5px;
      color: #06120f;
      background: var(--accent);
      font-size: 11px;
      font-weight: 900;
    }
    .toast-main {
      display: block;
      min-width: 0;
      flex: 1 1 auto;
      overflow: hidden;
    }
    .toast-title {
      display: block;
      font-size: 13px;
      font-weight: 800;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toast-body {
      display: block;
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toast-time {
      display: block;
      flex: 0 0 auto;
      max-width: 72px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toast-x {
      flex: 0 0 auto;
      align-self: center;
      width: 24px;
      height: 24px;
      margin-left: 2px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      color: var(--muted);
      font-size: 15px;
      line-height: 1;
    }
    .toast-x:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
    .copy-toast {
      position: fixed;
      left: 50%;
      bottom: max(78px, calc(env(safe-area-inset-bottom) + 72px));
      z-index: 260;
      max-width: min(280px, calc(100vw - 28px));
      padding: 8px 13px;
      border: 1px solid rgba(119, 199, 177, .52);
      border-radius: 999px;
      background: rgba(20, 34, 35, .96);
      color: var(--text);
      box-shadow: 0 10px 28px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.07);
      font-size: 12px;
      font-weight: 850;
      line-height: 1.2;
      text-align: center;
      pointer-events: none;
      opacity: 0;
      transform: translate(-50%, 8px);
      transition: opacity .12s ease, transform .12s ease;
    }
    .copy-toast.show {
      opacity: 1;
      transform: translate(-50%, 0);
    }
    .copy-toast.error {
      border-color: rgba(255, 90, 79, .58);
      background: rgba(72, 29, 27, .96);
    }
    .file-open-progress {
      position: fixed;
      left: 50%;
      bottom: max(128px, calc(env(safe-area-inset-bottom) + 120px));
      z-index: 270;
      width: min(360px, calc(100vw - 28px));
      padding: 10px 12px 11px;
      border: 1px solid rgba(119, 199, 177, .48);
      border-radius: 8px;
      background: rgba(20, 34, 35, .97);
      color: var(--text);
      box-shadow: 0 18px 40px rgba(0, 0, 0, .34), 0 0 0 1px rgba(255, 255, 255, .03) inset;
      opacity: 0;
      pointer-events: none;
      transform: translate(-50%, 10px);
      transition: opacity .14s ease, transform .14s ease;
    }
    .file-open-progress.show {
      opacity: 1;
      transform: translate(-50%, 0);
    }
    .file-open-progress.error {
      border-color: rgba(255, 90, 79, .62);
      background: rgba(72, 29, 27, .97);
    }
    .file-open-progress.done {
      border-color: rgba(119, 199, 177, .68);
    }
    .file-open-progress.cancelable,
    .file-open-progress.actionable {
      pointer-events: auto;
    }
    .file-open-progress-top {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .file-open-progress-title {
      min-width: 0;
      flex: 1 1 auto;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 13px;
      font-weight: 850;
      letter-spacing: 0;
    }
    .file-open-progress-value {
      flex: 0 0 auto;
      color: rgba(237, 242, 240, .78);
      font-size: 12px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
    }
    .file-open-progress-cancel {
      flex: 0 0 auto;
      min-width: 44px;
      height: 24px;
      border: 1px solid rgba(237, 242, 240, .22);
      border-radius: 6px;
      background: rgba(237, 242, 240, .08);
      color: rgba(237, 242, 240, .86);
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      letter-spacing: 0;
    }
    .file-open-progress-cancel:active {
      background: rgba(237, 242, 240, .16);
    }
    .file-open-progress-cancel[hidden] {
      display: none;
    }
    .file-open-progress-action {
      flex: 0 0 auto;
      min-width: 44px;
      height: 24px;
      border: 1px solid rgba(119, 199, 177, .38);
      border-radius: 6px;
      background: rgba(119, 199, 177, .16);
      color: rgba(237, 242, 240, .92);
      font-size: 12px;
      font-weight: 850;
      line-height: 1;
      letter-spacing: 0;
    }
    .file-open-progress-action:active {
      background: rgba(119, 199, 177, .26);
    }
    .file-open-progress-action[hidden] {
      display: none;
    }
    .file-open-progress-bar {
      height: 4px;
      margin-top: 8px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(237, 242, 240, .13);
    }
    .file-open-progress-bar span {
      display: block;
      width: 0;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, rgba(119, 199, 177, .95), rgba(222, 201, 128, .95));
      transition: width .12s ease;
    }
    .file-open-progress.indeterminate .file-open-progress-bar span {
      animation: file-open-progress-slide 1.1s ease-in-out infinite;
    }
    .file-open-progress.error .file-open-progress-bar span {
      background: rgba(255, 120, 112, .95);
    }
    .file-open-progress-sub {
      margin-top: 6px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: rgba(237, 242, 240, .66);
      font-size: 12px;
      line-height: 1.35;
    }
    @keyframes file-open-progress-slide {
      0% { transform: translateX(-110%); }
      100% { transform: translateX(310%); }
    }
    .terminal-live {
      grid-column: 2;
      grid-row: 2 / 4;
      min-height: 0;
      display: grid;
      grid-template-rows: auto auto auto minmax(0, 1fr);
      border-left: 1px solid var(--line);
      background: rgba(16, 24, 26, .98);
      overflow: hidden;
      position: relative;
    }
    .terminal-live.closed { display: none; }
    .tool-panel-resize-handle,
    .terminal-resize-handle {
      position: absolute;
      top: 0;
      bottom: 0;
      left: -5px;
      width: 10px;
      z-index: 8;
      cursor: col-resize;
      touch-action: none;
    }
    .tool-panel-resize-handle::after,
    .terminal-resize-handle::after {
      content: "";
      position: absolute;
      top: 0;
      bottom: 0;
      left: 4px;
      width: 2px;
      background: transparent;
    }
    .tool-panel-resize-handle:hover::after,
    .tool-panel-resize-handle.active::after,
    .terminal-resize-handle:hover::after,
    .terminal-resize-handle.active::after {
      background: rgba(119, 199, 177, .72);
    }
    body.tool-panel-resizing,
    body.terminal-resizing {
      cursor: col-resize;
      user-select: none;
      -webkit-user-select: none;
    }
    .terminal-live-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 8px 12px;
      border-bottom: 1px solid rgba(255,255,255,.06);
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .terminal-live-status {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1 1 auto;
    }
    .terminal-target-select {
      min-width: 120px;
      max-width: 46%;
      height: 28px;
      padding: 0 24px 0 8px;
      border: 1px solid rgba(255,255,255,.10);
      border-radius: 6px;
      color: #d7e2e4;
      background: #162024;
      font: 600 11px/1.2 var(--sans);
      text-overflow: ellipsis;
    }
    .terminal-target-select:disabled {
      opacity: .55;
    }
    .terminal-font-controls {
      display: inline-flex;
      gap: 4px;
      flex: 0 0 auto;
    }
    .terminal-font-controls .panel-tool-btn {
      font-size: 12px;
      font-weight: 700;
      min-width: 28px;
    }
    /* Live-mode toggle: dim when off (slow mode), lit amber when real-time is on. */
    .terminal-mode-btn { opacity: .45; }
    .terminal-mode-btn.active { opacity: 1; color: #ffd166; }
    .terminal-live-summary {
      padding: 8px 12px;
      border-bottom: 1px solid rgba(255,255,255,.06);
      color: #d7e2e4;
      font-size: 13px;
      font-weight: 700;
      line-height: 1.35;
      background: rgba(119, 199, 177, .08);
    }
    .terminal-live-summary.warn {
      color: #ead38a;
      background: rgba(234, 211, 138, .10);
    }
    .terminal-live-summary.error {
      color: #ff9b9b;
      background: rgba(255, 95, 95, .10);
    }
    .terminal-interaction {
      display: grid;
      gap: 7px;
      padding: 8px 10px;
      border-bottom: 1px solid rgba(255,255,255,.06);
      background: rgba(8, 13, 14, .94);
    }
    .terminal-interaction.has-prompt {
      background: rgba(234, 211, 138, .08);
      box-shadow: inset 3px 0 rgba(234, 211, 138, .65);
    }
    .terminal-interaction-hint {
      min-width: 0;
      color: rgba(215, 226, 228, .72);
      font-size: 11px;
      line-height: 1.35;
    }
    .terminal-interaction-hint.active {
      color: #ead38a;
      font-weight: 700;
    }
    .terminal-quick-keys {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      min-width: 0;
    }
    .terminal-key {
      min-width: 34px;
      height: 29px;
      padding: 0 9px;
      border: 1px solid rgba(119, 199, 177, .22);
      border-radius: 6px;
      color: #d7e2e4;
      background: rgba(119, 199, 177, .08);
      font: 700 11px/1 var(--mono);
      cursor: pointer;
    }
    .terminal-key:hover,
    .terminal-key:focus-visible {
      border-color: rgba(119, 199, 177, .72);
      background: rgba(119, 199, 177, .18);
      outline: none;
    }
    .terminal-key.suggested {
      color: #fff3bd;
      border-color: rgba(234, 211, 138, .72);
      background: rgba(234, 211, 138, .16);
    }
    .terminal-key.danger {
      color: #ffb0b0;
      border-color: rgba(255, 95, 95, .35);
      background: rgba(255, 95, 95, .08);
    }
    .terminal-key:disabled {
      opacity: .45;
      cursor: default;
    }
    .terminal-text-send {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 6px;
    }
    .terminal-text-send input {
      min-width: 0;
      height: 30px;
      padding: 0 9px;
      border: 1px solid rgba(255,255,255,.10);
      border-radius: 6px;
      color: #eef4f2;
      background: #11191c;
      font: 12px/1.2 var(--mono);
    }
    .terminal-text-send button {
      height: 30px;
      padding: 0 12px;
      border: 1px solid rgba(119, 199, 177, .32);
      border-radius: 6px;
      color: #dff8ef;
      background: rgba(119, 199, 177, .13);
      font-weight: 700;
      cursor: pointer;
    }
    .terminal-live-text {
      min-height: 0;
      overflow: auto;
      padding: 10px 12px;
      margin: 0;
      color: #d7e2e4;
      background: #090d0e;
      /* Match the local wezterm terminal font (Maple Mono NF CN); falls back to
         the generic mono stack on devices without it (e.g. phone). */
      font-family: "Maple Mono NF CN", "Maple Mono NF", "Maple Mono", var(--mono);
      font-size: var(--term-font, 12px);
      line-height: 1.38;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      -webkit-overflow-scrolling: touch;
    }
    @media (min-width: 821px) {
      .terminal-live-text {
        white-space: pre;
        overflow-wrap: normal;
        contain: content;
      }
    }
    .messages {
      grid-column: 1;
      grid-row: 2;
      overflow: auto;
      min-height: 0;
      padding: 16px 18px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
    }
    .message-select-bar {
      position: absolute;
      left: 50%;
      bottom: 86px;
      z-index: 18;
      display: none;
      align-items: center;
      gap: 8px;
      max-width: min(620px, calc(100% - 32px));
      padding: 8px 10px;
      border: 1px solid rgba(119, 199, 177, .42);
      border-radius: 8px;
      background: rgba(9, 13, 14, .96);
      box-shadow: 0 12px 34px rgba(0, 0, 0, .36);
      transform: translateX(-50%);
    }
    .message-select-bar.show { display: flex; }
    .message-select-count {
      min-width: 86px;
      color: var(--text);
      font-size: 12px;
      white-space: nowrap;
    }
    .message-select-action {
      height: 30px;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 6px;
      background: rgba(20, 28, 30, .94);
      color: var(--text);
      cursor: pointer;
      padding: 0 10px;
      font-size: 12px;
    }
    .message-select-action.primary {
      border-color: rgba(119, 199, 177, .72);
      background: rgba(46, 120, 98, .88);
    }
    .message-select-action:disabled {
      cursor: default;
      opacity: .45;
    }
    .jump-bottom {
      position: absolute;
      right: 18px;
      bottom: 76px;
      z-index: 5;
      display: none;
      place-items: center;
      width: 40px;
      height: 40px;
      border: 1px solid rgba(119, 199, 177, .55);
      border-radius: 999px;
      background: rgba(25, 38, 40, .96);
      color: var(--text);
      cursor: pointer;
      padding: 0;
      box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
    }
    .jump-bottom svg {
      width: 22px;
      height: 22px;
      stroke: currentColor;
      stroke-width: 2.25;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .jump-bottom.show { display: grid; }
    .empty {
      color: var(--muted);
      text-align: center;
      margin: auto;
      max-width: 420px;
    }
    .topics .empty {
      margin: 20px 10px;
      text-align: left;
    }
    .row {
      display: flex;
      align-items: flex-end;
      gap: 8px;
    }
    .row.out { justify-content: flex-end; }
    .messages.select-mode .row {
      cursor: pointer;
      touch-action: pan-y;
    }
    .msg-select-check {
      display: none;
      flex: 0 0 auto;
      width: 24px;
      height: 24px;
      align-self: center;
      place-items: center;
      border: 1px solid rgba(237, 242, 240, .24);
      border-radius: 999px;
      background: rgba(9, 13, 14, .72);
      color: #d8fff1;
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 0;
    }
    .messages.select-mode .msg-select-check {
      display: grid;
    }
    .row.selected .msg-select-check {
      border-color: rgba(119, 199, 177, .88);
      background: rgba(46, 120, 98, .92);
    }
    .row.selected .bubble {
      border-color: rgba(119, 199, 177, .9);
      box-shadow: 0 0 0 2px rgba(119, 199, 177, .18);
    }
    .row.search-focus .bubble {
      border-color: rgba(119, 199, 177, .92);
      box-shadow: 0 0 0 2px rgba(119, 199, 177, .18);
    }
    .msg-avatar {
      flex: 0 0 auto;
      width: 34px;
      height: 34px;
      display: grid;
      place-items: center;
      border-radius: 999px;
      border: 1px solid rgba(216, 226, 223, .24);
      background: #2f3d42;
      color: #d8e2df;
      font-size: 22px;
      line-height: 1;
      align-self: flex-start;
      user-select: none;
    }
    .msg-avatar.cx {
      color: #effffb;
      background: #1f614f;
      border-color: rgba(119, 199, 177, .46);
    }
    .msg-avatar.cc {
      color: #e9f5ff;
      background: #245078;
      border-color: rgba(135, 190, 233, .45);
    }
    .msg-avatar.glm {
      color: #fff4c2;
      background: #7a4f08;
      border-color: rgba(231, 188, 85, .52);
    }
    .msg-avatar.me {
      color: #f1e9ff;
      background: #4a3a73;
      border-color: rgba(184, 158, 230, .45);
    }
    .bubble {
      width: fit-content;
      max-width: min(620px, 68%);
      padding: 10px 12px;
      border-radius: 8px;
      background: var(--bubble-in);
      border: 1px solid #334147;
      overflow-wrap: anywhere;
    }
    .row.out .bubble {
      background: var(--bubble-out);
      border-color: #49796b;
    }
    .bubble-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 2px;
    }
    .bubble-top .meta {
      margin-bottom: 0;
    }
    .msg-copy-actions {
      display: flex;
      align-items: center;
      gap: 4px;
      flex: 0 0 auto;
    }
    .msg-copy {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 34px;
      height: 22px;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 4px;
      background: rgba(16, 22, 24, .28);
      color: var(--muted);
      cursor: pointer;
      font-family: var(--mono);
      font-size: 11px;
      font-weight: 700;
      line-height: 1;
      letter-spacing: 0;
      padding: 0 6px;
      opacity: .72;
    }
    .msg-copy.msg-cite {
      min-width: 40px;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      letter-spacing: .1px;
    }
    .msg-copy:hover,
    .msg-copy:focus {
      color: var(--text);
      border-color: rgba(119, 199, 177, .65);
      opacity: 1;
      outline: none;
    }
    .msg-copy.copied {
      color: #ffd166;
      border-color: rgba(255, 209, 102, .55);
      opacity: 1;
    }
    .msg-copy.error {
      color: #ffb0aa;
      border-color: rgba(255, 155, 155, .55);
      opacity: 1;
    }
    .msg-copy.msg-zoom {
      min-width: 24px;
      width: 24px;
      padding: 0;
    }
    .msg-copy.msg-zoom .expand-corners {
      position: relative;
      display: block;
      width: 13px;
      height: 13px;
    }
    .msg-copy.msg-zoom .expand-corners::before,
    .msg-copy.msg-zoom .expand-corners::after {
      content: "";
      position: absolute;
      width: 6px;
      height: 6px;
      border-color: currentColor;
    }
    .msg-copy.msg-zoom .expand-corners::before {
      top: 1px;
      right: 1px;
      border-top: 2px solid;
      border-right: 2px solid;
    }
    .msg-copy.msg-zoom .expand-corners::after {
      left: 1px;
      bottom: 1px;
      border-left: 2px solid;
      border-bottom: 2px solid;
    }
    .typing-bubble {
      border-style: dashed;
      opacity: .92;
    }
    .meta {
      color: var(--muted);
      font-size: 11px;
      margin-bottom: 2px;
    }
    .meta.pending { color: #c9b77d; }
    .meta.uncertain { color: #d6b24a; }
    .meta.failed { color: var(--danger); }
    .msg-title {
      font-weight: 700;
      margin-bottom: 4px;
    }
    .msg-body {
      white-space: normal;
    }
    .msg-body p {
      margin: 0 0 8px;
    }
    .msg-body p:last-child {
      margin-bottom: 0;
    }
    .msg-body h1,
    .msg-body h2,
    .msg-body h3 {
      margin: 6px 0 8px;
      font-size: 1em;
      line-height: 1.35;
    }
    .msg-body ul,
    .msg-body ol {
      /* markers render outside the content box; keep them INSIDE the bubble by
         reserving the indent as padding (1.8em fits two-digit numbers like "12.") */
      margin: 4px 0 8px;
      padding: 0 0 0 1.8em;
    }
    .msg-body ol { list-style: decimal outside; }
    .msg-body ul { list-style: disc outside; }
    .msg-body li {
      margin: 2px 0;
    }
    .msg-body blockquote {
      margin: 6px 0 8px;
      padding-left: 10px;
      border-left: 3px solid rgba(119, 199, 177, .5);
      color: var(--muted);
    }
    .msg-body pre {
      max-width: 100%;
      overflow: auto;
      margin: 6px 0 8px;
      padding: 10px 11px;
      border-radius: 6px;
      background: #071011;
      border: 1px solid rgba(119, 199, 177, .18);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
      color: #d8f5ec;
      line-height: 1.5;
      tab-size: 2;
    }
    .msg-body .md-code-block {
      max-width: 100%;
      margin: 6px 0 8px;
      border-radius: 6px;
      cursor: copy;
      touch-action: manipulation;
    }
    .msg-body .md-code-block pre {
      margin: 0;
    }
    .msg-body .md-code-block:focus-visible {
      outline: 2px solid rgba(119, 199, 177, .62);
      outline-offset: 2px;
    }
    .msg-body .md-code-block.copied pre {
      border-color: rgba(119, 199, 177, .7);
      box-shadow: 0 0 0 2px rgba(119, 199, 177, .16), inset 0 1px 0 rgba(255,255,255,.025);
    }
    .msg-body .md-code-block.error pre {
      border-color: rgba(255, 155, 155, .58);
      box-shadow: 0 0 0 2px rgba(255, 155, 155, .12), inset 0 1px 0 rgba(255,255,255,.025);
    }
    .msg-body code {
      font-family: var(--mono);
      font-size: .91em;
      font-variant-ligatures: none;
      background: rgba(5, 10, 11, .34);
      border-radius: 4px;
      padding: 1px 4px;
    }
    .msg-body pre code {
      display: block;
      background: transparent;
      padding: 0;
      border-radius: 0;
      color: inherit;
      white-space: pre;
    }
    .row.has-md-table .bubble {
      max-width: min(920px, calc(100% - 44px));
    }
    .msg-body .md-table-wrap {
      position: relative;
      max-width: 100%;
      overflow: hidden;
      margin: 10px 0;
      border: 1px solid rgba(119, 199, 177, .3);
      border-radius: 6px;
      background: rgba(5, 10, 11, .24);
    }
    .msg-body .md-table-scroll {
      max-width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .msg-body .md-table {
      width: max-content;
      min-width: 100%;
      border-collapse: collapse;
      font-size: .92em;
      line-height: 1.45;
      color: #e3efeb;
      margin: 0;
    }
    .msg-body .md-table th,
    .msg-body .md-table td {
      padding: 6px 8px;
      border-right: 1px solid rgba(237, 242, 240, .1);
      border-bottom: 1px solid rgba(237, 242, 240, .1);
      vertical-align: top;
      text-align: center;
      overflow-wrap: normal;
      word-break: normal;
    }
    .msg-body .md-table th:last-child,
    .msg-body .md-table td:last-child {
      border-right: 0;
    }
    .msg-body .md-table tbody tr:last-child td {
      border-bottom: 0;
    }
    .msg-body .md-table th {
      background: rgba(216, 170, 58, .1);
      color: #ffd166;
      font-weight: 750;
      text-align: center;
      white-space: nowrap;
      border-bottom-color: rgba(255, 209, 102, .36);
    }
    .msg-body .md-table td {
      min-width: 64px;
    }
    .msg-body .md-table .align-left {
      text-align: left;
    }
    .msg-body .md-table .align-center {
      text-align: center;
    }
    .msg-body .md-table .align-right {
      text-align: right;
    }
    .table-zoom-modal {
      position: fixed;
      inset: 0;
      z-index: 99999;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0, 0, 0, .68);
      backdrop-filter: blur(7px);
    }
    .table-zoom-modal.open {
      display: flex;
    }
    .table-zoom-card {
      width: min(1440px, calc(100vw - 24px));
      height: min(92vh, 920px);
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
      border: 1px solid rgba(255, 255, 255, .16);
      border-radius: 8px;
      background: #0b1012;
      color: #e3efeb;
      box-shadow: 0 18px 62px rgba(0, 0, 0, .62);
      overflow: hidden;
    }
    .table-zoom-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-height: 44px;
      padding: 8px 10px 8px 14px;
      border-bottom: 1px solid rgba(255, 255, 255, .1);
      background: rgba(237, 242, 240, .035);
    }
    .table-zoom-head strong {
      color: #ffd166;
      font-family: var(--mono);
      font-size: 12px;
      letter-spacing: 0;
    }
    .table-zoom-actions {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex: 0 0 auto;
    }
    .table-zoom-action,
    .table-zoom-close {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 28px;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 4px;
      background: rgba(255, 255, 255, .06);
      color: #dfe7e5;
      cursor: pointer;
      font-family: var(--mono);
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      padding: 0 9px;
    }
    .table-zoom-close {
      width: 28px;
      padding: 0;
      font-size: 16px;
    }
    .table-zoom-action:hover,
    .table-zoom-action:focus-visible,
    .table-zoom-close:hover,
    .table-zoom-close:focus-visible {
      border-color: rgba(255, 209, 102, .58);
      color: #ffffff;
      outline: none;
    }
    .table-zoom-body {
      min-height: 0;
      overflow: hidden;
      background: #0f1418;
    }
    .table-zoom-scroll {
      height: 100%;
      overflow: auto;
      padding: 12px;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
    }
    .table-zoom-table-frame + .table-zoom-table-frame {
      margin-top: 14px;
    }
    .table-zoom-body .md-table {
      width: max-content;
      min-width: 100%;
      border-collapse: collapse;
      font-size: 14px;
      line-height: 1.48;
      color: #e3efeb;
      background: rgba(5, 10, 11, .28);
    }
    .table-zoom-body .md-table th,
    .table-zoom-body .md-table td {
      padding: 8px 10px;
      border-right: 1px solid rgba(237, 242, 240, .12);
      border-bottom: 1px solid rgba(237, 242, 240, .12);
      vertical-align: top;
      text-align: center;
      overflow-wrap: normal;
      word-break: normal;
    }
    .table-zoom-body .md-table th {
      background: rgba(216, 170, 58, .12);
      color: #ffd166;
      font-weight: 800;
      white-space: nowrap;
      border-bottom-color: rgba(255, 209, 102, .38);
    }
    .table-zoom-body .md-table td {
      min-width: 82px;
    }
    .table-zoom-body .md-table .align-left {
      text-align: left;
    }
    .table-zoom-body .md-table .align-center {
      text-align: center;
    }
    .table-zoom-body .md-table .align-right {
      text-align: right;
    }
    @media (max-width: 680px) {
      .table-zoom-modal {
        padding: 0;
      }
      .table-zoom-card {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
      }
      .table-zoom-scroll {
        padding: 8px;
      }
      .table-zoom-body .md-table {
        font-size: 13px;
      }
    }
    .msg-body a {
      color: var(--accent);
      text-decoration: none;
      border-bottom: 1px solid rgba(119, 199, 177, .45);
      cursor: pointer;
    }
    .attachment {
      display: inline-flex;
      align-items: center;
      max-width: 100%;
      color: var(--accent);
      text-decoration: none;
      border-bottom: 1px solid transparent;
    }
    button.attachment {
      appearance: none;
      border: 0;
      border-bottom: 1px solid transparent;
      background: transparent;
      cursor: pointer;
      font: inherit;
      padding: 0;
      text-align: left;
    }
    .attachment:hover { border-color: var(--accent); }
    .attachment-row {
      margin-top: 8px;
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .attachment-row.missing { opacity: .7; }
    .attachment-row.missing .attachment-file {
      color: rgba(237, 242, 240, .58);
      border-color: transparent;
    }
    .attachment-note {
      color: var(--muted);
      font-size: 11px;
      line-height: 1;
    }
    .attachment-file {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .attachment-action,
    .attachment-link {
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 5px;
      background: rgba(16, 22, 24, .28);
      color: var(--muted);
      cursor: pointer;
      font-size: 11px;
      line-height: 1;
      padding: 4px 7px;
      text-decoration: none;
    }
    .attachment-action:hover,
    .attachment-action:focus,
    .attachment-link:hover,
    .attachment-link:focus {
      color: var(--text);
      border-color: rgba(119, 199, 177, .65);
      outline: none;
    }
    .message-images {
      margin-top: 8px;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(132px, 220px));
      gap: 8px;
      max-width: 100%;
    }
    .image-thumb {
      appearance: none;
      padding: 0;
      border: 1px solid rgba(237, 242, 240, .16);
      border-radius: 6px;
      background: rgba(5, 10, 12, .28);
      cursor: zoom-in;
      overflow: hidden;
      min-width: 0;
      aspect-ratio: 16 / 10;
    }
    .image-thumb:hover,
    .image-thumb:focus {
      border-color: rgba(119, 199, 177, .72);
      outline: none;
    }
    .image-thumb img {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: contain;
      background: rgba(0, 0, 0, .22);
    }
    .image-thumb.missing { display: none; }
    .image-lightbox {
      position: fixed;
      inset: 0;
      z-index: 300;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 22px;
      background: rgba(2, 6, 7, .86);
    }
    .image-lightbox.open { display: flex; }
    .image-lightbox img {
      max-width: min(96vw, 1500px);
      max-height: 92vh;
      object-fit: contain;
      border-radius: 6px;
      box-shadow: 0 18px 80px rgba(0,0,0,.48);
    }
    .image-lightbox-toolbar {
      position: fixed;
      top: 12px;
      left: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      z-index: 1;
    }
    .image-lightbox-close,
    .image-lightbox-tool,
    .image-lightbox-nav {
      position: fixed;
      border: 1px solid rgba(237, 242, 240, .22);
      border-radius: 6px;
      background: rgba(13, 19, 21, .82);
      color: var(--text);
      cursor: pointer;
      line-height: 1;
    }
    .image-lightbox-close {
      top: 12px;
      right: 12px;
      width: 34px;
      height: 34px;
      font-size: 22px;
    }
    .image-lightbox-tool {
      position: static;
      height: 34px;
      padding: 0 10px;
      font-size: 12px;
      font-weight: 800;
    }
    .image-lightbox-nav {
      top: 50%;
      width: 42px;
      height: 54px;
      transform: translateY(-50%);
      font-size: 28px;
    }
    .image-lightbox-prev { left: 12px; }
    .image-lightbox-next { right: 12px; }
    .image-lightbox-tool:disabled,
    .image-lightbox-nav:disabled {
      opacity: .38;
      cursor: default;
    }
    .image-lightbox-caption {
      position: fixed;
      left: 16px;
      right: 16px;
      bottom: 14px;
      color: rgba(237, 242, 240, .82);
      font-size: 12px;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      pointer-events: none;
    }
    .title-panel.hidden { display: none; }
    .title-panel {
      grid-column: 2;
      grid-row: 2;
      min-width: 0;
      min-height: 0;
      z-index: 74;
      display: grid;
      grid-template-rows: auto 1fr;
      background: rgba(16, 24, 26, .98);
      border-left: 1px solid var(--line);
      overflow: hidden;
      position: relative;
    }
    .title-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 12px;
      border-bottom: 1px solid var(--line);
    }
    .title-head strong { font-size: 13px; }
    .title-head-actions { display: inline-flex; gap: 6px; align-items: center; }
    .title-form {
      min-height: 0;
      overflow: auto;
      padding: 12px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .title-mode {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
      padding: 3px;
      border: 1px solid rgba(237, 242, 240, .12);
      border-radius: 8px;
      background: rgba(237, 242, 240, .05);
    }
    .title-mode button {
      min-width: 0;
      border: 1px solid transparent;
      border-radius: 6px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font-size: 12px;
      font-weight: 850;
      line-height: 1;
      padding: 9px 10px;
    }
    .title-mode button.active {
      color: #06120f;
      border-color: rgba(119, 199, 177, .75);
      background: var(--accent);
    }
    .title-mode-note {
      min-height: 18px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }
    .title-field {
      display: grid;
      gap: 5px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0;
    }
    .title-field input,
    .title-field textarea {
      width: 100%;
      min-width: 0;
      border: 1px solid rgba(119, 199, 177, .36);
      border-radius: 6px;
      background: #101719;
      color: var(--text);
      padding: 8px 9px;
      font-size: 13px;
      outline: none;
    }
    .title-field input:disabled,
    .title-field textarea:disabled {
      color: rgba(237, 242, 240, .62);
      border-color: rgba(237, 242, 240, .14);
      background: rgba(237, 242, 240, .035);
      cursor: default;
    }
    .title-field textarea {
      min-height: 72px;
      resize: vertical;
      line-height: 1.35;
    }
    .title-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
    .title-actions button {
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 6px;
      background: rgba(237, 242, 240, .07);
      color: var(--text);
      cursor: pointer;
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      padding: 8px 10px;
    }
    .title-actions button.primary {
      color: #06120f;
      border-color: rgba(119, 199, 177, .75);
      background: var(--accent);
    }
    .title-actions button:disabled {
      opacity: .48;
      cursor: default;
    }
    .title-status {
      min-height: 18px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }
    .title-status.error { color: #ffb0aa; }
    .title-panel,
    .layout-panel,
    .download-panel,
    .search-panel,
    .terminal-live {
      min-width: 0;
      min-height: 0;
    }
    .layout-panel.hidden,
    .download-panel.hidden,
    .search-panel.hidden { display: none; }
    .layout-panel,
    .download-panel,
    .search-panel {
      grid-column: 2;
      grid-row: 2;
      z-index: 70;
      display: grid;
      grid-template-rows: auto auto 1fr;
      background: rgba(16, 24, 26, .98);
      border-left: 1px solid var(--line);
      overflow: hidden;
      position: relative;
    }
    .layout-panel {
      grid-template-rows: auto 1fr;
    }
    #termHistoryPanel {
      grid-template-rows: auto auto minmax(0, 1fr);
    }
    .layout-head,
    .download-head,
    .search-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 12px;
      border-bottom: 1px solid var(--line);
    }
    .layout-head strong,
    .download-head strong,
    .search-head strong { font-size: 13px; }
    .layout-head-actions,
    .download-head-actions,
    .search-head-actions { display: inline-flex; gap: 6px; align-items: center; }
    .layout-panel-body {
      min-height: 0;
      overflow: auto;
      padding: 12px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .layout-panel .icon-btn {
      min-width: 0;
      width: 100%;
      height: 32px;
      padding: 0 8px;
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      white-space: nowrap;
    }
    .layout-panel .workspace-launch .icon-btn {
      height: 38px;
    }
    .layout-panel .workspace-primary {
      border-color: rgba(111, 213, 183, .62);
      background: #183d35;
      color: #effffb;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    }
    .layout-panel .workspace-quiet {
      border-color: rgba(52, 67, 72, .86);
      background: #141d20;
      color: #c5d0cd;
    }
    .layout-panel .workspace-quiet:hover,
    .layout-panel .workspace-primary:hover {
      transform: translateY(-1px);
    }
    .panel-tool-btn {
      width: 30px;
      height: 30px;
      min-width: 30px;
      padding: 0;
      display: inline-grid;
      place-items: center;
      color: #edf2f0;
      border: 1px solid rgba(237, 242, 240, .34);
      border-radius: 6px;
      background: rgba(237, 242, 240, .07);
      font-size: 15px;
      font-weight: 850;
      line-height: 1;
      cursor: pointer;
    }
    .panel-tool-btn:hover:not(:disabled),
    .panel-tool-btn:focus-visible {
      color: #fff;
      border-color: rgba(255,255,255,.82);
      background: rgba(237, 242, 240, .14);
      outline: none;
    }
    .panel-tool-btn.danger {
      color: #fff4f3;
      border-color: rgba(255, 90, 79, .72);
      background: rgba(216, 61, 53, .62);
    }
    #downloadClearBtn {
      width: 42px;
      min-width: 42px;
      font-size: 11px;
    }
    .download-search,
    .global-search {
      margin: 10px 12px;
      height: 34px;
      border: 1px solid rgba(119, 199, 177, .36);
      border-radius: 6px;
      background: #101719;
      color: var(--text);
      padding: 0 10px;
      font-size: 13px;
      outline: none;
    }
    .download-cleanup-option {
      margin: -3px 12px 8px;
      display: flex;
      align-items: center;
      gap: 7px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 750;
      line-height: 1.25;
      user-select: none;
    }
    .download-cleanup-option input {
      width: 14px;
      height: 14px;
      margin: 0;
      accent-color: var(--danger);
    }
    .download-list,
    .search-list {
      overflow: auto;
      padding: 0 10px 10px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .download-item,
    .search-item {
      border: 1px solid rgba(237, 242, 240, .12);
      border-radius: 7px;
      background: rgba(237, 242, 240, .045);
      padding: 9px;
      display: grid;
      gap: 7px;
    }
    .search-item {
      cursor: pointer;
      text-align: left;
      color: var(--text);
    }
    .search-item:hover,
    .search-item:focus-visible {
      border-color: rgba(119, 199, 177, .6);
      outline: none;
    }
    .download-name {
      color: var(--text);
      font-weight: 800;
      font-size: 13px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    [data-term-history] .download-name {
      display: flex;
      align-items: baseline;
      gap: 8px;
      min-width: 0;
    }
    .term-history-title {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .term-history-time {
      flex: 0 0 auto;
      color: var(--muted);
      font-size: 11px;
      font-weight: 760;
      font-variant-numeric: tabular-nums;
    }
    .download-meta {
      color: var(--muted);
      font-size: 11px;
      line-height: 1.35;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    [data-term-history] .download-meta {
      white-space: normal;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .search-snippet {
      color: #dce7e4;
      font-size: 12px;
      line-height: 1.4;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .search-mark {
      color: #071113;
      background: var(--accent);
      border-radius: 3px;
      padding: 0 2px;
      font-weight: 850;
    }
    .download-actions {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }
    .download-actions button {
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 5px;
      background: rgba(16, 22, 24, .42);
      color: var(--text);
      cursor: pointer;
      font-size: 11px;
      line-height: 1;
      padding: 5px 8px;
    }
    .download-actions button:disabled {
      opacity: .45;
      cursor: default;
    }
    .term-preview-panel {
      border-top: 1px solid rgba(237, 242, 240, .11);
      margin-top: 2px;
      padding-top: 8px;
      display: grid;
      gap: 7px;
      min-width: 0;
    }
    .term-preview-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.3;
    }
    .term-preview-head button {
      border: 0;
      background: transparent;
      color: var(--accent);
      cursor: pointer;
      font-size: 11px;
      font-weight: 800;
      padding: 0;
      flex: 0 0 auto;
    }
    .term-preview-list {
      display: grid;
      gap: 6px;
      max-height: 300px;
      overflow: auto;
      padding-right: 2px;
    }
    .term-preview-msg {
      border-left: 2px solid rgba(119, 199, 177, .38);
      background: rgba(4, 8, 9, .22);
      padding: 6px 8px;
      display: grid;
      gap: 3px;
      min-width: 0;
    }
    .term-preview-meta {
      color: var(--muted);
      font-size: 10.5px;
      line-height: 1.2;
      font-weight: 750;
    }
    .term-preview-body {
      color: #e6efec;
      font-size: 12px;
      line-height: 1.45;
      white-space: normal;
      overflow-wrap: anywhere;
    }
    .term-preview-empty {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
      padding: 4px 0;
    }
    .term-preview-empty.error {
      color: var(--danger);
    }
    .term-preview-modal.hidden {
      display: none;
    }
    .term-preview-modal {
      position: fixed;
      inset: 0;
      z-index: 99998;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 22px;
      background: rgba(0, 0, 0, .58);
      backdrop-filter: blur(7px);
    }
    .term-preview-modal-card {
      width: min(1040px, calc(100vw - 28px));
      height: min(88vh, 860px);
      display: grid;
      grid-template-rows: auto auto minmax(0, 1fr);
      border: 1px solid rgba(255, 255, 255, .16);
      border-radius: 14px;
      background: #0c0e13;
      color: #dfe7e5;
      box-shadow: 0 16px 56px rgba(0, 0, 0, .6);
      overflow: hidden;
    }
    .term-preview-modal-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
      padding: 14px 16px 10px;
      border-bottom: 1px solid rgba(255, 255, 255, .1);
    }
    .term-preview-modal-title-wrap {
      display: grid;
      gap: 4px;
      min-width: 0;
      flex: 1 1 auto;
    }
    .term-preview-modal-title-wrap strong {
      color: #f4fbf8;
      font-size: 16px;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .term-preview-modal-title-wrap span {
      color: #8fa19d;
      font-size: 12px;
      line-height: 1.35;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .term-preview-modal-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      flex: 0 0 auto;
      flex-wrap: wrap;
    }
    .term-preview-modal-actions button {
      border: 1px solid rgba(237, 242, 240, .16);
      border-radius: 6px;
      background: rgba(237, 242, 240, .06);
      color: #dfe7e5;
      cursor: pointer;
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
      min-height: 30px;
      padding: 8px 10px;
    }
    .term-preview-modal-actions button.primary {
      border-color: rgba(119, 199, 177, .58);
      background: rgba(34, 64, 54, .62);
      color: #ecfffa;
    }
    .term-preview-modal-actions button:hover:not(:disabled),
    .term-preview-modal-actions button:focus-visible {
      border-color: rgba(119, 199, 177, .72);
      outline: none;
    }
    .term-preview-modal-actions button:disabled {
      opacity: .48;
      cursor: default;
    }
    .term-preview-modal-close {
      border: 0;
      background: transparent;
      color: #9aa9a5;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      padding: 1px 2px;
      flex: 0 0 auto;
    }
    .term-preview-modal-close:hover,
    .term-preview-modal-close:focus-visible {
      color: #ffffff;
      outline: none;
    }
    .term-preview-modal-summary {
      color: #9bb0ab;
      font-size: 12px;
      line-height: 1.4;
      padding: 9px 16px;
      background: rgba(119, 199, 177, .055);
      border-bottom: 1px solid rgba(255, 255, 255, .08);
    }
    .term-preview-modal-body {
      min-height: 0;
      overflow: hidden;
      background: #0f1418;
    }
    .term-preview-modal-list {
      height: 100%;
      overflow: auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .term-preview-modal-msg {
      width: fit-content;
      max-width: min(760px, 82%);
      border: 1px solid rgba(237, 242, 240, .1);
      border-radius: 8px;
      background: rgba(237, 242, 240, .055);
      padding: 9px 11px;
      display: grid;
      gap: 5px;
      overflow-wrap: anywhere;
    }
    .term-preview-modal-msg.me {
      align-self: flex-end;
      border-color: rgba(119, 199, 177, .32);
      background: rgba(34, 64, 54, .45);
    }
    .term-preview-modal-msg.system {
      max-width: 88%;
      align-self: center;
      border-color: rgba(255, 255, 255, .1);
      background: rgba(255, 255, 255, .045);
    }
    .term-preview-modal-msg-meta {
      color: #8fa19d;
      font-size: 11px;
      line-height: 1.2;
      font-weight: 750;
    }
    .term-preview-modal-msg-body {
      color: #e8f0ed;
      font-size: 13px;
      line-height: 1.55;
      white-space: pre-wrap;
    }
    .term-preview-modal-empty {
      color: #9bb0ab;
      padding: 24px;
      font-size: 13px;
      line-height: 1.5;
      text-align: center;
    }
    .term-preview-modal-empty.error {
      color: var(--danger);
    }
    .term-relay-modal.hidden {
      display: none;
    }
    .term-relay-modal {
      position: fixed;
      inset: 0;
      z-index: 99999;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(0, 0, 0, .52);
      backdrop-filter: blur(6px);
    }
    .term-relay-card {
      width: min(420px, calc(100vw - 32px));
      border: 1px solid rgba(255, 255, 255, .16);
      border-radius: 8px;
      background: #0c0e13;
      color: #dfe7e5;
      box-shadow: 0 16px 48px rgba(0, 0, 0, .55);
      overflow: hidden;
    }
    .term-relay-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 14px 10px;
      border-bottom: 1px solid rgba(255, 255, 255, .1);
    }
    .term-relay-title-wrap {
      min-width: 0;
      display: grid;
      gap: 4px;
    }
    .term-relay-title-wrap strong {
      color: #f4fbf8;
      font-size: 15px;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .term-relay-title-wrap span {
      color: #8fa19d;
      font-size: 12px;
      line-height: 1.35;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .term-relay-close {
      width: 28px;
      height: 28px;
      display: inline-grid;
      place-items: center;
      flex: 0 0 auto;
      border: 1px solid transparent;
      border-radius: 6px;
      background: transparent;
      color: #9aa9a5;
      cursor: pointer;
      font-size: 16px;
      line-height: 1;
      padding: 0;
    }
    .term-relay-close:hover,
    .term-relay-close:focus-visible {
      color: #ffffff;
      border-color: rgba(255, 255, 255, .2);
      background: rgba(255, 255, 255, .06);
      outline: none;
    }
    .term-relay-session {
      color: #b2c3bf;
      font-size: 12px;
      line-height: 1.45;
      padding: 10px 14px;
      background: rgba(119, 199, 177, .055);
      border-bottom: 1px solid rgba(255, 255, 255, .08);
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow-wrap: anywhere;
    }
    .term-relay-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      padding: 12px 14px 14px;
    }
    .term-relay-option {
      min-width: 0;
      min-height: 42px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid rgba(237, 242, 240, .16);
      border-radius: 8px;
      background: rgba(237, 242, 240, .06);
      color: #dfe7e5;
      cursor: pointer;
      font-size: 13px;
      font-weight: 800;
      line-height: 1;
      padding: 0 10px;
    }
    .term-relay-option.primary {
      grid-column: 1 / -1;
      border-color: rgba(119, 199, 177, .6);
      background: rgba(34, 64, 54, .68);
      color: #ecfffa;
    }
    .term-relay-option:hover,
    .term-relay-option:focus-visible {
      color: #ffffff;
      border-color: rgba(119, 199, 177, .72);
      background: rgba(237, 242, 240, .12);
      outline: none;
    }
    .term-relay-option.primary:hover,
    .term-relay-option.primary:focus-visible {
      background: rgba(44, 86, 72, .78);
    }
    .term-relay-option span {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    @media (max-width: 680px) {
      .term-preview-modal-head {
        flex-wrap: wrap;
      }
      .term-preview-modal-actions {
        order: 3;
        width: 100%;
        justify-content: flex-start;
      }
      .term-preview-modal-close {
        margin-left: auto;
      }
    }
    @media (max-width: 380px) {
      .term-relay-grid {
        grid-template-columns: 1fr;
      }
      .term-relay-option.primary {
        grid-column: auto;
      }
    }
    .term-resume-current {
      padding: 10px 12px 2px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .term-resume-current button {
      border: 1px solid rgba(119, 199, 177, .5);
      border-radius: 8px;
      background: rgba(34, 64, 54, .6);
      color: var(--text);
      cursor: pointer;
      padding: 10px 12px;
      font-size: 13px;
      font-weight: 700;
    }
    .term-resume-current button:disabled {
      opacity: .4;
      cursor: default;
    }
    .term-resume-note {
      color: var(--muted);
      font-size: 11.5px;
      line-height: 1.4;
    }
    .term-history-group {
      margin: 7px 12px 0;
      border: 1px solid rgba(237, 242, 240, .12);
      border-radius: 8px;
      overflow: hidden;
      flex-shrink: 0;
    }
    .term-history-group:last-of-type { margin-bottom: 10px; }
    .term-history-main {
      min-height: 0;
      display: flex;
      flex-direction: column;
      margin-bottom: 10px;
    }
    .term-history-group summary,
    .term-history-heading {
      cursor: pointer;
      padding: 9px 11px;
      font-size: 12.5px;
      font-weight: 700;
      color: var(--text);
      list-style: none;
      display: flex;
      align-items: center;
      gap: 7px;
      user-select: none;
    }
    .term-history-heading {
      cursor: default;
    }
    .term-history-group summary::-webkit-details-marker { display: none; }
    .term-history-group summary::before {
      content: "\25B8";
      font-size: 10px;
      color: var(--muted);
      transition: transform .15s;
    }
    .term-history-group[open] summary::before { transform: rotate(90deg); }
    .term-history-group .download-list {
      max-height: 38vh;
      overflow-y: auto;
      padding-top: 2px;
    }
    .term-history-main .download-list {
      flex: 1 1 auto;
      min-height: 0;
      max-height: none;
    }
    .term-history-model-group {
      display: flex;
      flex-direction: column;
      min-width: 0;
      margin: 0 0 12px;
      padding: 0 0 8px;
      border-bottom: 1px solid rgba(237, 242, 240, .1);
    }
    .term-history-model-group:last-child {
      margin-bottom: 0;
      border-bottom: 0;
    }
    .term-history-model-head {
      position: sticky;
      top: 0;
      z-index: 2;
      width: 100%;
      border: 0;
      border-left: 3px solid rgba(237, 242, 240, .22);
      border-bottom: 1px solid rgba(237, 242, 240, .1);
      border-radius: 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 8px 6px 7px 8px;
      color: #f5fbf8;
      background: rgba(10, 18, 20, .98);
      font-family: inherit;
      font-size: 13px;
      font-weight: 900;
      letter-spacing: 0;
      text-align: left;
      cursor: pointer;
    }
    .term-history-model-head::before {
      content: "\25B8";
      flex: 0 0 auto;
      color: var(--muted);
      font-size: 11px;
      transition: transform .14s ease;
    }
    .term-history-model-group:not(.collapsed) .term-history-model-head::before {
      transform: rotate(90deg);
    }
    .term-history-model-group.cc .term-history-model-head {
      border-left-color: #77c7b1;
    }
    .term-history-model-group.cx .term-history-model-head {
      border-left-color: #8fb7ff;
    }
    .term-history-model-group.term .term-history-model-head {
      border-left-color: #c8b57b;
    }
    .term-history-model-head:hover {
      color: #ffffff;
      background: rgba(16, 27, 30, .98);
    }
    .term-history-model-name {
      flex: 1 1 auto;
      min-width: 0;
    }
    .term-history-model-count {
      color: var(--muted);
      font-size: 11px;
      font-weight: 850;
    }
    .term-history-model-body {
      display: flex;
      flex-direction: column;
      gap: 6px;
      min-width: 0;
      padding-top: 6px;
    }
    .term-history-model-group.collapsed .term-history-model-body {
      display: none;
    }
    .term-session-group {
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .term-session-group + .term-session-group {
      margin-top: 6px;
    }
    .term-session-group-head {
      position: sticky;
      top: 0;
      z-index: 1;
      width: 100%;
      border: 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 6px 4px 4px;
      color: #dce9e5;
      background: rgba(16, 24, 26, .96);
      font-size: 12px;
      font-weight: 850;
      letter-spacing: 0;
      cursor: pointer;
      text-align: left;
      font-family: inherit;
    }
    .term-history-model-body .term-session-group-head {
      top: 35px;
    }
    .term-session-group-head::before {
      content: "▾";
      flex: 0 0 auto;
      color: var(--muted);
      font-size: 11px;
      transition: transform .14s ease;
    }
    .term-session-group.collapsed .term-session-group-head::before {
      transform: rotate(-90deg);
    }
    .term-session-group-head:hover {
      color: #ffffff;
    }
    .term-session-group-name {
      flex: 1 1 auto;
      min-width: 0;
    }
    .term-session-group-count {
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
    }
    .term-session-group-items {
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-width: 0;
    }
    .term-session-group.collapsed .term-session-group-items {
      display: none;
    }
    .term-history-group .download-search {
      margin: 2px 10px 8px;
      height: 30px;
      width: calc(100% - 20px);
    }
    .download-empty,
    .search-empty {
      color: var(--muted);
      text-align: center;
      padding: 28px 8px;
      font-size: 13px;
    }
    .confirm-dialog {
      position: fixed;
      inset: 0;
      z-index: 500;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(1, 6, 7, .72);
      backdrop-filter: blur(9px);
    }
    .confirm-dialog.open { display: flex; }
    .confirm-card {
      width: min(430px, calc(100vw - 32px));
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 8px;
      background: #0f181a;
      color: var(--text);
      box-shadow: 0 22px 78px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.055);
      overflow: hidden;
      transform: translateY(8px) scale(.985);
      opacity: .96;
      transition: transform .14s ease, opacity .14s ease;
    }
    .confirm-dialog.open .confirm-card {
      transform: translateY(0) scale(1);
      opacity: 1;
    }
    .confirm-head {
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr) 30px;
      align-items: center;
      gap: 11px;
      padding: 15px 15px 12px;
      border-bottom: 1px solid rgba(237, 242, 240, .08);
      background: rgba(237, 242, 240, .025);
    }
    .confirm-mark {
      width: 34px;
      height: 34px;
      display: grid;
      place-items: center;
      flex: 0 0 auto;
      border: 1px solid rgba(255, 90, 79, .5);
      border-radius: 7px;
      background: rgba(216, 61, 53, .20);
      color: #ffd4d0;
      font-size: 18px;
      font-weight: 900;
      line-height: 1;
    }
    .confirm-title-wrap { min-width: 0; }
    .confirm-kicker {
      min-height: 12px;
      color: #9fb0ac;
      font-size: 10px;
      font-weight: 850;
      line-height: 1;
      text-transform: uppercase;
      letter-spacing: .02em;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .confirm-title {
      min-width: 0;
      margin-top: 3px;
      font-size: 15px;
      font-weight: 850;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .confirm-icon-close {
      width: 30px;
      height: 30px;
      border: 1px solid rgba(237, 242, 240, .12);
      border-radius: 6px;
      background: rgba(237, 242, 240, .04);
      color: #cdd9d6;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
    }
    .confirm-icon-close:hover,
    .confirm-icon-close:focus-visible {
      color: #fff;
      border-color: rgba(255,255,255,.55);
      outline: none;
    }
    .confirm-message {
      padding: 14px 16px 8px;
      color: #cbd8d5;
      font-size: 13px;
      line-height: 1.48;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .confirm-detail {
      margin: 0 16px 14px;
      padding: 10px 11px;
      border: 1px solid rgba(255, 90, 79, .22);
      border-radius: 7px;
      background: rgba(216, 61, 53, .08);
      color: #e5eeeb;
      font-size: 12px;
      font-weight: 760;
      line-height: 1.35;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .confirm-detail:empty { display: none; }
    .confirm-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      padding: 0 16px 16px;
    }
    .confirm-actions button {
      min-width: 0;
      height: 38px;
      border: 1px solid rgba(237, 242, 240, .18);
      border-radius: 6px;
      background: rgba(237, 242, 240, .055);
      color: var(--text);
      cursor: pointer;
      font-size: 13px;
      font-weight: 850;
      line-height: 1;
    }
    .confirm-actions button:hover,
    .confirm-actions button:focus-visible {
      border-color: rgba(255,255,255,.66);
      outline: none;
    }
    .confirm-actions .confirm-accept {
      border-color: rgba(255, 90, 79, .72);
      background: rgba(216, 61, 53, .82);
      color: #fff7f6;
    }
    .confirm-actions .confirm-accept:hover,
    .confirm-actions .confirm-accept:focus-visible {
      border-color: #ffb0a8;
      background: #f14b42;
    }

    /* --- Relay / Fork (交接/分支) per-row control --------------------------- */
    .relayfork-controls {
      display: inline-flex;
      align-items: center;
      margin-left: 4px;
    }
    .relayfork-trigger {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      border-radius: 6px;
      border: 1px solid transparent;
      color: var(--muted);
      font-size: 13px;
      line-height: 1;
      cursor: pointer;
      user-select: none;
      transition: color .12s, border-color .12s, background .12s;
    }
    .relayfork-trigger:hover,
    .relayfork-trigger:focus-visible {
      color: var(--accent);
      border-color: var(--accent-2);
      background: rgba(77, 157, 137, .14);
      outline: none;
    }
    .relayfork-menu {
      position: fixed;
      z-index: 4000;
      min-width: 248px;
      padding: 8px;
      border-radius: 12px;
      border: 1px solid var(--accent-2);
      background: var(--panel-2);
      box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .relayfork-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .relayfork-row-label {
      flex: 0 0 auto;
      width: 34px;
      color: var(--text);
      font-size: 12px;
      font-weight: 800;
      cursor: help;
    }
    .relayfork-targets {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
    }
    .relayfork-target-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 3px 9px;
      border-radius: 7px;
      border: 1px solid var(--accent-2);
      background: var(--panel);
      color: var(--text);
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
      user-select: none;
      transition: background .12s, border-color .12s;
    }
    .relayfork-target-btn:hover,
    .relayfork-target-btn:focus-visible {
      background: var(--accent);
      border-color: var(--accent);
      color: #0c1311;
      outline: none;
    }
    @keyframes progressLivePulse {
      0%, 100% { opacity: .45; box-shadow: 0 0 0 0 rgba(90, 210, 150, .28); }
      50% { opacity: 1; box-shadow: 0 0 0 5px rgba(90, 210, 150, 0); }
    }
    .messages { overflow-anchor: none; }
    .turn-progress {
      width: 100%;
      margin: 10px 0 0;
      border: 1px solid rgba(116, 199, 155, .28);
      border-radius: 10px;
      background: linear-gradient(145deg, rgba(24, 43, 39, .94), rgba(18, 28, 30, .96));
      overflow: hidden;
      overflow-anchor: none;
    }
    .turn-progress.complete {
      border-color: rgba(255, 255, 255, .14);
      background: linear-gradient(145deg, rgba(28, 36, 38, .94), rgba(19, 26, 28, .96));
    }
    .progress-card-head {
      width: 100%;
      min-height: 42px;
      padding: 10px 12px;
      display: flex;
      align-items: center;
      gap: 9px;
      color: var(--text, #e5efeb);
      background: transparent;
      border: 0;
      cursor: pointer;
      text-align: left;
      font: inherit;
    }
    .progress-card-head:hover { background: rgba(255, 255, 255, .035); }
    .progress-card-status {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      font-weight: 700;
    }
    .progress-live-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #63ca91;
      flex: 0 0 auto;
    }
    .turn-progress.running .progress-live-dot { animation: progressLivePulse 1.6s ease-in-out infinite; }
    .turn-progress.complete .progress-live-dot { background: #80908b; animation: none; }
    .progress-card-count {
      margin-left: auto;
      padding: 2px 7px;
      border-radius: 999px;
      color: var(--muted, #9aa7a3);
      background: rgba(255, 255, 255, .06);
      font-size: 11px;
    }
    .progress-card-chevron { color: var(--muted, #9aa7a3); font-size: 14px; }
    .progress-card-preview {
      padding: 0 12px 11px 28px;
      color: var(--muted, #9aa7a3);
      font-size: 12px;
      line-height: 1.45;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .turn-progress.expanded .progress-card-preview { display: none; }
    .progress-card-body {
      padding: 3px 12px 12px;
      border-top: 1px solid rgba(255, 255, 255, .07);
      max-height: min(42vh, 380px);
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-gutter: stable;
      overflow-anchor: none;
    }
    .progress-event {
      display: grid;
      grid-template-columns: 24px minmax(0, 1fr);
      gap: 7px;
      padding: 9px 0;
    }
    .progress-event + .progress-event { border-top: 1px dashed rgba(255, 255, 255, .075); }
    .progress-event-rail { display: flex; justify-content: center; }
    .progress-event-icon {
      width: 20px;
      height: 20px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 6px;
      color: #7ad3a4;
      background: rgba(90, 210, 150, .11);
      font: 700 11px/1 var(--mono, monospace);
    }
    .progress-event.tool.error .progress-event-icon { color: #ef8a82; background: rgba(224, 114, 106, .13); }
    .progress-event-main { min-width: 0; }
    .progress-event-meta {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 4px;
      color: #8ea09a;
      font-size: 10px;
      letter-spacing: .02em;
    }
    .progress-event-meta time { margin-left: auto; color: #6f7f7a; }
    .progress-event-body {
      color: var(--text, #dfe9e5);
      font-size: 13px;
      line-height: 1.55;
      overflow-wrap: anywhere;
    }
    .progress-event-body > :first-child { margin-top: 0; }
    .progress-event-body > :last-child { margin-bottom: 0; }
    .progress-event-body.terminal { min-width: 0; }
    .progress-terminal-chunk {
      margin: 0;
      padding: 8px 9px;
      border: 1px solid rgba(255, 255, 255, .08);
      border-radius: 7px;
      background: rgba(3, 8, 9, .38);
      color: #d5dfdc;
      font: 11.5px/1.48 var(--mono, "Maple Mono NF CN", Consolas, monospace);
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      tab-size: 2;
    }
    .progress-event-fold > summary {
      color: #b8c8c2;
      cursor: pointer;
      font-size: 12px;
      line-height: 1.5;
    }
    .progress-event-fold[open] > summary { margin-bottom: 8px; }
    .progress-host-row { align-items: flex-start; }
    .progress-host-bubble { min-width: min(560px, calc(100vw - 120px)); }
    .progress-working-label {
      color: var(--muted, #9aa7a3);
      font-size: 12px;
      font-weight: 650;
    }
    @media (max-width: 720px) {
      .turn-progress { margin-top: 7px; border-radius: 9px; }
      .progress-host-bubble { min-width: 0; width: min(100%, calc(100vw - 64px)); }
      .progress-card-head { min-height: 40px; padding: 9px 10px; }
      .progress-card-preview { padding: 0 10px 10px 26px; }
      .progress-card-body { padding: 2px 10px 10px; }
    }
    @media (prefers-reduced-motion: reduce) {
      .turn-progress.running .progress-live-dot { animation: none; }
    }

/* Local file path links in message text (2026-07-17): click = open on host PC,
   the phone button pushes the file via ntfy. */
.msg-body .local-path-link {
  word-break: break-all;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}
.msg-body .local-path-push {
  border: none;
  background: none;
  padding: 0 2px;
  margin-left: 2px;
  font-size: 0.85em;
  line-height: 1;
  cursor: pointer;
  vertical-align: baseline;
  opacity: 0.75;
}
.msg-body .local-path-push:hover { opacity: 1; }

    @media (max-width: 640px) {
      .confirm-dialog {
        align-items: flex-end;
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
      }
      .confirm-card {
        width: 100%;
        max-width: none;
      }
      .confirm-head {
        padding: 15px 14px 12px;
      }
      .confirm-message {
        padding: 13px 14px 8px;
        font-size: 13px;
      }
      .confirm-detail {
        margin: 0 14px 14px;
      }
      .confirm-actions {
        padding: 0 14px 14px;
      }
      .confirm-actions button {
        height: 42px;
      }
    }
    .composer {
      grid-column: 1;
      grid-row: 3;
      border-top: 1px solid var(--line);
      background: var(--panel);
      padding: 12px;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: stretch;
    }
    .composer-actions {
      display: grid;
      grid-template-columns: repeat(2, 36px);
      gap: 5px;
      align-self: end;
    }
    .attach {
      width: 36px;
      height: 36px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--text);
      background: #101618;
      font-size: 15px;
      font-weight: 800;
      cursor: pointer;
    }
    .attach:hover,
    .attach:focus {
      border-color: var(--accent-2);
      outline: none;
    }
    .attach:disabled {
      opacity: .45;
      cursor: default;
    }
    .file-input {
      display: none;
    }
    .composer textarea {
      min-height: 34px;
      max-height: 150px;
      resize: vertical;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 7px 12px;
      color: var(--text);
      background: #101618;
      outline: none;
    }
    .composer textarea.has-cite {
      background: var(--bubble-in);
      border-color: #334147;
      box-shadow: inset 3px 0 0 rgba(119, 199, 177, .62);
      line-height: 1.45;
    }
    .composer textarea.has-cite:focus {
      border-color: rgba(119, 199, 177, .78);
      box-shadow: inset 3px 0 0 rgba(119, 199, 177, .78), 0 0 0 2px rgba(119, 199, 177, .12);
    }
    .composer textarea:focus { border-color: var(--accent-2); }
    .composer-input-shell {
      position: relative;
      min-width: 0;
      min-height: 34px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .composer-input-visual {
      display: none;
      max-height: 132px;
      overflow: auto;
      padding: 7px 12px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--text);
      background: var(--bubble-in);
      overflow-wrap: anywhere;
      line-height: 1.45;
      pointer-events: none;
      scrollbar-width: none;
    }
    .composer-input-visual::-webkit-scrollbar { display: none; }
    .composer-input-shell.has-cite .composer-input-visual { display: block; }
    .composer-input-shell.has-cite textarea {
      color: var(--text);
      background: #101618;
      border-color: #334147;
      box-shadow: inset 3px 0 0 rgba(119, 199, 177, .62);
    }
    .composer-input-shell.has-cite textarea:focus {
      border-color: rgba(119, 199, 177, .78);
      box-shadow: inset 3px 0 0 rgba(119, 199, 177, .78), 0 0 0 2px rgba(119, 199, 177, .12);
    }
    .composer-input-visual p {
      margin: 0 0 8px;
    }
    .composer-input-visual p:last-child { margin-bottom: 0; }
    .composer-input-visual blockquote {
      margin: 0 0 8px;
      padding-left: 10px;
      border-left: 3px solid rgba(119, 199, 177, .5);
      color: var(--muted);
    }
    .send {
      width: 36px;
      height: 36px;
      border: 0;
      border-radius: 6px;
      color: #06120f;
      background: var(--accent);
      font-weight: 800;
      font-size: 11px;
      cursor: pointer;
    }
    .send:disabled {
      opacity: .45;
      cursor: default;
    }
    .error {
      color: var(--danger);
    }
    .nav-toggle { display: none; }
    .nav-backdrop { display: none; }
    .actions-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      order: 20;
      flex: 0 0 auto;
      width: 25px;
      height: 25px;
      min-width: 25px;
      padding: 0;
      border: 1px solid rgba(237, 242, 240, .26);
      border-radius: 6px;
      color: #d9e5e2;
      background: rgba(237, 242, 240, .06);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 14px;
      line-height: 1;
      font-weight: 800;
      cursor: pointer;
      letter-spacing: 0;
    }
    .head-tool {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      order: 30;
      flex: 0 0 auto;
      width: 25px;
      height: 25px;
      min-width: 25px;
      padding: 0;
      border: 1px solid rgba(237, 242, 240, .26);
      border-radius: 6px;
      color: #d9e5e2;
      background: rgba(237, 242, 240, .06);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 14px;
      line-height: 1;
      font-weight: 800;
      cursor: pointer;
      letter-spacing: 0;
    }
    .head-tool.active {
      color: #071113;
      border-color: #ffffff;
      background: #edf2f0;
    }
    .head-tool.danger {
      color: #fff4f3;
      border-color: rgba(255, 90, 79, .78);
      background: rgba(216, 61, 53, .74);
    }
    .head-tool.danger:hover:not(:disabled),
    .head-tool.danger:focus-visible {
      color: #ffffff;
      border-color: #ffb0a8;
      background: #f14b42;
    }
    .head-tool svg,
    .quick-tool svg {
      width: 14px;
      height: 14px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .quick-tools {
      display: none;
      order: 0;
      align-items: center;
      gap: 4px;
      flex: 0 0 auto;
    }
    .quick-tool {
      width: 23px;
      height: 23px;
      display: inline-grid;
      place-items: center;
      border: 1px solid rgba(237, 242, 240, .26);
      border-radius: 6px;
      color: #d9e5e2;
      background: rgba(237, 242, 240, .06);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 9.5px;
      line-height: 1;
      font-weight: 800;
      cursor: pointer;
      padding: 0;
      letter-spacing: 0;
    }
    .actions-toggle:hover:not(:disabled),
    .actions-toggle:focus-visible,
    .head-tool:hover:not(:disabled),
    .head-tool:focus-visible,
    .quick-tool:hover:not(:disabled),
    .quick-tool:focus-visible {
      color: #ffffff;
      border-color: rgba(255,255,255,.72);
      background: rgba(237, 242, 240, .13);
      outline: none;
    }
    .quick-tool.active {
      color: #071113;
      border-color: #ffffff;
      background: #edf2f0;
    }
    .quick-tool.danger {
      color: #fff4f3;
      border-color: rgba(255, 90, 79, .78);
      background: rgba(216, 61, 53, .74);
    }
    .quick-tool.danger:hover:not(:disabled),
    .quick-tool.danger:focus-visible {
      border-color: #ffb0a8;
      background: #f14b42;
    }
    .quick-tool:disabled {
      opacity: .38;
      cursor: default;
    }
    @media (min-width: 821px) {
      .head-meta .quick-tools {
        display: flex;
      }
    }
    .head-meta {
      grid-column: 3;
      justify-self: end;
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      flex: 0 0 auto;
      min-width: 0;
      max-width: 100%;
    }
    @media (max-width: 1024px) and (min-width: 641px) {
      .chat.tool-panel-open {
        grid-template-columns: 1fr;
      }
      .title-panel,
      .layout-panel,
      .download-panel,
      .search-panel,
      .terminal-live {
        grid-column: 1;
        grid-row: 2;
        width: auto;
        min-width: 0;
        align-self: stretch;
        justify-self: stretch;
        margin: 8px 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .42);
      }
      .terminal-live {
        z-index: 72;
      }
      .tool-panel-resize-handle,
      .terminal-resize-handle {
        display: none;
      }
    }
    @media (max-width: 820px) and (min-width: 641px) {
      .app { grid-template-columns: 270px 1fr; min-width: 0; }
      .sidebar-resize-handle { display: none; }
      .bubble { max-width: 82%; }
      .chat-head {
        gap: 10px;
        padding: 12px;
        overflow: visible;
      }
      .chat-title {
        flex: 1 1 7em;
        min-width: 6.8em;
      }
      .chat-title strong {
        max-width: 7em;
        font-size: 14.5px;
      }
      .chat-title > span {
        max-width: min(34vw, 240px);
        font-size: 10px;
        line-height: 1.14;
      }
      .head-meta {
        gap: 6px;
      }
      .head-meta .quick-tools {
        display: none;
      }
      .actions-toggle {
        display: inline-flex;
      }
      .head-tool {
        width: 25px;
        height: 25px;
        min-width: 25px;
      }
      .chat-actions {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        right: 62px;
        transform: none;
        z-index: 95;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 4px;
        padding: 5px;
        width: max-content;
        max-width: min(276px, calc(100vw - 1.2em - 62px));
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 7px;
        box-shadow: 0 8px 24px rgba(0,0,0,.5);
      }
      .app.actions-open .chat-actions {
        display: flex;
      }
      .chat-actions .icon-btn.mobile-menu-tool {
        display: inline-flex;
      }
      .quota-pill {
        height: 26px;
        padding: 0 6px;
        font-size: 11px;
      }
      .topic-preview {
        -webkit-line-clamp: 1;
      }
    }
    @media (max-width: 1024px) and (min-width: 641px) and (hover: none) and (pointer: coarse) {
      :root { --tablet-top-safe-space: max(env(safe-area-inset-top, 0px), 14px); }
      .chat-head { padding-top: calc(12px + var(--tablet-top-safe-space)); }
      .side-head { padding-top: calc(16px + var(--tablet-top-safe-space)); }
    }
    @media (max-width: 640px) {
      /* WeChat-style two-page nav: list fills the screen; tapping a topic
         slides into a full-screen chat with a back arrow. Never both at once. */
      .app { grid-template-columns: 1fr; min-width: 0; }
      .app.sidebar-collapsed { grid-template-columns: 1fr; }
      .app.sidebar-hidden { grid-template-columns: 1fr; }
      .app.sidebar-hidden .sidebar { display: flex; }
      .sidebar-resize-handle { display: none; }
      .sidebar-restore-btn { display: none !important; }
      .sidebar { width: 100%; border-right: none; }
      .sidebar, .chat { grid-column: 1; grid-row: 1; }
      .sidebar-collapse-btn { display: none; }
      .app.sidebar-collapsed .title h1,
      .app.sidebar-collapsed #refreshBtn,
      .app.sidebar-collapsed .search,
      .app.sidebar-collapsed .status,
      .app.sidebar-collapsed .side-scroll {
        display: initial;
      }
      .app.sidebar-collapsed .side-scroll { display: block; }
      .chat { display: none; }
      .chat.tool-panel-open { grid-template-columns: 1fr; }
      .app.mobile-chat .sidebar { display: none; }
      .app.mobile-chat .chat { display: grid; }
      .nav-backdrop { display: none; }
      /* ADAPTIVE sizing: one fluid base font that scales with screen WIDTH
         (clamp + vw) — narrow phones get compact text, wide phones a bit more —
         and every size below is em-relative to it, so the whole UI auto-fits any
         phone and never needs a manual pinch-zoom. Tune the 3.5vw / 15px ceiling
         to shift the whole UI smaller or larger in one place. */
      body { font-size: var(--app-mobile-font-size); }
      :root { --mobile-top-safe-space: max(env(safe-area-inset-top, 0px), 6px); }
      .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        order: 0; flex: 0 0 auto; height: 1.8em; min-width: 1.1em;
        padding: 0 0.1em; font-size: 1.3em; line-height: 1; font-weight: 300;
        border: none; background: transparent;
      }
      /* WeChat-clean chat header: just the name on one line, drop the Slot·active subtitle. */
      #chatSub { display: none; font-size: 0.62em; }
      #chatName { max-width: 7em; }
      .chat-title strong { font-size: 0.98em; }
      /* Hard-contain the chat view so no child's intrinsic (min-content) width
         can push the layout viewport wider than the screen. Real-device data
         showed innerWidth growing 384 -> 409 on chat entry while the screen
         stayed 384 — that 25px is what cut off Close/Send and made it look
         "too big". overflow-x:hidden on these containers stops their wide
         content (the action-button row, quota pills) from expanding the page. */
      .chat { max-width: 100vw; overflow-x: hidden; }
      .chat-head { padding: calc(0.42em + var(--mobile-top-safe-space)) 0.85em 0.42em; gap: 0.45em; flex-wrap: nowrap; position: relative; }
      .chat-head > * { min-width: 0; }
      .composer { min-width: 0; overflow-x: hidden; }
      .composer textarea { min-width: 0; width: 100%; }
      .composer-status {
        min-height: 18px;
        gap: 6px;
        font-size: 0.78em;
        flex-wrap: nowrap;
      }
      .composer-terminal-status {
        flex: 1 1 100%;
        flex-wrap: nowrap;
        row-gap: 2px;
      }
      .composer-working,
      .composer-model,
      .composer-context,
      .composer-meter {
        flex-basis: auto;
      }
      .composer-status-segment.is-extra {
        display: none;
      }
      .composer-quota {
        display: none !important;
      }
      /* Keep mobile chat controls on one row; the title truncates instead of
         pushing quick buttons / menu / close onto a second row. */
      .chat-title { order: 1; flex: 1 1 auto; min-width: 0; }
      .chat-title strong { font-size: 1.02em; }
      .chat-title > span { font-size: 0.64em; line-height: 1.12; }
      .head-meta {
        order: 2; display: flex; align-items: center; gap: 6px;
        flex: 0 0 auto; min-width: max-content; justify-content: flex-end;
        margin-left: auto;
      }
      /* CC / CX stacked as one vertical column, with ⋮ snug to its right. */
      .quota-bar {
        flex: 1 1 auto; flex-direction: column; flex-wrap: nowrap;
        width: 100%; max-width: none;
        min-width: 0; gap: 3px; align-items: stretch;
      }
      .quota-pill {
        width: 100%;
        height: auto;
        min-height: 26px;
        grid-template-columns: 37px repeat(3, minmax(0, 1fr));
        grid-template-rows: auto auto;
        align-items: center;
        column-gap: 4px;
        row-gap: 1px;
        padding: 3px 5px;
        font-size: 0.74em;
        line-height: 1.05;
        white-space: normal;
        min-width: 0;
      }
      .quota-pill .quota-id {
        grid-row: 1 / span 2;
        justify-self: start;
        margin-left: 6px;
        width: 25px;
        min-width: 25px;
        height: 18px;
        font-size: 10.2px;
      }
      .quota-pill .quota-pct,
      .quota-pill .quota-sub {
        width: auto;
        min-width: 0;
        text-align: center;
      }
      .quota-pill .quota-sub { font-size: 0.92em; }
      .quota-pill .quota-pct:nth-child(2) { grid-column: 2; grid-row: 1; }
      .quota-pill .quota-sub:nth-child(3) { grid-column: 2; grid-row: 2; }
      .quota-pill .quota-pct:nth-child(4) { grid-column: 3; grid-row: 1; }
      .quota-pill .quota-sub:nth-child(5) { grid-column: 3; grid-row: 2; }
      .quota-pill .quota-pct:nth-child(6) { grid-column: 4; grid-row: 1; }
      .quota-pill .quota-sub:nth-child(7) { grid-column: 4; grid-row: 2; }
      /* Balance rows on narrow screens: pin the id chip to the left and center the
         amount across the WHOLE pill (not just the column right of the chip). */
      .quota-pill.balance {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        grid-template-columns: none;
        min-height: 26px;
        padding: 3px 6px;
      }
      .quota-pill.balance.multi {
        display: grid;
        grid-template-columns: 37px minmax(0, 1fr);
        justify-content: stretch;
      }
      .quota-pill.balance .quota-id {
        position: absolute;
        left: 6px;
        top: 50%;
        transform: translateY(-50%);
        grid-row: auto;
        margin-left: 0;
      }
      .quota-pill.balance.multi .quota-id {
        position: static;
        grid-column: 1;
        grid-row: 1;
        transform: none;
        margin-left: 6px;
      }
      .quota-pill.balance.multi .quota-bal-multi {
        grid-column: 2;
        width: 100%;
        justify-content: space-between;
        column-gap: 6px;
      }
      .quota-pill.balance.multi .quota-bal-multi .quota-bal {
        flex: 1 1 0;
        width: auto;
        text-align: center;
      }
      .quota-pill.balance .quota-bal {
        text-align: center;
        width: auto;
      }
      .side-actions-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 34px;
        height: 30px;
        min-width: 34px;
        padding: 0;
        font-size: 15px;
        line-height: 1;
        font-weight: 850;
      }
      .side-actions {
        display: none;
        position: absolute;
        top: 62px;
        right: 10px;
        z-index: 95;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 4px;
        padding: 5px;
        width: max-content;
        max-width: min(276px, calc(100vw - 20px));
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 7px;
        box-shadow: 0 8px 24px rgba(0,0,0,.5);
      }
      .app.side-actions-open .side-actions {
        display: flex;
      }
      .side-actions .icon-btn {
        width: 29px;
        height: 29px;
        min-width: 29px;
        padding: 0;
        justify-content: center;
        color: #edf2f0;
        border-color: rgba(237, 242, 240, .36);
        background: rgba(237, 242, 240, .07);
        font-size: 12px;
        box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
      }
      .side-actions .icon-btn:hover:not(:disabled) {
        color: #ffffff;
        border-color: rgba(255,255,255,.82);
        background: rgba(237, 242, 240, .14);
      }
      .side-actions .icon-btn svg {
        width: 15px;
        height: 15px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
      }
      /* Rarely-tapped action buttons collapse behind ⋮; the expanded strip
         opens to the LEFT of the pinned ⋮ / close buttons, so they do not move. */
      .actions-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 auto; width: 25px; height: 25px; min-width: 25px;
        padding: 0; font-size: 14px; line-height: 1; font-weight: 800;
      }
      .head-tool {
        width: 25px; height: 25px; min-width: 25px;
        padding: 0; font-size: 14px; line-height: 1; font-weight: 900;
      }
      .head-meta .quick-phrases,
      .head-meta .quick-tools { display: none; }
      /* Floating dropdown panel opens to the LEFT of ⋮ / close, so the pinned
         controls stay in place and the extra tools never append at the far end. */
      .chat-actions {
        display: none; position: absolute; top: calc(100% + 4px); right: 66px; transform: none;
        z-index: 95; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px;
        padding: 5px; width: max-content; max-width: min(276px, calc(100vw - 1.2em - 66px));
        background: var(--panel); border: 1px solid var(--line);
        border-radius: 7px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
      }
      .app.actions-open .chat-actions { display: flex; }
      .chat-actions .icon-btn {
        width: 29px;
        height: 29px;
        min-width: 29px;
        padding: 0;
        font-size: 12px;
        justify-content: center;
      }
      .chat-actions .icon-btn.font-step-btn {
        width: 38px;
        min-width: 38px;
        font-size: 12px;
      }
      .chat-actions .icon-btn.mobile-menu-tool { display: inline-flex; }
      .chat-actions .icon-btn svg { width: 15px; height: 15px; }
      .title-panel,
      .layout-panel,
      .download-panel,
      .terminal-live {
        position: fixed;
        z-index: 90;
        top: calc(3.1em + var(--mobile-top-safe-space));
        right: 0.6em;
        bottom: calc(4.7em + env(safe-area-inset-bottom, 0px));
        left: 0.6em;
        width: auto;
        border: 1px solid var(--line);
        border-radius: 8px;
      }
      .terminal-live {
        left: max(0.45em, env(safe-area-inset-left, 0px));
        right: max(0.45em, env(safe-area-inset-right, 0px));
        width: auto !important;
        max-width: calc(100vw - 0.9em);
        min-width: 0;
        box-sizing: border-box;
        grid-template-rows: auto auto auto minmax(0, 1fr);
        overflow: hidden;
      }
      .terminal-live-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 0.35em;
        min-width: 0;
        padding: 0.45em 0.5em;
      }
      .terminal-target-select {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        max-width: none;
      }
      .terminal-live-status {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .terminal-font-controls {
        min-width: 0;
        max-width: 100%;
        gap: 0.25em;
      }
      .terminal-font-controls .panel-tool-btn,
      #terminalCloseBtn {
        width: 2em;
        height: 2em;
        min-width: 2em;
        padding: 0;
      }
      .terminal-interaction {
        gap: 0.45em;
        padding: 0.5em;
      }
      .terminal-quick-keys {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.15em;
        scrollbar-width: none;
      }
      .terminal-quick-keys::-webkit-scrollbar { display: none; }
      .terminal-key {
        flex: 0 0 auto;
        min-width: 2.7em;
        height: 2.45em;
        padding: 0 0.7em;
      }
      .terminal-text-send input {
        font-size: 16px;
      }
      .tool-panel-resize-handle,
      .terminal-resize-handle { display: none; }
      .messages { padding: 0.8em 0.9em; gap: 0.9em; }
      .bubble { max-width: calc(100% - 44px); padding: 0.55em 0.75em; font-size: 1em; line-height: 1.45; }
      .topic { grid-template-columns: 2.35em 1fr auto; gap: 0.55em; padding: 0.55em 0.7em; min-height: 0; }
      .avatar { width: 2.35em; height: 2.35em; font-size: 0.86em; }
      .topic-name { font-size: 1em; }
      .topic-sub { font-size: 0.85em; }
      .topic-meta { font-size: 0.78em; }
      .topic-time { font-size: 0.78em; }
      .topic-preview { -webkit-line-clamp: 1; }
      .mobile-order-toggle {
        display: inline-grid;
        place-items: center;
      }
      .app.mobile-order-mode .topic {
        grid-template-columns: 34px minmax(0, 1fr) 36px 40px;
        padding-right: 8px;
      }
      .app.mobile-order-mode .mobile-order-controls {
        display: flex;
      }
      .app.mobile-order-mode .topic-order-handle {
        width: 34px;
        height: 34px;
        font-size: 20px;
      }
      .app.mobile-order-mode .badge {
        justify-self: end;
      }
      .side-head { padding: calc(0.7em + var(--mobile-top-safe-space)) 0.85em 0.7em; }
      .title h1 { font-size: 1.3em; }
      .search { display: none; }
      .status { display: none; }
      .workspace-panel .icon-btn, .workspace-panel .fill-select { height: 2.3em; font-size: 0.8em; }
      .composer { padding: 0.7em 0.85em; }
      .quick-phrase-panel { grid-template-columns: minmax(0, 1fr); }
      .quick-phrase-actions { grid-template-columns: 1fr 1fr; }
      /* MUST stay >= 16px: mobile browsers auto-zoom the whole page when a
         focused input has a smaller font. Focusing the composer on chat entry
         was triggering that zoom — why the chat looked enlarged and needed a
         manual pinch-out, while the list view and other sites stayed fine. */
      .composer textarea { font-size: max(16px, var(--app-font-size)); }
      .toast-stack { left: 8px; right: 8px; }
    }

/* ── Stats modal on phones ──────────────────────────────────────────────────
   Fixed 2026-08-08. The modal card used to be a single `overflow:auto` box, so
   the header scrolled away with the content and the ✕ became unreachable — the
   panel could be opened but not closed. The card is now a flex column with a
   non-scrolling header and an independently scrolling body; on phones it goes
   full-screen and uses dvh so the iOS Safari URL bar cannot clip it. */
@media (max-width: 640px) {
  #statsModal {
    align-items: stretch;
    justify-content: stretch;
  }
  #statsModalCard {
    width: 100%;
    max-width: none;
    max-height: 100%;
    height: 100vh;      /* fallback for browsers without dvh */
    height: 100dvh;
    border: 0;
    border-radius: 0;
    /* Do not rely on env() alone: it resolves to 0 whenever the UA reports no
       inset (or the page is not treated as covering the notch), which puts the
       header back under the status bar. max() guarantees clearance either way. */
    padding: max(env(safe-area-inset-top), 44px) 10px calc(8px + env(safe-area-inset-bottom));
  }
  #statsModalHead {
    background: #0c0e13;
    z-index: 2;
    padding-bottom: 6px;
    min-height: 44px;
  }
  /* Last-resort close affordance. The full-screen card covers the backdrop, so
     the existing tap-outside-to-close path is unreachable on a phone; if the
     top-right ✕ is also hard to hit, this bottom bar always is not. */
  #statsCloseBottom {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    margin-top: 8px;
    padding: 13px 0;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    color: #dfe7e5;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
  }
  #statsContent iframe {
    min-height: 0 !important;   /* let flex decide; avoids double scrollbars */
  }
}
