/* Tandem. Dark by default, light supported; measurements follow docs/reference/ui-diff.md. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --blue: #1680f3;
  --blue-hover: #126fd4;
  --focus: #1e86fc;
  --sidebar-w: 300px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141414;
  --surface: #1c1c1c;
  --menu: #242424;
  --modal: #191919;
  --sunken: #1f1f1f;
  --text: #ececec;
  --text-2: rgba(236, 236, 236, .66);
  --text-3: rgba(236, 236, 236, .54);
  --text-4: rgba(236, 236, 236, .36);
  --border-1: rgba(255, 255, 255, .22);
  --border-2: rgba(255, 255, 255, .11);
  --border-3: rgba(255, 255, 255, .07);
  --divider: rgba(255, 255, 255, .04);
  --fill: rgba(255, 255, 255, .06);
  --fill-hover: rgba(255, 255, 255, .1);
  --selected: rgba(255, 255, 255, .05);
  --track: #1b1b1b;
  --raised: #222;
  --cta: #ececec;
  --cta-hover: #fff;
  --cta-text: #141414;
  --cta-off: #979797;
  --composer: #2f2f2f;
  --composer-border: transparent;
  --composer-shadow: none;
  --success: #3fbf87;
  --danger: #f2686f;
  --warn: #e5a23c;
  --overlay: rgba(0, 0, 0, .55);
  --shadow-menu: inset 0 0 0 .5px rgba(255, 255, 255, .1), 0 10px 20px -3px rgba(0, 0, 0, .45), 0 4px 6px -4px rgba(0, 0, 0, .4);
  --shadow-modal: 0 20px 32px -5px rgba(0, 0, 0, .5), 0 8px 12px -6px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .06);
  --shadow-control: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-pill: 0 4px 12px -1px rgba(0, 0, 0, .35);
  --tip-bg: #ececec;
  --tip-text: #141414;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fcfcfc;
  --surface: #fff;
  --menu: #fff;
  --modal: #fcfcfc;
  --sunken: #f5f5f5;
  --text: #1c1c1c;
  --text-2: rgba(28, 28, 28, .68);
  --text-3: rgba(28, 28, 28, .56);
  --text-4: rgba(28, 28, 28, .4);
  --border-1: rgba(28, 28, 28, .24);
  --border-2: rgba(28, 28, 28, .12);
  --border-3: rgba(28, 28, 28, .08);
  --divider: rgba(0, 0, 0, .06);
  --fill: rgba(28, 28, 28, .06);
  --fill-hover: rgba(28, 28, 28, .1);
  --selected: rgba(0, 0, 0, .06);
  --track: #f2f2f2;
  --raised: #fff;
  --cta: #1c1c1c;
  --cta-hover: #363636;
  --cta-text: #fff;
  --cta-off: #8f8f8f;
  --composer: #fff;
  --composer-border: #ebebeb;
  --composer-shadow: 0 2px 10px rgba(0, 0, 0, .04);
  --success: #00854a;
  --danger: #cd2834;
  --warn: #aa6300;
  --overlay: rgba(0, 0, 0, .13);
  --shadow-menu: inset 0 0 0 .5px rgba(28, 28, 28, .12), 0 10px 20px -3px rgba(28, 28, 28, .1), 0 4px 6px -4px rgba(28, 28, 28, .1);
  --shadow-modal: 0 20px 32px -5px rgba(28, 28, 28, .1), 0 8px 12px -6px rgba(28, 28, 28, .1), 0 0 0 1px rgba(28, 28, 28, .04);
  --shadow-control: 0 1px 3px rgba(28, 28, 28, .12);
  --shadow-pill: 0 4px 12px -1px rgba(28, 28, 28, .08);
  --tip-bg: #1c1c1c;
  --tip-text: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 420 14px/20px var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
h1, h2, h3, h4, p { margin: 0; font-weight: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled, [aria-disabled="true"] { cursor: default; }
input, textarea { background: none; border: 0; outline: 0; padding: 0; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
a { color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
textarea:focus-visible, input:focus-visible { outline: none; }
.spacer { flex: 1 1 0; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon, .mark { flex: none; display: block; }

/* --- Shell ------------------------------------------------------------------------------------ */

#app {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
}
body[data-net]:not([data-net="online"]) #app { height: calc(100dvh - var(--banner-h, 36px)); }
/* Each part keeps its own column, so hiding the sidebar or the panel never shifts the others into it. */
@media (min-width: 768px) {
  #app > .sidebar { grid-column: 1; grid-row: 1; }
  #app > #main { grid-column: 2; grid-row: 1; }
  #app > .panel { grid-column: 3; grid-row: 1; }
}

.banner {
  min-height: 36px;
  padding: 8px 16px;
  background: #dba43f;
  color: #1c1c1c;
  text-align: center;
  font-size: 13px;
  line-height: 20px;
}

.appbar, .scrim { display: none; }

.sidebar {
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--divider);
  color: var(--text-2);
}
body[data-sidebar="hidden"] .sidebar { display: none; }

.side-top { flex: none; height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 9px 0 10px; }

.icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-2);
  position: relative;
}
.icon-btn:hover:not(:disabled), .icon-btn[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.icon-btn:disabled { color: var(--text-4); }
.icon-btn.round { border-radius: 50%; width: 28px; height: 28px; }
.icon-btn.lg { width: 36px; height: 36px; border-radius: 8px; }
.icon-btn.md { width: 32px; height: 32px; border-radius: 50%; color: var(--text); }

.surface-toggle { flex: none; display: flex; padding: 2px; gap: 0; height: 30px; border-radius: 9px; background: var(--track); }
.surface-toggle button { width: 29px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--text-3); }
.surface-toggle button[aria-selected="true"] { background: var(--raised); color: var(--text); box-shadow: var(--shadow-control); }

.side-pane { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.side-nav { flex: none; display: flex; flex-direction: column; gap: 1px; padding: 4px 8px 0; }
.nav-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 8px; color: var(--text); font-size: 14px; }
.nav-item .icon { color: var(--text); }
.nav-item:hover { background: var(--fill); }
.nav-item[aria-current="page"] { background: var(--selected); }
/* How many reviews and approvals wait on the Review page. */
.nav-count { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: var(--bg); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }

.side-section { flex: none; display: flex; align-items: center; gap: 1px; height: 26px; margin-top: 7px; padding: 0 9px 0 16px; }
.side-title { font-size: 13px; color: var(--text); border-radius: 4px; }
.side-title:hover { color: var(--text-2); }
.side-empty { padding: 14px 16px 0 40px; font-size: 12px; line-height: 16px; color: var(--text-3); }

