/* baru team – Oberfläche (Claude). Keine externen Schriften oder Abhängigkeiten. */

:root {
  --brand: #2860D8;
  --brand-600: #1F4FB8;
  --brand-50: #EAF1FD;
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F0F2F6;
  --chat-bg: #F3F5F8;
  --text: #172536;
  --muted: #5B687A;
  --faint: #7A8697;
  --line: #E2E6EC;
  --rail: #0F2A5C;
  --rail-ic: #A9BCE3;
  --bubble-in: #FFFFFF;
  --bubble-out: #E3ECFC;
  --bubble-out-line: #CFDDF8;
  --code-bg: #EEF1F6;
  --danger: #B83232;
  --danger-bg: #FCECEC;
  --warn: #8A5700;
  --warn-bg: #FFF4DE;
  --ok: #1F8A5B;
  --codex: #0F7B6C;
  --claude: #B4562F;
  --boss: #2860D8;
  --shadow: 0 1px 2px rgba(23, 37, 54, .06), 0 4px 16px rgba(23, 37, 54, .06);
  --shadow-lg: 0 12px 40px rgba(15, 30, 60, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #4B7FEA;
  --brand-600: #6B96F0;
  --brand-50: #1A2A48;
  --bg: #0E1520;
  --surface: #141D2B;
  --surface-2: #1A2535;
  --chat-bg: #0F1723;
  --text: #E4EAF2;
  --muted: #A3B0C2;
  --faint: #8190A6;
  --line: #243246;
  --rail: #0A1220;
  --rail-ic: #7F93B8;
  --bubble-in: #1A2535;
  --bubble-out: #1E3560;
  --bubble-out-line: #28457A;
  --code-bg: #0F1826;
  --danger: #F07C7C;
  --danger-bg: #3A1D22;
  --warn: #F0BC5E;
  --warn-bg: #33291A;
  --ok: #4CC38A;
  --codex: #3CC2AE;
  --claude: #E48C62;
  --boss: #8CB0F7;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.noscript { padding: 2rem; text-align: center; }
.view { height: 100dvh; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .55rem 1.1rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn .ic { width: 19px; height: 19px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { min-height: 34px; padding: .3rem .75rem; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.small { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn.small .ic { width: 20px; height: 20px; }

/* ---------- Boot ---------- */
.boot { display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--muted); }
.boot-logo { border-radius: 14px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Anmeldung ---------- */
.login { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); background: var(--surface); }
.login-art { position: relative; overflow: hidden; background: var(--rail); }
.login-art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.login-art-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3rem 3rem 2.6rem; color: #fff;
  background: linear-gradient(to top, rgba(10, 25, 55, .82), rgba(10, 25, 55, 0));
  display: grid; gap: .4rem;
}
.login-art-caption strong { font-size: 1.35rem; letter-spacing: -.01em; }
.login-art-caption span { opacity: .9; font-size: .98rem; max-width: 36rem; }
.login-side { display: grid; place-items: center; padding: 2rem 1.25rem; overflow-y: auto; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: .5rem; }
.login-logo { border-radius: 14px; margin-bottom: .75rem; }
.login-card h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; letter-spacing: -.02em; }
.login-sub { margin: 0 0 1.25rem; color: var(--muted); }
.login-card label { font-weight: 600; font-size: .9rem; }
.pw-field { position: relative; }
.pw-field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 20px; height: 20px; }
.pw-field input { padding-left: 42px; }
input[type="password"], input[type="text"], input[type="search"], .dlg textarea {
  width: 100%; min-height: 46px; padding: .6rem .8rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 1rem;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.login-card .btn.primary { margin-top: .5rem; }
.note { margin: 0; padding: .6rem .8rem; border-radius: 10px; background: var(--brand-50); font-size: .9rem; }
.form-error { margin: 0; color: var(--danger); font-size: .9rem; }
.warn-text { margin: 0; color: var(--warn); font-size: .85rem; }
.login-card label:not(:first-of-type) { margin-top: .5rem; }
.login-card .opt { font-weight: 400; color: var(--faint); }
.login-hint { margin: 0; font-size: .8rem; color: var(--faint); }
.otp-input { font-family: var(--mono); font-size: 1.1rem !important; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
.login-dl { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); display: grid; gap: .35rem; }
.login-dl-version { color: var(--muted); font-size: .82rem; text-align: center; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
  .login-art-caption { padding: 1.25rem; }
  .login-art-caption span { display: none; }
  .login-side { place-items: start center; padding-top: 1.5rem; }
}

/* ---------- App-Gerüst ---------- */
.app {
  display: grid;
  grid-template-columns: 68px 310px minmax(0, 1fr) auto;
  height: 100dvh; overflow: hidden; position: relative;
}
.rail {
  background: var(--rail); display: flex; flex-direction: column; align-items: center;
  gap: .4rem; padding: 14px 0 16px;
}
.rail-logo { border-radius: 10px; margin-bottom: 14px; background: #fff; }
.rail-btn {
  width: 46px; height: 46px; display: grid; place-items: center;
  border: 0; border-radius: 13px; background: transparent; color: var(--rail-ic);
  transition: background .15s, color .15s;
}
.rail-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail-btn.active { background: rgba(255, 255, 255, .14); color: #fff; }
.rail-spacer { flex: 1; }

.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; }
.side-title { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
.side-title h1 { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; }
.side-actions { display: flex; }
.mobile-only { display: none; }
.status {
  border: 0; background: none; padding: .2rem .1rem; font-size: .78rem; color: var(--faint);
  display: inline-flex; align-items: center; gap: .35rem; min-height: 28px;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status[data-state="live"]::before { background: var(--ok); }
.status[data-state="error"], .status[data-state="offline"] { color: var(--danger); }
.status[data-state="error"]::before, .status[data-state="offline"]::before { background: var(--danger); }
.side-filter { position: relative; margin: 6px 14px 8px; }
.side-filter .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.side-filter input { min-height: 40px; padding-left: 36px; background: var(--surface-2); border-color: transparent; font-size: .92rem; }
.side-banner { margin: 4px 14px 8px; padding: .7rem .8rem; border-radius: 12px; background: var(--brand-50); font-size: .85rem; display: grid; gap: .5rem; }
.side-banner-acts { display: flex; gap: .4rem; }
.side-banner.tools { background: var(--warn-bg); color: var(--text); }
.side-banner.tools .btn { flex: 1; }

.chan-list { flex: 1; overflow-y: auto; padding: 2px 8px 16px; }
.chan-sec { margin: 12px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.chan {
  display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 64px;
  padding: .55rem .7rem; border: 0; border-radius: 12px; background: transparent; text-align: left;
  transition: background .12s;
}
.chan:hover { background: var(--surface-2); }
.chan[aria-current="true"] { background: var(--brand-50); }
.chan-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.chan-top { min-width: 0; display: flex; align-items: baseline; gap: .5rem; }
.chan-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-time { font-size: .75rem; color: var(--faint); flex: none; }
.chan-bottom { min-width: 0; display: flex; align-items: center; gap: .5rem; }
.chan-last { flex: 1; min-width: 0; font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-new { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none; }
.chan.unread .chan-name, .chan.unread .chan-last { color: var(--text); }
.chan-emptyfilter { padding: 1rem; color: var(--muted); font-size: .9rem; }

.avatar {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem; color: #fff; background: var(--brand);
}
.avatar .ic { width: 22px; height: 22px; }
.avatar.k-channel { background: var(--brand-50); color: var(--brand); }
.avatar.k-codex { background: var(--codex); border-radius: 50%; }
.avatar.k-claude { background: var(--claude); border-radius: 50%; }
.avatar.k-boss { background: var(--boss); border-radius: 50%; }
.avatar.xl { width: 72px; height: 72px; border-radius: 20px; font-size: 1.6rem; }
.avatar.xl.k-codex, .avatar.xl.k-claude { border-radius: 50%; }
.avatar.xl .ic { width: 34px; height: 34px; }

/* ---------- Unterhaltung ---------- */
.convo { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); position: relative; }
.convo-head {
  display: flex; align-items: center; gap: .25rem; min-height: 64px; padding: 8px 12px 8px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.back-btn { display: none; }
.head-id {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .75rem;
  border: 0; background: none; padding: 4px 6px; border-radius: 12px; text-align: left; min-height: 48px;
}
.head-id:hover { background: var(--surface-2); }
.head-id .avatar { width: 40px; height: 40px; }
.head-text { display: grid; min-width: 0; }
.head-name { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-desc { font-size: .83rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; gap: 2px; }
.head-actions .icon-btn[aria-expanded="true"] { background: var(--brand-50); color: var(--brand); }

.searchbar { display: flex; align-items: center; gap: .5rem; padding: 6px 12px 6px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.searchbar > .ic { color: var(--faint); width: 20px; height: 20px; }
.searchbar input { border: 0; box-shadow: none !important; min-height: 40px; padding: .4rem 0; background: transparent; }
.conn-banner { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--warn-bg); color: var(--warn); font-size: .87rem; }
.conn-banner span { flex: 1; }

.convo-body { position: relative; flex: 1; min-height: 0; display: flex; }
.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.column { width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px clamp(12px, 3vw, 40px) 22px; }
.older-wrap { display: flex; justify-content: center; }
.older-wrap .btn { margin-bottom: 10px; }
.empty { text-align: center; color: var(--muted); margin: 3rem 1rem; }

.day { display: flex; justify-content: center; margin: 18px 0 10px; position: sticky; top: 6px; z-index: 1; pointer-events: none; }
.day span {
  font-size: .75rem; font-weight: 600; color: var(--muted);
  background: var(--surface); padding: .25rem .75rem; border-radius: 999px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

/* Nachrichten */
.msg { display: flex; gap: .6rem; margin-top: 12px; position: relative; }
.msg.cont { margin-top: 3px; }
.msg > .avatar { width: 34px; height: 34px; font-size: .85rem; border-radius: 50%; margin-top: 2px; }
.msg.cont > .avatar { visibility: hidden; height: 0; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine > .avatar { display: none; }
.bubble-wrap { display: flex; flex-direction: column; min-width: 0; max-width: min(760px, 78%); }
.msg.mine .bubble-wrap { align-items: flex-end; }
.bubble {
  position: relative; min-width: 76px; max-width: 100%;
  padding: .5rem .75rem .35rem; border-radius: 16px;
  background: var(--bubble-in); box-shadow: 0 1px 1.5px rgba(23, 37, 54, .07);
  border: 1px solid transparent;
}
.msg:not(.mine):not(.cont) .bubble { border-top-left-radius: 6px; }
.msg.mine:not(.cont) .bubble { border-top-right-radius: 6px; }
.msg.mine .bubble { background: var(--bubble-out); border-color: var(--bubble-out-line); box-shadow: none; }
.msg.flash .bubble { animation: flash 1.8s ease; }
@keyframes flash { 0%, 45% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 45%, transparent); } 100% { box-shadow: none; } }
.who { font-size: .8rem; font-weight: 700; margin-bottom: 1px; }
.a-codex { color: var(--codex); }
.a-claude { color: var(--claude); }
.a-boss { color: var(--boss); }
.a-other { color: var(--muted); }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.body.collapsed { max-height: 16em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.body code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .08em .35em; border-radius: 5px; }
.body pre { margin: .35rem 0; padding: .6rem .75rem; background: var(--code-bg); border-radius: 10px; overflow-x: auto; white-space: pre; font-size: .84rem; line-height: 1.5; }
.body pre code { background: none; padding: 0; font-size: inherit; }
.more { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: .85rem; padding: .3rem 0; min-height: 32px; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; margin-top: 1px; font-size: .7rem; color: var(--faint); }
.meta .ic { width: 13px; height: 13px; }
.meta time { font-variant-numeric: tabular-nums; }

.quote {
  display: block; width: 100%; text-align: left; margin: .15rem 0 .35rem; padding: .35rem .6rem;
  border: 0; border-left: 3px solid var(--brand); border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 8%, transparent); font-size: .84rem; color: var(--muted);
}
.quote strong { display: block; color: var(--text); font-size: .78rem; }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

.atts { display: flex; flex-wrap: wrap; gap: 4px; margin: .2rem 0 .1rem; }
.att { display: block; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.att img { display: block; max-width: min(300px, 100%); max-height: 260px; object-fit: cover; }
.att-missing { font-size: .82rem; color: var(--muted); }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react-chip {
  display: inline-flex; align-items: center; gap: .25rem; min-height: 30px; padding: 0 .55rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .85rem;
}
.react-chip.mine { border-color: var(--brand); background: var(--brand-50); }
.react-chip span { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Aktionsleiste an Nachrichten */
.acts {
  position: absolute; top: -20px; z-index: 3; display: none; gap: 1px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.msg:not(.mine) .acts { left: 44px; }
.msg.mine .acts { right: 0; }
.msg:hover .acts, .msg:focus-within .acts, .msg.sel .acts { display: flex; }
.acts .icon-btn { width: 36px; height: 36px; border-radius: 9px; }
.acts .icon-btn .ic { width: 19px; height: 19px; }
.acts .icon-btn.on { color: var(--brand); }
.react-pop {
  position: absolute; z-index: 4; top: -64px; display: flex; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.msg:not(.mine) .react-pop { left: 44px; }
.msg.mine .react-pop { right: 0; }
.react-pop button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; font-size: 1.3rem; }
.react-pop button:hover, .react-pop button.mine { background: var(--brand-50); }

/* Jobs, Outbox */
.jobs, .outbox { display: grid; gap: 6px; margin-top: 8px; }
.job {
  display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--muted);
  padding: .45rem .75rem; border-radius: 12px; background: var(--surface); width: fit-content; max-width: 100%;
  box-shadow: 0 1px 1.5px rgba(23, 37, 54, .06);
}
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.job-failed, .job-interrupted { background: var(--danger-bg); color: var(--danger); }
.job-text { min-width: 0; }
.job-error { font-size: .8rem; opacity: .9; overflow-wrap: anywhere; }
.out-state { font-size: .72rem; color: var(--faint); }
.out-held .bubble, .out-rejected .bubble, .out-unsure .bubble { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.out-note { margin: .3rem 0 0; font-size: .8rem; color: var(--danger); white-space: normal; }
.out-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; justify-content: flex-end; }

.jump {
  position: absolute; right: 22px; bottom: 14px; z-index: 5;
  display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: 0 .9rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--brand);
  font-weight: 600; font-size: .85rem; box-shadow: var(--shadow);
}
.jump .ic { width: 18px; height: 18px; }

/* Suche */
.search-results { position: absolute; inset: 0; z-index: 6; overflow-y: auto; background: var(--chat-bg); padding: 12px clamp(12px, 3vw, 40px) 24px; }
.sr-head { font-size: .85rem; color: var(--muted); margin: 0 auto 10px; max-width: 900px; }
.sr-list { display: grid; gap: 8px; max-width: 900px; margin: 0 auto; }
.sr-item { display: grid; gap: .2rem; text-align: left; width: 100%; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.sr-item:hover { border-color: var(--brand); }
.sr-top { display: flex; gap: .5rem; font-size: .8rem; color: var(--muted); }
.sr-text { font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
mark { background: color-mix(in srgb, #F5C542 55%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Composer */
.composer {
  flex: none; position: relative;
  padding: 8px clamp(10px, 2vw, 24px) calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer.dragging { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-50); }
.composer > :not(.emoji-panel) { max-width: 1180px; margin-left: auto; margin-right: auto; }
.reply-bar { display: flex; align-items: center; gap: .6rem; padding: .3rem .3rem .3rem .75rem; margin-bottom: 6px; border-left: 3px solid var(--brand); border-radius: 10px; background: var(--surface-2); }
.reply-bar > .ic { color: var(--brand); width: 18px; height: 18px; }
.reply-text { flex: 1; min-width: 0; display: grid; font-size: .84rem; }
.reply-text strong { font-size: .78rem; }
.reply-text span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.targets { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.targets-label { font-size: .75rem; color: var(--faint); margin-right: 2px; font-weight: 600; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.pill span {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 .7rem;
  border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 1px solid transparent; cursor: pointer;
}
.pill input:checked + span { background: var(--brand-50); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.mention-hint { font-size: .74rem; color: var(--faint); margin-left: .4rem; }
.compose-row { display: flex; align-items: flex-end; gap: 6px; }
.field { flex: 1; min-width: 0; display: flex; align-items: flex-end; background: var(--surface-2); border: 1px solid transparent; border-radius: 22px; padding: 1px 3px 1px 14px; }
.field:focus-within { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--surface); }
.field textarea {
  flex: 1; min-width: 0; resize: none; border: 0; background: transparent; outline: none; box-shadow: none;
  padding: 10px 0; min-height: 42px; max-height: 140px; line-height: 1.4; font-size: 1rem;
}
.field .icon-btn { margin-bottom: 2px; width: 38px; height: 38px; }
.send-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--brand); color: #fff; transition: background .15s, opacity .15s, transform .1s; }
.send-btn:hover:not(:disabled) { background: var(--brand-600); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { opacity: .4; cursor: default; }
.send-btn .ic { width: 21px; height: 21px; margin-left: 2px; }
.counter { font-size: .78rem; color: var(--muted); margin: 4px 0 0; }
.counter.over { color: var(--danger); }

.attach-list { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 6px; padding-bottom: 2px; }
.pend { display: flex; align-items: center; gap: .55rem; padding: 6px; flex: none; max-width: 320px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.pend-error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.pend-thumb { position: relative; width: 48px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--surface-2); flex: none; display: grid; place-items: center; }
.pend-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pend-ph { font-size: .7rem; color: var(--muted); }
.pend-spin { position: absolute; inset: 12px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .6); border-top-color: var(--brand); animation: spin .9s linear infinite; }
.pend-info { display: grid; min-width: 0; font-size: .78rem; }
.pend-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.pend-state { color: var(--muted); }
.pend-msg { color: var(--danger); }
.pend-actions { display: flex; gap: 2px; }
.attach-status { font-size: .8rem; color: var(--muted); margin: 0 0 6px; }
.attach-status.err { color: var(--danger); }

.emoji-panel {
  position: absolute; bottom: calc(100% - 4px); right: clamp(10px, 2vw, 24px); z-index: 10;
  width: 336px; max-width: calc(100vw - 20px); padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.emoji-panel button { height: 40px; border: 0; background: none; border-radius: 9px; font-size: 1.3rem; padding: 0; }
.emoji-panel button:hover, .emoji-panel button:focus-visible { background: var(--surface-2); }

/* ---------- Details ---------- */
.details { width: 340px; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.details-head { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); }
.details-head h2 { margin: 0; font-size: 1.05rem; }
.details-body { overflow-y: auto; padding: 18px; display: grid; gap: 22px; align-content: start; }
.d-profile { display: grid; justify-items: center; text-align: center; gap: .35rem; }
.d-profile h3 { margin: .4rem 0 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.d-desc { margin: 0; color: var(--muted); font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-meta { margin: 0; color: var(--faint); font-size: .8rem; }
.d-sec h4 { display: flex; align-items: center; gap: .45rem; margin: 0 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.d-sec h4 .ic { width: 17px; height: 17px; }
.d-pins { display: grid; gap: 6px; }
.d-pin { display: grid; gap: .1rem; text-align: left; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .85rem; width: 100%; }
.d-pin:hover { border-color: var(--brand); }
.d-pin strong { font-size: .78rem; }
.d-pin span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.d-empty { color: var(--faint); font-size: .85rem; margin: 0; }
.d-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.d-media button { aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.d-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-hint { font-size: .75rem; color: var(--faint); margin: .5rem 0 0; }

/* ---------- Dialoge ---------- */
.dlg { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(10, 20, 40, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 20px; }
.dlg-head h2 { margin: 0; font-size: 1.1rem; }
.dlg-body { padding: 8px 20px 16px; display: grid; gap: .5rem; }
.dlg-body > label { font-weight: 600; font-size: .88rem; margin-top: .4rem; }
.dlg-body .opt { font-weight: 400; color: var(--faint); }
.dlg textarea { resize: vertical; min-height: 80px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 0 20px 18px; }
.sheet { width: min(420px, calc(100vw - 24px)); max-height: min(760px, calc(100dvh - 24px)); }
.sheet .dlg-body { gap: 0; overflow-y: auto; max-height: calc(min(760px, 100dvh - 24px) - 60px); }
.m-sec { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: .55rem; }
.m-sec h3 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .95rem; }
.m-sec h3 .ic { width: 19px; height: 19px; color: var(--brand); }
.m-note { margin: 0; font-size: .88rem; color: var(--muted); }
.m-note[data-state="on"] { color: var(--ok); font-weight: 600; }
.m-note[data-state="warn"] { color: var(--warn); }
.m-note[data-state="blocked"] { color: var(--danger); }
.m-hint { margin: 0; font-size: .8rem; color: var(--faint); }
#logout { margin-top: 16px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: grid; place-items: center; min-height: 40px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }

/* Scrollbare Dialoge (2FA, Arbeitsprotokoll) */
.dlg.scroll { max-height: calc(100dvh - 24px); }
.dlg.scroll[open] { display: flex; flex-direction: column; }
.dlg.scroll .dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg-head .dlg-title { flex: 1; min-width: 0; display: grid; }
.dlg-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.dlg.scroll .dlg-foot { padding-top: 10px; }

.totp-step { display: grid; gap: .45rem; padding: .6rem 0 .8rem; }
.totp-step + .totp-step { border-top: 1px solid var(--line); padding-top: .9rem; }
.totp-step h3 { margin: 0; font-size: 1rem; }
.totp-step > label { font-weight: 600; font-size: .88rem; }
.totp-qr { justify-self: center; }
.totp-qr img { display: block; width: min(220px, 62vw); height: auto; aspect-ratio: 1; padding: 10px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.totp-secret { display: flex; align-items: stretch; gap: .5rem; }
.totp-secret code {
  flex: 1; min-width: 0; display: flex; align-items: center; padding: .5rem .75rem; border-radius: 10px;
  background: var(--code-bg); font-family: var(--mono); font-size: .95rem; letter-spacing: .04em;
  overflow-wrap: anywhere; user-select: all; -webkit-user-select: all;
}

/* Freigabekarten über dem Eingabefeld */
.approvals {
  flex: none; max-height: 45dvh; overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 8px; padding: 8px clamp(10px, 2vw, 24px);
  background: var(--chat-bg); border-top: 1px solid var(--line);
}
.approvals > .appr { width: 100%; max-width: 1180px; margin: 0 auto; }
.appr {
  display: grid; gap: .45rem; padding: .7rem .85rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: 14px; box-shadow: var(--shadow);
}
.appr-head { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.appr-head .avatar { width: 32px; height: 32px; font-size: .85rem; border-radius: 50%; }
.appr-title { display: grid; min-width: 0; }
.appr-title strong { font-size: .92rem; }
.appr-title span { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appr-sum { margin: 0; font-size: .93rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.appr-where { margin: 0; display: flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--warn); }
.appr-where .ic { width: 16px; height: 16px; }
.appr-lock { margin: 0; font-size: .8rem; color: var(--muted); }
.appr-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.cmd summary {
  display: flex; align-items: center; gap: .4rem; min-height: 44px; width: fit-content;
  cursor: pointer; list-style: none; font-size: .86rem; font-weight: 600; color: var(--brand);
}
.cmd summary::-webkit-details-marker, .al-sum::-webkit-details-marker { display: none; }
.cmd summary::before, .al-sum::before { content: "▸"; display: inline-block; transition: transform .15s; }
.cmd[open] summary::before, .al-row[open] > .al-sum::before { transform: rotate(90deg); }
.cmd pre, .al-pre {
  margin: 0; padding: .6rem .75rem; max-height: 40dvh; overflow: auto;
  background: var(--code-bg); border-radius: 10px;
  font-family: var(--mono); font-size: .82rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}

.tool-strip {
  flex: none; display: flex; align-items: center; gap: .6rem; min-height: 48px;
  padding: 2px clamp(10px, 2vw, 24px); background: var(--surface); border-top: 1px solid var(--line);
  font-size: .85rem; color: var(--muted);
}
.tool-strip > .ic { width: 18px; height: 18px; color: var(--brand); }
.tool-strip-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Arbeitsprotokoll */
.al-list { display: grid; gap: 6px; }
.al-empty { margin: 1.5rem 0; text-align: center; color: var(--muted); font-size: .9rem; }
.al-row { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.al-sum {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; min-height: 44px;
  padding: .55rem .75rem; cursor: pointer; list-style: none; border-radius: 12px;
}
.al-sum:hover { background: var(--surface-2); }
.al-sum::before { color: var(--faint); }
.al-agent { font-weight: 700; font-size: .85rem; }
.al-time { font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.al-text { flex-basis: 100%; font-size: .9rem; overflow-wrap: anywhere; }
.al-body { display: grid; gap: .45rem; padding: 0 .75rem .8rem; }
.al-field { margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; font-size: .86rem; }
.al-k { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); min-width: 6.5rem; }
.al-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.st { font-size: .72rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.st-running, .st-pending { background: var(--brand-50); color: var(--brand); }
.st-approval { background: var(--warn-bg); color: var(--warn); }
.st-done { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.st-failed, .st-interrupted { background: var(--danger-bg); color: var(--danger); }

.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; background: rgba(8, 14, 26, .97); color: #fff; flex-direction: column; }
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(0, 0, 0, .7); }
.lb-head { display: flex; align-items: center; gap: .25rem; padding: calc(8px + env(safe-area-inset-top)) 10px 8px 18px; }
.lb-name { flex: 1; min-width: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.lightbox .icon-btn { color: #DFE6F2; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px 16px; }
.lb-stage img { max-width: calc(100% - 110px); max-height: 100%; object-fit: contain; border-radius: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 520px); padding: .7rem 1rem; border-radius: 12px;
  background: #172536; color: #fff; font-size: .9rem; box-shadow: var(--shadow-lg);
}

/* ---------- Mittlere Breite: Details überlagern ---------- */
@media (max-width: 1180px) {
  .details { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow-lg); }
}

/* ---------- Mobil: Liste -> Chat ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 100%; grid-template-rows: 100%; }
  .rail { display: none; }
  .mobile-only { display: inline-grid; }
  .sidebar, .convo { grid-area: 1 / 1; height: 100dvh; border: 0; }
  .convo { transition: transform .26s cubic-bezier(.2, .7, .2, 1), visibility 0s; z-index: 2; }
  .sidebar { transition: transform .26s cubic-bezier(.2, .7, .2, 1), opacity .26s, visibility 0s; }
  .app[data-pane="list"] .convo { transform: translateX(100%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .7, .2, 1), visibility 0s .26s; }
  .app[data-pane="chat"] .sidebar { transform: translateX(-20%); opacity: 0; visibility: hidden; transition: transform .26s, opacity .26s, visibility 0s .26s; }
  .side-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .convo-head { padding: calc(6px + env(safe-area-inset-top)) 6px 6px 4px; min-height: 60px; }
  .back-btn { display: inline-grid; }
  .head-id { gap: .6rem; padding: 4px; }
  .head-id .avatar { width: 38px; height: 38px; }
  .chan { min-height: 68px; }
  .column { padding: 10px 10px 16px; }
  .bubble-wrap { max-width: 88%; }
  .msg > .avatar { display: none; }
  .msg:not(.mine) .acts, .msg:not(.mine) .react-pop { left: 0; }
  .msg:hover .acts, .msg:focus-within .acts { display: none; }
  .msg.sel .acts { display: flex; }
  .acts { top: auto; bottom: -50px; }
  .acts .icon-btn { width: 44px; height: 44px; }
  .react-pop { top: auto; bottom: -106px; }
  .msg.sel { margin-bottom: 54px; }
  .msg.sel.popopen { margin-bottom: 112px; }
  .att img { max-width: 100%; max-height: 240px; }
  .details { position: fixed; inset: 0; width: 100%; z-index: 30; border: 0; padding-top: env(safe-area-inset-top); }
  .composer { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .field textarea { max-height: 104px; }
  .pill span { min-height: 44px; }
  .field .icon-btn { width: 44px; height: 44px; }
  .react-chip, .seg span { min-height: 44px; }
  .emoji-panel { right: 8px; left: 8px; width: auto; grid-template-columns: repeat(7, 1fr); }
  .emoji-panel button { height: 44px; }
  .lb-stage img { max-width: 100%; }
  .lb-nav { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .14) !important; }
  #lb-prev { left: 16px; }
  #lb-next { right: 16px; }
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .jump { right: 12px; }
  .dlg.scroll { width: calc(100vw - 16px); max-height: calc(100dvh - 16px - env(safe-area-inset-top)); }
  .approvals { max-height: 40dvh; padding: 6px 8px; }
  .appr-acts .btn { flex: 1; }
  .tool-strip { padding: 2px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
