/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */

/**
 *  Default styles for xterm.js
 */

.xterm {
    cursor: text;
    position: relative;
    user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
    outline: none;
}

.xterm .xterm-helpers {
    position: absolute;
    top: 0;
    /**
     * The z-index of the helpers must be higher than the canvases in order for
     * IMEs to appear on top.
     */
    z-index: 5;
}

.xterm .xterm-helper-textarea {
    padding: 0;
    border: 0;
    margin: 0;
    /* Move textarea out of the screen to the far left, so that the cursor is not visible */
    position: absolute;
    opacity: 0;
    left: -9999em;
    top: 0;
    width: 0;
    height: 0;
    z-index: -5;
    /** Prevent wrapping so the IME appears against the textarea at the correct position */
    white-space: nowrap;
    overflow: hidden;
    resize: none;
}

.xterm .composition-view {
    /* TODO: Composition position got messed up somewhere */
    background: #000;
    color: #FFF;
    display: none;
    position: absolute;
    white-space: nowrap;
    z-index: 1;
}

.xterm .composition-view.active {
    display: block;
}

.xterm .xterm-viewport {
    /* On OS X this is required in order for the scroll bar to appear fully opaque */
    background-color: #000;
    overflow-y: scroll;
    cursor: default;
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
}

.xterm .xterm-screen {
    position: relative;
}

.xterm .xterm-screen canvas {
    position: absolute;
    left: 0;
    top: 0;
}

.xterm .xterm-scroll-area {
    visibility: hidden;
}

.xterm-char-measure-element {
    display: inline-block;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: -9999em;
    line-height: normal;
}

.xterm.enable-mouse-events {
    /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
    cursor: default;
}

.xterm.xterm-cursor-pointer,
.xterm .xterm-cursor-pointer {
    cursor: pointer;
}

.xterm.column-select.focus {
    /* Column selection mode */
    cursor: crosshair;
}

.xterm .xterm-accessibility:not(.debug),
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
    pointer-events: none;
}

.xterm .xterm-accessibility-tree:not(.debug) *::selection {
  color: transparent;
}

.xterm .xterm-accessibility-tree {
  user-select: text;
  white-space: pre;
}

.xterm .live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.xterm-dim {
    /* Dim should not apply to background, so the opacity of the foreground color is applied
     * explicitly in the generated class and reset to 1 here */
    opacity: 1 !important;
}

.xterm-underline-1 { text-decoration: underline; }
.xterm-underline-2 { text-decoration: double underline; }
.xterm-underline-3 { text-decoration: wavy underline; }
.xterm-underline-4 { text-decoration: dotted underline; }
.xterm-underline-5 { text-decoration: dashed underline; }

.xterm-overline {
    text-decoration: overline;
}

.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }

.xterm-strikethrough {
    text-decoration: line-through;
}

.xterm-screen .xterm-decoration-container .xterm-decoration {
	z-index: 6;
	position: absolute;
}

.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
	z-index: 7;
}

.xterm-decoration-overview-ruler {
    z-index: 8;
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: none;
}

.xterm-decoration-top {
    z-index: 2;
    position: relative;
}
:root {
  --bg: #0d1117;
  --panel: #11161e;
  --panel-2: #161c26;
  --line: #232b38;
  --text: #d7dee8;
  --muted: #7d8aa0;
  --accent: #4c8dff;
  --accent-dim: #2b3b5c;
  --green: #3fb950;
  --amber: #d2a24a;
  --red: #f06d6d;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --shadow: rgba(0, 0, 0, 0.4);
  --user-bubble: #1a2333;
  color-scheme: dark;
}
/* Lyst tema — samme semantikk (accent/grønn/rød), rolige gråtoner. Byttes i Aktivitet-fanen. */
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #e2e6ec;
  --text: #1d2430;
  --muted: #6b7686;
  --accent: #2f6fe0;
  --accent-dim: #d6e3fb;
  --green: #1f8f3a;
  --amber: #a56d0c;
  --red: #d13d3d;
  --shadow: rgba(20, 30, 50, 0.14);
  --user-bubble: #e9eef7;
  color-scheme: light;
}
/* Varmt tema — à la Claude Code / claude.ai: kremhvit bakgrunn, varm gråbrun tekst, terrakotta-aksent.
   Lavere luminans enn «Lyst» (ingen rent hvite flater) → behagelig i lengre økter. */
