:root {
  --bg-body: #f5f5f7;
  --bg-sidebar: #ffffff;
  --bg-topbar: rgba(245, 245, 247, 0.92);
  --border-subtle: #d2d2d7;
  --text-main: #1d1d1f;
  --text-muted: #6e6e73;
  --accent: #0071e3;
  --accent-soft: #dbeafe;
}

/* Grundlayout */

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

/* Sidebar */

.app-sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 40;
}

/* Logo */

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 0, #60a5fa 0, #2563eb 40%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: .05em;
  color: #ffffff;
}

.app-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.app-logo-text-main {
  font-size: 1rem;
  font-weight: 600;
}

.app-logo-text-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Workspace & Modul-Titel */

.app-sidebar-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.app-sidebar-workspace {
  flex: 1;
}

.app-sidebar-module {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Workspace Nav */

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.app-nav-link {
  border-radius: 0.9rem;
  border: 1px solid transparent;
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-main);
  text-decoration: none;
  transition: all 0.15s ease-out;
}

.app-nav-link-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #f5f5f7;
  border: 1px solid #e5e5ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.app-nav-link span {
  flex: 1;
}

.app-nav-link small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.app-nav-link:hover {
  background: #f2f2f7;
  border-color: #e5e5ea;
  transform: translateY(-1px);
}

.app-nav-link.active {
  background: #e5f1ff;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 113, 227, 0.18);
}

/* Modul-Menü Kopf (Back + Titel) */

.sidebar-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sidebar-back-btn {
  font-size: 0.78rem;
  padding-inline: 0.6rem;
  border-radius: 999px;
}

.sidebar-module-title {
  font-size: 0.88rem;
  font-weight: 500;
}

/* Modul-Menü Inhalt */

.sidebar-module-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sidebar-archive {
  flex: 1;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

/* Sidebar Footer */

.app-sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge-pill-soft {
  border-radius: 999px;
  border: 1px solid #d2d2d7;
  background: #f5f5f7;
  font-size: 0.7rem;
  padding: 0.18rem 0.6rem;
  color: var(--text-muted);
}

/* Konto-Button im Sidebar-Footer */

.btn-account-sidebar {
  border-radius: 999px;
  border: 1px solid #d2d2d7;
  background: linear-gradient(to bottom, #ffffff, #f5f5f7);
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
  font-weight: 500;
}

.btn-account-sidebar:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #ffffff;
}

/* Main Area */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */

.app-topbar {
  height: 56px;
  border-bottom: 1px solid rgba(210, 210, 215, 0.9);
  background-color: var(--bg-topbar);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-topbar-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.app-topbar-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.app-main-inner {
  padding: 0.9rem;
}

/* Cards */

.card-modern {
  background: #ffffff;
  border-radius: 1.2rem;
  border: 1px solid rgba(210, 210, 215, 0.9);
  box-shadow:
    0 22px 45px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.6);
}

/* Text Studio */

.text-result {
  min-height: 220px;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

/* Chat Layout */

.chat-wrapper {
  min-height: calc(100vh - 120px);
}

.chat-sidebar-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.chat-main-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#chat-messages {
  background: #f5f5f7;
  border-radius: 1.2rem;
  border: 1px solid #e5e5ea;
  padding: 0.9rem;
  flex: 1;
  overflow: auto;
}

/* Chat Bubbles */

.chat-message {
  margin-bottom: 0.75rem;
  display: flex;
}

.chat-message--user {
  justify-content: flex-end;
}

.chat-message--assistant {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 80%;
  border-radius: 1.2rem;
  padding: 0.6rem 0.8rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  animation: bubble-in 0.18s ease-out;
  font-size: 0.9rem;
}

.chat-bubble-user {
  background: var(--accent);
  color: #ffffff;
}

.chat-bubble-assistant {
  background: #e5e5ea;
  color: #1d1d1f;
}

.chat-meta {
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.chat-meta .badge {
  font-size: 0.65rem;
}

/* Typing Indicator */

.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #e5e5ea;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #9ca3af;
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

/* Scrollbars */

* {
  scrollbar-width: thin;
  scrollbar-color: #9ca3af transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: #9ca3af;
  border-radius: 999px;
}

/* Animations */

.fade-in-up {
  opacity: 0;
  transform: translateY(6px);
  animation: fade-in-up 0.25s ease-out forwards;
}
.fade-in-up.delay-1 {
  animation-delay: 0.06s;
}
.fade-in-up.delay-2 {
  animation-delay: 0.12s;
}
.fade-in-up.delay-3 {
  animation-delay: 0.18s;
}

@keyframes fade-in-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* Mobile Sidebar / Drawer */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.24);
  }

  .app-sidebar.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
  }

  .sidebar-backdrop.sidebar-backdrop-visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .app-main-inner {
    padding: 0.6rem;
  }
}
