/* ===== Open-WebUI-inspiriertes Dark Theme ===== */
:root {
  --bg: #171717;          /* Hauptfläche (gray-900) */
  --bg-side: #0d0d0d;     /* Sidebar (gray-950) */
  --bg-elev: #212121;     /* Karten/Modals */
  --bg-input: #262626;    /* Inputs (gray-850) */
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #ececec;
  --text-2: #b4b4b4;
  --text-3: #8e8e8e;
  --text-4: #676767;
  --accent: #3b82f6;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: #93c5fd; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* ===== Basis-Elemente ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; cursor: pointer; border-radius: 9999px;
  padding: .5rem 1rem; font-weight: 500; font-size: .875rem;
  background: var(--bg-input); color: var(--text);
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #303030; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: #fff; color: #000; }
.btn-primary:hover { background: #e5e5e5; }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .6rem; border: none; cursor: pointer;
  background: transparent; color: var(--text-2); transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.active { color: #facc15; }
.icon-btn svg, .btn svg, .nav-item svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }

.input, .select, .textarea {
  width: 100%; background: var(--bg-input); border: 1px solid transparent;
  border-radius: var(--radius); padding: .55rem .85rem; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--border-strong); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { resize: vertical; min-height: 5rem; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%23999'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem; padding-right: 2.2rem; }

label.field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--text-3); }
label.field > span { padding-left: .2rem; }
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: #fff; width: 1rem; height: 1rem; }

.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: .5rem 0; }

/* ===== Login ===== */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-logo { display: flex; align-items: center; gap: .6rem; justify-content: center; font-size: 1.6rem; font-weight: 600; margin-bottom: .5rem; }
.auth-logo .logo { width: 2.2rem; height: 2.2rem; }
.auth-card .input { padding: .75rem 1rem; }
.auth-card .btn { padding: .75rem; }
.auth-switch { text-align: center; font-size: .85rem; color: var(--text-3); }
.auth-switch button { background: none; border: none; color: var(--text); cursor: pointer; text-decoration: underline; }