.rows { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 6px 8px 12px; scrollbar-width: thin; }
.group-label { display: flex; align-items: center; gap: 4px; min-height: 30px; padding: 2px 4px 0 8px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.group-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-more { opacity: 0; }
.group-label:hover .group-more, .group-more:focus-visible, .group-more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .group-more { opacity: 1; } }
.srow { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: center; column-gap: 4px; width: 100%; padding: 4px 8px 5px 0; border-radius: 8px; }
.srow:hover { background: var(--fill); }
.srow[aria-current="page"] { background: var(--selected); }
.srow-dot { width: 7px; height: 7px; border-radius: 50%; justify-self: center; background: transparent; }
.srow[data-dot="working"] .srow-dot { background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
.srow[data-dot="unread"] .srow-dot { background: #36b1fb; }
.srow[data-dot="needs"] .srow-dot { background: var(--warn); }
.srow[data-dot="failed"] .srow-dot { background: var(--danger); }
.srow[data-dot="stopped"] .srow-dot { background: var(--text-4); }
.srow[data-dot="read"] .srow-dot { box-shadow: inset 0 0 0 1px var(--border-1); }
.srow-title { font-size: 13px; line-height: 18px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow-meta { grid-column: 2; display: flex; align-items: center; gap: 5px; padding-left: 1px; font-size: 12px; line-height: 18px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow-flag { color: var(--warn); }
.srow-flag::after { content: " ·"; color: var(--text-3); }
@keyframes pulse { 50% { opacity: .35; } }

.agents { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.arow { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 8px; border-radius: 10px; color: var(--text); }
.arow:hover { background: var(--fill); }
.arow[aria-current="page"] { background: var(--selected); }
.arow .agent-tile { height: 38px; }
.arow-body { min-width: 0; flex: 1; }
.arow-name { display: block; font-size: 14px; line-height: 20px; }
.arow-preview { display: block; font-size: 13px; line-height: 18px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.agent-tile { flex: none; position: relative; display: grid; place-items: center; width: 40px; height: 40px; color: var(--text); --mark-cut: var(--bg); }
.agent-tile.sm { width: 32px; height: 32px; }
.agent-tile img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.agent-tile .badge { position: absolute; right: -1px; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: #f26b12; border: 2px solid var(--bg); }
.agent-tile .badge[data-state="idle"] { background: var(--text-4); }
.agent-tile .badge[data-state="working"] { background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }

.side-foot { flex: none; height: 72px; display: flex; align-items: center; gap: 8px; padding: 0 25px 0 12px; }
.profile { display: flex; align-items: center; gap: 10px; min-width: 0; height: 44px; padding: 0 10px 0 12px; border-radius: 10px; color: var(--text); font-size: 15px; }
.profile:hover { background: var(--fill); }
.profile span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #75909b; color: #fff; font-size: 14px; font-weight: 500; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

#main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1 1 0; min-height: 0; }
.expand { position: absolute; top: 10px; left: 10px; z-index: 3; }

/* --- New session ------------------------------------------------------------------------------ */

.home { display: flex; align-items: center; justify-content: center; padding: 0 16px; }
.starter { width: min(668px, 100%); }
.starter-head { display: flex; align-items: center; gap: 10px; height: 32px; margin-bottom: 22px; }
.quiet-pick { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; margin-left: -8px; border-radius: 8px; font-size: 13px; color: var(--text-2); max-width: 220px; }
.quiet-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiet-pick:hover, .quiet-pick[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.quiet-pick + .quiet-pick { margin-left: 0; }
/* How many more go with the name shown: "+2". */
.quiet-pick .pick-count { flex: none; padding: 0 6px; height: 18px; line-height: 18px; border-radius: 9px; background: var(--fill-hover); color: var(--text-2); font-size: 11px; font-weight: 500; overflow: visible; }
.quiet-pick[data-count="0"] { color: var(--text-3); }
#repos-pick { max-width: 400px; min-width: 0; flex: 0 1 auto; }
#access-pick[data-access="edit"] { color: var(--text); }

.seg { display: inline-flex; padding: 2px; height: 30px; border-radius: 15px; background: var(--track); }
.seg button { height: 26px; padding: 0 12px; border-radius: 13px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--raised); color: var(--text); font-weight: 500; box-shadow: var(--shadow-control); }

.starter-card { display: flex; flex-direction: column; min-height: 108px; border-radius: 16px; background: var(--composer); border: 1px solid var(--composer-border); box-shadow: var(--composer-shadow); cursor: text; }
.starter-card textarea { flex: 1; display: block; width: 100%; min-height: 52px; max-height: 240px; padding: 16px 16px 0; resize: none; font-size: 14px; line-height: 20px; }
.starter-tools { display: flex; align-items: center; gap: 2px; padding: 4px 12px 12px 13px; }
.starter-tools .icon-btn { width: 28px; height: 28px; border-radius: 50%; }

.chip-pick { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border-radius: 14px; font-size: 14px; color: var(--text-2); white-space: nowrap; min-width: 0; }
.chip-pick .chip-text { overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chip-pick.muted { color: var(--text-3); padding-left: 2px; margin-left: -4px; }
.chip-pick:hover, .chip-pick[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.chip-pick.model .icon { display: none; }
.chip-pick.model:hover .icon, .chip-pick.model:focus-visible .icon, .chip-pick.model[aria-expanded="true"] .icon { display: block; }
.chip-pick.muted:hover, .chip-pick.muted[aria-expanded="true"] { padding-left: 8px; margin-left: -10px; }
.chip-pick:disabled { background: none; color: var(--text-3); }
.chip-pick .glyph { display: grid; place-items: center; width: 14px; height: 14px; }

.send { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-left: 8px; border-radius: 50%; background: var(--cta); color: var(--cta-text); }
.send:hover:not(:disabled) { background: var(--cta-hover); }
.send[data-empty="true"], .send:disabled { background: var(--cta-off); }
html[data-theme="dark"] .send[data-empty="true"], html[data-theme="dark"] .send:disabled { color: #2f2f2f; }
.send[data-mode="stop"] { background: var(--cta); }
/* A prompt on its way: a ring in the round button, and (new session) a word beside it. */
.spinner { display: block; width: 14px; height: 14px; border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
.send-status { margin-left: 8px; font-size: 13px; color: var(--text-3); white-space: nowrap; }
.starter[data-sending="true"] textarea, .composer-pill textarea:read-only { color: var(--text-2); }

.note { margin: 10px 4px 0; font-size: 12px; line-height: 17px; color: var(--text-3); }
.note.warn { color: var(--warn); }
.form-error { margin: 10px 4px 0; font-size: 13px; color: var(--danger); }

/* --- Thread: a session, or a chat with an agent ------------------------------------------------ */

.thread { display: flex; flex-direction: column; position: relative; }
.thread-head { flex: none; height: 60px; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 60px; }
.thread-head .back { display: none; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; background: var(--fill); }
body[data-sidebar="hidden"] .thread-head { padding-left: 60px; }
.pill-btn { display: flex; align-items: center; gap: 8px; max-width: 100%; height: 40px; padding: 0 14px 0 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-3); box-shadow: var(--shadow-pill); font-size: 14px; font-weight: 500; }
.pill-btn .mark-slot { display: grid; place-items: center; width: 30px; height: 24px; --mark-cut: var(--surface); }
#thread-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-flag { flex: none; padding: 1px 8px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); font-size: 12px; font-weight: 420; line-height: 18px; white-space: nowrap; }
.pill-btn:hover { background: var(--sunken); }

.messages { flex: 1 1 0; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.messages-inner { display: flex; flex-direction: column; gap: 8px; width: min(960px, 100% - 32px); margin: 0 auto; padding: 0 5px 16px; }
.thread-loading { margin: 12px auto 0; padding: 0 16px; font-size: 13px; line-height: 18px; color: var(--text-3); text-align: center; }
.stamp { align-self: center; margin: 20px 0 22px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.stamp:not(:first-child) { margin-top: 14px; margin-bottom: 8px; }
.msg { max-width: min(80%, 560px); font-size: 14px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant, .msg.user, .msg.error { padding: 7px 12px; border-radius: 18px; }
.msg.assistant { align-self: flex-start; background: var(--fill); box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .16); }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; }
.msg.error { align-self: flex-start; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
/* Tool activity. Minimal: one line that unfolds. Normal: a card with the first line of output. Verbose: cards start open. */
.msg.tool { align-self: flex-start; max-width: 100%; min-width: 0; padding: 0 12px; font: 12px/18px var(--mono); color: var(--text-3); white-space: normal; }
.msg.tool[data-kind="activity"] { display: flex; align-items: baseline; gap: 6px; overflow: hidden; }
.msg.tool[data-kind="activity"]::before, .msg.tool summary::before { content: "›"; flex: none; color: var(--text-4); transition: transform .12s var(--ease); }
.msg.tool[open] > summary::before { transform: rotate(90deg); }
.msg.tool summary { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 18px; list-style: none; cursor: pointer; border-radius: 6px; }
.msg.tool summary::-webkit-details-marker { display: none; }
.msg.tool summary:hover { color: var(--text-2); }
.tool-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-sum { display: none; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-4); }
.tool-state { flex: none; display: inline-grid; place-items: center; width: 12px; height: 12px; color: var(--success); }
.msg.tool[data-state="failed"] .tool-state { color: var(--danger); }
.tool-state.spin { border: 1.5px solid var(--border-1); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tool-body { margin: 4px 0 6px 12px; padding: 8px 10px; border: 1px solid var(--border-3); border-radius: 10px; background: var(--sunken); max-width: min(100%, 640px); }
.tool-label { font: 11px/16px var(--font); color: var(--text-4); }
.tool-pre { margin: 2px 0 8px; max-height: 220px; overflow: auto; font: 12px/17px var(--mono); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-pre:last-child { margin-bottom: 0; }
body[data-toolview="normal"] .msg.tool[data-kind="call"], body[data-toolview="verbose"] .msg.tool[data-kind="call"] { width: min(100%, 560px); margin: 1px 0; padding: 6px 10px; border: 1px solid var(--border-3); border-radius: 12px; background: var(--surface); }
body[data-toolview="normal"] .tool-sum, body[data-toolview="verbose"] .tool-sum { display: block; }
body[data-toolview="normal"] .tool-title, body[data-toolview="verbose"] .tool-title { flex: none; max-width: 60%; color: var(--text-2); }
body[data-toolview="normal"] .tool-body, body[data-toolview="verbose"] .tool-body { margin: 6px 0 2px; }
.meta-row { display: none; align-self: flex-start; padding: 0 12px; font-size: 11px; line-height: 16px; color: var(--text-4); }
body[data-toolview="verbose"] .meta-row { display: block; }
.msg.assistant[data-streaming="true"]::after { content: ""; display: inline-block; width: 6px; height: 14px; margin-left: 3px; vertical-align: -2px; border-radius: 1px; background: var(--text-3); animation: pulse 1s ease-in-out infinite; }
.msg.assistant[data-partial="true"] { border: 1px dashed var(--border-2); }

/* What a run changed: files with their line counts; each unfolds to its patch. */
.msg.diff { align-self: flex-start; width: min(100%, 640px); max-width: 100%; padding: 0; border: 1px solid var(--border-3); border-radius: 14px; background: var(--surface); white-space: normal; overflow: hidden; }
.diff-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.diff-title { flex: 1; min-width: 0; color: var(--text); }
.diff-add { color: var(--success); font: 12px/18px var(--mono); }
.diff-del { color: var(--danger); font: 12px/18px var(--mono); }
.diff-files { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border-3); }
.diff-files li + li { border-top: 1px solid var(--divider); }
.diff-file { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 12px; text-align: left; font-size: 13px; color: var(--text); }
.diff-file:hover { background: var(--fill); }
.diff-status { flex: none; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; font: 600 10px/1 var(--mono); background: var(--fill); color: var(--warn); }
.diff-status.added { color: var(--success); }
.diff-status.deleted { color: var(--danger); }
.diff-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px/18px var(--mono); direction: rtl; text-align: left; }
.diff-patch { border-top: 1px solid var(--divider); background: var(--sunken); }
.patch { margin: 0; padding: 6px 0; max-height: 360px; overflow: auto; font: 12px/18px var(--mono); }
.pl { display: block; padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pl.add { background: color-mix(in srgb, var(--success) 14%, transparent); }
.pl.del { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.pl.hunk, .pl.note { color: var(--text-4); }
.patch-note { padding: 8px 12px; font-size: 12px; color: var(--text-3); }
.review { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border-3); font-size: 13px; }
.review-text { flex: 1; min-width: 120px; color: var(--text-2); }
.review[data-status="approved"] .review-text { color: var(--success); }
.review[data-status="changes_requested"] .review-text { color: var(--warn); }
.review-comment { flex-basis: 100%; color: var(--text-3); overflow-wrap: anywhere; }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.msg.notice[data-tone="stopped"] { color: var(--text-4); }
.msg.notice { align-self: center; max-width: 100%; padding: 2px 12px; font-size: 12px; line-height: 18px; color: var(--text-3); text-align: center; }

.usage-pills { flex: none; display: flex; align-items: center; gap: 6px; width: min(960px, 100% - 32px); margin: 0 auto; padding: 0 2px 8px; }
.usage-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--border-3); background: var(--fill); color: var(--text-2); font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: default; }
.usage-pill:first-child { padding-left: 7px; }
.usage-ring { display: grid; place-items: center; width: 14px; height: 14px; }
.usage-ring-track { stroke: var(--border-1); }
.usage-ring-fill { stroke: var(--accent, var(--blue)); }
.usage-pill[data-level="high"] .usage-ring-fill { stroke: var(--warn); }
.usage-pill[data-level="full"] .usage-ring-fill { stroke: var(--danger); }
.usage-pills[data-busy="true"] .usage-ring { animation: pulse 1.4s ease-in-out infinite; }

.composer { flex: none; width: min(960px, 100% - 32px); margin: 0 auto; padding-bottom: 20px; }
.composer-pill { display: flex; align-items: flex-end; gap: 8px; min-height: 46px; padding: 8px; border-radius: 22px; background: var(--composer); border: 1px solid var(--composer-border); cursor: text; }
.composer-pill textarea { flex: 1 1 130px; min-width: 130px; height: 28px; max-height: 200px; padding: 4px 0 4px 2px; resize: none; font-size: 14px; line-height: 20px; }
.composer-pill .send { margin-left: 0; }
.composer-pill .chip-pick.model { flex: 0 1 auto; }
.composer-pill .chip-pick.model .chip-text { max-width: 140px; }
.thread-brief { display: none; }
.round-btn { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--fill); color: var(--text-2); }
.round-btn:hover, .round-btn[aria-expanded="true"] { background: var(--fill-hover); color: var(--text); }
.round-btn[aria-pressed="true"] { background: var(--danger); color: #fff; }
.thread .form-error { width: min(960px, 100% - 32px); margin: -12px auto 12px; padding: 0 12px; }

/* --- Side panel ------------------------------------------------------------------------------- */

.panel { position: relative; width: var(--panel-w, 420px); min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
/* The panel's left edge is its handle: drag it to resize. A line shows where it is on hover and while dragging. */
.panel-grip { position: absolute; z-index: 3; top: 0; bottom: 0; left: 0; width: 9px; cursor: col-resize; touch-action: none; }
.panel-grip::after { content: ""; position: absolute; top: 14px; bottom: 14px; left: 2px; width: 2px; border-radius: 1px; background: var(--accent); opacity: 0; transition: opacity .12s; }
.panel-grip:hover::after, .panel-grip:focus-visible::after, body[data-resizing="panel"] .panel-grip::after { opacity: .9; }
.panel-grip:focus-visible { outline: none; }
body[data-resizing] { cursor: col-resize; user-select: none; -webkit-user-select: none; }
body[data-resizing] * { cursor: col-resize !important; }
body[data-resizing] iframe { pointer-events: none; }
.panel-head { flex: none; height: 60px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 14px; }
.panel-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0 25px 24px 17px; scrollbar-width: thin; }
.agent-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 0; min-height: 52px; }
.agent-head button.agent-tile { border-radius: 10px; }
.agent-head button.agent-tile:hover { background: var(--fill); }
.agent-head-text { min-width: 0; }
.agent-head-name { font-size: 15px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-head-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; line-height: 20px; color: var(--text-3); }
.panel-label { margin: 16px 12px 7px; font-size: 14px; line-height: 20px; color: var(--text-3); }
.panel-card { border: 1px solid var(--border-3); border-radius: 12px; background: var(--surface); }
.computer { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 9px 10px 9px 12px; }
.computer-text { flex: 1; min-width: 0; }
.computer-title { font-size: 14px; line-height: 20px; }
.computer-sub { font-size: 14px; line-height: 20px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.computer-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; background: var(--fill); font-size: 13px; color: var(--text); }
.computer-btn:hover:not(:disabled) { background: var(--fill-hover); }
.panel-note { padding: 16px 12px; font-size: 13px; line-height: 18px; color: var(--text-3); }
.todos { list-style: none; margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.todos li { display: flex; align-items: baseline; gap: 9px; font-size: 13px; line-height: 19px; }
.todos li::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--border-1); transform: translateY(1px); }
.todos li[data-status="in_progress"]::before { border-color: var(--blue); background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
.todos li[data-status="completed"]::before { border-color: var(--success); background: var(--success); }
.todos li[data-status="completed"] span { color: var(--text-3); text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 2px; }
.chip { height: 30px; max-width: 100%; padding: 0 12px; border-radius: 15px; background: var(--fill); font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: var(--fill-hover); }
.chip.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.chip.with-icon span { overflow: hidden; text-overflow: ellipsis; }
.facts { padding: 4px 12px; }
.fact { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; font-size: 13px; line-height: 18px; }
.fact dt { flex: none; }
.fact dd { min-width: 0; }
.fact dd .select-btn { height: 24px; margin: -3px 0; max-width: 100%; }
.fact dd .select-btn span { overflow: hidden; text-overflow: ellipsis; }
.fact + .fact { border-top: 1px solid var(--divider); }
.fact dt { color: var(--text-3); }
.fact dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.panel-actions { display: flex; gap: 8px; margin: 16px 2px 0; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); }
.status[data-status="running"]::before, .status[data-status="queued"]::before { background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
.status[data-status="done"] { color: var(--success); }
.status[data-status="done"]::before { background: var(--success); }
.status[data-status="failed"] { color: var(--danger); }
.status[data-status="failed"]::before { background: var(--danger); }
.status[data-status="needs"] { color: var(--warn); }
.status[data-status="needs"]::before { background: var(--warn); }
.tag { padding: 1px 6px; border-radius: 4px; background: var(--fill); font-size: 12px; line-height: 16px; color: var(--text-2); }
.fallback { color: var(--warn); font-size: 13px; }

/* --- Buttons and form controls ---------------------------------------------------------------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--fill); font-size: 13px; color: var(--text); white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--fill-hover); }
.btn:disabled { color: var(--text-4); }
.btn.primary { background: var(--cta); color: var(--cta-text); }
.btn.primary:hover:not(:disabled) { background: var(--cta-hover); }
.btn.primary:disabled { background: var(--cta-off); color: var(--cta-text); }
.btn.outline { background: var(--surface); border: 1px solid var(--border-3); }
.btn.text { background: none; color: var(--text-2); padding: 0 8px; }
.btn.text:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.lg { height: 36px; padding: 0 16px; border-radius: 18px; font-size: 14px; }
.btn.block { width: 100%; height: 36px; border-radius: 10px; }

.select-btn { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 6px 0 8px; border-radius: 6px; border: 1px solid var(--border-3); background: var(--surface); font-size: 13px; white-space: nowrap; }
.select-btn .icon { color: var(--text-2); }
.select-btn:hover, .select-btn[aria-expanded="true"] { background: var(--sunken); }

.switch { flex: none; position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--fill); box-shadow: inset 0 0 0 1px var(--border-3); transition: background .1s; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(28, 28, 28, .2); transition: transform .12s var(--ease); }
.switch[aria-checked="true"] { background: var(--blue); box-shadow: none; }
.switch[aria-checked="true"]:hover { background: var(--blue-hover); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(14px); }

.field { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-3); background: var(--surface); font-size: 13px; }
.field:focus { border-color: var(--border-1); }
textarea.field { height: auto; padding: 8px 10px; line-height: 20px; resize: vertical; }
.field-row { display: flex; align-items: center; gap: 8px; }

.tabs { display: inline-flex; gap: 2px; }
.tabs button { height: 28px; padding: 0 12px; border-radius: 14px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--fill); color: var(--text); }

[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--tip-bg);
  color: var(--tip-text);
  font: 420 12px/16px var(--font);
  white-space: nowrap;
  pointer-events: none;
}
[data-tip][data-tip-side="top"]:hover::after, [data-tip][data-tip-side="top"]:focus-visible::after { top: auto; bottom: calc(100% + 8px); }
[data-tip][data-tip-align="start"]:hover::after, [data-tip][data-tip-align="start"]:focus-visible::after { left: 0; transform: none; }
[data-tip][data-tip-align="end"]:hover::after, [data-tip][data-tip-align="end"]:focus-visible::after { left: auto; right: 0; transform: none; }
[data-tip][aria-expanded="true"]::after { display: none; }

/* --- Menus and popovers ----------------------------------------------------------------------- */

#layer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#layer > * { pointer-events: auto; }

.menu, .popover { position: fixed; z-index: 60; background: var(--menu); border-radius: 12px; box-shadow: var(--shadow-menu); overflow-y: auto; scrollbar-width: thin; }
.menu { min-width: 144px; max-width: calc(100vw - 16px); padding: 5px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 0 8px; border-radius: 8px; font-size: 13px; line-height: 18px; color: var(--text); white-space: nowrap; }
.menu-item + .menu-item { margin-top: 1px; }
.menu-item:hover, .menu-item:focus-visible, .menu-item.open, .menu-item.checked { background: var(--fill); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item[aria-disabled="true"] { color: var(--text-4); background: none; }
.menu-icon { flex: none; display: grid; place-items: center; width: 16px; color: var(--text-2); }
.menu-label { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
/* The hint gives way first: a long one is cut short before the label loses a letter. */
.menu-hint { flex: 0 1000 auto; min-width: 0; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.menu-stack { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 5px 0; }
.menu-detail { font-size: 12px; line-height: 16px; color: var(--text-3); white-space: normal; }
.menu.model-menu .menu-detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-fill { flex: 1; min-width: 8px; }
.menu-badge { padding: 1px 7px; border-radius: 9px; background: var(--fill-hover); font-size: 11px; line-height: 16px; color: var(--text-2); }
.menu-tag { padding: 1px 6px; border-radius: 4px; background: var(--fill); font-size: 12px; line-height: 16px; color: var(--text-2); }
.menu-check { color: var(--blue); display: grid; }
.menu-chevron { color: var(--text-2); display: grid; }
.menu-divider { height: 1px; margin: 4px 8px; background: var(--border-3); }
.menu-heading { padding: 8px 8px 4px; font-size: 13px; color: var(--text-3); }
.menu-search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; margin-bottom: 4px; color: var(--text-3); }
.menu-search-input { flex: 1; width: 0; font-size: 14px; color: var(--text); }
.menu.roomy .menu-item { min-height: 32px; font-size: 14px; line-height: 20px; }
.menu.roomy .menu-check { color: var(--text); }
.menu.model-list { min-width: 262px; max-height: min(560px, calc(100dvh - 16px)) !important; }
/* A long list scrolls inside the menu; the family it is in stays in view at the top. */
.menu.model-list .menu-heading { position: sticky; top: 0; z-index: 1; background: var(--menu); }
.menu.roomy .menu-item.checked:not(:hover):not(:focus-visible):not(.open) { background: none; }
.menu.add-menu .menu-label { flex: none; }
.select-menu { min-width: 146px; }
.select-menu .menu-item { min-height: 30px; }
.select-menu .menu-check { color: var(--text-2); }
.menu.add-menu { width: 360px; }
.menu.add-menu .menu-item { font-size: 14px; min-height: 30px; }

.popover { padding: 16px; }
.popover:focus-visible { outline: none; }
.popover h3 { font-size: 15px; line-height: 22px; font-weight: 500; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.share { width: 360px; padding: 12px; }
.share .pop-head { padding: 4px 4px 0; }
.share-banner { position: relative; padding: 28px 24px 20px; border-radius: 12px; background: var(--fill); text-align: center; font-size: 14px; color: var(--text-2); }
.share-banner strong { display: block; margin-top: 10px; font-size: 15px; font-weight: 500; color: var(--text); }
.share-banner .icon-btn { position: absolute; top: 8px; right: 8px; }
.share-faces { display: inline-flex; align-items: center; }
.share-faces > * + * { margin-left: -6px; }
.share .field { width: 100%; height: 36px; margin: 8px 0 4px; font-size: 14px; }
.share-row { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 2px; font-size: 14px; }
.share-row .role { margin-left: auto; color: var(--text-2); }
.share-access { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 0 2px; border-radius: 8px; font-size: 14px; }
.share-access:hover, .share-access[aria-expanded="true"] { background: var(--fill); }
.tile-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border-3); background: var(--fill); color: var(--text-2); }
.share-foot { display: flex; align-items: center; gap: 8px; width: calc(100% + 24px); margin: 10px -12px -12px; padding: 12px 14px; border-top: 1px solid var(--border-3); font-size: 14px; }
.share-foot small { display: block; font-size: 14px; color: var(--text-2); }
.share-foot:hover { background: var(--fill); }

.looks { width: 294px; padding: 12px; }
.looks .tabs { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-3); width: 100%; }
.look-preview { display: grid; place-items: center; height: 180px; border-radius: 14px; background: var(--fill); --mark-cut: var(--sunken); }
.look-grid { display: flex; flex-wrap: wrap; gap: 6px 5px; justify-content: center; width: 260px; margin: 18px auto; }
.look-grid button { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; --mark-cut: var(--menu); }
.look-grid button:hover { background: var(--fill); }
.look-grid button[aria-pressed="true"] { background: var(--fill); box-shadow: inset 0 0 0 1px var(--border-2); }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; padding: 0 18px 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--menu); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 1.5px var(--text); }
.looks textarea.field { width: 100%; height: 168px; font-size: 15px; line-height: 22px; resize: none; }
.dropzone { display: grid; place-content: center; justify-items: center; gap: 10px; height: 216px; border: 1px dashed var(--border-1); border-radius: 12px; font-size: 15px; color: var(--text-2); }

.anywhere { width: 340px; padding: 16px; }
.anywhere h3 { font-size: 17px; font-weight: 420; }
.anywhere-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.anywhere-tile { display: flex; align-items: flex-start; gap: 8px; height: 111px; padding: 8px; border-radius: 10px; background: color-mix(in srgb, var(--text) 22%, var(--menu)); font-size: 14px; color: var(--text); }
html[data-theme="light"] .anywhere-tile { background: #c3c7ca; }
html[data-theme="light"] .anywhere-tile:nth-child(2) { background: #b3c2cf; }
.anywhere-tile:hover { filter: brightness(1.06); }
.anywhere-tile .tile-icon { width: 22px; height: 22px; border-radius: 6px; border: 0; background: var(--raised); color: var(--text); }
.anywhere-tile span:last-child { line-height: 22px; }

.toasts { position: fixed; z-index: 90; right: 16px; bottom: calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: 20px minmax(0, 1fr) 20px; gap: 10px; align-items: start; padding: 11px 10px 11px 12px; border-radius: 10px; background: var(--menu); box-shadow: var(--shadow-menu); color: var(--text); text-align: left; font-size: 13px; line-height: 18px; transition: background .12s; animation: toast-in 240ms cubic-bezier(.2, .9, .3, 1) both; }
.toast[data-open] { cursor: pointer; }
.toast[data-open]:hover { background: color-mix(in srgb, var(--menu) 94%, var(--text)); }
.toast[data-open]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toast.leaving { pointer-events: none; animation: toast-out 160ms ease-in both; }
.toast-mark { display: grid; place-items: center; width: 20px; height: 20px; margin-top: -1px; border-radius: 50%; color: var(--text-3); background: color-mix(in srgb, currentColor 16%, transparent); }
.toast[data-kind="ok"] .toast-mark { color: var(--success); }
.toast[data-kind="bad"] .toast-mark { color: var(--danger); }
.toast-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.toast-title { font-weight: 500; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toast-body { color: var(--text-3); font-size: 12.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.toast-x { display: grid; place-items: center; width: 20px; height: 20px; margin-top: -1px; border-radius: 5px; color: var(--text-4); opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.toast:hover .toast-x, .toast:focus-within .toast-x { opacity: 1; }
.toast-x:hover { color: var(--text); background: var(--fill-hover); }
@media (hover: none) { .toast-x { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(12px); } }

/* --- Modals ----------------------------------------------------------------------------------- */

.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: var(--overlay); }
.modal { position: relative; display: flex; width: min(1120px, 100%); height: min(800px, 100%); background: var(--modal); border-radius: 16px; box-shadow: var(--shadow-modal); overflow: hidden; }
.modal:focus-visible { outline: none; }
.modal-close { position: absolute; top: 18px; right: 18px; z-index: 2; }

.modal.small { width: min(420px, 100%); height: auto; max-height: 100%; }
.dialog-body { display: flex; flex-direction: column; gap: 12px; width: 100%; padding: 24px; }
.dialog-body h2 { font-size: 17px; line-height: 22px; font-weight: 500; }
.dialog-body p { font-size: 13px; color: var(--text-2); }
.dialog-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.dialog-body .field { height: 36px; font-size: 14px; color: var(--text); }
.dialog-body textarea.field { height: 88px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.settings-nav { flex: none; width: 300px; padding: 0 8px 16px; border-right: 1px solid var(--divider); overflow-y: auto; scrollbar-width: thin; }
.back-link { display: flex; align-items: center; justify-content: flex-end; height: 56px; margin-bottom: 14px; padding-right: 6px; }
.back-link button { display: inline-flex; align-items: center; gap: 9px; height: 28px; padding: 0 8px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.back-link button:hover { background: var(--fill); color: var(--text); }
.set-nav-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; margin-bottom: 2px; padding: 0 9px; border-radius: 8px; font-size: 13px; color: var(--text); }
.set-nav-item .icon { color: var(--text-2); }
.set-nav-item:hover { background: var(--fill); }
.set-nav-item[aria-current="page"] { background: var(--selected); }
.set-nav-label { padding: 14px 9px 8px; font-size: 12px; line-height: 16px; color: var(--text-3); }

.settings-body { flex: 1 1 0; min-width: 0; overflow-y: auto; padding: 68px 74px 48px 64px; scrollbar-width: thin; }
.set-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.set-h { font-size: 17px; line-height: 22px; font-weight: 500; }
.set-sub { margin-top: 6px; max-width: 480px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.set-section { margin-top: 28px; }
.settings-body .page-toolbar { margin-top: 24px; }
.settings-body .page-toolbar + .set-section { margin-top: 18px; }
.set-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px; margin-bottom: 8px; }
.set-label h3 { font-size: 12px; line-height: 16px; color: var(--text); }
.set-label p { font-size: 12px; line-height: 16px; color: var(--text-2); }
.set-label.big h3 { font-size: 14px; line-height: 20px; color: var(--text-2); }
.set-card { padding: 8px 14px; border: 1px solid var(--border-3); border-radius: 12px; background: var(--surface); }
.set-card + .set-card { margin-top: 16px; }
.set-card.tight { padding: 0 8px; }
.set-card.tight .set-row { min-height: 46px; padding: 0; gap: 8px; }
.set-row.tall { padding: 12px 0; }
.set-row { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 9px 0; }
.set-text { flex: 1; min-width: 0; }
.set-title { display: flex; align-items: center; gap: 7px; font-size: 13px; line-height: 18px; color: var(--text); }
.set-title .icon { color: var(--text-2); }
.set-desc { font-size: 13px; line-height: 18px; color: var(--text-2); }
.set-control { flex: none; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.set-note { padding: 12px 0; font-size: 12px; line-height: 18px; color: var(--text-2); }
.set-foot { margin-top: 10px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.set-empty { padding: 22px 0 8px; font-size: 13px; color: var(--text-3); text-align: center; }
.set-empty + .set-foot { font-size: 13px; text-align: center; }
.mono { font: 13px/18px var(--mono); overflow-wrap: anywhere; }
.underline { text-decoration: underline; text-underline-offset: 2px; }
.provider-row { display: flex; align-items: center; gap: 12px; min-height: 68px; }
.provider-row .btn { padding: 0 17px; }
.provider-row .glyph { flex: none; display: grid; place-items: center; width: 16px; height: 16px; }
.provider-row .set-text { font-size: 13px; }
.ok-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--success); white-space: nowrap; }
.ok-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ok-dot.warn { color: var(--warn); }
.ok-dot.off { color: var(--text-3); }
.meter { height: 3px; margin: 12px 0 10px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 2px; background: var(--border-1); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 14px 8px 12px 0; font-weight: 420; font-size: 12px; color: var(--text-2); text-align: left; white-space: nowrap; }
.table td { padding: 9px 8px 9px 0; border-top: 1px solid var(--divider); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table td[colspan] { text-align: left; }
#usage-range button { padding: 0 9px; }
.settings-body .toolbar { gap: 6px; flex-wrap: nowrap; }
.table th:last-child, .table td:last-child { text-align: right; padding-right: 0; }
.table .muted, .muted { color: var(--text-2); }
.table .clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person { display: flex; align-items: center; gap: 10px; }
.person small { display: block; font-size: 13px; color: var(--text-2); }

.custom-body { flex: 1 1 0; min-width: 0; overflow-y: auto; padding: 68px 48px 48px; scrollbar-width: thin; }
.custom-body > .tabs { margin: 20px 0 22px; }
.custom-section { padding: 0 8px; }
.custom-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.custom-head h3 { font-size: 15px; line-height: 22px; }
.custom-head p { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.custom-tools { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.custom-tools .icon-btn { width: 28px; height: 28px; }
.custom-sub { display: flex; align-items: center; gap: 6px; margin: 22px 0 6px; font-size: 13px; line-height: 18px; }
.custom-sub .count { color: var(--text-4); }
.custom-empty { padding: 18px 2px 20px; font-size: 13px; color: var(--text-2); }
#memory-empty { margin-left: -8px; font-size: 14px; }
.custom-tools .btn.text { color: var(--text); }
.plugin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; }
.plugin { display: flex; align-items: center; gap: 12px; min-height: 54px; padding-right: 2px; }
.plugin-tile { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-3); background: var(--surface); }
.plugin-tile span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 600; }
.plugin-text { flex: 1; min-width: 0; }
.plugin-name { font-size: 13px; line-height: 18px; }
.plugin-meta { font-size: 12px; line-height: 17px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-bar { display: flex; align-items: center; justify-content: space-between; margin: 20px -8px 0; padding: 0 8px 16px; border-bottom: 1px solid var(--border-3); font-size: 13px; }
.memory-list { margin: 0 -8px; }
.memory-item { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--divider); font-size: 14px; }
.memory-item small { color: var(--text-3); font-size: 12px; white-space: nowrap; }

.modal.market { width: min(1100px, 100%); height: min(860px, 100%); border-radius: 20px; }
.market-body { flex: 1 1 0; min-width: 0; overflow-y: auto; padding: 38px 50px 48px 40px; scrollbar-width: thin; }
.market .modal-close { top: 16px; right: 26px; width: 32px; height: 32px; border-radius: 50%; background: var(--fill); }
.market h2 { font-size: 36px; line-height: 44px; font-weight: 420; letter-spacing: -.01em; }
.market-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.market-chips button { height: 40px; padding: 0 18px; border-radius: 20px; background: var(--fill); font-size: 14px; white-space: nowrap; }
.market-chips button:hover { background: var(--fill-hover); }
.market-chips button[aria-selected="true"] { background: var(--cta); color: var(--cta-text); }
.market-search { display: flex; align-items: center; gap: 10px; height: 48px; margin-top: 32px; padding: 0 18px; border-radius: 24px; background: var(--fill); color: var(--text-2); }
.market-search input { flex: 1; font-size: 16px; color: var(--text); }
.market-h { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 6px; font-size: 18px; line-height: 24px; }
.market-h.lead { margin-bottom: 18px; }
.market-h button { padding: 4px 12px; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.market-h button:hover { background: var(--fill); color: var(--text); }
.featured { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 79px; }
.featured-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 183px; padding: 16px 12px; border-radius: 16px; background: var(--sunken); font-size: 14px; line-height: 22px; text-align: center; --mark-cut: #fff; }
.featured-card:hover { background: var(--fill-hover); }
.featured-card .mark { margin-bottom: 18px; }
.featured-card small { font-size: 14px; color: var(--text-2); }
.market-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 36px; }
.market-item { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 0 12px 0 16px; border-radius: 12px; }
.market-item:hover { background: var(--fill); }
.market-item .mark { --mark-cut: #fff; }
.market-text { flex: 1; min-width: 0; }
.market-name { font-size: 15px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-desc { font-size: 14px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-item .btn { height: 32px; padding: 0 14px; border-radius: 16px; font-size: 14px; }

.modal.palette { width: min(600px, 100%); height: auto; max-height: min(520px, 100%); flex-direction: column; align-self: start; margin-top: 12vh; }
.palette-input { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border-3); color: var(--text-3); }
.palette-input input { flex: 1; font-size: 15px; color: var(--text); }
.palette-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.palette-group { padding: 8px 10px 4px; font-size: 12px; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border-radius: 8px; font-size: 14px; }
.palette-item .icon { color: var(--text-2); }
.palette-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { margin-left: auto; padding-left: 12px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.palette-item[aria-selected="true"] { background: var(--fill); }
/* A session found by what was said in it: its title, and the words around the match. */
.palette-text { display: flex; flex-direction: column; min-width: 0; padding: 5px 0; }
.palette-detail { font-size: 12px; line-height: 16px; color: var(--text-3); }
.palette-empty { padding: 28px 16px; text-align: center; font-size: 13px; color: var(--text-2); }
kbd { padding: 1px 5px; border-radius: 4px; background: var(--fill); font: 11px/16px var(--font); color: var(--text-2); }

/* --- Pages: Sessions, Automations, Review, Analytics ------------------------------------------ */

.page { overflow-y: auto; scrollbar-width: thin; }
.page-inner { width: min(1074px, 100% - 48px); margin: 0 auto; padding: 68px 0 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.page-card { margin-top: 28px; padding: 6px 16px; border: 1px solid var(--border-3); border-radius: 12px; background: var(--surface); }
.page-card + .page-card { margin-top: 24px; }
.page-card h3 { padding: 12px 0 2px; font-size: 13px; line-height: 18px; color: var(--text); }
.page-card .caption { font-size: 12px; color: var(--text-2); }
.page-empty { display: grid; place-content: center; justify-items: center; gap: 6px; min-height: 180px; padding: 28px 16px; text-align: center; font-size: 13px; color: var(--text-2); }
.page-empty strong { font-size: 14px; font-weight: 500; color: var(--text); }
.page-empty .btn { margin-top: 10px; }
.list-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 9px 0; text-align: left; }
.list-row + .list-row { border-top: 1px solid var(--divider); }
button.list-row:hover .list-title { text-decoration: underline; text-underline-offset: 2px; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 14px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 13px; line-height: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-side { flex: none; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.progress { width: 72px; height: 3px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--success); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: 10px 0 14px; }
.tile { padding: 4px 16px 4px 0; }
.tile + .tile { padding-left: 16px; border-left: 1px solid var(--divider); }
.tile dt { font-size: 12px; line-height: 16px; color: var(--text-2); }
.tile dd { margin: 6px 0 0; font-size: 24px; line-height: 30px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tile small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.chart { display: block; width: 100%; height: 190px; margin: 6px 0 4px; }
.chart .bar { fill: var(--blue); }
.chart .grid { stroke: var(--divider); stroke-width: 1; }
.chart text { fill: var(--text-3); font: 11px var(--font); }
.chart .value { fill: var(--text-2); }

/* --- Sign-in ---------------------------------------------------------------------------------- */


/* --- Narrower desktop: the side panel floats over the thread ---------------------------------- */

@media (max-width: 1019px) {
  .panel { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(420px, 100%); box-shadow: var(--shadow-modal); border-left: 1px solid var(--border-3); }
  .panel-grip { display: none; }
}

/* --- Phone: drawer sidebar, composer at the bottom -------------------------------------------- */

@media (max-width: 767px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .appbar { display: flex; align-items: center; gap: 4px; height: calc(52px + var(--safe-top)); padding: var(--safe-top) 4px 0; }
  .appbar-title { flex: 1; min-width: 0; text-align: center; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appbar .icon-btn { width: 44px; height: 44px; border-radius: 10px; color: var(--text); }
  body[data-view="thread"] .appbar { display: none; }

  .sidebar { position: fixed; z-index: 25; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); transform: translateX(-102%); transition: transform .2s var(--ease); box-shadow: none; }
  body[data-sidebar="hidden"] .sidebar { display: flex; }
  body[data-drawer="open"] .sidebar { transform: none; box-shadow: var(--shadow-modal); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 24; background: var(--overlay); }
  #collapse-btn, .expand { display: none; }
  .side-top { height: 52px; }
  .side-top .icon-btn { width: 44px; height: 44px; }
  .side-top { gap: 0; padding: 0 8px 0 4px; }
  .surface-toggle { height: 48px; border-radius: 13px; }
  .surface-toggle button { width: 44px; height: 44px; border-radius: 11px; }
  .nav-item { height: 44px; }
  .side-section { height: 44px; padding-right: 4px; }
  .side-section .icon-btn { width: 44px; height: 44px; }
  .side-title { height: 44px; }
  .srow { min-height: 48px; }
  .arow { min-height: 56px; }
  .side-foot .icon-btn { width: 44px; height: 44px; }
  .side-foot { padding-right: 12px; gap: 4px; }
  .side-foot .spacer { display: none; }
  .profile { flex: 1; }

  #main { grid-row: 2; }
  .home { align-items: flex-end; padding: 0 12px calc(12px + var(--safe-bottom)); }
  .starter-head { flex-wrap: wrap; height: auto; row-gap: 8px; margin-bottom: 12px; }
  .quiet-pick { height: 44px; max-width: 180px; }
  /* While a prompt is on its way the level chip makes room for "Starting…". */
  .starter[data-sending="true"] #effort-pick { display: none; }
  .seg { height: 48px; border-radius: 24px; }
  .seg button { height: 44px; border-radius: 22px; padding: 0 14px; }
  .starter-card { min-height: 104px; }
  .starter-card textarea { font-size: 16px; line-height: 22px; }
  .starter-tools { gap: 0; padding: 0 8px 8px; }
  .starter-tools .icon-btn, .starter-tools .send { width: 44px; height: 44px; }
  .starter-tools .chip-pick { height: 44px; }
  .chip-pick .chip-text { max-width: 96px; }

  .thread-head { height: calc(56px + var(--safe-top)); padding: var(--safe-top) 64px 0; }
  .thread-head .back { display: grid; left: 8px; top: calc(50% + var(--safe-top) / 2); width: 44px; height: 44px; }
  .pill-btn { height: 44px; }
  .messages-inner, .usage-pills, .composer { width: calc(100% - 24px); }
  .usage-pills { overflow-x: auto; scrollbar-width: none; }
  .msg { max-width: 88%; }
  .msg.diff, .msg.tool { max-width: 100%; }
  .msg.tool summary { min-height: 44px; min-width: 44px; }
  .msg.tool[data-kind="activity"] { min-height: 28px; }
  .diff-file { min-height: 44px; }
  .review .btn.sm { height: 44px; min-width: 44px; padding: 0 14px; font-size: 13px; }
  .composer { padding-bottom: calc(10px + var(--safe-bottom)); }
  .composer-pill { border-radius: 26px; padding: 4px; gap: 2px; }
  .composer-pill textarea { height: 44px; padding: 11px 0 11px 6px; font-size: 16px; line-height: 22px; }
  .composer-pill .round-btn, .composer-pill .send { width: 44px; height: 44px; }
  .composer-pill .chip-pick { display: none; }
  .thread-brief { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 0 14px 6px; font-size: 12px; line-height: 16px; color: var(--text-3); }
  .thread-brief .glyph { flex: none; display: grid; place-items: center; width: 12px; height: 12px; }
  .thread-brief span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .panel { width: 100%; border-left: 0; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
  .panel-head .icon-btn { width: 44px; height: 44px; }
  .panel-head { gap: 4px; padding: 0 8px; }
  .panel-body { padding: 0 16px 24px; }
  .agent-head .agent-tile { width: 44px; height: 44px; }
  .computer-btn { height: 44px; }
  .chip { height: 44px; border-radius: 22px; padding: 0 16px; }
  .panel .btn { height: 44px; border-radius: 22px; padding: 0 16px; }

  .menu-item, .menu.roomy .menu-item { min-height: 44px; font-size: 15px; }
  .menu-search { height: 44px; }
  .menu-search-input { font-size: 16px; }
  .menu.add-menu { width: calc(100vw - 16px); }
  .share, .anywhere { width: min(360px, calc(100vw - 16px)); }
  [data-tip]::after { display: none; }
  .toasts { top: calc(12px + var(--safe-top)); bottom: auto; left: 12px; right: 12px; width: auto; flex-direction: column-reverse; }
  .toast { padding: 12px 10px 12px 12px; animation-name: toast-in-top; }
  @keyframes toast-in-top { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }

  .overlay { padding: 0; }
  .modal, .modal.market { width: 100%; height: 100%; border-radius: 0; flex-direction: column; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
  .modal.small { width: calc(100% - 32px); height: auto; border-radius: 16px; padding: 0; }
  .modal.palette { width: 100%; height: 100%; max-height: none; margin: 0; }
  .palette-input input, .dialog-body .field, .field { font-size: 16px; }
  .palette-item { min-height: 48px; }
  .modal-close { top: calc(8px + var(--safe-top)); right: 8px; width: 44px; height: 44px; }
  .settings-nav { width: 100%; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-right: 0; border-bottom: 1px solid var(--divider); overflow-x: auto; overflow-y: hidden; flex: none; height: 56px; scrollbar-width: none; }
  .back-link { height: auto; margin: 0; padding: 0; flex: none; }
  .back-link button { height: 44px; min-width: 44px; justify-content: center; }
  .back-link button span { display: none; }
  .set-nav-item { width: auto; flex: none; height: 44px; margin: 0; padding: 0 12px; }
  .set-nav-label { display: none; }
  .settings-body, .custom-body { padding: 24px 16px 40px; }
  .market-body { padding: 20px 16px 40px; }
  .market h2 { font-size: 28px; line-height: 36px; }
  .market-chips { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  .market-chips button { height: 44px; }
  .featured { grid-template-columns: 1fr 1fr; gap: 12px; }
  .market-list, .plugin-grid { grid-template-columns: minmax(0, 1fr); }
  .market-item { padding: 0 4px; }
  .market-item .btn, .btn, .select-btn { min-height: 44px; border-radius: 22px; padding: 0 16px; }
  .select-btn { border-radius: 10px; }
  .tabs button { height: 44px; border-radius: 22px; padding: 0 14px; }
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .icon-btn { width: 44px; height: 44px; }
  /* The switch keeps its size to the eye; the element around it grows to a 44 px target. */
  .switch, .switch[aria-checked="true"], .switch[aria-checked="true"]:hover { width: 48px; height: 44px; background: none; box-shadow: none; }
  .switch::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 26px; border-radius: 13px; background: var(--fill); box-shadow: inset 0 0 0 1px var(--border-3); }
  .switch[aria-checked="true"]::before { background: var(--blue); box-shadow: none; }
  .switch-knob { top: 11px; width: 22px; height: 22px; }
  .switch[aria-checked="true"] .switch-knob { transform: translateX(22px); }
  .set-row { flex-wrap: wrap; row-gap: 8px; }
  .set-text { flex-basis: 60%; }
  .field, .dialog-body .field { height: 44px; }
  .table-wrap { overflow-x: auto; }

  .page-inner { width: calc(100% - 32px); padding: 16px 0 calc(32px + var(--safe-bottom)); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .tiles { grid-template-columns: 1fr 1fr; row-gap: 14px; }
  .tile:nth-child(odd) { padding-left: 0; border-left: 0; }
  .list-row { min-height: 64px; flex-wrap: wrap; row-gap: 4px; }
  .list-side { flex-basis: 100%; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Settings: accounts and limits --- */
.ok-dot.bad { color: var(--danger); }
.link-btn { font-size: 13px; text-align: right; text-decoration: underline; text-decoration-color: var(--border-1); text-underline-offset: 3px; }
.set-note.warn { color: var(--warn); }
.form-error { font-size: 13px; color: var(--danger); }
.acct-banner { display: flex; align-items: flex-start; gap: 10px; margin-top: 20px; padding: 10px 14px; border-radius: 12px; background: var(--fill); font-size: 12px; line-height: 18px; color: var(--text-2); }
.acct-banner .icon { flex: none; margin-top: 2px; }
.acct-banner[data-vault="none"] { background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); }
.route-order { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 12px 0 4px; list-style: none; }
.route-step { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.route-step[data-available="false"] { color: var(--text-3); }
.acct-rank { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--fill); font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.acct-provider .set-label p { margin-top: 2px; }
.acct-card { padding: 0 14px; }
.acct { padding: 14px 0; }
.acct + .acct { border-top: 1px solid var(--divider); }
.acct[data-status="disabled"] .usage-list, .acct[data-status="disabled"] .acct-title { opacity: .55; }
.acct-head { display: flex; align-items: center; gap: 10px; }
.acct-title { flex: 1 1 0; min-width: 0; }
.acct-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-tools { display: flex; align-items: center; gap: 2px; }
.acct-detail, .acct-unknown, .acct-check { margin: 8px 0 0 28px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.acct[data-status="limited"] .acct-detail, .acct[data-status="error"] .acct-detail { color: var(--danger); }
.acct[data-status="needs_credentials"] .acct-detail { color: var(--warn); }
/* A meter per limit window: the fill carries the state, the track is the same colour, lighter. */
.usage-list { display: grid; gap: 8px; margin: 12px 0 0 28px; }
.usage-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 300px; align-items: center; gap: 14px; font-size: 12px; line-height: 16px; }
.usage-bar { height: 6px; border-radius: 3px; color: var(--text-2); background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.usage-bar span { display: block; height: 100%; border-radius: 3px; background: currentColor; }
.usage-row[data-state="near"] .usage-bar { color: var(--warn); }
.usage-row[data-state="limited"] .usage-bar { color: var(--danger); }
.usage-figure { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-value { color: var(--text); }
.acct-served { padding: 4px 14px; }
.served-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; min-height: 44px; padding: 8px 0; font-size: 13px; text-align: left; }
.served-row + .served-row { border-top: 1px solid var(--divider); }
.served-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.served-by { display: flex; flex-direction: column; min-width: 0; }
.served-when { font-size: 12px; white-space: nowrap; }
.acct-source { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--text-2); }
.acct-fields { display: flex; flex-direction: column; gap: 12px; }
.acct-fields small { font-size: 12px; color: var(--text-3); }
.acct-hint { font-size: 12px; line-height: 18px; }
.acct-hint.warn { color: var(--warn); }
@media (max-width: 767px) {
  .acct-head { flex-wrap: wrap; }
  .acct-title { flex-basis: calc(100% - 28px); }
  .acct-status { flex: 1 1 0; min-width: 0; margin-left: 28px; white-space: normal; line-height: 18px; }
  .acct-status::before { flex: none; }
  .usage-list, .acct-detail, .acct-unknown, .acct-check { margin-left: 0; }
  .usage-row { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .served-row { grid-template-columns: minmax(0, 1fr) auto; }
  .served-by { grid-column: 1 / -1; grid-row: 2; }
  .acct-source .seg { max-width: 100%; overflow-x: auto; }
  .link-btn { display: inline-flex; align-items: center; justify-content: flex-end; min-height: 44px; min-width: 44px; }
}

/* --- 6c: automations, review, analytics, channels, policies --- */
select.field { appearance: none; padding-right: 28px; color: var(--text); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center; }
.dialog-body .field-row .field { flex: 1; min-width: 0; }
.field.mono { font-family: var(--mono); font-size: 12px; }
button.link { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-align: left; text-decoration: underline; text-decoration-color: var(--border-1); text-underline-offset: 2px; }
.table .clip.wide { max-width: 320px; }

.auto-item + .auto-item, .review-item + .review-item { border-top: 1px solid var(--divider); }
.list-row.automation[data-enabled="false"] .list-title { color: var(--text-2); }
.auto-next { color: var(--text-3); }
.last-run { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.last-run:not(:disabled):hover span:last-child { text-decoration: underline; }
.auto-history { margin: 0 0 12px; padding: 4px 12px 2px; border: 1px solid var(--border-3); border-radius: 10px; background: var(--sunken); }
.auto-history .caption { padding-top: 8px; }
.run-detail { margin-top: 2px; font-size: 12px; white-space: normal; }

.review-item .list-sub { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.review-item .list-sub span:first-child { overflow: hidden; text-overflow: ellipsis; }
.review-item .btn svg { flex: none; }
.review-state { font-size: 13px; color: var(--text-2); }
.review-state[data-status="approved"] { color: var(--success); }
.review-state[data-status="changes_requested"] { color: var(--warn); }
.review-note { padding: 0 0 10px; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.review-diff { margin: 0 0 10px; border: 1px solid var(--border-3); border-radius: 10px; overflow: hidden; }
.review-diff .diff-files { border-top: 0; }
.review-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 0 12px; font-size: 13px; }

/* Charts: two series, the validated pair for each surface (blue, orange). */
html[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; }
html[data-theme="light"] { --series-1: #2a78d6; --series-2: #eb6834; }
.chart .bar.ok { fill: var(--series-1); }
.chart .bar.bad { fill: var(--series-2); }
.chart .bar-group:hover .bar, .chart .bar-group:focus .bar { filter: brightness(1.15); }
.chart .bar-group:focus { outline: none; }
.chart .bar-group:focus-visible rect { stroke: var(--focus); stroke-width: 1.5; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.ok { background: var(--series-1); }
.swatch.bad { background: var(--series-2); }
#usage-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.page-card p.caption { padding: 2px 0 10px; }
.use-account { padding: 10px 0; border-top: 1px solid var(--divider); }
.use-name { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.use-none { padding-top: 4px; font-size: 12px; }
.use-row { display: grid; grid-template-columns: minmax(90px, 200px) minmax(60px, 1fr) minmax(90px, auto); align-items: center; gap: 12px; padding-top: 6px; font-size: 12px; color: var(--text-2); }
.use-amount { text-align: right; font-variant-numeric: tabular-nums; }
.progress.wide { width: 100%; height: 4px; }
.progress.wide span { background: var(--series-1); }
.progress[data-level="near"] span { background: var(--warn); }
.progress[data-level="full"] span { background: var(--danger); }
.set-row.channel .set-control { gap: 10px; }

@media (max-width: 767px) {
  #usage-tiles { grid-template-columns: 1fr 1fr; }
  #usage-tiles .tile:last-child { grid-column: 1 / -1; padding-left: 0; border-left: 0; }
  .review-item .list-sub { flex-wrap: wrap; white-space: normal; }
  .review-bar .btn.sm, .review-item .list-side .btn.sm, .auto-history .btn.sm { height: 44px; padding: 0 14px; font-size: 14px; }
  .last-run { min-height: 44px; }
  .list-side { flex-wrap: wrap; row-gap: 6px; }
  .list-side .run-now, .use-template { height: 44px; }
  /* An automation on a phone: when it runs next and how the last run went, then its controls on their own line. */
  .automation .auto-next + * { flex: 1 0 55%; }
  .automation .list-side .switch { margin-left: auto; }
  .use-row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .use-row .progress { grid-column: 1 / -1; grid-row: 2; }
  .chart-legend { flex-basis: 100%; }
  .table .clip.wide { max-width: 160px; }
  button.link { min-height: 44px; }
  select.field { height: 44px; }
  #range-tabs button { min-width: 44px; }
  /* The wide tables keep their main columns on a phone; the rest are on a wider screen. */
  .page-card .table th { white-space: normal; vertical-align: bottom; }
  #harness-table :is(th, td):nth-child(n+5):nth-child(-n+7), #account-table :is(th, td):is(:nth-child(2), :nth-child(6), :nth-child(7)), #day-table :is(th, td):nth-child(5) { display: none; }
  .page-card summary.caption { display: flex; align-items: center; min-height: 44px; }
}

/* What a composer's next prompt takes with it: files, a page, a repository, secrets, skills. */
#new-chips { padding: 0 14px 6px; }
#thread-chips { padding: 0 10px 8px; }
.attached .chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; cursor: default; }
.attached .chip .icon { flex: none; color: var(--text-2); }
.attached .chip-label { overflow: hidden; text-overflow: ellipsis; }
.chip-x { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 11px; color: var(--text-3); }
.chip-x:hover { background: var(--fill-hover); color: var(--text); }
@media (max-width: 767px) {
  .attached .chip { height: 44px; padding: 0 0 0 14px; border-radius: 22px; }
  .chip-x { width: 44px; height: 44px; border-radius: 22px; }
}

/* The harnesses' own marks. */
svg.logo { flex: none; display: block; }
.chip-pick .glyph { display: inline-grid; place-items: center; }
.login-code { font: 600 24px/32px var(--mono, ui-monospace, monospace); letter-spacing: 2px; text-align: center; padding: 10px; border-radius: 10px; background: var(--fill); }
#login-dialog #login-link { align-self: flex-start; }
#login-status[data-state="failed"] { color: var(--danger, #e5484d); }
.acct-login { margin-left: auto; }
.acct-provider h3 { display: flex; align-items: center; gap: 8px; }

/* AI models: each harness with its models and their thinking levels. */
.provider-card + .provider-card { margin-top: 12px; }
.provider-row .glyph svg.logo { display: block; }
.model-rows { display: flex; flex-direction: column; border-top: 1px solid var(--divider); padding: 6px 0; }
.model-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 4px; border-radius: 8px; text-align: left; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
.model-row:hover, .model-row:focus-visible { background: var(--fill); }
.model-row .model-name { font-size: 13px; }
/* A token shown once; an MCP snippet to copy. */
.token-once { padding: 12px; border-radius: 10px; background: var(--fill); word-break: break-all; user-select: all; font-size: 12px; }
.mcp-snippet { margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; line-height: 18px; max-width: 100%; }
.table td.row-actions { text-align: right; white-space: nowrap; }
.table td.row-actions .btn + .btn { margin-left: 6px; }

/* The project dialog (project-dialog.js): repositories and environments of a project. */
.project-dialog .pd-block { display: flex; flex-direction: column; gap: 8px; }
.project-dialog .pd-label { font-size: 13px; color: var(--text-2); }
.project-dialog .pd-list { display: flex; flex-direction: column; gap: 6px; }
.project-dialog .pd-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--fill); color: var(--text); }
.project-dialog .pd-row > svg { flex: none; color: var(--text-3); }
.project-dialog .pd-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; line-height: 18px; color: var(--text); overflow-wrap: anywhere; }
.project-dialog .pd-folder { font-size: 12px; color: var(--text-3); }
.project-dialog .pd-row .pd-ref { flex: 0 1 132px; min-width: 0; height: 30px; font-size: 13px; }
.project-dialog .pd-add { display: flex; gap: 8px; }
.project-dialog .pd-add .field { flex: 1; min-width: 0; }
.project-dialog .pd-hint { font-size: 12px; line-height: 17px; color: var(--text-3); }
.project-dialog .pd-check { flex-direction: row; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.project-dialog .pd-check:hover { background: var(--fill); }
.project-dialog .pd-check input { flex: none; width: 16px; height: 16px; }
.dialog-error { font-size: 13px; color: var(--danger); }
.chip.fixed { color: var(--text-2); background: none; box-shadow: inset 0 0 0 1px var(--border-3); }
.review-applied-repo, .review-applied-error { display: block; }
.review-applied-error { color: var(--danger); }
@media (max-width: 767px) {
  .project-dialog .pd-row { flex-wrap: wrap; }
  .project-dialog .pd-row .pd-ref { flex: 1 1 100%; height: 44px; font-size: 16px; }
  .project-dialog .pd-check { min-height: 44px; }
}

/* The phone's one-line harness and level is a button: it opens the pickers the chips hold on a desktop. */
.thread-brief { background: none; border: 0; text-align: left; width: 100%; cursor: pointer; }
@media (max-width: 767px) { .thread-brief { min-height: 32px; } }
.share-note { font-size: 13px; line-height: 18px; color: var(--text-2); padding: 0 2px 8px; }

/* The automation dialog's pick lists (automations.js): environments, secrets and skills for its runs. */
.auto-form .auto-uses { display: flex; flex-direction: column; gap: 6px; }
.auto-form .auto-uses-label { font-size: 13px; color: var(--text-2); }
.auto-form .auto-uses-list { display: flex; flex-direction: column; gap: 2px; max-height: 152px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.auto-form .auto-uses-hint { font-size: 12px; line-height: 17px; color: var(--text-3); }
.auto-form .auto-check { flex-direction: row; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.auto-form .auto-check:hover { background: var(--fill); }
.auto-form .auto-check input { flex: none; width: 16px; height: 16px; }
.auto-form .auto-check-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; line-height: 18px; color: var(--text); overflow-wrap: anywhere; }
.auto-form .auto-check-note { font-size: 12px; color: var(--text-3); }
/* The marketplace's "Your agents" rows (customize.js): edit and remove sit before Open. */
.market-item.own .icon-btn { flex: none; }
@media (max-width: 767px) {
  .auto-form .auto-check { min-height: 44px; }
  .market-item.own { gap: 8px; }
  .market-item.own .icon-btn { width: 44px; height: 44px; }
}

/* Home: the composer in the middle, what is still to set up under it at the same width. */
.home { flex-direction: column; gap: 16px; }
.home > .starter { flex: none; }
.setup-slot { width: min(668px, 100%); flex: none; }
.setup-slot .setup-steps { margin: 0; }
@media (max-width: 767px) {
  .home { align-items: stretch; justify-content: flex-end; }
  .setup-slot { order: -1; width: 100%; }
}

/* The Tunnels button: beside the project pick on the home composer, at the right of a conversation's header. */
.tunnel-slot { display: inline-flex; align-items: center; }
.starter-head .spacer { flex: 1; }
.thread-head .tunnel-slot { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
@media (max-width: 767px) {
  .thread-head .tunnel-slot { right: 8px; top: calc(50% + var(--safe-top) / 2); }
}

/* ---- The new-session composer: a wide card, the project and where it runs above it, the tools
   in one row along its bottom (add, options, model, level; the microphone or Send at the right). */
:root { --accent-warm: #d97757; --accent-warm-hover: #e08565; }
.home { position: relative; }
/* A quiet field of dots behind the top of the page, fading out towards the composer. */
.home::before { content: ''; position: absolute; inset: 0 0 45% 0; pointer-events: none; opacity: .55;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1.4px); background-size: 9px 9px;
  -webkit-mask-image: radial-gradient(120% 90% at 85% 0%, #000 0%, transparent 62%); mask-image: radial-gradient(120% 90% at 85% 0%, #000 0%, transparent 62%); }
.home > * { position: relative; }
.starter { width: min(760px, 100%); }
.starter-head { gap: 6px; height: 34px; margin-bottom: 10px; padding: 0 6px; }
.starter-head .quiet-pick { height: 32px; padding: 0 10px; margin-left: 0; border-radius: 9px; font-size: 15px; font-weight: 500; color: var(--text-2); gap: 7px; }
.starter-head .quiet-pick:first-child { margin-left: -4px; }
.starter-head .quiet-pick > svg:last-child { color: var(--text-4); margin-left: 1px; }
.starter-card { min-height: 132px; border-radius: 14px; border: 1px solid var(--border-3); box-shadow: none; }
html[data-theme="dark"] .starter-card { background: #2a2a29; }
.starter-card textarea { min-height: 64px; padding: 18px 20px 4px; font-size: 16px; line-height: 24px; }
.starter-card textarea::placeholder { color: var(--text-4); }
.starter-tools { gap: 6px; padding: 6px 12px 12px 12px; }
.starter-tools .icon-btn { width: 34px; height: 34px; border-radius: 9px; color: var(--text-2); }
.starter-tools .icon-btn:hover, .starter-tools .icon-btn[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.starter-tools .chip-pick { height: 34px; padding: 0 10px; border-radius: 9px; font-size: 15px; gap: 7px; }
.starter-tools .chip-pick.model { color: var(--text); font-weight: 500; }
.starter-tools .chip-pick.model .glyph { display: grid; place-items: center; width: 18px; height: 18px; }
.starter-tools .chip-pick.muted { padding-left: 10px; margin-left: 0; }
.starter-tools .chip-pick.muted:hover, .starter-tools .chip-pick.muted[aria-expanded="true"] { padding-left: 10px; margin-left: 0; }
.starter-tools .chip-pick > svg:last-child { color: var(--text-4); }
.starter-tools .send { width: 38px; height: 38px; margin-left: 6px; border-radius: 10px; background: var(--accent-warm); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 1px 2px rgba(0, 0, 0, .25); }
.starter-tools .send:hover:not(:disabled) { background: var(--accent-warm-hover); }
.starter-tools .send[data-empty="true"], .starter-tools .send:disabled { background: var(--accent-warm); opacity: .6; color: #fff; }
html[data-theme="dark"] .starter-tools .send[data-empty="true"], html[data-theme="dark"] .starter-tools .send:disabled { color: #fff; }
.starter-tools .send.mic[aria-pressed="true"] { background: var(--danger); }
.starter-tools .send[hidden] { display: none; }
@media (max-width: 767px) {
  .starter-head .quiet-pick { height: 44px; font-size: 15px; }
  .starter-card { min-height: 120px; }
  .starter-tools { gap: 2px; padding: 2px 8px 8px; }
  .starter-tools .icon-btn, .starter-tools .send { width: 44px; height: 44px; }
  .starter-tools .chip-pick { height: 44px; padding: 0 8px; }
  .starter-tools .chip-pick .chip-text { max-width: 104px; }
}
/* The composer sits in the upper part of the page, so its menus and the model picker open below it. */
@media (min-width: 768px) {
  .home { justify-content: flex-start; padding-top: clamp(96px, 33vh, 330px); }
}

/* In a conversation's header the Tunnels button is its icon and dot alone, and the title makes room for it. */
.thread-head .tn-btn-word { display: none; }
.thread-head .pill-btn { max-width: 100%; min-width: 0; }
.thread-head { padding-right: 72px; }
