/* Portal-Oberfläche (Stufe 1). Nutzt die Tokens aus base.css; eigene Klassen mit Präfix lp-. */
:root {
  --lp-chrome: #efebe3;
  --lp-chrome-2: #e8e3d9;
  --lp-paper: #fbfaf6;
  --lp-line: #e2dccf;
  --lp-hover: rgba(47, 93, 138, .08);
  --lp-here: #fff3c4;
  --lp-here-line: #c9a227;
  --lp-side-w: 272px;
  --lp-act-w: 48px;
  --lp-status-h: 26px;
  --lp-bar-h: 36px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lp-chrome: #141417; --lp-chrome-2: #1b1b1f; --lp-paper: #1c1c20; --lp-line: #2e2e35;
    --lp-hover: rgba(127, 176, 224, .10); --lp-here: #3a3218; --lp-here-line: #c9a227;
  }
}
:root[data-theme="dark"] {
  --lp-chrome: #141417; --lp-chrome-2: #1b1b1f; --lp-paper: #1c1c20; --lp-line: #2e2e35;
  --lp-hover: rgba(127, 176, 224, .10); --lp-here: #3a3218; --lp-here-line: #c9a227;
}

body.lp-body { overflow: hidden; background: var(--lp-chrome); }
.lp-grow { flex: 1; }
.lp-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.small { padding: 3px 9px; font-size: .82rem; border-radius: 6px; }
.lp-icon-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; }
.lp-icon-btn:hover { background: var(--lp-hover); color: var(--fg); }
.lp-icon-btn .lp-icon { width: 17px; height: 17px; }

/* ------------------------------------------------------------------ Grundgerüst */
.lp-app {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: var(--lp-act-w) var(--lp-side-w) minmax(0, 1fr) var(--lp-dock-cur, 0px);
  grid-template-rows: minmax(0, 1fr) var(--lp-status-h);
  grid-template-areas: "act side main dock" "status status status status";
}
.lp-app.sidebar-closed { grid-template-columns: var(--lp-act-w) 0 minmax(0, 1fr) var(--lp-dock-cur, 0px); }
.lp-app.dock-open { --lp-dock-cur: var(--lp-dock-w, 420px); }
.lp-app.sidebar-closed .lp-sidebar { visibility: hidden; border: 0; }
.lp-activity { grid-area: act; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: var(--lp-chrome); border-right: 1px solid var(--lp-line); }
.lp-sidebar { grid-area: side; min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--lp-chrome-2); border-right: 1px solid var(--lp-line); }
.lp-main { grid-area: main; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--lp-chrome); }
.lp-main > .lp-workspace { flex: 1; }
.lp-status { grid-area: status; display: flex; align-items: center; gap: 14px; padding: 0 10px; font-size: .78rem; color: var(--muted); background: var(--lp-chrome); border-top: 1px solid var(--lp-line); white-space: nowrap; overflow: hidden; }
.lp-mobilebar, .lp-mobile-head { display: none; }

