/* ===============================================================
   Chattify - Darkmode / Glassmorphism
   =============================================================== */

:root {
  --accent:          #3b82f6;
  --accent-soft:     #60a5fa;
  --accent-deep:     #1d4ed8;
  --accent-glow:     rgba(59, 130, 246, 0.35);

  --bg:              #070b14;
  --bg-2:            #0b1220;

  --glass:           rgba(255, 255, 255, 0.045);
  --glass-strong:    rgba(255, 255, 255, 0.075);
  --stroke:          rgba(255, 255, 255, 0.09);
  --stroke-strong:   rgba(255, 255, 255, 0.16);

  --text:            #e8eefb;
  --text-dim:        #9fb0cc;
  --text-faint:      #64748b;

  --ok:              #34d399;
  --warn:            #fbbf24;
  --danger:          #f87171;

  --radius:          18px;
  --radius-sm:       12px;
  --pill:            999px;

  --shadow:          0 18px 48px rgba(0, 0, 0, 0.55);
  --blur:            saturate(160%) blur(18px);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

/* Hintergrundverlauf */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1000px 620px at 12% -8%,  rgba(59, 130, 246, 0.20), transparent 60%),
    radial-gradient(880px 520px at 105% 8%,   rgba(29, 78, 216, 0.16),  transparent 62%),
    radial-gradient(720px 620px at 50% 115%,  rgba(96, 165, 250, 0.10), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 55%);
}

/* feines Raster */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 20%, transparent 78%);
}

::selection { background: var(--accent); color: #fff; }

/* --- Scrollbars ------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.16) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.26); background-clip: content-box; }

/* ===============================================================
   Typografie / // Prefix
   =============================================================== */

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }

.h::before,
h1.prefix::before,
h2.prefix::before,
h3.prefix::before {
  content: "// ";
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.04em;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.95rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 0.82rem; }
.mono  { font-family: var(--mono); }

/* ===============================================================
   Glasflaechen
   =============================================================== */

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}

.card { padding: 22px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ===============================================================
   Logo
   =============================================================== */

.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo svg { width: 38px; height: 38px; filter: drop-shadow(0 6px 16px var(--accent-glow)); flex: none; }
.logo-text { font-size: 1.16rem; font-weight: 680; letter-spacing: -0.03em; }
.logo-text span { color: var(--accent); }

/* ===============================================================
   Buttons - durchgehend Pillenform
   =============================================================== */

button, .btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 560;
  border-radius: var(--pill);
  border: 1px solid var(--stroke-strong);
  background: var(--glass-strong);
  color: var(--text);
  padding: 10px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}

button:hover, .btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.24); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }

button:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent) 45%, var(--accent-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.32);
}
.btn-primary:hover { box-shadow: 0 14px 34px rgba(59, 130, 246, 0.44); background: linear-gradient(135deg, #7cb0fb, #3b82f6 45%, #2563eb); }

.btn-ghost { background: transparent; border-color: var(--stroke); }
.btn-ghost:hover { background: var(--glass-strong); }

.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.32); background: rgba(248, 113, 113, 0.08); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.5); }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* ===============================================================
   Formularelemente
   =============================================================== */

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 560;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

input, textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.07);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
  outline: none;
}

textarea { resize: vertical; min-height: 92px; line-height: 1.6; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%239fb0cc' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 11px;
  padding-right: 38px;
}
select option { background: var(--bg-2); color: var(--text); }

input[type="range"] {
  padding: 0;
  height: 26px;
  background: transparent;
  border: none;
  box-shadow: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
  cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: var(--pill); background: rgba(255,255,255,0.14); }
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; cursor: pointer;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

/* ===============================================================
   Login
   =============================================================== */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 26px;
}

