/* Projektwerk PWA – Gestaltung. Farben wie in der Android-App (ui/Theme.kt). */
:root {
  --bg:#111416; --surface:#15191b; --s-lowest:#0c0f10; --s-low:#171b1d; --s:#1b2022; --s-high:#242a2d; --s-highest:#2e3538;
  --fg:#e2e5e7; --fg2:#bfc8cc; --outline:#7d898e; --line:#394246;
  --primary:#7cc4a4; --on-primary:#00382a; --primary-c:#1f4e3e; --on-primary-c:#b9f0d6;
  --secondary:#9fc9e8; --secondary-c:#214a63; --on-secondary-c:#cde6f8;
  --tertiary:#e7c07a; --tertiary-c:#4d3a10; --on-tertiary-c:#ffe2ad;
  --error:#ffb4ab; --error-c:#7a1f1a; --on-error-c:#ffdad6;
  --ok:#7edb9b; --warn:#f0c674; --added:#7edb9b; --modified:#8ec5ff; --deleted:#ff9b91; --conflict:#ff8a65; --unversioned:#9aa5aa;
  --diff-add:rgba(126,219,155,.14); --diff-del:rgba(255,155,145,.14);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --chat-font: 14px;
  --vvh: 100dvh;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg:#f7f9f9; --surface:#fbfcfc; --s-lowest:#ffffff; --s-low:#f2f5f5; --s:#eceff0; --s-high:#e5e9ea; --s-highest:#dde2e3;
  --fg:#181c1d; --fg2:#3f484b; --outline:#6b777b; --line:#c1c9cc;
  --primary:#1b6b52; --on-primary:#ffffff; --primary-c:#bdefd8; --on-primary-c:#002117;
  --secondary:#2b6384; --secondary-c:#cbe6fa; --on-secondary-c:#001e2f;
  --tertiary:#7a5900; --tertiary-c:#ffdf9e; --on-tertiary-c:#261a00;
  --error:#b3261e; --error-c:#f9dedc; --on-error-c:#410e0b;
  --ok:#1b7a3d; --warn:#8a5a00; --added:#1b7a3d; --modified:#1d5fa8; --deleted:#b3261e; --conflict:#b84a00; --unversioned:#6b777b;
  --diff-add:rgba(27,122,61,.13); --diff-del:rgba(179,38,30,.11);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin:0; height:100%; overflow:hidden; background:var(--bg); color:var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { position: fixed; inset: 0; }
#app { position: fixed; left:0; right:0; top:0; height: var(--vvh); display:flex; flex-direction:column; overflow:hidden; }
.boot { margin:auto; color:var(--fg2); }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }   /* unter 16px zoomt iOS beim Fokus */
button { cursor:pointer; touch-action: manipulation; }
a { color: var(--primary); }
.mono { font-family: var(--mono); }
.muted { color: var(--fg2); }
.small { font-size: 13px; }
.err { color: var(--error); }
.grow { flex:1 1 0; min-width:0; min-height:0; }
.row { display:flex; align-items:center; gap:8px; }
.col { display:flex; flex-direction:column; }
.wrap { flex-wrap: wrap; }
.scroll { overflow:auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.hscroll { overflow-x:auto; white-space:nowrap; scrollbar-width:none; -webkit-overflow-scrolling: touch; }
.hscroll::-webkit-scrollbar { display:none; }
.ellipsis { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.clamp2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.pad { padding: 12px 16px; }

/* ---------- Schaltflächen */
.btn { min-height:44px; padding: 0 16px; border-radius: 22px; border:1px solid var(--outline); background:transparent; color:var(--primary);
  font-weight:600; font-size:15px; display:inline-flex; align-items:center; justify-content:center; gap:6px; white-space:nowrap; flex:none; }
.btn.fill { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.tonal { background: var(--s-highest); border-color: transparent; color: var(--fg); }
.btn.danger { color: var(--error); }
.btn.fill.danger { background: var(--error-c); color: var(--on-error-c); }
.btn.text { border-color: transparent; padding: 0 10px; }
.btn.sm { min-height:36px; font-size:14px; padding:0 12px; border-radius:18px; }
.btn.block { width:100%; }
.btn:disabled { opacity:.45; cursor:default; }
.btn:active:not(:disabled), .icon:active:not(:disabled), .item:active { filter: brightness(1.25); }
.icon { width:44px; height:44px; flex:none; border:0; background:transparent; border-radius:22px; display:inline-flex; align-items:center;
  justify-content:center; color:var(--fg); font-size:20px; line-height:1; padding:0; }
.icon.sm { width:36px; height:36px; font-size:17px; }
.icon.on { color: var(--primary); }
.icon svg, .btn svg, .nav svg, .key svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.icon.sm svg, .key svg { width:18px; height:18px; }
.key { display:inline-flex; align-items:center; justify-content:center; }
.chip { min-height:34px; padding:0 12px; border-radius:17px; border:1px solid var(--line); background:transparent; color:var(--fg2); font-size:14px;
  display:inline-flex; align-items:center; gap:6px; white-space:nowrap; flex:none; }
.chip.on { background: var(--secondary-c); color: var(--on-secondary-c); border-color: transparent; }
.badge { display:inline-block; padding:1px 8px; border-radius:10px; font-size:12px; font-weight:600; background: var(--s-highest); color:var(--fg2); white-space:nowrap; }
.badge.warn { background: var(--tertiary-c); color: var(--on-tertiary-c); }
.spin { width:16px; height:16px; flex:none; border:2px solid var(--line); border-top-color: var(--primary); border-radius:50%; animation: spin .8s linear infinite; display:inline-block; }
.spin.lg { width:28px; height:28px; border-width:3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:32px; text-align:center; flex:1; }

/* ---------- Formulare */
.field { display:flex; flex-direction:column; gap:4px; margin-bottom:12px; }
.field > span { font-size:13px; color:var(--fg2); }
.input { width:100%; min-height:46px; padding:10px 12px; border-radius:10px; border:1px solid var(--outline); background: var(--s-low); color: var(--fg); outline:none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
textarea.input { resize:none; line-height:1.4; }

/* ---------- Anmeldung */
.login { margin:auto; width:100%; max-width:380px; padding:24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.login img { width:72px; height:72px; border-radius:18px; }
.login h1 { margin:16px 0 4px; font-size:26px; }

/* ---------- Kopfzeile */
.topbar { flex:none; background: var(--s); padding-top: env(safe-area-inset-top); border-bottom:1px solid var(--line); }
.topbar .inner { min-height:36px; padding: 4px calc(12px + env(safe-area-inset-right)) 4px calc(12px + env(safe-area-inset-left)); gap:12px; font-size:12.5px; color:var(--fg2); }
.dot { width:9px; height:9px; border-radius:50%; background: var(--ok); flex:none; }
.dot.off { background: var(--error); }
.dot.busy { background: var(--warn); }
.topbar b { color: var(--fg); font-weight:600; }
.tone-warn { color: var(--warn); } .tone-err { color: var(--error); }

/* ---------- Hauptbereich und Navigation */
.main { flex:1 1 0; min-height:0; display:flex; position:relative; }
.listpane { flex:1 1 0; min-width:0; display:flex; flex-direction:column; background: var(--surface); }
.workspace { flex:1 1 0; min-width:0; display:flex; flex-direction:column; background: var(--surface); }
.narrow .workspace { position:absolute; inset:0; z-index:5; }
.wide .listpane { flex: 0 0 380px; border-right:1px solid var(--line); }
.nav { flex:none; display:flex; background: var(--s); border-top:1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.nav button { flex:1 1 0; min-width:0; border:0; background:transparent; color:var(--fg2); padding:7px 0 5px; display:flex; flex-direction:column; align-items:center; gap:2px;
  font-size:10.5px; position:relative; }
.nav button.on { color: var(--primary); }
.nav button.on svg { stroke-width:2.4; }
.nav .count { position:absolute; top:3px; left:calc(50% + 6px); min-width:17px; height:17px; border-radius:9px; background: var(--tertiary); color:#2b1d00; font-size:11px; font-weight:700; line-height:17px; padding:0 4px; }
.wide .nav { flex-direction:column; border-top:0; border-right:1px solid var(--line); width:84px; padding-top:8px; }
.wide .nav button { flex:none; padding:10px 0; font-size:11.5px; }

.panehead { flex:none; min-height:52px; padding: 4px 4px 4px 16px; gap:4px; border-bottom:1px solid var(--line); }
.panehead h2 { margin:0; font-size:17px; font-weight:650; }
.panehead .sub { font-size:12.5px; color:var(--fg2); }
.panehead.back { padding-left:4px; }
.sect { padding: 14px 16px 4px; font-size:13.5px; font-weight:650; color: var(--primary); }
.item { display:flex; align-items:center; gap:10px; padding: 10px 6px 10px 16px; min-height:52px; border:0; border-bottom:1px solid var(--s-high); background:transparent;
  width:100%; text-align:left; color:var(--fg); }
.item.sel { background: var(--primary-c); color: var(--on-primary-c); }
.item .t { font-size:15.5px; font-weight:550; }
.item .d { font-size:12.5px; color: var(--fg2); }
.item.sel .d { color: inherit; opacity:.85; }
.card { background: var(--s-low); border-radius:12px; padding:12px; margin: 8px 12px; }
.banner { flex:none; padding:8px 16px; font-size:14px; overflow-wrap:anywhere; background: var(--tertiary-c); color: var(--on-tertiary-c); }
.banner.err { background: var(--error-c); color: var(--on-error-c); }

/* ---------- Dialoge, Auswahlblätter, Meldungen */
.backdrop { position:absolute; inset:0; z-index:50; background: rgba(0,0,0,.55); display:flex; align-items:flex-end; justify-content:center; }
.backdrop.mid { align-items:center; padding:16px; }
.sheet { width:100%; max-width:560px; max-height: 82%; background: var(--s-high); border-radius: 18px 18px 0 0; display:flex; flex-direction:column;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 30px rgba(0,0,0,.4); }
.sheet .title { padding:14px 18px 8px; font-weight:650; font-size:15px; color: var(--fg2); }
.sheet .opt { display:block; width:100%; text-align:left; border:0; background:transparent; padding: 13px 18px; font-size:16px; min-height:50px; }
.sheet .opt small { display:block; color:var(--fg2); font-size:12.5px; margin-top:2px; white-space:normal; }
.sheet .opt.danger { color: var(--error); }
.sheet .opt:disabled { opacity:.4; }
.sheet .opt.on { color: var(--primary); font-weight:600; }
.sheet hr, .dialog hr { border:0; border-top:1px solid var(--line); margin:4px 0; }
.dialog { width:100%; max-width:520px; max-height:100%; background: var(--s-high); border-radius:18px; display:flex; flex-direction:column; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.dialog h3 { margin:0; padding:18px 20px 8px; font-size:19px; }
.dialog .body { padding: 4px 20px 8px; overflow:auto; -webkit-overflow-scrolling:touch; }
.dialog .actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; padding: 8px 14px 14px; }
.toast { position:absolute; left:12px; right:12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index:60; margin:0 auto; max-width:520px; background: var(--fg); color: var(--bg);
  padding:12px 16px; border-radius:10px; font-size:14.5px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* ---------- Arbeitsbereich: Reiter, Terminal */
.tabs { flex:none; background: var(--s); border-bottom:1px solid var(--line); min-height:46px; padding-right:2px; }
.tab { display:inline-flex; align-items:center; gap:4px; height:36px; padding:0 6px 0 12px; border-radius:18px; border:0; background:transparent; color:var(--fg2); font-size:14px; flex:none; max-width:210px; }
.tab.on { background: var(--primary-c); color: var(--on-primary-c); }
.tab > .ellipsis { flex:1 1 auto; min-width:0; }
.tab .x { flex:none; display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:13px; border:0; background:transparent; color:inherit; font-size:15px; padding:0; }
.tab i { width:8px; height:8px; border-radius:50%; background: var(--tertiary); flex:none; }
.termwrap { flex:1 1 0; min-height:0; position:relative; background:#0c0f10; }
.termhost { position:absolute; inset:0; padding: 4px 0 0 6px; }
.termhost .xterm { height:100%; }
.termhost .xterm-viewport { overflow:hidden !important; }
.termover { position:absolute; inset:0; background: rgba(0,0,0,.72); z-index:3; color:#fff; }
.keys { flex:none; background: var(--s-high); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap:4px; border-top:1px solid var(--line); }
.kbd-open .keys, .kbd-open .composer, .kbd-open .chatinput { padding-bottom:4px; }
.key { flex:none; min-width:44px; height:40px; padding:0 9px; border-radius:8px; border:1px solid var(--line); background: var(--s); color:var(--fg); font: 600 14px var(--mono); }
.key.on { background: var(--primary); color: var(--on-primary); border-color:transparent; }
.composer { flex:none; background: var(--s-high); padding:8px; border-top:1px solid var(--line); }

/* ---------- Chat */
.chat { flex:1 1 0; min-height:0; display:flex; flex-direction:column; position:relative; font-size: var(--chat-font); }
.chatlist { flex:1 1 0; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; padding: 12px 12px 16px; display:flex; flex-direction:column; gap:8px; }
.bubble { align-self:flex-end; max-width: min(88%, 640px); background: var(--primary-c); color: var(--on-primary-c); padding:10px 14px; border-radius: 16px 16px 4px 16px;
  white-space:pre-wrap; overflow-wrap:anywhere; font-size: calc(var(--chat-font) + 2px); line-height:1.4; -webkit-user-select:text; user-select:text; }
.atext { font-size: calc(var(--chat-font) + 2px); line-height:1.45; overflow-wrap:anywhere; -webkit-user-select:text; user-select:text; }
.atext p { margin: 0 0 8px; white-space:pre-wrap; }
.atext code { font-family: var(--mono); font-size:.9em; background: var(--s-highest); padding:1px 4px; border-radius:4px; }
.atext h4 { margin: 10px 0 4px; font-size:1.05em; }
.atext ul, .atext ol { margin: 0 0 8px; padding-left: 22px; }
.atext li { margin-bottom:2px; }
.atext table { border-collapse:collapse; font-size:.92em; margin-bottom:8px; display:block; overflow-x:auto; max-width:100%; }
.atext th, .atext td { border:1px solid var(--line); padding:4px 8px; text-align:left; vertical-align:top; }
.atext th { background: var(--s-high); }
.codeblock { background: var(--s-highest); border-radius:8px; margin-bottom:8px; }
.codeblock .head { padding: 0 2px 0 10px; font-size:11.5px; color:var(--outline); }
.codeblock pre { margin:0; padding: 0 10px 10px; overflow-x:auto; font: calc(var(--chat-font) - 1px)/1.4 var(--mono); -webkit-user-select:text; user-select:text; }
.toolrow { background: var(--s-low); border-radius:8px; padding:6px 10px; border:0; width:100%; text-align:left; color:var(--fg); display:block; }
.toolrow .lbl { font-weight:600; font-size: calc(var(--chat-font) - 1px); flex:none; }
.toolrow .sum { font: calc(var(--chat-font) - 2px) var(--mono); color:var(--fg2); }
.toolrow pre { margin:6px 0 0; font: calc(var(--chat-font) - 2px)/1.35 var(--mono); white-space:pre-wrap; overflow-wrap:anywhere; max-height:320px; overflow:auto; color:var(--fg2); -webkit-user-select:text; user-select:text; }
.toolrow.error .lbl, .toolrow.error pre.res { color: var(--error); }
.toolgroup { display:flex; flex-direction:column; gap:5px; }
.toolgroup .inner { padding-left:12px; display:flex; flex-direction:column; gap:4px; }
.cmdline { font: calc(var(--chat-font) - 2px) var(--mono); color: var(--outline); padding:0 8px; overflow-wrap:anywhere; white-space:pre-wrap; }
.chatimg { max-width: min(100%, 560px); max-height:340px; border-radius:10px; background: var(--s-highest); display:block; }
.sticky { position:absolute; top:0; left:8px; right:8px; z-index:2; background: var(--primary-c); color: var(--on-primary-c); border:0; text-align:left; border-radius: 0 0 12px 12px;
  padding:6px 12px; box-shadow: 0 3px 10px rgba(0,0,0,.35); font-size: var(--chat-font); display:flex; gap:8px; }
.toend { position:absolute; bottom:6px; left:50%; transform:translateX(-50%); z-index:2; }
.chatbar { flex:none; background: var(--s); padding: 2px 4px 2px 12px; font-size:14px; border-top:1px solid var(--line); }
.askcard { flex:none; background: var(--tertiary-c); color: var(--on-tertiary-c); padding:12px; max-height:46%; overflow:auto; display:flex; flex-direction:column; gap:8px; }
.askcard .opt { background: var(--surface); color: var(--fg); border:0; border-radius:10px; padding:10px; text-align:left; display:flex; gap:10px; width:100%; }
.askcard .opt b { color: var(--primary); min-width:14px; }
.askcard .btn { border-color: currentColor; color: inherit; }
.askcard .btn.fill { background: var(--on-tertiary-c); color: var(--tertiary-c); border-color:transparent; }
.screen { background: var(--s-lowest); color: var(--fg); border-radius:8px; padding:8px; font: calc(var(--chat-font) - 2.5px)/1.3 var(--mono); white-space:pre; overflow:auto; max-height:220px; margin:0; }
.queued { align-self:flex-end; background: var(--s-high); border-radius:12px; padding:6px 12px; max-width:88%; font-size:14px; color:var(--fg2); }
.suggest { flex:none; background: var(--s-high); border-top:1px solid var(--line); max-height:40%; overflow:auto; }
.suggest button { display:flex; gap:12px; align-items:baseline; width:100%; border:0; background:transparent; padding:9px 14px; text-align:left; }
.attach { flex:none; background: var(--s-high); padding:4px 8px; gap:6px; }
.chatinput { flex:none; background: var(--s-high); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); align-items:flex-end; gap:4px; }
.chatinput textarea { flex:1 1 0; min-width:0; min-height:46px; max-height:200px; border-radius:22px; padding: 11px 14px; line-height:1.35; }
.sendbtn { width:46px; height:46px; border-radius:23px; background: var(--primary); color: var(--on-primary); }
.sendbtn:disabled { background: var(--s-highest); color: var(--outline); }
.todo { display:flex; gap:8px; align-items:flex-start; font-size:14.5px; padding:3px 0; }
.todo i { flex:none; width:16px; height:16px; border-radius:50%; border:2px solid var(--outline); margin-top:2px; }
.todo.completed i { background: var(--ok); border-color: var(--ok); }
.todo.in_progress i { border-color: var(--primary); border-top-color: transparent; animation: spin 1s linear infinite; }
.todo.completed span { color: var(--fg2); }
.todo.in_progress span { font-weight:650; }
.lightbox { position:absolute; inset:0; z-index:70; background: rgba(0,0,0,.95); display:flex; overflow:auto; }
.lightbox img { margin:auto; max-width:100%; max-height:100%; object-fit:contain; touch-action: pinch-zoom; }

/* ---------- Dateien, SVN, Diff */
.svnb { flex:none; width:24px; text-align:center; font: 700 13px var(--mono); }
.c-added { color: var(--added); } .c-modified { color: var(--modified); } .c-deleted { color: var(--deleted); } .c-conflict { color: var(--conflict); } .c-unversioned { color: var(--unversioned); }
.tree .item { min-height:44px; padding-top:6px; padding-bottom:6px; }
.tree .tw { flex:none; width:18px; color: var(--outline); font-size:12px; text-align:center; }
.check { flex:none; width:22px; height:22px; accent-color: var(--primary); margin:0 4px 0 0; }
.diff { font: 12.5px/1.45 var(--mono); min-width:100%; width:max-content; padding-bottom:24px; -webkit-user-select:text; user-select:text; }
.diff div { padding: 0 10px 0 0; white-space:pre; display:flex; }
.diff .no { flex:none; width:42px; text-align:right; padding-right:8px; color: var(--outline); -webkit-user-select:none; user-select:none; }
.diff .add { background: var(--diff-add); } .diff .del { background: var(--diff-del); }
.diff .file { background: var(--s-highest); font-weight:700; padding:6px 10px; margin-top:8px; position:sticky; left:0; }
.diff .hunk { color: var(--secondary); background: var(--s-low); padding-left:10px; }
.diff .meta { color: var(--outline); padding-left:10px; }
.output { margin:0; padding:10px 12px 30px; font: 12.5px/1.4 var(--mono); white-space:pre-wrap; overflow-wrap:anywhere; -webkit-user-select:text; user-select:text; }
.editor { flex:1 1 0; min-height:0; overflow:hidden; display:flex; }
.editor .cm-editor { flex:1; min-width:0; height:100%; font-size: var(--editor-font, 14px); }
.editor .cm-scroller { font-family: var(--mono); overscroll-behavior: contain; }
.kv { display:grid; grid-template-columns: max-content 1fr; gap:4px 14px; font-size:13.5px; }
.kv dt { color: var(--fg2); } .kv dd { margin:0; overflow-wrap:anywhere; }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:18px; overflow:hidden; flex:none; }
.seg button { border:0; background:transparent; color: var(--fg2); padding:0 12px; height:34px; font-size:13.5px; }
.seg button.on { background: var(--secondary-c); color: var(--on-secondary-c); }
@media (min-width: 900px) { .toast { bottom:24px; } }
