/* The shell (frame, header, sidebar, rail, bottom bar, sheets, palette) and round 2 of the areas (chat, projects, settings), after app.css. */
/* ==== redesign: the shell, then the areas ==== */

/* ---- shell: frame ---- */
/* The app's frame: the container every layout query asks (requirements/ui/layout.md §2). */
.app-frame { container: shell / size; width: 100%; height: 100vh; height: 100dvh; position: relative; overflow: hidden; background: var(--bg); }
.app { height: 100%; display: flex; flex-direction: column; min-width: 0; position: relative; }
.layout { flex: 1; display: flex; min-height: 0; min-width: 0; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view[hidden] { display: none !important; }

/* ---- shell: header ---- */
header {
  flex: none; display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap;
  height: calc(var(--header-h) + var(--safe-top)); padding-top: var(--safe-top);
  padding-left: max(8px, var(--safe-left)); padding-right: max(8px, var(--safe-right));
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: var(--z-header);
  /* Nothing pushes past the frame (its last buttons cut off) or over the next button: the conversation's name gives way first. */
  overflow: hidden;
}
header h1, #page-title { font-size: var(--text-md); font-weight: 600; margin: 0 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
#page-title .crumb { color: var(--muted); font-weight: 500; }
#page-title a.crumb { text-decoration: none; border-radius: var(--r-xs); }
#page-title a.crumb:is(:hover, :focus-visible) { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
#page-title .crumb-sep { color: var(--line-strong); margin: 0 6px; }
.hbtn { border: none; background: none; color: var(--ink-2); min-width: var(--tap); min-height: var(--tap); width: 40px; height: 40px; padding: 0; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative; text-decoration: none; }
@media (hover: hover) { .hbtn:hover { background: var(--surface-hover); color: var(--ink); } }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: var(--glow); margin: 0 6px; }
.dot.offline-dot { background: var(--warn-fill); box-shadow: none; }
/* The agent on screen, in the chat: its avatar and name open the agent picker. */
.agent-switch { display: inline-flex; align-items: center; gap: 8px; border: none; background: none; padding: 0 8px; min-width: 0; flex: none; font-weight: 600; font-size: var(--text-md); }
.agent-switch .avatar { width: 26px; height: 26px; font-size: 15px; }
.agent-switch .chev { width: 14px; height: 14px; color: var(--muted); }
.thread-wrap { display: inline-flex; align-items: center; gap: 2px; min-width: 0; flex: 0 1 auto; position: relative; overflow: hidden; }
#thread-btn { min-width: 0; border: none; background: none; max-width: 40cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: var(--text-sm); padding: 0 8px; display: block; line-height: var(--control-h); }
#thread-btn::before { content: "/"; color: var(--line-strong); margin-right: 8px; }
#thread-star { color: var(--muted); font-size: 17px; }
#thread-star.starred { color: var(--star); }
.offline { font-size: var(--text-xs); font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: var(--r-full); padding: 2px 10px; }
.offline::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
/* A newer version in git, beside Offline: information only. */
.update-chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: var(--tap-sm); min-width: var(--tap-sm); font-size: var(--text-xs); font-weight: 600; color: var(--accent); background: var(--accent-soft); border: none; border-radius: var(--r-full); padding: 2px 10px 2px 6px; margin-left: 6px; flex: none; }
.update-chip .ico { width: 14px; height: 14px; }
/* Running now (activity.js): the header's chip and its list in the popover. */
.activity-chip { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap-sm); font-size: var(--text-xs); font-weight: 600; color: var(--ok); background: var(--ok-soft); border: none; border-radius: var(--r-full); padding: 2px 10px; margin-left: 6px; flex: none; white-space: nowrap; }
.activity-chip.waiting { color: var(--warn); background: var(--warn-soft); }
.pop .act-list { display: flex; flex-direction: column; gap: 2px; padding: 0 4px 6px; min-width: min(360px, calc(100cqw - 32px)); max-width: 440px; }
.pop .act-row { padding: 6px; border-radius: var(--r-md); white-space: normal; }
.pop .act-row.waiting { background: var(--warn-soft); }
.pop .act-head { display: flex; align-items: center; gap: 8px; }
.pop .act-title { flex: 1; min-width: 0; font-weight: 600; font-size: var(--text-sm2); color: var(--ink); overflow-wrap: anywhere; }
.pop .act-stop { flex: none; min-height: var(--tap-sm); padding: 2px 10px; }
.pop .act-meta { font-size: var(--text-xs); color: var(--muted); }
.pop .act-summary { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.update-commits { margin: 4px 10px 8px; padding-left: 16px; font-size: var(--text-sm); display: flex; flex-direction: column; gap: 4px; max-width: 360px; }
.pop .pop-text { padding: 4px 10px; font-size: var(--text-sm); max-width: 360px; white-space: normal; }
/* Search: an icon, a field from 1024 px. */
.search-btn .search-text, .search-btn kbd { display: none; }
.header-new .label { display: none; }
.header-new { background: var(--primary-bg); color: var(--primary-ink); border-radius: var(--r-md); }
@media (hover: hover) { .header-new:hover { background: var(--primary-hover); color: var(--primary-ink); } }
.badge-dot, .hbtn .count, .tab-item .count, .rail-item .count {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--primary-bg); color: var(--primary-ink); font-size: var(--text-2xs); font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; margin: 0;
}
.back-btn { display: none; }
.app[data-depth="sub"] .back-btn { display: inline-flex; }

/* ---- shell: sidebar (desktop), drawer (tablet) ---- */
#sidebar {
  flex: none; width: var(--side-w); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 12px 10px calc(12px + var(--safe-bottom)) max(10px, var(--safe-left)); display: none; flex-direction: column; gap: 6px;
}
.side-top { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.side-new { width: 100%; min-height: max(40px, var(--control-h)); justify-content: flex-start; gap: 8px; display: inline-flex; align-items: center; }
.side-search { width: 100%; min-height: var(--control-h); display: flex; align-items: center; gap: 8px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); font-weight: 400; text-align: left; }
.side-search .side-text { flex: 1; }
.side-label {
  display: flex; align-items: center; gap: 2px; padding: 0 4px; margin: 10px 0 2px;
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.side-label .side-head { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; min-height: var(--tap-sm); color: inherit; text-decoration: none; }
.side-label .side-head .nav-ico { display: none; }
.side-label .icon-btn { min-width: var(--tap-sm); min-height: var(--tap-sm); color: var(--muted); font-size: 16px; padding: 0; }
.side-fold { font-size: var(--text-2xs); }
.side-fold .chevron { display: inline-block; transition: transform var(--dur-fast); transform: rotate(90deg); }
.side-label.folded .side-fold .chevron { transform: none; }
nav.views.folded { display: none; }
.side-link { color: inherit; text-decoration: none; }
@media (hover: hover) { .side-link:hover, .side-head:hover { color: var(--accent-strong); } }
.views { display: flex; flex-direction: column; gap: 1px; }
.side-group { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: var(--row-h); padding: 0 10px; border-radius: var(--r-md);
  color: var(--ink); text-decoration: none; font-size: var(--text-sm2); position: relative;
}
@media (hover: hover) { .nav-link:hover { background: var(--surface-hover); } }
.nav-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-ico { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.nav-ico svg, .rail-item svg, .tab-item svg, .tile svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.nav-link.active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); color: var(--ink); }
.nav-link.active .nav-ico, .nav-link:hover .nav-ico { color: var(--accent-strong); }
.nav-link .count { margin-left: auto; font-size: var(--text-2xs); font-weight: 600; color: var(--ink-2); background: var(--surface-sunken); border-radius: var(--r-full); padding: 0 7px; line-height: 18px; font-variant-numeric: tabular-nums; }
.nav-link .count.unread { background: var(--primary-bg); color: var(--primary-ink); }
/* Overdue to-dos (todo.js): red wherever the count shows. */
.nav-link .count.overdue, .rail-item .count.overdue, .tab-item .count.overdue, .tile .count.overdue { background: var(--err); color: var(--bg); }
.tile .count.overdue { border-radius: var(--r-full); padding: 0 6px; }
.agent-emoji { font-size: 16px; line-height: 1; }
.conv-link .conv-star { border: none; background: none; min-height: 0; padding: 0 4px; font-size: var(--text-sm2); color: var(--muted); opacity: var(--reveal); position: relative; }
.conv-link .conv-star::after { content: ""; position: absolute; inset: -8px; }
.conv-link:hover .conv-star, .conv-link .conv-star:focus-visible, .conv-link .conv-star.starred { opacity: 1; }
.conv-link .conv-star.starred { color: var(--star); }
.conv-more { font-size: var(--text-xs); color: var(--muted); background: none; border: none; min-height: var(--tap-sm); padding: 0 10px; text-align: left; cursor: pointer; text-decoration: none; display: flex; align-items: center; }
@media (hover: hover) { .conv-more:hover { color: var(--accent-strong); } }
.project-link .busy { margin-left: auto; }
.busy { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot { 50% { opacity: .35; } }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: var(--text-sm); min-height: var(--row-h); }
.side-user .meta { color: var(--muted); font-size: var(--text-xs); }
/* The commit the server runs: small, under the account (and at the foot of More). */
.build-commit { display: block; padding: 0 10px 6px; color: var(--muted); font-size: var(--text-xs); font-family: var(--font-mono); text-decoration: none; }
.build-commit[hidden] { display: none; }
#more-sheet .build-commit { padding: 12px 0 0; text-align: center; }
.avatar { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: inline-flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 700; line-height: 1; }