:root[data-theme="warm"] {
  --bg: #f4f1ea;
  --panel: #faf8f3;
  --panel-2: #ece8df;
  --line: #dcd6c9;
  --text: #2f2b24;
  --muted: #7a7365;
  --accent: #c4633c;
  --accent-dim: #f0d8ca;
  --green: #3b7d4c;
  --amber: #9a6a12;
  --red: #c2433a;
  --shadow: rgba(60, 45, 25, 0.14);
  --user-bubble: #ebe5d8;
  color-scheme: light;
}
:root[data-theme="light"] .brand .dot,
:root[data-theme="warm"] .brand .dot { box-shadow: none; }
:root[data-theme="light"] .mab-modes button.on,
:root[data-theme="light"] .mab-chip.on,
:root[data-theme="light"] .mab-viewtoggle button.on,
:root[data-theme="warm"] .mab-modes button.on,
:root[data-theme="warm"] .mab-chip.on,
:root[data-theme="warm"] .mab-viewtoggle button.on { color: var(--accent); }
:root[data-theme="light"] .slashitem.active .slashcmd,
:root[data-theme="warm"] .slashitem.active .slashcmd { color: var(--text); }
/* Varmt: stille knapper/input får litt kremtone i stedet for hvitt; primærknapp terrakotta m/ kremtekst. */
:root[data-theme="warm"] .mab-viewtoggle button.on { background: var(--accent); color: #fff7ee; }
:root[data-theme="warm"] .modepill.avenda { border-color: #b9cbb9; }

* { box-sizing: border-box; }

/* Scrollbarer: tynne, transparent spor, dempet tommel — ingen lys stripe langs kanten. */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

html, body, #root { height: 100%; margin: 0; }
/* iOS Safari: 100 % følger ikke URL-feltets dynamiske høyde — dvh gjør det (composeren blir
   aldri liggende bak hjem-indikatoren/verktøylinjen). */
@supports (height: 100dvh) {
  html, body, #root { height: 100dvh; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; height: 100%; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  -webkit-app-region: drag;
}
.brand { font-weight: 600; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.brand .tag {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; font-weight: 500;
}
.topright { display: flex; align-items: center; gap: 12px; -webkit-app-region: no-drag; }
.modelsel { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.statuspill {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.statuspill.busy { color: var(--accent); border-color: var(--accent-dim); }

/* Arbeidsmodus-bryter (topbar, per økt): 💼 jobb (fail-closed) / 🏠 privat / 🏢 Avenda (fail-closed) */
.modepill {
  font-family: var(--font-mono); font-size: 11px; border-radius: 999px; cursor: pointer;
  padding: 4px 11px; background: transparent; white-space: nowrap;
}
.modepill.jobb { color: var(--accent); border: 1px solid var(--accent-dim); }
.modepill.privat { color: var(--muted); border: 1px solid var(--line); }
/* Avenda: palett-grønn + dempet grønn kant — samme system som jobb (accent + accent-dim). */
.modepill.avenda { color: var(--green); border: 1px solid #2b5c3b; }
.modepill:hover { color: var(--text); }
.tabhidden { color: var(--muted); font-size: 11.5px; align-self: center; padding: 0 8px; white-space: nowrap; cursor: help; }
.mode-hidden { color: var(--amber); }

/* Møteopptak-knapp (topbar): ⏺ start → ⏹ REC mm:ss (rød puls) → 🎙 transkriberer → 📝 referat? */
.recwrap { display: flex; align-items: center; gap: 6px; }
.recbtn {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; cursor: pointer; white-space: nowrap;
}
.recbtn:hover { color: var(--text); border-color: var(--accent-dim); }
.recbtn.active { color: #f85149; border-color: rgba(248, 81, 73, 0.55); animation: recpulse 1.6s ease-in-out infinite; }
.recbtn.transcribing { color: var(--amber); border-color: var(--line); cursor: default; }
.recbtn.done { color: var(--green); border-color: rgba(63, 185, 80, 0.5); }
.rec-err { color: var(--amber); font-size: 12px; cursor: help; }
@keyframes recpulse { 50% { border-color: rgba(248, 81, 73, 0.15); } }

/* Tilkoblings-pill: vises kun når forbindelsen til verten ikke står (gjenkobling/frakoblet/utløpt) */
.connpill {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; white-space: nowrap;
  border: 1px solid rgba(210, 162, 74, 0.5); border-radius: 20px; padding: 4px 12px;
  color: var(--amber); background: rgba(210, 162, 74, 0.08);
}
.connpill.disconnected, .connpill.auth { color: var(--red); border-color: rgba(240, 109, 109, 0.5); background: rgba(240, 109, 109, 0.08); }
.connpill .connreload { background: transparent; border: none; color: var(--accent); padding: 0; font-size: 11px; text-decoration: underline; }

/* Server-modus-kontroll */
.server-ctl { display: flex; align-items: center; gap: 6px; position: relative; }
/* Login-lenker (mobil): popover under «Server»-knappen med kopierbare token-i-URL-lenker */
.srv-links { position: absolute; top: 100%; right: 0; margin-top: 6px; z-index: 30; width: 340px; max-width: 80vw;
  background: var(--panel-2); border: 1px solid var(--accent-dim); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 8px 24px var(--shadow); }
.srv-links-hint { color: var(--muted); font-size: 11px; line-height: 1.4; }
.srv-links-empty { color: var(--red); font-size: 11px; line-height: 1.4; }
.srv-link { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; cursor: pointer; text-align: left; }
.srv-link:hover { border-color: var(--accent); }
.srv-link-label { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.srv-link-url { color: var(--text); font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.srv-link-copy { color: var(--muted); font-size: 11px; white-space: nowrap; }
.srvbtn {
  display: flex; align-items: center; gap: 6px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 12px; font-size: 11px; font-weight: 500;
}
.srvbtn .srvdot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.srvbtn.on { color: var(--green); border-color: #2f6b39; }
.srvbtn.on .srvdot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.srverr { color: var(--red); font-size: 11px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Form-elementer */
select, input {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
}
select { cursor: pointer; }
select:disabled { opacity: 0.5; }

/* Fane-rad (én fane per arbeidsflate, farget per prosjekt) */
.tabbar {
  display: flex; align-items: flex-end; gap: 3px;
  padding: 6px 10px 0; background: var(--panel);
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tabchip {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 9px; border: 1px solid var(--line); border-bottom: none;
  border-radius: 7px 7px 0 0; background: var(--panel-2); color: var(--muted);
  cursor: pointer; max-width: 210px; flex: none;
}
.tabchip:hover { color: var(--text); }
.tabchip.active { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--pc); }
.tabdot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); flex: none; box-shadow: 0 0 6px var(--pc); }
.tabtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; max-width: 150px; }
.tabrename { font-size: 12px; padding: 1px 5px; width: 140px; }
.tabbusy {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--accent); border-top-color: transparent; animation: tabspin 0.7s linear infinite;
}
@keyframes tabspin { to { transform: rotate(360deg); } }
.tabclose { background: transparent; border: none; color: var(--muted); padding: 0 1px; font-size: 15px; line-height: 1; border-radius: 4px; }
.tabclose:hover { color: var(--red); }
.tabadd { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 5px 11px; margin-left: 2px; flex: none; align-self: center; }
.tabadd:hover { color: var(--text); border-color: var(--accent-dim); }
.tabkind { color: var(--muted); font-size: 11px; flex: none; }

/* Terminal-fane (xterm) */
.xterm-host { flex: 1; min-height: 0; padding: 6px 4px 6px 8px; background: var(--bg); overflow: hidden; }
.xterm-host .xterm { height: 100%; }

/* Prosjektbar */
.projectbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.pb-label { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; }
.pb-current { font-weight: 600; color: var(--accent); }
.pb-select { min-width: 220px; }
.pb-spacer { flex: 1; }
.projectbar .dockreopen { margin-left: 0; }
.m-sess { opacity: 0.7; }

/* Mappevelger-modal (web-modus — ingen native dialog) */
.fp-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 60; }
.fp { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 480px; max-width: 92vw; height: 70vh; max-height: 560px; display: flex; flex-direction: column; box-shadow: 0 12px 40px var(--shadow); }
.fp-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.fp-path { display: flex; gap: 6px; padding: 10px 14px 0; }
.fp-path input { flex: 1; font-family: var(--font-mono); font-size: 12px; min-width: 0; }
.fp-err { color: var(--red); font-size: 12px; padding: 8px 14px 0; }
.fp-list { flex: 1; overflow-y: auto; padding: 8px; }
.fp-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 13px; font-weight: 400; }
.fp-item:hover { background: var(--panel-2); filter: none; }
.fp-item.up { color: var(--muted); }
.fp-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.fp-cur { flex: 1; color: var(--muted); font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }

/* Tre kolonner */
.cols {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
}
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); border-bottom: 1px solid var(--line); background: var(--panel-2);
  min-height: 36px;
}
.panel-head button { text-transform: none; letter-spacing: 0; }
.ph-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gjøremål */
.tasklist { margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.view-tasks { display: flex; flex-direction: column; min-height: 0; }
.notes-rec { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.notes-rec-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
.notes-rec .rec-err { font-size: 12px; }
.tasks-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tasks-bar .ph-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.task {
  display: flex; flex-direction: column; gap: 6px;
  padding: 9px 11px; border-radius: 8px; margin-bottom: 6px;
  border: 1px solid transparent; background: var(--panel-2);
}
.task.sub { margin-left: 16px; border-left: 2px solid var(--line); border-radius: 0 8px 8px 0; background: var(--panel); }
.task.in_progress { border-color: var(--accent-dim); }
.task.done { opacity: 0.6; }
.task-row { display: flex; align-items: baseline; gap: 8px; }
.task-status { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.task.in_progress .task-status { color: var(--accent); }
.task.done .task-status { color: var(--green); }
.task-title { font-size: 13px; flex: 1; word-break: break-word; }
.task.done .task-title { text-decoration: line-through; }

.ctx-toggle {
  background: transparent; color: var(--muted); border: none; padding: 0;
  font-size: 11.5px; cursor: pointer; white-space: nowrap;
}
.ctx-toggle:hover { color: var(--accent); }

.task-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.task-actions button { padding: 3px 8px; font-size: 11.5px; }
.task-actions button.danger:hover { color: var(--red); border-color: var(--red); }

/* Resume-kontekst (kapsel) */
.ctx { display: flex; flex-direction: column; gap: 8px; padding: 8px 2px 2px; border-top: 1px dashed var(--line); }
.ctx-block { display: flex; flex-direction: column; gap: 4px; }
.ctx-label { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; }
.ctx-notes { font-size: 12px; line-height: 1.45; color: var(--text); white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; word-break: break-all;
}
.chip.mem { color: var(--amber); }
.ctx-meta { flex-direction: row; gap: 6px; flex-wrap: wrap; }

/* Oppgave-editor */
.task-editor {
  display: flex; flex-direction: column; gap: 7px;
  padding: 11px; border-radius: 8px; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--accent-dim);
}
.te-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); }
.te-input, .te-area { width: 100%; font-family: inherit; font-size: 12px; }
.te-area { resize: vertical; font-family: var(--font-mono); line-height: 1.5; }
.te-ctxtoggle { text-align: left; font-size: 11px; padding: 2px 0; }
.te-ctx { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 2px; border-top: 1px dashed var(--line); }
.te-row { display: flex; gap: 6px; }
.te-row .te-input { flex: 1; }
.te-actions { display: flex; gap: 8px; margin-top: 2px; }
.te-actions button { padding: 6px 12px; font-size: 12px; }

.controls { padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); }
button {
  font: inherit; cursor: pointer; font-size: 13px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 8px 14px; font-weight: 500; line-height: 1.2;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.4; cursor: default; filter: none; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.ghost:hover { color: var(--text); background: var(--panel-2); filter: none; }
button.sm { padding: 4px 10px; font-size: 12px; }

/* Chat / logg */
.chat.panel, .log.panel { overflow: hidden; }
.chat-head .sess { color: var(--green); font-family: var(--font-mono); font-size: 11px; margin-left: 8px; }
.log-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; font-family: var(--font-ui); font-size: 14px; line-height: 1.6; }
/* Samtalekolonne: skalerer med skjermen — 860 px-gulv (laptop), 70 vw på brede skjermer, tak 1240 px (lesbar linjelengde). */
.log-col { max-width: clamp(860px, 70vw, 1240px); margin: 0 auto; }
.log-body .fence-body, .log-body pre, .log-body code { font-family: var(--font-mono); }
.hint { color: var(--muted); font-style: italic; }
.ev { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
/* Brukerens melding: rolig boble høyrestilt (chat-mønster), maks 78 % bredde. */
.ev.user {
  color: var(--text); background: var(--user-bubble); border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px; padding: 9px 13px; margin: 18px 0 10px auto !important;
  width: fit-content; max-width: 88%; font-family: var(--font-ui); white-space: pre-wrap;
}
.ev.user .ev-you { display: none; }
.ev.divider { color: var(--muted); margin: 14px 0 4px; font-size: 12px; font-weight: 500; }
.ev.text { color: var(--text); margin: 6px 0 4px; white-space: normal; }
.ev.status { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.ev.tool { color: var(--amber); font-family: var(--font-mono); font-size: 12px; }
.ev.file { color: var(--accent); font-family: var(--font-mono); font-size: 12px; }
.ev.error { color: var(--red); background: rgba(240, 109, 109, 0.08); border: 1px solid rgba(240, 109, 109, 0.35); border-radius: 8px; padding: 7px 10px; margin: 8px 0; font-size: 13px; }
.ev.done { color: var(--green); font-weight: 600; font-family: var(--font-mono); font-size: 12px; }

/* Markdown-lite i svar */
.md-p { margin: 0; }
.md-gap { height: 0.65em; }
.md-h { font-weight: 650; margin: 12px 0 4px; line-height: 1.3; }
.md-h1 { font-size: 1.25em; } .md-h2 { font-size: 1.15em; } .md-h3 { font-size: 1.05em; } .md-h4 { font-size: 1em; color: var(--muted); }
.md-list { margin: 2px 0 4px; padding-left: 22px; }
.md-list li { margin: 1px 0; }
.md-code { font-family: var(--font-mono); font-size: 0.9em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.md-hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.ev.text a { color: var(--accent); text-decoration: none; }
.ev.text a:hover { text-decoration: underline; }

/* Aktivitetsblokk per tur (C′) — det eneste sporet av verktøykall i selve samtalen. */
.turn-act { margin: 6px 0 8px; border: 1px solid var(--line); border-radius: 10px; background: transparent; overflow: hidden; }
.turn-act-head { display: flex; align-items: center; gap: 6px; }
.turn-act-tog {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: transparent; border: 0; color: var(--muted); font-family: var(--font-mono); font-size: 12px;
  text-align: left; cursor: pointer; border-radius: 0;
}
.turn-act-tog:hover { color: var(--text); filter: none; }
.turn-act-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-act.live .turn-act-tog { color: var(--accent); }
.turn-act.live { border-color: var(--accent-dim); }
.turn-act-more { flex: none; background: transparent; border: 0; border-left: 1px solid var(--line); color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; padding: 6px 10px; border-radius: 0; cursor: pointer; }
.turn-act-more:hover { color: var(--accent); filter: none; }
.turn-act-body { border-top: 1px solid var(--line); padding: 4px 10px 6px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; background: var(--panel); }
.turn-act-body .act-body { max-height: 240px; }
.act-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: actpulse 1.4s ease-in-out infinite; flex: none; }
@keyframes actpulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .act-dot { animation: none; } }

/* Mobil-elementer (kompakt topprad + ⋯-ark) — usynlige på desktop */
.m-project, .m-more, .m-sheet, .m-sheet-overlay { display: none; }

/* Tema-knapp i topbar (mørkt → lyst → system) */
.themebtn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; width: 30px; height: 28px; padding: 0; font-size: 14px; line-height: 1; }
.themebtn:hover { color: var(--text); border-color: var(--accent-dim); filter: none; }

/* Aktivitet-fanen i panelet */
.view-activity { display: flex; flex-direction: column; min-height: 0; }
.act-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.act-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.act-list { flex: 1; overflow-y: auto; padding: 8px 10px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; }
.act-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; color: var(--muted); border-bottom: 1px solid transparent; }
.act-row.tool { display: block; }
.act-row-head { display: flex; align-items: baseline; gap: 8px; width: 100%; background: transparent; border: 0; color: var(--text); padding: 3px 0; text-align: left; font: inherit; cursor: pointer; }
.act-row-head:hover { filter: none; color: var(--accent); }
.act-ico { flex: none; width: 14px; text-align: center; color: var(--muted); }
.act-name { flex: none; font-weight: 600; }
.act-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.act-chev { flex: none; color: var(--muted); }
.act-body { margin: 2px 0 8px 22px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; white-space: pre-wrap; word-break: break-word; font-size: 11px; max-height: 360px; overflow: auto; }
.act-row.file .act-name { color: var(--accent); font-weight: 500; }
.act-row.done .act-ico, .act-row.done .act-sum { color: var(--green); }
.act-row.error .act-ico, .act-row.error .act-sum { color: var(--red); white-space: normal; }
.act-row.turn { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.act-turn { flex: none; color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.act-row.live { color: var(--accent); align-items: center; }

/* Fenced blokker i assistent-tekst → kopierbare kort (utkast/notat/kode — core/draft-blocks.mjs).
   Kopier-knappen gir REN tekst på utklippstavla: dreper «kopier fra terminal»-støyen. */
.ev.text { position: relative; padding-right: 30px; }
.ev-copy { position: absolute; top: 0; right: 0; opacity: 0; transition: opacity 0.12s; }
.ev.text:hover .ev-copy, .ev-copy:focus-within { opacity: 1; }
.ev-copy .fence-copy { padding: 2px 7px; font-size: 11px; }
.fence { white-space: normal; border: 1px solid var(--line); border-radius: 8px; margin: 7px 0; background: var(--panel-2); overflow: hidden; }
.fence-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 9px; border-bottom: 1px solid var(--line); }
.fence-label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.fence-actions { display: flex; gap: 6px; align-items: center; }
.fence-actions button { padding: 2px 9px; font-size: 11px; }
.fence-body { margin: 0; padding: 9px 11px; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; overflow-x: auto; }
.fence.utkast { border-color: var(--accent-dim); }
.fence.utkast .fence-label { color: var(--accent); }
.fence.notat .fence-label { color: var(--green); }

/* Composer (chat-input nederst i midtkolonnen) */
.composer { border-top: 1px solid var(--line); padding: 10px 14px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.chat-input {
  width: 100%; resize: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
}
.chat-input:focus { outline: none; border-color: var(--accent-dim); }
.chat-input:disabled { opacity: 0.6; }
.composer-actions { display: flex; gap: 6px; align-items: center; }
/* Én primær (Send), resten stille tekstknapper uten ramme — samme høyde (36 px), samme radius. */
.composer-actions button { height: 36px; padding: 0 16px; border-radius: 9px; font-size: 13px; }
.composer-actions button[type="submit"] { font-weight: 600; padding: 0 20px; }
.composer-actions button.ghost { border-color: transparent; color: var(--muted); }
.composer-actions button.ghost:hover, .composer-actions button.ghost.on { color: var(--text); background: var(--panel-2); border-color: transparent; }
.composer-actions .attach-btn { width: 36px; padding: 0; font-size: 15px; }
/* Stopp: nødutgangen. Rød og fylt (ikke .ghost) — den skal være det ØYET finner mens noe kjører,
   og den vises uansett bare da. Pulsen speiler at det faktisk står en kjøring bak knappen. */
.composer-actions .stopbtn {
  background: rgba(240, 109, 109, 0.14); color: var(--red);
  border: 1px solid rgba(240, 109, 109, 0.55); border-radius: 8px;
  font-weight: 600; white-space: nowrap; animation: stoppulse 1.8s ease-in-out infinite;
}
.composer-actions .stopbtn:hover { background: rgba(240, 109, 109, 0.24); color: #fff; }
@keyframes stoppulse { 50% { border-color: rgba(240, 109, 109, 0.2); } }
@media (prefers-reduced-motion: reduce) { .composer-actions .stopbtn { animation: none; } }
.composer-meta { margin-left: auto; color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; opacity: 0.85; }
/* Usage + kontekst-stripe under chatten (desktop; mobil beholder ctx-pillen i chat-headeren) */
.composer-meta .m-usage { color: var(--muted); }
.composer-meta .m-ctx { color: var(--muted); }
.composer-meta .m-ctx.warn { color: #ff8f5e; font-weight: 600; }

/* Vedlegg: chips i composeren (før send) og på brukerens tur i loggen */
.attach-row { display: flex; gap: 6px; flex-wrap: wrap; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; background: var(--bg);
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-chip.err { color: var(--red, #f85149); border-color: rgba(248, 81, 73, 0.5); }
.attach-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 1px; line-height: 1; }
.attach-x:hover { color: var(--red, #f85149); }
.ev-attach { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

/* Slash-palett (over meldingsfeltet) */
.slashmenu {
  border: 1px solid var(--accent-dim); border-radius: 8px; background: var(--panel-2);
  overflow: hidden; box-shadow: 0 -4px 16px var(--shadow);
}
.slashitem { display: flex; align-items: baseline; gap: 10px; padding: 7px 11px; cursor: pointer; }
.slashitem.active { background: var(--accent-dim); }
.slashcmd { color: var(--accent); font-family: var(--font-mono); font-size: 12px; min-width: 72px; }
.slashitem.active .slashcmd { color: #fff; }
.slashdesc { color: var(--muted); font-size: 12px; }
.slashitem.active .slashdesc { color: var(--text); }

/* Modus-bryter (read-only ↔ workspace-write) */
.modebtn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 20px; padding: 3px 11px; font-size: 11px; font-weight: 500; white-space: nowrap;
}
.modebtn:hover { color: var(--text); }
.modebtn.write {
  color: var(--amber); border-color: var(--amber);
  background: rgba(210, 162, 74, 0.12); font-weight: 600;
}
.modebtn.bypass {
  color: var(--red); border-color: var(--red);
  background: rgba(240, 109, 109, 0.14); font-weight: 600;
}
/* Tydelig markering etter tilgangsnivå */
/* Tilgangsnivå signaliseres av modebtn-pillen (farge + symbol) — ingen striper over composeren.
   Mobil har ikke pillen synlig → ring på ⋯ + svak tint på skrivefeltet (se mobil-blokken). */
.composer.write, .composer.bypass { border-top-color: var(--line); box-shadow: none; }
.composer-actions button.debate { color: var(--accent); border-color: var(--accent-dim); }
.recipesel { font-size: 11px; padding: 4px 6px; }

/* Orkestrerings-kort (debatt → dommer), inline i samtalen */
.orch {
  margin: 12px 0; border: 1px solid var(--accent-dim); border-radius: 10px;
  background: var(--panel-2); overflow: hidden; font-family: -apple-system, sans-serif;
}
.orch-head {
  padding: 9px 12px; background: rgba(76, 141, 255, 0.1); color: var(--accent);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--line);
}
.orch-role { border-bottom: 1px solid var(--line); }
.orch-roletog {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text); padding: 8px 12px; font-size: 12.5px;
}
.orch-roletog:hover { background: var(--panel); }
.orch-rolename { flex: 1; }
.orch-expand { color: var(--muted); font-size: 11px; }
.orch-state { font-family: var(--font-mono); font-size: 12px; width: 14px; text-align: center; }
.orch-state.running { color: var(--accent); }
.orch-state.done { color: var(--green); }
.orch-state.failed, .orch-state.timeout { color: var(--red); }
.orch-state.pending { color: var(--muted); }
.orch-roletext {
  padding: 8px 14px 12px 35px; color: var(--muted); font-family: var(--font-mono);
  font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  border-top: 1px dashed var(--line);
}
.orch-judge { background: rgba(63, 185, 80, 0.06); }
.orch-judge-head {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  color: var(--green); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.orch-judge-text {
  padding: 0 14px 12px 35px; color: var(--text); font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}

/* Multi-agent-popover (åpnes fra «Flere: N ▾» i composeren) */
.mab-trigger.on { color: var(--accent); border-color: var(--accent-dim); }
.mab-pop {
  border: 1px solid var(--accent-dim); border-radius: 10px; background: var(--panel-2);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 -4px 16px var(--shadow);
}
/* Fanebryter for panelets hovedmodus (Konsultasjon | Oppdrag). Samme segmenterte mønster som
   .mab-viewtoggle, men større/tydeligere og full bredde — dette er hovedvalget, ikke en detalj. */
.mab-modes { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mab-modes button {
  flex: 1 1 0; background: transparent; color: var(--muted); border: none; border-radius: 0;
  padding: 7px 12px; font-size: 12px; font-weight: 600;
}
.mab-modes button + button { border-left: 1px solid var(--line); }
.mab-modes button.on { background: var(--accent-dim); color: #fff; }
.mab-pop-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mab-pop-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.mab-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.mab-chip { background: var(--bg); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 3px 9px; font-size: 11.5px; }
.mab-chip.on { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
.mab-presets { display: flex; align-items: center; gap: 5px; }
.mab-master-sel { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; margin-left: auto; }
.mab-master-sel select { font-size: 11px; padding: 3px 5px; }
.mab-pop-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.mab-cost { color: var(--muted); font-size: 11px; margin-right: auto; }
/* Visnings-bryter «Se alle / Syntese» (segmentert) + primær «Kjør med flere» */
.mab-viewtoggle { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.mab-viewtoggle button { background: transparent; color: var(--muted); border: none; border-radius: 0; padding: 5px 11px; font-size: 11px; font-weight: 500; }
.mab-viewtoggle button + button { border-left: 1px solid var(--line); }
.mab-viewtoggle button.on { background: var(--accent-dim); color: #fff; }
.mab-run { font-size: 12px; padding: 7px 14px; }

/* Multi-agent-kort (kringkast → kolonner / debatt-konklusjon) */
.mab { margin: 12px 0; border: 1px solid var(--accent-dim); border-radius: 10px; background: var(--panel-2); overflow: hidden; font-family: -apple-system, sans-serif; }
.mab-head { padding: 9px 12px; background: rgba(76, 141, 255, 0.1); color: var(--accent); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--line); }
.mab-toggle { padding: 7px 12px; font-size: 11px; }
.mab-cols { display: flex; gap: 1px; background: var(--line); border-top: 1px solid var(--line); overflow-x: auto; }
.mab-col { flex: 1 1 0; min-width: 170px; background: var(--panel-2); padding: 9px 11px; display: flex; flex-direction: column; gap: 6px; }
.mab-col-head { font-size: 12px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.mab-col-text { font-size: 12px; line-height: 1.5; color: var(--muted); white-space: pre-wrap; word-break: break-word; flex: 1; }
.mab-col-actions { display: flex; flex-wrap: wrap; gap: 5px; align-self: flex-start; }
.mab-continue { color: var(--accent); border-color: var(--accent-dim); }
.mab-masterbtn { margin: 10px 12px; }
.mab-master-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
/* Fold-in = den grønne «commit til master»-handlingen (matcher fold-gate-temaet). Solid grønn med
   mørk tekst → høy kontrast (tidligere: grønn tekst på blå primary-bakgrunn = uleselig). */
.mab-fold { background: var(--green); color: var(--bg); border: none; font-weight: 600; }

/* Fold-gate: godkjennings-port (rediger-før-commit) over composer */
.fold-gate { margin: 0 12px 8px; padding: 10px; border: 1px solid rgba(63, 185, 80, 0.4); border-radius: 8px; background: rgba(63, 185, 80, 0.06); display: flex; flex-direction: column; gap: 8px; }
.fold-gate-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--green); font-weight: 600; }
.fold-gate-hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.fold-gate-caveat { font-size: 12px; color: #e3b341; background: rgba(227, 179, 65, 0.1); border: 1px solid rgba(227, 179, 65, 0.35); border-radius: 6px; padding: 6px 8px; }
.fold-gate-text { width: 100%; resize: vertical; font: inherit; font-size: 12px; line-height: 1.5; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; box-sizing: border-box; }
.fold-gate-actions { display: flex; gap: 6px; }

/* Kontekst-rollover: terskel-banner over composer (amber = varsel, ikke feil) */
.handoff-banner { margin: 0 12px 8px; padding: 8px 10px; border: 1px solid rgba(210, 162, 74, 0.5); border-radius: 8px; background: rgba(210, 162, 74, 0.08); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--text); }
.handoff-banner .handoff-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mab-master .mab-continue { display: inline-block; margin-top: 8px; color: var(--green); border-color: rgba(63, 185, 80, 0.4); }
.mab-master-actions .mab-continue { margin-top: 0; }
.mab-master { background: rgba(63, 185, 80, 0.06); border-top: 1px solid var(--line); padding: 10px 12px; }
.mab-master-head { color: var(--green); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.mab-master-text { color: var(--text); font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* YOLO-milepæl-kort (kloss 1): fase-FSM med status per fase + maskinlesbar verdict */
.ms { margin: 12px 0; border: 1px solid var(--accent-dim); border-radius: 10px; background: var(--panel-2); overflow: hidden; font-family: -apple-system, sans-serif; }
.ms-head { padding: 9px 12px; background: rgba(76, 141, 255, 0.1); color: var(--text); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.ms-goal { padding: 8px 12px 4px; font-size: 12.5px; color: var(--text); line-height: 1.5; }
.ms-phases { padding: 6px 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.ms-phase { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.ms-phase-name { color: var(--text); min-width: 200px; }
.ms-phase-meta { color: var(--muted); font-size: 11px; }
.ms-ui-check { margin-left: 22px; padding: 3px 8px; font-size: 11px; color: var(--muted); border-left: 2px solid var(--line); word-break: break-all; }
.ms-ui-check b { color: var(--warn, #e3b341); }
/* Rådgivende visuell vurdering (skive 2) — aldri gate, tydelig merket */
.ms-advice { margin-left: 22px; padding: 4px 8px; border-left: 2px solid var(--accent); }
.ms-advice-tag { display: inline-block; font-size: 11px; letter-spacing: 0.4px; color: var(--accent); margin-bottom: 3px; }
.ms-advice-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 11px; line-height: 1.5; color: var(--muted); font-family: var(--font-mono); max-height: 180px; overflow-y: auto; }
.ms-verdict { border-top: 1px solid var(--line); padding: 9px 12px; font-size: 12px; line-height: 1.5; }
.ms-verdict.done { background: rgba(63, 185, 80, 0.08); }
.ms-verdict.failed { background: rgba(248, 81, 73, 0.08); }
.ms-verdict.timeout { background: rgba(227, 179, 65, 0.08); }
.ms-verdict-line { color: var(--text); }
.ms-findings { margin: 6px 0 0; padding-left: 4px; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.ms-findings li { font-size: 12px; color: var(--muted); }
.ms-sev { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; margin-right: 5px; }
.ms-sev.critical { background: rgba(248, 81, 73, 0.2); color: var(--red); }
.ms-sev.high { background: rgba(227, 179, 65, 0.2); color: #e3b341; }
.ms-sev.med, .ms-sev.low { background: var(--line); color: var(--muted); }
.ms-verdict-hint { margin-top: 6px; font-size: 11px; color: var(--muted); }
.ms-verdict-hint code { font-family: var(--font-mono); font-size: 11.5px; background: var(--bg); padding: 1px 4px; border-radius: 4px; word-break: break-all; }

/* Retry-loop (kloss 2): forsøks-badge i hodet, divider mellom forsøk, plateau-varsel */
.ms-attempts { margin-left: auto; font-size: 11px; font-weight: 700; color: #e3b341; background: rgba(227, 179, 65, 0.16); padding: 1px 6px; border-radius: 4px; text-transform: none; letter-spacing: 0; }
/* P1: signert revisjonsspor-badge (samme pille-mønster som .ms-attempts). */
.ledger-badge { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.ledger-badge.ok { color: var(--green); background: rgba(63, 185, 80, 0.15); }
.ledger-badge.warn { color: #e3b341; background: rgba(227, 179, 65, 0.16); }
.ledger-badge.bad { color: var(--red, #f85149); background: rgba(240, 109, 109, 0.16); }
.ledger-badge.unsigned { color: var(--muted); background: none; font-weight: 600; }
/* Kompaktvariant (ConsultView-rader): kun ikonet, à la .consult-badge. */
.ledger-badge.compact { flex: none; width: 16px; padding: 0; text-align: center; background: none; font-size: 12px; }
/* I .ms-head skal badgen ligge til høyre SAMMEN med .ms-attempts: badgen tar auto-margen når den
   finnes (to auto-marger ville ellers delt friplassen og sentrert badgen), og .ms-attempts nuller
   sin — mangler badgen (gamle kjøringer uten ledger) beholder .ms-attempts sin egen auto-marg. */
.ms-head .ledger-badge { margin-left: auto; }
.ms-head .ledger-badge ~ .ms-attempts { margin-left: 0; }
.ms-retry { margin: 4px 0 2px; padding: 4px 0 3px; border-top: 1px dashed var(--line); }
.ms-retry-head { font-size: 11px; color: #e3b341; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ms-retry-toggle { font-size: 11.5px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0; }
.ms-retry-fb { margin: 4px 0 0; padding: 6px 8px; background: var(--bg); border-radius: 5px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; }
.ms-plateau { margin-top: 6px; font-size: 12px; color: #e3b341; }

/* Autopilot (kloss 4): produkt-kort = kjede-oversikt (plan + per-milepæl-status + commits) */
.ms.prod { border-color: rgba(163, 113, 247, 0.5); }
.ms.prod .ms-head { background: rgba(163, 113, 247, 0.12); }
.prod-degraded { padding: 2px 12px 4px; }
/* Regresjons-baseline (kloss 5): grønn = voktet, amber = uvoktet (ingen/ukjent testsuite) */
.prod-baseline { padding: 3px 12px 4px; }
.prod-baseline.clean { color: #3fb950; }
.prod-baseline.unguarded { color: #e3b341; }
.prod-plan { margin: 4px 0 6px; padding: 4px 12px 8px; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.prod-ms { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text); }
.prod-ms.active .prod-ms-title { font-weight: 600; }
.prod-ms.pending .prod-ms-title { color: var(--muted); }
/* Bounded replan (kloss 6): droppet/splittet rad beholdes synlig (gjennomstreket), split-deler innrykket */
.prod-ms.dropped .prod-ms-title, .prod-ms.split .prod-ms-title { text-decoration: line-through; color: var(--muted); }
.prod-ms.part { padding-left: 14px; }
.prod-replan { padding: 3px 12px 4px; }
.prod-replan.accepted { color: #e3b341; }
.prod-replan.rejected { color: var(--muted); }
.prod-ms-title { flex: 0 1 auto; }
.prod-sha { font-family: var(--font-mono); font-size: 11px; background: var(--bg); color: var(--muted); padding: 1px 5px; border-radius: 4px; }

/* Mastermind-oppdrag: kunnskapsarbeid-søsteren til milepælen (mastermind planlegger/dømmer/
   syntetiserer, utfører graver). Egen farge (cyan) så de tre FSM-kortene skilles på ett blikk:
   blå = milepæl, lilla = autopilot, cyan = oppdrag. */
.ms.opp { border-color: rgba(57, 197, 207, 0.5); }
.ms.opp .ms-head { background: rgba(57, 197, 207, 0.12); flex-wrap: wrap; }
.opp-flow { text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--muted); font-weight: 600; }
.opp-answered { color: #39c5cf; background: rgba(57, 197, 207, 0.16); }
/* Self-preference-bias-varsel: informerer, blokkerer aldri (brukeren kan ha valgt det bevisst). */
.opp-samefamily { margin: 4px 12px 2px; padding: 4px 8px; border-radius: 6px; font-size: 12px; color: #e3b341; background: rgba(227, 179, 65, 0.1); border: 1px solid rgba(227, 179, 65, 0.3); }
.opp-degraded { padding: 2px 12px 4px; }
.opp-who { min-width: 62px; }
.opp-subs { margin: 0 0 8px; padding: 0 12px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.opp-sub { font-size: 12px; color: var(--text); }
.opp-sub-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.opp-sub-title { flex: 1 1 160px; min-width: 0; word-break: break-word; }
.opp-chip { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; white-space: nowrap; background: var(--line); color: var(--muted); }
.opp-chip.done { color: var(--green); background: rgba(63, 185, 80, 0.15); }
.opp-chip.failed { color: var(--red); background: rgba(240, 109, 109, 0.16); }
.opp-chip.running { color: var(--accent); background: rgba(76, 141, 255, 0.16); }
.opp-chip.timeout, .opp-chip.attempt { color: #e3b341; background: rgba(227, 179, 65, 0.16); }
.opp-fb-toggle { margin-left: 22px; font-size: 11.5px; }
.opp-fb { margin-left: 22px; }
/* Syntesen rendres av TextRow (samme renderer som svartekst i tråden) — kun plassering her. */
.opp-synth { margin-top: 6px; }
/* Rolle-velgerne i «Flere»-panelets Oppdrag-fane: samme stil/størrelse som master-selecten, men
   uten dens auto-marg (den ville dyttet de to feltene fra hverandre). Ingen topp-skillelinje mer —
   fanen ER skillet, raden ligger nå rett under forklaringslinja. */
.mab-pop-row.opp-roles { gap: 12px; }
.mab-master-sel.opp-sel { margin-left: 0; }
.opp-pane-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.opp-pane-warn { margin: 0; color: #e3b341; font-size: 11px; line-height: 1.4; }

/* DoD-quorum (kloss 3): akseptkriterier + per-kriterium ✓/✗ fra dommeren */
.ms-dod { margin: 2px 12px 6px; border: 1px solid var(--line); border-radius: 7px; background: rgba(76, 141, 255, 0.05); }
.ms-dod-head { width: 100%; text-align: left; padding: 6px 9px; font-size: 12px; color: var(--text); background: none; border: none; cursor: pointer; }
.ms-dod-body { padding: 0 9px 8px; }
.ms-dod-goal { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 5px; }
.ms-dod-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.ms-dod-item { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--text); }
.ms-dod-mark { font-weight: 700; width: 12px; flex: none; }
.ms-dod-item.met .ms-dod-mark { color: var(--green, #3fb950); }
.ms-dod-item.unmet .ms-dod-mark { color: var(--red); }
.ms-dod-item.pending { color: var(--muted); }
.ms-dod-item.pending .ms-dod-mark { color: var(--muted); }
.ms-dod-id { font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex: none; }
.ms-dod-text { color: inherit; }

/* Apply-til-hovedtre: menneske-styrt port — legg en bestått milepæls isolerte endringer på hovedtreet */
.ms-apply { margin-top: 8px; }
.ms-apply-btn { margin-top: 7px; background: var(--green); color: var(--bg); border: none; font-weight: 600; padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.ms-apply-btn:hover:not(:disabled) { filter: brightness(1.08); }
.ms-apply-btn:disabled { opacity: 0.6; cursor: default; }
/* To-stegs apply: armert knapp = bekreftelses-steget (klikk 2 utfører; blur disarmerer) */
.ms-apply-btn.armed.clean { box-shadow: 0 0 0 2px var(--green); outline: 2px solid var(--bg); outline-offset: -2px; }
.ms-apply-btn.armed.threeway { background: #e3b341; box-shadow: 0 0 0 2px #e3b341; outline: 2px solid var(--bg); outline-offset: -2px; }
.ms-apply-actions .ms-apply-res { flex-basis: 100%; margin-top: 0; }
.ms-apply-res { margin-top: 4px; font-size: 12px; line-height: 1.5; color: var(--text); }
.ms-apply-res.done { color: var(--green); }
.ms-apply-res.conflict { color: #e3b341; }
.ms-apply-res.failed { color: var(--red); }
.ms-apply-res code { font-family: var(--font-mono); font-size: 11.5px; background: var(--bg); padding: 1px 4px; border-radius: 4px; word-break: break-all; }

/* Diff-viewer: review NØYAKTIG hva Apply legger på hovedtreet, før du trykker */
.ms-apply-actions { display: flex; gap: 8px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.ms-diff-btn { font-size: 12px; }
.ms-diff { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.ms-diff-msg { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.ms-diff-msg.err { color: var(--red); }
.ms-diff-banner { padding: 6px 12px; font-size: 11px; font-weight: 600; border-bottom: 1px solid var(--line); }
.ms-diff-banner.clean { color: var(--green); background: rgba(63, 185, 80, 0.08); }
.ms-diff-banner.threeway { color: #e3b341; background: rgba(227, 179, 65, 0.08); }
.ms-diff-body { margin: 0; padding: 6px 0; max-height: 320px; overflow: auto; font-family: var(--font-mono); font-size: 11px; line-height: 1.45; white-space: pre; }
.ms-diff-body .dl { padding: 0 12px; }
.ms-diff-body .dl.add { background: rgba(63, 185, 80, 0.12); color: #56d364; }
.ms-diff-body .dl.del { background: rgba(248, 81, 73, 0.12); color: #f85149; }
.ms-diff-body .dl.hunk { color: #79c0ff; background: rgba(56, 139, 253, 0.08); }
.ms-diff-body .dl.meta { color: var(--muted); }
.ms-diff-trunc { padding: 6px 12px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

/* Subagent-tre: én headless agent sine interne `Agent`-subagenter, status per subagent (FleetView) */
.subs { margin: 6px 0 8px; font-family: var(--font-ui); }
.subs-head { text-transform: none; letter-spacing: 0; }
.subs-ico { color: var(--muted); flex: none; }
.subs-list { display: flex; flex-direction: column; padding: 0; }
.subrow-live { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subrow { padding: 7px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.subrow:last-child { border-bottom: none; }
.subrow.running { background: rgba(76, 141, 255, 0.05); }
.subrow.failed { background: rgba(248, 81, 73, 0.06); }
.subrow-head { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.subrow-type { color: var(--accent); font-weight: 600; font-size: 11px; white-space: nowrap; }
.subrow-desc { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.subrow-tok { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.subrow-live { color: var(--muted); font-size: 12px; padding-left: 21px; font-style: italic; }
.subrow-toggle { font-size: 11.5px; padding: 1px 0 1px 21px; align-self: flex-start; }
.subrow-acts { padding-left: 21px; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.subact { font-size: 12px; color: var(--muted); font-family: var(--font-mono); white-space: pre-wrap; word-break: break-word; }

/* Agent-plan-kort (TodoWrite → avkrysning → gjøremål / sekvensiell kjøring) */
.todocap { margin: 10px 0; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); overflow: hidden; font-family: -apple-system, sans-serif; }
.todocap.latest { border-color: var(--accent-dim); }
.todocap-head { display: block; width: 100%; text-align: left; padding: 8px 12px; font-size: 12px; }
.todocap.latest .todocap-head { color: var(--accent); }
.todocap-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.todocap-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 12px; background: var(--panel-2); font-size: 12.5px; line-height: 1.45; color: var(--text); cursor: pointer; }
.todocap-item input { margin-top: 2px; flex: none; }
.todocap-badge { color: var(--muted); }
.todocap-item.in_progress .todocap-badge { color: var(--accent); }
.todocap-item.completed .todocap-badge { color: var(--green); }
.todocap-item.completed .todocap-text { color: var(--muted); text-decoration: line-through; }
.todocap-text { flex: 1; word-break: break-word; }
.todocap-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px dashed var(--line); }
.todocap-count { color: var(--muted); font-size: 11px; margin-right: auto; }
.todocap-run { color: var(--accent); border-color: var(--accent-dim); }

/* Dock (høyre, kollapsbar) */
.dock { overflow: hidden; }
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 6px; padding: 4px 10px; font-size: 11px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--accent); border-color: var(--accent-dim); }
.collapse { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 9px; font-size: 13px; }
.dockreopen { margin-left: auto; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hint.pad { padding: 14px; }
.subbar { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.subbar input { flex: 1; font-family: var(--font-mono); font-size: 11px; }
.webview { flex: 1; border: none; background: #fff; }

/* Prosjekt-info */
.proj-info { overflow-y: auto; padding: 14px; }
.proj-info h3 { margin: 0 0 12px; font-size: 15px; color: var(--text); }
.kv { display: flex; gap: 10px; margin-bottom: 7px; font-size: 12px; align-items: baseline; }
.kv > span { color: var(--muted); min-width: 54px; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.kv code { color: var(--text); font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.kv-label { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; margin: 16px 0 8px; }
.scripts { display: flex; flex-direction: column; gap: 5px; }
.script { display: flex; gap: 10px; align-items: baseline; }
.script .sk { color: var(--accent); font-family: var(--font-mono); font-size: 12px; min-width: 90px; }
.script .sv { color: var(--muted); font-family: var(--font-mono); font-size: 11px; word-break: break-all; }
.readme {
  white-space: pre-wrap; word-break: break-word; color: var(--muted); font-family: var(--font-mono);
  font-size: 11px; line-height: 1.5; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; margin: 0;
}

/* Gjøremåls-oversikt på tvers av prosjekter (dock-fanen «Gjøremål») */
.overview-view { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.overview-filters { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.overview-filters .chip {
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 11px; cursor: pointer;
}
.overview-filters .chip.on { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.chip-sep { width: 6px; }
.overview-sub { font-size: 11.5px; color: var(--muted); }
.overview-group { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.overview-ghead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.overview-gname { font-size: 12px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overview-ghead .chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); cursor: pointer; }
.overview-ghead .chip.jobb { color: var(--amber, #e3b341); border-color: var(--amber, #e3b341); }
.overview-ghead .chip.privat { color: var(--green, #3fb950); border-color: var(--green, #3fb950); }
.overview-gcount { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.overview-task {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  background: none; border: none; border-top: 1px solid var(--line); padding: 6px 2px;
  color: var(--text); font-size: 12px; cursor: pointer;
}
.overview-task:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.overview-task:disabled { opacity: 0.5; cursor: default; }
.overview-task.done { color: var(--muted); text-decoration: line-through; }
.overview-task.in_progress .overview-mark { color: var(--amber, #e3b341); }
.overview-mark { font-family: var(--font-mono); flex-shrink: 0; }
.overview-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overview-tag, .task-tag { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.overview-run { color: var(--accent); flex-shrink: 0; }
.overview-empty { font-size: 12px; color: var(--muted); padding: 12px 2px; }
.te-tag { cursor: pointer; }

/* Notater */
.view-notes { padding: 10px; gap: 8px; }
.notes {
  flex: 1; width: 100%; resize: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
}
/* Møtenotater → chat: handlingsrad under notatflaten */
.notes-actions { display: flex; gap: 8px; align-items: center; }
.notes-action-sel {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 12px;
}
.notes-send, .notes-clear { white-space: nowrap; }
/* Forslag etter dokumentasjons-kjøring: tøm flaten? (mennesket avgjør) */
.notes-suggest {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--text); background: var(--bg);
}
.notes-suggest span { flex: 1; min-width: 0; }

/* Bruk-fane (usage + kontekst) */
.usage-view { overflow-y: auto; padding: 14px; }
.ctx-meter { margin: 6px 0 16px; }
.ctx-bar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ctx-fill { height: 100%; background: var(--accent); transition: width 0.3s; }
.ctx-num { color: var(--muted); font-family: var(--font-mono); font-size: 11px; margin-top: 5px; }
.usage-row { display: flex; flex-direction: column; gap: 2px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.usage-model { font-size: 12.5px; color: var(--text); }
.usage-nums { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.usage-total { margin-top: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--green); }
.usage-note { margin-top: 14px; font-size: 11.5px; line-height: 1.5; }
.sess.ctx { color: var(--amber); margin-left: 6px; }
/* Over rollover-terskelen: pillen skifter til rød-oransje (matcher handoff-banneret). */
.sess.ctx.warn { color: #ff8f5e; font-weight: 600; }

/* Konsultasjons-historikk (durable ledger) */
.consult-view { overflow-y: auto; padding: 10px; }
.consult-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.consult-head .kv-label { margin: 6px 0 8px; }

/* Økter (host-registeret): åpne + avsluttede chat-faner på tvers av enheter */
.sess-row { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 7px; }
.sess-row.closed { opacity: 0.75; }
.sess-dot { flex: 0 0 auto; font-size: 11px; line-height: 1.7; }
.sess-dot.open { color: #3fb950; }
.sess-dot.closed { color: var(--muted); }
.sess-main { flex: 1 1 auto; min-width: 0; }
.sess-title { font-size: 12.5px; color: var(--text); font-weight: 500; }
.sess-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sess-snippet { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
.sess-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.sess-actions .ghost.sm { font-size: 11px; padding: 2px 8px; }
.sess-danger { color: #ff6b6b; border-color: rgba(248, 81, 73, 0.5); }

/* «Rydd agent-prosesser»: prosesser med cwd i prosjektmappene — menneske-styrt opprydding */
.procs-view { overflow-y: auto; }
.procs-note { margin-bottom: 6px; }
.procs-err { color: var(--red, #f85149); font-size: 12px; margin: 0 0 7px; }
.proc-row { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 7px; }
.proc-row.own { border-style: dashed; opacity: 0.85; }
.proc-main { flex: 1 1 auto; min-width: 0; }
.proc-title { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.proc-pid { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.proc-ports { font-size: 11.5px; color: #e3b341; border: 1px solid rgba(227, 179, 65, 0.4); border-radius: 5px; padding: 0 5px; }
.proc-own { font-size: 11.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 5px; padding: 0 5px; }
.proc-meta { font-size: 11px; color: var(--muted); margin-top: 1px; word-break: break-all; }
.proc-cmd { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proc-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; }
.proc-actions .ghost.sm { font-size: 11px; padding: 2px 8px; }
.consult-round { border: 1px solid var(--line); border-radius: 7px; margin-bottom: 7px; overflow: hidden; }
.consult-round-head { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 10px; cursor: pointer; color: var(--text); }
.consult-round-head:hover { background: rgba(255, 255, 255, 0.03); }
.consult-badge { flex: none; width: 16px; text-align: center; font-size: 12px; }
.consult-badge.folded, .consult-badge.done { color: var(--green); }
.consult-badge.partial { color: #e3b341; }
.consult-badge.failed { color: var(--red, #f85149); }
.consult-badge.running { color: var(--accent); }
.consult-brief { flex: 1; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.consult-meta { flex: none; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.consult-body { padding: 8px 10px; border-top: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.consult-answer, .consult-synth { display: flex; flex-direction: column; gap: 4px; }
.consult-synth { border-top: 1px dashed var(--line); padding-top: 8px; }
.consult-answer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.consult-answer-text { font-size: 12px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto; }

/* ============================================================================
   MOBIL (iPhone — smale skjermer, samme breakpoint som useIsMobile i App.jsx).
   Prinsipp: chat er HELE flaten; Gjøremål-panelet og docken blir fullskjerms-ark
   (position:fixed) over chatten med egne lukk-knapper (⟨ / ⟩ finnes fra før).
   display:flex på .cols nøytraliserer den inline grid-template-columns-stilen
   (gjelder kun grid).

   Vertikal plass er den knappe ressursen: med tastaturet oppe har en iPhone 17
   Pro Max ~530 px synlig høyde, så alt de fire faste radene (topbar/faner/
   prosjektbar/panelhode) + composeren tar, går rett fra samtalen. Målt 2026-07-30
   i emulert 440×956: 388 px fast chrome → 305 px, dvs. chatten vokste fra 27 %
   til 42 % av skjermen med tastaturet oppe.
   ========================================================================== */
@media (max-width: 760px) {
  /* iOS auto-zoomer inn på felt med font < 16px — hold alle skriveflater på 16px. */
  select, input, textarea { font-size: 16px; }

  /* Topbar: komprimer — MVP-tag og feltetiketter vekk, selects deler bredden. */
  .topbar { padding: calc(5px + env(safe-area-inset-top)) 10px 5px; gap: 6px; }
  .brand { font-size: 12px; gap: 6px; }
  .brand .tag { display: none; }
  .topright { gap: 6px; flex: 1; min-width: 0; justify-content: flex-end; }
  /* Selectene må KRYMPE, ikke ha fast bredde: .topright er flex-end, så når
     innholdet ikke får plass renner overskuddet ut VENSTRE skjermkant — og
     topbaren har ingen scroll, så dropdownen blir permanent uleselig.
     min-width:0 + flex:1 1 0 gjør at de truncater i stedet for å klippes bort. */
  .modelsel { gap: 0; flex: 1 1 0; min-width: 0; }
  .modelsel-label { display: none; }
  .modelsel select { max-width: none; width: 100%; min-width: 0; padding: 6px; }
  .modepill, .recwrap, .recbtn, .server-ctl { flex: none; }
  .modepill, .recbtn { min-height: 34px; }
  /* «⏺ Møteopptak» → bare ⏺. Ordet kostet ~75 px av de ~200 som skulle deles mellom modell- og
     effort-feltet; tilstanden leses uansett av fargen (rød puls = tar opp). REC-teller og
     «transkriberer»/«referat?» beholder teksten — de er transiente og bærer faktisk informasjon. */
  .recbtn-label, .modepill-label { display: none; }
  .statuspill { max-width: 92px; padding: 5px 9px; }
  .connpill { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

  /* ÉN kompakt topprad: prosjekt ▾ · modell ▾ · (status) · ⋯ — effort/tema/modus/opptak bor i ⋯-arket.
     Prosjektbar og samtale-hode (Oppgaver/ctx/tilgang/Vis panel) er borte på mobil: alt i arket. */
  .effortsel, .themebtn, .modepill, .recwrap, .projectbar, .chat-head, .m-hide, .ev-copy { display: none !important; }
  .m-project {
    display: block; flex: 1 1 0; min-width: 0; padding: 6px 8px; font-size: 16px;
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: inset 3px 0 0 var(--pc, var(--accent));
  }
  .m-more {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 40px; min-height: 36px; border-radius: 10px; padding: 0; font-size: 20px; line-height: 1;
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  }
  /* Tilgangsnivået synes som ring på ⋯ (write = gul, full = rød) — ett signal, ikke tre. */
  .m-more.write { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
  .m-more.bypass { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); color: var(--red); }
  main.panel.chat { box-shadow: none !important; }
  .composer.write .chat-input { border-color: rgba(210, 162, 74, 0.4); }
  .composer.bypass .chat-input { border-color: rgba(240, 109, 109, 0.45); }

  /* ⋯-arket (bottom sheet) */
  .m-sheet-overlay { display: block; position: fixed; inset: 0; background: var(--shadow); z-index: 80; }
  .m-sheet {
    display: flex; flex-direction: column; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 81;
    background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px var(--shadow);
  }
  .m-sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 2px; }
  .m-sheet-info { font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: center; }
  .m-sheet-info .warn { color: #ff8f5e; font-weight: 600; }
  .m-sheet-row { display: flex; gap: 8px; }
  .m-sheet-row > * { flex: 1 1 0; min-width: 0; }
  .m-sheet-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
  .m-sheet-field select { flex: 1; min-width: 0; padding: 8px; }
  .m-sheet .m-sheet-btn { display: flex !important; align-items: center; justify-content: center; min-height: 42px; font-size: 13.5px; border-radius: 10px; }
  .m-sheet .modepill, .m-sheet .modebtn, .m-sheet .recbtn { text-transform: none; letter-spacing: 0; }
  .m-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .m-sheet-close { min-height: 42px; border-radius: 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

  /* Fane-rad: touch-vennlige chips med snap-scroll. «+» og «N skjult» er KLEBRIGE
     i høyre kant — ellers ligger «ny fane» bak hele fane-scrollingen. */
  .tabbar { -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 5px 8px 0; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabchip { padding: 4px 10px; max-width: 170px; }
  .tabtitle { max-width: 110px; }
  .tabclose {
    min-width: 28px; min-height: 28px; font-size: 17px; padding: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .tabadd, .tabhidden {
    position: sticky; z-index: 2; background: var(--panel);
    box-shadow: 0 0 0 12px var(--panel);
  }
  .tabadd { right: 0; min-height: 34px; padding: 6px 13px; }
  .tabhidden { right: 42px; }

  /* Prosjektbar: dropdownen SIER prosjektnavnet og fane-chipen sier det igjen —
     etikett + duplikat-navn er ren høyde. Full sti skjules som før. */
  .projectbar { flex-wrap: wrap; gap: 8px; padding: 5px 10px; }
  .pb-label, .pb-current { display: none; }
  .pb-select { min-width: 0; flex: 1 1 140px; }
  .projectbar .ghost.sm { min-height: 34px; }

  /* Ett-kolonne-layout: chat fyller alt; sidepaneler blir fullskjerms-ark. */
  .cols { display: flex; flex-direction: column; }
  .panel.chat { flex: 1; min-height: 0; }
  .panel.tasks, .panel.dock {
    position: fixed; inset: 0; z-index: 70;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-shadow: 0 0 40px var(--shadow);
  }

  /* Panelhode: sesjons-ID hører hjemme i Økter-panelet, ikke i en fast rad på
     mobil. Kontekst-pillen (.sess.ctx) blir — den er hele rollover-varselet. */
  .panel-head { padding: 5px 10px; min-height: 0; }
  .panel-head .sess:not(.ctx) { display: none; }
  .panel-head .ghost.sm, .panel-head .modebtn { min-height: 34px; }
  .collapse { padding: 7px 16px; font-size: 16px; min-height: 36px; min-width: 42px; }
  .dock-head .tabs { overflow-x: auto; scrollbar-width: none; }
  .dock-head .tabs::-webkit-scrollbar { display: none; }
  .dock-head .tab { padding: 8px 11px; white-space: nowrap; min-height: 38px; }

  /* Chat-loggen: litt tettere padding, rolig overscroll (ingen kjede-scroll bak). */
  .log-body { padding: 10px; overscroll-behavior: contain; }
  .ev.user { max-width: 96%; }
  .turn-act { border: 0; border-radius: 0; margin: 2px 0 6px; }
  .turn-act.live { border: 0; }
  .turn-act-tog { padding: 4px 0; }
  .turn-act-tog::before { content: '⚙'; opacity: 0.7; }
  .turn-act.live .turn-act-tog::before { content: none; }
  .turn-act-more { display: none; }
  .turn-act-body { border: 1px solid var(--line); border-radius: 8px; margin-top: 2px; }
  .turn-act-body .act-body { max-height: 180px; }
  /* Fanestripen: myk fade i venstre kant hinter om at den scroller. */
  .tabbar { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px); mask-image: linear-gradient(90deg, transparent 0, #000 14px); }

  /* Kopier-knappen: ingen hover på touch → alltid svakt synlig, touch-vennlig mål. */
  .ev-copy { opacity: 0.55; }
  .fence-actions button, .ev-copy .fence-copy { min-height: 34px; }
  .ctx-toggle { min-height: 30px; }

  /* Composer: ÉN vannrett scrollbar knapperad. Wrap ga to–tre rader (104 px) på
     en flate der 530 px er alt du har med tastaturet oppe. Meta-linja er kuttet —
     modell og effort står allerede i topbarens to selects. */
  .composer { padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .chat-input { font-size: 16px; padding: 9px 11px; }
  .composer-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .composer-actions::-webkit-scrollbar { display: none; }
  .composer-actions button { min-height: 40px; padding: 8px 13px; flex: none; }
  .composer-actions .attach-btn { padding: 8px 11px; }
  .composer-meta { display: none; }
  .controls button { min-height: 40px; }

  /* <webview> er Electron-only: i nettleser blir Preview-fanen et ukjent element
     med hvit bakgrunn — et blendende fullskjerms tomrom i mørk modus. */
  .webview { background: var(--bg); }

  /* Multi-agent: kolonner stables vertikalt, popover-fot bryter pent. */
  .mab-cols { flex-direction: column; }
  .mab-col { min-width: 0; }
  .mab-chip { padding: 6px 11px; }
  .mab-run { min-height: 40px; }
  /* Fanebryteren er panelets hovedvalg → touch-høyde, og segmentene deler bredden likt. */
  .mab-modes button { min-height: 40px; font-size: 12.5px; }

  /* Kort/detaljer som antar bred flate. */
  .ms-phase-name { min-width: 120px; }
  .attach-chip { max-width: 100%; }
  .srv-links { width: min(340px, 92vw); }

  /* Mappevelger: nesten fullskjerm (native-følelse). */
  .fp { width: 94vw; height: 84vh; max-height: none; }

  /* Økter/prosess-rader: handlingsknappene får touch-høyde. */
  .sess-actions .ghost.sm, .proc-actions .ghost.sm { font-size: 12px; padding: 7px 10px; }
  .overview-task { padding: 9px 2px; }
  .task-actions button { padding: 7px 10px; font-size: 12px; }

  /* Landskap: notch/hjem-indikator ligger i SIDEKANTENE — hold innhold klar. */
  .topbar, .tabbar, .projectbar, .panel-head, .composer {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
}

/* Telefon-tier. 480px, IKKE 430: iPhone 17/16 Pro Max er 440 pt bredt, så den
   gamle grensa bommet på nøyaktig den modellen — brand-teksten ble stående og
   dyttet modell-dropdownen ut av venstre skjermkant. iPad mini (744) beholder den. */
@media (max-width: 480px) {
  .brand { display: none; }
  .topright { justify-content: flex-start; }
  /* «○ klar» klemmes til 20 px og er uleselig uansett — kun aktiv status betyr noe. */
  .statuspill:not(.busy) { display: none; }
  .statuspill.busy { flex: 0 1 auto; min-width: 0; max-width: 84px; }
}