/* Aktivitätsleiste */
.lp-act { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.lp-act:hover { color: var(--fg); background: var(--lp-hover); }
.lp-act.active { color: var(--accent); }
.lp-act.active::before { content: ""; position: absolute; left: -4px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--accent); }
.lp-act.current { color: var(--fg); background: var(--lp-hover); }
.lp-act .lp-icon { width: 21px; height: 21px; }
.lp-act-sep { width: 22px; height: 1px; margin: 6px 0; background: var(--lp-line); }
.lp-act-dot { position: absolute; right: 8px; bottom: 8px; width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.lp-act-sync.ok .lp-act-dot { background: var(--ok); }
.lp-act-sync.warn .lp-act-dot { background: var(--warn); }
.lp-act-sync.bad .lp-act-dot { background: var(--bad); }
.lp-act-sync.busy .lp-icon { animation: lp-spin 1.2s linear infinite; }
@keyframes lp-spin { to { transform: rotate(360deg); } }

/* Seitenleiste */
.lp-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.lp-panel[hidden] { display: none; }
.lp-panel-head { display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 6px 0 14px; flex: none; }
.lp-panel-title { font-size: .74rem; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.lp-panel-msg { padding: 10px 14px; font-size: .85rem; color: var(--muted); }
.lp-tree { flex: 1; overflow: auto; padding: 2px 0 20px; font-size: .86rem; }
.lp-tree-row { display: flex; align-items: center; gap: 4px; height: 26px; padding-right: 8px; cursor: pointer; white-space: nowrap; color: var(--fg); outline: none; user-select: none; }
.lp-tree-row:hover { background: var(--lp-hover); }
.lp-tree-row:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.lp-tree-row.active { background: var(--accent-soft); }
.lp-tree-chev { width: 14px; height: 14px; color: var(--muted); transition: transform .12s; }
.lp-tree-row.open .lp-tree-chev { transform: rotate(90deg); }
.lp-tree-chev-spacer { width: 14px; flex: none; }
.lp-tree-icon { width: 16px; height: 16px; color: var(--muted); }
.lp-tree-row.dir .lp-tree-icon { color: var(--accent); opacity: .8; }
.lp-tree-name { overflow: hidden; text-overflow: ellipsis; }
.lp-tree-empty { height: 24px; line-height: 24px; }
.lp-search-box { padding: 4px 10px 8px; }
.lp-search-input { width: 100%; padding: 5px 9px; font-size: .86rem; }
.lp-search-results { flex: 1; overflow: auto; padding-bottom: 20px; }
.lp-search-sec-title { padding: 8px 14px 4px; font-size: .74rem; font-weight: 600; color: var(--muted); }
.lp-search-sec > p { padding: 0 14px; }
.lp-search-hit { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; width: 100%; padding: 4px 14px; border: 0; background: transparent; color: var(--fg); text-align: left; font: inherit; font-size: .84rem; cursor: pointer; }
.lp-search-hit:hover { background: var(--lp-hover); }
.lp-search-hit.grep { flex-direction: column; align-items: flex-start; }
.lp-hit-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lp-hit-text { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lp-hit-text mark { background: var(--hl-yellow); color: inherit; border-radius: 2px; }

/* Statusleiste */
.lp-st-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.lp-st-path { overflow: hidden; text-overflow: ellipsis; }
.lp-st-right { margin-left: auto; display: inline-flex; gap: 12px; align-items: center; }
.lp-st-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .6; }
.lp-st-sync.ok .lp-st-dot { background: var(--ok); opacity: 1; }
.lp-st-sync.warn .lp-st-dot { background: var(--warn); opacity: 1; }
.lp-st-sync.bad { color: var(--bad); }
.lp-st-sync.bad .lp-st-dot { background: var(--bad); opacity: 1; }
.lp-st-sync.busy .lp-st-dot { background: var(--accent); opacity: 1; animation: pulse 1s infinite; }
.lp-st-btn { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border: 1px solid var(--lp-line); border-radius: 5px; background: transparent; color: var(--fg); font: inherit; font-size: .74rem; cursor: pointer; }
.lp-st-btn:hover { border-color: var(--accent); }
.lp-st-btn .lp-icon { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ Arbeitsfläche */
.lp-workspace { position: relative; min-width: 0; min-height: 0; padding: 6px; overflow: hidden; }
.lp-workspace > .lp-split, .lp-workspace > .lp-group { height: 100%; }
.lp-split { display: grid; min-width: 0; min-height: 0; overflow: hidden; }
.lp-divider { position: relative; z-index: 2; background: transparent; border-radius: 3px; outline: none; }
.lp-split.horizontal > .lp-divider { cursor: col-resize; }
.lp-split.vertical > .lp-divider { cursor: row-resize; }
.lp-divider:hover, .lp-divider:focus-visible { background: color-mix(in srgb, var(--accent) 35%, transparent); }
body.lp-resizing { user-select: none; }
body.lp-resizing.horizontal { cursor: col-resize; }
body.lp-resizing.vertical { cursor: row-resize; }
body.lp-resizing iframe, body.lp-resizing .lp-host { pointer-events: none; }

.lp-group { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--lp-paper); border: 1px solid var(--lp-line); border-radius: 10px; outline: none; }
.lp-group.focused { border-color: color-mix(in srgb, var(--accent) 45%, var(--lp-line)); }
.lp-group-bar { display: flex; align-items: center; gap: 4px; height: var(--lp-bar-h); min-height: var(--lp-bar-h); padding: 0 6px; background: var(--lp-chrome-2); border-bottom: 1px solid var(--lp-line); }
.lp-group-bar[hidden] { display: none; }
.lp-grip { display: grid; place-items: center; flex: 0 0 20px; height: 20px; border: 1px solid var(--lp-line); border-radius: 6px; font-size: 10px; color: var(--muted); cursor: grab; user-select: none; }
.lp-group.focused .lp-grip { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--lp-line)); background: var(--accent-soft); }
.lp-tabs { display: flex; align-items: center; align-self: stretch; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.lp-tab { position: relative; display: flex; align-items: center; flex-shrink: 0; max-width: 220px; height: 28px; margin: 0 1px; border: 1px solid transparent; border-radius: 7px; }
.lp-tab:hover:not(.active) { background: var(--lp-hover); }
.lp-tab.active { background: var(--lp-paper); border-color: var(--lp-line); }
.lp-group.focused .lp-tab.active { border-color: color-mix(in srgb, var(--accent) 35%, var(--lp-line)); }
.lp-tab.drop-before::before { content: ""; position: absolute; left: -2px; top: 4px; bottom: 4px; width: 2px; background: var(--accent); border-radius: 2px; }
.lp-tab > button[role=tab] { display: flex; align-items: center; gap: 6px; min-width: 0; height: 100%; padding: 0 4px 0 9px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; border-radius: inherit; }
.lp-tab.active > button[role=tab] { color: var(--fg); }
.lp-tab-icon { width: 14px; height: 14px; }
.lp-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-tab-close { display: grid; place-items: center; width: 20px; height: 20px; margin-right: 4px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
.lp-tab-close:hover { background: var(--lp-hover); color: var(--fg); }
.lp-tab-close .dot { display: none; font-size: 10px; }
.lp-tab.dirty .lp-tab-close .x { display: none; }
.lp-tab.dirty .lp-tab-close .dot { display: inline; color: var(--fg); }
.lp-tab.dirty .lp-tab-close:hover .x { display: inline; }
.lp-tab.dirty .lp-tab-close:hover .dot { display: none; }
.lp-tab:not(.active):not(:hover):not(.dirty) .lp-tab-close { visibility: hidden; }
.lp-group-tools { display: flex; gap: 1px; flex: none; }
.lp-group-body { position: relative; flex: 1; min-height: 0; }
.lp-host { position: absolute; inset: 0; overflow: auto; }
.lp-host[hidden] { display: none !important; } /* sonst überschreibt .lp-host[data-viewer] (display:flex) das Ausblenden */
.lp-host.view { padding: 22px 30px; }
.lp-host-spinner { padding: 18px; }
.lp-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; }

/* Ablagezonen beim Ziehen */
.lp-dropzones { display: none; position: absolute; inset: var(--lp-bar-h) 0 0 0; z-index: 30; }
.lp-workspace.dragging .lp-dropzones { display: block; }
.lp-drop { position: absolute; display: grid; place-items: center; border-radius: 8px; font-size: .78rem; color: var(--accent); }
.lp-drop > span { opacity: 0; padding: 3px 8px; border-radius: 6px; background: var(--bg-elev); box-shadow: var(--shadow); transition: opacity .1s; }
.lp-drop.over { background: color-mix(in srgb, var(--accent) 16%, transparent); outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -4px; }
.lp-drop.over > span { opacity: 1; }
.lp-drop.center { inset: 25%; }
.lp-drop.left { left: 0; top: 0; bottom: 0; width: 25%; }
.lp-drop.right { right: 0; top: 0; bottom: 0; width: 25%; }
.lp-drop.up { left: 25%; right: 25%; top: 0; height: 25%; }
.lp-drop.down { left: 25%; right: 25%; bottom: 0; height: 25%; }

/* Alte Ansichten im Tab */
.lp-view-host .map-wrap, .lp-view-host .tu-wrap { height: 100%; }

/* Menüs und Schnellöffnen */
.lp-menu { position: fixed; z-index: 120; min-width: 200px; padding: 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.lp-menu-item { display: flex; justify-content: space-between; gap: 20px; width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--fg); font: inherit; font-size: .86rem; text-align: left; cursor: pointer; }
.lp-menu-item:hover:not(:disabled), .lp-menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.lp-menu-item:disabled { opacity: .45; cursor: default; }
.lp-menu-item.danger { color: var(--bad); }
.lp-menu-hint { color: var(--muted); font-size: .78rem; }
.lp-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.lp-quickopen { position: fixed; inset: 0; z-index: 110; display: flex; justify-content: center; align-items: flex-start; padding-top: 10vh; background: rgba(0,0,0,.18); }
.lp-qo-box { width: min(620px, calc(100% - 24px)); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 50px rgba(0,0,0,.25); overflow: hidden; }
.lp-qo-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 14px; font-size: 1rem; background: transparent; }
.lp-qo-input:focus { outline: none; }
.lp-qo-list { max-height: 50vh; overflow: auto; padding: 4px; }
.lp-qo-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.lp-qo-item.sel { background: var(--accent-soft); }
.lp-qo-name { white-space: nowrap; }
.lp-qo-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-qo-empty { padding: 12px; }
.lp-qo-hint { padding: 6px 12px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ Viewer allgemein */
.lp-host[data-viewer] { overflow: hidden; display: flex; flex-direction: column; }
.lp-viewer-toolbar { display: flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 3px 10px; border-bottom: 1px solid var(--lp-line); background: var(--lp-paper); overflow-x: auto; }
.lp-seg { display: inline-flex; padding: 2px; border-radius: 7px; background: var(--lp-chrome-2); }
.lp-seg-btn { padding: 2px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.lp-seg-btn.active { background: var(--lp-paper); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn.active { color: var(--accent); }
.lp-viewer-msg { margin: auto; display: grid; justify-items: center; gap: 8px; padding: 30px; text-align: center; }
.lp-viewer-msg.error strong { color: var(--bad); }
.lp-dl-icon { font-size: 28px; color: var(--muted); }
.lp-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 7px 12px; flex: none; font-size: .85rem; background: color-mix(in srgb, var(--warn) 16%, var(--lp-paper)); border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, var(--lp-line)); }
.lp-banner-actions { display: inline-flex; gap: 6px; margin-left: auto; }

/* Markdown */
.lp-md-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.lp-md-body[data-mode="preview"] { grid-template-columns: minmax(0, 1fr); }
.lp-md-body[data-mode="edit"] { grid-template-columns: minmax(0, 1fr); }
.lp-md-body[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.lp-md-body.outline-open[data-mode="preview"], .lp-md-body.outline-open[data-mode="edit"] { grid-template-columns: minmax(0, 1fr) clamp(150px, 26%, 260px); }
.lp-md-body.outline-open[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) clamp(150px, 18%, 240px); }
.lp-md-body[data-mode="preview"] .lp-md-editor, .lp-md-body[data-mode="edit"] .lp-md-preview-scroll { display: none; }
.lp-md-body:not(.outline-open) .lp-outline { display: none; }
.lp-md-editor { display: block; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 18px 22px; resize: none; border: 0; border-radius: 0; background: var(--lp-paper); font: 13.5px/1.6 var(--mono); tab-size: 2; }
.lp-md-editor:focus { outline: none; }
.lp-md-body[data-mode="split"] .lp-md-editor { border-right: 1px solid var(--lp-line); }
.lp-md-preview-scroll { min-height: 0; overflow: auto; }
.lp-md-preview { max-width: 820px; margin: 0 auto; padding: 22px 32px 40vh; }
.lp-md-content { font-family: var(--font-read); font-size: 16.5px; line-height: 1.68; }
.lp-md-content h1, .lp-md-content h2, .lp-md-content h3, .lp-md-content h4, .lp-md-content h5, .lp-md-content h6 { font-family: var(--font); margin: 1.6em 0 .55em; scroll-margin-top: 12px; }
.lp-md-content h1 { font-size: 1.55rem; } .lp-md-content h2 { font-size: 1.28rem; } .lp-md-content h3 { font-size: 1.1rem; } .lp-md-content h4, .lp-md-content h5, .lp-md-content h6 { font-size: 1rem; }
.lp-md-content > :first-child { margin-top: 0; }
.lp-md-content code { font-size: .84em; padding: .1em .3em; border-radius: 4px; background: var(--lp-chrome-2); }
.lp-md-content pre code { padding: 0; background: none; }
.lp-md-content pre { font-size: 13px; line-height: 1.5; background: var(--lp-chrome-2); }
.lp-md-content img { max-width: 100%; }
.lp-md-content ul, .lp-md-content ol { padding-left: 1.4em; }
.lp-md-content li + li { margin-top: .2em; }
.lp-md-content hr { border: 0; border-top: 1px solid var(--lp-line); margin: 1.6em 0; }
.lp-md-content table { margin: 0 0 1em; display: block; overflow-x: auto; }
.lp-md-content .katex { font-size: 1.06em; }
.lp-md-content .katex-display { margin: .9em 0; padding: 2px 0; }
.lp-here { position: relative; margin-left: -12px !important; margin-right: -12px !important; padding: 6px 12px; border-radius: 8px; background: var(--lp-here); box-shadow: inset 3px 0 0 var(--lp-here-line); }
.lp-here::after { content: "当前位置"; display: inline-block; white-space: nowrap; margin-left: 10px; padding: 1px 7px; border-radius: 999px; font-size: .68rem; font-weight: 600; vertical-align: middle; color: #7a5d00; background: color-mix(in srgb, var(--lp-here-line) 25%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lp-here::after { color: #f0d27a; } }
.lp-outline { min-height: 0; overflow: auto; border-left: 1px solid var(--lp-line); background: var(--lp-chrome-2); font-size: .8rem; }
.lp-outline-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 6px 12px; font-size: .72rem; font-weight: 600; letter-spacing: .06em; color: var(--muted); background: var(--lp-chrome-2); }
.lp-outline-list { padding: 0 4px 30px; }
.lp-outline-item { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 5px; color: var(--fg); text-decoration: none; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-outline-item:hover { background: var(--lp-hover); }
.lp-outline-item.current { background: var(--accent-soft); }
.lp-outline-item.here { background: var(--lp-here); font-weight: 600; }
.lp-here-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--lp-here-line); }