.login-card {
  width: 100%;
  max-width: 404px;
  padding: 40px 34px 32px;
  text-align: center;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.login-card .logo { justify-content: center; margin-bottom: 22px; }
.login-card .logo svg { width: 54px; height: 54px; }
.login-card .logo-text { font-size: 1.5rem; }

.login-card h1 { font-size: 1.25rem; margin-bottom: 6px; }
.login-card .sub { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 26px; }
.login-card form { text-align: left; }
.login-card .btn-primary { margin-top: 4px; }

.login-foot {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--stroke);
  font-size: 0.74rem;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ===============================================================
   App-Rahmen
   =============================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  background: rgba(7, 11, 20, 0.72);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-wrap: wrap;
}

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.who { text-align: right; line-height: 1.25; }
.who strong { display: block; font-size: 0.9rem; font-weight: 600; }
.who span { font-size: 0.72rem; color: var(--text-faint); font-family: var(--mono); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--pill);
  font-size: 0.68rem;
  font-weight: 620;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-family: var(--mono);
  border: 1px solid var(--stroke-strong);
  background: var(--glass-strong);
  color: var(--text-dim);
}
.badge-accent { background: rgba(59, 130, 246, 0.14); border-color: rgba(59, 130, 246, 0.36); color: var(--accent-soft); }
.badge-ok     { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.32); color: var(--ok); }
.badge-warn   { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.32); color: var(--warn); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.page { padding: 26px; max-width: 1480px; margin: 0 auto; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }

/* ===============================================================
   Mitarbeiter-Layout
   =============================================================== */

.workspace {
  display: grid;
  grid-template-columns: 322px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  height: calc(100vh - 69px - 52px);
  min-height: 560px;
}

.sidebar { display: flex; flex-direction: column; padding: 18px; height: 100%; min-height: 0; }
.sidebar .card-head { margin-bottom: 13px; }

.search-row { position: relative; margin-bottom: 13px; }
.search-row input { padding-left: 38px; border-radius: var(--pill); }
.search-row svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.contact-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; min-height: 0; }

.contact {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  padding: 11px 13px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: normal;
}
.contact:hover { background: var(--glass); border-color: var(--stroke); transform: none; }
.contact.active {
  background: rgba(59, 130, 246, 0.13);
  border-color: rgba(59, 130, 246, 0.4);
}
.contact-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contact-name { font-weight: 570; font-size: 0.89rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-meta { font-size: 0.71rem; color: var(--text-faint); font-family: var(--mono); margin-top: 2px; }
.contact-count {
  flex: none;
  font-family: var(--mono);
  font-size: 0.67rem;
  padding: 2px 8px;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
}

.sidebar-foot { padding-top: 13px; margin-top: 13px; border-top: 1px solid var(--stroke); }

/* --- Chatbereich ----------------------------------------------- */

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--stroke);
  flex-wrap: wrap;
  flex: none;
}
.chat-head h2 { font-size: 1rem; }
.chat-head .contact-meta { margin-top: 3px; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
}

.msg { max-width: 74%; display: flex; flex-direction: column; gap: 5px; animation: msgIn 0.26s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.msg-in  { align-self: flex-start; }
.msg-out { align-self: flex-end; align-items: flex-end; }

.bubble {
  padding: 11px 16px;
  border-radius: 17px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--stroke);
  background: var(--glass-strong);
}
.msg-in  .bubble { border-bottom-left-radius: 6px; }
.msg-out .bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.26), rgba(29, 78, 216, 0.2));
  border-color: rgba(59, 130, 246, 0.38);
}

.msg-meta {
  font-size: 0.68rem;
  color: var(--text-faint);
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 5px;
}
.msg-meta button {
  background: none; border: none; padding: 0;
  color: var(--text-faint); font-size: 0.68rem;
  font-family: var(--mono); cursor: pointer;
}
.msg-meta button:hover { color: var(--danger); background: none; transform: none; }

.tag-ai {
  font-size: 0.6rem;
  padding: 1px 7px;
  border-radius: var(--pill);
  background: rgba(59, 130, 246, 0.16);
  color: var(--accent-soft);
  letter-spacing: 0.07em;
}

