:root {
  color-scheme: light;
  --hub-column-header-height: 76px;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --panel-muted: #f8fafc;
  --toolbar-bg: rgba(255, 255, 255, 0.94);
  --line: #d7dde6;
  --line-strong: #b9c3d0;
  --text: #17202b;
  --muted: #687487;
  --accent: #176b8f;
  --accent-strong: #0f536f;
  --accent-text: #ffffff;
  --danger: #a13e32;
  --code: #eef2f6;
  --select: #e5f2f7;
  --active-topic-bg: #d5edf6;
  --active-topic-border: #176b8f;
  --shadow-soft: rgba(23, 107, 143, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11161d;
  --panel: #18202a;
  --panel-soft: #151c25;
  --panel-muted: #202a36;
  --toolbar-bg: rgba(24, 32, 42, 0.96);
  --line: #334151;
  --line-strong: #526275;
  --text: #edf3f7;
  --muted: #a8b4c2;
  --accent: #49a7c9;
  --accent-strong: #7ac7e2;
  --accent-text: #081018;
  --danger: #ff8b7f;
  --code: #101720;
  --select: #263b48;
  --active-topic-bg: #12384a;
  --active-topic-border: #62c1e2;
  --shadow-soft: rgba(98, 193, 226, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

body {
  margin: 0;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

button.secondary {
  background: var(--panel);
  color: var(--accent);
}

button.secondary:hover {
  background: var(--select);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 9px 10px;
}

.token-field {
  -webkit-text-security: disc;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  height: var(--app-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 250px 220px minmax(280px, 360px) minmax(0, 1fr);
}

.identity-panel,
.pipeline-panel,
.explorer-panel,
.workspace {
  min-width: 0;
  min-height: 0;
}

.identity-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding: 0 14px 18px;
}

.pipeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
  overflow: hidden;
  padding: 0 12px 18px;
}

.cockpit-panel {
  gap: 16px;
}

.cockpit-header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cockpit-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  margin: 0 -14px;
  padding: 0 14px;
}

.cockpit-header .icon-actions {
  justify-content: flex-end;
}

.cockpit-header > * {
  transform: translateY(-2px);
}

.cockpit-header h2,
.settings-header h2,
.cockpit-section h2 {
  margin: 0;
  font-size: 20px;
}

.cockpit-header h2 {
  line-height: 34px;
}

.cockpit-header p,
.settings-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.agent-section {
  display: grid;
  gap: 8px;
}

.pipeline-header {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: var(--hub-column-header-height);
  border-bottom: 1px solid var(--line);
  margin: 0 -12px;
  padding: 0 12px;
}

.pipeline-header h2 {
  margin: 0;
  font-size: 20px;
}

.pipeline-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-status-text {
  color: var(--accent-strong);
  font-weight: 700;
}

.agent-section {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.agent-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.agent-separator {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--panel-muted);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.agent-pulse {
  --agent-pulse-ring: rgba(104, 116, 135, 0.28);
  width: 10px;
  min-width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.agent-working {
  border-color: rgba(214, 154, 45, 0.58);
  background: rgba(214, 154, 45, 0.11);
}

.agent-working .agent-pulse {
  --agent-pulse-ring: rgba(214, 154, 45, 0.45);
  background: #d69a2d;
}

.agent-waiting,
.agent-queued {
  border-color: rgba(73, 167, 201, 0.52);
  background: rgba(73, 167, 201, 0.1);
}

.agent-waiting .agent-pulse,
.agent-queued .agent-pulse {
  --agent-pulse-ring: rgba(73, 167, 201, 0.42);
  background: #49a7c9;
}

.agent-ready,
.agent-idle {
  border-color: rgba(45, 155, 87, 0.38);
}

.agent-ready .agent-pulse,
.agent-idle .agent-pulse {
  background: #2d9b57;
}

.agent-blocked {
  border-color: rgba(161, 62, 50, 0.58);
  background: rgba(161, 62, 50, 0.1);
}

.agent-blocked .agent-pulse {
  background: var(--danger);
}

.agent-state-label {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

.agent-state-working {
  border-color: rgba(214, 154, 45, 0.48);
  color: #9a650d;
}

.agent-state-waiting,
.agent-state-queued {
  border-color: rgba(73, 167, 201, 0.48);
  color: var(--accent);
}

.agent-state-ready,
.agent-state-idle {
  border-color: rgba(45, 155, 87, 0.4);
  color: #2d7f4c;
}

.agent-state-blocked {
  border-color: rgba(161, 62, 50, 0.48);
  color: var(--danger);
}

.agent-text {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.agent-text strong,
.agent-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-text strong {
  font-size: 13px;
  font-weight: 800;
}

.agent-text small {
  color: inherit;
  opacity: 0.8;
  font-size: 12px;
}

.pipeline-view {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.pipeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  padding: 7px;
}

.pipeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -13px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid var(--accent);
  transform: translateX(-50%);
}

.pipeline-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--accent-strong);
  padding: 3px 5px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.pipeline-body {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.pipeline-agent,
.pipeline-title,
.pipeline-body small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-agent {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.pipeline-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.pipeline-body small {
  color: var(--muted);
  font-size: 11px;
}

.pipeline-running {
  border-color: var(--accent);
}

.pipeline-completed {
  border-color: #2d8a57;
}

.pipeline-blocked {
  border-color: #b84a62;
}

.pipeline-review {
  border-color: #5f7890;
}

.pipeline-waiting {
  border-color: #9a6a16;
}

.pipeline-discussion {
  grid-template-columns: 70px minmax(0, 1fr) auto;
  background: #fff8d9;
}

:root[data-theme="dark"] .pipeline-discussion {
  background: #3a2d12;
}

.discussion-end-button {
  min-height: 30px;
  border-color: #b84a62;
  background: #fff0f2;
  color: #8d2438;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.discussion-end-button:hover:not(:disabled) {
  border-color: #8d2438;
  background: #b84a62;
  color: #fff;
}

:root[data-theme="dark"] .discussion-end-button {
  background: #54202b;
  color: #ffdce2;
}

.pipeline-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 10px;
  font-size: 12px;
}

.empty.compact {
  padding: 8px 0;
  font-size: 13px;
}

.settings-modal[hidden],
.roadmap-modal[hidden],
.rescue-modal[hidden],
.completed-tasks-modal[hidden],
.closure-notices-modal[hidden],
.project-path-modal[hidden],
.project-memory-modal[hidden] {
  display: none;
}

.settings-modal,
.roadmap-modal,
.rescue-modal,
.completed-tasks-modal,
.closure-notices-modal,
.project-path-modal,
.project-memory-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.38);
  padding: 18px;
}

.project-memory-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1240px, 96vw);
  max-height: min(820px, 92vh);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.project-path-panel {
  display: grid;
  grid-template-rows: auto auto;
  width: min(520px, 96vw);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.project-path-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-path-header h2 {
  margin: 0;
  font-size: 20px;
}

.project-path-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.project-path-form {
  display: grid;
  gap: 14px;
}

.project-path-form input[type="text"],
.project-path-form input:not([type]) {
  width: 100%;
}

.project-path-rights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.project-path-rights legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.project-path-rights label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

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

.project-memory-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.project-memory-header h2,
.project-memory-header p {
  margin: 0;
}

.project-memory-header p {
  color: var(--muted);
  font-size: 13px;
}

.project-memory-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.project-memory-search-bar {
  display: flex;
  gap: 8px;
  min-width: 0;
}

#projectMemorySearch {
  min-width: 0;
  flex: 1 1 260px;
}

#clearProjectMemorySearch {
  flex: 0 0 auto;
}

.project-memory-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.project-memory-toc,
.project-memory-content {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
}

.project-memory-toc {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
  padding: 8px;
}

.project-memory-content {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.project-memory-toc-folder {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 6px;
}

.project-memory-toc-phase {
  margin-left: 12px;
  background: var(--panel-muted);
}

.project-memory-toc-topic-list {
  display: grid;
  gap: 5px;
  margin-left: 12px;
}

.project-memory-toc-summary {
  cursor: pointer;
  list-style-position: outside;
}

.project-memory-toc-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 30px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  padding: 5px 7px;
  text-align: left;
  cursor: pointer;
}

.project-memory-toc-button:hover,
.project-memory-toc-button.is-active {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.project-memory-toc-button.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.project-memory-toc-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  font-size: 13px;
}

.project-memory-toc-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.project-memory-list {
  display: grid;
  align-content: start;
  gap: 8px;
  width: min(100%, 840px);
  justify-self: center;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.project-memory-handbook-overview,
.project-memory-handbook-section,
.project-memory-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.project-memory-handbook-overview,
.project-memory-handbook-section {
  display: grid;
  gap: 8px;
}

.project-memory-handbook-overview h3,
.project-memory-handbook-section h3,
.project-memory-handbook-topic h4,
.project-memory-handbook-overview p,
.project-memory-handbook-section p,
.project-memory-handbook-topic p,
.project-memory-handbook-points {
  margin: 0;
}

.project-memory-learned-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.project-memory-learned-list li {
  display: grid;
  gap: 3px;
  overflow-wrap: anywhere;
}

.project-memory-learned-list small {
  color: var(--muted);
  font-size: 12px;
}

.project-memory-empty-search {
  border-style: dashed;
}

.project-memory-handbook-overview h3,
.project-memory-handbook-section h3,
.project-memory-handbook-topic h4 {
  overflow-wrap: anywhere;
}

.project-memory-handbook-overview p,
.project-memory-handbook-phase,
.project-memory-handbook-topic p {
  font-size: 13px;
  line-height: 1.4;
}

.project-memory-handbook-overview p,
.project-memory-handbook-phase,
.project-memory-handbook-meta,
.project-memory-handbook-topic small,
.project-memory-empty {
  color: var(--muted);
  font-size: 12px;
}

.project-memory-handbook-list {
  display: grid;
  gap: 7px;
}

.project-memory-handbook-topic {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.project-memory-handbook-topic:first-child {
  border-top: 0;
  padding-top: 0;
}

.project-memory-handbook-graphic {
  margin: 0;
  width: min(100%, 560px);
}

.project-memory-handbook-graphic svg {
  display: block;
  width: 100%;
  height: auto;
}

.project-memory-handbook-graphic rect {
  stroke: var(--line);
  stroke-width: 1.5;
}

.project-memory-handbook-graphic line,
.project-memory-handbook-graphic path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-memory-handbook-graphic circle {
  stroke: var(--line);
  stroke-width: 1.5;
}

.project-memory-handbook-graphic .is-muted {
  fill: var(--panel-muted);
}

.project-memory-handbook-graphic .is-active {
  fill: var(--select);
  stroke: var(--accent);
}

.project-memory-handbook-graphic-label {
  fill: var(--text);
  font-size: 7px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.project-memory-handbook-graphic-note {
  fill: var(--muted);
  font-size: 6.5px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.project-memory-handbook-meta {
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  padding: 2px 7px;
  font-weight: 800;
}

.project-memory-handbook-label {
  margin-top: 3px;
  font-size: 12px;
}

.project-memory-handbook-points {
  display: grid;
  gap: 4px;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.project-memory-handbook-notes {
  color: var(--muted);
}

@media (max-width: 760px) {
  .project-memory-panel {
    max-height: 92vh;
  }

  .project-memory-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 32vh) minmax(0, 1fr);
  }

  .project-memory-search-bar {
    flex-wrap: wrap;
  }

  #projectMemorySearch {
    flex-basis: 100%;
  }

  .runtime-settings-grid {
    grid-template-columns: 1fr;
  }
}

.completed-tasks-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, 96vw);
  max-height: min(620px, 88vh);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.closure-notices-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(820px, 96vw);
  max-height: min(680px, 88vh);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.closure-notices-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.closure-notices-header h2, .closure-notices-header p { margin: 0; }
.closure-notices-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.closure-notices-actions label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.closure-notices-actions small { flex-basis: 100%; color: var(--muted); }
.closure-notices-header p, .closure-notices-list small, .closure-notice-item p, .closure-audit-item p, .closure-notices-empty { color: var(--muted); font-size: 12px; }
.closure-notices-list { display: grid; gap: 8px; min-height: 0; overflow: auto; padding-right: 4px; }
.closure-notice-item, .closure-audit-item, .closure-notices-empty { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); padding: 10px; }
.closure-notice-item strong, .closure-audit-item strong { font-size: 11px; text-transform: uppercase; }
.closure-notice-item span, .closure-notice-item p, .closure-notice-item small, .closure-notice-evidence { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.closure-audit-item span, .closure-audit-item p, .closure-audit-item small, .closure-audit-report, .closure-notice-acknowledge { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.closure-notice-item p, .closure-audit-item p { margin: 0; }
.closure-notice-next { font-weight: 700; }
.closure-notice-evidence, .closure-audit-report, .closure-notice-acknowledge { justify-self: start; }
.closure-notice-acknowledged { opacity: .62; }
.closure-notice-blockiert { border-left: 3px solid #b84a62; }
.closure-notice-wartet { border-left: 3px solid #b88622; }
.closure-notice-offen { border-left: 3px solid #3c77ad; }
.closure-audit-blocked { border-left: 3px solid #b84a62; }
.closure-audit-open { border-left: 3px solid #b88622; }
.closure-audit-clear { border-left: 3px solid #3f8a63; }

.completed-tasks-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.completed-tasks-header h2,
.completed-tasks-header p {
  margin: 0;
}

.completed-tasks-header p {
  color: var(--muted);
  font-size: 13px;
}

.completed-tasks-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.completed-task-item,
.completed-tasks-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.completed-task-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 4px 10px;
}

.completed-task-item strong {
  font-size: 11px;
  text-transform: uppercase;
}

.completed-task-item span,
.completed-task-item small,
.completed-task-blocker {
  min-width: 0;
  overflow-wrap: anywhere;
}

.completed-task-item small,
.completed-task-blocker,
.completed-tasks-empty {
  color: var(--muted);
  font-size: 12px;
}

.completed-task-item small,
.completed-task-blocker {
  grid-column: 2;
}

.completed-task-blocker {
  margin: 0;
}

.completed-task-subtasks {
  grid-column: 2;
  min-width: 0;
  margin-top: 4px;
}

.completed-task-subtasks summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.completed-task-subtask-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.completed-task-subtask {
  display: grid;
  gap: 2px;
  min-width: 0;
  border-left: 2px solid var(--line);
  padding-left: 8px;
}

.completed-task-subtask strong,
.completed-task-subtask small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.completed-task-subtask strong {
  color: var(--text);
  font-size: 12px;
  text-transform: none;
}

.completed-task-completed {
  border-color: #4f8f63;
  background: #e4f6e9;
}

.completed-task-completed strong {
  color: #23613a;
}

.completed-task-blocked,
.completed-task-failed {
  border-color: #b84a62;
  background: #fbe6e3;
}

.completed-task-blocked strong,
.completed-task-failed strong {
  color: #8b2d24;
}

.completed-task-paused {
  border-color: #d69a2d;
  background: #fff3d8;
}

.completed-task-paused strong {
  color: #7a4c00;
}

:root[data-theme="dark"] .completed-task-completed {
  border-color: #4c9762;
  background: #12331d;
}

:root[data-theme="dark"] .completed-task-completed strong {
  color: #a9e5b9;
}

:root[data-theme="dark"] .completed-task-blocked,
:root[data-theme="dark"] .completed-task-failed {
  border-color: #a84f47;
  background: #3a1817;
}

:root[data-theme="dark"] .completed-task-blocked strong,
:root[data-theme="dark"] .completed-task-failed strong {
  color: #ffb4ac;
}

:root[data-theme="dark"] .completed-task-paused {
  border-color: #ad7a25;
  background: #3a2b12;
}

:root[data-theme="dark"] .completed-task-paused strong {
  color: #ffd27a;
}

.settings-panel {
  display: grid;
  width: min(760px, 96vw);
  max-height: min(820px, 92vh);
  overflow: auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.runtime-settings {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.runtime-settings header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.runtime-settings h3 {
  margin: 0;
  font-size: 15px;
}

#runtimeSettingsStatus {
  color: var(--muted);
  font-size: 12px;
}

#runtimeSettingsStatus.error {
  color: var(--danger);
}

.runtime-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.runtime-field-description {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.runtime-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.runtime-settings-actions button {
  flex: 1 1 180px;
}

.roadmap-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, 96vw);
  height: min(760px, 92vh);
  max-height: min(760px, 92vh);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.rescue-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(760px, 96vw);
  max-height: min(820px, 92vh);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.roadmap-header,
.rescue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.roadmap-header h2,
.rescue-header h2,
.roadmap-section h3 {
  margin: 0;
}

.roadmap-header p,
.rescue-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.rescue-form {
  display: grid;
  gap: 12px;
}

.rescue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.rescue-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rescue-form input,
.rescue-form select,
.rescue-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

.rescue-form textarea {
  min-height: 154px;
  resize: vertical;
}

.rescue-interval {
  display: grid;
  grid-template-columns: minmax(64px, 0.7fr) minmax(96px, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.rescue-interval-badge {
  border: 1px solid rgba(58, 123, 213, 0.45);
  border-radius: 999px;
  background: rgba(58, 123, 213, 0.14);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  padding: 5px 8px;
  white-space: nowrap;
}

.rescue-interval-badge[hidden] {
  display: none;
}

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

.rescue-form.is-editing {
  border-left: 3px solid #3a7bd5;
  padding-left: 10px;
}

.rescue-form.is-interval .rescue-interval {
  border-radius: 8px;
  outline: 2px solid rgba(58, 123, 213, 0.22);
  outline-offset: 3px;
}

.trigger-list-wrap {
  display: grid;
  min-height: 120px;
  overflow: hidden;
  gap: 8px;
}

.trigger-list-wrap h3 {
  margin: 0;
  font-size: 14px;
}

.trigger-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.trigger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-muted);
  padding: 9px 10px;
}

.trigger-active {
  border-left-color: #3ba66b;
}

.trigger-paused,
.trigger-completed {
  border-left-color: #9aa3b2;
}

.trigger-locked {
  border-left-color: #3a7bd5;
}

.trigger-error {
  border-left-color: #d65353;
}

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

.trigger-title-row strong,
.trigger-next,
.trigger-recurrence,
.trigger-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trigger-item span,
.trigger-empty {
  color: var(--muted);
  font-size: 12px;
}

.trigger-status,
.trigger-mode {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.trigger-mode-interval {
  border-color: rgba(58, 123, 213, 0.52);
  background: rgba(58, 123, 213, 0.14);
}

.trigger-mode-once {
  border-color: rgba(104, 116, 135, 0.42);
  background: rgba(104, 116, 135, 0.1);
}

.trigger-status-active {
  border-color: #3ba66b;
  background: rgba(59, 166, 107, 0.16);
}

.trigger-status-paused,
.trigger-status-completed {
  border-color: #9aa3b2;
  background: rgba(154, 163, 178, 0.14);
}

.trigger-status-locked {
  border-color: #3a7bd5;
  background: rgba(58, 123, 213, 0.16);
}

.trigger-status-error {
  border-color: #d65353;
  background: rgba(214, 83, 83, 0.16);
}

.trigger-recurrence {
  font-weight: 800;
}

.trigger-actions {
  grid-row: 1 / span 4;
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.trigger-actions button {
  white-space: nowrap;
}

.roadmap-body {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.roadmap-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.roadmap-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 3px 7px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.project-goal-roadmap {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  padding: 10px 12px;
}

.project-goal-tree-root {
  display: grid;
  gap: 8px;
}

.project-goal-root-summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
}

.project-goal-tree {
  display: grid;
  gap: 7px;
  margin-left: 14px;
}

.project-goal-tree-node {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 13px;
  line-height: 1.35;
}

details.project-goal-tree-node {
  display: grid;
  gap: 7px;
}

.project-goal-leaf {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.project-goal-tree-summary {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  cursor: pointer;
}

.project-goal-marker {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 3px;
  background: currentColor;
}

.project-goal-title {
  min-width: 0;
}

.project-goal-done {
  color: #25603c;
  border-color: #78b88d;
  background: #e4f4e9;
}

.project-goal-pending {
  color: #67512a;
  border-color: #bda66e;
  background: #f4edd9;
}

.roadmap-control-plan,
.roadmap-logbook-intro,
.roadmap-restpunkte,
.roadmap-level {
  display: grid;
  gap: 10px;
}

.roadmap-control-plan,
.roadmap-logbook-intro,
.roadmap-restpunkte {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  padding: 10px 12px;
}

.roadmap-control-plan {
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
}

.roadmap-plan-input {
  width: 100%;
  min-height: 120px;
  height: 100%;
  resize: vertical;
}

.roadmap-plan-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.roadmap-plan-footer small {
  color: var(--muted);
  font-size: 12px;
}

.roadmap-restpunkte h3,
.roadmap-restpunkte h4,
.roadmap-restpunkte p,
.roadmap-restpunkte ul {
  margin: 0;
}

.roadmap-restpunkte h3 {
  font-size: 15px;
}

.roadmap-restpunkte h4 {
  margin-top: 4px;
  font-size: 13px;
}

.roadmap-restpunkte ul {
  display: grid;
  gap: 5px;
  padding-left: 18px;
}

.roadmap-restpunkte li,
.roadmap-restpunkte p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.roadmap-restpunkte code {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  padding: 1px 4px;
}

.roadmap-logbook-intro h3,
.roadmap-logbook-intro p {
  margin: 0;
}

.roadmap-logbook-intro h3 {
  font-size: 14px;
}

.roadmap-logbook-intro p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.roadmap-level-plan {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.roadmap-section-roadmap .roadmap-node,
.roadmap-tree-list .roadmap-node {
  background: var(--panel);
}

.roadmap-folder {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  padding: 7px;
}

.roadmap-folder-phase {
  margin-left: 18px;
  background: var(--panel);
}

.roadmap-folder-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}

.roadmap-folder-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.roadmap-folder-hint {
  overflow: hidden;
  max-width: 260px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.roadmap-tree-list {
  margin-left: 18px;
}

.roadmap-level-machine {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.roadmap-level-header,
.roadmap-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}

.roadmap-level-header h3,
.roadmap-section-header h3 {
  margin: 0;
  font-size: 14px;
}

.roadmap-level-header span,
.roadmap-section-header span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roadmap-section {
  display: grid;
  gap: 7px;
}

.roadmap-section-compact .roadmap-node {
  grid-template-columns: minmax(0, 1fr) auto;
}

.roadmap-section-compact .roadmap-actions {
  grid-column: 1 / -1;
}

.roadmap-list {
  display: grid;
  gap: 5px;
}

.roadmap-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  align-items: center;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  background: var(--panel-muted);
}

.roadmap-node-main {
  display: grid;
  min-width: 0;
  gap: 3px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.roadmap-node-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.roadmap-node-note,
.roadmap-node small,
.roadmap-machine-status {
  overflow: hidden;
  color: inherit;
  opacity: 0.8;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.roadmap-node-note {
  white-space: normal;
  line-height: 1.35;
}

.roadmap-machine-status {
  max-width: 190px;
}

.roadmap-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.roadmap-action {
  min-height: 24px;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 800;
}

.roadmap-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--hub-column-header-height);
  border-bottom: 1px solid var(--line);
  margin: 0 -14px;
  padding: 0 14px;
}

.mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-weight: 800;
}

.brand h1,
.panel-header h2,
.toolbar h2 {
  margin: 0;
  font-size: 20px;
}

#topicTitle {
  color: var(--accent-strong);
}

.brand p,
.panel-header p,
.toolbar p,
.status {
  margin: 3px 0 0;
  color: var(--muted);
}

.token-actions,
.icon-actions,
.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-actions button {
  flex: 1;
}

.user-badge {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status {
  min-height: 20px;
  font-size: 13px;
  line-height: 1.35;
}

.status.error {
  color: var(--danger);
}

.explorer-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--panel-soft);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--hub-column-header-height);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

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

.tree-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

.tree-tabs button {
  height: 34px;
  min-height: 34px;
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 700;
}

.tree-tabs button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.tree {
  overflow: auto;
  min-height: 0;
  padding: 10px;
}

.tree details {
  margin: 2px 0;
}

.tree-project-card {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  padding: 6px;
  margin: 0 0 9px;
}

:root[data-theme="dark"] .tree-project-card {
  background: var(--panel);
}

.tree-project-card.is-active-project {
  border-color: var(--active-topic-border);
  background: var(--active-topic-bg);
  box-shadow: inset 3px 0 0 var(--active-topic-border);
}

.tree-project-card.is-active-project .tree-project-summary {
  color: var(--accent-strong);
}

.tree-project-card.is-active-project.is-flow-running {
  border-color: #d69a2d;
  background: color-mix(in srgb, #f6c15f 16%, var(--panel));
}

.tree-project-card.is-active-project.is-flow-blocked {
  border-color: #d07a70;
  background: color-mix(in srgb, #f1a29a 18%, var(--panel));
}

.tree-project-card.is-active-project.is-flow-alert {
  border-color: #c9443a;
  background: color-mix(in srgb, #ff6b5f 22%, var(--panel));
  box-shadow: inset 3px 0 0 #c9443a;
}

:root[data-theme="dark"] .tree-project-card.is-active-project.is-flow-running {
  background: color-mix(in srgb, #ad7a25 20%, var(--panel));
}

:root[data-theme="dark"] .tree-project-card.is-active-project.is-flow-blocked {
  background: color-mix(in srgb, #a84f47 22%, var(--panel));
}

:root[data-theme="dark"] .tree-project-card.is-active-project.is-flow-alert {
  background: color-mix(in srgb, #c9443a 28%, var(--panel));
}

.tree summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border-radius: 6px;
  padding: 4px 6px;
  list-style: none;
  cursor: pointer;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  content: "▸";
  width: 14px;
  color: var(--muted);
}

.tree details[open] > summary::before {
  content: "▾";
}

.tree-project-summary {
  min-height: 42px;
  padding-top: 8px;
  padding-bottom: 8px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
}

.tree-project-card.is-project-only > summary::before {
  display: none;
}

.tree-project-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

.tree-project-summary .tree-project-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-state-tiles {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.tree-project-summary .project-state-tiles {
  margin-left: auto;
}

.project-state-tile {
  display: inline-grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.project-state-tile:hover {
  color: var(--accent-strong);
  border-color: currentColor;
  transform: translateY(-1px);
}

.project-card-tiles {
  flex-wrap: wrap;
  max-width: min(520px, 48vw);
}

.milestone-tile {
  justify-content: flex-start;
  gap: 6px;
  width: auto;
  min-width: 118px;
  max-width: 220px;
  padding: 0 7px;
  overflow: hidden;
  cursor: default;
}

.milestone-tile:hover {
  filter: none;
  transform: none;
}

.milestone-tile::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

.milestone-done {
  color: #25603c;
  border-color: #78b88d;
  background: #e4f4e9;
}

.milestone-pending {
  color: #67512a;
  border-color: #bda66e;
  background: #f4edd9;
}

.project-goal-tiles {
  align-items: flex-start;
}

.project-goal-tile {
  min-width: 132px;
}

.project-goal-more {
  min-width: 38px;
  justify-content: center;
  color: var(--muted);
  border-color: var(--line-strong);
  background: var(--panel-muted);
}

.milestone-progress {
  flex: 0 0 38px;
  width: 38px;
  height: 6px;
  accent-color: currentColor;
}

.milestone-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-state-running {
  color: #62d98b;
  border-color: color-mix(in srgb, #62d98b 70%, var(--line-strong));
  background: var(--panel);
}

.project-state-waiting {
  color: #f2c66d;
  border-color: color-mix(in srgb, #f2c66d 72%, var(--line-strong));
  background: var(--panel);
}

.project-state-blocked {
  color: #ff938a;
  border-color: color-mix(in srgb, #ff938a 72%, var(--line-strong));
  background: var(--panel);
}

.project-state-stopped {
  color: #b7c0d8;
  border-color: color-mix(in srgb, #b7c0d8 72%, var(--line-strong));
  background: var(--panel);
}

.project-status-modal[hidden] {
  display: none !important;
}

.project-status-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: 88px 18px 18px;
  background: rgba(0, 0, 0, 0.28);
}

.project-status-panel {
  display: grid;
  gap: 10px;
  width: min(520px, calc(100vw - 36px));
  max-height: min(620px, calc(100vh - 110px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  padding: 12px;
}

.project-status-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.project-status-header h2 {
  margin: 0;
  font-size: 16px;
}

.project-status-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.project-status-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
}

.project-status-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  align-items: center;
  width: 100%;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
}

.project-status-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.project-status-item span {
  min-width: 0;
  grid-column: 1;
  color: var(--muted);
  font-size: 11px;
}

.project-status-item small {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.project-status-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px;
}

.tree-topic-row {
  display: flex;
  align-items: stretch;
  gap: 5px;
  min-width: 0;
  margin: 2px 0;
}

.tree-topic-select {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 6px 7px;
  text-align: left;
}

.tree-topic-select .tree-title {
  font-size: 12px;
  font-weight: 700;
}

.tree-topic-row.is-active-topic .tree-topic-select {
  background: var(--active-topic-bg);
  border: 1px solid var(--active-topic-border);
  color: var(--accent-strong);
  font-weight: 800;
  box-shadow: inset 3px 0 0 var(--active-topic-border);
}

.tree-topic-row.is-active-topic .tree-count {
  color: var(--accent-strong);
}

.tree summary:hover,
.tree button:hover,
.tree-topic-select:hover {
  background: var(--select);
}

.tree-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  color: var(--muted);
  font-size: 12px;
}

.task-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  max-width: 118px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 2px 6px;
  overflow: hidden;
  color: var(--muted);
  background: var(--panel-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-active,
.task-running {
  color: #7a4c00;
  border-color: #d69a2d;
  background: #fff3d8;
}

.task-ready {
  color: #0f536f;
  border-color: #6bb6cf;
  background: #e0f4fa;
}

.task-completed {
  color: #23613a;
  border-color: #72b386;
  background: #e4f6e9;
}

.task-waiting_for_user {
  color: #67512a;
  border-color: #bda66e;
  background: #f4edd9;
}

.task-blocked {
  color: #8b2d24;
  border-color: #d07a70;
  background: #fbe6e3;
}

.task-stopped {
  color: #7f1d1d;
  border-color: #ef4444;
  background: #fee2e2;
}

:root[data-theme="dark"] .task-active,
:root[data-theme="dark"] .task-running {
  color: #ffd27a;
  border-color: #ad7a25;
  background: #3a2b12;
}

:root[data-theme="dark"] .task-ready {
  color: #9fdff2;
  border-color: #3f8da8;
  background: #102f3b;
}

:root[data-theme="dark"] .task-completed {
  color: #a9e5b9;
  border-color: #4c9762;
  background: #12331d;
}

:root[data-theme="dark"] .task-waiting_for_user {
  color: #e2cc8e;
  border-color: #8f7740;
  background: #2f2818;
}

:root[data-theme="dark"] .task-blocked {
  color: #ffb4ac;
  border-color: #a84f47;
  background: #3a1817;
}

:root[data-theme="dark"] .task-stopped {
  color: #fecaca;
  border-color: #dc2626;
  background: #3b1518;
}

.tree-add {
  display: inline-grid;
  min-width: 68px;
  min-height: 26px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--accent);
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 700;
}

.tree-roadmap,
.tree-source,
.tree-archive,
.tree-close {
  display: inline-grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  padding: 0;
}

.tree-source.is-empty {
  opacity: 0.5;
}

.tree-roadmap:hover,
.tree-source:hover,
.tree-archive:hover,
.tree-close:hover {
  color: var(--accent-strong);
}

.tree-roadmap svg,
.tree-source svg,
.tree-archive svg,
.tree-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tree-children {
  margin: 5px 0 0 18px;
}

.topic-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px 30px;
  gap: 5px;
  margin: 5px 0 7px 18px;
}

.topic-create-form input {
  min-width: 0;
  padding: 7px 8px;
}

.topic-create-form button {
  min-width: 30px;
  height: 32px;
  padding: 0;
}

.workspace {
  --task-panel-visible-height: 164px;
  display: grid;
  grid-template-rows: auto auto auto minmax(80px, 1fr);
  border-left: 1px solid var(--line);
  height: var(--app-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--hub-column-header-height);
  border-bottom: 1px solid var(--line);
  background: var(--toolbar-bg);
  padding: 0 22px;
}

.topic-heading {
  min-width: 0;
  flex: 1 1 auto;
  max-width: min(990px, 100%);
}

.topic-heading.is-hidden {
  display: none;
}

.topic-heading p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#threadLabel {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

#threadLabel {
  display: flex;
  align-items: center;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-muted);
  color: #fff;
}

.chat-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.rescue-button {
  border-color: #2f7d66;
  background: #36b58d;
  color: #061b14;
  font-weight: 900;
}

.calendar-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: #4d6fb5;
  background: #7da2f7;
  color: #07152f;
  font-weight: 900;
}

.memory-button {
  border-color: #2f7d66;
  background: #36b58d;
  color: #061b14;
  font-weight: 900;
}

.rescue-button:hover {
  border-color: #22624f;
  background: #49c9a1;
  color: #04140f;
}

.calendar-button:hover {
  border-color: #3f5f9f;
  background: #93b4ff;
  color: #06122a;
}

.memory-button:hover {
  border-color: #22624f;
  background: #49c9a1;
  color: #04140f;
}

.rescue-button:disabled,
.calendar-button:disabled {
  opacity: 0.45;
}

.calendar-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: rgba(7, 21, 47, 0.16);
  padding: 0 6px;
  font-size: 12px;
  line-height: 1;
}

.calendar-count[hidden] {
  display: none;
}

.toolbar-counters {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(58px, auto));
  gap: 6px;
}

.toolbar-counter {
  display: grid;
  min-width: 58px;
  min-height: 38px;
  align-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-muted);
  color: var(--text);
  padding: 4px 8px;
}

.toolbar-counter strong,
.toolbar-counter small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-counter strong {
  font-size: 16px;
  line-height: 1;
}

.toolbar-counter small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

:root[data-theme="dark"] .rescue-button {
  border-color: #68d6b5;
  background: #11634d;
  color: #e7fff7;
}

:root[data-theme="dark"] .calendar-button {
  border-color: #9bb8ff;
  background: #274b93;
  color: #eef4ff;
}

:root[data-theme="dark"] .memory-button {
  border-color: #68d6b5;
  background: #11634d;
  color: #e7fff7;
}

.task-panel {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  height: var(--task-panel-visible-height);
  max-height: var(--task-panel-visible-height);
  min-height: var(--task-panel-visible-height);
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 10px 22px;
}

.task-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  align-items: center;
  gap: 6px 8px;
}

.task-panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.task-panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  grid-column: 1 / -1;
}

.completed-tasks-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  border-color: #4f8f63;
  background: #2f7d46;
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.closure-notices-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  border-color: #9b5d21;
  background: #b56a20;
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}
.closure-notices-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.closure-notices-button span { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.22); color: #fff; font-size: 12px; }
.closure-notices-button:hover { border-color: #7a4315; background: #8d4d16; color: #fff; }

.completed-tasks-button strong,
.completed-tasks-button span {
  min-width: 0;
}

.completed-tasks-button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.completed-tasks-button span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 12px;
}

.completed-tasks-button:hover {
  border-color: #23613a;
  background: #23613a;
  color: #fff;
}

:root[data-theme="dark"] .completed-tasks-button {
  border-color: #4c9762;
  background: #2f7d46;
  color: #fff;
}

:root[data-theme="dark"] .completed-tasks-button:hover {
  border-color: #a9e5b9;
  background: #23613a;
  color: #fff;
}

.task-panel-meta span,
.task-panel-empty {
  color: var(--muted);
  font-size: 12px;
}

.task-panel-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.task-panel-list > .completed-tasks-button {
  width: 100%;
}

.task-panel-latest {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-width: 0;
  border: 0;
  border-left: 3px solid #4f8f63;
  border-radius: 0;
  background: transparent;
  padding: 4px 6px 4px 9px;
  color: var(--text);
  text-align: left;
}

.task-panel-latest-blocked,
.task-panel-latest-failed {
  border-left-color: #b84a62;
}

.task-panel-latest span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-panel-latest small {
  color: var(--muted);
}

.task-panel-section {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.task-panel-section + .task-panel-section {
  padding-top: 2px;
  border-top: 1px solid var(--line);
}

.task-panel-section-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.task-panel-inline-empty {
  min-height: 32px;
  display: grid;
  align-items: center;
}

.task-panel-package {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.task-panel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.task-panel-row-with-action {
  grid-template-columns: minmax(0, 1fr) 58px;
}

.task-panel-current-row .task-panel-item,
.task-panel-current-row .task-panel-stop {
  min-height: 48px;
}

.task-panel-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  width: 100%;
  min-height: 44px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 6px 8px;
  text-align: left;
}

.task-panel-stop {
  display: inline-grid;
  place-items: center;
  width: 58px;
  min-width: 58px;
  min-height: 44px;
  border-color: #d43f3a;
  background: #b42318;
  color: #fff;
  padding: 6px;
  font-size: 12px;
  font-weight: 900;
}

.task-panel-stop:hover:not(:disabled) {
  border-color: #7f1d1d;
  background: #8f1d14;
  color: #fff;
}

.task-panel-stop:disabled {
  opacity: 0.42;
}

.task-panel-item:hover {
  border-color: var(--accent);
  background: var(--select);
  color: var(--text);
}

.task-panel-pipeline {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  width: 100%;
  min-height: 34px;
  border-color: var(--line);
  background: var(--panel-muted);
  color: var(--muted);
  padding: 5px 8px;
  text-align: left;
  cursor: pointer;
}

.task-panel-pipeline:hover {
  border-color: var(--accent);
  background: var(--select);
  color: var(--text);
}

.task-panel-pipeline strong {
  color: var(--accent-strong);
  font-size: 10px;
  text-transform: uppercase;
}

.task-panel-pipeline span,
.task-panel-pipeline small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-panel-pipeline span {
  font-size: 12px;
  font-style: italic;
}

.task-panel-pipeline small {
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
}

.task-panel-pipeline-blocked {
  border-color: #b84a62;
}

.task-panel-pipeline-waiting {
  border-color: #9a6a16;
}

.task-panel-pipeline-review {
  border-color: #5f7890;
}

.task-panel-pipeline-running {
  border-color: var(--accent);
}

.task-panel-status-line {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 5px 10px;
  text-align: left;
}

.task-panel-status-line:disabled {
  cursor: default;
  opacity: 1;
}

.task-panel-status-line strong {
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.task-panel-status-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.task-panel-status-running {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.task-panel-status-blocked {
  border-color: #ef4444;
  background: #fee2e2;
}

.task-panel-status-waiting,
.task-panel-status-review {
  border-color: #d6a22f;
  background: #fff4d5;
}

.task-panel-item strong {
  color: var(--accent-strong);
  font-size: 11px;
  text-transform: uppercase;
}

.task-panel-item span,
.task-panel-item small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-panel-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}

.task-panel-item .task-outcome-flags {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
}

.task-panel-item .task-outcome-flag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-muted);
  color: var(--muted);
  padding: 1px 4px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
}

.task-outcome-planned {
  border-color: #b7791f;
  color: #7a4a10;
}

.task-outcome-implemented-uncommitted {
  border-color: #c05621;
  color: #8a3a14;
}

.task-outcome-verified {
  border-color: #2f6f9f;
  color: #1f5c86;
}

.task-outcome-committed,
.task-outcome-visible-result-posted {
  border-color: #2f7d46;
  color: #23613a;
}

.task-outcome-blocked-by-dirty-worktree,
.task-outcome-blocked-no-visible-result {
  border-color: #b42318;
  color: #8f1d14;
}

.task-panel-running {
  border-color: var(--accent);
}

.task-panel-blocked {
  border-color: #b84a62;
}

.task-panel-review {
  border-color: #5f7890;
}

.task-panel-waiting {
  border-color: #9a6a16;
}

.task-panel-item.task-provisional {
  border-color: #c58f17;
  border-style: dashed;
  background: #fff8d9;
}

.task-panel-item.task-provisional strong {
  color: #8a5a00;
}

:root[data-theme="dark"] .task-panel-item.task-provisional {
  border-color: #d6a83a;
  background: #3a2d12;
}

:root[data-theme="dark"] .task-panel-item.task-provisional strong {
  color: #ffd166;
}

.messages {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 18px 22px;
}

.scroll-top {
  position: absolute;
  left: 50%;
  top: calc(var(--hub-column-header-height) + var(--task-panel-visible-height, 164px) + var(--composer-height, 170px) + 18px);
  transform: translateX(-50%);
  z-index: 5;
  min-height: 34px;
  border-color: var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px var(--shadow-soft);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
}

.scroll-top.has-unread {
  box-shadow: 0 0 0 3px var(--shadow-soft), 0 10px 22px var(--shadow-soft);
}

.scroll-top[hidden] {
  display: none;
}

.scroll-top:hover {
  background: var(--accent-strong);
  color: #fff;
}

.empty {
  color: var(--muted);
  padding: 24px 0;
}

.thread-overview {
  display: grid;
  gap: 12px;
  padding: 10px 0 18px;
}

.thread-overview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.thread-overview-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.thread-overview-header span {
  color: var(--muted);
  font-size: 12px;
}

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

.thread-overview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
}

.thread-overview-item:hover {
  border-color: var(--accent);
  background: var(--active-topic-bg);
}

.thread-overview-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-overview-item > span:not(.thread-overview-status) {
  color: var(--muted);
  font-size: 12px;
}

.thread-overview-status {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.chat-package {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--panel-soft);
  margin: 0 0 12px clamp(12px, 2.2vw, 28px);
  overflow: clip;
  width: calc(100% - clamp(12px, 2.2vw, 28px));
}

.chat-package.is-current {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.chat-package-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.chat-package-summary::-webkit-details-marker {
  display: none;
}

.chat-package-arrow {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.16s ease;
}

.chat-package[open] .chat-package-arrow {
  transform: rotate(90deg);
}

.chat-package-summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-package-count,
.chat-package-current {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chat-package-current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.chat-package-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.chat-package-body .message {
  margin-bottom: 0;
}

.chat-package-ungrouped {
  padding: 12px;
}

.chat-package-ungrouped-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.package-composer {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.package-composer textarea {
  min-height: 86px;
  resize: vertical;
}

.package-composer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.package-composer-actions select {
  width: min(180px, 100%);
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 12px;
  padding: 14px;
}

.message.is-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--shadow-soft);
}

.message.is-paused {
  opacity: 0.62;
}

.message.is-paused::before {
  content: "Pausiert";
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--code);
  color: var(--muted);
  font-size: 12px;
}

.message.is-running {
  border-color: var(--accent);
}

.message.is-memory {
  border-color: var(--accent);
  background: var(--panel-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.message.is-memory h3 {
  color: var(--accent-strong);
}

.message.from-codex,
.message.from-deepseek,
.message.from-task-memory,
.message.from-engine-worker,
.message.from-health-watcher,
.message.from-monitor-agent {
  background: #fff;
}

:root[data-theme="dark"] .message.from-codex,
:root[data-theme="dark"] .message.from-deepseek,
:root[data-theme="dark"] .message.from-task-memory,
:root[data-theme="dark"] .message.from-engine-worker,
:root[data-theme="dark"] .message.from-health-watcher,
:root[data-theme="dark"] .message.from-monitor-agent {
  background: var(--panel);
}

.message.from-peter {
  border-color: var(--accent);
}

.message.from-peter pre {
  max-height: none;
  overflow: visible;
}

.memory-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.memory-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel-muted);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 800;
}

.memory-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.memory-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 7px 8px;
}

.memory-item strong {
  font-size: 12px;
  text-transform: uppercase;
}

.memory-item span,
.memory-item small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}

.memory-ausstehend strong {
  color: #67512a;
}

.memory-running strong {
  color: #7a4c00;
}

.memory-wartet strong {
  color: #73520d;
}

.memory-erledigt strong {
  color: #23613a;
}

.memory-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 8px;
  font-size: 13px;
}

.message.is-running::after {
  content: "";
  display: block;
  width: 34%;
  min-width: 120px;
  height: 2px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.75;
}

.message header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.route-editor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.route-editor strong {
  white-space: nowrap;
}

.route-recipient {
  width: auto;
  min-width: 104px;
  max-width: 190px;
  padding: 4px 24px 4px 7px;
  border-color: var(--line-strong);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.message-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

.message-actions button {
  padding: 5px 8px;
  font-size: 12px;
}

.message-actions .icon-only {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
}

.message-actions .icon-only svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message strong {
  color: var(--accent-strong);
}

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

.message h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.message pre {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 6px;
  background: var(--code);
  padding: 10px;
  margin: 8px 0 0;
}

.attachments {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attachments.is-empty {
  display: none;
}

.attachment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 8px;
}

.attachment img {
  display: block;
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--code);
  cursor: zoom-in;
}

.attachment a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.attachment-name {
  min-width: 0;
  font-weight: 700;
}

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

.attachment-remove {
  width: 32px;
  height: 32px;
  padding: 0;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
}

.image-modal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  width: min(1120px, 96vw);
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.image-modal-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-modal-panel img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 72px);
  object-fit: contain;
  margin: 0 auto;
  background: var(--code);
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 39px;
  min-height: 39px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent);
  padding: 8px;
  cursor: pointer;
}