/* ---- shell: rail (tablet; phone on its side) ---- */
nav.rail {
  flex: none; width: calc(var(--rail-w) + var(--safe-left)); display: none; flex-direction: column; align-items: stretch; gap: 2px;
  padding: 6px 4px calc(6px + var(--safe-bottom)) calc(4px + var(--safe-left)); background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none;
}
.rail-item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 4px 2px; border: none; background: none; border-radius: var(--r-md);
  color: var(--ink-2); font-size: var(--text-2xs); font-weight: 500; text-decoration: none; line-height: 1.2; text-align: center;
}
.rail-item .ico-wrap { width: 48px; height: 28px; border-radius: var(--r-full); display: inline-flex; align-items: center; justify-content: center; }
.rail-item svg { width: 22px; height: 22px; }
@media (hover: hover) { .rail-item:hover .ico-wrap { background: var(--surface-hover); } }
.rail-item.active { color: var(--ink); font-weight: 600; }
.rail-item.active .ico-wrap { background: var(--accent-soft); color: var(--accent-strong); }
.rail-item .count { top: 2px; right: 6px; }
.rail-sep { flex: 1; min-height: 8px; }

/* ---- shell: bottom bar (phone) ---- */
nav.tabbar {
  flex: none; display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: var(--z-bottom);
  padding: 0 max(4px, var(--safe-right)) var(--safe-bottom) max(4px, var(--safe-left));
}
.tab-item {
  flex: 1; min-width: 0; position: relative; height: var(--bottom-h); border: none; background: none; border-radius: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: var(--text-2xs); font-weight: 500; text-decoration: none; min-height: 0;
}
.tab-item svg { width: 24px; height: 24px; }
.tab-item.active { color: var(--accent-strong); font-weight: 600; }
.tab-item.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tab-item .count { top: 5px; right: auto; left: calc(50% + 4px); }
.tab-item .lbl, .rail-item .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }

/* ---- shell: scrim, drawer, sheets, popovers ---- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-drawer) - 1); display: none; }
.app.drawer-open .scrim, .app.sheet-open .scrim { display: block; }
.app.sheet-open .scrim { z-index: calc(var(--z-sheet) - 1); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet); max-height: 85cqh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-raised); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-3);
  padding: 6px max(16px, var(--safe-right)) calc(16px + var(--safe-bottom)) max(16px, var(--safe-left));
  transform: translateY(105%); visibility: hidden; transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.sheet.open { transform: none; visibility: visible; transition: transform var(--dur) var(--ease); }
.sheet-grip { display: block; width: 100%; height: 24px; border: none; background: none; min-height: 0; padding: 0; position: relative; cursor: grab; touch-action: none; }
.sheet-grip::after { content: ""; position: absolute; left: 50%; top: 10px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-strong); }
.sheet h2 { font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile {
  min-height: 88px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); text-decoration: none;
  font-size: var(--text-sm); font-weight: 500; position: relative; text-align: center;
}
.tile svg { width: 24px; height: 24px; color: var(--accent-strong); }
.tile.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.tile .count { position: absolute; top: 6px; right: 8px; font-size: var(--text-2xs); font-weight: 700; color: var(--ink-2); }
.sheet-search { width: 100%; justify-content: flex-start; gap: 8px; color: var(--muted); font-weight: 400; min-height: 44px; display: flex; align-items: center; background: var(--bg); }
/* A popover: anchored to its button from 600 px, a bottom sheet on phones. */
.pop {
  position: fixed; z-index: var(--z-sheet); min-width: 240px; max-width: min(360px, calc(100cqw - 16px)); max-height: 70cqh; overflow-y: auto;
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 6px;
}
.pop .pop-item, .agent-pick button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none; background: none; min-height: var(--row-h);
  padding: 0 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--text-sm2); font-weight: 400;
}
.pop .pop-item .sub { margin-left: auto; color: var(--muted); font-size: var(--text-xs); }
.pop .pop-item.current { font-weight: 600; }
.pop .pop-item.danger { color: var(--err); }
@media (hover: hover) { .pop .pop-item:hover, .agent-pick button:hover { background: var(--surface-hover); } }
.pop .pop-label { padding: 8px 10px 4px; font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pop .pop-row { display: flex; align-items: center; gap: 10px; padding: 4px 10px; min-height: var(--row-h); font-size: var(--text-sm2); }
.pop .pop-row select { flex: 1; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.agent-pick { position: fixed; z-index: var(--z-sheet); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 6px; min-width: 220px; }

/* ---- shell: command palette (Ctrl+K) ---- */
.palette-wrap { position: fixed; inset: 0; z-index: calc(var(--z-sheet) + 1); background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: 0; }
.palette {
  width: 100%; height: 100%; background: var(--surface-raised); display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--safe-top);
}
.palette-field { display: flex; align-items: center; gap: 10px; padding: 8px max(12px, var(--safe-left)); border-bottom: 1px solid var(--line); }
.palette-field input { flex: 1; border: none; outline: none; background: none; font-size: 17px; min-height: 44px; padding: 0; }
.palette-field input:focus { outline: none; }
.palette-list { overflow-y: auto; padding: 6px; flex: 1; }
.palette-group { padding: 10px 10px 4px; font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; text-align: left; min-height: var(--row-h); padding: 0 10px; border-radius: var(--r-sm); font-size: var(--text-sm2); font-weight: 400; color: var(--ink); }
.palette-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; color: var(--muted); flex: none; }
.palette-item .path { color: var(--muted); }
.palette-item kbd { margin-left: auto; }
.palette-item[aria-selected="true"] { background: var(--sel-bg); color: var(--sel-ink); }
.palette-item[aria-selected="true"] svg { color: currentColor; }
.palette-empty { padding: 24px 10px; color: var(--muted); font-size: var(--text-sm); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--muted); }

/* ---- foundation: tabs ---- */
.tab-strip { position: relative; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); margin-bottom: 16px; min-width: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
/* Conversations on a phone: Last, Yours and Starred as tabs, the other kinds as chips under them (chat.js drawConvMore). */
.conv-tab-more { display: none; }
@container shell (width < 600px) {
  #conv-tabs .tab:not([data-tab="last"], [data-tab="user"], [data-tab="starred"]) { display: none; }
  #conv-tabs .tab[data-tab="last"] { order: -3; }
  #conv-tabs .tab[data-tab="user"] { order: -2; }
  #conv-tabs .tab[data-tab="starred"] { order: -1; }
  .conv-tab-more { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -6px 0 12px; }
  .conv-tab-more::-webkit-scrollbar { display: none; }
  .conv-tab-more .chip-btn { flex: none; }
}
.tab-strip > .tabs { flex: 1; border-bottom: none; margin: 0; }
.tab-strip[data-overflow~="end"] > .tabs { mask-image: linear-gradient(to right, black calc(100% - 28px), transparent); }
.tab-strip[data-overflow~="start"] > .tabs { mask-image: linear-gradient(to left, black calc(100% - 28px), transparent); }
.tab-strip[data-overflow~="start"][data-overflow~="end"] > .tabs { mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent); }
.tab {
  flex: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  min-height: var(--row-h); padding: 0 12px; font-size: var(--text-sm2); font-weight: 500; color: var(--muted);
  white-space: nowrap; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
@media (hover: hover) { .tab:hover:not(.active) { background: none; color: var(--ink); } }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { font-size: var(--text-2xs); font-weight: 600; color: var(--ink-2); background: var(--surface-sunken); border-radius: var(--r-full); padding: 0 7px; line-height: 18px; margin: 0; font-variant-numeric: tabular-nums; }
.tab .count:empty { display: none; }
/* E-ink: arrows in place of the fading edges (shown there only). */
.tab-arrow { display: none; flex: none; border: none; background: var(--surface); min-width: var(--tap); padding: 0; font-size: 18px; }
/* Segmented: filters and modes. */
.page-top .filter, .seg-control { display: inline-flex; background: var(--surface-sunken); border-radius: var(--r-full); padding: 2px; gap: 2px; border: none; overflow: visible; flex: none; }
.page-top .filter button, .seg-control button { border: none; border-radius: var(--r-full); background: none; min-height: var(--control-h-sm); padding: 0 12px; font-size: var(--text-xs); color: var(--ink-2); }
.page-top .filter button.on, .seg-control button.on, .seg-control button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px var(--shadow-color); }

