/* Code-Editor (/code/<id>) – eigene Seite auf den Hub-Tokens; Knöpfe/Felder/Modal/Toasts aus hub.css */

html:has(body.code-page),
body.code-page { height: 100%; overflow: hidden; }
body.code-page,
body.code-page .monaco-editor,
body.code-page .monaco-editor *,
body.code-page .monaco-diff-editor * { user-select: text; -webkit-user-select: text; }

.ed { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg); }

/* ---------- Kopfzeile ---------- */
.ed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 52px; padding: 7px 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.ed-brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.ed-kicker { color: var(--muted); font-size: 13px; }
.ed-title { max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 650; text-decoration: none; }
.ed-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.ed-by { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ed-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.ed-controls .segmented { padding: 3px; border-radius: 9px; }
.ed-controls .segmented button { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 13px; }
.ed-controls .segmented button.is-active { background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ed-label { color: var(--muted); font-size: 13px; }
.ed-hidden[aria-pressed="true"] { background: var(--bg-2); border-color: var(--red); color: var(--text); }
.ed-controls .btn-sm svg { width: 15px; height: 15px; }

/* ---------- Hinweiszeile ---------- */
.ed-note { display: flex; align-items: center; gap: 12px; padding: 7px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 14px; }
.ed-note[hidden] { display: none; }
.ed-note.is-error { color: #ff8a84; }
.ed-note .btn { margin-left: auto; }

/* ---------- Körper ---------- */
.ed-body { display: flex; flex: 1; min-height: 0; }
.ed-body[hidden] { display: none; }
.ed-side { display: flex; flex-direction: column; width: 272px; flex: none; min-height: 0; overflow: auto; border-right: 1px solid var(--line); background: var(--bg-2); }
.ed-side[hidden] { display: none; }
.ed-sec { border-bottom: 1px solid var(--line); padding: 8px 0 10px; }
.ed-sec:last-child { border-bottom: 0; }
.ed-sec-head { display: flex; align-items: center; gap: 6px; padding: 2px 8px 6px 12px; color: var(--muted); font-size: 12px; font-weight: 650; }
.ed-sec-head span { flex: 1; }
.ed-sec-head .icon-btn { width: 26px; height: 26px; font-size: 16px; border-radius: 6px; }
.ed-sec-head .icon-btn svg { width: 15px; height: 15px; }
.ed-sec-head .icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.ed-empty { padding: 4px 12px 2px; color: var(--muted); font-size: 12.5px; }

/* Dateibaum */
.ed-folder, .ed-file { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 26px; padding: 0 8px 0 var(--indent, 12px); border: 0; background: transparent; color: var(--muted); text-align: left; white-space: nowrap; }
.ed-folder { font-size: 12px; font-weight: 650; line-height: 26px; }
.ed-file { height: 28px; font: 13px/28px var(--font-mono); cursor: pointer; }
.ed-file:hover, .ed-file.is-active { background: var(--surface-hover); color: var(--text); }
.ed-file.is-changed::after { content: "M"; margin-left: auto; color: #e6c65a; font-size: 11px; font-weight: 700; }
.ed-file.is-added::after { content: "A"; margin-left: auto; color: #6ee7a1; font-size: 11px; font-weight: 700; }
.ed-file:focus-visible, .ed-tab-name:focus-visible, .ed-tab-x:focus-visible, .ed-row:focus-visible { outline-offset: -2px; }
.ed-file .ed-file-name { overflow: hidden; text-overflow: ellipsis; }
.ed-file-ic { flex: none; width: 14px; height: 14px; opacity: 0.8; }
.ed-removed { padding: 2px 12px; color: #ff8a84; font: 12px/24px var(--font-mono); text-decoration: line-through; }

/* Listen (Entwürfe, Requests) */
.ed-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 12px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.ed-row:hover, .ed-row.is-active { background: var(--surface-hover); }
.ed-row .ed-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ed-row .ed-row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ed-row .ed-row-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-pill { padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font: 600 11px/1.5 var(--font-mono); white-space: nowrap; }
.ed-pill-proposed { color: #e6c65a; border-color: rgba(230, 198, 90, 0.4); }
.ed-pill-merged { color: #6ee7a1; border-color: rgba(110, 231, 161, 0.35); }
.ed-pill-rejected { color: #ff8a84; border-color: rgba(255, 138, 132, 0.4); }
.ed-pill-draft { color: var(--text); border-color: var(--line-strong); }
.ed-sec .btn { margin: 6px 12px 0; }
.ed-sec .btn-sm svg { width: 14px; height: 14px; }

/* Inline-Formular (neue Datei, umbenennen) */
.ed-inline { display: flex; gap: 6px; padding: 4px 12px 2px; }
.ed-inline input { flex: 1; min-width: 0; height: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); color: var(--text); font: 13px var(--font-mono); }
.ed-inline input:focus { outline: none; border-color: var(--red); }
.ed-inline .btn { height: 30px; padding: 0 9px; margin: 0; }

/* ---------- Bühne ---------- */
.ed-stage { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.ed-tabs { display: flex; flex: none; height: 36px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg-2); scrollbar-width: thin; }
.ed-tab { display: flex; align-items: stretch; flex: none; border-right: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.ed-tab.is-active { background: var(--bg); color: var(--text); }
.ed-tab-name, .ed-tab-x { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.ed-tab-name { display: inline-flex; align-items: center; gap: 8px; padding: 0 4px 0 12px; font-family: var(--font-mono); font-size: 12.5px; }
.ed-tab.is-dirty .ed-tab-name::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.ed-tab-x { padding: 0 10px; font-size: 16px; line-height: 1; }
.ed-tab-x:hover { color: var(--text); }
.ed-tabs-right { display: flex; align-items: center; gap: 6px; margin-left: auto; padding: 0 8px; }
.ed-tabs-right .btn { height: 26px; padding: 0 9px; font-size: 12px; }
.ed-tabs-right .btn[aria-pressed="true"] { border-color: var(--red); color: var(--text); }
.ed-code { position: relative; flex: 1; min-height: 0; }
#monaco, #diff { position: absolute; inset: 0; }
#monaco[hidden], #diff[hidden] { display: none; }
.ed-cover { position: absolute; inset: 0; z-index: 2; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 24px; background: var(--bg); text-align: center; }
.ed-cover[hidden] { display: none; }
.ed-cover strong { font-family: var(--font-display); font-size: 22px; font-weight: 680; }
.ed-cover p { max-width: 48ch; color: var(--muted); text-wrap: balance; }
#cover-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#cover-actions:empty { display: none; }

/* ---------- Statuszeile ---------- */
.ed-status { display: flex; justify-content: space-between; gap: 12px; flex: none; height: 26px; align-items: center; padding: 0 12px; border-top: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font: 12px/1 var(--font-mono); }
.ed-status-right { display: flex; gap: 14px; }
#status-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status-lsp.is-ready { color: #6ee7a1; }
#status-lsp.is-error, #status-lsp.is-closed { color: #ff8a84; }
#status-lsp.is-connecting { color: #e6c65a; }
#status-save.is-saving { color: #e6c65a; }
#status-save.is-error { color: #ff8a84; }

/* ---------- Monaco-Anpassungen ---------- */
.monaco-editor .suggest-widget, .monaco-editor .monaco-hover, .monaco-editor .parameter-hints-widget { border-radius: 9px !important; }

/* ---------- Entwürfe-Übersicht (/code) ---------- */
.ed-drafts { flex: 1; min-height: 0; overflow: auto; padding: 24px 20px 40px; }
.ed-drafts[hidden] { display: none; }
.ed-drafts-inner { max-width: 820px; margin: 0 auto; }
.ed-drafts h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.ed-drafts .page-sub { margin: 4px 0 18px; color: var(--muted); }
.ed-draft-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); color: var(--text); text-decoration: none; margin-bottom: 8px; }
.ed-draft-card:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.ed-draft-card .ed-row-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ed-draft-card .ed-row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.ed-draft-card .ed-row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-draft-card time { color: var(--muted); font: 12px var(--font-mono); white-space: nowrap; }

/* ---------- Modal ---------- */
.ed-modal { width: min(520px, 100%); padding: 22px; border-radius: 14px; }
.ed-modal h2 { margin-bottom: 4px; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.ed-modal .ed-modal-sub { margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.ed-modal form { display: flex; flex-direction: column; gap: 12px; }
.ed-modal .ed-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.ed-modal .ed-conflicts { padding: 8px 12px; border: 1px solid rgba(255, 138, 132, 0.4); border-radius: 8px; color: #ff8a84; font: 12.5px var(--font-mono); }
.modal[hidden] { display: none; }
.modal { background: rgba(0, 0, 0, 0.55); }

@media (max-width: 720px) {
  .ed-title { max-width: 60vw; }
  .ed-controls { margin-left: 0; }
  .ed-body { flex-direction: column; }
  .ed-side { width: 100%; max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
  .ed-cover strong { font-size: 18px; }
  .ed-status-right { gap: 8px; }
}
