/* Farben nach Rolle. Hell und dunkel folgen der Systemeinstellung; es gibt keinen eigenen Schalter. */
:root {
  --bg: #ffffff;
  --bg-side: #f4f5f7;
  --bg-raised: #ffffff;
  --bg-sunken: #eef0f3;
  --bg-selected: #e2e6ec;
  --bg-user: #e6edf9;
  --border: #d5dae1;
  --text: #1b1f24;
  --text-2: #4c5663;
  --accent: #1a62d6;
  --accent-text: #ffffff;
  --ok: #17713f;
  --warn: #8a5a00;
  --warn-bg: #fdf4dc;
  --warn-border: #d9b65c;
  --err: #b3261e;
  --claude: #e8a06b;
  --codex: #8ad6c6;
  --grok: #c3b0f5;
  --local: #b9d88a;
  --badge-text: #17120a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1f24;
    --bg-side: #15181c;
    --bg-raised: #232830;
    --bg-sunken: #15181c;
    --bg-selected: #2a313b;
    --bg-user: #2a3140;
    --border: #353c47;
    --text: #e8ebef;
    --text-2: #a8b1bd;
    --accent: #8fbcff;
    --accent-text: #0b1626;
    --ok: #6fd39a;
    --warn: #f0c36a;
    --warn-bg: #24211a;
    --warn-border: #6b5524;
    --err: #ff9a91;
  }
}
@media (prefers-contrast: more) {
  :root { --border: currentColor; --text-2: var(--text); }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.1rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; margin-top: 8px; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.87rem; }
.muted { color: var(--text-2); }
.small { font-size: 0.87rem; }
.error { color: var(--err); font-size: 0.9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-raised); cursor: pointer;
}
button:hover { background: var(--bg-selected); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.quiet { border-color: transparent; background: transparent; color: var(--text-2); padding: 0 8px; }
button.quiet:hover { background: var(--bg-selected); color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-sunken);
}
textarea { resize: vertical; }
label { display: block; font-size: 0.9rem; font-weight: 500; margin: 12px 0 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--bg-side); }
.card { width: min(360px, 100%); padding: 24px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); }
.card button { width: 100%; margin-top: 18px; }
.card .error { margin-top: 12px; }

/* Aufbau */
.app {
  --sidebar-width: var(--layout-sidebar-width, 300px);
  --terminal-width: var(--layout-terminal-width, 46%);
  position: relative; height: 100%; display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}
