:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --line: #d8d8d2;
  --text: #232622;
  --muted: #62675f;
  --accent: #1f6f78;
  --accent-soft: #e6f2f2;
  --warn: #8a5a00;
  --code: #171a18;
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  box-shadow: 0 18px 42px rgb(0 0 0 / 14%);
}

.auth-form {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
}

.auth-form button,
.link-button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 9px 10px;
}

.auth-form button {
  margin-top: 6px;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.link-button {
  margin-top: 10px;
  border: 0;
  color: var(--accent);
  text-align: left;
  padding-left: 0;
}

button,
select,
input,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  max-height: 100vh;
  border-right: 1px solid var(--line);
  background: #ededE8;
  padding: 18px 14px;
  overflow-x: hidden;
  overflow-y: auto;
}

.brand {
  margin-bottom: 22px;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
}

.brand-subtitle,
.active-meta,
.git-summary,
.muted {
  color: var(--muted);
}

.sidebar-section {
  margin: 18px 0;
}

.project-form {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.server-project-panel {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.project-form input,
.server-project-panel select,
.merge-form input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 8px;
}

.merge-form {
  display: grid;
  gap: 7px;
}

.merge-source-picker {
  position: relative;
  min-width: 0;
}

.merge-source-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
}

.merge-source-count {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.merge-source-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 7px;
  width: 100%;
  height: min(520px, var(--merge-dropdown-space, 70vh));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgb(0 0 0 / 16%);
  overflow: hidden;
}

.merge-source-picker.open-upward .merge-source-dropdown {
  top: auto;
  bottom: calc(100% + 5px);
}

.merge-source-dropdown[hidden] {
  display: none;
}

.merge-source-dropdown input {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.merge-order-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.merge-selected-order {
  display: grid;
  gap: 4px;
  max-height: 128px;
  overflow-y: auto;
}

.merge-selected-order:empty {
  display: none;
}

.merge-selected-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
}

.merge-selected-number,
.merge-option-order {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
}

.merge-selected-remove {
  border: 0 !important;
  padding: 2px 5px !important;
  background: transparent !important;
  color: var(--muted) !important;
}

.merge-source-options {
  display: grid;
  gap: 4px;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.merge-source-option {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px !important;
  text-align: left;
}

.merge-source-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.merge-option-order.empty {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.merge-option-label {
  min-width: 0;
}

.merge-option-title,
.merge-option-id {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-option-title {
  font-weight: 650;
}

.merge-option-id {
  color: var(--muted);
  font-size: 11px;
}

.project-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.project-buttons button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.project-buttons button {
  padding: 7px 6px;
}

.server-project-panel button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 7px 8px;
}

.merge-form button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 7px 8px;
}

.provider-settings {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.provider-settings label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 6px;
}

.settings-row input,
.provider-settings select,
.settings-row button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.settings-row input,
.provider-settings select {
  padding: 7px 8px;
}

.settings-row button {
  cursor: pointer;
}

.settings-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.settings-status.ok {
  color: var(--accent);
}

.settings-status.error {
  color: #842828;
}

.section-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

button.section-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.section-toggle-caret {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
}

button.section-toggle[aria-expanded="false"] .section-toggle-caret {
  transform: rotate(-90deg);
}

.nav-list {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.branch-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 5px;
}

.nav-item,
.wide-button,
.tab,
.composer button,
	.branch-options-button,
	.branch-options-menu button,
	.message-options-menu button,
	.file-toolbar button,
	.file-upload-button,
	.file-row {
	  border: 1px solid var(--line);
	  background: var(--panel);
	  color: var(--text);
	  cursor: pointer;
	}

.nav-item {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  padding: 9px 10px;
  text-align: left;
  border-radius: 6px;
}

.branch-main {
  min-width: 0;
}

.branch-options-button {
  width: 34px;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1;
}

.branch-options-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.branch-row.open .branch-options-menu {
  display: grid;
  gap: 4px;
}

.branch-options-menu button {
  width: 100%;
  padding: 7px 8px;
  border-radius: 5px;
  text-align: left;
}

.branch-options-menu button.danger {
  color: #842828;
}

.nav-item.active,
.wide-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.branch-row.job-running .branch-main,
.branch-row.job-running .branch-options-button {
  border-color: #c56a12;
  box-shadow: inset 0 0 0 1px #c56a12;
}

.branch-row.job-done .branch-main,
.branch-row.job-done .branch-options-button {
  border-color: #2f8f46;
  box-shadow: inset 0 0 0 1px #2f8f46;
}

/* Same two states, tallied on the folder header, so collapsing a folder does not
   hide the fact that something inside it is running or waiting to be read. */
.folder-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.folder-dot.job-running {
  background: #c56a12;
}

.folder-dot.job-done {
  background: #2f8f46;
}

#contextChatButton.job-running {
  border-color: #c56a12;
  box-shadow: inset 0 0 0 1px #c56a12;
}

#contextChatButton.job-done {
  border-color: #2f8f46;
  box-shadow: inset 0 0 0 1px #2f8f46;
}

#contextChatButton.job-failed {
  border-color: #b33636;
  box-shadow: inset 0 0 0 1px #b33636;
}