/* --- Eingabebereich --------------------------------------------- */

.composer {
  flex: none;
  border-top: 1px solid var(--stroke);
  padding: 16px 22px 18px;
  background: rgba(255, 255, 255, 0.015);
}

.composer-row { display: flex; gap: 10px; align-items: flex-start; }
.composer-row textarea { min-height: 76px; }
.composer-actions { display: flex; flex-direction: column; gap: 8px; flex: none; width: 190px; }

.draft-box {
  margin-top: 14px;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(59, 130, 246, 0.34);
  background: rgba(59, 130, 246, 0.07);
  animation: msgIn 0.3s ease;
}
.draft-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.draft-box textarea { background: rgba(7, 11, 20, 0.45); min-height: 88px; }
.draft-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }

/* ===============================================================
   Admin
   =============================================================== */

.grid { display: grid; gap: 18px; }
.grid-kpi  { grid-template-columns: repeat(auto-fit, minmax(min(196px, 100%), 1fr)); }
.grid-2    { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); align-items: start; }

.kpi { padding: 19px 21px; position: relative; overflow: hidden; }
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.55;
}
.kpi-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 9px;
}
.kpi-value { font-size: 2rem; font-weight: 660; letter-spacing: -0.035em; line-height: 1.05; }
.kpi-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 5px; }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 14px 11px;
  border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}
tbody td { padding: 13px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.14s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.028); }
td.num { font-family: var(--mono); text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }

.who-cell { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.76rem; font-weight: 650;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-deep));
  box-shadow: 0 4px 12px var(--accent-glow);
}

.bar-track { height: 5px; border-radius: var(--pill); background: rgba(255,255,255,0.08); overflow: hidden; margin-top: 6px; min-width: 76px; }
.bar-fill  { height: 100%; border-radius: var(--pill); background: linear-gradient(90deg, var(--accent-soft), var(--accent)); }

.feed { display: flex; flex-direction: column; gap: 9px; max-height: 420px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.feed-item { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--stroke); background: rgba(255,255,255,0.025); }
.feed-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.feed-name { font-size: 0.82rem; font-weight: 570; }
.feed-text { font-size: 0.81rem; color: var(--text-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }

.rules-box {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap;
  background: rgba(7, 11, 20, 0.5);
  border: 1px solid var(--stroke);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 15px 17px;
  max-height: 210px;
  overflow-y: auto;
}

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 16px; }

.range-row { display: flex; align-items: center; gap: 13px; }
.range-row output { font-family: var(--mono); font-size: 0.85rem; color: var(--accent-soft); min-width: 30px; text-align: right; }

/* ===============================================================
   Hinweise, Leerzustaende, Toasts
   =============================================================== */

.empty { text-align: center; padding: 52px 24px; color: var(--text-faint); margin: auto; }
.empty svg { width: 46px; height: 46px; opacity: 0.32; margin-bottom: 14px; }
.empty p { margin: 6px 0 0; font-size: 0.87rem; }
.empty strong { display: block; color: var(--text-dim); font-size: 0.95rem; font-weight: 570; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  border: 1px solid var(--stroke);
  background: var(--glass);
  margin-bottom: 16px;
}
.notice-warn { border-color: rgba(251, 191, 36, 0.32); background: rgba(251, 191, 36, 0.08); color: #fde68a; }
.notice-info { border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.07); }
.notice svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

.inline-error {
  color: var(--danger);
  font-size: 0.82rem;
  min-height: 19px;
  margin-top: 10px;
}

#toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(370px, calc(100vw - 40px));
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 17px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid var(--stroke-strong);
  background: rgba(15, 23, 42, 0.93);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  animation: toastIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.out { animation: toastOut 0.24s ease forwards; }
.toast-ok     { border-left: 3px solid var(--ok); }
.toast-error  { border-left: 3px solid var(--danger); }
.toast-info   { border-left: 3px solid var(--accent); }