/* ---- foundation: badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; font-size: var(--text-2xs); font-weight: 600; border-radius: var(--r-full); padding: 0 8px; background: var(--surface-sunken); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: middle; }
.badge.on { background: var(--primary-bg); color: var(--primary-ink); }
.badge.off { background: var(--err-soft); color: var(--err); }
.badge.ok-badge { background: var(--ok-soft); color: var(--ok); }
.badge.err-badge { background: var(--err-soft); color: var(--err); }
.badge.remote::before, .badge.ok-badge::before, .badge.err-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- chat ---- */
main#log, .chat main {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 20px var(--log-pad) 16px; display: flex; flex-direction: column; gap: var(--sp-6);
  width: 100%; max-width: calc(var(--chat-width, var(--chat-max)) + 2 * var(--log-pad)); margin: 0 auto;
}
.agent-log { display: flex; flex-direction: column; gap: var(--sp-6); }
.agent-log[hidden] { display: none; }
.msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg > * { min-width: 0; max-width: 100%; }
.msg .who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); letter-spacing: 0; text-transform: none; }
.msg .who .who-info { margin: 0; font-size: var(--text-xs); font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg .who .who-actions { border: 1px solid var(--line); background: none; min-height: 22px; padding: 0 8px; border-radius: var(--r-full); font-size: var(--text-2xs); font-weight: 500; color: var(--muted); }
.msg .who .who-actions[aria-expanded="true"] { color: var(--accent-strong); border-color: var(--accent); }
.msg .who .read-aloud { border: none; background: none; min-height: 0; padding: 2px; color: var(--muted); opacity: var(--reveal); position: relative; display: inline-flex; }
.msg .who .read-aloud::after { content: ""; position: absolute; inset: calc((var(--tap) - 20px) / -2); }
.msg .who .read-aloud svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.msg:hover .who .read-aloud, .msg .who .read-aloud:focus-visible { opacity: 1; }
.msg .who .read-aloud.on { opacity: 1; color: var(--accent-strong); }
.bubble { word-wrap: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg.user { align-items: flex-end; }
.user .bubble { background: var(--user-bg); padding: 10px 14px; border-radius: var(--r-xl) var(--r-xl) var(--r-sm) var(--r-xl); max-width: 85%; }
/* The owner's name goes; the time moves under the bubble. */
.msg.user .who { order: 2; font-weight: 400; }
.msg.user .who .who-name { display: none; }
.assistant .bubble { background: none; border: none; padding: 0; font-size: var(--text-md); }
.assistant .md { max-width: 72ch; }
.msg.pending .bubble { opacity: .7; outline: 1px dashed var(--accent); outline-offset: 2px; }
.error .bubble { color: var(--err); }
.tools-list { display: flex; flex-direction: column; gap: 2px; border-left: 2px solid var(--line); padding: 2px 0 2px 12px; margin: 0 0 2px 10px; }
.tool { font-family: var(--font-mono); font-size: var(--text-xs); line-height: 18px; color: var(--muted); background: none; padding: 1px 0; border-radius: 0; align-self: flex-start; overflow-wrap: anywhere; }
.tool::before { content: "✓ "; color: var(--ok); }
/* A step with its call: a click opens what went in and what came out under it (termCall, as the terminal page draws it). */
.tool.has-detail { cursor: pointer; }
/* How long a call took: after its step's line and its name, quieter. */
.tool-ms, .term-ms { color: var(--muted); white-space: nowrap; }
.term-ms { margin-left: auto; padding-left: 8px; font-size: var(--text-xs); }
.tool.has-detail:hover { color: var(--ink-2); text-decoration: underline dotted; }
.tool.has-detail:focus-visible { outline: 1px solid var(--accent); }
.tool-detail { font-family: var(--font-mono); font-size: var(--text-xs); border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--surface-sunken); padding: 6px 8px; margin: 2px 0 4px; max-height: 24em; overflow: auto; }
.tools { display: flex; flex-direction: column; gap: 3px; margin: 2px 0; align-items: flex-start; }
.tools-toggle { font-size: var(--text-xs); color: var(--muted); border-radius: var(--r-full); min-height: 24px; padding: 0 10px; }
.bubble pre { background: var(--surface-sunken); padding: 12px 14px; border-radius: var(--r-md); overflow-x: auto; }
.bubble code { font-family: var(--font-mono); font-size: .9em; }
.md .code-block { border-radius: var(--r-md); }
.md .code-head { font-family: var(--font-mono); }
.md .code-copy { min-height: 22px; padding: 0 8px; font-size: var(--text-2xs); }
/* Small chips look small; their hit area is the full target (as .read-aloud). */
:is(.msg .who .who-actions, .tools-toggle, .md .code-copy) { position: relative; }
:is(.msg .who .who-actions, .tools-toggle, .md .code-copy)::after { content: ""; position: absolute; inset: calc((var(--tap) - 22px) / -2) -4px; }
.note { font-size: var(--text-xs); color: var(--muted); text-align: center; border-top: 1px dashed var(--line); padding-top: 10px; }
.banner { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-lg); padding: 10px 14px; font-size: var(--text-sm2); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }
.chat-empty h2 { font-size: var(--text-2xl); color: var(--ink); margin: 0 0 6px; }
/* E-ink: "More below" when the answer runs past the screen (shown there only). */
.more-below { display: none; }

