/* CavaBau – Gestaltung: warme Töne (Kalkstein, Terrakotta), mobil und Desktop */

:root {
  --bg: #f4f1ec; --surface: #fff; --surface2: #faf8f4; --ink: #2b2622; --muted: #7b726a; --line: #e4ddd3;
  --accent: #7a4b2a; --accent2: #b5653a; --accent-soft: #f3e6dc; --ok: #3d7a4f; --ok-soft: #e3f0e6;
  --warn: #b7791f; --warn-soft: #fbf0d9; --red: #b3392f; --red-soft: #f8e2df; --blue: #2f5f8a; --blue-soft: #e2ecf5;
  --radius: 10px; --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 2px 8px rgba(60, 40, 20, .05);
  --side: 248px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --surface: #24211d; --surface2: #2a2622; --ink: #ece6dd; --muted: #a39a90; --line: #3a352f;
    --accent: #d99a6c; --accent2: #e0a477; --accent-soft: #3a2b20; --ok: #7cc28f; --ok-soft: #22332a;
    --warn: #e2b55c; --warn-soft: #3a3120; --red: #e57a70; --red-soft: #3d2522; --blue: #8ab4dc; --blue-soft: #22303d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 14px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 22px 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { margin-left: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* Rahmen */
.shell { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 14.5px; }
.nav a:hover { background: var(--surface2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 4px; }
.nav .cnt { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav .cnt.hot { color: var(--red); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; text-align: center; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.main { margin-left: var(--side); padding: 22px 28px 60px; max-width: 1180px; }
.topbar, .tabbar { display: none; }

.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.langs button { border: 0; background: transparent; padding: 3px 9px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.langs button.on { background: var(--accent); color: #fff; }

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card + .card { margin-top: 10px; }
.grid { display: grid; gap: 12px; }
.grid.cols2 { grid-template-columns: 1fr 1fr; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: block; color: var(--ink); border-left: 4px solid var(--c, var(--accent)); }
.tile:hover { text-decoration: none; border-color: var(--line); border-left-color: var(--c, var(--accent)); background: var(--surface2); }
.tile .t { font-weight: 650; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 14px; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface2); text-decoration: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12.5px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; }
.chip.draft { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }
.chip.approved { background: var(--blue-soft); border-color: transparent; color: var(--blue); font-weight: 600; }
.chip.sent { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.late { background: var(--red-soft); border-color: transparent; color: var(--red); font-weight: 600; }
.chip.soon { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14.5px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.head h1 { margin: 0; }
.empty { color: var(--muted); padding: 18px 4px; }
.err { color: var(--red); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

/* Verlauf */
.entry { position: relative; }
.entry .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.entry .who { color: var(--ink); font-weight: 600; font-size: 14px; }
.entry .kind { font-size: 15px; }
.entry .dir-in { color: var(--blue); }
.entry .dir-out { color: var(--accent2); }
.entry .subj { font-weight: 600; margin-bottom: 4px; }
.texts { display: grid; grid-template-columns: 1fr; gap: 10px; }
.texts.two { grid-template-columns: 1fr 1fr; }
.txt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.txt.clip { max-height: 9.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.tr { border-left: 3px solid var(--accent-soft); padding-left: 10px; }
.tr .lab, .orig .lab { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.more { font-size: 13px; cursor: pointer; color: var(--accent); background: none; border: 0; padding: 4px 0 0; }
.entry .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.atts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 3px 9px; border-radius: 6px; background: var(--surface2); border: 1px solid var(--line); color: var(--ink); }
.daysep { font-size: 12.5px; color: var(--muted); margin: 18px 2px 6px; font-weight: 600; }

/* Listen und Tabellen */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.li { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; }
.li.done .t { text-decoration: line-through; color: var(--muted); }
.li:hover { background: var(--surface2); }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface); flex: none; cursor: pointer; margin-top: 1px; display: grid; place-items: center; color: #fff; font-size: 14px; }
.check.on { background: var(--ok); border-color: var(--ok); }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.t th, table.t td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; font-size: 14px; }
table.t th { background: var(--surface2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
table.t tr:hover td { background: var(--surface2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Projektakte */
.dossier .stand { font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; }
.dossier ul { margin: 4px 0 0; padding-left: 20px; }
.dossier li { margin: 4px 0; }
.dossier .sec { margin-top: 16px; }

/* KI-Gespräch */
.chatwrap { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.chatlist a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatlist a.on { background: var(--accent-soft); color: var(--accent); }
.msgs { display: flex; flex-direction: column; gap: 12px; min-height: 200px; }
.msg { max-width: 860px; padding: 11px 14px; border-radius: 12px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; white-space: pre-wrap; max-width: 80%; }
.msg.assistant { background: var(--surface); border: 1px solid var(--line); }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.wait { color: var(--muted); font-style: italic; }
.ref { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-weight: 600; cursor: pointer; vertical-align: 1px; }
.ask { display: flex; gap: 8px; margin-top: 14px; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.ask textarea { flex: 1; resize: none; min-height: 46px; max-height: 180px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }

/* Formulare */
.dlg-back { position: fixed; inset: 0; background: rgba(30, 20, 10, .35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.dlg { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.dlg h2 { margin: 0 0 14px; }
.dlg .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.f { display: block; margin-top: 12px; }
.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.f input, .f select, .f textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.f textarea { min-height: 120px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .ask textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent2); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pick { display: flex; gap: 6px; flex-wrap: wrap; }
.pick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.pick button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 9px; z-index: 80; font-size: 14px; max-width: 90vw; }
.login { max-width: 360px; margin: 12vh auto; }
.login .brand { justify-content: center; font-size: 24px; }
.preview iframe, .preview img { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; object-fit: contain; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv .k { color: var(--muted); }
.cs { display: grid; grid-template-columns: minmax(70px, 38%) 1fr; gap: 6px; }
.search-in { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface2); margin-bottom: 10px; }

/* Mobil */
@media (max-width: 900px) {
  .side { display: none; }
  .main { margin-left: 0; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; background: var(--bg);
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px; border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; font-size: 17px; }
  .topbar .brand img { width: 26px; height: 26px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0; font-size: 11px; color: var(--muted); position: relative; }
  .tabbar a .ico { font-size: 19px; height: 22px; }
  .tabbar a.on { color: var(--accent); font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .badge { position: absolute; top: 1px; left: 56%; background: var(--red); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; }
  h1 { font-size: 20px; }
  .grid.tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .grid.tiles .card { padding: 10px 12px; }
  .grid.tiles .t { font-size: 14.5px; line-height: 1.3; }
  .grid.cols2, .texts.two, .f2 { grid-template-columns: 1fr; }
  .chatwrap { grid-template-columns: 1fr; }
  .chatlist { display: none; }
  .chatlist.open { display: block; }
  /* mobil: Dialog bildschirmfüllend und mit dem Inhalt mitwachsend (nicht auf Bildschirmhöhe gestreckt, sonst läuft langer Inhalt ohne Hintergrund über) */
  .dlg-back { padding: 0; display: block; background: var(--surface); overscroll-behavior: contain; }
  .dlg { border-radius: 0; min-height: 100%; height: auto; box-shadow: none; padding: calc(14px + env(safe-area-inset-top)) 16px calc(90px + env(safe-area-inset-bottom)); }
  table.t.resp thead { display: none; }
  table.t.resp, table.t.resp tbody, table.t.resp tr, table.t.resp td { display: block; width: 100%; }
  table.t.resp tr { border-top: 1px solid var(--line); padding: 8px 4px; }
  table.t.resp td { border: 0; padding: 2px 10px; }
  table.t.resp td.num { text-align: left; }
  .hide-m { display: none !important; }
}
@media (min-width: 901px) { .hide-d { display: none !important; } }