.pane-divider {
  display: none; position: absolute; z-index: 3; inset-block: 0;
  width: 20px; transform: translateX(-50%); touch-action: none; cursor: col-resize;
}
.pane-divider::before { content: ''; position: absolute; inset-block: 0; left: 50%; width: 1px; background: var(--border); }
.pane-divider::after { content: ''; position: absolute; top: calc(50% - 18px); left: calc(50% - 1px); width: 3px; height: 36px; border-radius: 2px; background: var(--text-2); }
.pane-divider:hover::before, .pane-divider:focus-visible::before, .pane-divider[data-dragging]::before { width: 2px; background: var(--accent); }
.pane-divider:hover::after, .pane-divider:focus-visible::after, .pane-divider[data-dragging]::after { background: var(--accent); }
.pane-divider:focus-visible { outline-offset: -3px; }
.sidebar-divider { left: var(--sidebar-width); }
.terminal-divider { left: calc(100% - var(--terminal-width)); }
.app.is-resizing, .app.is-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (pointer: coarse) { .pane-divider { width: 28px; } }
@media (min-width: 721px) { .app:not(.sidebar-minimized) > .sidebar-divider { display: block; } }
@media (min-width: 1201px) { .app.with-term > .terminal-divider { display: block; } }
.sidebar, .sidebar-rail { background: var(--bg-side); border-right: 1px solid var(--border); }
.sidebar { display: flex; flex-direction: column; gap: 10px; padding: 14px 10px; min-height: 0; min-width: 0; }
.sidebar-rail { display: none; padding: 14px 6px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding-inline: 6px; }
.sidebar-icon { display: block; position: relative; width: 16px; height: 13px; border: 1px solid currentColor; border-radius: 3px; }
.sidebar-icon::after { position: absolute; content: ''; inset: 0 auto 0 4px; border-left: 1px solid currentColor; }
.icon-button { display: grid; place-items: center; min-width: 36px; }
@media (min-width: 721px) {
  .app.sidebar-minimized { --sidebar-width: 50px; }
  .app.sidebar-minimized > .sidebar-rail { display: block; }
  .app.sidebar-minimized > .sidebar { display: none; }
}
.sidebar-head { gap: 6px; }
.sidebar-head .brand { flex: 1; }
#open-roadmaps { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
#open-roadmaps[aria-current="page"] { background: var(--bg-selected); color: var(--text); }
.brand { font-size: 1.05rem; font-weight: 600; }
.wide { width: 100%; font-weight: 500; }
.sidebar-tools { display: flex; gap: 6px; align-items: stretch; }
.sidebar-tools select { flex: 1; min-width: 0; font-size: 0.9rem; }
.sidebar-tools button { font-size: 0.9rem; }
.sidebar-tools button[aria-pressed="true"] { background: var(--bg-selected); font-weight: 600; }
.project-filter label { margin: 0 0 4px; padding-inline: 6px; color: var(--text-2); }
.project-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.project-list > * { flex-shrink: 0; }
.sidebar-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.9rem; }
.sidebar-foot .muted { flex: 1; padding-left: 6px; }
.sidebar-foot .error { flex-basis: 100%; margin: 0; padding: 0 6px; }

