  /* ================================================================
     Tokens. Warm tinted neutrals + one clay accent (Restrained).
     ================================================================ */
  :root {
    --sidew: 260px;
    --ui: "Vazirmatn", "Noto Sans Arabic", system-ui, sans-serif;
    --mono: "JetBrainsMono NF", "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", monospace;
    --ease: cubic-bezier(.22, 1, .36, 1);
    --r: 8px;

    --bg: oklch(0.985 0.004 70);
    --panel: oklch(0.962 0.006 70);
    --raised: oklch(0.995 0.003 70);
    --hover: oklch(0.925 0.008 70);
    --line: oklch(0.885 0.008 70);
    --line-soft: oklch(0.93 0.006 70);
    --fg: oklch(0.24 0.01 60);
    --muted: oklch(0.5 0.012 60);
    --faint: oklch(0.64 0.01 60);
    --accent: oklch(0.6 0.14 42);
    --accent-fg: oklch(0.985 0.01 60);
    --accent-soft: oklch(0.6 0.14 42 / 0.12);
    --live: oklch(0.64 0.15 150);
    --err: oklch(0.56 0.18 28);
    --code: oklch(0.945 0.006 70);
    --mark: oklch(0.9 0.14 95);
    --shadow: 0 1px 2px oklch(0.2 0.01 60 / .06), 0 8px 24px oklch(0.2 0.01 60 / .10);
    --sb: oklch(0.24 0.01 60 / .18);
    --sb-hover: oklch(0.24 0.01 60 / .34);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: oklch(0.205 0.006 60); --panel: oklch(0.235 0.007 60); --raised: oklch(0.265 0.008 60);
      --hover: oklch(0.285 0.008 60); --line: oklch(0.335 0.008 60); --line-soft: oklch(0.29 0.007 60);
      --fg: oklch(0.93 0.006 70); --muted: oklch(0.72 0.01 70); --faint: oklch(0.57 0.01 70);
      --accent: oklch(0.73 0.13 48); --accent-fg: oklch(0.2 0.02 45); --accent-soft: oklch(0.73 0.13 48 / 0.15);
      --live: oklch(0.75 0.15 150); --err: oklch(0.7 0.16 28); --code: oklch(0.25 0.007 60);
      --mark: oklch(0.55 0.1 95); --shadow: 0 1px 2px oklch(0 0 0 / .3), 0 10px 30px oklch(0 0 0 / .45);
      --sb: oklch(0.93 0.006 70 / .16); --sb-hover: oklch(0.93 0.006 70 / .3);
    }
  }
  :root[data-theme="dark"] {
    --bg: oklch(0.205 0.006 60); --panel: oklch(0.235 0.007 60); --raised: oklch(0.265 0.008 60);
    --hover: oklch(0.285 0.008 60); --line: oklch(0.335 0.008 60); --line-soft: oklch(0.29 0.007 60);
    --fg: oklch(0.93 0.006 70); --muted: oklch(0.72 0.01 70); --faint: oklch(0.57 0.01 70);
    --accent: oklch(0.73 0.13 48); --accent-fg: oklch(0.2 0.02 45); --accent-soft: oklch(0.73 0.13 48 / 0.15);
    --live: oklch(0.75 0.15 150); --err: oklch(0.7 0.16 28); --code: oklch(0.25 0.007 60);
    --mark: oklch(0.55 0.1 95); --shadow: 0 1px 2px oklch(0 0 0 / .3), 0 10px 30px oklch(0 0 0 / .45);
    --sb: oklch(0.93 0.006 70 / .16); --sb-hover: oklch(0.93 0.006 70 / .3);
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body { display: flex; font-family: var(--ui); background: var(--bg); color: var(--fg); overflow: hidden; -webkit-font-smoothing: antialiased; }
  button, input { font: inherit; color: inherit; }
  [hidden] { display: none !important; }
  svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
  ::selection { background: var(--accent-soft); }

  /* Scrollbars: thin, rounded, quiet until hovered */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--sb); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; transition: background-color .2s; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--sb-hover); }
  ::-webkit-scrollbar-corner { background: transparent; }
  .scroll::-webkit-scrollbar { width: 12px; }

  /* ================================================================
     Buttons
     ================================================================ */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r);
    border: 1px solid var(--line); background: var(--raised); cursor: pointer; font-size: 13px; transition: background-color .15s, border-color .15s, color .15s; }
  .btn:hover { background: var(--hover); }
  .btn:active { transform: translateY(.5px); }
  .btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); font-weight: 600; }
  .btn.primary:hover { background: color-mix(in oklch, var(--accent) 88%, var(--fg)); }
  .icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); border: 0; background: none; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s; }
  .icon-btn:hover { background: var(--hover); color: var(--fg); }
  kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); direction: ltr; unicode-bidi: isolate; }

  /* ================================================================
     Sidebar
     ================================================================ */
  #side { position: relative; width: var(--sidew); flex: none; display: flex; flex-direction: column; background: var(--panel); border-inline-end: 1px solid var(--line); min-height: 0; }
  body.collapsed #side { display: none; }
  body.resizing { cursor: col-resize; user-select: none; }
  #resizer { position: absolute; top: 0; bottom: 0; inset-inline-end: -4px; width: 8px; cursor: col-resize; z-index: 6; }
  #resizer::after { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-start: 3px; width: 2px; background: var(--accent); opacity: 0; transition: opacity .15s; }
  #resizer:hover::after, body.resizing #resizer::after { opacity: 1; }

  .side-top { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--hover); gap: 2px; }
  .seg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border: 0; border-radius: 7px; background: none; cursor: pointer; font-size: 13px; color: var(--muted); transition: background-color .15s, color .15s; }
  .seg button.on { background: var(--raised); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px oklch(0 0 0 / .08); }
  .count { font-size: 11px; color: var(--faint); font-weight: 500; }
  .live-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--live); font-weight: 600; }
  .live-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }

  .pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .pane-tools { display: flex; gap: 6px; padding: 0 12px 8px; }
  .pane-tools > .btn:not(.primary) { flex: none; width: 32px; padding: 0; }
  .pane-tools .btn.primary { flex: 1; }
  .field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--raised); color: var(--faint); }
  .field:focus-within { border-color: var(--accent); }
  .field input { flex: 1; width: 100%; min-width: 0; border: 0; background: none; outline: none; font-size: 13px; color: var(--fg); }

  /* page thumbnails */
  #thumbs { list-style: none; margin: 0; padding: 4px 12px 24px; overflow-y: auto; overflow-x: hidden; flex: 1; }
  #thumbs li { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
  #thumbs .n { width: 18px; font-size: 12px; color: var(--faint); padding-top: 4px; text-align: center; font-variant-numeric: tabular-nums; }
  #thumbs .col { position: relative; flex: 1; min-width: 0; }
  #thumbs .thumb { aspect-ratio: 16 / 10; max-height: 150px; overflow: hidden; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; position: relative; transition: border-color .15s, box-shadow .15s; }
  #thumbs li:hover .thumb { border-color: var(--faint); }
  #thumbs li.on .thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  #thumbs li.on .n { color: var(--accent); font-weight: 700; }
  #thumbs li.over .thumb { box-shadow: 0 -3px 0 var(--accent); }
  #thumbs .mini { position: absolute; top: 0; right: 0; transform-origin: top right; pointer-events: none; }
  :root[dir="ltr"] #thumbs .mini { right: auto; left: 0; transform-origin: top left; }
  #thumbs .name { font-size: 12px; padding: 4px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 20px; outline: none; color: var(--muted); }
  #thumbs li.on .name { color: var(--fg); }
  #thumbs .name:empty::before { content: attr(data-ph); color: var(--faint); opacity: 0; transition: opacity .15s; }
  #thumbs li:hover .name:empty::before { opacity: .8; }
  #thumbs .name[contenteditable] { white-space: normal; background: var(--raised); border: 1px solid var(--accent); border-radius: 4px; padding: 2px 6px; color: var(--fg); }
  #thumbs .del { position: absolute; top: 6px; inset-inline-end: 6px; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px;
    background: var(--panel); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s, color .15s; box-shadow: var(--shadow); }
  #thumbs .del svg { width: 14px; height: 14px; }
  #thumbs li:hover .del { opacity: 1; }
  #thumbs .del:hover { color: var(--err); }

  /* session list */
  #sessList { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 0 6px 24px; }
  .proj { margin-bottom: 2px; }
  .proj + .proj { border-top: 1px solid var(--line-soft); padding-top: 2px; }
  .proj-name { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; width: 100%; margin: 4px 0 2px; padding: 7px 8px; border: 0; border-radius: 9px;
    background: var(--panel); color: var(--fg); font: inherit; text-align: start; cursor: pointer; user-select: none; transition: background-color .15s; }
  .proj-name:hover { background: var(--hover); }
  .pj-ava { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-size: 13px; font-weight: 700;
    color: oklch(0.42 0.11 var(--h)); background: oklch(0.92 0.045 var(--h)); }
  :root[data-theme="dark"] .pj-ava:not(.icon) { color: oklch(0.86 0.09 var(--h)); background: oklch(0.34 0.06 var(--h)); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pj-ava:not(.icon) { color: oklch(0.86 0.09 var(--h)); background: oklch(0.34 0.06 var(--h)); } }
  .pj-ava.icon { color: var(--muted); background: var(--hover); }
  .pj-ava svg { width: 15px; height: 15px; }
  .pj-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
  .pj-title, .pj-sub { max-width: 100%; text-align: right; }
  .pj-title { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pj-sub { font-size: 11px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pj-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .pj-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .pj-badge.live { color: var(--live); background: color-mix(in oklch, var(--live) 14%, transparent); }
  .pj-badge.ask { color: var(--accent); background: var(--accent-soft); }
  .pj-chev { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: var(--faint); }
  .pj-chev svg { width: 15px; height: 15px; transition: transform .2s var(--ease); }
  .proj.shut .pj-chev svg { transform: rotate(90deg); }
  :root[dir="ltr"] .proj.shut .pj-chev svg { transform: rotate(-90deg); }
  .proj-name:hover .pj-chev { color: var(--fg); }
  .proj.shut { padding-bottom: 0; }
  .proj.shut .sess, .proj.shut .agents-toggle, .proj.shut .agents, .proj.shut .more-btn { display: none; }
  .more-btn { display: block; margin: 2px 8px 8px; padding: 5px 10px; border: 1px dashed var(--line); border-radius: var(--r); background: none; color: var(--muted); font-size: 12px; cursor: pointer; width: calc(100% - 16px); }
  .more-btn:hover { border-color: var(--accent); color: var(--accent); }
  .sess { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r); cursor: pointer; transition: background-color .12s; }
  .sess:hover { background: var(--hover); }
  .sess.on { background: var(--accent-soft); }
  .sess.on .stt { font-weight: 600; }
  .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; margin-top: 7px; }
  .dot.live { background: var(--live); animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in oklch, var(--live) 22%, transparent); } }
  .st { min-width: 0; flex: 1; }
  .stt { text-align: right; font-size: 13px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .sm { font-size: 11px; color: var(--faint); margin-top: 1px; }
  .sm.live { color: var(--live); font-weight: 600; }
  .empty { color: var(--muted); font-size: 13px; padding: 16px 10px; line-height: 1.8; }
  .skel { height: 44px; margin: 6px 4px; border-radius: var(--r); background: var(--hover); animation: fade 1.2s ease-in-out infinite alternate; }
  .skel:nth-child(2) { animation-delay: .15s; } .skel:nth-child(3) { animation-delay: .3s; } .skel:nth-child(4) { animation-delay: .45s; }
  @keyframes fade { to { opacity: .45; } }

  /* footer */
  .side-foot { display: flex; align-items: center; gap: 2px; padding: 8px 8px; border-top: 1px solid var(--line); }
  .chip { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised);
    font-size: 12px; cursor: pointer; color: var(--muted); transition: border-color .15s, color .15s, background-color .15s; }
  .chip .dot { margin: 0; }
  #srvBtn.on .dot { background: var(--live); }
  #srvBtn:not(.on) .dot { background: var(--err); }
  .chip:hover { border-color: var(--faint); color: var(--fg); }
  .chip .act { display: none; }
  .chip:hover .lbl { display: none; }
  .chip:hover .act { display: inline; }
  #saveState { font-size: 11px; color: var(--faint); margin-inline-start: 6px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
  #saveState.bad { color: var(--err); }

  /* ================================================================
     Main
     ================================================================ */
  #main { flex: 1; position: relative; min-width: 0; }
  .scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }
  .page { font-size: 22px; line-height: 1.7; padding: 40px 48px; overflow-wrap: anywhere; }
  #ed { position: relative; min-height: 100%; outline: none; }
  #ed.blank::before { content: attr(data-ph); position: absolute; color: var(--faint); pointer-events: none; }
  .hints { position: absolute; bottom: 20px; inset-inline-start: 48px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--faint); pointer-events: none; transition: opacity .2s; }
  .hints span { display: inline-flex; gap: 6px; align-items: center; }
  #open { position: fixed; top: 12px; inset-inline-start: 12px; z-index: 5; background: var(--panel); border: 1px solid var(--line); }
  body:not(.collapsed) #open { display: none; }

  /* rich content (editor + session view) */
  .page h1, .page h2, .page h3, .page h4 { line-height: 1.35; margin: 1.1em 0 .45em; }
  .page h1 { font-size: 1.6em; } .page h2 { font-size: 1.35em; } .page h3 { font-size: 1.15em; } .page h4 { font-size: 1em; }
  .page p { margin: .5em 0; }
  .page ul, .page ol { padding-inline-start: 1.4em; margin: .4em 0; }
  .page li { margin: .2em 0; }
  table { border-collapse: collapse; margin: 14px 0; font-size: .82em; line-height: 1.6; }
  td, th { border: 1px solid var(--line); padding: 7px 12px; vertical-align: top; text-align: start; }
  th { background: var(--code); font-weight: 600; }
  code { font-family: var(--mono); background: var(--code); padding: .1em .4em; border-radius: 5px; font-size: .8em; unicode-bidi: isolate; }
  pre { font-family: var(--mono); background: var(--code); padding: 12px 16px; border-radius: var(--r); overflow-x: auto; font-size: 13px; line-height: 1.6; text-align: left; border: 1px solid var(--line-soft); }
  pre code { background: none; padding: 0; font-size: inherit; }
  /* fenced code block: header with language + options, then the code */
  .cb { margin: 12px 0; border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--code); overflow: clip; } /* clip, not hidden: hidden would stop the header from sticking */
  .cb-head { position: sticky; top: var(--pin-h, 0px); z-index: 1; background: var(--code); display: flex; align-items: center; gap: 4px; min-height: 30px; padding: 2px 6px; border-bottom: 1px solid var(--line-soft); }
  .cb-lang { flex: 1; min-width: 0; padding-inline-start: 6px; font: 11px/1 var(--mono); color: var(--faint); text-align: start; unicode-bidi: isolate; }
  .cb-btns { display: flex; gap: 2px; margin-inline-start: auto; }
  .cb-head .icon-btn { width: 26px; height: 26px; }
  .cb-head .icon-btn svg { width: 15px; height: 15px; }
  .cb-head .icon-btn.on { color: var(--accent); background: var(--accent-soft); }
  .cb pre { margin: 0; border: 0; border-radius: 0; background: none; }
  .cb[data-wrap="1"] pre { white-space: pre-wrap; word-break: break-word; }
  .cb[data-wrap="0"] pre { white-space: pre; }
  .cb[data-flip] pre { text-align: start; }
  .cb[data-flip="ltr"] pre, .cb[data-flip="ltr"] pre .cl { direction: ltr; }
  .cb[data-flip="rtl"] pre, .cb[data-flip="rtl"] pre .cl { direction: rtl; }
  /* mostly-Arabic block: wraps instead of scrolling, each line aligns to its own start edge */
  pre.rtl-pre { white-space: pre-wrap; text-align: start; font-family: var(--ui); font-size: 14px; line-height: 1.8; }
  pre.rtl-pre .cl { display: block; }
  blockquote { margin: 10px 0; padding: 6px 16px; background: var(--code); border-radius: var(--r); color: var(--muted); }
  hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
  a { color: var(--accent); text-underline-offset: 3px; }

  /* ================================================================
     Session view
     ================================================================ */
  .phead { flex: none; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--line-soft); padding: 10px 20px; display: flex; gap: 6px; align-items: center; min-width: 0; }
  .vt { min-width: 0; flex: 1; }
  .ptitle { text-align: right; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pmeta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
  .pmeta { white-space: nowrap; overflow: hidden; min-width: 0; }
  .pmeta > * { flex: none; }
  .pmeta .parent-link { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pbody { max-width: var(--vw, 920px); margin-inline: auto; font-size: 17px; line-height: 1.8; padding: 20px 32px 160px; transition: max-width .25s var(--ease); }
  .vskel { margin-inline: auto; max-width: var(--vw, 920px); }
  #widthMenu { position: fixed; z-index: 15; min-width: 190px; padding: 4px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); animation: in .15s var(--ease); }
  #widthMenu button { display: flex; width: 100%; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: none; cursor: pointer; font-size: 13px; text-align: start; }
  #widthMenu button:hover { background: var(--hover); }
  #widthMenu button.on { color: var(--accent); font-weight: 600; }
  #widthMenu .bar { width: 28px; height: 8px; border-radius: 3px; background: var(--line); position: relative; flex: none; }
  #widthMenu .bar i { position: absolute; inset-block: 0; right: 50%; transform: translateX(50%); border-radius: 3px; background: var(--faint); }
  #widthMenu button.on .bar i { background: var(--accent); }
  #widthMenu .k { margin-inline-start: auto; color: var(--faint); font-size: 11px; }

  /* subagents */
  .agents-toggle { display: flex; align-items: center; gap: 6px; margin: -2px 0 4px; padding: 3px 8px; padding-inline: 10px 8px; margin-inline-start: 26px; border: 0; border-radius: 6px; background: none;
    cursor: pointer; font-size: 11.5px; color: var(--muted); }
  .agents-toggle:hover { background: var(--hover); color: var(--fg); }
  .agents-toggle svg { width: 12px; height: 12px; transition: transform .2s var(--ease); }
  .agents-toggle.open svg { transform: rotate(-90deg); }
  /* chevrons: collapsed points the way text runs (left in RTL, right in LTR), open points down */
  :root[dir="ltr"] .chev, :root[dir="ltr"] .agents-toggle svg { transform: rotate(180deg); }
  :root[dir="ltr"] .agents-toggle.open svg, :root[dir="ltr"] details[open] > summary .chev { transform: rotate(270deg); }
  .agents-toggle .live-badge { font-weight: 500; }
  .agents { margin-inline-start: 26px; padding-inline-start: 6px; border-inline-start: 1px solid var(--line); margin-bottom: 4px; }
  .sess.agent { padding: 6px 8px; }
  .sess.agent .stt { font-size: 12.5px; -webkit-line-clamp: 1; }
  .sess.agent .dot { width: 6px; height: 6px; margin-top: 8px; }
  .open-agent { margin-inline-start: auto; flex: none; height: 24px; padding: 0 8px; font-size: 12px; }
  .parent-link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
  .parent-link:hover { text-decoration: underline; }
  .msg { position: relative; margin: 8px 0; min-width: 0; }
  .msg.ai { margin: 16px 0; }
  .msg.ai + .msg.ai { margin-top: 22px; }
  .pbody p { margin: .7em 0; }
  .pl { display: block; } /* one line of a mixed-language paragraph, with its own direction */
  .pbody li { margin: .35em 0; }
  .pbody details.tools { margin: 12px 0; }
  .msg.user + details.tools, details.tools + .msg.ai, .tool-imgs + .msg.ai { margin-top: 18px; }
  /* long unbroken text (JSON, URLs, paths) wraps instead of pushing the page sideways */
  .pbody, .pbody .msg { overflow-wrap: anywhere; }
  .pbody table { display: block; max-width: 100%; overflow-x: auto; }
  .pbody pre { max-width: 100%; }
  .pbody details.tools, .pbody details.tool { min-width: 0; max-width: 100%; }
  .msg > :first-child { margin-top: 0; }
  .msg.user { background: var(--accent-soft); border-radius: 12px; padding: 12px 18px 14px; margin: 40px 0 18px; }
  .msg.user .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  .msg-actions { position: absolute; top: 0; inset-inline-end: 0; display: flex; gap: 2px; padding: 2px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line);
    box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s; }
  .msg.ai:hover .msg-actions { opacity: 1; pointer-events: auto; }
  .msg-actions .icon-btn { width: 28px; height: 28px; }

  details.tools { margin: 6px 0; border-radius: var(--r); font-size: 13px; }
  details.tools > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r); cursor: pointer; color: var(--muted); transition: background-color .12s; }
  details.tools > summary::-webkit-details-marker { display: none; }
  details.tools > summary:hover { background: var(--hover); }
  details.tools[open] > summary { background: var(--hover); }
  .chev { transition: transform .2s var(--ease); }
  details[open] > summary .chev { transform: rotate(-90deg); }
  .g-last { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; color: var(--faint); }
  .g-last b, .t-name { color: var(--fg); font-weight: 600; font-family: var(--mono); font-size: 12px; }
  .tlist { padding: 4px 0 4px; margin-inline-start: 14px; border-inline-start: 1px solid var(--line); }
  details.tool > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 4px 10px; cursor: pointer; border-radius: 6px; color: var(--muted); }
  details.tool > summary::-webkit-details-marker { display: none; }
  details.tool > summary:hover { background: var(--hover); }
  .t-sum { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .st-ico { width: 14px; height: 14px; display: grid; place-items: center; flex: none; }
  .st-ico svg { width: 14px; height: 14px; }
  .ok .st-ico, .st-ico.ok { color: var(--live); }
  .bad .st-ico, .st-ico.bad { color: var(--err); }
  .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  details.tool pre { margin: 4px 10px 10px; font-size: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
  details.tool pre.err { color: var(--err); }
  .note { font-size: 12px; color: var(--faint); margin: 10px 0; }
  .task, details.task > summary { display: flex; align-items: baseline; gap: 8px; }
  .task { margin: 8px 0; font-size: 12.5px; color: var(--muted); }
  details.task { display: block; }
  details.task > summary { cursor: pointer; list-style: none; }
  details.task > summary::-webkit-details-marker { display: none; }
  .task-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transform: translateY(-1px); }
  .task.ok .task-dot { background: var(--live); }
  .task.bad .task-dot { background: var(--err); }
  .task-sum { min-width: 0; overflow-wrap: anywhere; }
  .task-time { flex: none; margin-inline-start: auto; font-size: 11px; color: var(--faint); }
  .task-body { margin: 6px 0 4px; padding-inline-start: 15px; font-size: 13px; color: var(--fg); }
  .divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 28px 0; }
  .divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
  .imgs { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 10px 0 4px; }
  .imgs .shot { display: block; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--code); cursor: zoom-in; transition: border-color .15s, transform .15s var(--ease); }
  .imgs .shot:hover { border-color: var(--accent); }
  /* the frame caps the width, the image fills it: a % max-width on the img made the frame as wide as the message */
  .imgs .shot { max-width: min(100%, 440px); }
  .imgs img { display: block; max-height: 240px; max-width: 100%; width: auto; height: auto; }
  .tool-imgs { margin: 2px 0 12px; padding-inline-start: 14px; }
  /* image viewer */
  #lightbox { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: oklch(0.13 0.008 60 / .94); color: oklch(0.93 0.005 70); animation: in .15s var(--ease); }
  .lb-top { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
  .lb-count { font-variant-numeric: tabular-nums; font-size: 13px; opacity: .8; }
  .lb-title { flex: 1; min-width: 0; font-size: 12.5px; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-tools { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: oklch(1 0 0 / .07); }
  .lb-btn { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 7px; background: none; color: inherit; cursor: pointer; font: inherit; font-size: 12px; text-decoration: none; }
  .lb-btn:hover { background: oklch(1 0 0 / .12); }
  .lb-btn.on { background: oklch(1 0 0 / .18); }
  .lb-btn svg { width: 16px; height: 16px; }
  .lb-zoom { min-width: 54px; font-variant-numeric: tabular-nums; }
  .lb-sep { width: 1px; height: 18px; background: oklch(1 0 0 / .18); margin: 0 4px; }
  .lb-main { flex: 1; min-height: 0; display: flex; }
  .lb-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; cursor: grab; touch-action: none; direction: ltr; /* pan/zoom math is in screen pixels */
    background-image: conic-gradient(oklch(1 0 0 / .05) 25%, transparent 0 50%, oklch(1 0 0 / .05) 0 75%, transparent 0); background-size: 20px 20px; }
  .lb-stage.dragging { cursor: grabbing; }
  #lbImg { position: absolute; top: 0; left: 0; transform-origin: 0 0; max-width: none; box-shadow: 0 6px 30px oklch(0 0 0 / .5); user-select: none; }
  #lbImg.pixel { image-rendering: pixelated; }
  #lbImg.animating { transition: transform .2s var(--ease); }
  .lb-info { flex: none; width: 270px; overflow-y: auto; padding: 14px 16px; border-inline-start: 1px solid oklch(1 0 0 / .1); font-size: 12.5px; }
  .lb-info h4 { margin: 0 0 10px; font-size: 13px; }
  .lb-info dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 12px; margin: 0; }
  .lb-info dt { opacity: .6; }
  .lb-info dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .lb-info .mono { font-family: var(--mono); font-size: 11.5px; }
  /* previous sits at the start edge, next at the end edge: in Arabic next is on the left, in English on the right */
  .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; border-radius: 50%; background: oklch(1 0 0 / .1); color: inherit; cursor: pointer; display: grid; place-items: center; }
  .lb-nav:hover { background: oklch(1 0 0 / .2); }
  .lb-nav svg { width: 20px; height: 20px; }
  .lb-prev { inset-inline-start: 16px; } .lb-next { inset-inline-end: 16px; }
  #lightbox.info .lb-next { inset-inline-end: 286px; } /* clear of the properties panel (270px + gap) */
  :root[dir="ltr"] .lb-nav svg { transform: scaleX(-1); } /* the markup draws the arrows for RTL */
  #lightbox.single .lb-nav, #lightbox.single .lb-strip { display: none; }
  /* thumbnails: auto margins center a short strip, but a long one starts at its edge so every item stays reachable
     (justify-content: center clips the start of an overflowing flex row) */
  .lb-strip { flex: none; display: flex; justify-content: flex-start; gap: 6px; padding: 8px 14px 6px; overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth; }
  .lb-strip > :first-child { margin-inline-start: auto; }
  .lb-strip > :last-child { margin-inline-end: auto; }
  .lb-strip::-webkit-scrollbar { height: 6px; }
  .lb-strip::-webkit-scrollbar-thumb { background: oklch(1 0 0 / .2); border-width: 1px; }
  .lb-strip button { flex: none; width: 54px; height: 40px; padding: 0; border: 2px solid transparent; border-radius: 6px; background: oklch(1 0 0 / .06); cursor: pointer; overflow: hidden; opacity: .55; transition: opacity .15s, transform .15s var(--ease), border-color .15s; }
  .lb-strip button.on { border-color: var(--accent); opacity: 1; transform: translateY(-2px); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 35%, transparent); }
  .lb-peek { position: fixed; z-index: 45; width: 340px; padding: 6px; border-radius: 12px; background: oklch(0.22 0.008 60); border: 1px solid oklch(1 0 0 / .14);
    box-shadow: 0 12px 40px oklch(0 0 0 / .55); pointer-events: none; animation: peekIn .12s var(--ease); }
  @keyframes peekIn { from { opacity: 0; transform: translateY(6px); } }
  .lb-peek img { display: block; width: 100%; max-height: 230px; object-fit: contain; border-radius: 7px; background: oklch(1 0 0 / .05); }
  .lb-peek-cap { display: flex; gap: 8px; align-items: baseline; padding: 6px 4px 2px; font-size: 12px; color: oklch(0.93 0.005 70); }
  .lb-peek-cap b, .lb-count { flex: none; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; } /* "7 / 55", not "55 / 7" in RTL */
  .lb-peek-cap span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .7; }
  .lb-peek.is-current { border-color: var(--accent); }
  .lb-strip button:hover { opacity: 1; }
  .lb-strip img { width: 100%; height: 100%; object-fit: contain; }
  .lb-hint { flex: none; text-align: center; font-size: 11px; opacity: .5; padding: 2px 14px 8px; }
  /* diffs */
  .diff { margin: 4px 10px 10px; border: 1px solid var(--line-soft); border-radius: var(--r); overflow: auto; max-height: 520px; font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--code); text-align: left; }
  .diff .df-file { position: sticky; top: 0; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11.5px; }
  .diff .dl { display: flex; white-space: pre-wrap; word-break: break-word; padding: 0 10px 0 0; }
  .diff .dl .sg { flex: none; width: 22px; text-align: center; color: var(--faint); user-select: none; }
  .diff .dl.add { background: oklch(0.72 0.14 150 / .16); }
  .diff .dl.add .sg { color: var(--live); }
  .diff .dl.del { background: oklch(0.65 0.17 28 / .14); }
  .diff .dl.del .sg { color: var(--err); }
  .diff .dl.gap { color: var(--faint); font-style: italic; padding: 2px 32px; }
  .diff .df-sep { border-top: 1px dashed var(--line); margin: 4px 0; }
  .stat { font-family: var(--mono); font-size: 11px; flex: none; }
  .stat .a { color: var(--live); } .stat .d { color: var(--err); }

  /* pinned plan / todos */
  .ppin { position: sticky; top: 0; z-index: 1; margin: 0 auto; max-width: var(--vw, 920px); padding: 8px 32px 0; }
  .ppin details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px oklch(0 0 0 / .05); }
  .ppin summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
  .ppin summary::-webkit-details-marker { display: none; }
  .ppin .pin-k { font-weight: 700; }
  .ppin .pin-now { color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
  .ppin .pin-body { max-height: 45vh; overflow-y: auto; padding: 4px 16px 12px; border-top: 1px solid var(--line-soft); font-size: 14px; line-height: 1.7; }
  .ppin .pbar { width: 70px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
  .ppin .pbar i { display: block; height: 100%; background: var(--live); }
  .todo { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
  .todo .ti { flex: none; width: 16px; height: 16px; margin-top: 4px; display: grid; place-items: center; }
  .todo .ti svg { width: 14px; height: 14px; }
  .todo.completed { color: var(--faint); text-decoration: line-through; }
  .todo.completed .ti { color: var(--live); }
  .todo.in_progress { font-weight: 600; }
  .todo .ring { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--faint); }

  .ask-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--accent); }
  .ask-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  #notifyBtn.on { color: var(--accent); }
  /* plan usage: gauge button with the highest percentage, and a popover with both limits */
  .usage-btn { width: auto !important; min-width: 28px; padding: 0 6px; gap: 4px; display: inline-flex; align-items: center; }
  .usage-btn[hidden] { display: none; }
  .usage-btn .up { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .usage-btn.warn, .usage-btn.warn .up { color: oklch(0.68 0.15 75); }
  .usage-btn.crit, .usage-btn.crit .up { color: var(--err); }
  #usageMenu { position: fixed; z-index: 15; width: 300px; max-width: calc(100vw - 16px); padding: 12px 14px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); animation: in .15s var(--ease); font-size: 12.5px; }
  .u-row + .u-row { margin-top: 12px; }
  .u-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; }
  .u-pct { font-variant-numeric: tabular-nums; }
  .u-bar { height: 8px; margin: 6px 0 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
  .u-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--live); transition: width .3s var(--ease); }
  .u-row.warn .u-bar i { background: oklch(0.72 0.15 75); }
  .u-row.crit .u-bar i { background: var(--err); }
  .u-reset { color: var(--muted); font-size: 12px; }
  .u-foot { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11.5px; line-height: 1.5; }
  .u-foot code { direction: ltr; }


  .pjump { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 4; box-shadow: var(--shadow); border-radius: 999px; }
  /* ---------- split panes ---------- */
  /* columns come from JS (--cols); once they are full the next panes wrap to a new row, each row as tall as the
     view, and the whole area scrolls down */
  #panes { position: absolute; inset: 0; display: flex; flex-direction: column; }
  #pgrids { position: relative; flex: 1; min-height: 0; }
  /* one grid per tab (a row of columns); the ones not shown keep their layout and scroll positions but cannot be
     seen or hit. A column is a stack of panes, each at least 440px high: more than fit makes the tab scroll down */
  .pgrid { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, 1fr);
    grid-template-rows: minmax(100%, auto); gap: 1px; background: var(--line); overflow: auto; overscroll-behavior: contain; }
  .pgrid:not(.cur) { visibility: hidden; pointer-events: none; }
  .pcol { display: flex; flex-direction: column; gap: 1px; min-width: 0; background: var(--line); }
  .pcol > .pane-v { flex: 1 1 0; min-height: 440px; }
  /* tabs: one session (or one split layout) each */
  #tabbar { flex: none; display: flex; align-items: stretch; gap: 2px; padding: 6px 8px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  #tabbar::-webkit-scrollbar { display: none; }
  .vtab { position: relative; flex: 0 1 200px; min-width: 96px; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 6px 0 10px; border: 1px solid transparent; border-bottom: 0;
    border-radius: 8px 8px 0 0; color: var(--muted); font-size: 12.5px; cursor: pointer; user-select: none; }
  .vtab:hover { background: var(--hover); color: var(--fg); }
  .vtab.cur { background: var(--bg); border-color: var(--line); color: var(--fg); font-weight: 600; margin-bottom: -1px; height: 33px; }
  .vtab .dot { flex: none; }
  .vt-t { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .vt-n, .vt-x { margin-inline-start: auto; }
  .vt-n + .vt-x { margin-inline-start: 0; }
  .vt-n { flex: none; font-size: 10.5px; padding: 0 5px; border-radius: 8px; background: var(--raised); color: var(--muted); font-variant-numeric: tabular-nums; }
  .vt-x, .vtab-add { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 5px; background: none; color: var(--faint); cursor: pointer; padding: 0; }
  .vt-x svg, .vtab-add svg { width: 12px; height: 12px; }
  .vt-x:hover, .vtab-add:hover { background: var(--raised); color: var(--fg); }
  .vtab-add { align-self: center; width: 26px; height: 26px; margin-inline-start: 2px; }
  .vtab.dragging { opacity: .45; }
  .vtab.drop-before::before, .vtab.drop-after::after { content: ''; position: absolute; inset-block: 4px; width: 3px; border-radius: 2px; background: var(--accent); }
  .vtab.drop-before::before { inset-inline-start: -2px; }
  .vtab.drop-after::after { inset-inline-end: -2px; }
  .pane-v { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
  /* drag a pane by its header to move it: a bar marks where it will land */
  .phead { cursor: grab; }
  .phead button, .phead input { cursor: pointer; }
  .pane-v.dragging { opacity: .45; }
  /* where a dragged pane lands: the half of the pane it would take is tinted */
  .pane-v[class*="drop-"]::after { content: ''; position: absolute; z-index: 30; pointer-events: none; background: color-mix(in oklch, var(--accent) 22%, transparent);
    border: 2px solid var(--accent); }
  .pane-v.drop-l::after { inset-block: 0; left: 0; right: 50%; }
  .pane-v.drop-r::after { inset-block: 0; left: 50%; right: 0; }
  .pane-v.drop-t::after { inset: 0 0 50% 0; }
  .pane-v.drop-b::after { inset: 50% 0 0 0; }
  .pane-v.active .phead { box-shadow: inset 0 -2px 0 var(--accent); }
  .pmain { flex: 1; min-height: 0; display: flex; }
  /* session info panel */
  .psum { color: var(--muted); font-variant-numeric: tabular-nums; }
  .psum::before { content: '·'; margin-inline-end: 8px; color: var(--faint); }
  .phead [data-a="info"].on { color: var(--accent); background: var(--accent-soft); }
  .pinfo { flex: none; max-height: 42vh; overflow-y: auto; border-bottom: 1px solid var(--line-soft); background: var(--panel); padding: 10px 20px 12px; font-size: 12.5px; }
  .info-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: baseline; }
  .ii { display: contents; }
  .ik { color: var(--muted); font-size: 12px; white-space: nowrap; }
  .iv { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; align-items: baseline; }
  .iv small { color: var(--faint); font-size: 11px; }
  .iv b { font-variant-numeric: tabular-nums; }
  .ichip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--hover); font-size: 11.5px; white-space: nowrap; }
  .ichip.mono, .mono { font-family: var(--mono); font-size: 11px; }
  .ichip.ok { color: var(--live); } .ichip.live { color: var(--live); background: color-mix(in oklch, var(--live) 12%, transparent); } .ichip.bad { color: var(--err); }
  .ipath { font-family: var(--mono); font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
  .icopy { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; }
  .icopy:hover { background: var(--hover); color: var(--fg); }
  .icopy svg { width: 13px; height: 13px; }
  .itools { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; margin-top: 2px; }
  .ifiles { display: flex; flex-direction: column; gap: 2px; width: 100%; }
  .ifile { display: flex; align-items: baseline; gap: 8px; padding: 3px 6px; border: 0; border-radius: 5px; background: none; color: var(--fg); cursor: pointer; text-align: start; min-width: 0; }
  .ifile:hover { background: var(--hover); }
  .ifile small { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .ifile b { color: var(--muted); font-size: 11px; margin-inline-start: auto; }
  .imeter { position: relative; width: 140px; height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; align-self: center; }
  .imeter i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: var(--live); }
  .imeter.mid i { background: oklch(0.72 0.15 75); } .imeter.high i { background: var(--err); }
  .igit { display: grid; grid-template-columns: minmax(0, max-content); justify-content: start; gap: 1px; width: 100%; margin-top: 2px; font-family: var(--mono); font-size: 11px; }
  .igit div { display: flex; gap: 8px; min-width: 0; max-width: 100%; padding: 1px 6px; direction: ltr; }
  .igit b { flex: none; width: 2ch; font-weight: 600; }
  .igit span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .igit .gM b { color: oklch(0.66 0.14 75); } .igit .gA b { color: var(--live); } .igit .gD b { color: var(--err); } .igit .gQ b { color: var(--faint); }
  .ichip.warn { color: oklch(0.6 0.15 65); background: color-mix(in oklch, oklch(0.72 0.15 75) 14%, transparent); }
  .pgrid[data-cols="3"] .pinfo, .pgrid[data-cols="4"] .pinfo { padding-inline: 12px; }
  .pgrid[data-cols="3"] .info-grid, .pgrid[data-cols="4"] .info-grid { grid-template-columns: 1fr; gap: 2px; }
  .pgrid[data-cols="3"] .ik, .pgrid[data-cols="4"] .ik { margin-top: 6px; }
  .pgrid[data-cols="3"] .psum, .pgrid[data-cols="4"] .psum { display: none; }
  /* in-session search */
  .psearch { flex: none; border-bottom: 1px solid var(--line-soft); background: var(--panel); }
  .ps-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 16px; }
  .ps-field { flex: 1 1 200px; height: 30px; }
  .ps-field.bad { border-color: var(--err); }
  .ps-field.pending svg { animation: fade .6s ease-in-out infinite alternate; color: var(--accent); }
  .ps-count { font-size: 12px; color: var(--muted); min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .ps-row .icon-btn { width: 28px; height: 28px; }
  .ps-row .icon-btn.on { color: var(--accent); background: var(--accent-soft); }
  .ps-sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
  .ps-opt { height: 26px; min-width: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-family: var(--mono); font-size: 12px; direction: ltr; }
  .ps-opt:hover { background: var(--hover); color: var(--fg); }
  .ps-opt.on { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 40%, transparent); }
  .ps-dd { height: 28px; }
  .ps-list { max-height: 38vh; overflow-y: auto; overflow-x: hidden; border-top: 1px solid var(--line-soft); padding: 4px 8px 8px; }
  .ps-item { display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: start; font-size: 12.5px; color: var(--fg); }
  .ps-item:hover { background: var(--hover); }
  .ps-item.cur { background: var(--accent-soft); }
  .ps-kind { flex: none; min-width: 54px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
  .ps-snip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  .ps-snip b { color: var(--fg); background: var(--mark); border-radius: 2px; font-weight: 600; }
  .ps-empty { font-size: 12px; color: var(--faint); padding: 8px; }
  ::highlight(pad-hit) { background-color: var(--mark); color: inherit; }
  ::highlight(pad-cur) { background-color: var(--accent); color: var(--accent-fg); }
  .msg.flash { animation: flash 1.2s var(--ease); }
  @keyframes flash {
    0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 55%, transparent); }
    25% { box-shadow: 0 0 0 6px color-mix(in oklch, var(--accent) 30%, transparent); }
    100% { box-shadow: 0 0 0 14px transparent; }
  }
  @keyframes pop { 0% { box-shadow: 0 0 0 7px color-mix(in oklch, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent) 35%, transparent); } }
  .rail-nav .icon-btn:active, .rail-item:active { transform: scale(.92); }
  .rail-nav .icon-btn, .rail-item { transition: background-color .15s, color .15s, transform .12s var(--ease); }
  .rail-item.cur { transition: background-color .25s var(--ease), color .25s, border-color .25s; }
  .rail-item.has-hit { position: relative; }
  .rail-item.has-hit::after { content: ''; position: absolute; top: 4px; inset-inline-end: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--mark); box-shadow: 0 0 0 1px var(--accent); }
  .pscroll { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; }
  /* titles align to the UI edge even when the text sets its own dir (an English title in the Arabic UI) */
  :root[dir="ltr"] .pj-title, :root[dir="ltr"] .pj-sub, :root[dir="ltr"] .stt, :root[dir="ltr"] .ptitle { text-align: left; }
  /* message rail (at the end edge: left in RTL): your prompts in order */
  .prail { flex: none; width: 48px; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-inline-start: 1px solid var(--line-soft); transition: width .2s var(--ease); }
  .prail.wide { width: 260px; }
  .rail-nav { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
  .prail.wide .rail-nav { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .rail-nav .icon-btn { width: 30px; height: 28px; }
  .rail-count { font-size: 11px; color: var(--faint); text-align: center; padding: 10px 4px 6px; line-height: 1.3; white-space: nowrap; overflow: hidden; }
  .rail-count b { font-size: 12px; color: var(--muted); }
  .rail-count .rc-w { display: none; }
  .prail.wide .rail-count { text-align: start; padding-inline: 14px; }
  .prail.wide .rail-count .rc-w { display: inline; }
  .rail-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 6px 6px 24px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
  .rail-list::-webkit-scrollbar { width: 6px; }
  .rail-list::-webkit-scrollbar-thumb { border-width: 1px; }
  /* narrow rail: no scrollbar at all (wheel / drag still scroll); soft fades show there is more */
  .prail:not(.wide) .rail-list::-webkit-scrollbar,
  .pgrid[data-cols="3"] .rail-list::-webkit-scrollbar, .pgrid[data-cols="4"] .rail-list::-webkit-scrollbar { width: 0; display: none; }
  .rail-list.fade-top { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px); mask-image: linear-gradient(to bottom, transparent 0, #000 28px); }
  .rail-list.fade-bottom { -webkit-mask-image: linear-gradient(to top, transparent 0, #000 28px); mask-image: linear-gradient(to top, transparent 0, #000 28px); }
  .rail-list.fade-top.fade-bottom { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%); }
  /* narrow rail: a quiet timeline of numbered stops */
  .prail:not(.wide) .rail-list { align-items: center; gap: 2px; }
  .prail:not(.wide) .rail-item { width: 36px; min-height: 28px; border-radius: 8px; }
  .prail:not(.wide) .rail-item .ri-n { min-width: 26px; height: 24px; border-radius: 7px; color: var(--faint); font-weight: 500; }
  .prail:not(.wide) .rail-item:hover .ri-n { color: var(--fg); }
  .prail:not(.wide) .rail-item.cur { background: none; border-color: transparent; }
  .prail:not(.wide) .rail-item.cur .ri-n { color: var(--accent-fg); font-weight: 700; box-shadow: 0 2px 6px color-mix(in oklch, var(--accent) 35%, transparent); }
  .prail:not(.wide) .rail-item:not(.cur):hover { background: var(--hover); }
  .rail-count .rc-cap { display: block; font-size: 9.5px; color: var(--faint); margin-top: 1px; }
  .prail.wide .rail-count .rc-cap { display: none; }
  :root[dir="ltr"] .rail-count .rc-cap { font-size: 8.5px; } /* "messages" is wider than the Arabic word */
  /* flex: none so long lists scroll instead of squeezing items into each other */
  .rail-item { flex: none; position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 32px; padding: 0;
    border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; color: var(--muted); font-size: 12px; text-align: start; }
  .rail-item:hover { background: var(--hover); color: var(--fg); }
  .rail-item.cur { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 30%, transparent); }
  .ri-n { flex: none; display: grid; place-items: center; min-width: 24px; height: 22px; padding: 0 4px; border-radius: 6px; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 11.5px; }
  .rail-item.cur .ri-n { background: var(--accent); color: var(--accent-fg); }
  .ri-body { display: none; }
  .prail.wide .rail-item { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: start; padding: 10px; padding-inline: 10px 12px; }
  .prail.wide .ri-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .ri-t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; font-size: 12.5px; color: var(--fg); overflow-wrap: anywhere; }
  .rail-item.cur .ri-t { color: var(--fg); font-weight: 500; }
  .ri-time { font-size: 10.5px; color: var(--faint); }
  .rail-wide { margin-top: 2px; }
  /* in 3-4 columns the rail stays narrow so the text keeps its room */
  .pgrid[data-cols="3"] .prail.wide, .pgrid[data-cols="4"] .prail.wide { width: 48px; }
  .pgrid[data-cols="3"] .prail.wide .rail-nav, .pgrid[data-cols="4"] .prail.wide .rail-nav { flex-direction: column; }
  .pgrid[data-cols="3"] .prail .ri-body, .pgrid[data-cols="4"] .prail .ri-body { display: none; }
  .pgrid[data-cols="3"] .rail-count .rc-w, .pgrid[data-cols="4"] .rail-count .rc-w { display: none; }
  .pgrid[data-cols="3"] .rail-wide, .pgrid[data-cols="4"] .rail-wide { display: none; }
  .pgrid[data-cols="3"] .prail.wide .rail-item, .pgrid[data-cols="4"] .prail.wide .rail-item { display: flex; justify-content: center; padding: 0; align-items: center; width: 36px; }
  .pgrid[data-cols="3"] .prail.wide .rail-list, .pgrid[data-cols="4"] .prail.wide .rail-list { align-items: center; }
  .pgrid[data-cols="3"] .prail.wide .rail-count, .pgrid[data-cols="4"] .prail.wide .rail-count { text-align: center; padding-inline: 4px; }
  .pagents { flex: none; display: flex; gap: 6px; align-items: center; padding: 6px 20px; border-bottom: 1px solid var(--line-soft); background: var(--panel); overflow-x: auto; }
  .pagents::-webkit-scrollbar { height: 6px; }
  .pagents::-webkit-scrollbar-thumb { border-width: 1px; }
  .pa-label { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--fg); margin-inline-end: 6px; }
  .pa-count { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .pa-count.live { color: var(--live); background: color-mix(in oklch, var(--live) 14%, transparent); }
  .pa-count.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: pulse 2s ease-in-out infinite; }
  .pa-count.done { color: var(--muted); background: var(--hover); }
  .pa-sep { flex: none; width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
  .chip.pa { height: 28px; padding: 0 10px; font-size: 12px; gap: 7px; max-width: 260px; color: var(--fg); }
  .chip.pa svg { width: 12px; height: 12px; flex: none; }
  .chip.pa .pa-st { flex: none; display: grid; place-items: center; width: 14px; height: 14px; }
  .chip.pa .pa-st .dot { margin: 0; width: 7px; height: 7px; }
  .chip.pa .pa-type { flex: none; font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
  .chip.pa.live { border-color: color-mix(in oklch, var(--live) 45%, var(--line)); background: color-mix(in oklch, var(--live) 8%, var(--raised)); }
  .chip.pa.done { color: var(--muted); }
  .chip.pa.done .pa-st { color: var(--live); }
  .chip.pa.stopped .pa-st .dot { background: var(--faint); }
  .chip.pa.stopped { color: var(--muted); }
  .chip.pa.busy { border-color: color-mix(in oklch, var(--live) 45%, var(--line)); background: color-mix(in oklch, var(--live) 8%, var(--raised)); }
  .chip.pa .spin { width: 10px; height: 10px; border-width: 1.5px; border-top-color: var(--live); }
  .chip.pa.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); color: var(--fg); }
  .chip.pa.parent { color: var(--accent); }
  .pbg { flex: none; display: flex; gap: 6px; align-items: center; padding: 6px 20px; border-bottom: 1px solid var(--line-soft); background: var(--panel); overflow-x: auto; }
  .pbg::-webkit-scrollbar { height: 6px; }
  .pbg::-webkit-scrollbar-thumb { border-width: 1px; }
  .chip.pa.bgc.running { border-color: color-mix(in oklch, var(--live) 45%, var(--line)); background: color-mix(in oklch, var(--live) 8%, var(--raised)); }
  .chip.pa.bgc.running .spin { width: 10px; height: 10px; border-width: 1.5px; border-top-color: var(--live); }
  .chip.pa.bgc.failed { color: var(--fg); } .chip.pa.bgc.failed .pa-st { color: var(--err); }
  .chip.pa.bgc.stopped { color: var(--muted); } .chip.pa.bgc.stopped .pa-st .dot { background: var(--faint); }
  .pbg-view { flex: none; max-height: 46vh; overflow-y: auto; border-bottom: 1px solid var(--line-soft); background: var(--panel); padding: 8px 20px 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 10px; }
  .bgv-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .bgv-st { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
  .bgv-st b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bgv-meta { flex: 1; min-width: 0; color: var(--faint); font-size: 11px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bgv-k { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; margin-bottom: 4px; }
  .bgv-om { font-weight: 400; color: var(--faint); margin-inline-start: auto; }
  .bgv-cmd, .bgv-out, .bgv-ev { margin: 0; padding: 8px 10px; border-radius: var(--r); background: var(--code); border: 1px solid var(--line-soft); font: 11.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; overflow: auto; }
  .bgv-cmd { max-height: 120px; }
  .bgv-ev { max-height: 90px; }
  .bgv-out { max-height: 280px; min-height: 40px; }
  .bgv-out.none { color: var(--faint); font-family: var(--ui); }
  .bgv-note { padding: 10px 12px; border-radius: var(--r); background: var(--hover); border: 1px solid var(--line-soft); line-height: 1.6; }
  .bgv-note p { margin: 0 0 6px; }
  .bgv-dir { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .bgv-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
  .bgv-actions small { color: var(--faint); }
  .u-note { margin: 0 0 6px; line-height: 1.6; } small.u-note { display: block; margin: 8px 0 0; color: var(--faint); }
  .bgv-files { display: flex; flex-direction: column; gap: 2px; }
  .bgp { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .bgp b { flex: none; min-width: 52px; font-size: 10.5px; font-weight: 700; color: var(--muted); }
  .bgp.w b { color: var(--err); } .bgp.r b { color: var(--live); }
  .bgv-file { display: flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--faint); min-width: 0; }
  .pgrid[data-cols="3"] .pbg, .pgrid[data-cols="4"] .pbg, .pgrid[data-cols="3"] .pbg-view, .pgrid[data-cols="4"] .pbg-view { padding-inline: 12px; }
  .pagents.open, .pbg.open { flex-wrap: wrap; align-content: flex-start; max-height: 34vh; overflow-x: hidden; overflow-y: auto; }
  button.pa-count { border: 0; cursor: pointer; font-family: inherit; }
  button.pa-count:hover { filter: brightness(.95); }
  button.pa-count.on { box-shadow: inset 0 0 0 1.5px var(--accent); }
  .sx-tools { flex: none; display: inline-flex; align-items: center; gap: 2px; }
  .sx-field { display: flex; align-items: center; height: 26px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); }
  .sx-field:focus-within { border-color: var(--accent); }
  .sx-q { width: 120px; border: 0; background: none; outline: none; font-size: 12px; color: var(--fg); }
  .sx-toggle { width: 26px; height: 26px; } .sx-toggle svg { width: 14px; height: 14px; } .sx-toggle.on { color: var(--accent); }
  .chip.pa.more { color: var(--accent); border-style: dashed; }
  .sx-none { color: var(--faint); font-size: 12px; padding: 0 6px; }
  .pa-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .vempty-in { color: var(--muted); font-size: 14px; padding: 24px 0; }
  .vempty-in .quick { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
  .vempty-in .quick button { justify-content: flex-start; height: auto; padding: 8px 12px; text-align: start; }
  /* denser text when several panes share the screen */
  .pgrid[data-cols="2"] .pbody { font-size: 16px; padding: 16px 22px 140px; }
  .pgrid[data-cols="3"] .pbody, .pgrid[data-cols="4"] .pbody { font-size: 14.5px; line-height: 1.7; padding: 14px 16px 120px; }
  .pgrid[data-cols="3"] .phead, .pgrid[data-cols="4"] .phead, .pgrid[data-cols="3"] .pagents, .pgrid[data-cols="4"] .pagents { padding-inline: 12px; }
  .pgrid[data-cols="3"] .ppin, .pgrid[data-cols="4"] .ppin { padding-inline: 12px; }
  .pgrid[data-cols="3"] .phead [data-a="width"], .pgrid[data-cols="4"] .phead [data-a="width"] { display: none; }
  /* open-in-new-pane button on sidebar rows */
  .sess { position: relative; }
  .row-acts { position: absolute; top: 6px; inset-inline-end: 6px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
  .sess:hover .row-acts, .sess:focus-within .row-acts { opacity: 1; }
  .split-btn, .pin-btn { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: var(--raised); color: var(--muted);
    cursor: pointer; transition: color .15s; box-shadow: 0 1px 3px oklch(0 0 0 / .12); }
  .split-btn svg, .pin-btn svg { width: 14px; height: 14px; }
  .split-btn:hover, .pin-btn:hover, .pin-btn.on { color: var(--accent); }
  .sess.pinned .row-acts { opacity: 1; }
  .sess.pinned .row-acts .split-btn { display: none; }
  .sess.pinned:hover .row-acts .split-btn { display: grid; }
  .sess.pinned .pin-btn { background: none; box-shadow: none; }
  .sm-proj { color: var(--muted); }
  .proj-name.static { cursor: default; }
  .proj-name.static:hover { background: var(--panel); }
  .pinned-group .pj-ava.icon { color: var(--accent); background: var(--accent-soft); }
  /* quick filters */
  #groupBy, #foldAll { flex: none; width: 32px; padding: 0; }
  #groupBy.on { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 45%, transparent); background: var(--accent-soft); }
  .sess-filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 6px; }
  .date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 0 12px 8px; }
  .date-sel { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--raised); color: var(--muted); }
  .date-sel svg { width: 14px; height: 14px; flex: none; }
  /* custom dropdowns */
  .dd-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
  .dd-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0; padding-inline: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--raised);
    color: var(--fg); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background-color .15s; }
  .dd-btn:hover { border-color: var(--faint); }
  .dd-btn.open { border-color: var(--accent); }
  .dd-caret { width: 14px; height: 14px; color: var(--muted); transition: transform .2s var(--ease); }
  .dd-btn.open .dd-caret { transform: rotate(180deg); }
  .date-sel .dd-btn { height: 26px; border: 0; background: none; padding: 0 4px; }
  .date-sel.on .dd-btn { color: var(--accent); font-weight: 600; }
  .date-sel.on .dd-caret { color: var(--accent); }
  .dd-menu { position: fixed; z-index: 50; max-height: min(340px, 60vh); overflow-y: auto; padding: 4px; border-radius: 10px; background: var(--raised);
    border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; animation: ddIn .14s var(--ease); }
  @keyframes ddIn { from { opacity: 0; transform: translateY(-4px); } }
  .dd-menu::-webkit-scrollbar { width: 6px; }
  .dd-menu::-webkit-scrollbar-thumb { border-width: 1px; }
  .dd-opt { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 32px; padding: 0 10px; border-radius: 7px; cursor: pointer; color: var(--fg); }
  .dd-opt.act { background: var(--hover); }
  .dd-opt.sel { color: var(--accent); font-weight: 600; }
  .dd-opt.sel.act { background: var(--accent-soft); }
  .dd-check { width: 14px; height: 14px; flex: none; opacity: 0; }
  .dd-opt.sel .dd-check { opacity: 1; }
  .dd-group { padding: 8px 10px 4px; font-size: 11px; color: var(--faint); font-weight: 600; }
  .dd-group:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
  .date-sel.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
  .date-custom { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 11px; color: var(--faint); }
  .date-custom input { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); color: var(--fg); font: inherit; font-size: 12px; padding: 0 6px; max-width: 132px; color-scheme: light dark; }
  .date-clear { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
  .date-clear:hover { background: var(--hover); color: var(--err); }
  .date-clear svg { width: 14px; height: 14px; }
  .qf { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised);
    color: var(--muted); font-size: 12px; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
  .qf:hover { color: var(--fg); border-color: var(--faint); }
  .qf.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
  .qf-n { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .85; }
  .qf.has-live:not(.on) .qf-n { color: var(--live); font-weight: 700; opacity: 1; }
  .qf.has-ask:not(.on) .qf-n { color: var(--accent); font-weight: 700; opacity: 1; }
  .sess.on:not(.act) { background: color-mix(in oklch, var(--accent-soft) 55%, transparent); }
  .t-name { flex: none; }
  .side-foot .icon-btn { width: 28px; height: 28px; }
  #langBtn { font-size: 12px; font-weight: 700; }
  .side-foot .chip { padding: 0 8px; gap: 5px; }
  /* a narrow sidebar: the status chip gives up its label first, then the buttons wrap to a second row */
  .side-foot { flex-wrap: wrap; row-gap: 4px; min-width: 0; }
  .side-foot .chip { flex: 0 1 auto; min-width: 0; max-width: 100%; }
  .side-foot .chip .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .vempty { display: grid; place-content: center; text-align: center; gap: 10px; color: var(--muted); padding: 40px; }
  .vempty h2 { margin: 0; font-size: 18px; color: var(--fg); }
  .vempty p { margin: 0; font-size: 14px; }
  .vempty .quick { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; align-items: stretch; min-width: 320px; }
  .vempty .quick button { justify-content: flex-start; height: auto; padding: 8px 12px; text-align: start; }
  .vskel { padding: 32px; max-width: 920px; }
  .vskel div { height: 14px; border-radius: 6px; background: var(--hover); margin: 14px 0; animation: fade 1.2s ease-in-out infinite alternate; }

  /* ================================================================
     Overlays
     ================================================================ */
  #tblbar { position: fixed; z-index: 10; display: flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
  #tblbar .btn { height: 26px; font-size: 12px; padding: 0 8px; border: 0; background: none; }
  #tblbar .btn:hover { background: var(--hover); }
  #search { position: fixed; inset: 0; background: oklch(0.15 0.01 60 / .35); z-index: 20; display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh; animation: in .15s var(--ease); }
  #search .box { width: min(640px, 92vw); background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
  #search .qrow { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--faint); }
  #search input { flex: 1; border: 0; padding: 16px 0; font-size: 17px; background: none; outline: none; color: var(--fg); }
  #results { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
  #results li { padding: 9px 12px; cursor: pointer; border-radius: var(--r); font-size: 14px; display: flex; gap: 10px; }
  #results li.sel { background: var(--accent-soft); }
  #results .rn { font-weight: 600; white-space: nowrap; }
  #results .snip { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  #results mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
  #toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 30; box-shadow: var(--shadow); animation: in .2s var(--ease); }
  @keyframes in { from { opacity: 0; transform: translateY(4px); } }
  #toast { animation-name: toastIn; }
  @keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- folder connect card ---------- */
.empty.connect p { margin: 8px 0; }
.connect-hint { font-size: 12px; color: var(--faint); }
.empty pre { font-size: 12px; padding: 8px 10px; margin: 8px 0; }

/* ---------- AskUserQuestion cards ---------- */
.ask-card { margin: 18px 0; border: 1px solid color-mix(in oklch, var(--accent) 35%, var(--line)); border-radius: 12px; background: var(--raised); overflow: hidden; }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--accent-soft); font-size: 13px; }
.ask-ico { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-weight: 800; font-size: 12px; }
.ask-title { font-weight: 700; }
.ask-state { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.ask-card.pending .ask-state { color: var(--accent); font-weight: 600; animation: fade 1s ease-in-out infinite alternate; }
.ask-card.answered .ask-state { color: var(--live); font-weight: 600; }
.ask-card.declined .ask-state { color: var(--err); }
.ask-q { padding: 12px 14px; }
.ask-q + .ask-q { border-top: 1px solid var(--line-soft); }
.ask-chip { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); margin-bottom: 6px; }
.ask-text { font-weight: 600; margin-bottom: 8px; }
.ask-multi { font-weight: 400; font-size: .85em; color: var(--faint); }
.ask-opts { display: flex; flex-direction: column; gap: 6px; }
.ask-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 8px; font-size: .92em; }
.ask-o { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ask-o span { color: var(--muted); font-size: .9em; }
.ask-mark { flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 1.5px solid var(--line); }
.ask-opt.picked { border-color: var(--live); background: color-mix(in oklch, var(--live) 9%, transparent); }
.ask-opt.picked .ask-mark { border-color: var(--live); background: var(--live); box-shadow: inset 0 0 0 3px var(--raised); }
.ask-card.answered .ask-opt:not(.picked) { opacity: .55; }
.ask-custom { margin-top: 8px; font-size: .92em; padding: 8px 10px; border-radius: 8px; background: var(--code); }

/* non-"updates" thinking blocks: collapsed, quiet */
details.thinking { margin: 8px 0; font-size: .9em; color: var(--muted); }
details.thinking > summary { cursor: pointer; font-size: 12px; color: var(--faint); list-style: none; }
details.thinking > summary::before { content: '◇ '; }
details.thinking .th-body { padding: 4px 12px; border-inline-start: 2px solid var(--line); margin-top: 4px; }

/* a question or plan Claude is waiting on (optional hook) */
.pwait { max-width: var(--vw, 920px); margin: -140px auto 160px; padding: 0 32px; --pw: var(--accent); }
.pwait > * { max-width: 100%; }
.pwait .pw-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--pw); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; background: var(--accent-soft); }
.pwait .pw-head small { color: var(--muted); margin-inline-start: auto; }
.pw-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pw); animation: pwPulse 1.4s ease-out infinite; }
@keyframes pwPulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--pw) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.pwait .pw-q, .pwait .pw-plan { border: 1px solid var(--pw); border-top: 0; padding: 12px 16px 14px; background: var(--panel); font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.pwait .pw-q:last-child, .pwait .pw-plan { border-radius: 0 0 var(--r) var(--r); }
.pwait .pw-q + .pw-q { border-top: 1px solid var(--line-soft); }
.pwait .pw-q > small { color: var(--faint); }
.pw-qt { font-weight: 600; margin: 6px 0 8px; }
.pw-opts { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; }
.pw-opts b { display: block; font-weight: 600; }
.pw-opts span { display: block; color: var(--muted); font-size: 13.5px; }

/* ---------- first-run guide (hosted page, nothing connected yet) ---------- */
.vempty.is-welcome { display: block; place-content: initial; text-align: start; padding: clamp(24px, 6vh, 72px) 24px 48px; }
.welcome { max-width: 600px; margin: 0 auto; color: var(--fg); font-size: 15px; line-height: 1.65; }
.w-head { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.w-head img { flex: none; border-radius: 12px; }
.w-head h1 { margin: 0 0 2px; font-size: 24px; line-height: 1.25; letter-spacing: -0.01em; }
.w-head p { margin: 0; color: var(--muted); font-size: 15px; }
.w-body h2 { margin: 0 0 14px; font-size: 17px; }
.w-body > p { margin: 0 0 14px; color: var(--muted); }
.w-steps { list-style: none; margin: 0; padding: 0; counter-reset: wstep; display: flex; flex-direction: column; gap: 18px; }
.w-steps li { counter-increment: wstep; position: relative; padding-inline-start: 42px; min-height: 28px; }
.w-steps li::before { content: counter(wstep); position: absolute; inset-inline-start: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.w-steps li p { margin: 2px 0 8px; }
.w-steps kbd { font-size: 12px; }
.w-copy { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); }
.w-copy code { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; min-width: min(12ch, 50vw); background: none; padding: 0; }
.w-copy .btn { height: 28px; padding: 0 10px; flex: none; }
.w-copy .btn svg { width: 14px; height: 14px; }
.w-copy .btn.done { color: var(--live); border-color: color-mix(in oklch, var(--live) 50%, transparent); }
.btn.big { height: 42px; padding: 0 20px; font-size: 15px; }
.w-body > .w-alt { margin: 26px 0 8px; color: var(--muted); }
.w-alt a { color: var(--accent); }
.w-err { margin: 18px 0 0; padding: 10px 14px; border-radius: var(--r); border: 1px solid color-mix(in oklch, var(--err) 45%, transparent);
  background: color-mix(in oklch, var(--err) 9%, transparent); color: var(--fg); }
.w-safe { display: flex; align-items: center; gap: 8px; margin: 32px 0 0; padding-top: 18px; border-top: 1px solid var(--line-soft, var(--line)); color: var(--muted); font-size: 13.5px; }
.w-safe svg { flex: none; width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.w-help { margin-top: 20px; color: var(--muted); font-size: 14px; }
.w-help summary { cursor: pointer; width: fit-content; color: var(--accent); }
.w-help ul { margin: 8px 0 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }
.w-help code { font-family: var(--mono); font-size: 12.5px; }
.w-dev { margin-top: 14px; color: var(--muted); font-size: 13.5px; }
.w-dev summary { cursor: pointer; width: fit-content; }
.w-dev summary:hover { color: var(--fg); }
.w-dev p { margin: 8px 0; }
.empty.connect .btn { margin-top: 8px; }
@media (max-width: 720px) {
  /* setup on a narrow screen: the guide gets the whole width */
  body.needs-setup #side { display: none; }
  .w-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .w-head h1 { font-size: 21px; }
}
.keys { unicode-bidi: isolate; white-space: nowrap; }
