/* ============ Meine KI – Styles ============ */
:root {
  --bg: #0b0f16;
  --bg2: #0e1420;
  --panel: #121a29;
  --panel2: #172238;
  --border: #22304a;
  --text: #e6edf7;
  --text-dim: #8fa3c0;
  --accent: #22d3ee;
  --accent2: #7c3aed;
  --accent-soft: rgba(34, 211, 238, .14);
  --danger: #ef4444;
  --ok: #34d399;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  /* iPhone: Abstände für Notch/Dynamic Island und Home-Balken */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Arbeit-Profil (Containerterminal) */
body[data-profile="arbeit"] {
  --accent: #f97316;
  --accent2: #f59e0b;
  --accent-soft: rgba(249, 115, 22, .15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 700px at 80% -10%, rgba(124, 58, 237, .10), transparent 60%),
              radial-gradient(900px 600px at -10% 110%, var(--accent-soft), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overscroll-behavior-y: none;   /* iPhone: kein Gummiband-Wackeln der ganzen Seite */
}

body[data-profile="arbeit"] {
  background: radial-gradient(1200px 700px at 80% -10%, rgba(249, 115, 22, .10), transparent 60%),
              radial-gradient(900px 600px at -10% 110%, var(--accent-soft), transparent 55%),
              var(--bg);
}

button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* iPhone: kein Grau-Blitzen beim Antippen, keine Zoom-Verzögerung */
button, .btn, .icon-btn, .nav-item, .chip, .cal-day, .note-card, .task-row, .task-check {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.spacer { flex: 1; }
.muted { color: var(--text-dim); font-weight: normal; font-size: 13px; }

/* ============ SIDEBAR ============ */
#sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-text h1 { font-size: 19px; margin: 0; line-height: 1.1; }
.brand-text span { font-size: 12px; color: var(--text-dim); }

.ai-orb {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--accent), var(--accent2), var(--accent));
  animation: orb-spin 6s linear infinite, orb-pulse 2.4s ease-in-out infinite;
  box-shadow: 0 0 18px var(--accent);
  position: relative;
}
.ai-orb::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--panel);
}
.ai-orb.big { width: 54px; height: 54px; min-width: 54px; }
.ai-orb.big::after { inset: 7px; }

@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-pulse {
  0%, 100% { box-shadow: 0 0 12px var(--accent); }
  50% { box-shadow: 0 0 26px var(--accent); }
}
.ai-orb.thinking { animation-duration: 1.2s, .8s; }

.profile-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg2);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.profile-switch button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.profile-switch button svg { width: 15px; height: 15px; fill: currentColor; }
.profile-switch button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f16;
}
.profile-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: -6px;
  display: none;
}
body[data-profile="privat"] .profile-hint { display: block; }

#mainNav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; fill: currentColor; }
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.badge {
  margin-left: auto;
  background: var(--accent);
  color: #0b0f16;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  display: none;
}
.badge.show { display: inline-block; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.key-status {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}
.key-status.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.key-status-label { font-size: 12px; color: var(--text-dim); }

/* ============ MAIN / TABS ============ */
#main { flex: 1; overflow: hidden; position: relative; }
.tab { display: none; height: 100%; overflow-y: auto; padding: 22px; }
.tab.active { display: block; }
#tab-dashboard.active { display: flex; flex-direction: column; overflow: hidden; }

.section-title { margin: 4px 0 18px; font-size: 22px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 0;
  color: #0b0f16;
}
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(239, 68, 68, .12); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel2);
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }
.icon-btn:hover { color: var(--text); filter: brightness(1.2); }

/* ============ DASHBOARD ============ */
.overview-strip {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-dim);
}
.overview-strip b { color: var(--text); }
.overview-strip .sep { color: var(--border); }

.chat-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.chat-header-text h2 { margin: 0; font-size: 18px; }
.chat-header-text span { font-size: 12.5px; color: var(--text-dim); }
#btnClearChat { margin-left: auto; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;   /* iPhone: Chat scrollt, Seite nicht */
}