/* The composer: one surface, the field, round buttons. */
footer { flex: none; background: var(--bg); padding: 6px var(--log-pad) calc(10px + var(--safe-bottom)); }
/* A notch on the right (a phone on its side) stays clear of the text and Send. */
main#log, footer { padding-right: max(var(--log-pad), var(--safe-right)); }
.composer {
  max-width: var(--chat-width, var(--chat-max)); margin: 0 auto; display: flex; gap: 6px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-xl); padding: 5px 5px 5px 14px;
  transition: border-color var(--dur-fast);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea:where(:not(.monaco-editor *)) {
  flex: 1; min-width: 0; border: none; background: none; outline: none; resize: none;
  min-height: 40px; max-height: 40cqh; padding: 9px 0; font-size: var(--input-fs); line-height: 1.45;
}
.composer textarea:focus { outline: none; }
.mic, .send, .stop {
  flex: none; width: max(40px, var(--tap)); height: max(40px, var(--tap)); min-height: 0; padding: 0; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.mic { background: none; border: none; color: var(--ink-2); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mic svg, .send svg, .stop svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .mic:hover { background: var(--surface-hover); color: var(--ink); } }
.mic[data-state]:not([data-state="off"]):not([data-state="error"]) { color: var(--accent-strong); background: var(--accent-soft); box-shadow: var(--glow); }
.mic[data-state="recording"] { color: var(--accent-ink); background: var(--err); animation: pulse-dot 1.2s ease-in-out infinite; }
.mic[data-state="error"] { color: var(--err); }
.mic[data-mode="hold"]:is([data-state="off"], :not([data-state])) { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
/* The microphone's ▾: its two ways (voice.js micMenu). */
.mic-mode { flex: none; width: 22px; min-width: 0; height: max(36px, var(--tap)); min-height: 0; margin-left: -6px; padding: 0; border: none; border-radius: var(--r-full); background: none; color: var(--muted); font-size: var(--text-2xs); }
@media (hover: hover) { .mic-mode:hover { color: var(--ink); background: var(--surface-hover); } }
.send { background: var(--primary-bg); color: var(--primary-ink); border: none; font-weight: 600; }
.send .send-label { display: none; }
@media (hover: hover) { .send:hover:not(:disabled) { background: var(--primary-hover); color: var(--primary-ink); box-shadow: var(--glow-strong); } }
.send:disabled { background: var(--surface-sunken); color: var(--muted); }
.stop { background: var(--err); color: var(--accent-ink); border: none; }
.stop svg { fill: currentColor; stroke: none; width: 14px; height: 14px; }
.hint { max-width: var(--chat-width, var(--chat-max)); margin: 6px auto 0; font-size: var(--text-2xs); color: var(--muted); min-height: 0; }
.hint:empty { display: none; }
.reply-chip { max-width: var(--chat-width, var(--chat-max)); }
.reply-chip button { min-width: var(--tap); }

/* Attachments: 📎 in the composer, the chips over it as they upload, and in a message (attachments.js). */
.attach-btn { flex: none; width: max(40px, var(--tap)); height: max(40px, var(--tap)); min-height: 0; padding: 0; margin-left: -9px; border: none; border-radius: var(--r-full); background: none; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.attach-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .attach-btn:hover { background: var(--surface-hover); color: var(--ink); } }
/* The composer's ◔: a menu of the conversation's fast mode, effort and ultracode, the button saying how they are; lit when any isn't as the agent has it. */
 /* The composer's "/": every command, grouped (chat.js commandsMenu). */
.cmd-btn { flex: none; width: max(36px, var(--tap)); height: max(36px, var(--tap)); min-height: 0; padding: 0; border: none; border-radius: var(--r-full); background: none; color: var(--muted); font-family: var(--mono, monospace); font-size: var(--text-sm2); font-weight: 700; }
@media (hover: hover) { .cmd-btn:hover { background: var(--surface-hover); color: var(--ink); } }
/* On a phone the ◔ alone (lit when something isn't the agent's), so the field keeps its width; the menu says the rest. */
.attach-tray { max-width: var(--chat-width, var(--chat-max)); margin: 0 auto 6px; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.attach-tray[hidden] { display: none; }
.attach-chip { position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px; max-width: 240px; padding: 4px 4px 4px 6px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none; overflow: hidden; }
.attach-chip.error { border-color: var(--err); }
.attach-chip.error .attach-sub { color: var(--err); white-space: normal; }
.attach-chip.preparing, .attach-chip.uploading { opacity: .8; }
.attach-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-sm); flex: none; }
.attach-icon { font-size: 22px; line-height: 1; flex: none; }
.attach-text { display: flex; flex-direction: column; min-width: 0; font-size: var(--text-sm); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-sub { font-size: var(--text-2xs); color: var(--muted); white-space: nowrap; }
.attach-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-sunken); }
.attach-progress > span { display: block; height: 100%; background: var(--accent); transition: width var(--dur-fast); }
.attach-x { flex: none; border: none; background: none; min-width: 32px; min-height: 32px; padding: 0; color: var(--muted); }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 85%; margin-bottom: 4px; }
.msg-attach-img img { display: block; max-width: min(240px, 60vw); max-height: 200px; border-radius: var(--r-md); border: 1px solid var(--line); object-fit: cover; }
.chat.view.drop-target footer .composer { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-style: dashed; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* A conversation an agent is answering in now (refreshWorking): a pulsing dot. */
.conv-link.working .label::after, .conv-card.working .name::after { content: " ●"; color: var(--accent); animation: pulse-dot 1.6s ease-in-out infinite; }
/* A conversation whose agent waits for your answer (markAsking): the mark is a node of its own, so its title says what it means. */
.conv-ask { margin-left: 4px; font-size: var(--text-xs); cursor: help; }
.conv-link.asking .label, .conv-card.asking .name { color: var(--accent); }

/* "New version": a bar at the bottom (above the bottom bar on phones), above the composer in the chat (chat: additions). */
.update-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: var(--z-float); bottom: calc(16px + var(--safe-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100cqw - 32px); padding: 8px 8px 8px 16px; font-size: var(--text-sm2);
  background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}

/* ---- foundation: pages, lists, cards, forms ---- */
.page-view {
  flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain;
  --page-pad-top: 16px; --page-pad-bottom: calc(32px + var(--safe-bottom));
  padding-block: var(--page-pad-top) var(--page-pad-bottom);
  padding-left: max(var(--gutter), var(--safe-left)); padding-right: max(var(--gutter), var(--safe-right));
}
.page-view .inner { margin: 0 auto; max-width: var(--inner-max); min-width: 0; }
.page-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.page-top .intro { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: var(--text-sm2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.page-top .intro.open { -webkit-line-clamp: unset; display: block; }
/* On phones the actions take a second row, at its end; a filter stays at its start. */
.page-top > .intro + button, .page-top > .filter + .primary, #planner-new { margin-left: auto; }
/* The Planner's project filter: a choice, and the project chosen as a chip with ✕. */
#planner-project { width: auto; max-width: 14em; min-height: var(--control-h-sm); font-size: var(--text-xs); }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-sunken); border-radius: var(--r-full); padding: 0 4px 0 10px; min-height: var(--control-h-sm); font-size: var(--text-xs); }
.filter-chip[hidden] { display: none; }
.filter-chip .chip-x { border: none; background: none; min-height: 0; padding: 2px 6px; color: var(--ink-2); }
.page-view .intro { color: var(--muted); font-size: var(--text-sm2); margin: 0 0 8px; }
.page-view h2 { font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-2); margin: 28px 0 10px; }
.conv-section > h2, details.builtins summary, .page-view .integration-group > h2 { font-size: var(--text-sm); text-transform: none; letter-spacing: 0; color: var(--ink-2); font-weight: 600; }
.item-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: 16px; }
.card { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 12px 16px; min-width: 0; }
.card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .row button, .integration .head button, .conv-card .acts button { min-height: var(--control-h-sm); padding: 0 10px; font-size: var(--text-xs); }
.card .title { font-size: var(--text-md); }
.card .meta, .conv-card .meta { font-variant-numeric: tabular-nums; }
.conv-card { border-radius: var(--r-lg); }
@media (hover: hover) { .conv-card:hover, .notif-item:hover, .meeting-card:hover { border-color: var(--line-strong); background: var(--surface-hover); } }
/* The card around it opens the conversation: the star is a full touch target, so a near miss doesn't. */
.conv-card .conv-star { color: var(--muted); border: none; background: none; min-height: var(--tap-sm); min-width: var(--tap-sm); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.conv-card .conv-star.starred { color: var(--star); }
.item-form {
  background: var(--surface); border: 1.5px solid var(--accent); border-radius: var(--r-lg);
  padding: var(--sp-4); margin-top: 16px; display: flex; flex-direction: column; gap: 12px;
}
.item-form label, .item-form .field { font-size: var(--text-xs); font-weight: 500; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.item-form :is(input, textarea, select):where(:not(.monaco-editor *)), .settings select, .audit-filters :is(select, input),
.memory-search, .code-bar select, .code-comments select, .usage-head select, .notepad-bar select, .scratch-bar input[type=date], .event-interval input, .cut-edge,
.code-agent textarea, .auth-card input, .user-list select {
  background: var(--surface); border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); font-size: var(--input-fs);
}
.item-form :is(input, textarea):focus, .memory-search:focus, .audit-filters :is(input, select):focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.item-form .two { display: grid; grid-template-columns: 1fr; gap: 12px 16px; }
/* An emoji is a few characters: it stays beside the name, also on a phone. */
.item-form .two.name-emoji { grid-template-columns: 1fr 5.5em; }
.item-form .three { display: grid; grid-template-columns: 1fr; gap: 12px 16px; }
.item-form .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.item-form .err { flex: 1; color: var(--err); font-size: var(--text-sm); }
:is(.item-list, .settings).grid > .item-form { grid-column: 1 / -1; }
.settings section { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.settings h3 { font-size: var(--text-md); margin: 0 0 10px; }
.settings .hint-text, .hint-text { font-size: var(--text-xs); color: var(--muted); }
.empty { font-size: var(--text-sm); color: var(--muted); }
.sev-high { color: var(--warn); }

/* ---- settings: a list of groups, the group beside it (or after it, on phones) ---- */
.settings-layout { display: block; }
.settings-tabs {
  flex-direction: column; gap: 0; border: var(--bw) solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  overflow: hidden; margin: 0; padding: 0;
}
.settings-tabs .tab {
  width: 100%; justify-content: flex-start; text-align: left; border-bottom: 1px solid var(--line); min-height: 56px; padding: 8px 14px;
  color: var(--ink); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; white-space: normal;
}
.settings-tabs .tab:last-child { border-bottom: none; }
.settings-tabs .tab .tab-name { font-weight: 600; font-size: var(--text-sm2); }
.settings-tabs .tab .tab-desc { grid-row: 2; font-size: var(--text-xs); color: var(--muted); font-weight: 400; }
.settings-tabs .tab::after { content: "›"; grid-row: 1 / 3; grid-column: 2; font-size: 20px; color: var(--muted); }
.settings-group-label { padding: 14px 14px 6px; font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--line); }
.settings-group-label:first-child { padding-top: 8px; }
.settings-detail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings-detail-head { display: flex; align-items: center; gap: 8px; }
.settings-detail-head h2 { margin: 0; font-size: var(--text-xl); color: var(--ink); font-weight: 600; }
.settings-layout[data-mode="list"] .settings-detail { display: none; }
.settings-layout[data-mode="detail"] .settings-tabs { display: none; }
/* Display: the three modes as one choice, a sample under it. */
.display-pick { display: flex; flex-direction: column; gap: 10px; }
.display-pick .seg-control button { font-size: var(--text-sm); min-height: var(--control-h); padding: 0 14px; }
.display-sample { border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: 10px 14px; font-size: var(--text-md); }

/* ---- projects: tiles, head ---- */
/* A project's tabs (and a page's) stay in view under the header while the page scrolls. */
/* A sticky bar in a page sticks to its scroller's padding edge: offset by that padding, it meets the header (no gap to see the page through). */
.project-head + .tab-strip, .page-view .inner > .tab-strip { position: sticky; top: calc(-1 * var(--page-pad-top)); z-index: var(--z-sticky); background: var(--bg); }
.project-head + .tab-strip { margin-bottom: 0; }
.project-head-name { font-size: var(--text-xl); font-weight: 650; }
.folder-tile { border-radius: var(--r-lg); }

/* ---- projects: code view ---- */
/* No bottom bar on this page: it keeps clear of the home indicator and a side notch itself. */
.code-view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-bottom: var(--safe-bottom); }
/* Its header as every project page's (the same gutter and top, the tabs where they are on the others): switching
   tabs leaves it in place. The editor's room is what's under it. */
#code-project-head { --page-pad-top: 16px; flex: none; display: flex; flex-direction: column; gap: 14px; margin-top: 8px; padding: var(--page-pad-top) max(var(--gutter), var(--safe-right)) 0 max(var(--gutter), var(--safe-left)); }
#code-project-head > .tab-strip { position: static; margin-bottom: 0; }
#code-project-head > .project-head { margin-bottom: 0; }
.code-main { padding-right: var(--safe-right); }
.code-layout { display: inline-flex; background: var(--surface-sunken); border-radius: var(--r-full); padding: 2px; gap: 2px; flex: none; }
.code-layout button { border: none; border-radius: var(--r-full); background: none; min-height: var(--control-h-sm); padding: 0 12px; font-size: var(--text-xs); color: var(--ink-2); margin: 0; }
.code-layout button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px var(--shadow-color); }
.code-layout #code-files { margin-right: 4px; }
.code-bar-extra { display: contents; }
.code-more { display: none; }
.code-main {
  --files-w: 260px; --agent-w: 360px;
  flex: 1; display: grid; min-height: 0; min-width: 0; position: relative;
  grid-template-columns: var(--files-w) minmax(0, 1fr) var(--agent-w);
}
.code-main.no-tree { grid-template-columns: minmax(0, 1fr) var(--agent-w); }
.code-main[data-layout="code"] { grid-template-columns: var(--files-w) minmax(0, 1fr); }
.code-main.no-tree[data-layout="code"], .code-main[data-layout="side"], .code-main.no-tree[data-layout="side"] { grid-template-columns: minmax(0, 1fr); }
.code-main[data-layout="side"]:not(.no-tree) { grid-template-columns: var(--files-w) minmax(0, 1fr); }
.code-main.no-tree .code-side, .code-main[data-layout="code"] .code-comments, .code-main[data-layout="side"] .code-center { display: none; }
.code-main[data-layout="files"] .code-center, .code-main[data-layout="files"] .code-comments { display: none; }
.code-main[data-layout="files"] { grid-template-columns: minmax(0, 1fr); }
.code-main[data-layout="files"] .code-side { display: block; }
.code-side { background: var(--surface); }
.code-pane-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none; z-index: 2; }
.code-pane-grip::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 4px; }
@media (hover: hover) { .code-pane-grip:hover::after { background: var(--accent-soft); } }
.code-pane-grip.dragging::after { background: var(--accent-soft); }
.code-main:not([data-layout="both"]) .code-pane-grip { display: none; }
.tree-file.active { background: var(--accent-soft); color: var(--accent-strong); }
.tree-file.wt-A { color: var(--ok); } .tree-file.wt-M, .tree-dir.wt-M { color: var(--warn); }

/* ---- notepad ---- */
/* No bottom bar on this page either. */
#view-notepad { overflow: hidden; display: flex; flex-direction: column; padding-bottom: calc(12px + var(--safe-bottom)); }
.notepad { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; width: 100%; }
.notepad-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; order: 3; }
.notepad-sheet { order: 2; }
.notepad-hint { order: 4; display: none; }
.notepad-tools .tool-group { flex: none; border-radius: var(--r-lg); }
.notepad-tools .tool-group button { min-height: var(--tap); min-width: var(--tap); justify-content: center; }
.notepad-tools .tool-group button[aria-pressed="true"] { background: var(--sel-bg); color: var(--sel-ink); }
.notepad-bar { flex-wrap: wrap; }
.focus-exit { display: none; position: fixed; top: calc(8px + var(--safe-top)); right: max(8px, var(--safe-right)); z-index: var(--z-drawer); }
.app.focus-mode .focus-exit { display: inline-flex; }
.app.focus-mode :is(header, nav.rail, nav.tabbar, #sidebar, .notepad-bar) { display: none !important; }
.app.focus-mode #view-notepad { padding: 8px; }

/* ---- shell: e-ink paging buttons (shown in e-ink with "Scroll by pages" on) ---- */
.page-btns { display: none; position: fixed; right: max(16px, var(--safe-right)); top: 50%; transform: translateY(-50%); z-index: var(--z-float); flex-direction: column; gap: 8px; }
.page-btns button { width: 56px; height: 56px; padding: 0; font-size: 20px; background: var(--surface); }
.eink-offer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px max(16px, var(--safe-left)); background: var(--surface); border-bottom: 1px solid var(--line); font-size: var(--text-sm2); }