.project-head, .sub-row { display: flex; align-items: center; gap: 3px; padding-inline: 2px; }
.project-name { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 600; }
.project-toggle { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; }
.project-head button { min-height: 36px; padding-inline: 6px; }
.project-head .new-chat { font-size: 0.87rem; }
.project-title, .sub-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-title-static { padding: 7px 6px; }
.project-chevron { flex: none; width: 7px; height: 7px; margin-inline: 2px; border: solid var(--text-2); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); }
.project-toggle[aria-expanded="true"] .project-chevron { transform: translateY(-2px) rotate(45deg); }
.sidebar-action { flex: none; font-size: 1rem; }
.project-types { display: flex; flex-wrap: wrap; gap: 4px; padding: 1px 8px 4px; }
.type-label {
  display: inline-block; padding: 2px 6px; border-radius: 5px;
  background: var(--bg-sunken); color: var(--text-2); font-size: 0.87rem;
}
@media (prefers-color-scheme: dark) {
  .type-label { background: var(--bg-raised); }
}
.sub {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left; min-height: 36px;
  padding: 4px 8px 4px 14px; border: 0; background: transparent; border-radius: 8px;
}
.sub-row:has([aria-current="page"]) { background: var(--bg-selected); border-radius: 8px; font-weight: 500; }
.sub-meta { flex: 1; min-width: 0; }
.sub-title { display: block; font-size: 0.9rem; }
.sub-work-area { display: block; color: var(--text-2); font-size: 0.87rem; }
.no-subs { padding: 2px 14px; font-size: 0.87rem; color: var(--text-2); }
.sidebar-move { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
#sidebar-action-hint, #sidebar-action-error, #s-project { margin-top: 8px; }

.badge { flex: none; min-width: 24px; height: 20px; padding: 0 4px; border-radius: 6px; font-size: 0.73rem; font-weight: 600; color: var(--badge-text); display: inline-flex; align-items: center; justify-content: center; }
.badge.claude { background: var(--claude); }
.badge.codex { background: var(--codex); }
.badge.grok { background: var(--grok); }
.badge.local { background: var(--local); }

/* Zustand immer mit Wort, nie nur mit Farbe. */
.status { flex: none; font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }
.status.running { color: var(--ok); }
.status.waiting { color: var(--warn); border: 1px solid var(--warn-border); border-radius: 999px; padding: 0 7px; font-weight: 500; }
.status.error { color: var(--err); }

/* Chat */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.empty { margin: auto; text-align: center; padding: 24px; color: var(--text-2); }
.empty h1 { color: var(--text); margin-bottom: 6px; }
.chat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.chat-title { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.chat-work-area { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
.chat-work-area button { min-height: 28px; font-size: 0.87rem; }
.chat-head select { width: auto; }
.back { display: none; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.messages > * { width: min(760px, 100%); margin-inline: auto; flex-shrink: 0; } /* Lange Verläufe scrollen; nichts darin wird zusammengedrückt. */
.msg { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Die eigene Nachricht schließt rechts mit der Textspalte ab, nicht mit dem Fensterrand. */
.msg.user { width: auto; max-width: min(600px, 85%); margin-inline: auto max(0px, calc((100% - 760px) / 2)); align-self: flex-end; background: var(--bg-user); padding: 9px 13px; border-radius: 16px 16px 4px 16px; }
.msg.user + .msg.agent, .steps + .msg.agent { margin-top: 0; }
.message-attachments, .draft-attachments { list-style: none; padding: 0; }
.message-attachments { display: grid; gap: 6px; margin: 0; white-space: normal; }
.msg-text + .message-attachments { margin-top: 8px; }
.attachment-link { display: block; min-height: 36px; padding: 5px 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.attachment-link:hover, .attachment-link:active { background: var(--bg-selected); }
.attachment-link .attachment-name { text-decoration: underline; text-underline-offset: 0.13em; }
.attachment-preview {
  display: block; width: min(16rem, 100%); height: min(10rem, 24vh); object-fit: contain;
  object-position: left center; margin-bottom: 5px; border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
  .attachment-preview[data-media-type="image/gif"] { display: none; }
}
.attachment-name { overflow-wrap: anywhere; }
.attachment-meta { display: block; font-size: 0.87rem; color: var(--text-2); }
.md { white-space: normal; display: flex; flex-direction: column; gap: 8px; }
.md p { white-space: pre-wrap; }
.md h3 { margin: 6px 0 0; font-size: 1rem; }
.md h3.md-h1, .md h3.md-h2 { font-size: 1.1rem; }
.md ul, .md ol { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 3px; }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--bg-sunken); border: 1px solid var(--border); }
.md pre { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-sunken); border: 1px solid var(--border); overflow-x: auto; }
.md pre code { padding: 0; border: 0; background: transparent; white-space: pre; }
.md a { color: var(--accent); }
.notice { font-size: 0.9rem; color: var(--text-2); }
.notice.error { color: var(--err); }

.steps { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.steps summary { padding: 8px 12px; cursor: pointer; font-size: 0.9rem; font-weight: 500; background: var(--bg-sunken); }
.step { display: flex; align-items: baseline; gap: 10px; padding: 7px 12px; border-top: 1px solid var(--border); font-size: 0.9rem; }
.step-state { flex: none; width: 7.5em; font-size: 0.8rem; color: var(--text-2); }
.step-state.done { color: var(--ok); }
.step-state.failed { color: var(--err); }
.step-title { flex: none; color: var(--text-2); }
.step-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-diff { flex: none; font-size: 0.8rem; }
.step-diff .add { color: var(--ok); }
.step-diff .del { color: var(--err); }

.approval { border: 1px solid var(--warn-border); background: var(--warn-bg); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.approval-title { font-weight: 600; color: var(--warn); }
.approval code { display: block; padding: 9px 11px; border-radius: 8px; background: var(--bg-sunken); overflow: auto; max-height: 50vh; white-space: pre; }
.approval.resolved code { max-height: 8em; overflow: auto; white-space: pre; }
.chat-head select { max-width: 11em; }
.chat-head #chat-approvals { max-width: none; }
/* Eingeschaltet arbeitet der Agent ohne Rückfrage; das soll man dem Schalter ansehen. */
#chat-approvals.auto { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.approval.resolved { border-color: var(--border); background: transparent; }
.approval.resolved { padding: 8px 12px; gap: 6px; }
.approval.resolved .approval-title { color: var(--text-2); font-weight: 500; font-size: 0.9rem; }
.approval.resolved code { padding: 0; background: transparent; font-size: 0.8rem; color: var(--text-2); }

/* Solange der Agent arbeitet, steht das über dem Eingabefeld: mit Wort und Zeit, nicht nur als Animation. */
.working { width: min(760px, calc(100% - 40px)); margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text); }
.working-dots { display: inline-flex; gap: 4px; }
.working-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); opacity: 0.35; }
@media (prefers-reduced-motion: no-preference) {
  .working-dots span { animation: working-pulse 1.2s ease-in-out infinite; }
  .working-dots span:nth-child(2) { animation-delay: 0.2s; }
  .working-dots span:nth-child(3) { animation-delay: 0.4s; }
}
@keyframes working-pulse { 0%, 80%, 100% { opacity: 0.35; } 40% { opacity: 1; } }
#working-time { font-variant-numeric: tabular-nums; }

.composer { padding: 0 20px 20px; }
.composer > :where(:not(.visually-hidden)) { width: min(760px, 100%); margin-inline: auto; display: block; }
.composer textarea { border-radius: 14px; background: var(--bg-raised); min-height: 60px; }
.composer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 8px; }
.composer-row .muted { flex: 1 1 8rem; }
#composer-send { margin-inline-start: auto; }
#composer-attach:active { background: var(--bg-selected); }
.composer-feedback:not(:empty) { margin-top: 6px; overflow-wrap: anywhere; }
.composer .draft-attachments {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin-block: 4px 0;
  padding: 4px; max-height: min(26vh, 12rem); overflow-y: auto;
}
.draft-attachment {
  display: flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-raised);
}
.draft-attachment-info { min-width: 0; }
.draft-attachment .attachment-remove { flex: none; min-width: 36px; min-height: 36px; padding: 0; font-size: 1.15rem; }
.attachment-remove:active { background: var(--bg-selected); }

