/* ZMM Studio — ruhig, hell, Markenfarben (Kobalt + Silber) */
:root {
  --bg: #eef0f4;
  --bg-deep: #e4e7ee;
  --surface: #f8f9fb;
  --surface-strong: #ffffff;
  --ink: #141b3d;
  --ink-soft: #3d4566;
  --ink-mute: #5d6584;
  --cobalt: #22439e;
  --cobalt-deep: #172e72;
  --rose: #dc4b76;
  --line: rgba(34, 67, 158, 0.12);
  --line-strong: rgba(34, 67, 158, 0.22);
  --ok: #1f7a55;
  --shadow: 0 1px 2px rgba(20, 27, 61, 0.04), 0 8px 24px -12px rgba(20, 27, 61, 0.12);
  --radius: 18px;
  --sans: "Hind", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sidebar: 288px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cobalt); }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; border-radius: 8px; }

.display {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--cobalt-deep);
}

.btn-primary {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--cobalt);
  color: #fff;
  font-weight: 500;
  padding: 0.8rem 1.4rem;
  transition: background 0.2s, transform 0.2s;
}
.btn-primary:hover { background: var(--cobalt-deep); }
.btn-primary:active { transform: scale(0.98); }

/* ---------- Login ---------- */
body.login {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 20% -10%, #ffffff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #dfe4ef 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: left;
}
.login-logo { display: block; margin-bottom: 2.5rem; }
.login-card h1 { font-size: 4rem; margin: 0; }
.login-sub { margin: 0.5rem 0 2.5rem; color: var(--ink-soft); }
.login-form { display: grid; gap: 1.1rem; }
.login-form label { display: grid; gap: 0.35rem; }
.login-form label span { font-size: 0.85rem; color: var(--ink-mute); letter-spacing: 0.02em; }
.login-form input {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 0.8rem 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form input:focus { border-color: var(--cobalt); box-shadow: 0 0 0 4px rgba(34, 67, 158, 0.1); }
.login-form .btn-primary { margin-top: 0.6rem; padding: 0.95rem; }
.login-error { margin: 0; color: #a3123e; font-size: 0.95rem; }

/* ---------- App-Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100dvh; }

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg-deep);
  min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 14px;
}
.sidebar-head img { height: 22px; width: auto; }
.sidebar-head .tag { font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--cobalt-deep); margin-left: 10px; }
.brand { display: flex; align-items: baseline; text-decoration: none; }
.new-btn {
  margin: 4px 16px 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 14px;
  padding: 0.7rem 0.95rem;
  font-weight: 500;
  color: var(--cobalt-deep);
  transition: background 0.2s, border-color 0.2s;
}
.new-btn:hover { background: var(--surface-strong); border-color: var(--cobalt); }
.new-btn svg { width: 18px; height: 18px; }

.list-label { padding: 12px 20px 6px; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); }
.conv-list { list-style: none; margin: 0; padding: 0 10px 16px; overflow-y: auto; flex: 1; }
.conv-list a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
}
.conv-list a:hover { background: rgba(255, 255, 255, 0.6); }
.conv-list a[aria-current="page"] { background: var(--surface-strong); box-shadow: var(--shadow); }
.conv-title { display: block; font-size: 0.95rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-mute); margin-top: 2px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cobalt); animation: pulse 1.4s ease-in-out infinite; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.9rem; color: var(--ink-soft);
}
.sidebar-foot a { text-decoration: none; }
.link-btn { appearance: none; border: 0; background: none; padding: 0; color: var(--ink-mute); font-size: 0.85rem; }
.link-btn:hover { color: var(--cobalt); }

/* ---------- Hauptbereich ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--cobalt-deep);
}
.icon-btn:hover { background: rgba(34, 67, 158, 0.07); }
.icon-btn svg { width: 22px; height: 22px; }

.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread-inner { max-width: 760px; margin: 0 auto; padding: 48px 28px 32px; }

/* Leerer Zustand */
.empty { padding-top: 10vh; }
.empty h1 { font-size: clamp(2.8rem, 6vw, 4.2rem); margin: 0 0 0.6rem; }
.empty p { color: var(--ink-soft); font-size: 1.15rem; margin: 0 0 2.4rem; max-width: 34rem; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.suggestion {
  appearance: none; text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.suggestion:hover { border-color: var(--line-strong); background: var(--surface-strong); transform: translateY(-1px); }
.suggestion strong { display: block; font-weight: 500; color: var(--cobalt-deep); }
.suggestion span { display: block; font-size: 0.9rem; color: var(--ink-mute); line-height: 1.4; margin-top: 2px; }

/* Nachrichten */
.msg { margin: 0 0 28px; }
.msg.enter { animation: rise 0.35s ease both; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  max-width: 85%;
  background: var(--cobalt);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 20px 20px 6px 20px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-user .who { font-size: 0.78rem; color: var(--ink-mute); margin-bottom: 4px; }
.msg-user .attach { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg-user .attach img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.msg-user .attach .chip { font-size: 0.8rem; color: var(--ink-mute); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }

.msg-agent { color: var(--ink); }
.msg-agent .prose > :first-child { margin-top: 0; }
.msg-agent .prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 0.9em; }
.prose ul, .prose ol { margin: 0 0 0.9em; padding-left: 1.3em; }
.prose li { margin: 0.2em 0; }
.prose h3, .prose h4 { font-size: 1rem; font-weight: 600; margin: 1.2em 0 0.4em; color: var(--cobalt-deep); }
.prose strong { font-weight: 600; }
.prose code { font-size: 0.88em; background: rgba(34, 67, 158, 0.07); padding: 0.1em 0.35em; border-radius: 6px; }
.prose blockquote { margin: 0 0 0.9em; padding-left: 1em; border-left: 2px solid var(--line-strong); color: var(--ink-soft); }

/* Arbeitsschritte */
.steps { margin: 0 0 22px; font-size: 0.92rem; color: var(--ink-mute); }
.steps summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 8px; border-radius: 999px; transition: background 0.15s;
}
.steps summary::-webkit-details-marker { display: none; }
.steps summary:hover { background: rgba(34, 67, 158, 0.06); }
.steps summary svg { width: 14px; height: 14px; transition: transform 0.2s; }
.steps[open] summary svg { transform: rotate(90deg); }
.steps ol { list-style: none; margin: 8px 0 0 14px; padding: 0 0 0 14px; border-left: 1px solid var(--line-strong); }
.steps li { padding: 2px 0; }

.live-step { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 22px; }
.live-step .label { background: linear-gradient(90deg, var(--ink-mute) 0%, var(--cobalt) 50%, var(--ink-mute) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2.2s linear infinite; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(34, 67, 158, 0.18); border-top-color: var(--cobalt); animation: spin 0.9s linear infinite; flex: none; }

/* Live-Karte */
.live-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 14px 0 0;
  padding: 14px 16px 14px 18px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.live-card .state { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ok); }
.live-card .state i { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(31, 122, 85, 0.14); }
.live-card .path { display: block; font-weight: 400; color: var(--ink-mute); font-size: 0.85rem; }
.live-card a { text-decoration: none; font-weight: 500; white-space: nowrap; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.45rem 0.95rem; }
.live-card a:hover { border-color: var(--cobalt); }

.notice { margin: 0 0 22px; padding: 12px 16px; border-radius: 14px; background: rgba(220, 75, 118, 0.08); color: #8f1d40; font-size: 0.95rem; }

/* Eingabe */
.composer-wrap { padding: 0 28px 22px; background: linear-gradient(180deg, transparent, var(--bg) 30%); }
.composer {
  max-width: 760px; margin: 0 auto;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 10px 10px 10px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 4px rgba(34, 67, 158, 0.06), var(--shadow); }
.composer.drag { border-color: var(--cobalt); border-style: dashed; }
.composer textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  min-height: 28px; max-height: 260px; padding: 8px 0 4px; line-height: 1.5;
}
.composer textarea::placeholder { color: #8a90a8; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-hint { font-size: 0.78rem; color: var(--ink-mute); }
.composer-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.send-btn {
  appearance: none; border: 0; width: 42px; height: 42px; border-radius: 50%;
  background: var(--cobalt); color: #fff; display: grid; place-items: center;
  transition: background 0.2s, opacity 0.2s, transform 0.2s;
}
.send-btn:hover { background: var(--cobalt-deep); }
.send-btn:disabled { opacity: 0.35; cursor: default; }
.send-btn svg { width: 18px; height: 18px; }
.send-btn.stop { background: var(--ink); }
.previews { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0 2px; }
.previews:empty { display: none; }
.preview { position: relative; }
.preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; }
.preview button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; font-size: 13px; line-height: 22px; padding: 0;
}
.preview.loading img { opacity: 0.4; }
.preview.loading::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; border: 2px solid rgba(34, 67, 158, 0.2); border-top-color: var(--cobalt); animation: spin 0.9s linear infinite; }

.scrim { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 20;
    transform: translateX(-102%); transition: transform 0.28s ease;
    box-shadow: 0 0 60px rgba(20, 27, 61, 0.2);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 27, 61, 0.25); z-index: 10; }
  .topbar { display: flex; }
  .topbar img { height: 18px; }
  .thread-inner { padding: 28px 16px 24px; }
  .empty { padding-top: 4vh; }
  .suggestions { grid-template-columns: 1fr; }
  .composer-wrap { padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .msg-user .bubble { max-width: 92%; }
  body { font-size: 16px; }
}