/* ---- foundation: what shows on hover elsewhere shows always on touch (and e-ink) ---- */
.seg-who.again { opacity: max(var(--reveal), 0); }

/* ==== round 2: how a project, the chat and Settings work (requirements/ui/project.md, chat.md, settings.md) ==== */

/* ---- foundation: shared bits (chips, icons, the popover, toasts) ---- */
.err-t { color: var(--err); font-weight: 600; } .ok-t { color: var(--ok); }
.ok { color: var(--ok); font-size: var(--text-sm); }
.be-tag { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; margin-left: 4px; border: 1px dashed var(--violet); color: var(--violet); border-radius: var(--r-xs); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .04em; vertical-align: middle; cursor: help; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: var(--r-full); background: var(--surface-sunken); color: var(--ink-2); font-size: var(--text-2xs); font-weight: 600; white-space: nowrap; }
.spin { display: inline-block; color: var(--accent); animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dot-ok, .dot-bad { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }
.dot-bad { background: var(--err); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-h-sm); padding: 0 10px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
}
.chip-btn .ico, .chip-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chip-btn.muted { color: var(--muted); border-style: dashed; }
.chip-btn[aria-pressed="true"], .chip-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hbtn .ico { width: 20px; height: 20px; }
/* The one popover: short questions (in place of confirm()), a note, a small form, a wide panel. */
.pop .pop-q { text-transform: none; letter-spacing: 0; font-size: var(--text-sm2); font-weight: 600; color: var(--ink); padding: 10px 10px 6px; max-width: 320px; white-space: normal; }
.pop .pop-note { margin: 2px 10px 6px; font-size: var(--text-xs); color: var(--muted); white-space: normal; }
.pop .pop-item:disabled { color: var(--muted); cursor: not-allowed; }
.pop .pop-form { padding: 4px 6px 6px; display: flex; flex-direction: column; gap: 10px; min-width: min(320px, calc(100cqw - 32px)); }
.pop .pop-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--ink-2); }
.pop .pop-form :is(select, textarea, input[type=text], input[type=datetime-local]) { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); font: inherit; font-size: var(--input-fs); background: var(--surface); padding: 4px 8px; }
.pop .pop-form .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pop .pop-acts { display: flex; justify-content: flex-end; padding: 6px; }
/* askText / askConfirm (ask.js): the question, a note, a field, Cancel and the answer; full width on a phone's sheet. */
.pop .pop-ask { max-width: 420px; }
.pop .pop-ask .pop-q, .pop .pop-ask .pop-note { padding: 6px 4px 0; margin: 0; max-width: none; }
.pop .pop-ask input { width: 100%; box-sizing: border-box; }
.pop .pop-ask .actions button { min-height: var(--tap-sm); min-width: 88px; }
.pop.pop-wide { max-width: min(640px, calc(100cqw - 16px)); }
.pop.pop-wide .item-form { margin: 0; border: none; padding: 6px; }
.pop .p-commit { border: none; padding: 0; }
/* Toasts: bottom right; above the bottom bar on phones. */
.toasts { position: fixed; right: max(16px, var(--safe-right)); bottom: calc(16px + var(--safe-bottom)); z-index: calc(var(--z-sheet) - 2); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: min(420px, calc(100cqw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2); font-size: var(--text-sm2); animation: toast-in var(--dur) var(--ease); }
.toast .toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .toast-act { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.toast .toast-x { border: none; background: none; min-width: var(--tap-sm); min-height: var(--tap-sm); padding: 0; color: var(--muted); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---- projects: the head (chips, Ask, Open ▾) ---- */
/* One row: the name and chips take what they need, Open editor the rest of it. */
.project-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: nowrap; margin-bottom: 10px; }
.project-head-title { display: flex; align-items: center; gap: 8px 10px; flex: 0 1 auto; min-width: 0; flex-wrap: wrap; }
.project-head-desc { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.p-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: var(--r-full); background: var(--surface-sunken); color: var(--ink-2); font-size: var(--text-xs); font-weight: 600; text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.chip:is(:hover, :focus-visible) { background: var(--surface-hover); color: var(--ink); }
.chip.bad { background: var(--err-soft); color: var(--err); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.agents { background: var(--accent-soft); color: var(--accent-strong); }
.p-head-acts { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
.p-head-acts .p-open { flex: 1 1 auto; min-width: 0; }
.p-head-acts .p-open .split-main { flex: 1 1 auto; min-width: 0; justify-content: center; }
.p-open .split-main .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-ask-btn { display: inline-flex; align-items: center; gap: 6px; }
.p-ask-btn .ico, .split-btn .ico { width: 18px; height: 18px; }
.split-btn { display: inline-flex; align-items: stretch; }
.split-btn .split-main { border-radius: var(--r-md) 0 0 var(--r-md); display: inline-flex; align-items: center; gap: 6px; }
.split-btn .split-arrow { border-radius: 0 var(--r-md) var(--r-md) 0; border-left: none; padding: 0 8px; min-width: 0; }
.split-btn .split-arrow .ico { width: 14px; height: 14px; }
/* ⋯ (Copy path, Refresh, Settings) at every width: desktop has no other way to them. */
.p-head-acts .p-more { display: inline-flex; flex: none; }
/* Open editor: where it opens under the label (dev container, app); a dot when it's running already. */
.p-open .split-main { position: relative; }
.p-open .p-open-where:not(:empty) { font-size: var(--text-xs); font-weight: 400; font-style: italic; }
.p-open .p-open-where:not(:empty)::before { content: "· "; }
.p-open .split-main.is-up::after, .folder-tile .folder-ide.is-up::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); border: 1.5px solid var(--surface); }
.folder-tile .folder-ide { position: relative; cursor: pointer; }
.tab .count:not(:empty) { margin-left: 2px; }
.folder-tile .folder-slot.needs { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); font-weight: 600; }
.folder-tile .folder-review { font-size: var(--text-xs); color: var(--accent-strong); text-decoration: none; font-weight: 600; }

/* ---- projects: Overview: Needs you, then two columns (Ask, Agent work, Working copy | Where, Tasks, Conversations) ---- */
.p-grid { display: flex; flex-direction: column; gap: 14px; }
.p-main, .p-side { display: contents; }
.p-needs { order: 0; } .p-setup { order: 1; } .p-ask { order: 2; } .p-work { order: 3; } .p-wc { order: 4; } .p-sched { order: 5; } .p-convs { order: 6; } .p-where { order: 7; }
.p-card { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; min-width: 0; }
.p-card h3, .p-needs h3 { font-size: var(--text-md); margin: 0; }
.p-card h4, .p-branches h4 { font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.p-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.p-card-head h3 { flex: 1; min-width: 0; }
.p-link { font-size: var(--text-xs); color: var(--accent-strong); text-decoration: none; white-space: nowrap; }
.p-link:hover { text-decoration: underline; }
/* A memory project's dev projects (chat.js devProjectLinks): their names, then "Project page →". */
.dev-project-links { font-size: var(--text-xs); font-weight: 500; }
.dev-project-links a:not(.p-link) { color: inherit; }
.conv-section > h2 .dev-project-links { margin-left: auto; }
.p-needs { background: var(--warn-soft); border: 1px solid var(--warn-fill); border-left-width: 4px; border-radius: var(--r-lg); padding: 10px 14px; }
.p-needs h3 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--warn); margin-bottom: 4px; }
.needs-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--line); font-size: var(--text-sm2); }
.needs-row:first-of-type { border-top: none; }
.needs-t { flex: 1 1 260px; min-width: 0; }
.needs-a { display: flex; gap: 6px; flex-wrap: wrap; }
.needs-a button { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.p-setup { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-lg); padding: 14px 16px; }
.p-setup-form { display: flex; flex-direction: column; gap: 10px; }
.p-setup-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--ink-2); }
.p-setup-form label.check { flex-direction: row; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--ink); }
.p-setup-form textarea { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); font: inherit; font-family: var(--font-mono); font-size: var(--input-fs); padding: 6px 8px; background: var(--surface); }
.p-setup-form .actions { display: flex; align-items: center; gap: 10px; }
/* Ask an agent: a composer; one line on phones until tapped. */
details.p-card > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; }
details.p-card > summary::-webkit-details-marker { display: none; }
.p-ask-peek, .p-where-peek { color: var(--muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
details[open] > summary :is(.p-ask-peek, .p-where-peek) { display: none; }
details.p-card:not([open]) > summary h3::before { content: "▸ "; color: var(--muted); }
.p-ask-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.p-ask-form textarea { width: 100%; border: var(--bw) solid var(--line-input); border-radius: var(--r-md); font: inherit; font-size: var(--input-fs); padding: 8px 10px; min-height: 76px; resize: vertical; background: var(--surface); }
.p-ask-form textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.p-ask-where { display: grid; grid-template-columns: 1fr; gap: 6px; }
.p-radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; min-height: var(--tap); }
.p-radio input { margin-top: 3px; flex: none; }
.p-radio > span { display: flex; flex-direction: column; gap: 1px; font-size: var(--text-sm2); }
.p-radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.p-ask-row, .p-ask-at, .p-ask-repeat { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.p-ask-form :is(select, input[type=date], input[type=time]) { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); font-size: var(--input-fs); background: var(--surface); }
.p-ask-foot { margin: 0; }
.p-ask-form > .err { color: var(--err); font-size: var(--text-sm); }
.p-ask-form > .err:empty { display: none; }
/* Agent work: running, to review, recent; each row's main action at its end. */
.work-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; color: inherit; text-decoration: none; }
.p-work-body h4 + .work-row, .p-work-body h4 + details.work-row { border-top: none; }
details.work-row { display: block; }
details.work-row > summary { display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer; }
details.work-row > summary::-webkit-details-marker { display: none; }
details.work-row .run-output { margin: 6px 0 2px 30px; }
.work-ico { flex: none; width: 20px; text-align: center; color: var(--muted); font-size: var(--text-md); }
.work-row.running .work-ico, .work-row.conv .work-ico { color: var(--accent); }
.work-row.error .work-ico { color: var(--err); }
.work-main { flex: 1; min-width: 0; }
.work-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm2); }
.work-main .hint-text { overflow-wrap: anywhere; }
.work-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.work-acts button:not(.hbtn) { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.work-acts .hbtn { width: var(--tap-sm); height: var(--tap-sm); }
.run-output { font-size: var(--text-sm); color: var(--ink-2); background: var(--surface-sunken); border-radius: var(--r-md); padding: 8px 10px; white-space: pre-wrap; }
/* Working copy: one line of state, its actions, the shared commit form. */
.wc-line { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; font-size: var(--text-sm2); font-variant-numeric: tabular-nums; }
.wc-line.wc-none { margin: 0; }
.wc-line .p-link { white-space: nowrap; }
.wc-line span { color: var(--ink-2); }
.p-wc-body > .hint-text { margin: 4px 0 8px; }
.wc-acts { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wc-acts:empty { display: none; }
.p-ask-done { margin: 6px 0 0; font-size: var(--text-sm); }
.wc-acts .wc-msg { flex-basis: 100%; }
.wc-acts .wc-msg:empty { display: none; }
.p-commit { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.p-changes .p-commit { border-top: none; margin-top: 0; padding-top: 0; }
.p-commit-top { display: flex; align-items: center; gap: 12px; }
.p-commit .link-btn { min-height: var(--tap-sm); font-size: var(--text-xs); }
.p-commit .git-files { display: flex; flex-direction: column; gap: 2px; }
.p-commit .git-file { display: flex; align-items: center; gap: 8px; min-height: var(--row-h); font-size: var(--text-sm); }
.p-commit .git-file a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.p-commit .git-file a:hover { text-decoration: underline; }
.p-commit-msg { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--ink-2); }
.p-commit textarea { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); font: inherit; font-size: var(--input-fs); padding: 6px 8px; background: var(--surface); }
.p-commit .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-commit .err { color: var(--err); font-size: var(--text-sm); }
.danger { color: var(--err); }
button.danger { border-color: var(--err); }
.sched-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--text-sm2); }
.sched-row:first-child { border-top: none; }
.sched-row.paused { opacity: .7; }
.sched-ico { flex: none; width: 20px; text-align: center; color: var(--accent-strong); }
.p-row { display: flex; align-items: center; gap: 6px 8px; min-height: var(--row-h); font-size: var(--text-sm2); min-width: 0; flex-wrap: wrap; }
.p-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; font-size: var(--text-xs); }
.p-where-body h4 { margin-top: 10px; }
.p-conv { display: flex; align-items: center; gap: 8px; min-height: var(--row-h); color: var(--ink); text-decoration: none; border-radius: var(--r-sm); padding: 0 4px; font-size: var(--text-sm2); }
.p-conv:hover { background: var(--surface-hover); }
.p-conv-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-conv.working .hint-text { color: var(--accent-strong); }
.p-new-conv { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.p-new-conv select { flex: 1; min-width: 0; border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); background: var(--surface); }
/* A project whose worker is offline: projects.js marks the page's root with data-offline. */
.p-offline-only { display: none; }
[data-offline] .p-offline-only { display: block; }
[data-offline] :is(span, div).p-offline-only { display: inline; }
[data-offline] div.p-row.p-offline-only { display: flex; }
[data-offline] .p-online-only { display: none; }