.msg { display: flex; gap: 10px; max-width: 88%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar {
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 50%;
  background: var(--panel2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}
.msg.assistant .avatar {
  background: conic-gradient(var(--accent), var(--accent2), var(--accent));
  border: 0;
}
.msg .bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--accent-soft), var(--panel2));
  border-color: var(--accent);
}
.msg .bubble .msg-time { display: block; margin-top: 6px; font-size: 11px; color: var(--text-dim); white-space: normal; }
.msg .tool-notes {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ok);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  white-space: normal;
}
.msg .bubble.error { border-color: var(--danger); color: #fca5a5; }

.msg-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg-images img {
  height: 84px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.attach-bar { display: flex; gap: 8px; padding: 8px 0; flex-wrap: wrap; }
.attach-bar:empty { padding: 0; }

.attach-thumb {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.attach-thumb img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; }
.attach-thumb .remove {
  cursor: pointer;
  color: var(--danger);
  font-weight: 700;
  padding: 0 3px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));   /* iPhone: über dem Home-Balken */
}
#chatInput {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 40px;
  line-height: 1.4;
}

.chat-side {
  width: 290px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.side-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.side-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.side-list { display: flex; flex-direction: column; gap: 8px; }
.side-list .empty { color: var(--text-dim); font-size: 13px; }
.side-event { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.side-event .time { color: var(--accent); font-weight: 700; min-width: 40px; }
.side-event .dot { width: 8px; height: 8px; min-width: 8px; border-radius: 50%; align-self: center; }

.quick-actions { display: flex; flex-direction: column; gap: 7px; }
.quick-actions button {
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
}
.quick-actions button:hover { border-color: var(--accent); color: var(--accent); }

/* ============ KALENDER ============ */
.cal-layout { display: flex; gap: 16px; align-items: flex-start; }
.cal-main {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-title { font-size: 19px; margin: 0 4px; min-width: 170px; text-align: center; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}
.cal-weekdays div { text-align: center; padding: 4px 0; }
.cal-weekdays div:nth-child(6), .cal-weekdays div:nth-child(7) { color: var(--accent); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(88px, auto);
  gap: 6px;
}
.cal-day {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .12s;
}
.cal-day:hover { border-color: var(--accent); }
.cal-day.other { opacity: .38; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-day .day-num { font-size: 12.5px; font-weight: 700; color: var(--text-dim); text-align: right; padding-right: 2px; }
.cal-day.today .day-num { color: var(--accent); }
.cal-day .ev {
  font-size: 11px;
  line-height: 1.25;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .05);
  border-left: 3px solid var(--cat, var(--accent));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-day .ev.allday { font-style: italic; }
.cal-day .more { font-size: 11px; color: var(--text-dim); padding-left: 3px; }

.cal-side { width: 300px; min-width: 250px; display: flex; flex-direction: column; gap: 14px; }

.day-details-date { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.day-event {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  margin-bottom: 7px;
  font-size: 13.5px;
}
.day-event .dot { width: 10px; height: 10px; min-width: 10px; border-radius: 50%; }
.day-event .meta { color: var(--text-dim); font-size: 12px; }
.day-event .grow { flex: 1; min-width: 0; }
.day-event .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-event .actions { display: flex; gap: 4px; }
.day-event .actions button {
  border: 0; background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 13px; padding: 3px 6px; border-radius: 6px;
}
.day-event .actions button:hover { color: var(--accent); background: var(--panel2); }
.upcoming-day { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: 6px; }

/* ============ NOTIZEN ============ */
.notes-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.notes-toolbar input[type="search"] { width: 280px; }
.notes-toolbar select { width: 160px; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.note-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .12s, transform .12s;
  position: relative;
}
.note-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.note-card.pinned { border-color: var(--accent); box-shadow: 0 0 14px var(--accent-soft); }
.note-card h4 { margin: 0; font-size: 15px; padding-right: 26px; }
.note-card .note-preview {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  max-height: 90px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-card .note-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.note-card .note-tags span {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}
.note-card .note-foot { display: flex; justify-content: space-between; align-items: center; color: var(--text-dim); font-size: 11.5px; }
.note-card .pin {
  position: absolute;
  top: 10px; right: 8px;
  background: none; border: 0; cursor: pointer;
  font-size: 15px; color: var(--text-dim);
}
.note-card .pin.pinned { color: var(--accent); }
.note-card .note-thumbs { display: flex; gap: 4px; }
.note-card .note-thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 60px 20px;
  font-size: 15px;
}

/* ============ EINSTELLUNGEN ============ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.settings-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.settings-card h3 { margin: 0 0 10px; font-size: 16px; }
.settings-card .hint { color: var(--text-dim); font-size: 13px; margin: 8px 0; }
.settings-card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.settings-card .row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.settings-card input[type="text"], .settings-card input[type="password"] { min-width: 220px; }
.settings-card.danger { border-color: var(--danger); }
.settings-card input#apiKeyInput { min-width: 260px; }

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, .72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal.wide { max-width: 720px; }
.modal.small { max-width: 380px; }
.modal h3 { margin: 0 0 14px; font-size: 18px; }

.modal form label { display: block; font-size: 13px; color: var(--text-dim); font-weight: 600; margin-bottom: 12px; }
.modal form input:not([type="checkbox"]), .modal form select, .modal form textarea { width: 100%; margin-top: 5px; }
.modal form textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }
.check-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px !important; padding-top: 22px; }
.check-label input { margin: 0; }

.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }

/* Kamera */
.camera-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; min-height: 240px; }
.camera-wrap video { width: 100%; display: block; }

.note-attach-area { margin-bottom: 12px; }
.note-attach-buttons { display: flex; gap: 8px; margin-bottom: 8px; }
.attach-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.file-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 92px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
.file-chip img { width: 78px; height: 78px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.file-chip .file-icon { width: 78px; height: 78px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--accent); }
.file-chip .file-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .remove-file {
  border: 0; background: none; color: var(--danger);
  cursor: pointer; font-weight: 700; font-size: 13px; padding: 0 4px;
}

/* Dateien-Liste */
.files-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
}
.file-row img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.file-row .file-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 18px; }
.file-row .grow { flex: 1; min-width: 0; overflow: hidden; }
.file-row .grow div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-row .grow div:last-child { color: var(--text-dim); font-size: 12px; }
.file-row button {
  border: 0; background: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 4px 7px; border-radius: 6px;
}
.file-row button:hover { color: var(--danger); background: var(--panel2); }

.text-modal-body { font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.modal-overlay.lightbox { cursor: zoom-out; }
.modal-overlay.lightbox .modal { all: unset; }
.modal-overlay.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 10px; }

/* ============ TOASTS & BENACHRÄCHTIGUNGEN ============ */
#toastContainer {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.reminder { border-left-color: var(--accent); cursor: pointer; }
.toast.reminder b { color: var(--accent); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } }

#notifCenter {
  position: fixed;
  top: calc(20px + var(--safe-top));
  right: 20px;
  z-index: 210;
  display: none;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 24px var(--accent);
  cursor: pointer;
}
#notifCenter.show { display: flex; animation: notif-bounce .6s ease infinite alternate; }
@keyframes notif-bounce { from { transform: scale(1); } to { transform: scale(1.08); } }