.error-box { background: rgba(239,68,68,.12); color: #fca5a5; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }
.info-box { background: rgba(59,130,246,.12); color: #bfdbfe; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }

/* ===== App-Layout ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 260px; flex-shrink: 0; background: var(--bg-side);
  display: flex; flex-direction: column; transition: margin-left .2s ease;
  border-right: 1px solid rgba(255,255,255,0.03);
}
.sidebar.collapsed { margin-left: -260px; }
.sidebar-top { padding: .6rem .6rem .25rem; display: flex; flex-direction: column; gap: .15rem; }
.brand { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem .6rem; font-weight: 600; font-size: 1rem; }
.brand .logo { width: 1.5rem; height: 1.5rem; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: .25rem .6rem 1rem; }
.sidebar-section { margin-top: .9rem; }
.sidebar-label { font-size: .72rem; font-weight: 500; color: var(--text-4); padding: .2rem .55rem .35rem; display: flex; align-items: center; gap: .3rem; }
.sidebar-label .icon-btn { width: 1.4rem; height: 1.4rem; }
.sidebar-label .icon-btn svg { width: .9rem; height: .9rem; }

.nav-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .45rem .55rem; border-radius: .6rem; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; text-align: left; font-size: .875rem;
  transition: background .12s, color .12s; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item .count { margin-left: auto; font-size: .72rem; color: var(--text-3); font-weight: 600; }
.nav-item.unread .label { font-weight: 600; color: var(--text); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .hover-actions { display: none; margin-left: auto; }
.nav-item:hover .hover-actions { display: flex; }
.nav-item:hover .hover-actions + .count { display: none; }

.new-btn {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .55rem .6rem; border-radius: .6rem; border: none; background: transparent;
  color: var(--text); cursor: pointer; font-weight: 500;
}
.new-btn:hover { background: var(--bg-hover); }
.new-btn .plus { width: 1.6rem; height: 1.6rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; }
.new-btn .plus svg { width: 1rem; height: 1rem; }

.account-head { display: flex; align-items: center; gap: .5rem; padding: .35rem .55rem; border-radius: .6rem; cursor: pointer; color: var(--text-2); font-size: .8rem; font-weight: 500; }
.account-head:hover { background: var(--bg-hover); }
.account-dot { width: .55rem; height: .55rem; border-radius: 9999px; flex-shrink: 0; }
.chev { width: .9rem; height: .9rem; transition: transform .15s; color: var(--text-4); }
.chev.open { transform: rotate(90deg); }

.sidebar-bottom { padding: .5rem .6rem .7rem; position: relative; }
.user-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem; border-radius: .7rem; border: none; background: transparent; cursor: pointer; color: var(--text); }
.user-btn:hover { background: var(--bg-hover); }
.avatar { width: 2rem; height: 2rem; border-radius: 9999px; background: linear-gradient(135deg, #6366f1, #ec4899); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; color: #fff; flex-shrink: 0; text-transform: uppercase; }
.avatar.sm { width: 2.2rem; height: 2.2rem; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 5rem; height: 5rem; font-size: 2rem; }
.avatar-edit { position: relative; cursor: pointer; border-radius: 9999px; flex-shrink: 0; }
.avatar-edit .overlay { position: absolute; inset: 0; border-radius: 9999px; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; color: #fff; }
.avatar-edit .overlay svg { width: 1.4rem; height: 1.4rem; }
.avatar-edit:hover .overlay { opacity: 1; }
.avatar-edit.drag .overlay { opacity: 1; background: rgba(59,130,246,.55); }

.menu {
  position: absolute; z-index: 60; min-width: 13rem; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .3rem; display: flex; flex-direction: column;
}
.menu button, .menu a { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: .55rem; border: none; background: none; cursor: pointer; text-align: left; color: var(--text); font-size: .85rem; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--bg-hover); }
.menu button svg { width: 1rem; height: 1rem; color: var(--text-3); }
.menu .danger { color: #fca5a5; }

/* ===== Hauptbereich ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { height: 3.25rem; display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; flex-shrink: 0; }
.topbar h1 { font-size: 1.05rem; font-weight: 500; margin: 0; }
/* Suchleiste exakt mittig: gleich breite Seitenspalten, Mitte max. 40rem */
.topbar-center { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 40rem) minmax(0, 1fr); gap: .75rem; }
.topbar-center .tb-left { display: flex; align-items: center; min-width: 0; }
.topbar-center .tb-right { display: flex; align-items: center; justify-content: flex-end; min-width: 0; }
.topbar-center .search { max-width: none; width: 100%; }
@media (max-width: 800px) {
  .topbar-center { grid-template-columns: auto minmax(0, 1fr); }
  .topbar-center .tb-right { display: none; }
}
.search {
  flex: 1; max-width: 40rem; display: flex; align-items: center; gap: .5rem;
  background: var(--bg-input); border-radius: 9999px; padding: .1rem .4rem .1rem .9rem;
}
.search input { flex: 1; background: transparent; border: none; outline: none; padding: .45rem 0; }
.search svg { width: 1rem; height: 1rem; color: var(--text-3); }

.content { flex: 1; display: flex; min-height: 0; }

/* ===== Mail-Liste ===== */
.list-pane { width: 420px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.list-pane.full { width: auto; flex: 1; border-right: none; }
.list-toolbar { display: flex; align-items: center; gap: .15rem; padding: .25rem .6rem; min-height: 2.6rem; border-bottom: 1px solid var(--border); }
.list-toolbar .chips { display: flex; gap: .3rem; margin-left: .4rem; }
.chip { border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); border-radius: 9999px; padding: .15rem .65rem; font-size: .75rem; cursor: pointer; }
.chip.on { background: #fff; color: #000; border-color: #fff; }
.msg-list { flex: 1; overflow-y: auto; }
.msg {
  display: flex; gap: .65rem; padding: .7rem .9rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.035);
  transition: background .1s; position: relative;
}
.msg:hover { background: var(--bg-hover); }
.msg.selected { background: var(--bg-active); }
.msg.checked { background: rgba(59,130,246,.12); }
.msg .msg-check { display: flex; align-items: flex-start; padding-top: .15rem; }
.msg .msg-check input { accent-color: #fff; }
.msg .body { flex: 1; min-width: 0; }
.msg .line1 { display: flex; align-items: baseline; gap: .5rem; }
.msg .from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg .date { font-size: .74rem; color: var(--text-3); flex-shrink: 0; }
.msg .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: .85rem; }
.msg .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-4); font-size: .8rem; }
.msg.unread .from, .msg.unread .subject { color: var(--text); font-weight: 600; }
.msg.unread .date { color: var(--text); font-weight: 600; }
.msg.unread::before { content: ""; position: absolute; left: .3rem; top: 50%; width: .35rem; height: .35rem; margin-top: -.175rem; border-radius: 9999px; background: var(--accent); }
.msg .icons { display: flex; gap: .15rem; align-items: center; color: var(--text-3); }
.msg .icons svg { width: .85rem; height: .85rem; }
.msg .star { color: #facc15; }
/* Gmail-artige Zeilen-Aktionen: erscheinen beim Überfahren anstelle des Datums */
.msg .line1 { position: relative; }
.row-actions { display: none; align-items: center; gap: .05rem; flex-shrink: 0; margin: -.3rem -.3rem -.3rem 0; }
.row-actions .icon-btn { width: 1.75rem; height: 1.75rem; border-radius: 9999px; }
.row-actions .icon-btn svg { width: 1rem; height: 1rem; }
.row-actions .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.msg:hover .row-actions, .msg:focus-within .row-actions { display: flex; }
.msg:hover .line1 .date, .msg:focus-within .line1 .date { display: none; }
/* Touch-Geräte haben kein Hover -> Aktionen dezent dauerhaft zeigen */
@media (hover: none) {
  .row-actions { display: flex; }
  .msg .line1 .date { display: none; }
}
.msg mark { background: rgba(250, 204, 21, .22); color: #fde68a; border-radius: .2rem; padding: 0 .1rem; }
.msg .preview mark { color: #fde68a; }
.hit-meta { display: flex; align-items: center; gap: .35rem; margin-top: .25rem; font-size: .7rem; color: var(--text-3); }
.hit-meta .account-dot { width: .45rem; height: .45rem; }
.folder-tag { background: var(--bg-input); border-radius: .35rem; padding: .05rem .4rem; color: var(--text-2); }
.search .seg button { padding: .2rem .65rem; font-size: .75rem; }
.list-footer { display: flex; align-items: center; justify-content: space-between; padding: .4rem .8rem; font-size: .78rem; color: var(--text-3); border-top: 1px solid var(--border); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; flex: 1; color: var(--text-4); padding: 2rem; text-align: center; }
.empty svg { width: 3rem; height: 3rem; opacity: .5; }

/* ===== Lesebereich ===== */
.read-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.read-toolbar { display: flex; align-items: center; gap: .15rem; padding: .25rem .6rem; min-height: 2.6rem; border-bottom: 1px solid var(--border); }
.read-scroll { flex: 1; overflow-y: auto; padding: 1.25rem 1.75rem 2rem; }
.read-subject { font-size: 1.35rem; font-weight: 500; margin: 0 0 1rem; word-break: break-word; }
.read-head { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; }
.read-head .who { flex: 1; min-width: 0; }
.read-head .who .name { font-weight: 600; }
.read-head .who .addr { color: var(--text-3); font-size: .82rem; }
.read-head .who .to { color: var(--text-3); font-size: .78rem; margin-top: .1rem; }
.read-head .date { color: var(--text-3); font-size: .8rem; white-space: nowrap; }
.mail-frame-wrap { background: #fff; border-radius: var(--radius); overflow: hidden; }
.mail-frame-wrap.dark { background: transparent; }
.mail-frame { width: 100%; border: none; display: block; min-height: 120px; }
.remote-banner { display: flex; align-items: center; gap: .6rem; background: var(--bg-elev); border-radius: var(--radius); padding: .5rem .8rem; margin-bottom: .75rem; font-size: .82rem; color: var(--text-2); }
.attachments { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.attachment { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); font-size: .82rem; max-width: 16rem; }
.attachment:hover { background: #2a2a2a; }
.attachment svg { width: 1.1rem; height: 1.1rem; color: var(--text-3); flex-shrink: 0; }
.invite-card { display: flex; align-items: center; gap: .9rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.invite-card .date-badge { width: 3.2rem; text-align: center; border-radius: .6rem; background: #2a2a2a; padding: .3rem 0; }
.invite-card .date-badge .m { font-size: .65rem; text-transform: uppercase; color: #f87171; font-weight: 600; }
.invite-card .date-badge .d { font-size: 1.3rem; font-weight: 600; }
.quick-reply { display: flex; gap: .5rem; margin-top: 1.25rem; }

/* ===== Composer (Gmail-artig, unten rechts) ===== */
.composer {
  position: fixed; right: 1.5rem; bottom: 0; width: 560px; max-width: calc(100vw - 2rem);
  height: 560px; max-height: calc(100vh - 2rem); background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow); z-index: 50;
  display: flex; flex-direction: column;
}
.composer.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, 90vw); height: 85vh; border-radius: var(--radius-lg); }
.composer.min { height: auto; }
.composer-head { display: flex; align-items: center; gap: .25rem; padding: .45rem .5rem .45rem 1rem; background: #262626; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; font-size: .875rem; font-weight: 500; }
.composer.max .composer-head { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.composer-head .icon-btn { width: 1.75rem; height: 1.75rem; }
.composer-fields { padding: 0 1rem; }
.composer-field { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.composer-field > span { color: var(--text-3); font-size: .85rem; min-width: 3rem; }
.composer-field input, .composer-field select { flex: 1; background: transparent; border: none; outline: none; padding: .55rem 0; }
.composer-field select option { background: var(--bg-elev); }
.composer-field .toggle { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: .8rem; }
.composer-field .toggle:hover { color: var(--text); }
.editor { flex: 1; overflow-y: auto; padding: .8rem 1rem; outline: none; min-height: 6rem; word-wrap: break-word; }
.editor:empty::before { content: attr(data-placeholder); color: var(--text-4); }
.editor blockquote { border-left: 2px solid var(--border-strong); margin: .5rem 0; padding-left: .8rem; color: var(--text-3); }
.composer-atts { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 1rem .5rem; }
.att-chip { display: flex; align-items: center; gap: .3rem; background: var(--bg-input); border-radius: 9999px; padding: .2rem .3rem .2rem .7rem; font-size: .75rem; }
.att-chip button { border: none; background: none; color: var(--text-3); cursor: pointer; display: flex; }
.composer-foot { display: flex; align-items: center; gap: .2rem; padding: .6rem .8rem; border-top: 1px solid var(--border); }
.fmt-bar { display: flex; gap: .05rem; }
.fmt-bar .icon-btn { width: 1.8rem; height: 1.8rem; }

/* ===== Modals ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 32rem; max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 52rem; }
.modal-head { display: flex; align-items: center; padding: 1rem 1.25rem .5rem; }
.modal-head h2 { margin: 0; font-size: 1.1rem; font-weight: 500; flex: 1; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .75rem 1.25rem 1.1rem; }

.settings { display: flex; min-height: 26rem; }
.settings-nav { width: 12rem; padding: .25rem .75rem 1rem; display: flex; flex-direction: column; gap: .1rem; flex-shrink: 0; }
.settings-body { flex: 1; padding: .25rem 1.25rem 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; max-height: 70vh; }
.settings-body h3 { margin: .2rem 0 0; font-size: .95rem; font-weight: 500; }
.card { background: var(--bg-input); border-radius: var(--radius); padding: .75rem .9rem; display: flex; align-items: center; gap: .75rem; }
.card .grow { flex: 1; min-width: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; background: #111; padding: .45rem .7rem; border-radius: .55rem; word-break: break-all; user-select: all; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem .9rem; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
legend { padding: 0 .4rem; font-size: .8rem; color: var(--text-3); }

/* ===== Toasts ===== */
.toasts { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--bg-elev); border: 1px solid var(--border-strong); padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .85rem; pointer-events: auto; display: flex; gap: .6rem; align-items: center; }
.toast.error { border-color: rgba(239,68,68,.5); color: #fca5a5; }
.toast button { background: none; border: none; color: #93c5fd; cursor: pointer; font-weight: 500; }

.spinner { width: 1.2rem; height: 1.2rem; border: 2px solid rgba(255,255,255,.15); border-top-color: #fff; border-radius: 9999px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-bar { height: 2px; background: linear-gradient(90deg, transparent, #fff, transparent); background-size: 200% 100%; animation: load 1s linear infinite; }
@keyframes load { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===== Kalender ===== */
.cal-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.cal-toolbar { display: flex; align-items: center; gap: .4rem; padding: .25rem .9rem .6rem; }
.cal-toolbar h2 { margin: 0 0 0 .4rem; font-size: 1.15rem; font-weight: 500; }
.seg { display: inline-flex; background: var(--bg-input); border-radius: 9999px; padding: .15rem; }
.seg button { border: none; background: transparent; padding: .3rem .8rem; border-radius: 9999px; cursor: pointer; color: var(--text-2); font-size: .82rem; }
.seg button.on { background: #fff; color: #000; }

.month { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto; min-height: 0; border-top: 1px solid var(--border); overflow-y: auto; }
.month-head { font-size: .72rem; color: var(--text-3); text-align: center; padding: .4rem 0; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.month-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .25rem .25rem .35rem; min-height: 6.5rem; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: rgba(255,255,255,.02); }
.month-cell.other { background: rgba(0,0,0,.18); }
.month-cell.other .daynum { color: var(--text-4); }
.daynum { font-size: .78rem; width: 1.6rem; height: 1.6rem; display: flex; align-items: center; justify-content: center; border-radius: 9999px; align-self: center; margin-bottom: 1px; }
.daynum.today { background: #fff; color: #000; font-weight: 600; }
.ev-pill { font-size: .74rem; padding: .08rem .4rem; border-radius: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; display: flex; align-items: center; gap: .3rem; color: var(--text); }
.ev-pill:hover { filter: brightness(1.2); }
.ev-pill.allday { color: #fff; }
.ev-pill .dot { width: .45rem; height: .45rem; border-radius: 9999px; flex-shrink: 0; }
.ev-pill .t { color: var(--text-3); flex-shrink: 0; }
.more { font-size: .72rem; color: var(--text-3); padding-left: .4rem; cursor: pointer; }
.more:hover { color: var(--text); }

.week { flex: 1; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--border); }
.week-head { display: flex; border-bottom: 1px solid var(--border); padding-right: 8px; }
.week-head .gutter, .week-allday .gutter { width: 3.5rem; flex-shrink: 0; font-size: .65rem; color: var(--text-4); display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 .4rem .3rem 0; }
.week-head .wd { flex: 1; text-align: center; padding: .4rem 0; min-width: 0; }
.week-head .wd .n { font-size: 1.3rem; width: 2.4rem; height: 2.4rem; margin: 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 9999px; cursor: pointer; }
.week-head .wd .n:hover { background: var(--bg-hover); }
.week-head .wd .n.today { background: #fff; color: #000; font-weight: 600; }
.week-head .wd .l { font-size: .7rem; color: var(--text-3); text-transform: uppercase; }
.week-allday { display: flex; border-bottom: 1px solid var(--border); padding-right: 8px; min-height: 1.6rem; }
.week-allday .col { flex: 1; padding: 2px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); min-width: 0; }
.week-body { flex: 1; overflow-y: auto; position: relative; }
.week-grid { display: flex; position: relative; }
.week-grid .hours { width: 3.5rem; flex-shrink: 0; }
.week-grid .hour-label { height: 3rem; font-size: .65rem; color: var(--text-4); text-align: right; padding-right: .4rem; transform: translateY(-.45rem); }
.week-grid .daycol { flex: 1; position: relative; border-left: 1px solid var(--border); min-width: 0; }
.week-grid .slot { height: 3rem; border-bottom: 1px solid rgba(255,255,255,.04); cursor: pointer; }
.week-grid .slot:hover { background: rgba(255,255,255,.025); }
.ev-block { position: absolute; border-radius: .4rem; padding: .15rem .35rem; font-size: .72rem; overflow: hidden; cursor: pointer; border-left: 3px solid; line-height: 1.25; }
.ev-block:hover { filter: brightness(1.15); z-index: 5; }
.ev-block .t { opacity: .8; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 9999px; background: #ef4444; }

.agenda { flex: 1; overflow-y: auto; padding: 0 1rem 2rem; border-top: 1px solid var(--border); }
.agenda-day { display: flex; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.agenda-day .d { width: 5rem; flex-shrink: 0; color: var(--text-3); font-size: .85rem; }
.agenda-day .d.today { color: var(--text); font-weight: 600; }
.agenda-day .evs { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.agenda-ev { display: flex; gap: .7rem; align-items: center; padding: .35rem .5rem; border-radius: .5rem; cursor: pointer; }
.agenda-ev:hover { background: var(--bg-hover); }
.agenda-ev .time { width: 7.5rem; color: var(--text-3); font-size: .82rem; flex-shrink: 0; }

.mini-cal { padding: .25rem .3rem; }
.mini-cal .mhead { display: flex; align-items: center; font-size: .82rem; padding: 0 .2rem .3rem; }
.mini-cal .mhead .icon-btn { width: 1.5rem; height: 1.5rem; }
.mini-cal .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; font-size: .7rem; }
.mini-cal .grid .h { color: var(--text-4); padding: .15rem 0; }
.mini-cal .grid button { border: none; background: none; color: var(--text-2); width: 1.7rem; height: 1.7rem; border-radius: 9999px; cursor: pointer; font-size: .7rem; margin: 0 auto; }
.mini-cal .grid button:hover { background: var(--bg-hover); }
.mini-cal .grid button.other { color: var(--text-4); }
.mini-cal .grid button.today { background: #fff; color: #000; font-weight: 600; }
.mini-cal .grid button.sel:not(.today) { background: rgba(255,255,255,.12); color: var(--text); }

.cal-item { display: flex; align-items: center; gap: .55rem; padding: .35rem .55rem; border-radius: .6rem; font-size: .85rem; color: var(--text-2); cursor: pointer; position: relative; }
.cal-item:hover { background: var(--bg-hover); }
.cal-item .box { width: 1rem; height: 1rem; border-radius: .3rem; border: 2px solid; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cal-item .box svg { width: .75rem; height: .75rem; color: #000; }
.cal-item .actions { display: none; margin-left: auto; }
.cal-item:hover .actions { display: flex; }
.cal-item .shared { font-size: .68rem; color: var(--text-4); }

.event-pop .when { display: flex; gap: .6rem; align-items: center; color: var(--text-2); font-size: .88rem; }
.event-pop .when svg { width: 1rem; height: 1rem; color: var(--text-3); }
.color-swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.color-swatches button { width: 1.6rem; height: 1.6rem; border-radius: 9999px; border: 2px solid transparent; cursor: pointer; }
.color-swatches button.on { border-color: #fff; }
.share-row { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: calc(100% + .25rem); background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius); z-index: 5; padding: .25rem; box-shadow: var(--shadow); }
.suggest-list button { display: flex; width: 100%; gap: .5rem; align-items: center; padding: .4rem .6rem; border: none; background: none; border-radius: .5rem; cursor: pointer; text-align: left; }
.suggest-list button:hover { background: var(--bg-hover); }

/* ===== KI-Assistent (rechte Sidebar, Open-WebUI-Stil) ===== */
.ai-panel {
  width: 400px; flex-shrink: 0; background: var(--bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; position: relative;
}
.ai-panel.wide { width: min(640px, 45vw); }
.ai-head { height: 3.25rem; display: flex; align-items: center; gap: .25rem; padding: 0 .5rem 0 .9rem; flex-shrink: 0; }
.ai-head .title { flex: 1; min-width: 0; font-weight: 500; font-size: .95rem; display: flex; align-items: center; gap: .45rem; }
.ai-head .title .model { font-size: .72rem; color: var(--text-3); font-weight: 400; }
.ai-history { position: absolute; top: 3.25rem; left: .5rem; right: .5rem; z-index: 20; max-height: 60%; overflow-y: auto; }
.ai-history .item { display: flex; align-items: center; gap: .3rem; }
.ai-history .item button.open { flex: 1; min-width: 0; }
.ai-scroll { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; display: flex; flex-direction: column; gap: 1.1rem; }
.ai-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; text-align: center; color: var(--text-3); padding: 1rem; }
.ai-empty .hello { font-size: 1.35rem; color: var(--text); font-weight: 500; }
.ai-suggest { display: flex; flex-direction: column; gap: .45rem; width: 100%; max-width: 22rem; }
.ai-suggest button { text-align: left; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius); padding: .6rem .8rem; cursor: pointer; color: var(--text-2); font-size: .85rem; }
.ai-suggest button:hover { border-color: var(--border-strong); color: var(--text); }
.ai-msg.user { align-self: flex-end; max-width: 85%; background: var(--bg-input); border-radius: 1.25rem; padding: .55rem .95rem; white-space: pre-wrap; word-break: break-word; }
.ai-msg.assistant { display: flex; gap: .65rem; align-items: flex-start; }
.ai-msg.assistant .ai-avatar { width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: .05rem; }
.ai-msg.assistant .ai-avatar svg { width: 1rem; height: 1rem; }
.ai-msg .ai-body { flex: 1; min-width: 0; line-height: 1.6; word-break: break-word; }
.ai-tool { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--text-3); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9999px; padding: .15rem .65rem .15rem .45rem; margin: 0 .3rem .35rem 0; }
.ai-tool svg { width: .85rem; height: .85rem; }
.ai-tool.error { color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.ai-tool .spinner { width: .75rem; height: .75rem; border-width: 1.5px; }
.ai-tool.done svg { color: #86efac; }
.ai-typing { display: inline-flex; gap: .25rem; padding: .3rem 0; }
.ai-typing span { width: .4rem; height: .4rem; border-radius: 9999px; background: var(--text-3); animation: aiblink 1.2s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiblink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-error { background: rgba(239, 68, 68, .12); color: #fca5a5; border-radius: var(--radius); padding: .55rem .8rem; font-size: .85rem; }
.ai-input-wrap { padding: .4rem .75rem .9rem; flex-shrink: 0; }
.ai-input { background: var(--bg-input); border: 1px solid var(--border); border-radius: 1.5rem; padding: .55rem .55rem .55rem 1rem; display: flex; align-items: flex-end; gap: .4rem; }
.ai-input:focus-within { border-color: var(--border-strong); }
.ai-input textarea { flex: 1; background: transparent; border: none; outline: none; resize: none; max-height: 12rem; min-height: 1.5rem; line-height: 1.5; padding: .2rem 0; }
.ai-input textarea::placeholder { color: var(--text-4); }
.ai-send { width: 2rem; height: 2rem; border-radius: 9999px; border: none; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.ai-send:disabled { opacity: .3; cursor: default; }
.ai-send svg { width: 1rem; height: 1rem; }
.ai-hint { font-size: .68rem; color: var(--text-4); text-align: center; margin-top: .4rem; }

/* Markdown in Antworten */
.md p { margin: 0 0 .6rem; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2rem 0 .6rem; padding-left: 1.3rem; } .md li { margin: .15rem 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1rem; font-weight: 600; margin: .8rem 0 .4rem; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; background: rgba(255,255,255,.08); padding: .1rem .35rem; border-radius: .35rem; }
.md pre { background: #0d0d0d; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; overflow-x: auto; margin: .4rem 0 .7rem; }
.md pre code { background: none; padding: 0; font-size: .8rem; }
.md blockquote { border-left: 2px solid var(--border-strong); margin: .4rem 0; padding-left: .8rem; color: var(--text-2); }
.md a { color: #93c5fd; }
.md table { border-collapse: collapse; margin: .4rem 0 .7rem; font-size: .82rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-strong); padding: .3rem .55rem; text-align: left; }
.md th { background: rgba(255,255,255,.04); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: .8rem 0; }

@media (max-width: 1000px) {
  .ai-panel, .ai-panel.wide { position: fixed; right: 0; top: 0; bottom: 0; z-index: 65; width: min(420px, 100vw); box-shadow: var(--shadow); }
}
@media (max-width: 1000px) {
  .list-pane { width: 340px; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; z-index: 70; height: 100%; }
  .list-pane { width: auto; flex: 1; border-right: none; }
  .list-pane.hidden-mobile { display: none; }
  .composer { right: 0; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .week-head .gutter, .week-allday .gutter, .week-grid .hours { width: 2.5rem; }
}