/* ---- projects: Code: the review bar, the changed files, the diff ---- */
.code-review-bar { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px max(14px, var(--safe-left)); background: var(--accent-soft); border-bottom: 1px solid var(--accent); font-size: var(--text-sm2); }
.rb-top { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; min-width: 0; }
.rb-label { font-weight: 700; }
.rb-branch { font-weight: 600; overflow-wrap: anywhere; }
.rb-sub { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.rb-sub .link-btn { min-height: 0; font-size: var(--text-xs); }
.rb-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rb-acts button:not(.hbtn) { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.rb-state { font-size: var(--text-sm); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rb-state .err { color: var(--err); font-weight: 600; }
.rb-guard { flex-basis: 100%; }
.review-files { display: flex; flex-direction: column; padding: 6px; }
.review-files-head { font-size: var(--text-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; display: flex; gap: 6px; align-items: center; }
.review-files .tree-file { display: flex; align-items: center; gap: 8px; min-height: var(--row-h); padding: 0 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--text-sm); overflow-wrap: anywhere; }
.review-diff { flex: 1; overflow: auto; font-family: var(--font-mono); font-size: var(--text-sm); min-height: 0; }
.rdiff { padding: 8px 0; }
.rdiff-line { display: flex; align-items: stretch; min-height: 22px; }
.rdiff-line.add { background: var(--diff-add); }
.rdiff-line.del { background: var(--diff-del); }
.rdiff-line.code-commented { box-shadow: inset 4px 0 0 var(--accent); }
.rdiff-ln { flex: none; width: 48px; min-height: 0; padding: 0 8px 0 0; text-align: right; border: none; border-radius: 0; background: none; color: var(--muted); font: inherit; font-size: var(--text-xs); }
.rdiff-ln:hover { color: var(--accent-strong); text-decoration: underline; }
.rdiff-sign { flex: none; width: 18px; color: var(--muted); }
.rdiff-line.add .rdiff-sign { color: var(--diff-plus); font-weight: 700; } .rdiff-line.del .rdiff-sign { color: var(--diff-minus); font-weight: 700; }
.rdiff-line code { white-space: pre; }
.rdiff-note { padding: 0 16px; font-family: var(--font-sans); }
.code-center { display: flex; flex-direction: column; min-height: 0; }

/* ---- projects: Git: the sync bar's inline New branch, Changes, branches in groups ---- */
.p-inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.p-inline-form input { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); font-size: var(--input-fs); font-family: var(--font-mono); }
.p-inline-form .err { color: var(--err); font-size: var(--text-sm); }
.p-changes.p-collapsed .p-changes-body .empty { margin: 0; }
.p-changes .p-done { margin: 0 0 8px; }
.p-branches .git-branch-row { flex-wrap: wrap; }
.p-branches .git-branch-row .grow { min-width: min(260px, 100%); }
.branch-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.branch-acts button:not(.hbtn), .branch-acts .button { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.p-branch-msg:empty { display: none; }
/* The Git page: what a row's action did (under its row), the bar's message, a merge left conflicted. */
.git-row-note { flex-basis: 100%; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 8px; border-radius: var(--r-md); background: var(--surface-sunken); }
.git-row-note .err, .git-bar-msg .err, .git-merging .err { color: var(--err); font-weight: 600; }
.git-bar-msg { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: var(--text-sm); }
.git-bar-msg:empty { display: none; }
.git-merging { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--err); border-radius: var(--r-md); display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); }
.git-merging[hidden] { display: none; }
.git-busy { color: var(--accent); }
.p-branch-msg { margin-top: 10px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-sunken); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: var(--text-sm); }
.p-branch-msg .err { color: var(--err); font-weight: 600; }

/* ---- projects: a project's Conversations, Memory, Settings ---- */
.p-conv-filter { margin: 4px 0 12px; }
.conv-card .tag { margin-left: 2px; }
.p-mem + .p-card-head, .p-skills-head { margin-top: 20px; }
.p-mem-form { margin-top: 0; }
.p-settings { display: block; }
.p-settings-toc { display: none; }
.p-fs { border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.p-fs legend { font-weight: 600; font-size: var(--text-md); padding: 0 6px; }
.p-settings-form { border: none; padding: 0; background: none; gap: 16px; }
.p-settings-form > .actions { position: sticky; bottom: calc(-1 * var(--page-pad-bottom)); background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 2; }
.danger-block { border-left: 4px solid var(--err) !important; margin-top: 16px; }
.danger-block h3 { color: var(--err); }
.p-quick h3 { margin: 0; font-size: var(--text-md); }
.p-quick details summary { cursor: pointer; }
.p-state-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: var(--text-md); margin: 0 0 4px; }