/* Sprache ergänzt den Entwurf; Aufnahme und Wiedergabe bleiben sichtbar und abbrechbar. */
.voice-controls { padding-top: 10px; }
.voice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.voice-auto { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; margin: 0; font-size: 0.9rem; cursor: pointer; }
.voice-auto input { width: 20px; min-height: 20px; height: 20px; padding: 0; accent-color: var(--accent); }
.voice-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
#voice-record[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.voice-status { color: var(--text-2); margin-top: 5px; overflow-wrap: anywhere; }
.voice-status:empty { display: none; }
.voice-status.error { color: var(--err); }
#voice-player { display: block; width: min(100%, 380px); height: 40px; margin-top: 8px; }
.voice-message-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.voice-message-actions button { font-size: 0.87rem; }

/* Dialoge */
dialog { width: min(520px, calc(100% - 24px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--bg); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog form, .dialog-body { padding: 22px; }
.dialog-body form { padding: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.project-type-field { min-inline-size: 0; margin: 12px 0; padding: 0; border: 0; }
.project-type-field legend { padding: 0; margin-bottom: 4px; font-size: 0.9rem; font-weight: 500; }
.type-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(126px, 100%), 1fr)); gap: 2px 8px; }
.type-options label { display: flex; align-items: center; gap: 7px; margin: 0; min-height: 30px; padding: 3px; font-weight: 400; }
.type-options input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.conn-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.conn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.9rem; }
.conn-name { flex: 1 1 160px; min-width: 0; }
.conn button { min-height: 30px; }
.conn-result { flex-basis: 100%; overflow-wrap: anywhere; }
.conn-result button { margin-top: 6px; }