.file-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  display: none;
}

.ocr-toggle {
  min-width: 48px;
  min-height: 39px;
  padding: 0 10px;
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.ocr-toggle.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.composer {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  max-height: min(42vh, 360px);
  overflow: auto;
  padding: 14px 22px 18px;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.composer-scope {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.composer.is-thread-composer .composer-scope {
  color: var(--accent);
}

.composer.is-project-composer .composer-scope {
  color: var(--warning);
}

.composer[hidden] {
  display: none !important;
}

.composer.is-disabled {
  opacity: 0.94;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
}

.rescue-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 39px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.rescue-toggle input {
  margin: 0;
}

.composer.is-admin-rescue {
  border-top-color: #b42318;
  box-shadow: inset 0 2px 0 #d92d20;
}

.composer.is-admin-rescue .rescue-toggle {
  border-color: #b42318;
  background: #d92d20;
  color: #fff;
}

.package-composer.is-admin-rescue {
  border-color: #b42318;
  box-shadow: inset 0 2px 0 #d92d20;
}

.package-composer.is-admin-rescue .rescue-toggle {
  border-color: #b42318;
  background: #d92d20;
  color: #fff;
}

select.is-system-recipient,
.system-recipient-option {
  color: #b42318;
  font-weight: 800;
}

.inline-select {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.inline-select span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-switch {
  gap: 8px;
}

.theme-switch button {
  width: 100%;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px 190px minmax(250px, 320px) minmax(0, 1fr);
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .composer-actions {
    grid-template-columns: auto auto minmax(110px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr) auto;
  }
}

@media (max-width: 820px) {
  html,
  body {
    height: auto;
    min-height: var(--app-height, 100dvh);
    overflow-y: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(140px, 24vh) minmax(160px, 30vh) minmax(420px, auto);
    height: auto;
    min-height: var(--app-height, 100dvh);
    overflow: visible;
  }

  .identity-panel,
  .pipeline-panel,
  .explorer-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    --task-panel-visible-height: 232px;
    border-left: none;
    height: auto;
    min-height: min(680px, var(--app-height, 100dvh));
    overflow: visible;
    grid-template-rows: auto auto auto minmax(160px, 1fr);
  }

  .chat-controls {
    justify-content: flex-start;
  }

  .task-panel {
    grid-template-columns: 1fr;
  }

  .messages {
    min-height: 160px;
    max-height: min(44vh, 380px);
  }

  .chat-package-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .chat-package {
    margin-left: 8px;
    width: calc(100% - 8px);
  }

  .chat-package-current {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .package-composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .package-composer-actions select {
    width: 100%;
  }

  .composer {
    max-height: none;
  }

  .composer-actions {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .inline-select {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .file-button {
    justify-content: center;
  }
}

@media (max-height: 620px) {
  .task-panel {
    --task-panel-visible-height: 128px;
  }

  .messages {
    padding: 12px 18px;
  }

  .composer {
    max-height: min(54vh, 320px);
  }
}