/* ============ ANMELDUNG (Login) ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124, 58, 237, .16), transparent 60%),
    radial-gradient(700px 500px at 20% 110%, var(--accent-soft), transparent 55%),
    rgba(5, 8, 14, .97);
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
.login-overlay.open { display: flex; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: login-in .35s ease;
}
@keyframes login-in { from { transform: translateY(16px); opacity: 0; } }

.login-card h1 {
  margin: 16px 0 2px;
  font-size: 24px;
  letter-spacing: .3px;
}
.login-sub {
  margin: 0 0 22px;
  color: var(--text-dim);
  font-size: 13px;
}
.login-orb {
  margin: 0 auto;
  display: block;
}

.login-card form { text-align: left; }
.login-card label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  font-size: 15px;
}
.login-remember {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 18px;
}
.login-remember input { margin: 0; }
.login-btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

.login-error {
  margin-top: 14px;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}
.login-error.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.login-links { margin-top: 8px; text-align: center; }
.login-switch {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 6px;
  text-decoration: underline;
}
.login-switch:hover { filter: brightness(1.25); }

.register-title { margin: 0 0 4px; font-size: 18px; text-align: center; }
.register-hint {
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 0 0 14px;
  text-align: left;
  font-weight: 400;
}
.login-mini-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Abmelde-Knopf in der Sidebar */
.sidebar-footer .icon-btn { width: 30px; height: 30px; min-width: 30px; }
.sidebar-footer .icon-btn svg { width: 15px; height: 15px; }

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============ AUFGABEN ============ */
.tasks-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tasks-input-row #taskInput { flex: 1; min-width: 220px; }
.tasks-input-row #taskDue { width: 150px; }
.tasks-input-row #taskPrio { width: 110px; }