/* ---- chat: the header ---- */
.thread-title { display: inline-flex; flex-direction: column; justify-content: center; min-width: 0; line-height: 1.2; }
.thread-status { font-size: var(--text-2xs); color: var(--muted); padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40cqw; }
#thread-btn { line-height: 1.3; min-height: 0; }
/* The conversation's name shrinks well before the project's chip, then the agent's name; the state chips and buttons keep their size. */
.thread-wrap { flex-shrink: 10; }
.thread-wrap .thread-title { flex: 0 10 auto; }
.agent-switch { flex: 0 1 auto; min-width: 0; }
.agent-switch .agent-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.update-chip, .group-switch { flex: none; }
/* The prompt cache's countdown: quiet, tabular; muted once it's gone. */
.cache-chip { flex: none; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.cache-chip.cold { color: var(--muted); }
.group-switch { display: inline-flex; align-items: center; border: none; background: none; padding: 0 6px; min-height: var(--tap); }
.group-avatars { display: inline-flex; }
.group-avatars .avatar { width: 26px; height: 26px; font-size: 15px; border: 2px solid var(--surface); margin-left: -8px; }
.group-avatars .avatar:first-child { margin-left: 0; }
.app[data-page="chat"] .header-more { display: inline-flex; }
.split-open { display: none; }
.app[data-split="conv"] .split-open:not([hidden]) { display: inline-flex; }
.g-members { display: flex; flex-direction: column; padding: 0 6px; }
.g-member { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; min-height: var(--row-h); font-size: var(--text-sm2); }
.g-rules { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 10px; font-size: var(--text-sm); }
.g-rules dt { color: var(--muted); }
.g-rules dd { margin: 0; }
/* ---- chat: the composer's lines (To:, setup bar, @, queued), New reply ---- */
.conv-bar, .to-line { max-width: var(--chat-width, var(--chat-max)); margin: 0 auto 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* The conversation bar (chat.js drawConvBar): a chip per thing it's set to; what's off dashed (.muted), what's on lit (.on). */
.conv-bar .chip-btn { flex: none; max-width: 260px; }
.conv-bar .chip-btn .lbl, .conv-bar .bar-model { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.conv-bar .bar-model { color: var(--muted); font-weight: 400; }
.conv-bar .chip-btn.on .bar-model { color: inherit; }
.usage-chip { font-variant-numeric: tabular-nums; color: var(--ink-2); }
/* The context window's fill (chat.js contextMeter): a thin bar before the numbers; warm when nearly full. */
.ctx-meter { width: 36px; height: 6px; margin-right: 6px; vertical-align: middle; }
.usage-chip.ctx-full { color: var(--warn); }
.term-ctx { flex: none; align-self: center; font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.term-ctx.ctx-full { color: var(--warn); }
/* The status line, a row of its own on a phone (its header has no room). */
.chat-status-row { display: none; }
/* A message a conversation was opened at (a search's match, #m<id>). */
.msg.hit > .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }
.load-failed button { margin-left: 6px; }
/* A permission prompt: the command apart, in monospace; Allow once and Deny plain to tell apart. */
.question-card.permission { border-color: var(--accent); }
.q-command { margin: 6px 0 8px; padding: 8px 10px; border-radius: var(--r-md, 8px); background: var(--surface-2, var(--surface)); border: 1px solid var(--line); font-family: var(--mono, monospace); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12em; overflow: auto; }
.q-option.q-allow { border-color: var(--ok); }
.q-option.q-allow .q-label { color: var(--ok); }
.q-option.q-deny { border-color: var(--err); }
.q-option.q-deny .q-label { color: var(--err); }
:root[data-display^="eink"] :is(.q-option.q-allow, .q-option.q-deny) { border-width: var(--bw); border-color: var(--ink); }
:root[data-display^="eink"] .msg.hit > .bubble { outline: 3px solid var(--ink); }
/* The terminal page's Stop, and what was typed while it answered. */
.term-stop { flex: none; align-self: flex-end; }
.term-user .term-tag { color: var(--muted); font-size: var(--text-xs); }
.term-user.queued { opacity: .75; }
.to-line { font-size: var(--text-xs); color: var(--muted); margin-bottom: 6px; padding: 0 14px; }
.mention-list { max-width: var(--chat-width, var(--chat-max)); margin: 0 auto 6px; display: flex; flex-direction: column; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 4px; }
.mention { display: flex; align-items: center; gap: 8px; border: none; background: none; justify-content: flex-start; min-height: var(--row-h); font-weight: 500; }
.mention[aria-selected="true"] { background: var(--sel-bg); color: var(--sel-ink); }
/* A command in the composer's list (/reloadSystemPrompt …), its hint beside it. */
.mention .cmd-name { font-family: var(--font-mono); }
.chat-empty .examples { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.chat-empty .examples .chip-btn { white-space: normal; text-align: left; min-height: var(--tap-sm); }
.new-reply { position: absolute; left: 50%; transform: translateX(-50%); bottom: 120px; z-index: 4; border-radius: var(--r-full); background: var(--primary-bg); color: var(--primary-ink); border: none; box-shadow: var(--shadow-2); font-weight: 600; }
#view-chat { position: relative; }
/* ---- chat: messages ---- */
.msg-acts { display: inline-flex; gap: 2px; opacity: var(--reveal); margin-left: auto; }
.msg:hover .msg-acts, .msg.show-acts .msg-acts, .msg.last .msg-acts, .msg-acts:focus-within { opacity: 1; }
.msg-act { border: none; background: none; min-height: 22px; padding: 0 6px; font-size: var(--text-2xs); color: var(--muted); position: relative; }
.msg-act::after { content: ""; position: absolute; inset: calc((var(--tap) - 22px) / -2) 0; }
.msg-act:hover { color: var(--accent-strong); }
.msg .who { width: 100%; }
.msg.user .who { width: auto; }
.live-step { align-self: flex-start; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-full); min-height: 26px; padding: 0 12px; font-size: var(--text-xs); color: var(--ink-2); font-family: var(--font-mono); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-step .spin { animation: pulse-dot 1.2s ease-in-out infinite; }

/* An agent's question (AskUserQuestion): answered in place while its call waits. */
.question-card { align-self: stretch; border: 1px solid var(--accent); border-radius: var(--r-lg); background: var(--surface); padding: var(--sp-3) var(--sp-4); margin: var(--sp-2) 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.question-card.answered { border-color: var(--line); background: var(--surface-sunken); gap: var(--sp-1); padding: var(--sp-2) var(--sp-3); }
.q-who { font-size: var(--text-xs); color: var(--muted); }
.q-block { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.q-block legend { padding: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); }
.q-chip { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .04em; color: var(--accent-strong); background: var(--accent-soft); border-radius: var(--r-full); padding: 1px 8px; }
.q-text { font-weight: 600; }
.q-hint { font-size: var(--text-xs); color: var(--muted); }
.q-options { display: flex; flex-direction: column; gap: var(--sp-1); }
.q-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); color: var(--ink); }
.q-option:hover { background: var(--surface-hover); }
.q-option[aria-pressed="true"] { border-color: var(--accent); background: var(--sel-bg); color: var(--sel-ink); }
.q-label { font-weight: 600; }
.q-desc { font-size: var(--text-xs); color: var(--muted); }
.q-preview { margin: 0; padding: var(--sp-2) var(--sp-3); background: var(--tool-bg); border: 1px solid var(--line); border-radius: var(--r-md); font-family: var(--font-mono); font-size: var(--text-xs); white-space: pre; overflow-x: auto; max-height: 320px; }
.q-other { width: 100%; }
.q-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.q-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); border-bottom: 1px solid var(--line); padding-bottom: var(--sp-2); }
.q-tab { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-full); padding: 2px 12px; font-size: var(--text-xs); color: var(--ink-2); }
.q-tab[aria-selected="true"] { border-color: var(--accent); background: var(--sel-bg); color: var(--sel-ink); font-weight: 600; }
.q-review { display: flex; flex-direction: column; gap: var(--sp-1); }
.q-review-row { display: flex; flex-wrap: wrap; text-align: left; border: 0; background: transparent; padding: 2px 0; color: var(--ink); overflow-wrap: anywhere; }
.q-review-row:hover { color: var(--accent); }
.q-done { font-size: var(--text-sm); color: var(--ink-2); }
.q-done.muted { color: var(--muted); }
.tools-more { font-size: var(--text-xs); min-height: 0; align-self: flex-start; margin: 2px 0; }
.msg-retry { display: flex; gap: 8px; }
.msg-retry button { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.msg-note { margin: 4px 0 0; }
.msg.queued .bubble { outline: 1px dashed var(--accent); outline-offset: 2px; opacity: .8; }
.queued-acts { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.queued-acts .link-btn { min-height: var(--tap-sm); font-size: var(--text-xs); }
.msg.elsewhere .bubble { opacity: .8; }
.note.origin { text-align: left; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-md); padding: 8px 12px; background: var(--surface); color: var(--ink-2); font-size: var(--text-sm); }
/* A work item asking the owner: its question itself, to answer by writing here. */
.note.origin.work-asks { border-left-color: var(--warn); display: flex; flex-direction: column; gap: 6px; }
.note.origin.work-asks > p { margin: 0; }
.work-asks-q { color: var(--ink); font-size: var(--text-sm2); }
/* A question in words (a work item's, work_ask) keeps its lines. */
.question-card .q-text { white-space: pre-wrap; }
.work-asks-q > :first-child { margin-top: 0; } .work-asks-q > :last-child { margin-bottom: 0; }
.load-earlier { display: flex; justify-content: center; align-items: center; gap: 6px; }
.load-earlier button { min-height: var(--control-h-sm); font-size: var(--text-xs); border-radius: var(--r-full); }
/* ---- chat: the sidebar's conversations ---- */
.side-sub { padding: 8px 10px 2px; font-size: var(--text-2xs); color: var(--muted); font-weight: 600; }
.conv-link .conv-av { font-size: 15px; }
.av-stack { display: inline-flex; } .av-stack span + span { margin-left: -6px; }
.conv-link .conv-flags { font-size: var(--text-2xs); color: var(--accent-strong); }
.conv-link .conv-flags:empty { display: none; }
.conv-time, .conv-state { flex: none; font-size: var(--text-2xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.working-t { color: var(--accent-strong); font-weight: 600; }
.unread-mark { color: var(--accent); font-size: 10px; line-height: 1; }
.conv-link.unread .label, .conv-card.unread .name { font-weight: 700; }
.conv-link.unread .conv-time, .conv-card.unread .conv-time { color: var(--accent-strong); font-weight: 600; }
.conv-link .conv-dots { border: none; background: none; min-height: 0; padding: 0 4px; color: var(--muted); display: none; position: relative; }
.conv-link .conv-dots::after { content: ""; position: absolute; inset: -8px -2px; }
.conv-link .conv-star:not(.starred) { display: none; }
.conv-link:is(:hover, :focus-within) :is(.conv-dots, .conv-star) { display: inline-flex; }
.conv-link:is(:hover, :focus-within) :is(.conv-time, .conv-state) { display: none; }
.conv-link.working .label::after { content: none; }
/* Touch: ⋯ is always there (no hover to find it). */
@media (hover: none) { .conv-link .conv-dots { display: inline-flex; opacity: .7; } }
.conv-more .unread-n { color: var(--accent-strong); font-weight: 600; }
/* ---- chat: Conversations: tools, sections, cards ---- */
.conv-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.conv-tools input[type=search] { flex: 1 1 220px; min-width: 0; border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); font-size: var(--input-fs); padding: 0 10px; background: var(--surface); }
.conv-tools select { border: var(--bw) solid var(--line-input); border-radius: var(--r-md); min-height: var(--control-h); background: var(--surface); max-width: 100%; }
.tab .unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.conv-card { grid-template-columns: auto minmax(0, 1fr) auto; }
.conv-card .conv-who { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin: 0 0 2px; }
.conv-card .name { white-space: normal; overflow-wrap: anywhere; }
.conv-card.current { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conv-side .hbtn { width: var(--tap-sm); height: var(--tap-sm); }
.conv-card .preview mark { background: var(--mark); color: var(--ink); border-radius: 2px; }
.conv-section > h2 { display: flex; align-items: center; gap: 8px; }
.conv-section > h2 .p-link { margin-left: auto; font-weight: 500; }
.conv-also a { color: var(--accent-strong); }
/* Tablet on its side: Conversations and the open conversation side by side. */
.app[data-split="conv"] #view-conversations { flex: 0 0 min(400px, 45cqw); border-right: 1px solid var(--line); }
.app[data-split="conv"] #view-conversations .inner { max-width: none; }

/* ---- settings: the list's state, status lines, blocks ---- */
.settings-tabs .tab.warn .tab-desc { color: var(--warn); font-weight: 600; }
.settings-tabs .tab.err .tab-desc { color: var(--err); font-weight: 600; }
.settings-tabs .tab:is(.warn, .err) .tab-name::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn-fill); margin-left: 8px; vertical-align: 2px; }
.settings-tabs .tab.err .tab-name::after { background: var(--err); }
.settings-tabs .tab-link .tab-name { color: var(--ink-2); }
.attn { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full); background: var(--err); color: var(--accent-ink); font-size: var(--text-2xs); font-weight: 700; line-height: 16px; text-align: center; }
.nav-link .attn { position: static; margin-left: auto; }
.s-status { font-size: var(--text-sm2); color: var(--ink); margin: -2px 0 10px; }
.s-status.warn { color: var(--warn); }
.s-statusbar { border-left: 4px solid var(--accent) !important; }
.s-statusbar .s-bar-calm { display: flex; flex-direction: column; gap: 8px; }
.s-statusbar .s-bar-trouble { display: none; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--err); font-weight: 600; }
.s-statusbar[data-level="err"] { background: var(--err-soft); border-left-color: var(--err) !important; }
.s-statusbar[data-level="err"] .s-bar-calm { display: none; }
.s-statusbar[data-level="err"] .s-bar-trouble { display: flex; }
.m38 { width: 38%; }
.limit-row .meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.s-card-meter { margin: 6px 0; }
.s-del-note { margin: 4px 0 0; }
.s-saved { font-weight: 600; }
.link-btn.s-reset { margin-right: auto; font-size: var(--text-xs); min-height: var(--tap-sm); }
.settings .actions:has(.s-reset) .err { flex: 0 1 auto; }
.s-block { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.s-block h4 { margin: 0; font-size: var(--text-sm2); }
ul.plain { list-style: none; margin: 0; padding: 0; }
.s-sessions li { display: flex; align-items: center; gap: 8px; min-height: var(--row-h); border-top: 1px solid var(--line); padding: 4px 0; flex-wrap: wrap; }
.s-sessions li:first-child { border-top: none; }
.s-sessions li button { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.s-signout { border-top: 1px solid var(--line); padding-top: 12px; align-items: flex-start; }
.s-pen > summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.s-pen > summary::-webkit-details-marker { display: none; }
.s-pen > summary h3 { margin: 0; }
.s-pen > summary h3::before { content: "▸ "; color: var(--muted); }
.s-pen[open] > summary h3::before { content: "▾ "; }
.s-pen h4 { margin: 16px 0 6px; }
.field-label { font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); }
.s-phone-only { display: none; }
.w-details > summary { cursor: pointer; font-size: var(--text-sm); font-weight: 600; min-height: var(--tap-sm); display: flex; align-items: center; gap: 8px; }
.w-details[open] > summary { margin-bottom: 6px; }
.w-stray-list { margin: 6px 0; padding-left: 18px; font-size: var(--text-sm); }
.w-stray-list li { margin: 2px 0; }
/* A project about to move: what its copy has that the repository doesn't, and the choice. */
.p-move-check { margin-top: 10px; padding: 10px 14px; background: var(--warn-soft); border: 1px solid var(--warn-fill); border-left-width: 4px; border-radius: var(--r-lg); }
.p-move-check ul { margin: 6px 0; padding-left: 18px; }
.s-users-top { margin-bottom: 8px; }
.s-switch input { width: 20px; height: 20px; }
.s-confirm { background: var(--err-soft); border: 1px solid var(--err); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: var(--text-sm2); }
.s-confirm p { margin: 0; }
.s-confirm .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
button.danger:not(.pop-item) { background: var(--err); color: var(--accent-ink); border-color: var(--err); }
.p-commit button.danger, .p-mem-form button.danger, .s-user-form button.danger { background: var(--surface); color: var(--err); }
.restart-overlay { position: fixed; inset: 0; z-index: var(--z-auth); background: var(--bg); display: grid; place-items: center; text-align: center; padding: 24px; }
.restart-overlay h2 { font-size: var(--text-2xl); margin: 0 0 8px; }
.s-sticky { position: sticky; top: calc(-1 * var(--page-pad-top)); z-index: 2; background: var(--surface); padding: 6px 0; }
.log-new-line { display: flex; align-items: center; gap: 8px; font-size: var(--text-2xs); font-weight: 700; color: var(--accent-strong); margin: 4px 0; }
.log-new-line::before, .log-new-line::after { content: ""; flex: 1; border-top: 2px solid var(--accent); }
.log-entry.has-extra { cursor: pointer; }
.log-entry .extra { grid-column: 1 / -1; margin: 4px 0 0; font-size: var(--text-xs); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-entry.error { box-shadow: inset 3px 0 0 var(--err); }
.log-entry.warn { box-shadow: inset 3px 0 0 var(--warn-fill); }
.card-more { display: none; }
.row-saved { margin-left: 8px; font-size: var(--text-xs); }
.policy-grid .row-saved { grid-column: auto; }
.token-box { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: var(--r-md); display: flex; flex-direction: column; gap: 8px; }
.token-box p { margin: 0; }
.w-compose { margin: 0; font-size: var(--text-xs); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-sunken); padding: 8px; border-radius: var(--r-sm); }

/* ---- shared: round 2 by size (projects, chat, settings) ---- */
@container shell (width < 600px) {
  .project-head .p-chips .chip:not(.bad) { display: none; }
  .project-head-desc { display: none; }
  .p-ask-btn .lbl { display: none; }
  .p-ask-btn { padding: 0 10px; }
  .p-head-acts .p-more { display: inline-flex; }
  .p-open .split-main .p-open-where { display: none; }
  .chip .long { display: none; }
  .rb-acts .rb-mr { display: none; }
  .branch-acts > button:not(.primary):not(.hbtn):not(:first-child) { display: none; }
  .card .row > .card-rest { display: none; }
  .card-more { display: inline-flex; margin-left: auto; }
  .card .row button[data-primary] { margin-left: auto; }
  .card .row button[data-primary] ~ .card-more { margin-left: 0; }
  .s-wide-only { display: none; }
  .s-phone-only { display: block; }
  .w-details:not([open]) > summary .hint-text { display: none; }
  .thread-status { display: none; }
  .chat-status-row:not([hidden]) { display: block; padding: 4px 16px; font-size: var(--text-xs); color: var(--muted); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toasts { bottom: calc(var(--bottom-h) + 12px + var(--safe-bottom)); left: 16px; right: 16px; max-width: none; align-items: stretch; }
  .app:is([data-page="code"], [data-page="notepad"]) .toasts { bottom: calc(12px + var(--safe-bottom)); }
  .new-reply { bottom: 110px; }
  .conv-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 2px; }
  .conv-bar::-webkit-scrollbar { display: none; }
  .conv-bar .chip-btn { max-width: 200px; }
  .conv-card .preview { -webkit-line-clamp: 1; }
  .conv-card .meta:last-child { display: none; }
  .p-settings-form > .actions { bottom: calc(-1 * var(--page-pad-bottom)); }
}
@container shell (width >= 600px) {
  .p-ask-where { grid-template-columns: 1fr 1fr; }
  .p-ask-peek { display: none; }
}
@container shell (width >= 600px) and (width < 1024px) {
  .project-head .chip .long { display: none; }
  .p-open .p-open-where { display: none; }
}
@container shell (width >= 1024px) {
  .p-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
  .p-grid > :is(.p-needs, .p-setup) { grid-column: 1 / -1; }
  .p-main, .p-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .p-side .p-where { order: 0; } .p-side .p-sched { order: 1; } .p-side .p-convs { order: 2; }
  .p-settings { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start; }
  .p-settings-toc { display: flex; flex-direction: column; position: sticky; top: calc(56px - var(--page-pad-top)); gap: 2px; }
  .p-settings-toc a { color: var(--ink-2); text-decoration: none; font-size: var(--text-sm); padding: 6px 10px; border-radius: var(--r-sm); }
  .p-settings-toc a:hover { background: var(--surface-hover); color: var(--ink); }
  .p-settings-form > .actions { position: static; border: none; }
  .project-head-desc { flex-basis: auto; flex: 1 1 200px; }
}
@container shell (width >= 1440px) {
  .p-grid { grid-template-columns: minmax(0, 1fr) 380px; }
}