.nav-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.nav-meta {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.wide-button {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border-radius: 6px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar > div:first-child {
  min-width: 0;
}

.active-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.active-title {
  font-size: 20px;
  font-weight: 750;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.open-dir-button {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.open-dir-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.open-dir-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.active-meta {
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.tab {
  padding: 8px 12px;
  border-radius: 6px;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.event-panel-toggle {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.event-panel-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sequence-order-picker {
  position: relative;
}

.sequence-order-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 100px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgb(0 0 0 / 16%);
  overflow: auto;
}

.sequence-order-dropdown[hidden],
.sequence-order-picker[hidden] {
  display: none;
}

.sequence-order-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.sequence-order-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sequence-order-speak {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  text-align: left;
}

.sequence-evaluator-toggle {
  padding: 6px 8px;
  white-space: nowrap;
}

.sequence-evaluator-toggle.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.sequence-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.sequence-agent-rows {
  display: grid;
  gap: 12px;
}

.sequence-agent-row {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.sequence-agent-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sequence-dialog::backdrop {
  background: rgb(0 0 0 / 35%);
}

.sequence-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.sequence-dialog label {
  display: grid;
  gap: 5px;
  font-weight: 650;
}

.sequence-dialog input,
.sequence-dialog select,
.sequence-dialog textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions button {
  padding: 8px 12px;
}

.sequence-update-dialog {
  width: min(1100px, calc(100vw - 32px));
}

.sequence-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 320px;
}

.sequence-compare section {
  min-width: 0;
}

.sequence-compare h4 {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.sequence-compare pre {
  height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f7f7f2;
}

.sequence-compare .sequence-summary-view {
  height: 160px;
}

.tab-panel {
  display: none;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 22px;
}

.tab-panel.active {
  display: block;
}

#chatTab.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  overflow: hidden;
  padding: 18px 22px;
}

/* Any sidebar panel opens the second column — the rule used to name only
   .event-visible, so BTW and Model rendered under the chat instead of beside it. */
#chatTab.active.event-visible,
#chatTab.active.btw-visible,
#chatTab.active.model-visible {
  grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px);
}

#chatTab.active.event-visible .message-list,
#chatTab.active.event-visible .composer,
#chatTab.active.event-visible .progress-panel,
#chatTab.active.event-visible .chat-error,
#chatTab.active.event-visible .resource-stage,
#chatTab.active.btw-visible .message-list,
#chatTab.active.btw-visible .composer,
#chatTab.active.btw-visible .progress-panel,
#chatTab.active.btw-visible .chat-error,
#chatTab.active.btw-visible .resource-stage,
#chatTab.active.model-visible .message-list,
#chatTab.active.model-visible .composer,
#chatTab.active.model-visible .progress-panel,
#chatTab.active.model-visible .chat-error,
#chatTab.active.model-visible .resource-stage {
  width: 100%;
  max-width: none;
}

#summariesTab.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.chat-main {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 30;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgb(247 251 249 / 88%);
  color: var(--accent);
  font-weight: 750;
  pointer-events: none;
}

.drop-overlay[hidden] {
  display: none;
}

.chat-main.drop-active .message-list,
.chat-main.drop-active .composer,
.chat-main.drop-active .progress-panel,
.chat-main.drop-active .chat-error {
  filter: saturate(0.85);
}

.message-list {
  display: grid;
  gap: 12px;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
  scrollbar-gutter: stable;
}

.message {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 12px;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.pending-message {
  border-style: dashed;
  background: #fbfbf8;
}

/* Your own messages: black background, white text, to stand out from agents. */
.message-user {
  background: #17181c;
  border-color: #17181c;
  color: #f4f4f5;
}

.message-user .message-header {
  color: #b8b9bd;
}

.message-user .message-role {
  color: #ffffff;
}

.message-user .message-text a {
  color: #8ec7ff;
}

.message-user .message-text code {
  background: rgba(255, 255, 255, 0.14);
  color: #f4f4f5;
}

.message-user .message-options-button {
  color: #b8b9bd;
}

/* A chat that got no answer: light red, with one-click resend / delete.
   Declared after .message-user so it overrides the black user-message style. */
.message-failed {
  background: #fdecea;
  border-color: #f1b0b0;
  color: #5a1a1a;
}

.message-failed .message-header {
  color: #8a4a4a;
}

.message-failed .message-role {
  color: #b3261e;
}

.message-failed .message-text a {
  color: #0645ad;
}

.message-failed .message-text code {
  background: rgba(0, 0, 0, 0.06);
  color: #5a1a1a;
}

.message-failed .message-options-button {
  color: #8a4a4a;
}

.message-failed-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.message-failed-note {
  color: #b3261e;
  font-size: 12px;
  font-weight: 700;
  margin-right: auto;
}

.message-failed-resend,
.message-failed-delete {
  padding: 5px 11px;
  border-radius: 5px;
  font-weight: 650;
  cursor: pointer;
}

.message-failed-resend {
  border: 1px solid #b3261e;
  background: #fff;
  color: #b3261e;
}

.message-failed-resend:hover {
  background: #b3261e;
  color: #fff;
}

.message-failed-delete {
  border: 1px solid #d0a0a0;
  background: transparent;
  color: #8a2a2a;
}

.message-failed-delete:hover {
  background: #f6dada;
}

.pending-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.message-role {
  color: var(--accent);
  font-weight: 700;
}

.message-meta-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.message-number {
  min-width: 2ch;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  text-align: right;
}

.message-options {
  position: relative;
  display: inline-flex;
}

.message-options-button {
  width: 26px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}

.message-options-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.message-options-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 142px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.message-options.open .message-options-menu {
  display: grid;
  gap: 4px;
}

.message-options-menu button {
  width: 100%;
  padding: 7px 8px;
  border-radius: 5px;
  text-align: left;
}

.message-options-menu button.danger {
  color: #842828;
}

.message-text {
  max-width: 100%;
  min-width: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.sequence-evaluation {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #cbd9da;
  border-radius: 8px;
  background: #f4f8f8;
  font-size: 0.9rem;
}

.sequence-evaluation summary {
  cursor: pointer;
  color: #176b73;
  font-weight: 700;
}

.sequence-evaluation ul {
  margin: 8px 0 0 20px;
}

.sequence-criteria .passed {
  color: #256b3b;
}

.sequence-criteria .failed {
  color: #9a3d2f;
}

.message-text p {
  margin: 0 0 0.55em;
}

.message-text p:last-child,
.message-text ul:last-child,
.message-text ol:last-child,
.message-text blockquote:last-child,
.message-text pre:last-child {
  margin-bottom: 0;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4 {
  margin: 0.65em 0 0.35em;
  line-height: 1.25;
}

.message-text h1 {
  font-size: 18px;
}

.message-text h2 {
  font-size: 16px;
}

.message-text h3,
.message-text h4 {
  font-size: 14px;
}

.message-text ul,
.message-text ol {
  margin: 0.25em 0 0.65em 1.2em;
  padding-left: 1.1em;
}

.message-text li {
  margin: 0.15em 0;
}

.message-text blockquote {
  margin: 0.45em 0 0.65em;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.message-text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #f3f3ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.message-text pre {
  margin: 0.45em 0 0.75em;
  padding: 10px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f7f2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

.message-text pre code {
  padding: 0;
  background: transparent;
  white-space: inherit;
}

.message-revise-input {
  display: block;
  width: 100%;
  min-height: 140px;
  height: auto;
  max-height: none;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  resize: none;
}

.message-revise-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 8px;
}

.message-revise-actions button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.message-revise-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.message-revise-actions button[disabled] {
  cursor: wait;
  opacity: 0.65;
}

.message-revise-status {
  margin-top: 5px;
}

.file-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.file-link code {
  color: inherit;
}

.message-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.message-resources-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.message-resources code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.resource-stage {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 980px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d6b36a;
  border-radius: 6px;
  background: #fff8e8;
  color: var(--text);
}

.resource-stage[hidden] {
  display: none;
}

.resource-stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.resource-stage-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-stage-clear,
.resource-stage-chip button {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid #d6b36a;
  border-radius: 999px;
  background: #fffdf6;
  color: #842828;
  cursor: pointer;
  line-height: 1;
}

.resource-stage-clear {
  margin-left: auto;
}

.resource-stage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.resource-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: min(100%, 320px);
  padding: 4px 5px 4px 8px;
  border: 1px solid #e4cca0;
  border-radius: 999px;
  background: #fffdf6;
  font-size: 12px;
}

.resource-stage-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px;
  gap: 8px;
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 10%);
}

.composer.context-mode {
  grid-template-columns: minmax(0, 1fr) 90px 100px;
}

.composer textarea {
  min-height: 72px;
  max-height: 216px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #ffffff;
  overflow-y: auto;
  resize: vertical;
}

.composer button {
  border-radius: 6px;
}

.composer button[hidden] {
  display: none;
}

.composer button.danger-button {
  border-color: #a72e2e;
  background: #a72e2e;
  color: #fff;
}

.composer button.danger-button:hover:not([disabled]) {
  border-color: #842828;
  background: #842828;
}

.composer button[disabled] {
  cursor: wait;
  opacity: 0.65;
}

.progress-panel {
  display: grid;
  gap: 5px;
  width: 100%;
  max-width: none;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fdfdfb;
  padding: 9px 11px;
}

.progress-panel[hidden] {
  display: none;
}

/* One line, clipped: this is the current activity, and a long shell command must
   not push the panel open. The agent's own lines wrap freely below it. */
.progress-title {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-events {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

/* What the model said reads as speech; the tool lines under it stay machinery. */
.progress-events .progress-said {
  color: var(--text);
}

.progress-events .progress-step {
  color: var(--muted);
  opacity: 0.75;
}

/* The commentary stack grows during a turn, so it scrolls rather than pushing the
   composer off screen. */
.progress-events {
  max-height: 40vh;
  overflow-y: auto;
}

.progress-events .progress-said + .progress-said {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dotted var(--line);
}


.event-panel {
  align-self: stretch;
  display: none;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  max-width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

/* Events, BTW and Model share the one sidebar slot; never more than one is open.
   Scoped by id rather than class because the panels share .event-panel for layout,
   so a class rule would show all of them at once. */
#chatTab.active.event-visible #eventPanel {
  display: grid;
}

#chatTab.active.btw-visible #btwPanel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

#chatTab.active.model-visible #modelPanel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.model-form {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 10px 11px;
  border-top: 1px solid var(--line);
  overflow-y: auto;
}

.model-form select {
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.model-form label {
  font-size: 12px;
  color: var(--muted);
}

.btw-form {
  display: grid;
  gap: 8px;
  padding: 10px 11px;
  border-top: 1px solid var(--line);
}

.btw-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.btw-form button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.event-panel[hidden] {
  display: none;
}

.event-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.event-status {
  color: var(--accent);
  text-transform: none;
}

.event-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-header-actions button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
}

.event-copy-status {
  min-height: 18px;
  padding: 4px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.event-meta {
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.event-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  padding: 10px 11px;
}

.event-item {
  display: grid;
  gap: 2px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.event-time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.event-message {
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.artifact-links {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.artifact-touched > summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.artifact-touched[open] > summary {
  margin-bottom: 5px;
}

.artifact-touched > div {
  margin-left: 12px;
}

.approval-requests {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.approval-request {
  display: grid;
  gap: 5px;
  border: 1px solid #d6b36a;
  border-radius: 6px;
  background: #fff8e8;
  padding: 8px;
  font-size: 12px;
}

.approval-request code {
  overflow-wrap: anywhere;
}

.approval-actions {
  display: flex;
  gap: 6px;
}

.approval-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
}

.approval-status {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.error-banner {
  width: 100%;
  max-width: 980px;
  border: 1px solid #d08b8b;
  background: #fff2f2;
  color: #842828;
  border-radius: 6px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.error-banner[hidden] {
  display: none;
}

.chat-error {
  margin: 0;
  font-weight: 650;
}

.error-banner.compact {
  margin: 8px 0 0;
  padding: 8px;
  font-size: 12px;
}

.markdown {
  max-width: 1080px;
  line-height: 1.55;
  word-break: keep-all;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 1.2em 0 0.45em;
}

.markdown table,
.message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0 18px;
  background: var(--panel);
}

.markdown th,
.markdown td,
.message-text th,
.message-text td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

/* Chat is narrower than the report pane, so let wide tables scroll instead of
   overflowing the message bubble. */
.message-text table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}

.file-browser {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.file-toolbar {
  display: grid;
  grid-template-columns: 70px 88px minmax(180px, 1fr) 58px 104px 112px 120px;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.file-toolbar input[type="text"] {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 8px;
}

.file-toolbar button,
.file-upload-button {
  min-width: 0;
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}

.file-upload-button {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}

.file-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-browser-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.file-list {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.file-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  min-width: 0;
  border-radius: 6px;
  padding: 9px 10px;
  text-align: left;
}

.file-row:hover {
  border-color: var(--accent);
}

.file-icon {
  grid-row: span 2;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.file-name,
.file-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name {
  font-weight: 650;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
}

.file-preview {
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.version-grid {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.archive-layout,
.summary-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: 0;
}

.summary-layout {
  height: 100%;
  align-items: stretch;
}

.archive-list,
.archive-viewer,
.summary-list,
.summary-editor {
  min-width: 0;
}

.summary-list {
  max-height: 100%;
  overflow: auto;
}

.summary-editor {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.summary-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.summary-toolbar h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

#summarySaveButton {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 7px 10px;
}

#summarySaveButton:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

#summaryEditor {
  width: 100%;
  height: 100%;
  min-height: min(560px, calc(100vh - 230px));
  resize: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

.archive-heading {
  margin-bottom: 12px;
}

.archive-heading h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.graph-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.graph-toolbar button {
  min-width: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 7px 10px;
}

.branch-graph {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfbf8;
}

.branch-graph-svg {
  display: block;
  min-width: 100%;
  height: auto;
}

.graph-edge path {
  fill: none;
  stroke: #8e948b;
  stroke-width: 1.6;
  marker-end: url("#graphArrow");
}

.graph-edge text {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fbfbf8;
  stroke-width: 4px;
}

.graph-edge-merge path {
  stroke: #8b4b96;
  stroke-width: 2.1;
}

.graph-edge-sequence path {
  stroke: #8b4fc4;
  stroke-dasharray: 7 4;
}

.graph-edge-sequence text {
  fill: #6e329f;
}

.graph-edge-fork path {
  stroke: var(--accent);
  stroke-width: 2;
}

.graph-edge-clone path {
  stroke-dasharray: 5 4;
}

.graph-edge-archive path {
  stroke: #8a5a00;
  stroke-dasharray: 4 4;
}

#graphArrow path {
  fill: #8e948b;
}

.graph-node {
  outline: none;
}

.graph-node rect {
  fill: #ffffff;
  stroke: var(--line);
  stroke-width: 1.2;
}

.graph-node circle {
  fill: var(--accent);
}

.graph-node.active rect {
  stroke: var(--accent);
  stroke-width: 2.2;
  fill: var(--accent-soft);
}

.graph-node.clickable {
  cursor: pointer;
}

.graph-node.clickable:hover rect {
  stroke: var(--accent);
}

.graph-node-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.graph-node-meta {
  fill: var(--muted);
  font-size: 11px;
}

.graph-node-root rect {
  fill: #eff2ee;
}

.graph-node-archive rect {
  fill: #fff8e8;
  stroke: #d6b36a;
}

.graph-node-archive circle {
  fill: #8a5a00;
}

.graph-status-archived rect {
  fill: #f3f3ef;
  stroke-dasharray: 4 3;
}

.graph-status-missing rect {
  fill: #f6eded;
  stroke: #d08b8b;
  stroke-dasharray: 4 3;
}

.graph-status-missing circle {
  fill: #842828;
}

.version-grid section {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.version-grid h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.definition-list {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 8px;
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-block {
  min-height: 120px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: var(--code);
  color: #ecf0eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.document-list {
  display: grid;
  gap: 8px;
}

.document-item {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 9px;
}

.menu-toggle {
  display: none;
  font-size: 20px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

@media (max-width: 820px) {
  .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  body {
    overflow: auto;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar,
  .archive-layout,
  .file-browser-grid,
  .file-toolbar,
  #chatTab.active,
  .composer,
  .graph-toolbar,
  .version-grid {
    grid-template-columns: 1fr;
  }

  .graph-toolbar {
    display: grid;
  }

  .event-panel {
    position: static;
    height: auto;
    max-height: none;
    min-height: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .topbar {
    display: grid;
  }

  .menu-toggle {
    display: block;
  }

  #sidebarMenuToggle {
    margin: 8px 14px;
    justify-self: start;
  }

  .sidebar:not(.open),
  .tabs:not(.open) {
    display: none;
  }
}


.kit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
}

.kit-button .icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  background: var(--panel);
}

.settings-overlay[hidden] {
  display: none;
}

.settings-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px;
}

.settings-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-page-head h1 {
  margin: 0;
  font-size: 22px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.settings-tab.active,
.kit-settings-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.settings-panel {
  display: none;
  max-width: 560px;
}

.settings-panel.active {
  display: block;
}

#settingsPanel-kit {
  max-width: none;
}

.kit-settings {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.kit-settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kit-settings-tab {
  text-align: left;
}

.kit-settings-form {
  display: grid;
  gap: 8px;
  max-width: 560px;
}

.kit-settings-form h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.kit-settings-custom {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.kit-settings-custom:empty {
  display: none;
}

.kit-settings-test-output {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
}

.kit-settings-test-output.fail {
  border-color: #b91c1c;
}

@media (max-width: 820px) {
  .kit-settings {
    grid-template-columns: 1fr;
  }

  .kit-settings-tabs {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.kit-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  background: var(--panel);
}

.kit-overlay[hidden] {
  display: none;
}

.kit-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

.kit-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.kit-page-head h1 {
  margin: 0;
  font-size: 22px;
}

.kit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.kit-description {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
}

.kit-list a,
.kit-list a:visited,
.kit-list a:hover {
  color: inherit;
  text-decoration: none;
}

@media (max-width: 1120px) {
  #chatTab.active.event-visible {
    grid-template-columns: minmax(0, 1fr);
  }

  #chatTab.active.event-visible .event-panel {
    max-height: 260px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .composer {
    grid-template-columns: 1fr;
  }

  .composer button {
    min-height: 42px;
  }
}

/* Orchestration log: how the agents produced one output */
.orchestration-button {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 1px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.orchestration-button:hover {
  background: var(--accent);
  color: #fff;
}

.orchestration-dialog {
  width: min(920px, 92vw);
  max-height: 86vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.orchestration-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.orchestration-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.orchestration-title {
  font-size: 16px;
  font-weight: 750;
}

.orchestration-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.orchestration-body {
  padding: 14px 16px 18px;
  overflow-y: auto;
  max-height: calc(86vh - 60px);
}

.orch-task {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  background: var(--bg);
}

.orch-task-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.orch-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.orch-chip {
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

.orch-arrow {
  color: var(--muted);
}

.orch-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.orch-entry {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
}

.orch-entry.orch-delegation {
  border-left-color: var(--warn);
  margin-left: 22px;
}

.orch-entry.orch-failed {
  border-left-color: #a33;
}

.orch-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.orch-seq {
  font-weight: 700;
  color: var(--muted);
  min-width: 18px;
}

.orch-role {
  font-weight: 750;
}

.orch-stage {
  color: var(--muted);
}

.orch-badge {
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 7px;
  color: var(--muted);
}

.orch-duration {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.orch-block {
  margin-top: 6px;
}

.orch-block summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.orch-block pre {
  margin: 6px 0 0;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: normal;
  overflow-x: auto;
  font-size: 12px;
  max-height: 320px;
  overflow-y: auto;
}

/* Orchestration timeline (Gantt): subagent lanes on a shared time axis */
.orch-timeline {
  --lane-label-w: 160px;
  margin: 4px 0 8px;
}

.orch-ruler {
  display: grid;
  grid-template-columns: var(--lane-label-w) 1fr;
  margin-bottom: 6px;
}

.orch-ruler::before { content: ""; }

.orch-ruler-track {
  position: relative;
  height: 16px;
  border-bottom: 1px solid var(--line);
}

.orch-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.orch-tick:first-child { transform: none; }
.orch-tick:last-child { transform: translateX(-100%); }

.orch-lane {
  display: grid;
  grid-template-columns: var(--lane-label-w) 1fr;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.orch-lane-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.orch-lane-name {
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orch-lane-dur {
  font-size: 10px;
  color: var(--muted);
}

.orch-lane-track {
  position: relative;
  height: 20px;
  background: var(--bg);
  border-radius: 5px;
  border: 1px solid var(--line);
}

.orch-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-width: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2, #4a9aa3));
  box-shadow: 0 1px 3px rgb(0 0 0 / 18%);
}

.orch-lane-detail {
  grid-column: 1 / -1;
}

.orch-lane-detail > summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  padding: 3px 0 3px var(--lane-label-w);
}

.orch-ev-list {
  margin: 2px 0 4px var(--lane-label-w);
  border-left: 2px solid var(--line);
  padding-left: 10px;
  display: grid;
  gap: 3px;
}

.orch-ev {
  display: grid;
  grid-template-columns: 46px 16px 1fr;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}

.orch-ev-t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.orch-ev-i { text-align: center; }
.orch-ev-l { min-width: 0; overflow-wrap: anywhere; word-break: keep-all; }
.orch-ev-text .orch-ev-l { color: var(--muted); }

.orch-ev-summary {
  margin: 4px 0 6px var(--lane-label-w);
}

.orch-ev-summary pre {
  margin: 4px 0 0;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-size: 12px;
  max-height: 240px;
  overflow-y: auto;
}

.orch-entry-timeline {
  margin: 6px 0 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.orch-entry-tl-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Extensions ------------------------------------------------------------- */
.extension-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.extension-row .extension-item {
  flex: 1;
  min-width: 0;
}

.extension-row.disabled .extension-item {
  opacity: 0.5;
}

.extension-toggle {
  flex-shrink: 0;
  cursor: pointer;
}

.extension-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.extension-content {
  padding: 8px 4px;
}

.extension-header h2 {
  margin: 0 0 2px;
}

.extension-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.extension-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.extension-form input {
  flex: 1;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.extension-form button {
  padding: 9px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.instagram-result {
  margin-top: 14px;
}

.instagram-profile {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.instagram-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--accent-soft);
}

.instagram-profile-info {
  min-width: 0;
}

.instagram-profile-name {
  font-size: 18px;
  font-weight: 700;
}

.instagram-profile-name a {
  color: var(--text);
  text-decoration: none;
}

.instagram-profile-fullname {
  color: var(--muted);
  margin-bottom: 8px;
}

.instagram-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 14px;
}

.instagram-bio {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.4;
}

.instagram-external a {
  color: var(--accent);
  font-size: 13px;
}

.instagram-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.instagram-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: var(--accent-soft);
  display: block;
}

.instagram-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.instagram-video-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  color: #fff;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.instagram-tile-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  opacity: 0;
  transition: opacity 0.15s ease;
}

.instagram-tile:hover .instagram-tile-meta {
  opacity: 1;
}

.instagram-private-note,
.instagram-empty {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

/* Branch folders --------------------------------------------------------- */
.branch-folder {
  margin-top: 4px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  border-radius: 6px;
}

.folder-header:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.folder-caret {
  display: inline-block;
  transition: transform 0.12s ease;
  font-size: 10px;
}

.branch-folder.collapsed .folder-caret {
  transform: rotate(-90deg);
}

.folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.folder-count {
  flex-shrink: 0;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

/* Collapsed folders keep their (JS-filtered) body visible — only the active
   branch is rendered inside, so we no longer hide the whole body here. */
.branch-folder.collapsed .folder-body:empty {
  display: none;
}

.folder-body {
  padding-left: 6px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}

/* Branch folder actions + picker dialog ---------------------------------- */
.branch-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.branch-actions #contextChatButton {
  flex: 1;
}

.branch-actions #newFolderButton {
  flex-shrink: 0;
  width: auto;
  white-space: nowrap;
}

.folder-header-row {
  display: flex;
  align-items: center;
}

.folder-header-row .folder-header {
  flex: 1;
  min-width: 0;
}

.folder-delete {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.branch-folder:hover .folder-delete {
  opacity: 1;
}

.folder-delete:hover {
  background: #fdecea;
  color: #b3261e;
}

.folder-empty {
  padding: 6px 10px;
  font-size: 11px;
  font-style: italic;
}

.folder-dialog {
  width: min(360px, 92vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.folder-dialog::backdrop {
  background: rgb(0 0 0 / 32%);
}

.folder-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.folder-dialog-head button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.folder-dialog-target-row {
  padding: 10px 14px 6px;
  font-size: 12px;
  color: var(--muted);
}

.folder-dialog-list {
  display: grid;
  gap: 4px;
  padding: 6px 12px;
  max-height: 320px;
  overflow-y: auto;
}

.folder-pick {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.folder-pick:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.folder-pick.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.folder-dialog-new {
  display: flex;
  gap: 6px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line);
}

.folder-dialog-new input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.folder-dialog-new button {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* Guiding knowledge + Knowledging ---------------------------------------- */
.knowledge-dialog {
  width: min(520px, 94vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.knowledge-dialog::backdrop {
  background: rgb(0 0 0 / 32%);
}

.knowledge-dialog .settings-status {
  padding: 0 14px 12px;
  font-size: 12px;
}

.knowledge-dialog-hint {
  padding: 0 14px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.knowledge-dialog-list {
  display: grid;
  gap: 6px;
  padding: 6px 12px;
  max-height: 320px;
  overflow-y: auto;
}

.knowledge-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.knowledge-pick:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.knowledge-pick.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.knowledge-pick-toggle {
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.knowledge-pick.active .knowledge-pick-toggle {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.knowledge-pick-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.knowledge-pick-title {
  font-weight: 600;
}

.knowledge-pick-meta {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.knowledge-source {
  margin: 10px 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft, var(--panel));
}

.knowledge-source-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.knowledge-source-text {
  font-size: 12px;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.knowledge-form {
  display: grid;
  gap: 10px;
  padding: 4px 14px 12px;
}

.knowledge-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.knowledge-field select,
.knowledge-field input,
.knowledge-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.knowledge-result {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow-y: auto;
}

.extensions-version {
  padding: 0 2px 8px;
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.extensions-version code {
  font-size: 10px;
  padding: 1px 3px;
  border-radius: 3px;
  background: var(--accent-soft);
}

.ext-dirty {
  color: var(--warn, #b7791f);
}

.extension-updated {
  margin-left: 6px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

.extensions-stale {
  margin: 0 0 8px;
  padding: 7px 9px;
  border: 1px solid var(--warn, #b7791f);
  border-radius: 6px;
  background: color-mix(in srgb, var(--warn, #b7791f) 12%, transparent);
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
}

/* Google Workspace extension panel --------------------------------------- */
.gw-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

.gw-chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.gw-chip.ok {
  background: #e6f4ea;
  color: #137333;
}

.gw-chip.off {
  background: var(--line);
  color: var(--muted);
}

.gw-refresh {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.gw-steps {
  padding-left: 20px;
  display: grid;
  gap: 12px;
  line-height: 1.5;
}

.gw-steps code {
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.gw-steps .code-block {
  margin: 6px 0 0;
  white-space: pre;
  overflow-x: auto;
}

.gw-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.gw-warn {
  color: var(--warn);
}

/* Archived branch restore ------------------------------------------------ */
.archived-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 5px;
  align-items: center;
}

.archived-row .archived-main {
  min-width: 0;
}

.archived-restore {
  width: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  padding: 8px 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
}

.archived-restore:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Composer: while a turn runs, the right button switches its mode --------- */
#historyChatButton.mode-swap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
  padding-top: 5px;
  padding-bottom: 5px;
}

#historyChatButton .mode-swap-detail {
  font-size: 9px;
  font-weight: 400;
  opacity: 0.8;
  white-space: nowrap;
}



/* The turn's working notes: present, but folded so the answer still leads. */
.turn-narration {
  margin: 0 0 8px;
  padding: 6px 8px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.turn-narration > summary {
  cursor: pointer;
  user-select: none;
}

.turn-narration > div {
  margin-top: 4px;
  line-height: 1.45;
}


/* Boss chat ------------------------------------------------------------------
   A desk rather than a conversation: the board of branch cards is the primary
   surface and takes the wide column; the log of what was asked sits beside it;
   the composer runs underneath both. */
.chat-main.boss-mode {
  grid-template-columns: minmax(0, 1.75fr) minmax(260px, 1fr);
}

.chat-main.boss-mode > * {
  grid-column: 1 / -1;
}

.chat-main.boss-mode > .boss-board {
  grid-column: 1;
  grid-row: 1;
}

.chat-main.boss-mode > .message-list {
  grid-column: 2;
  grid-row: 1;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

@media (max-width: 1100px) {
  .chat-main.boss-mode {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.6fr) minmax(110px, 1fr) auto auto;
  }

  .chat-main.boss-mode > .message-list {
    grid-column: 1;
    grid-row: 2;
    padding-left: 0;
    border-left: 0;
  }
}

.boss-board {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.boss-board[hidden] {
  display: none;
}

.boss-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
}

.boss-bar input {
  flex: 1 1 220px;
  min-width: 0;
}

.boss-bar-gap {
  flex: 0 0 8px;
}

.boss-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
  align-content: start;
  align-items: start;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
  scrollbar-gutter: stable;
}

.boss-empty {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.boss-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.boss-card.has-draft {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.boss-card.is-running {
  border-color: #c56a12;
  box-shadow: inset 3px 0 0 #c56a12;
}

.boss-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.boss-card-title {
  flex-shrink: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-card-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.boss-card-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-state {
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.boss-state.running  { background: #c56a12; color: #fff; }
.boss-state.ready    { background: var(--accent); color: #fff; }
.boss-state.drafting { background: var(--accent-soft); color: var(--accent); }
.boss-state.failed   { background: #b33636; color: #fff; }
.boss-state.idle     { background: var(--line); color: var(--muted); }

.boss-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.boss-card-told {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.boss-card-told-text {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-card-answer {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.boss-card-answer-body {
  max-height: 5.8em;
  overflow: hidden;
  font-size: 12.5px;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}

.boss-card-answer.expanded .boss-card-answer-body {
  max-height: 340px;
  overflow-y: auto;
  -webkit-mask-image: none;
  mask-image: none;
}

.boss-link {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.boss-card-progress {
  overflow: hidden;
  color: #c56a12;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The draft is the part that is meant to be read, argued with and rewritten, so
   it is set apart from the branch's status above it. */
.boss-card-draft {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.boss-chip {
  padding: 0 6px;
  border-radius: 8px;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.boss-chip.followup { background: var(--accent-soft); color: var(--accent); }
.boss-chip.done     { background: #e2f3e6; color: #2f8f46; }

/* Why this follow-up exists, so approving it is a judgement and not a reflex. */
.boss-card-why {
  color: var(--muted);
  font-size: 12px;
}

.boss-card textarea,
.boss-card input[type="text"],
.boss-bar input,
.boss-picker-head input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.boss-card textarea {
  line-height: 1.5;
  resize: vertical;
}

.boss-card-feedback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.boss-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.boss-card-actions-label {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.boss-card button,
.boss-bar button,
.boss-empty button,
.boss-picker-head button,
.boss-folder-all {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.boss-card button.boss-card-title,
.boss-card button.boss-link {
  padding: 0;
  border: 0;
}

.boss-card button.boss-card-title {
  font-size: 14px;
  font-weight: 700;
}

.boss-card button:hover:not([disabled]),
.boss-bar button:hover:not([disabled]) {
  border-color: var(--accent);
}

.boss-card button[disabled],
.boss-bar button[disabled] {
  cursor: wait;
  opacity: 0.55;
}

.boss-approve {
  font-weight: 700;
}

.boss-approve.suggested {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.boss-suggested {
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 7px;
  background: rgb(255 255 255 / 25%);
  font-size: 10px;
}

.boss-discard {
  color: var(--muted);
}

.boss-link.boss-zoom {
  margin-left: 2px;
  font-weight: 400;
  opacity: 0.85;
}

.boss-link.boss-zoom:hover {
  opacity: 1;
  text-decoration: underline;
}

/* The reader: one thing, in full, at a measure that can actually be read. */
.boss-reader {
  width: min(780px, 94vw);
  max-height: 86vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgb(0 0 0 / 22%);
}

.boss-reader[open] {
  display: flex;
  flex-direction: column;
}

.boss-reader::backdrop {
  background: rgb(17 24 39 / 38%);
}

.boss-reader-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.boss-reader-titles {
  flex: 1;
  min-width: 0;
  font-size: 15px;
}

.boss-reader-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.boss-reader-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.boss-reader-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background: var(--bg);
}

.boss-reader-body,
.boss-reader-edit {
  display: block;
  width: 100%;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.75;
}

.boss-reader-body[hidden],
.boss-reader-edit[hidden] {
  display: none;
}

.boss-reader-body {
  overflow-wrap: anywhere;
}

.boss-reader-edit {
  min-height: 46vh;
  resize: vertical;
}

.boss-reader-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.boss-reader-foot .settings-status {
  margin-right: auto;
}

.boss-reader-foot button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.boss-reader-foot button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* The log beside the board: compact, it is a record rather than the main event. */
.boss-log-entry {
  padding: 8px 10px;
  font-size: 12.5px;
}

.boss-log-entry.boss-log-feedback {
  border-left: 3px solid #d9a400;
}

.boss-log-entry.message-assistant {
  background: transparent;
}

/* Composer: one action. */
.composer.boss-mode {
  grid-template-columns: minmax(0, 1fr) 110px 90px;
}

/* Branch picker (Branches tab): the sidebar's folders, with checkboxes. */
#bossTab.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  padding: 18px 22px;
}

.boss-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  max-width: 760px;
  min-height: 0;
}

.boss-picker-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.boss-picker-hint {
  color: var(--muted);
  font-size: 12px;
}

.boss-picker-list {
  display: grid;
  gap: 2px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
}

/* Unlike the sidebar, a collapsed folder here hides everything inside it: the
   count on its header already says how many are chosen. */
.boss-pick-folder.collapsed .folder-body {
  display: none;
}

.boss-pick-folder .folder-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.boss-folder-all {
  flex-shrink: 0;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
  visibility: hidden;
}

.boss-pick-folder:hover .boss-folder-all {
  visibility: visible;
}

.folder-count.has-picked {
  background: var(--accent);
  color: #fff;
}

.boss-pick {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
}

.boss-pick:hover {
  background: var(--accent-soft);
}

.boss-pick-title {
  font-weight: 650;
}

.boss-pick.running .boss-pick-title {
  color: #c56a12;
}

.boss-pick-meta {
  color: var(--muted);
  font-size: 11px;
}

/* Sidebar: the desk's branches under the Boss chat button. */
.branch-actions {
  flex-wrap: wrap;
}

.branch-actions #bossChatButton {
  flex: 1;
  white-space: nowrap;
}

#bossChatButton.job-running {
  border-color: #c56a12;
  box-shadow: inset 0 0 0 1px #c56a12;
}

.boss-pending-badge {
  display: inline-block;
  min-width: 16px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 8px;
  background: #d9a400;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.boss-pending-badge[hidden] {
  display: none;
}

.boss-nav-folder {
  margin-bottom: 6px;
}

.boss-nav-folder[hidden] {
  display: none;
}

.boss-nav-folder .branch-folder {
  margin-top: 0;
}

.boss-nav-folder .branch-folder.collapsed .folder-body {
  display: none;
}

.boss-nav-folder .folder-body {
  border-left-color: #d9a400;
}

.boss-nav-folder .branch-row {
  grid-template-columns: minmax(0, 1fr);
}

/* Each Boss is a row; the branches it holds unfold beneath it. */
.boss-desk + .boss-desk {
  margin-top: 5px;
}

/* The delete control floats over the row instead of taking a column, so a Boss
   that can be deleted is as wide as one that cannot. */
.boss-nav-folder .boss-desk-row .boss-desk-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  line-height: 22px;
}

.boss-desk-caret {
  display: inline-block;
  width: 12px;
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.12s ease;
}

.boss-desk.open .boss-desk-caret {
  transform: rotate(90deg);
}

.boss-desk-delete {
  visibility: hidden;
  color: var(--muted);
}

.boss-desk-row:hover .boss-desk-delete {
  visibility: visible;
}

.boss-desk-branches {
  margin-top: 5px;
  display: grid;
  gap: 5px;
}

.boss-desk-row .boss-pending-badge {
  vertical-align: 1px;
}

/* A Boss split off from another Boss, so it is tellable at a glance. */
.boss-star {
  margin-right: 4px;
  color: #d9a400;
}

.folder-picker {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.folder-picker[hidden] {
  display: none;
}

.folder-picker-path {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.folder-picker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.folder-picker button {
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.folder-picker-actions button {
  text-align: center;
}

.folder-picker button:disabled {
  opacity: 0.5;
  cursor: default;
}

#folderPickerList {
  max-height: 260px;
  overflow-y: auto;
}
