:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-soft: #f0f0f2;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --brand-soft: #ecfdf3;
  --danger: #dc2626;
  --warn-bg: #fffbeb;
  --warn: #92400e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 4px 16px rgba(24, 24, 27, .05);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(247, 247, 248, .88); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; min-height: 60px; }
.topbar h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.desktop-nav { display: none; gap: 4px; margin-left: 24px; }
.desktop-nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px; }
.desktop-nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.spacer { flex: 1; }
.page { max-width: 960px; margin: 0 auto; padding: 8px 16px 24px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 8px calc(6px + var(--safe-b));
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; border-radius: 10px; }
.bottom-nav a.active { color: var(--brand-dark); }

@media (min-width: 900px) {
  .desktop-nav { display: flex; }
  .bottom-nav { display: none; }
  .shell { padding-bottom: 32px; }
  .page { padding-top: 16px; }
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  min-height: 44px; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: #fafafa; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(0, 0, 0, .04); }
.btn-danger { color: var(--danger); }
.btn-lg { min-height: 54px; font-size: 17px; padding: 12px 22px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #3f3f46; }
.field small { color: var(--muted); font-size: 12px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 16px;
  outline: none; transition: border-color .15s, box-shadow .15s; min-height: 46px;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-zip { grid-template-columns: 110px 1fr; }
@media (max-width: 420px) { .grid-2.stack-sm { grid-template-columns: 1fr; } }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; cursor: pointer; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: #d4d4d8; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.muted { color: var(--muted); }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, #dcfce7, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand-mark { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 14px; }
.auth-head h1 { font-size: 26px; letter-spacing: -.03em; margin: 0 0 4px; }
.auth-head p { margin: 0; color: var(--muted); }
.segmented { display: flex; background: #ececef; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 10px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- Rechnungsliste ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 18px; }
.stat { padding: 14px 16px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.cta-new { margin-bottom: 20px; }
.inv-list { display: flex; flex-direction: column; overflow: hidden; }
.inv-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; border-bottom: 1px solid var(--line-soft); }
.inv-row:last-child { border-bottom: 0; }
.inv-row:hover { background: #fcfcfc; }
.inv-main { flex: 1; min-width: 0; }
.inv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-sub { font-size: 13px; color: var(--muted); }
.inv-amount { font-weight: 700; text-align: right; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #f4f4f5; color: #52525b; margin-top: 3px; }
.pill-offen { background: #fef3c7; color: #92400e; }
.pill-bezahlt { background: var(--brand-soft); color: var(--brand-dark); }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-state h3 { margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); }

/* ---------- Sheet (Neue Rechnung) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(24, 24, 27, .4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .22s cubic-bezier(.2, .8, .2, 1); max-height: 92dvh; overflow: auto; }
.sheet-grip { width: 40px; height: 5px; border-radius: 9px; background: #d4d4d8; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.sheet p.lead { margin: 0 0 16px; color: var(--muted); }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; padding: 22px 24px 24px; }
  .sheet-grip { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.dictate { position: relative; }
.dictate .textarea { min-height: 150px; padding-bottom: 64px; font-size: 17px; }
.mic {
  position: absolute; right: 10px; bottom: 10px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--brand); color: #fff;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(22, 163, 74, .35);
}
.mic.rec { background: var(--danger); box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }
.example { font-size: 13px; color: var(--muted); margin: 10px 2px 16px; }

/* ---------- Editor ---------- */
.editor { display: flex; flex-direction: column; height: 100dvh; }
.editor .topbar { background: var(--surface); border-bottom-color: var(--line); }
.editor .topbar-inner { max-width: none; padding: 10px 12px; min-height: 56px; gap: 8px; }
.editor-title { flex: 1; min-width: 0; }
.editor-title .t1 { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-title .t2 { font-size: 13px; color: var(--muted); }
.editor-tabs { padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.editor-body { flex: 1; min-height: 0; display: flex; }
.pane { flex: 1; min-width: 0; min-height: 0; display: none; flex-direction: column; }
.pane.show { display: flex; }
.pane-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.preview-pane { background: #ececef; }
.preview-wrap { padding: 16px; display: flex; justify-content: center; }
.paper { background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .08); border-radius: 4px; overflow: hidden; position: relative; transform-origin: top left; }
.zoom-hint { text-align: center; font-size: 13px; color: var(--muted); padding: 0 16px 20px; }
@media (min-width: 1000px) { .zoom-hint { display: none; } }
.paper iframe { border: 0; width: 794px; display: block; transform-origin: top left; pointer-events: none; }

.chat-log { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.typing { color: var(--muted); }
.chat-empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 13px; font-size: 14px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand-dark); }

.composer { padding: 10px 12px calc(10px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); }
.composer-inner { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px; resize: none; min-height: 46px; max-height: 140px; outline: none; font-size: 16px; line-height: 1.4; background: var(--bg); }
.composer textarea:focus { border-color: var(--brand); background: #fff; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.round-mic { background: var(--brand-soft); color: var(--brand-dark); }
.round-mic.rec { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
.round-send { background: var(--brand); color: #fff; }
.round-send:disabled { opacity: .45; }
.reply-pop { margin: 0 0 8px; background: var(--text); color: #fff; padding: 10px 14px; border-radius: 14px; font-size: 14px; animation: up .2s; }

.edit-form { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; width: 100%; }
.item-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.item-head { display: flex; align-items: center; justify-content: space-between; }
.item-head b { font-size: 13px; color: var(--muted); font-weight: 600; }
.item-grid { display: grid; grid-template-columns: .8fr 1.2fr 1.1fr; gap: 8px; }
.item-total { text-align: right; font-size: 14px; color: var(--muted); }
.totals-box { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); font-weight: 700; color: var(--brand-dark); }

.check-bar { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid #fde68a; background: var(--warn-bg); color: var(--warn); padding: 9px 14px; font-size: 13px; text-align: left; cursor: pointer; line-height: 1.35; }

@media (min-width: 1000px) {
  .editor { display: grid; grid-template-columns: 440px 1fr; grid-template-rows: auto auto auto 1fr auto; }
  .editor > .topbar { grid-column: 1 / -1; }
  .editor-tabs { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); }
  .check-bar { grid-column: 1; grid-row: 3; border-right: 1px solid var(--line); }
  .editor-body { display: contents; }
  .editor-tabs .seg-preview { display: none; }
  .pane.side { grid-column: 1; grid-row: 4; border-right: 1px solid var(--line); background: var(--bg); min-height: 0; }
  .preview-pane { display: flex !important; grid-column: 2; grid-row: 2 / 6; min-height: 0; }
  .composer { grid-column: 1; grid-row: 5; border-right: 1px solid var(--line); }
  .reply-pop { display: none; }
}

/* ---------- Vorlagen ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tpl { overflow: hidden; display: flex; flex-direction: column; }
.tpl.is-default { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand), var(--shadow); }
.tpl-thumb { background: #ececef; padding: 14px; display: flex; justify-content: center; height: 260px; overflow: hidden; cursor: pointer; }
.tpl-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tpl-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tpl-desc { font-size: 14px; color: var(--muted); flex: 1; }
.tpl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 600; background: var(--brand); color: #fff; border-radius: 99px; padding: 2px 9px; }
@media (max-width: 560px) {
  .tpl-grid { grid-template-columns: 1fr; }
}

.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=color] { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; background: #fff; cursor: pointer; }

/* ---------- Profil ---------- */
.logo-box { display: flex; align-items: center; gap: 14px; }
.logo-preview { width: 96px; height: 72px; border: 1px dashed var(--line); border-radius: var(--radius-sm); display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.save-bar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); margin-top: 20px; z-index: 5; }
@media (min-width: 900px) { .save-bar { bottom: 16px; } }

/* ---------- Toasts / Loader ---------- */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: up .2s; }
.toast.err { background: var(--danger); }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(0, 0, 0, .12); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px; }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.12); min-width: 210px; padding: 6px; z-index: 40; }
.menu-list button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 15px; text-align: left; }
.menu-list button:hover { background: var(--bg); }
.status-select { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; background: var(--surface); font-size: 14px; font-weight: 600; min-height: 36px; }
@media (max-width: 480px) { .hide-sm { display: none !important; } }

/* ---------- Neue Rechnung: Ein-Knopf-Spracheingabe ---------- */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 35; display: inline-flex; align-items: center; gap: 8px;
  height: 58px; padding: 0 22px 0 18px; border-radius: 99px; border: 0; background: var(--brand); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 24px rgba(22, 163, 74, .4); cursor: pointer; transition: transform .2s, opacity .2s;
}
.fab:active { transform: scale(.96); }
.fab-hidden { opacity: 0; transform: translateY(20px) scale(.9); pointer-events: none; }
@media (min-width: 900px) { .fab { bottom: 24px; right: 24px; } }
.cta-new { margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cta-type { color: var(--muted); }
.only-wide { display: none !important; }
@media (min-width: 1000px) { .only-wide { display: inline-flex !important; } }

.voice {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; padding: 16px 20px calc(20px + var(--safe-b));
  background: radial-gradient(900px 500px at 50% 0%, #dcfce7, transparent 65%), var(--surface); animation: fade .15s;
}
.voice-close { align-self: flex-end; }
.voice-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; max-width: 560px; width: 100%; margin: 0 auto; }
.voice-orb { width: 108px; height: 108px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 30px rgba(22, 163, 74, .35); }
.voice.listening .voice-orb { animation: orb 1.6s ease-out infinite; }
.voice.idle .voice-orb { background: #a1a1aa; box-shadow: none; }
.voice-orb .spinner { width: 34px; height: 34px; border-width: 3.5px; }
@keyframes orb { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45), 0 10px 30px rgba(22, 163, 74, .35); } 100% { box-shadow: 0 0 0 34px rgba(22, 163, 74, 0), 0 10px 30px rgba(22, 163, 74, .35); } }
.voice-status { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.voice-text { font-size: 19px; line-height: 1.45; min-height: 84px; max-height: 34dvh; overflow: auto; padding: 0 4px; }
.voice-text .interim { color: var(--muted); }
.voice-hint { color: var(--muted); font-size: 16px; }
.voice-actions { display: flex; flex-direction: column; gap: 8px; max-width: 420px; width: 100%; margin: 0 auto; }
.voice-done { background: var(--text); border-color: var(--text); color: #fff; }
.voice-done:hover { background: #000; }

/* ---------- Versionen ---------- */
.ver-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 0 11px; min-height: 36px; font-size: 14px; font-weight: 700; cursor: pointer; color: #3f3f46; }
.ver-btn.viewing { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.ver-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; background: #eff6ff; color: #1e3a8a; border-bottom: 1px solid #bfdbfe; font-size: 14px; }
.ver-banner-text { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ver-banner-actions { display: flex; gap: 4px; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.ver-list { display: flex; flex-direction: column; position: relative; margin: 0 -6px; }
.ver-item { display: flex; gap: 14px; text-align: left; border: 0; background: none; padding: 10px 8px 14px; border-radius: 12px; cursor: pointer; position: relative; }
.ver-item:hover { background: var(--bg); }
.ver-item.selected { background: var(--brand-soft); }
.ver-item:not(:last-child)::before { content: ""; position: absolute; left: 24px; top: 44px; bottom: -8px; width: 2px; background: var(--line); }
.ver-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #f4f4f5; color: #52525b; flex-shrink: 0; position: relative; z-index: 1; }
.ver-dot.src-ki, .ver-dot.src-erstellt { background: var(--brand-soft); color: var(--brand-dark); }
.ver-dot.src-status { background: #fef3c7; color: #92400e; }
.ver-dot.src-wiederhergestellt { background: #eff6ff; color: #1d4ed8; }
.ver-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ver-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ver-sum { font-size: 14px; color: #3f3f46; }
.ver-meta { font-size: 12px; color: var(--muted); }
.ver-badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 800; letter-spacing: .02em; background: var(--text); color: #fff; border-radius: 6px; padding: 1px 6px; flex-shrink: 0; }

/* ---------- Chat ---------- */
.msg { display: flex; gap: 8px; max-width: 88%; }
.msg.user { align-self: flex-end; flex-direction: column; align-items: flex-end; gap: 3px; }
.msg.assistant { align-self: flex-start; align-items: flex-end; }
.msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg .bubble { max-width: 100%; }
.msg-time { font-size: 11px; color: var(--muted); padding: 0 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; flex-shrink: 0; margin-bottom: 20px; }
.msg.assistant .typing { padding: 13px 16px; }
.msg.assistant:has(.typing) .avatar { margin-bottom: 0; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: #a1a1aa; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.day-sep { display: flex; justify-content: center; margin: 6px 0 2px; }
.day-sep span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--line-soft); border-radius: 99px; padding: 2px 10px; }
.ver-event { align-self: center; display: flex; align-items: center; gap: 8px; max-width: 94%; border: 1px dashed var(--line); background: transparent; border-radius: 99px; padding: 5px 12px 5px 6px; cursor: pointer; font-size: 13px; color: #52525b; }
.ver-event:hover, .ver-event.selected { border-style: solid; border-color: #93c5fd; background: #eff6ff; }
.ver-event-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ver-event-time { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.doc-card { align-self: stretch; display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); cursor: pointer; margin: 4px 0; }
.doc-card.selected { border-color: var(--brand); }
.doc-thumb { width: 116px; height: 120px; overflow: hidden; border-radius: 8px; background: #ececef; display: flex; justify-content: center; padding-top: 8px; flex-shrink: 0; pointer-events: none; }
.doc-thumb .paper { border-radius: 2px; }
.doc-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.doc-top { display: flex; align-items: center; gap: 6px; }
.doc-label { font-size: 12px; font-weight: 600; color: var(--brand-dark); }
.doc-title { font-weight: 700; }
.doc-sub { font-size: 14px; color: #3f3f46; }
.doc-change { font-size: 13px; color: var(--muted); }
@media (min-width: 1000px) { .doc-thumb { display: none; } .doc-card { cursor: default; } }
.frozen { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

@media (min-width: 1000px) {
  .ver-banner { grid-column: 2; grid-row: 2; align-self: start; z-index: 5; margin: 12px 16px 0; border: 1px solid #bfdbfe; border-radius: 12px; box-shadow: var(--shadow); }
}

/* Laufende Anfrage im Chat */
.msg.pending { animation: up .25s ease-out; }
.bubble.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.typing-label { background: linear-gradient(90deg, var(--muted) 0%, #d4d4d8 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

/* Kennzeichnung der Nicht-Produktiv-Umgebungen */
html[data-env] body::after {
  content: attr(data-env); position: fixed; top: calc(env(safe-area-inset-top, 0px) + 6px); left: 50%; transform: translateX(-50%); z-index: 200;
  background: #f97316; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 99px; pointer-events: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
html[data-env="dev"] body::after { content: "DEV"; }
html[data-env="local"] body::after { content: "LOKAL"; background: #6366f1; }
