:root {
  --bg: #f6f7f9; --panel: #ffffff; --side: #eef0f4; --text: #1c2030; --muted: #6b7280; --line: #dfe3ea;
  --accent: #2f5bd3; --accent-soft: #e3eafc; --warn: #b45309; --warn-soft: #fdf1e2; --danger: #b91c1c;
  --ok: #15803d; --agent: #8a5a00; --code: #eef0f4; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --t-ideenschmiede: #b7791f; --t-build: #2f5bd3; --t-review: #7e3fbf; --t-ux: #15803d; --t-release: #0e7490;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161f; --panel: #1b1e2a; --side: #171a24; --text: #dfe3f0; --muted: #8a90a6; --line: #2a2f40;
    --accent: #7aa2f7; --accent-soft: #24304f; --warn: #ffa05c; --warn-soft: #3a2a1a; --danger: #f7768e;
    --ok: #9ece6a; --agent: #e0af68; --code: #232737; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    --t-ideenschmiede: #e0af68; --t-build: #7aa2f7; --t-review: #bb9af7; --t-ux: #9ece6a; --t-release: #7dcfff;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
button, textarea, input { font: inherit; color: inherit; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { background: var(--code); padding: 10px 12px; border-radius: 8px; overflow: auto; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

#app { display: flex; height: 100vh; }
#side { width: 280px; flex: none; background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; padding: 14px 12px 24px; }
#center { flex: 1 1 420px; min-width: 360px; display: flex; flex-direction: column; background: var(--panel); }
#panel { flex: 1.25 1 520px; min-width: 380px; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg); }

.brand { font-size: 15px; display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.logo { color: var(--accent); }
.status { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 12px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok::before { content: "● "; color: var(--ok); }
.pill.off::before { content: "○ "; color: var(--danger); }
.pill.danger { background: var(--danger); color: #fff; border-color: transparent; cursor: pointer; }
.pill.btn { cursor: pointer; }
.new { display: flex; gap: 6px; padding: 0 4px 6px; }
.new button, .ghost, .primary, .seg button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.new button:hover, .ghost:hover { border-color: var(--accent); }
.new.big { justify-content: center; margin: 18px 0; }
.new.big button { padding: 9px 16px; }
.primary { background: var(--accent); color: #fff; border-color: transparent; }
.primary:hover { filter: brightness(1.08); }
.btn { text-decoration: none; display: inline-block; }

section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 4px 6px; display: flex; gap: 6px; align-items: center; }
.count { background: var(--warn); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; letter-spacing: 0; }
.count:empty { display: none; }
.list { display: flex; flex-direction: column; gap: 2px; }
.row { padding: 7px 8px; border-radius: 8px; cursor: pointer; display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 6px; align-items: baseline; }
.row:hover { background: var(--panel); }
.row.sel { background: var(--accent-soft); }
.row .mark { font-size: 11px; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .age { color: var(--muted); font-size: 12px; }
.row .sub { grid-column: 2 / 4; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark.warn { color: var(--warn); } .mark.busy { color: var(--accent); } .mark.danger { color: var(--danger); }
.kind { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kind.eskalation { color: var(--danger); } .kind.rueckfrage { color: var(--t-ideenschmiede); } .kind.review { color: var(--t-review); } .kind.freigabe { color: var(--warn); }
.empty-note { color: var(--muted); font-size: 12.5px; padding: 4px 8px; }

.lanes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 0 4px; }
.lane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; text-align: center; }
.lane b { display: block; font-size: 17px; }
.lane span { font-size: 10.5px; color: var(--muted); }
.lane.hot b { color: var(--warn); }

.empty { margin: auto; max-width: 520px; text-align: center; padding: 24px; }
.empty h2 { font-weight: 600; }

#chat, #decision { display: flex; flex-direction: column; height: 100%; }
.chathead, .panelhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.title { font-weight: 600; font-size: 15px; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.actions { display: flex; gap: 6px; align-items: center; }

.messages { flex: 1; overflow-y: auto; padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 780px; }
.msg .who { font-size: 12px; font-weight: 600; margin-bottom: 3px; display: flex; gap: 8px; }
.msg .who time { color: var(--muted); font-weight: 400; }
.msg.dennis { align-self: flex-end; }
.msg.dennis .bubble { background: var(--accent-soft); border-radius: 14px 14px 4px 14px; padding: 8px 12px; white-space: pre-wrap; }
.msg.dennis .who { justify-content: flex-end; color: var(--accent); }
.msg.agent .who { color: var(--agent); }
.msg.agent .body > :first-child { margin-top: 0; }
.msg.agent .body > :last-child { margin-bottom: 0; }
.msg.agent .body h1, .msg.agent .body h2, .msg.agent .body h3 { font-size: 14.5px; margin: 12px 0 4px; }
.msg.agent .body ul, .msg.agent .body ol { padding-left: 20px; margin: 6px 0; }
.msg.agent .body p { margin: 6px 0; }
.msg .state { font-size: 11.5px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg .state.err { color: var(--danger); }
.question { margin-top: 10px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 8px 12px; }
.question::before { content: "Rückfrage"; display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--warn); margin-bottom: 2px; }
.tools { font-size: 12.5px; color: var(--muted); }
.tools summary { cursor: pointer; list-style: none; }
.tools summary::before { content: "› "; }
.tools[open] summary::before { content: "⌄ "; }
.tools div { padding-left: 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.mockref { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; background: var(--bg); }
.mockref:hover { border-color: var(--accent); }
.system { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.typing { color: var(--muted); font-size: 13px; }
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.composer { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--bg); max-height: 200px; }
.composer textarea:focus, #decText:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.decbody { padding: 20px; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.detail { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
#decText { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--bg); resize: vertical; }
.decactions { display: flex; gap: 8px; flex-wrap: wrap; }

.versions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.versions .lbl { font-weight: 600; margin-right: 6px; }
.versions button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12.5px; }
.versions button.on { background: var(--accent); color: #fff; border-color: transparent; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; padding: 4px 9px; font-size: 12.5px; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.stage { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 16px; }
#frame { width: 100%; height: 100%; min-height: 400px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); transition: width .2s; }
.panelfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.noprev { margin: auto; color: var(--muted); text-align: center; max-width: 360px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 1100px) { #panel { position: fixed; inset: 0 0 0 auto; width: min(640px, 100vw); z-index: 5; box-shadow: var(--shadow); } }
@media (max-width: 760px) { #side { display: none; } #center { min-width: 0; } }

.loginpage { display: flex; align-items: center; justify-content: center; }
.loginbox { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.loginbox input { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--bg); }
.err { color: var(--danger); margin: 0; }
.me { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 10px; font-size: 12.5px; color: var(--muted); }
.me b { color: var(--text); font-weight: 600; }
.me a { color: var(--muted); cursor: pointer; text-decoration: underline; }
.online { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 4px 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }
.msg.dennis.other .bubble { background: var(--code); border-radius: 14px 14px 14px 4px; }
.msg.dennis.other { align-self: flex-start; }
.msg.dennis.other .who { justify-content: flex-start; }
button[disabled] { opacity: .5; cursor: not-allowed; }

.btn { color: var(--text); }
.lane span { white-space: nowrap; font-size: 10px; }
.note { color: var(--muted); font-size: 12.5px; }
.specbody { border-top: 1px solid var(--line); padding-top: 12px; }
.specbody h1 { font-size: 16px; } .specbody h2 { font-size: 14.5px; margin: 14px 0 4px; } .specbody h3 { font-size: 13.5px; }
.specbody ul, .specbody ol { padding-left: 20px; }
#decision .decbody { overflow-y: auto; }
#decText, .detail, .decactions { flex: none; }
#decText { min-height: 76px; }
.authwrap { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 20; }
h3.sub { font-size: 13px; margin: 6px 0; }
.revreport { border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin: 6px 0; background: var(--bg); }
.revreport.ok { border-left-color: var(--ok); }
.revreport summary { cursor: pointer; }
.revreport .body { margin-top: 8px; }

/* --- Telefon ------------------------------------------------------------------------------ */
.tabbar, .back, .mobile-only { display: none; }
.grow { flex: 1; min-width: 0; }
.pushbox { padding: 0 4px 10px; font-size: 12.5px; color: var(--muted); }
.pushbox button { margin-top: 4px; }
@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; }
  #app { height: calc(100dvh - 58px - env(safe-area-inset-bottom)); }
  #side { display: block; width: 100%; border-right: 0; padding-top: calc(14px + env(safe-area-inset-top)); }
  #side [data-tab] { display: none; }
  body[data-view="wartet"] #side [data-tab="wartet"],
  body[data-view="gespraeche"] #side [data-tab="gespraeche"],
  body[data-view="stand"] #side [data-tab="stand"] { display: block; }
  body[data-view="gespraeche"] #side .new[data-tab="gespraeche"] { display: flex; }
  #side #runningBox[hidden] { display: none !important; }
  .mobile-only { display: block; }
  body.has-sel #side { display: none; }
  body:not(.has-sel) #center { display: none; }
  #center { min-width: 0; width: 100%; }
  .back { display: inline-flex; font-size: 22px; line-height: 1; padding: 4px 12px; }
  .chathead { padding: calc(8px + env(safe-area-inset-top)) 10px 8px; gap: 8px; min-height: 52px; }
  .chathead .actions .ghost { padding: 5px 8px; font-size: 12.5px; }
  #closeThread { display: none; }
  .messages { padding: 12px 12px 8px; }
  .msg { max-width: 100%; }
  .composer { padding: 8px 10px; }
  .composer textarea { font-size: 16px; } /* kein Zoom beim Tippen (iOS) */
  #decText, .loginbox input { font-size: 16px; }
  .decbody { padding: 14px; }
  .decactions button { flex: 1 1 45%; padding: 10px; }
  .row { padding: 11px 10px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid var(--line); z-index: 10; }
  .tabbar button { flex: 1; border: 0; background: none; color: var(--muted); font-size: 11.5px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px; position: relative; }
  .tabbar button.on { color: var(--accent); font-weight: 600; }
  .tabbar .ti { font-size: 18px; line-height: 1; }
  .tabbar .count { position: absolute; top: 6px; left: calc(50% + 8px); }
  #panel { inset: 0; width: 100vw; padding-top: env(safe-area-inset-top); z-index: 20; }
  .panelhead { flex-wrap: wrap; }
  .panelfoot { flex-wrap: wrap; }
  .panelfoot .actions { width: 100%; }
  .panelfoot .actions button { flex: 1; }
  #device { display: none; }
  #frame { min-height: 60vh; }
  .stage { padding: 8px; }
}
