* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a25;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent2: #818cf8;
  --danger: #ef4444;
  --radius: 12px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* Screens */
.screen { display: none; height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* Login */
.login-container { margin: auto; padding: 40px; max-width: 380px; text-align: center; }
.login-container h1 { font-size: 2rem; margin-bottom: 4px; color: var(--accent2); }
.login-container .subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 0.85rem; }
.login-container input {
  width: 100%; padding: 14px 16px; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; background: var(--bg2); color: var(--text); font-size: 1rem;
  margin-bottom: 10px; outline: none;
}
.login-container input:focus { border-color: var(--accent); }
.login-container button {
  width: 100%; padding: 14px; border: none; border-radius: 10px;
  background: var(--accent); color: white; font-size: 1rem; font-weight: 600;
  cursor: pointer; margin-top: 6px;
}
.login-container button:hover { background: var(--accent2); }
.error { color: var(--danger); background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 10px; margin-top: 12px; font-size: 0.85rem; }

/* Header */
#chat-header {
  display: flex; align-items: center; padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 8px; min-height: 48px;
}
.header-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-title { font-weight: 600; font-size: 0.95rem; color: var(--accent2); }
.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto; }
.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Tabs Bar */
.tabs-bar {
  display: flex; gap: 2px; overflow-x: auto; flex: 1;
  scrollbar-width: none; -ms-overflow-style: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,0.04); white-space: nowrap;
  font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0;
  border: 1px solid transparent; transition: all 0.15s;
}
.tab:hover { background: rgba(255,255,255,0.08); }
.tab.active { background: var(--bg3); color: var(--text); border-color: rgba(255,255,255,0.1); }
.tab-title { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.tab-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 2px; border-radius: 4px;
}
.tab-close:hover { background: rgba(239,68,68,0.2); color: var(--danger); }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.welcome-msg { color: var(--text-muted); text-align: center; margin: auto; font-size: 1.1rem; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.5; font-size: 0.95rem; word-wrap: break-word; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg3); border-bottom-left-radius: 4px; }
.msg-content { white-space: pre-wrap; }
.msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.msg-action {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted); padding: 4px 10px; border-radius: 6px;
  font-size: 0.75rem; cursor: pointer;
}
.msg-action:hover { background: rgba(255,255,255,0.12); color: var(--text); }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; align-self: flex-start; }
.typing-indicator span {
  width: 8px; height: 8px; background: var(--text-muted); border-radius: 50%;
  animation: typing 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* Input */
.input-area { padding: 12px 16px; background: var(--bg2); border-top: 1px solid rgba(255,255,255,0.06); }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
#msg-input {
  flex: 1; padding: 12px 16px; border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-size: 1rem; resize: none; outline: none; max-height: 150px;
  font-family: inherit; line-height: 1.4;
}
#msg-input:focus { border-color: var(--accent); }
.send-btn {
  width: 44px; height: 44px; border: none; border-radius: 50%;
  background: var(--accent); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.3; cursor: default; }
.send-btn:hover:not(:disabled) { background: var(--accent2); }

/* Mobile */
@media (max-width: 600px) {
  .msg { max-width: 95%; font-size: 0.9rem; }
  .header-title { display: none; }
  .tab-title { max-width: 70px; }

  /* Extra Platz oben fuer iPhone Notch/StatusBar */
  #chat-header {
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    min-height: 56px;
    flex-wrap: wrap;
  }

  .tabs-bar {
    order: 3;
    width: 100%;
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid rgba(255,255,255,0.04);
  }

  .tab { padding: 6px 10px; font-size: 0.75rem; }

  .input-area { padding-bottom: max(12px, env(safe-area-inset-bottom, 12px)); }
  .login-container { padding: 20px; }
  .login-logo { width: min(50vw, 180px); }
}

/* PWA / Standalone Modus */
@media (display-mode: standalone) {
  #chat-header { padding-top: max(16px, env(safe-area-inset-top, 16px)); }
}

/* Logo */
.login-logo { width: min(40vw, 200px); height: auto; margin-bottom: 20px; opacity: 0.85; }
.header-logo { width: 28px; height: 28px; border-radius: 50%; }

/* SVG Background in chat */
.messages {
  background-image: url(/cv-bg-logo.png);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 80%;
  background-attachment: local;
}