/* PDF */
.lp-pdf-page { width: 3.2em; padding: 2px 6px; font-size: .82rem; text-align: center; }
.lp-pdf-zoomlabel { min-width: 74px; }
.lp-pdf-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--lp-chrome-2); }
.lp-pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 16px 40px; width: max-content; min-width: 100%; }
.lp-pdf-pagebox { position: relative; flex: none; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 14px rgba(0,0,0,.06); display: grid; place-items: center; }
.lp-pdf-pagebox > canvas { position: absolute; inset: 0; display: block; }
.lp-pdf-num { color: #999; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lp-pdf-pagebox { filter: brightness(.92); } }

/* Notebook */
.lp-nb-scroll { flex: 1; min-height: 0; overflow: auto; }
.lp-nb-cells { max-width: 980px; margin: 0 auto; padding: 18px 24px 40vh; }
.lp-nb-cell { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; margin-bottom: 12px; }
.lp-nb-prompt { padding-top: 8px; font: 12px var(--mono); color: var(--muted); text-align: right; }
.lp-nb-main { min-width: 0; }
.lp-nb-code { margin: 0; padding: 9px 12px; border-radius: 7px; background: var(--lp-chrome-2); border: 1px solid var(--lp-line); font-size: 13px; line-height: 1.5; overflow-x: auto; }
.lp-nb-code code.hljs { background: none; padding: 0; }
.lp-nb-outputs { padding: 6px 2px 0; display: grid; gap: 6px; }
.lp-nb-outputs pre { margin: 0; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
.lp-nb-stream.stderr { background: color-mix(in srgb, var(--warn) 10%, transparent); padding: 4px 6px; border-radius: 4px; }
.lp-nb-error { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); padding: 6px 8px; border-radius: 5px; }
.lp-nb-img { max-width: 100%; height: auto; background: #fff; border-radius: 4px; }
.lp-nb-svg svg { max-width: 100%; height: auto; }
.lp-nb-html { overflow-x: auto; font-size: .9rem; }
.lp-nb-html table { border-collapse: collapse; } .lp-nb-html td, .lp-nb-html th { border: 1px solid var(--border); padding: 3px 7px; }
.md-cell .lp-nb-main { padding: 2px 4px; font-family: var(--font-read); font-size: 16px; line-height: 1.65; }
.md-cell .lp-nb-main h1, .md-cell .lp-nb-main h2, .md-cell .lp-nb-main h3, .md-cell .lp-nb-main h4 { font-family: var(--font); margin-top: .8em; }

/* Bilder und Text */
.lp-img-box { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 16px; background: var(--lp-chrome-2); }
.lp-img-box img { cursor: zoom-out; background: repeating-conic-gradient(#0000000a 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.lp-img-box.fit img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.lp-text-scroll { flex: 1; min-height: 0; overflow: auto; }
.lp-text-wrap { display: flex; min-width: max-content; }
.lp-text-gutter { margin: 0; padding: 12px 10px 40px 14px; text-align: right; color: var(--muted); opacity: .6; user-select: none; font-size: 12.5px; line-height: 1.55; border-right: 1px solid var(--lp-line); }
.lp-text-code { margin: 0; padding: 12px 18px 40px; font-size: 12.5px; line-height: 1.55; }
.lp-text-code code.hljs, .lp-md-content pre code.hljs { background: none; padding: 0; }

/* Login */
.lp-login { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.lp-login-box { width: min(340px, 100%); display: grid; gap: 12px; justify-items: stretch; text-align: center; padding: 30px 26px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.lp-login-box h1 { margin: 0; font-size: 1.35rem; }
.lp-login-box p { margin: -6px 0 6px; }
.lp-login-mark { justify-self: center; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font: 600 26px var(--font-read); color: var(--bg-elev); background: var(--accent); }
.lp-login-box input { padding: 10px 12px; font-size: 1rem; }
.lp-login-box .btn { padding: 9px; font-size: 1rem; }
.lp-login-msg { min-height: 1.2em; font-size: .86rem; color: var(--bad); }

/* ------------------------------------------------------------------ Handy */
.lp-app.mobile {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "main" "mobilebar";
}
.lp-app.mobile .lp-activity, .lp-app.mobile .lp-sidebar, .lp-app.mobile .lp-status { display: none; }
.lp-app.mobile .lp-mobile-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 14px; flex: none; background: var(--lp-chrome-2); border-bottom: 1px solid var(--lp-line); }
.lp-mh-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lp-app.mobile .lp-workspace { padding: 0; }
.lp-app.mobile .lp-group { border: 0; border-radius: 0; }
.lp-app.mobile .lp-dropzones { display: none !important; }
.lp-app.mobile .lp-host.view { padding: 14px; }
.lp-app.mobile .lp-md-preview { padding: 14px 16px 40vh; }
.lp-app.mobile .lp-md-content { font-size: 16px; }
.lp-app.mobile .lp-md-body.outline-open { grid-template-columns: minmax(0, 1fr); }
.lp-app.mobile .lp-md-body.outline-open .lp-outline { position: absolute; inset: 0 0 0 18%; z-index: 5; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
.lp-app.mobile .lp-md-body { position: relative; }
.lp-app.mobile .lp-seg-btn[data-mode="split"] { display: none; }
.lp-app.mobile .lp-pdf-pages { padding: 4px 4px 30px; gap: 6px; }
.lp-app.mobile .lp-nb-cells { padding: 12px 10px 40vh; }
.lp-app.mobile .lp-nb-cell { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.lp-app.mobile .lp-nb-prompt { text-align: left; padding-top: 0; }
.lp-mobilebar { grid-area: mobilebar; }
.lp-app.mobile .lp-mobilebar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom); background: var(--lp-chrome-2); border-top: 1px solid var(--lp-line); }
.lp-mb-btn { display: grid; justify-items: center; gap: 2px; padding: 7px 0 6px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .72rem; cursor: pointer; }
.lp-mb-btn.active { color: var(--accent); }
.lp-mb-btn[hidden] { display: none; }
.lp-mb-btn .lp-icon { width: 22px; height: 22px; }
.lp-sheet { position: fixed; left: 0; right: 0; top: 0; bottom: calc(57px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; background: var(--lp-chrome-2); }
.lp-sheet[hidden] { display: none; }
.lp-sheet-head { display: flex; justify-content: space-between; align-items: center; height: 46px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--lp-line); }
.lp-sheet .lp-files .lp-panel-head { display: none; }
.lp-sheet .lp-tree { font-size: .95rem; }
.lp-sheet .lp-tree-row { height: 38px; }
.lp-tablist { flex: 1; overflow: auto; }
.lp-tablist-row { display: flex; align-items: center; border-bottom: 1px solid var(--lp-line); }
.lp-tablist-row.active { background: var(--accent-soft); }
.lp-tablist-open { flex: 1; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px 14px; border: 0; background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.lp-tablist-open .lp-tree-icon { grid-row: span 2; }
.lp-tablist-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-tablist-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ Agent (Stufe 2) */
.lp-dock { grid-area: dock; min-width: 0; min-height: 0; display: none; position: relative; background: var(--lp-paper); border-left: 1px solid var(--lp-line); }
.lp-app.dock-open .lp-dock { display: flex; }
.lp-app.mobile .lp-dock { display: none !important; }
.lp-dock-grip { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 3; }
.lp-dock-grip:hover { background: var(--accent-soft); }
.lp-dock-body { flex: 1; min-width: 0; display: flex; }
.lp-host.view.lp-agent-host, .lp-app.mobile .lp-host.view.lp-agent-host { padding: 0; overflow: hidden; display: flex; }

.ag-root { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--lp-paper); position: relative; }
.ag-tab .ag-log > *, .ag-tab .ag-compose > * { max-width: 860px; margin-left: auto; margin-right: auto; width: 100%; }
.ag-head { display: flex; align-items: center; gap: 4px; height: 38px; padding: 0 6px 0 4px; border-bottom: 1px solid var(--lp-line); background: var(--lp-chrome-2); flex: none; }
.ag-head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--fg); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-align: left; }
.ag-head-main:hover, .ag-head-main.open { background: var(--lp-hover); }
.ag-ic { width: 16px; height: 16px; color: var(--muted); }
.ag-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-folder { flex: none; padding: 0 7px; border-radius: 999px; font-size: .72rem; font-weight: 500; color: var(--accent); background: var(--accent-soft); }
.ag-folder[hidden] { display: none; }
.ag-list { position: absolute; top: 38px; left: 0; right: 0; max-height: 65%; overflow: auto; z-index: 10; background: var(--bg-elev); border-bottom: 1px solid var(--lp-line); box-shadow: 0 10px 24px rgba(0,0,0,.12); padding: 6px 0; }
.ag-list[hidden] { display: none; }
.ag-list-new { margin: 2px 10px 6px; }
.ag-list-row { display: flex; align-items: center; gap: 2px; padding-right: 6px; }
.ag-list-row.active { background: var(--accent-soft); }
.ag-list-row:hover { background: var(--lp-hover); }
.ag-list-open { flex: 1; min-width: 0; display: grid; gap: 1px; padding: 7px 12px; border: 0; background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.ag-list-title { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.ag-list-meta { display: flex; align-items: center; gap: 6px; }
.ag-dot, .ag-working .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; animation: ag-pulse 1.2s ease-in-out infinite; }
@keyframes ag-pulse { 50% { opacity: .3; } }

.ag-log { flex: 1; min-height: 0; overflow: auto; padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 12px; }
.ag-history { display: flex; flex-direction: column; gap: 14px; }
.ag-msg.user { align-self: flex-end; max-width: 88%; }
.ag-tab .ag-msg.user { margin-right: 0; width: auto; }
.ag-bubble { padding: 8px 12px; border-radius: 12px 12px 3px 12px; background: var(--accent); color: var(--bg-elev); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; }
.ag-msg.assistant { display: flex; flex-direction: column; gap: 6px; font-size: .94rem; }
.ag-md { overflow-wrap: anywhere; line-height: 1.55; }
.ag-md > :first-child { margin-top: 0; }
.ag-md > :last-child { margin-bottom: 0; }
.ag-md pre { overflow: auto; padding: 8px 10px; border-radius: 8px; background: var(--lp-chrome-2); font-size: .82rem; }
.ag-md .katex-display { overflow-x: auto; overflow-y: hidden; }
.ag-steps { font-size: .8rem; color: var(--muted); }
.ag-steps summary { cursor: pointer; user-select: none; width: max-content; }
.ag-steps ul { margin: 4px 0 0; padding: 6px 8px 6px 22px; border-left: 2px solid var(--lp-line); display: grid; gap: 3px; }
.ag-step code { font-size: .78rem; overflow-wrap: anywhere; }
.ag-step.bad code { color: var(--bad); }
.ag-step.running code::after { content: " …"; }
.ag-step.warn { color: var(--warn); }
.ag-files { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ag-file { padding: 1px 8px; border: 1px solid var(--lp-line); border-radius: 999px; background: var(--bg-elev); color: var(--accent); font: inherit; font-size: .78rem; cursor: pointer; }
.ag-file:hover { border-color: var(--accent); }
.ag-qlink { padding: 0 2px; border: 0; border-bottom: 1px dashed currentColor; background: none; color: var(--accent); font: inherit; font-weight: inherit; cursor: pointer; }
.ag-qlink:hover { border-bottom-style: solid; }
.ag-error { padding: 6px 10px; border-radius: 8px; color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, transparent); font-size: .85rem; }
.ag-meta { font-size: .72rem; }
.ag-working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.ag-empty { margin: auto; max-width: 340px; display: grid; justify-items: center; gap: 10px; text-align: center; padding: 30px 12px; color: var(--muted); }
.ag-empty-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.ag-empty-mark .lp-icon { width: 26px; height: 26px; }

.ag-mc { border: 1px solid var(--lp-line); border-radius: 12px; padding: 10px; background: var(--bg-elev); display: grid; gap: 8px; }
.ag-mc-q { font-size: .82rem; color: var(--muted); }
.ag-mc-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-mc-opt { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px; padding: 4px 12px 4px 6px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--fg); font: inherit; font-size: .85rem; cursor: pointer; text-align: left; }
.ag-mc-opt b { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 6px; background: var(--lp-chrome-2); }
.ag-mc-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22em; }
.ag-mc-opt.none { padding-left: 12px; color: var(--muted); }
.ag-mc-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ag-mc-opt[aria-pressed="true"] b { background: var(--accent); color: var(--bg-elev); }
.ag-mc-foot { display: flex; align-items: center; gap: 8px; }
.ag-mc-slider { width: 130px; accent-color: var(--accent); }
.ag-mc-slider.unset { opacity: .45; }
.ag-mc-confval { min-width: 1.4em; font-variant-numeric: tabular-nums; font-weight: 600; }

.ag-compose { flex: none; display: grid; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--lp-line); background: var(--lp-chrome-2); }
.ag-quick { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.ag-chip { flex: none; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); color: var(--fg); font: 500 .8rem var(--mono); cursor: pointer; }
.ag-chip:hover { border-color: var(--accent); color: var(--accent); }
.ag-input { width: 100%; min-height: 52px; max-height: 220px; resize: none; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); color: var(--fg); font: inherit; font-size: .93rem; line-height: 1.4; }
.ag-input:focus { outline: none; border-color: var(--accent); }
.ag-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.ag-toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.ag-usage.bad { color: var(--bad); }
.ag-bar .btn { padding: 5px 16px; }
.ag-stop[hidden], .ag-send[hidden] { display: none; }
.ag-dlg { display: grid; gap: 6px; min-width: min(420px, 80vw); }
.ag-dlg select, .ag-dlg textarea { width: 100%; font: inherit; }

