/* AI tab styles. Loaded after style.css; everything here is scoped to the AI tab (body[data-view=claude]) or its own class names. */

.usage-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text); }
.usage-row { display: grid; gap: 6px; }
.usage-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.usage-line strong { font-weight: 600; color: var(--text); }
.usage-bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.usage-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.3s ease; }
.usage-bar.warning span { background: var(--warning); }
.usage-bar.danger span { background: var(--danger); }
.usage-reset { font-size: 11.5px; color: var(--muted); }
.usage-empty { margin: 0; }
.usage-spend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.usage-spend div { display: grid; gap: 1px; }
.usage-spend strong { font-size: 16px; font-weight: 650; }
.usage-spend span { font-size: 11.5px; color: var(--muted); }

.claude-auth { display: grid; gap: 12px; width: 100%; text-align: left; justify-items: stretch; }
.claude-auth .segmented { justify-self: center; }
.claude-auth-help { display: grid; gap: 8px; }
.claude-auth-help p { margin: 0; }
.claude-auth-help a { color: var(--accent); }
.claude-command { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.claude-command code { font-family: var(--mono); font-size: 13px; }

/* attachments */
.claude-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.claude-attachments.hidden { display: none; }
.claude-attachment {
  position: relative; display: flex; align-items: center; gap: 6px; max-width: 220px; height: 44px; padding: 0 10px 0 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2);
}
.claude-attachment.picture { width: 56px; padding: 0; overflow: hidden; }
.claude-attachment img { width: 100%; height: 100%; object-fit: cover; }
.claude-attachment-icon { display: flex; color: var(--muted); }
.claude-attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claude-attachment-remove {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.msg-user { flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 85%; }
.msg-attachments .claude-attachment.picture { width: 88px; height: 88px; }

/* "/" and "@" suggestions */
.claude-popup {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px;
  scrollbar-width: none;
}
.claude-popup::-webkit-scrollbar { display: none; }
.claude-popup-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; min-width: 0; }
.claude-popup-item .icon { color: var(--muted); flex: none; }
.claude-popup-item.active { background: var(--surface-3); }
.claude-popup-label { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.claude-popup-hint { color: var(--muted); }
.claude-popup-note { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claude-popup-empty { padding: 8px 10px; font-size: 13px; color: var(--muted); }

.question { display: grid; gap: 8px; justify-items: start; }
.question > strong { font-size: 14.5px; }
.question .input { width: 100%; }
.question-options { display: grid; gap: 6px; width: 100%; }

.md.msg-info { color: var(--text-2); font-size: 13.5px; }

.claude-setup { max-width: 520px; margin: 0 auto; align-self: center; display: grid; justify-items: center; text-align: center; gap: 14px; padding: 32px 20px; }
.claude-setup h2 { font-size: 20px; }
.claude-setup p { margin: 0; }
.claude-setup a { color: var(--accent); }
.claude-key-row { display: flex; gap: 8px; width: 100%; }
.claude-key-row .input { flex: 1; }

.claude-side { display: none; flex-direction: column; min-height: 0; min-width: 0; border-left: 1px solid var(--border); background: var(--surface); }
.claude-shell.side-open .claude-side { display: flex; }
.claude-side-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 10px 10px 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.claude-side-head strong { font-size: 14px; }
.claude-side-head .spacer { flex: 1; }
.claude-side-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: none; }
.claude-side-body::-webkit-scrollbar { display: none; }
.claude-panel-buttons { display: flex; align-items: center; gap: 2px; }
.claude-panel-btn { position: relative; color: var(--muted); }
.claude-panel-btn.on { color: var(--accent); background: var(--accent-soft); }
.claude-panel-count {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 650; display: grid; place-items: center;
}
.side-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 30px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
.side-empty .tool-pre { text-align: left; max-width: 100%; }


.rail-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.rail-card-head { display: flex; align-items: center; gap: 5px; min-height: 38px; padding: 0 8px 0 12px; border-radius: 12px; user-select: none; min-width: 0; }
.rail-card:not(.fixed) > .rail-card-head { cursor: pointer; }
.rail-card:not(.fixed) > .rail-card-head:hover { background: var(--surface-2); }
.rail-card-head:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.rail-card-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.rail-card-summary { margin-left: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.rail-card-summary.running:not(:empty) { color: var(--accent); }
.rail-card-head .spacer { flex: 1; }
.rail-card-extra { display: flex; align-items: center; }
.rail-card-head > .icon { color: var(--muted); flex: none; width: 12px; height: 12px; transition: transform 0.15s; }
.rail-card.collapsed > .rail-card-head > .icon { transform: rotate(-90deg); }
.rail-card-peek { padding: 0 12px 10px; display: grid; gap: 8px; min-width: 0; }
.rail-card-peek:empty { display: none; }
.rail-card-body { padding: 0 12px 10px; display: grid; gap: 0; min-width: 0; }
.rail-card.collapsed > .rail-card-body { display: none; }
.rail-note { font-size: 12px; color: var(--muted); margin: 0; }
.rail-card-body > .btn { justify-self: start; margin-top: 6px; }
.rail-card .md-copy { width: 24px; height: 24px; }

/* rows: one size everywhere */
.env-row, .tree-root { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; font-size: 13px; color: var(--text); }
.env-row > .icon, .tree-root > .icon { color: var(--muted); flex: none; width: 15px; height: 15px; }
.env-name { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.env-name + .env-path::before { content: "· "; }
.env-path.ok { color: var(--success); }
.env-path.bad { color: var(--danger); }
.tree-root { cursor: pointer; border-radius: 6px; }
.tree-root:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.tree-caret { display: flex; color: var(--muted); flex: none; transition: transform 0.15s; }
.tree-caret .icon { width: 12px; height: 12px; }
.tree-block.collapsed .tree-caret { transform: rotate(-90deg); }
.tree-block { display: grid; gap: 0; min-width: 0; }
.tree-block.collapsed > ul.tree { display: none; }

/* context */
.context-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.context-head strong { font-size: 13px; font-weight: 600; }
.context-head span { font-size: 12px; color: var(--muted); }
.context-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.context-bar span { height: 100%; }
.context-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.context-legend.deferred { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.context-legend.tools { margin-top: 2px; }
.context-legend li { display: flex; align-items: center; gap: 8px; min-height: 26px; font-size: 12.5px; color: var(--muted); }
.context-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.context-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-name.hint { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.context-tokens { flex: none; text-align: right; }
.context-pct { flex: none; width: 42px; text-align: right; color: var(--text); }
.context-legend.deferred .context-pct, .context-legend.tools .context-tokens { color: var(--muted); }
.context-more { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 26px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; }
.context-more > span:first-of-type { flex: 1; }
.context-more .icon { transform: rotate(-90deg); transition: transform 0.15s; flex: none; width: 12px; height: 12px; }
.context-more.open .icon { transform: none; }
.context-more .context-pct { color: var(--muted); }

/* usage: the popover from the account row */
.usage-tools { display: inline-flex; align-items: center; gap: 2px; }
.usage-pop { width: 270px; padding: 12px; display: grid; gap: 12px; }
.usage-pop .usage-empty { max-width: 100%; }

/* settings page */
.prefs { display: grid; gap: 4px; text-align: left; min-width: min(420px, 78vw); }
.prefs-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; font-size: 14.5px; cursor: pointer; }
.prefs-row.static { cursor: default; }
.prefs-sub { display: grid; gap: 2px; margin: 0 0 6px 14px; padding-left: 14px; border-left: 2px solid var(--border); }
.prefs-sub .prefs-row { font-size: 13.5px; color: var(--text-2); min-height: 38px; }
.prefs .segmented button { padding: 0 9px; font-size: 12.5px; }
ul.tree { display: none; }
ul.tree { list-style: none; margin: 0; padding: 0 0 0 10px; display: grid; }
.tree-block > ul.tree { padding-left: 2px; margin-top: 4px; }
.tree-item {
  display: flex; align-items: center; gap: 5px; width: 100%; padding: 3px 6px; border: 0; border-radius: 6px; background: none;
  color: var(--text-2); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; min-width: 0;
}
.tree-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item:hover { background: var(--surface-3); color: var(--text); }
.tree-item .icon { flex: none; color: var(--muted); }
.tree-item > .icon:first-child { transform: rotate(-90deg); transition: transform 0.12s; }
li.open > .tree-item > .icon:first-child { transform: none; }
.tree-spacer { width: 13px; flex: none; }

/* sub agents */
.agent-list { display: grid; gap: 6px; min-width: 0; }
.agent-list:empty { display: none; }
.agent-row { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-width: 0; overflow: hidden; }
.agent-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; min-width: 0;
}
.agent-head:hover { background: var(--surface-3); }
.agent-head > .icon { flex: none; color: var(--muted); transition: transform 0.15s; }
.agent-row.open > .agent-head > .icon { transform: rotate(180deg); }
.agent-mark { display: flex; flex: none; color: var(--success); }
.agent-row.error .agent-mark { color: var(--danger); }
.agent-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.agent-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; min-width: 0; }
.agent-kind { flex: none; font-size: 10.5px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.agent-doing { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-body { padding: 2px 10px 10px; display: grid; gap: 8px; border-top: 1px solid var(--border); }
.agent-prompt { margin: 8px 0 0; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bg-main { display: flex; align-items: center; gap: 8px; padding: 7px 9px; min-width: 0; }
.bg-main > .spinner { flex: none; }
.agent-steps { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--border); display: grid; gap: 5px; }
.agent-step { position: relative; display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--text-2); min-width: 0; }
.agent-step::before { content: ""; position: absolute; left: -16px; top: 0.55em; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.agent-step.error::before { background: var(--danger); }
.agent-step-verb { flex: none; font-weight: 600; color: var(--text); }
.agent-step-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.agent-step-note { color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.agent-summary { margin: 0; font-size: 12px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* folder picker */
.picker { display: grid; gap: 10px; text-align: left; min-width: 0; }
.picker-quick { display: flex; align-items: center; gap: 6px; }
.picker-quick .input { flex: 1; min-width: 0; height: 32px; font-size: 12.5px; }
.picker-scroll { height: min(340px, 46vh); overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 4px; scrollbar-width: thin; }
ul.picker-tree { list-style: none; margin: 0; padding: 0; }
ul.picker-tree ul.picker-tree { display: none; }
li.open > ul.picker-tree { display: block; }
.picker-row { display: flex; align-items: center; gap: 6px; height: 28px; padding-right: 8px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.picker-row:hover { background: var(--surface-3); }
.picker-row.selected { background: var(--accent); color: var(--on-accent); }
.picker-row > .icon { flex: none; color: var(--muted); }
.picker-row.selected > .icon { color: var(--on-accent); }
.picker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-chev { width: 18px; height: 18px; flex: none; display: grid; place-items: center; border: 0; background: none; color: inherit; padding: 0; cursor: pointer; border-radius: 4px; }
.picker-chev .icon { transform: rotate(-90deg); transition: transform 0.12s; color: var(--muted); }
li.open > .picker-row .picker-chev .icon { transform: none; }
li.leaf > .picker-row .picker-chev { visibility: hidden; }
.picker-row.selected .picker-chev .icon { color: var(--on-accent); }

/* terminals */
.term-tabs { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.term-tabs::-webkit-scrollbar { display: none; }
.term-tab {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--text-2); white-space: nowrap; flex: none;
}
.term-tab .icon:first-child { color: var(--muted); }
.term-tab:hover { background: var(--surface-3); }
.term-tab.active { background: var(--accent-soft); color: var(--text); }
.term-tab.active .icon:first-child { color: var(--accent); }
.term-tab.dead span { text-decoration: line-through; color: var(--muted); }
.term-tab-close { width: 20px; height: 20px; border: 0; border-radius: 5px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.term-tab-close:hover { background: var(--surface-3); color: var(--text); }
.term-new { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.term-new:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.term-new:disabled { opacity: 0.4; cursor: default; }
.term-holder { flex: 1; min-height: 0; padding: 6px 4px 4px 8px; background: var(--term-bg, #0e1013); display: flex; }
.term-view { flex: 1; min-width: 0; min-height: 0; }
.term-view .xterm { height: 100%; }

/* the browser */

/* the suggestion before sending */
.claude-advice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: 740px; width: 100%; margin: 0 auto 8px; padding: 8px 8px 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
  font-size: 13px; animation: pop-in 0.15s ease;
}
.claude-advice > .icon { color: var(--accent); flex: none; }
.advice-text { flex: 1; min-width: 160px; }
.claude-box.checking .claude-send { animation: claude-pulse 0.9s ease-in-out infinite alternate; }
@keyframes claude-pulse { from { opacity: 0.35; } to { opacity: 0.9; } }

/* screenshots in the chat */

/* base rules the redesign below builds on */
.todo-list { list-style: none; margin: 0; padding: 2px 14px 10px 36px; display: grid; gap: 5px; font-size: 13.5px; color: var(--text-2); }
.todo-list li { display: flex; align-items: center; gap: 8px; }
.todo-list li.completed { color: var(--muted); text-decoration: line-through; }
.todo-list li.completed .icon { color: var(--success); }
.todo-list li.in_progress { color: var(--text); font-weight: 550; }
.todo-list li.in_progress .icon { color: var(--accent); }
.todo-box { width: 12px; height: 12px; border: 1.6px solid var(--border-strong); border-radius: 4px; flex: none; margin: 0 1px; }

.claude-input {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 15px; line-height: 1.45; padding: 4px 0; max-height: 220px; scrollbar-width: none;
}
.claude-input::-webkit-scrollbar { display: none; }
.claude-bar { display: flex; align-items: center; gap: 6px; margin-left: -6px; min-width: 0; }
.claude-bar .spacer { flex: 1; }
.claude-bar-group { display: flex; align-items: center; gap: 4px; min-width: 0; }
.claude-bar-btn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.claude-bar-btn:hover { background: var(--surface-3); color: var(--text); }
.claude-send { width: 34px; height: 34px; padding: 0; border-radius: 10px; flex: none; }
.claude-send.stop { background: var(--text); color: var(--surface); }
.claude-send:disabled { opacity: 0.35; }

.chip-select {
  display: inline-flex; align-items: center; gap: 3px; height: 30px; padding: 0 6px 0 9px; border-radius: 9px; min-width: 0;
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.chip-select > span { overflow: hidden; text-overflow: ellipsis; }
.chip-select .icon { color: var(--muted); transition: transform 0.15s; flex: none; }
.chip-select:hover, .chip-select.open { background: var(--surface-3); color: var(--text); }
.chip-select:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.chip-select.mode-plan { color: var(--accent); }
.chip-select.mode-all { color: var(--danger); }
.chip-select.open .icon { transform: rotate(180deg); }
.pick-menu { min-width: 230px; max-width: calc(100vw - 16px); }
.pick-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--text); }
.pick-item:hover { background: var(--surface-3); }
.pick-item.selected .icon { color: var(--accent); }
.pick-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pick-label { font-size: 13.5px; font-weight: 500; }
.pick-note { font-size: 12px; color: var(--muted); }

.question-option {
  display: grid; gap: 2px; text-align: left; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.question-option:hover { border-color: var(--border-strong); }
.question-option.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.question-option-label { font-weight: 550; font-size: 14px; }
.question-option-note { font-size: 12.5px; color: var(--muted); }

/* end of a turn */
.msg-result { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
.msg-result:empty { display: none; }
.msg-result-row { display: flex; align-items: center; gap: 8px; margin-left: -4px; }
.msg-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.msg-divider::before, .msg-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.md.msg-info { color: var(--text-2); font-size: 13.5px; }
.changes-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.changes-head, .changes-file-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 11px; border: 0; background: transparent;
  color: var(--text-2); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.changes-head:hover, .changes-file-head:hover { background: var(--surface-2); }
.changes-head > .icon:first-child, .changes-file-head > .icon { color: var(--muted); flex: none; }
.changes-head > .icon:last-child { color: var(--muted); transition: transform 0.15s; }
.changes-card.open .changes-head > .icon:last-child { transform: rotate(180deg); }
.changes-title { flex: 1; font-weight: 550; color: var(--text); }
.changes-path { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.changes-add { color: var(--success); font-family: var(--mono); font-size: 12px; }
.changes-del { color: var(--danger); font-family: var(--mono); font-size: 12px; }
.changes-list { border-top: 1px solid var(--border); }
.changes-diff { padding: 0 8px 8px; display: grid; gap: 8px; }

/* ======================================================================
   The AI tab. Warm paper, a serif voice for Claude's replies, quiet chrome.
   Tokens live on body[data-view="claude"], so the shared buttons, inputs and
   dialogs pick the palette up too. light-dark() follows the theme switch.
   ====================================================================== */

#ai-button .icon { color: #c6613f; }

body[data-view="claude"] {
  color-scheme: light dark;
  --bg: light-dark(#faf9f5, #262624);
  --surface: light-dark(#ffffff, #30302e);
  --surface-2: light-dark(#f5f3ec, #2b2b29);
  --surface-3: light-dark(#ece9df, #3a3a37);
  --border: light-dark(#e8e5da, #3d3c38);
  --border-strong: light-dark(#d8d4c5, #55534c);
  --text: light-dark(#1f1e1d, #ece9df);
  --text-2: light-dark(#3d3b37, #cfccc0);
  --muted: light-dark(#76736a, #98958b);
  --accent: light-dark(#c6613f, #e08a68);
  --accent-hover: light-dark(#b0532f, #eb9d7e);
  --accent-soft: light-dark(rgba(198, 97, 63, 0.11), rgba(224, 138, 104, 0.16));
  --on-accent: light-dark(#ffffff, #1a0f0a);
  --side: light-dark(#f0eee6, #1f1e1d);
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --code-key: light-dark(#a8481f, #f0a37f);
  --code-str: light-dark(#4a7a3c, #a5cf8f);
  --code-num: light-dark(#9a6a00, #e5c07b);
  --code-com: light-dark(#8d8a80, #7c7a72);
  --code-fn: light-dark(#34609b, #8cb4ee);
  background: var(--bg);
}
:root[data-theme="light"] body[data-view="claude"] { color-scheme: light; }
:root[data-theme="dark"] body[data-view="claude"] { color-scheme: dark; }

/* ---------- frame: the tab owns the whole window ---------- */
body[data-view="claude"] .shell { grid-template-columns: 1fr; }
body[data-view="claude"] .sidebar, body[data-view="claude"] .topbar { display: none; }
body[data-view="claude"] .main { height: 100vh; height: 100dvh; }
body[data-app="ai"] .tabbar { display: none !important; }
body[data-view="claude"] .content { flex: 1; min-height: 0; padding: 0; max-width: none; display: flex; }
#view-claude { flex: 1; min-width: 0; min-height: 0; display: flex; }
.claude-shell {
  flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr);
  padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent;
}
.claude-shell.side-open { grid-template-columns: 272px minmax(0, 1fr) min(560px, 44vw); }

.claude-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--accent); color: var(--on-accent); }
.claude-logo { width: 44px; height: 44px; }

/* ---------- sidebar ---------- */
.claude-aside { display: flex; flex-direction: column; min-height: 0; background: var(--side); border-right: 1px solid var(--border); }
.aside-top { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px; padding-top: max(14px, env(safe-area-inset-top)); }
.aside-brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.aside-brand img { width: 24px; height: 24px; }
.aside-nav { display: grid; gap: 1px; padding: 6px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.nav-item .icon { flex: none; color: var(--muted); }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 550; }
.nav-item.primary { color: var(--accent); font-weight: 550; }
.nav-item.primary .icon { color: var(--accent); }
.nav-item .nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; display: grid; place-items: center; }

.chat-list {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 4px 8px 8px; display: grid; grid-template-columns: minmax(0, 1fr);
  align-content: start; gap: 1px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.chat-group { padding: 14px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 550; }
.chat-list-empty { padding: 10px; margin: 0; }
.chat-item {
  display: flex; flex: 1; min-width: 0; box-sizing: border-box; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}

.chat-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .pill { font-size: 12px; }
.chat-item-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.aside-foot { display: flex; align-items: center; gap: 8px; padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.aside-account {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.aside-account:hover { background: var(--surface-3); }
.aside-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 650; flex: none; }
.aside-who { flex: 1; min-width: 0; display: grid; gap: 1px; }
.aside-who strong { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aside-who span { font-size: 12px; color: var(--muted); }
.aside-meter { height: 3px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 3px; }
.aside-meter span { display: block; height: 100%; background: var(--accent); }

/* ---------- main column ---------- */
.claude-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.claude-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); min-height: 56px; }
.claude-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.claude-title strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claude-title > span { flex: none; max-width: 40%; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claude-back { display: none; }
.claude-panel-btn.on { color: var(--accent); background: var(--accent-soft); }

.claude-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: row; }
.claude-messages { flex: 1; min-width: 0; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.claude-thread { max-width: 740px; margin: 0 auto; padding: 18px 24px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.claude-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.claude-items:empty, .claude-live:empty, .claude-pending:empty { display: none; }
.claude-working { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; }

/* the details panel docks to the right of the chat (replaces the old floating rail) */
.claude-rail {
  position: static; width: 320px; flex: none; display: none; flex-direction: column; gap: 10px; padding: 12px;
  overflow-y: auto; scrollbar-width: thin; pointer-events: auto; font-size: 13px; line-height: 1.4;
  border-left: 1px solid var(--border); background: var(--bg);
}
.claude-rail.open { display: flex; }
.rail-card { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
@media (min-width: 861px) {
  .claude-shell.rail-open .claude-messages { padding-right: 0; }
  .claude-shell.rail-open .claude-composer { padding-right: 24px; }
}

/* ---------- empty state ---------- */
.claude-empty { display: grid; justify-items: center; text-align: center; gap: 14px; padding: 12vh 8px 12px; }
.claude-empty h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; }
.claude-empty p { max-width: 440px; margin: 0; color: var(--muted); }
.claude-folder { display: flex; align-items: center; gap: 8px; }
.claude-folder .btn { max-width: 70vw; }
.claude-folder .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ---------- messages ---------- */
.msg-user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-user .bubble {
  max-width: 85%; padding: 10px 16px; border-radius: 20px; background: var(--surface-3); color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5;
}
.msg-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 85%; }
.msg-attachments .claude-attachment.picture { width: 88px; height: 88px; }

/* Claude's replies: serif, unboxed, comfortable line length */
.md { font-family: var(--serif); font-size: 16.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; display: grid; gap: 14px; }
.md > * { min-width: 0; }
.md p, .md ul, .md ol, .md blockquote { margin: 0; }
.md h3, .md h4, .md h5, .md h6 { font-weight: 600; line-height: 1.3; margin: 10px 0 -4px; letter-spacing: -0.005em; }
.md h3 { font-size: 21px; }
.md h4 { font-size: 18px; }
.md h5, .md h6 { font-size: 16.5px; }
.md ul, .md ol { padding-left: 24px; display: grid; gap: 6px; }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin-top: 6px; }
.md li { padding-left: 2px; }
.md li::marker { color: var(--muted); }
.md ul.loose, .md ol.loose { gap: 12px; }
.md strong { font-weight: 650; }
.md a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--accent); }
.md del { color: var(--muted); }
.md code { font-family: var(--mono); font-size: 0.84em; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); }
.md blockquote { border-left: 3px solid var(--border-strong); padding: 0 0 0 16px; color: var(--text-2); display: grid; gap: 8px; }
.md blockquote blockquote { margin-top: 4px; }
.md hr { border: 0; border-top: 1px solid var(--border); width: 100%; margin: 6px 0; }
.md-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.md table { border-collapse: collapse; font-family: var(--font); font-size: 14px; min-width: 100%; }
.md th, .md td { padding: 8px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md-code { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); font-family: var(--font); }
.md-code-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 6px 0 14px; font-size: 12px; color: var(--muted); }
.md-copy { border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.md-copy:hover { background: var(--surface-3); color: var(--text); }
.md-code pre { margin: 0; padding: 4px 16px 14px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 2; }
.md-code code { padding: 0; background: none; font-size: inherit; }
.tk-k { color: var(--code-key); }
.tk-s { color: var(--code-str); }
.tk-n { color: var(--code-num); }
.tk-c { color: var(--code-com); font-style: italic; }
.tk-f { color: var(--code-fn); }
.md.msg-note, .md.msg-info { font-family: var(--font); font-size: 14px; color: var(--muted); line-height: 1.55; gap: 8px; }
.md.msg-note { font-style: italic; }
.msg-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.msg-divider::before, .msg-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- steps and tool calls: quiet, one level deep ---------- */
.step-group { min-width: 0; }
.step-head {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 34px; padding: 0 12px 0 8px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.step-head:hover { background: var(--surface-3); color: var(--text-2); }
.step-lead { display: flex; flex: none; }
.step-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-head > .icon { flex: none; width: 14px; height: 14px; transition: transform 0.15s; transform: rotate(-90deg); }
.step-group.open .step-head > .icon { transform: none; }
.step-list { list-style: none; margin: 6px 0 4px 16px; padding: 0 0 0 14px; border-left: 1px solid var(--border-strong); display: grid; gap: 4px; min-width: 0; }
.step-group:not(.open) .step-list { display: none; }
.step { min-width: 0; }
.step::before { content: none; }
.step > .md { margin: 4px 0; }

.tool-row { border-radius: var(--radius-sm); background: transparent; overflow: hidden; }
.tool-head {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
  font: inherit; font-size: 13.5px; color: var(--text-2); text-align: left; cursor: pointer;
}
.tool-head.static { cursor: default; }
.tool-head:hover:not(.static) { background: var(--surface-3); }
.tool-head > .icon { color: var(--muted); flex: none; }
.tool-verb { font-weight: 550; flex: none; }
.tool-summary { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-mark { flex: none; display: flex; color: var(--success); }
.tool-row.error .tool-mark { color: var(--danger); }
.tool-row.open { background: var(--surface-2); }
.tool-details { padding: 4px 10px 10px; display: grid; gap: 8px; background: transparent; border: 0; }
.tool-pre {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 320px; overflow: auto; color: var(--text-2);
}
.tool-pre.diff { padding: 4px 0; white-space: pre; overflow-wrap: normal; }
.tool-pre.diff .del, .tool-pre.diff .add, .tool-pre.diff .ctx { display: grid; grid-template-columns: 28px minmax(0, 1fr); padding-right: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-pre.diff .ln { text-align: right; padding-right: 10px; color: var(--muted); opacity: 0.7; user-select: none; }
.tool-pre.diff .del { color: var(--danger); background: var(--danger-soft); }
.tool-pre.diff .add { color: var(--success); background: var(--success-soft); }
.tool-pre.diff .ctx { color: var(--muted); }
.todo-list { list-style: none; margin: 0; padding: 2px 12px 10px 38px; display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }

/* ---------- cards that need an answer ---------- */
.claude-pending { display: grid; gap: 12px; }
.permission-card {
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 16px; background: var(--surface);
  box-shadow: var(--shadow-sm); display: grid; gap: 12px; animation: pop-in 0.15s ease;
}
.permission-title { display: flex; align-items: center; gap: 9px; font-size: 14.5px; }
.permission-title .icon { color: var(--accent); }
.permission-card p { margin: 0; }
.permission-card .btn-row { justify-content: flex-end; flex-wrap: wrap; }
.question-card, .plan-card { background: var(--surface); border-color: var(--border-strong); }
.question > strong { font-size: 15px; }
.question-option { border-radius: var(--radius); padding: 10px 14px; }
.question-option-label { font-size: 14px; }
.plan-body { background: var(--surface-2); border-radius: var(--radius); }

/* end of a turn */
.msg-result { display: grid; gap: 8px; color: var(--muted); font-size: 13px; margin-top: -6px; }
.msg-result:empty { display: none; }
.msg-result-row { display: flex; align-items: center; gap: 8px; margin-left: -8px; }
.changes-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.changes-head, .changes-file-head { min-height: 40px; font-size: 13.5px; }
.changes-title { font-weight: 550; color: var(--text); }

/* ---------- composer ---------- */
.claude-composer { padding: 0 24px calc(16px + env(safe-area-inset-bottom)); }
.claude-box {
  position: relative; display: grid; gap: 6px; max-width: 740px; width: 100%; margin: 0 auto;
  border: 1px solid var(--border-strong); border-radius: 24px; background: var(--surface); padding: 14px 12px 10px 18px;
  box-shadow: var(--shadow-sm); transition: border-color 0.12s, box-shadow 0.12s;
}
.claude-box:focus-within, .claude-box.drop { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); box-shadow: 0 0 0 3px var(--accent-soft); }
.claude-input { font-size: 16px; line-height: 1.5; padding: 2px 0; max-height: 240px; }
.claude-bar { display: flex; align-items: center; gap: 4px; margin-left: -8px; min-width: 0; }
.claude-bar-btn { width: 36px; height: 36px; border-radius: 50%; }
.claude-send { width: 36px; height: 36px; border-radius: 50%; }
.claude-send.stop { background: var(--text); color: var(--bg); }
.chip-select { height: 36px; padding: 0 8px 0 12px; border-radius: 999px; font-size: 13.5px; gap: 4px; }
.chip-select.mode-plan { color: var(--accent); }
.chip-select.mode-all { color: var(--danger); }
.pick-menu { min-width: 250px; padding: 6px; border-radius: var(--radius); }
.pick-item { min-height: 44px; padding: 6px 10px; border-radius: var(--radius-sm); }
.pick-label { font-size: 14px; }
.pick-note { font-size: 12.5px; }
.pick-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.pick-head { padding: 8px 10px 2px; font-size: 12px; font-weight: 550; color: var(--muted); }
.claude-popup { border-radius: var(--radius); padding: 6px; }
.claude-popup-item { min-height: 40px; border-radius: var(--radius-sm); }
.claude-advice { border-radius: var(--radius); background: var(--surface); border-color: var(--border-strong); }

/* ---------- pages: Settings and Customize ---------- */
.claude-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top)); }
.page-head h1 { flex: 1; margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.page-wrap { max-width: 880px; margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 20px; }
.page-tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.page-tabs::-webkit-scrollbar { display: none; }
.page-tab {
  position: relative; min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--text); font-weight: 600; }
.page-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.page-lead { margin: 0; max-width: 60ch; color: var(--muted); font-size: 14px; line-height: 1.55; }

.set-nav { display: flex; gap: 4px; }
.set-group { display: grid; gap: 4px; }
.set-group > h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.set-group > .page-lead { margin-bottom: 8px; }
.set-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.set-row-text { display: grid; gap: 2px; min-width: 0; }
.set-row-text strong { font-size: 14px; font-weight: 550; }
.set-row-text span { font-size: 13px; color: var(--muted); }
.set-row .segmented button { padding: 0 11px; }
.set-row select, .set-row .input { max-width: 240px; }
.set-pad { padding: 16px 18px; display: grid; gap: 12px; }

/* ---------- Customize: the plugin directory ---------- */
.dir-tools { display: grid; gap: 12px; padding: 16px 0 4px; }
.dir-search { position: relative; }
.dir-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.dir-search input {
  width: 100%; height: 46px; padding: 0 16px 0 42px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.dir-search input:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); box-shadow: 0 0 0 3px var(--accent-soft); }
.dir-filters { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.dir-filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: transparent; color: var(--text-2); font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip small { font-size: 12px; opacity: 0.65; }
.dir-sort { margin-left: auto; flex: none; }
.dir-sort select { height: 34px; border-radius: 999px; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13.5px; }
.dir-count { font-size: 13px; color: var(--muted); padding: 4px 2px 0; }
.dir-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plugin-card {
  display: grid; align-content: start; gap: 8px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer;
}
.plugin-card:hover { border-color: var(--border-strong); }
.plugin-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pc-top { display: flex; align-items: flex-start; gap: 12px; }
.pc-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.pc-title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pc-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-by { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-desc { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pc-meta span { display: inline-flex; align-items: center; gap: 4px; }
.pc-state { flex: none; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; padding-top: 2px; }
.pc-state.on { color: var(--success); }
.dir-empty { padding: 48px 12px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.dir-empty strong { color: var(--text); font-size: 16px; font-weight: 600; }
.dir-more { justify-self: center; }

/* detail pane */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.32); animation: fade-in 0.15s ease; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(560px, 100vw); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: sheet-in 0.2s ease;
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 8px 12px 8px 20px; padding-top: max(8px, env(safe-area-inset-top)); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 24px 24px; display: grid; align-content: start; gap: 20px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
.sheet-title { display: flex; align-items: center; gap: 14px; }
.sheet-title .pc-icon { width: 52px; height: 52px; border-radius: 15px; font-size: 22px; }
.sheet-title h2 { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 500; }
.sheet-title span { font-size: 13.5px; color: var(--muted); }
.sheet-desc { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-2); }
.sheet-facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; font-size: 13.5px; }
.sheet-facts dt { color: var(--muted); }
.sheet-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sheet-facts a { color: var(--accent); }
.sheet-section { display: grid; gap: 8px; }
.sheet-section > h3 { margin: 0; font-size: 14px; font-weight: 600; }
.inc-list { list-style: none; margin: 0; padding: 0; display: grid; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.inc-list li { padding: 10px 14px; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.inc-list li:last-child { border-bottom: 0; }
.inc-list strong { font-size: 13.5px; font-weight: 600; font-family: var(--mono); }
.inc-list span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.sheet-note { margin: 0; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font-size: 13px; line-height: 1.5; }
.sheet-readme { max-height: 340px; overflow-y: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sheet-readme .md { font-size: 14.5px; }

/* skills, connectors, sources: plain rows */
.row-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-text strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-text span { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-tag { flex: none; font-size: 12.5px; color: var(--muted); padding: 2px 10px; border-radius: 999px; background: var(--surface-3); }
.add-form { display: flex; gap: 8px; }
.add-form .input { flex: 1; min-width: 0; height: 42px; }
.form-grid { display: grid; gap: 10px; }
.form-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  body[data-view="claude"] .content { padding: 0 0 env(safe-area-inset-bottom); }
  .claude-shell, .claude-shell.side-open, .claude-shell.side-open.side-wide { grid-template-columns: 1fr; }
  .claude-aside { display: none; border-right: 0; }
  .claude-shell.show-list .claude-aside { display: flex; }
  .claude-shell.show-list .claude-main { display: none; }
  .claude-back { display: inline-flex; }
  .claude-head { padding: 6px 8px; }
  .claude-title > span { display: none; }
  .claude-thread { padding: 12px 16px 16px; }
  .claude-composer { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .claude-box { padding: 12px 8px 8px 14px; border-radius: 22px; }
  .claude-shell.rail-open .claude-rail, .claude-shell.rail-open .claude-composer { padding-right: initial; }
  .claude-shell.rail-open .claude-rail {
    position: fixed; inset: 0; z-index: 40; width: auto; border-left: 0; padding: max(12px, env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg);
  }
  .rail-top { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 2px; }
  .rail-top strong { font-size: 16px; }
  .claude-shell.side-open .claude-side { position: fixed; inset: 0; z-index: 40; border-left: 0; padding-bottom: env(safe-area-inset-bottom); }
  .claude-panel-btn { width: 40px; }
  .claude-input { font-size: 16px; }
  .chip-select { padding: 0 6px 0 10px; }
  .msg-user .bubble { max-width: 92%; }
  .md { font-size: 16px; }
  .claude-empty { padding-top: 8vh; }
  .claude-empty h2 { font-size: 26px; }
  .page-head { padding: 6px 12px; }
  .page-head h1 { font-size: 22px; }
  .page-wrap { padding: 16px 14px 40px; }
  .page-tabs { padding: 0 8px; }
  .dir-list { grid-template-columns: minmax(0, 1fr); }
  .set-row { flex-wrap: wrap; padding: 12px 14px; }
  .sheet { width: 100vw; border-left: 0; }
  .sheet-body { padding: 0 16px 20px; }
  .add-form { flex-direction: column; }
  .add-form .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-scrim, .permission-card, .claude-advice { animation: none; }
}

/* a page (Settings, Customize) takes the place of the chat */
.claude-main.show-page > :not(.claude-page) { display: none; }
.claude-main:not(.show-page) > .claude-page { display: none; }
.pick-menu.as-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 70dvh; overflow-y: auto; z-index: 80;
  border-radius: 20px 20px 0 0; padding: 10px 8px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25);
}
.pick-menu.as-sheet .pick-item { min-height: 52px; }
.claude-page > .page-head, .claude-page > .page-tabs { width: min(880px, 100%); box-sizing: border-box; margin-inline: auto; }
.claude-page > .page-head { padding-inline: 24px; }
.claude-page > .page-tabs { padding-inline: 14px; }
@media (max-width: 860px) {
  .claude-page > .page-head { padding-inline: 12px; }
  .claude-page > .page-tabs { padding-inline: 4px; }
}
.md li > * + * { margin-top: 8px; }
.md li > .md-code, .md li > .md-table { font-size: 14px; }

/* ---------- round two: the session rail floats beside the chat, the message box shares the chat's column ---------- */
.claude-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.claude-rail { border-left: 0; background: transparent; padding: 4px 12px 12px 0; }
.rail-top { display: none; }
@media (min-width: 861px) {
  .claude-shell.rail-open .claude-composer { padding-right: 24px; }
}
@media (max-width: 860px) {
  .rail-top { display: flex; justify-content: flex-end; }
  .claude-shell.rail-open .claude-rail { background: var(--bg); padding: max(12px, env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
}

/* the terminal: a slim panel whose left edge you drag */
.claude-shell.side-open { grid-template-columns: 272px minmax(0, 1fr) var(--side-w, 380px); }
.claude-side { position: relative; border-left: 1px solid var(--border); background: var(--bg); }
.side-resizer { position: absolute; left: -4px; top: 0; bottom: 0; width: 9px; cursor: col-resize; z-index: 5; touch-action: none; }
.side-resizer::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background 0.12s; }
.side-resizer:hover::after, .side-resizer:focus-visible::after, body.resizing .side-resizer::after { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .claude-side iframe, body.resizing .term-view { pointer-events: none; }
@media (max-width: 860px) { .side-resizer { display: none; } }

/* effort opens beside the model list */
.pick-menu { overflow: visible; }
.pick-item.has-sub { position: relative; }
.pick-value { margin-left: auto; color: var(--muted); font-size: 13px; }
.pick-item.has-sub > .icon { transform: rotate(-90deg); color: var(--muted); flex: none; }
.pick-sub {
  display: none; position: absolute; left: calc(100% + 2px); bottom: -7px; min-width: 150px; padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.pick-menu.sub-left .pick-sub { left: auto; right: calc(100% + 2px); }
.pick-item.has-sub:hover > .pick-sub, .pick-item.has-sub:focus-within > .pick-sub, .pick-item.has-sub.open > .pick-sub { display: grid; gap: 1px; }
.pick-menu.as-sheet .pick-sub { position: static; box-shadow: none; border: 0; border-radius: 0; padding: 4px 0 0 12px; background: transparent; min-width: 0; }
.pick-menu.as-sheet .pick-item.has-sub { flex-wrap: wrap; }
.pick-menu.as-sheet .pick-sub { flex-basis: 100%; }
.pick-menu.as-sheet { overflow-y: auto; }

/* settings has nine tabs now: let the row scroll */
.page-tabs { scrollbar-width: none; }

/* ---------- screenshots: thumbnails in the chat ---------- */
.shots-group { display: flex; flex-wrap: wrap; gap: 8px; }
.shot-item { display: contents; }
.shot-thumb { display: block; width: 168px; height: 108px; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.shot-thumb:hover { border-color: var(--accent); }
.shot-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.shot-wait { display: inline-flex; align-items: center; gap: 8px; height: 108px; padding: 0 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); font-size: 13.5px; }
.lightbox {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; align-content: center; gap: 10px; padding: 24px;
  background: rgba(20, 19, 18, 0.86); cursor: zoom-out; animation: fade-in 0.15s ease;
}
.lightbox img { max-width: min(96vw, 1800px); max-height: calc(100dvh - 90px); border-radius: 10px; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lightbox-cap { color: #e7e4da; font-size: 13px; }
.lightbox-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; color: #fff; }

/* ---------- chat rows: the name, and a ⋯ menu ---------- */
.chat-row { position: relative; display: flex; align-items: center; min-width: 0; border-radius: var(--radius-sm); }
.chat-row:hover, .chat-row:focus-within, .chat-row.active { background: var(--surface-3); }
.chat-row.active .chat-item { color: var(--text); }
.chat-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat-more {
  flex: none; width: 32px; height: 32px; margin-right: 2px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer; opacity: 0;
}
.chat-row:hover .chat-more, .chat-row:focus-within .chat-more, .chat-row.active .chat-more, .chat-more:focus-visible { opacity: 1; }
.chat-more:hover { background: var(--border); color: var(--text); }
@media (hover: none) { .chat-more { opacity: 1; width: 40px; height: 40px; } }

/* the chat list folds away on wide screens */
.claude-expand, .aside-collapse { flex: none; }
.claude-expand { display: none; }
@media (min-width: 861px) {
  .claude-shell.aside-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .claude-shell.aside-collapsed.side-open { grid-template-columns: 0 minmax(0, 1fr) var(--side-w, 380px); }
  .claude-shell.aside-collapsed .claude-aside { visibility: hidden; overflow: hidden; border-right: 0; }
  .claude-shell.aside-collapsed .claude-expand { display: inline-flex; }
}
@media (max-width: 860px) { .aside-collapse { display: none; } }

/* dictation */
.claude-mic.listening { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); animation: mic-pulse 1.4s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 35%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* scheduled runs */
.msg-scheduled { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.schedule-row { align-items: flex-start; }
.schedule-row .env-name { white-space: normal; line-height: 1.35; }
.permission-card .check-row { font-size: 13px; color: var(--text-2); }
.chat-item-clock { display: inline-flex; color: var(--muted); flex: none; }