/* Ordnerauswahl im Projektdialog: die Wahl steht im Feld darüber, die Liste führt dorthin. */
.hint { margin-top: 5px; }
.browser { margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.browser-bar { display: flex; align-items: center; gap: 6px; padding: 4px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.browser-where { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--text-2); font-size: 0.8rem; padding: 0 4px; }
.browser-bar button { flex: none; min-height: 32px; }
.browser-new { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.browser-new input { flex: 1 1 200px; min-width: 0; }
.browser-new button { flex: none; }
.browser-list { list-style: none; margin: 0; padding: 4px; max-height: 220px; overflow-y: auto; }
.browser-list button {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; min-height: 36px;
  padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
}
.browser-list button:hover { background: var(--bg-selected); }
.browser-list .folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-list .chevron { flex: none; color: var(--text-2); }
.browser-msg { padding: 0 12px 8px; }
.browser-msg:empty { display: none; }
.browser-msg.error { color: var(--err); }

/* Schmale Fenster: Liste und Chat nacheinander statt nebeneinander, gleiche Funktionen. */
/* Terminal: rechts neben dem Chat; auf schmaleren Bildschirmen an seiner Stelle. */
.app.with-term { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--terminal-width); }
.term { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; border-left: 1px solid var(--border); background: var(--bg-side); }
.term-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.term-tabs { display: inline-flex; gap: 2px; padding: 2px; margin-right: auto; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-sunken); }
.term-tab { min-height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); }
.term-tab:hover { background: var(--bg-selected); color: var(--text); }
.term-tab[aria-selected="true"] { background: var(--bg-raised); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.term-msg { margin: 10px 14px 0; color: var(--text-2); }
.term-msg.error { color: var(--err); }
/* Die Terminalfläche bleibt in beiden Erscheinungsbildern dunkel: Die Farben von Programmen im
   Terminal (ls, git, Compiler) sind auf dunklen Grund abgestimmt. */
.term-body { position: relative; flex: 1; min-height: 160px; margin: 10px 14px 0; border-radius: 12px; background: #15181c; overflow: hidden; }
.term-view { position: absolute; inset: 8px 4px 8px 10px; }
.term-hint { padding: 8px 14px 12px; }
#chat-terminal[aria-expanded="true"] { background: var(--bg-selected); }
/* Roadmap: belegt denselben Platz wie der Chat. Zustände immer mit Zeichen und Wort. */
.roadmap { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.rm-head select { width: auto; }
.rm-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.rm-column { width: min(820px, 100%); margin-inline: auto; display: flex; flex-direction: column; gap: 16px; }
.rm-error { width: min(820px, calc(100% - 40px)); margin: 12px auto 0; }
.rm-summary { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; }
.rm-summary-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rm-percent { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rm-when { margin-left: auto; }
.rm-bar { display: block; height: 8px; border-radius: 999px; background: var(--bg-selected); overflow: hidden; }
.rm-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.rm-bar-fill.done { background: var(--ok); }
.rm-bar-empty { background: transparent; border: 1px dashed var(--border); }
.rm-label { font-size: 0.87rem; font-weight: 600; color: var(--text-2); }
.rm-label-row { display: flex; align-items: center; gap: 8px; min-height: 32px; margin-top: 6px; }
.rm-small { min-height: 32px; padding: 0 12px; font-size: 0.87rem; }
.rm-vision, .rm-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.rm-notes { padding: 10px 12px; border-radius: 10px; background: var(--bg-sunken); }
.rm-ok { color: var(--ok); }

.rm-stage { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.rm-stage > summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px; cursor: pointer; background: var(--bg-side); list-style: none; }
.rm-stage > summary::-webkit-details-marker { display: none; }
.rm-tri { width: 0; height: 0; border-left: 6px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; flex: none; }
.rm-stage[open] .rm-tri { transform: rotate(90deg); }
.rm-stage-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rm-stage-status { color: var(--text-2); white-space: nowrap; }
.rm-stage-status.done { color: var(--ok); }
.rm-stage-body { padding: 8px 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.rm-stage-body > .rm-label { margin-top: 10px; }
.rm-stage-actions, .rm-version-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.rm-version-actions { align-items: center; }
.rm-version-actions .rm-add { flex: 1 1 320px; }

.rm-items { list-style: none; margin: 0; padding: 0; }
.rm-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; border-top: 1px solid var(--bg-selected); flex-wrap: wrap; }
.rm-item.editing { display: block; }
.rm-status { width: auto; flex: none; min-height: 32px; padding: 0 10px; border-radius: 999px; background: var(--bg-raised); font-size: 0.87rem; color: var(--text-2); }
.rm-status.done { color: var(--ok); }
.rm-status:disabled { opacity: 1; }
.rm-item-title { flex: 1 1 200px; min-width: 0; text-align: left; border: 0; background: transparent; padding: 4px 6px; min-height: 32px; border-radius: 8px; overflow-wrap: anywhere; }
button.rm-item-title:hover { background: var(--bg-selected); }
.rm-item-title.discarded { color: var(--text-2); text-decoration: line-through; }
.rm-agent { min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 0.8rem; color: var(--text-2); }
.rm-agent.busy { color: var(--ok); }

.rm-add { display: flex; gap: 8px; padding-top: 8px; }
.rm-add input { flex: 1; }
.rm-edit { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.rm-edit-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.rm-first { width: min(560px, 100%); margin: 0 auto; }
.rm-first h2 { margin-bottom: 6px; }

.rm-cards { width: min(1000px, 100%); margin-inline: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.rm-card { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 16px; min-height: 0; text-align: left; border-radius: 14px; background: var(--bg); }
.rm-card.closed { background: var(--bg-side); }
.rm-card-top { display: flex; align-items: baseline; gap: 8px; }
.rm-card-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rm-card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.rm-card-cta { color: var(--accent); font-weight: 500; font-size: 0.9rem; }
.rm-num { font-variant-numeric: tabular-nums; }
.rm-entry-icon { flex: none; color: var(--accent); }

#dlg-handover { width: min(600px, calc(100% - 24px)); }
.h-targets-box { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; }
.h-targets-box legend { font-size: 0.9rem; font-weight: 500; padding: 0; margin-bottom: 5px; }
.h-targets { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.h-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); font-weight: 400; cursor: pointer; }
.h-choice:has(input:checked) { border-color: var(--accent); background: var(--bg-user); }
.h-choice input { width: auto; min-height: 0; margin: 0; }
.h-choice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 1200px) {
  .app.with-term { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .app.with-term .chat { display: none; }
  .term { border-left: 0; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  #hide-sidebar { display: none; }
  .app.show-chat .sidebar { display: none; }
  .app:not(.show-chat) .chat { display: none; }
  .back { display: inline-block; }
  .sub, button, .project-head button, .conn button, .browser-bar button, .browser-list button { min-height: 44px; }
  .sidebar .icon-button { min-width: 44px; }
  .project-filter select, .chat-head select, .type-options label, .chat-work-area button { min-height: 44px; }
  .chat-head, .messages { padding-inline: 14px; }
  .composer { padding: 0 14px 14px; }
  .composer-row .muted { flex-basis: 100%; order: 1; }
  .draft-attachment .attachment-remove { min-width: 44px; min-height: 44px; }
  .attachment-link { min-height: 44px; }
  .voice-auto { min-height: 44px; }
  .working { width: calc(100% - 28px); }
  /* Der Pfad bekommt eine eigene Zeile, damit er nicht mitten im Wort umbricht. */
  .browser-bar { flex-wrap: wrap; }
  .browser-where { order: 3; flex-basis: 100%; padding: 0 8px 6px; }
  .browser-bar #p-mkdir { margin-left: auto; }
  .browser-new input { flex-basis: 100%; }
  .app.with-term { grid-template-columns: minmax(0, 1fr); }
  .app.with-term .sidebar { display: none; }
  .term-body { margin-inline: 8px; }
  .term-tab { min-height: 44px; }
  .rm-body { padding: 14px; }
  .rm-status, .rm-small, .rm-item-title, .rm-agent { min-height: 44px; }
  .rm-when { margin-left: 0; flex-basis: 100%; }
  .rm-add { flex-wrap: wrap; }
  .rm-add input { flex-basis: 100%; }
}