.lp-app.mobile .ag-desktop-only { display: none; }
.lp-app.mobile .ag-log { padding: 12px 12px 8px; }
.lp-app.mobile .ag-compose { padding: 8px 10px 10px; }
.lp-app.mobile .ag-input { font-size: 16px; }
.lp-app.mobile .ag-bar .btn { padding: 9px 22px; font-size: 1rem; }
.lp-app.mobile .ag-chip { padding: 5px 12px; font-size: .85rem; }
.lp-app.mobile .ag-mc-opt { min-height: 42px; }
.lp-app.mobile .ag-mc-opt:not(.none) { width: 100%; }
.lp-app.mobile .ag-mc-opt span { max-width: none; white-space: normal; }

/* Tastenkürzel-Hilfe (⌘/ oder ?), Aufbau wie in live-os */
.lp-keys-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.35); }
.lp-keys { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 18px 24px; width: min(920px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.lp-keys-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.lp-keys-head h2 { margin: 0; font-size: 1.15rem; }
.lp-keys-head .muted { flex: 1; }
.lp-keys-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 28px; }
.lp-keys h3 { font-size: .78rem; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.lp-keys-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; font-size: .85rem; border-bottom: 1px solid var(--border); }
.lp-keys-keys { display: flex; align-items: center; gap: 4px; }
.lp-keys-reset { border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 2px; }
.lp-keys-reset:hover { color: var(--accent); }
.lp-kbd-btn { font: .74rem var(--font); border: 1px solid var(--border); border-radius: 5px; padding: 1px 7px; color: var(--fg); background: var(--bg); cursor: pointer; white-space: nowrap; }
.lp-kbd-btn:hover, .lp-kbd-btn.recording { border-color: var(--accent); color: var(--accent); }
.lp-keys-row.clash .lp-kbd-btn { border-color: var(--bad); color: var(--bad); }
.lp-keys-foot { margin: 14px 0 0; }