@keyframes toastIn  { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(22px); } }

/* Ladepunkte */
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: bounce 1.15s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.16s; }
.dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%, 62%, 100% { opacity: 0.28; transform: translateY(0); } 31% { opacity: 1; transform: translateY(-4px); } }

.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ===============================================================
   Responsiv
   =============================================================== */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .sidebar { height: auto; max-height: 420px; }
  .chat-panel { height: auto; min-height: 560px; }
  .chat-scroll { max-height: 440px; }
}

@media (max-width: 720px) {
  .page { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .composer-row { flex-direction: column; }
  .composer-actions { width: 100%; flex-direction: row; }
  .composer-actions button { flex: 1; }
  .msg { max-width: 92%; }
  .who { display: none; }
  .kpi-value { font-size: 1.65rem; }
}

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

/* ===============================================================
   Dialog
   =============================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 6, 14, 0.68);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade 0.18s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 452px;
  padding: 26px 26px 22px;
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal h2 { font-size: 1.06rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

/* ===============================================================
   Handy - Feinschliff
   Steht bewusst am Dateiende, damit es die frueheren Regeln schlaegt.
   =============================================================== */

@media (max-width: 720px) {

  /* iOS zoomt beim Antippen in jedes Feld unter 16px hinein.
     16px verhindert das, ohne dass es am Desktop auffaellt. */
  input, textarea, select {
    font-size: 16px;
  }

  /* Tippflaechen vergroessern - 30px waren zu wenig fuer den Daumen */
  .btn-sm {
    padding: 10px 17px;
    font-size: 0.84rem;
  }
  .msg-meta button {
    padding: 5px 2px;
  }

  /* Enger, damit vom Inhalt mehr uebrig bleibt */
  .card { padding: 18px 15px; }
  .chat-head { padding: 14px 15px; }
  .chat-scroll { padding: 16px 15px; }
  .composer { padding: 14px 15px 16px; }
  .sidebar { padding: 15px; }

  /* Kontaktliste kuerzer, damit der Chat ohne langes Scrollen sichtbar ist */
  .sidebar { max-height: 310px; }
  .chat-panel { min-height: 460px; }
  .chat-scroll { max-height: 50vh; }

  .topbar { gap: 10px; padding: 11px 15px; }
  .topbar-right { gap: 9px; }

  .page-head { margin-bottom: 17px; }
  h1 { font-size: 1.32rem; }

  /* Entwurfsknoepfe nebeneinander sind zu gequetscht */
  .draft-actions button { flex: 1 1 auto; }
}

@media (max-width: 430px) {

  .logo svg { width: 32px; height: 32px; }
  .logo-text { font-size: 1.02rem; }

  /* Zwei Statusabzeichen plus zwei Knoepfe passen sonst nicht in eine Zeile */
  .badge {
    font-size: 0.62rem;
    padding: 3px 9px;
    letter-spacing: 0.06em;
  }

  .kpi { padding: 16px 17px; }
  .kpi-value { font-size: 1.5rem; }

  .login-card { padding: 32px 22px 26px; }
  .login-card .logo svg { width: 46px; height: 46px; }
  .login-card .logo-text { font-size: 1.3rem; }

  .msg { max-width: 96%; }
  .bubble { font-size: 0.87rem; padding: 10px 14px; }

  /* Nachricht und Knoepfe untereinander statt nebeneinander */
  .composer-actions { flex-direction: column; }
  .composer-actions button { width: 100%; }

  .modal { padding: 22px 18px 18px; }
}

/* Tabellen auf dem Handy: seitlich scrollbar, mit sichtbarem Hinweis
   statt abgeschnittener Spalten. */
@media (max-width: 720px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table { min-width: 560px; }
  .table-wrap::after {
    content: "// seitlich wischen für alle Spalten";
    display: block;
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text-faint);
    padding: 9px 2px 0;
    position: sticky;
    left: 0;
  }
}