.tasks-filter { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.task-row.done { opacity: .55; }
.task-row .task-check {
  width: 22px; height: 22px; min-width: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0f16;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}
.task-row .task-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.task-row .task-title { flex: 1; min-width: 0; font-size: 14.5px; word-break: break-word; }
.task-row.done .task-title { text-decoration: line-through; }
.task-row .task-title input {
  width: 100%;
  font-size: 14.5px;
}
.task-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.task-due {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.task-due.overdue { background: rgba(239, 68, 68, .15); color: var(--danger); }
.task-prio { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.task-prio.p1 { background: rgba(239, 68, 68, .15); color: #f87171; }
.task-prio.p2 { background: rgba(250, 204, 21, .12); color: #facc15; }
.task-prio.p3 { background: rgba(148, 163, 184, .15); color: #94a3b8; }
.task-row .task-actions { display: flex; gap: 4px; }
.task-row .task-actions button {
  border: 0; background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 4px 7px; border-radius: 6px;
}
.task-row .task-actions button:hover { color: var(--accent); background: var(--panel2); }
.task-row .task-actions button.del:hover { color: var(--danger); }

/* ============ WETTER ============ */
.mini-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 0 4px;
  vertical-align: middle;
}
.mini-btn:hover { color: var(--accent); }
.weather-box { font-size: 13.5px; line-height: 1.6; color: var(--text-dim); }
.weather-box .weather-now {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
}
.weather-box .weather-now b { font-size: 24px; color: var(--accent); }
.weather-box .weather-desc { font-size: 13px; }
.weather-box .weather-line { margin-top: 6px; }
.weather-box .weather-wind { color: var(--text); }

/* Container-Prüfer nur im Arbeit-Profil */
body[data-profile="privat"] #containerCard { display: none; }
#containerCard input { width: 100%; text-transform: uppercase; letter-spacing: 1px; font-size: 15px; }
.container-result { margin-top: 10px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.container-result.ok { color: var(--ok); }
.container-result.bad { color: var(--danger); }
.container-result.info { color: var(--text-dim); }

/* KW-Anzeige im Kalender */
.cal-day .kw {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
}
.cal-day .day-num { display: flex; align-items: center; justify-content: flex-end; }

/* KI-Aktionen im Notiz-Editor */
.note-ki-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Mikrofon-Button: Aufnahme */
#btnChatMic.recording {
  color: var(--danger);
  border-color: var(--danger);
  animation: notif-bounce .6s ease infinite alternate;
}

/* ============ RESPONSIVE (Handy / iPhone 17 Pro) ============ */
@media (max-width: 980px) {
  #app { flex-direction: column; height: auto; min-height: 100vh; min-height: 100dvh; }

  /* ---------- Kopfzeile: schlank und kompakt ---------- */
  #sidebar {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) 10px calc(12px + var(--safe-left));
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand { gap: 8px; padding: 0; flex: 1; min-width: 0; }
  .brand .ai-orb { width: 26px; height: 26px; min-width: 26px; }
  .brand .ai-orb::after { inset: 4px; }
  .brand-text h1 { font-size: 15px; white-space: nowrap; }
  .brand-text span, .profile-hint { display: none !important; }
  .profile-switch {
    display: flex;
    grid-template-columns: none;
    padding: 3px;
    gap: 3px;
  }
  .profile-switch button { padding: 5px 9px; font-size: 11.5px; }
  .profile-switch button svg { width: 12px; height: 12px; }
  .sidebar-footer { margin: 0; padding: 3px 6px; gap: 6px; }
  .key-status { width: 8px; height: 8px; min-width: 8px; }
  .key-status-label { display: none; }
  .sidebar-footer .icon-btn { width: 26px; height: 26px; min-width: 26px; }
  .sidebar-footer .icon-btn svg { width: 13px; height: 13px; }

  /* ---------- Untere Tab-Leiste: wie echte iOS-Apps ---------- */
  #mainNav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    background: rgba(14, 20, 32, .95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 5px calc(6px + var(--safe-left)) calc(5px + var(--safe-bottom)) calc(6px + var(--safe-left));
  }
  .nav-item {
    position: relative;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 2px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .2px;
    border-radius: 10px;
  }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.active { background: none; box-shadow: none; color: var(--accent); }
  .badge { position: absolute; top: 2px; right: 10px; margin: 0; font-size: 9.5px; padding: 0 5px; }

  /* Platz für die untere Leiste schaffen */
  #main { padding-bottom: calc(62px + var(--safe-bottom)); }
  .tab { padding: 12px; }
  #tab-dashboard.active { overflow-y: auto; }   /* Handy: Dashboard komplett scrollbar */

  /* ---------- Dashboard/Chat ---------- */
  .chat-layout, .cal-layout { flex-direction: column; }
  .chat-side, .cal-side { width: 100%; }
  .chat-main { min-height: 68dvh; border-radius: 14px; }
  .overview-strip { font-size: 12px; padding: 10px 12px; gap: 6px; }
  .chat-header { padding-bottom: 10px; }
  .chat-header h2 { font-size: 16px; }
  .chat-header .ai-orb.big { width: 40px; height: 40px; min-width: 40px; }
  .chat-header .ai-orb.big::after { inset: 5px; }
  .msg { max-width: 94%; }
  #btnClearChat { padding: 6px 10px; font-size: 12px; }
  .quick-actions button { padding: 11px 12px; }

  /* ---------- Kalender: kompakt und gut lesbar ---------- */
  .cal-main { padding: 12px; border-radius: 14px; }
  .cal-toolbar { flex-wrap: wrap; gap: 6px; }
  .cal-title { font-size: 15px; min-width: 0; flex: 1; text-align: center; }
  .cal-toolbar .icon-btn { width: 34px; height: 34px; min-width: 34px; }
  .cal-weekdays div { font-size: 10px; }
  .cal-grid { grid-auto-rows: minmax(48px, auto); gap: 4px; }
  .cal-day { padding: 3px; border-radius: 7px; }
  .cal-day .day-num { font-size: 11px; }
  .cal-day .kw { font-size: 8px; padding: 0 3px; }
  .cal-day .ev { font-size: 9.5px; padding: 1px 3px; border-left-width: 2px; }
  .cal-day .more { font-size: 9.5px; }
  .side-card { padding: 12px; }

  /* ---------- Aufgaben & Notizen: volle Breite, große Tipp-Flächen ---------- */
  .task-row { padding: 10px 12px; }
  .task-check { width: 28px; height: 28px; min-width: 28px; }
  .notes-grid { grid-template-columns: 1fr; }
  .notes-toolbar input[type="search"] { width: 100%; }
  .tasks-input-row #taskInput { width: 100%; min-width: 0; }
  .tasks-input-row #taskDue { width: 132px; }

  /* ---------- Formulare: 16px = kein iOS-Reinzoom, Felder untereinander ---------- */
  input, select, textarea { font-size: 16px; }
  #chatInput { font-size: 16px; }
  .modal .form-row { flex-direction: column; gap: 4px; }
  .modal .check-label { padding-top: 0 !important; }
  .modal-actions { padding-bottom: calc(4px + var(--safe-bottom)); }
}
