/* leomore leo-bot — Chat-Frontend Styles
   Brand: #FBF8F3 bg, #211A12 ink, Verlauf #F9DD00->#F70806 nur Akzent
   Mobile-first, 375px baseline */

/* Fonts self-hosted (CSP: style-src/font-src 'self') */
@font-face {
  font-family: 'Clash Display';
  src: url('/fonts/clash-display-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Clash Display';
  src: url('/fonts/clash-display-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'General Sans';
  src: url('/fonts/general-sans-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'General Sans';
  src: url('/fonts/general-sans-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'General Sans';
  src: url('/fonts/general-sans-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --bg: #FBF8F3;
  --ink: #211A12;
  --ink-soft: #5c544a;
  --ink-faint: #8a8175;
  --card: #ffffff;
  --line: rgba(33, 26, 18, .10);
  --line-strong: rgba(33, 26, 18, .16);
  --c1: #F9DD00;
  --c4: #F70806;
  --grad: linear-gradient(100deg, #F9DD00 0%, #F8950A 38%, #F85701 70%, #F70806 100%);
  --grad-soft: linear-gradient(100deg, rgba(249,221,0,.10), rgba(248,87,1,.08));
  --shadow-sm: 0 1px 2px rgba(33,26,18,.04), 0 2px 8px rgba(33,26,18,.04);
  --shadow-md: 0 4px 14px rgba(33,26,18,.06), 0 14px 40px rgba(33,26,18,.07);
  --r-sm: 10px;
  --r-md: 16px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --chat-max: 640px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "General Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .display {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 248, 243, .92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--chat-max);
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -.02em;
  text-transform: lowercase;
  display: flex;
  align-items: center;
  gap: 1px;
}

.logo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--grad);
  margin-left: 2px;
  margin-bottom: -10px;
  flex-shrink: 0;
}

.header-back {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .2s;
}
.header-back:hover { color: var(--ink); }

/* ---------- Progress ---------- */

.progress-wrap {
  max-width: var(--chat-max);
  margin: 0 auto;
  padding: 16px 20px 0;
}

.progress-track {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--grad);
  width: 0%;
  transition: width .5s var(--ease);
}

.progress-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 7px;
}

/* ---------- Main Chat Area ---------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--chat-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 24px;
}

/* ---------- Messages ---------- */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}

.message {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: var(--r-md);
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.message.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 4px;
}

.message.bot ul,
.message.bot ol {
  padding-left: 1.4em;
  margin-top: 6px;
}

.message.bot li { margin-bottom: 3px; }

/* ---------- Preset Cards ---------- */

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.preset-card {
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  background: var(--bg);
  cursor: default;
}

.preset-card-name {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
}

.preset-card-desc {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.preset-card-ref {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.preset-card-ref a {
  border-bottom: 1px solid var(--line);
  transition: border-color .2s;
}

.preset-card-ref a:hover { border-color: var(--ink-faint); }

/* ---------- Typing Indicator ---------- */

.typing-indicator {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-md);
  border-bottom-left-radius: 4px;
  padding: 12px 15px;
  display: none;
  gap: 5px;
  align-items: center;
}

.typing-indicator.visible { display: flex; }

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: typing-bounce .9s ease-in-out infinite;
}

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

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Wiedereinstieg Banner ---------- */

.reentry-banner {
  background: var(--grad-soft);
  border: 1.5px solid rgba(249, 221, 0, .40);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 14px;
  display: none;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 2px;
}

.reentry-banner.visible { display: flex; }

.reentry-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.reentry-text strong {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 14px;
}

.reentry-text span {
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Status Bar ---------- */

#status-bar {
  font-size: 13px;
  color: var(--ink-faint);
  min-height: 20px;
  padding: 4px 0 8px;
  text-align: center;
  transition: color .2s;
}

#status-bar.error { color: var(--c4); }

/* ---------- Input Form ---------- */

#chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

#input {
  flex: 1;
  font-family: "General Sans", -apple-system, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 14px;
  min-height: 44px;
  max-height: 140px;
  resize: none;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
  overflow-y: auto;
  field-sizing: content;
}

#input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(33, 26, 18, .07);
}

#input::placeholder { color: var(--ink-faint); }

#input:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(248, 87, 1, .28);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), opacity .2s;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(248, 87, 1, .38);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(248, 87, 1, .24);
}

.send-btn:disabled {
  opacity: .40;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- State Views (error / done / invalid token) ---------- */

.state-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 16px;
  max-width: var(--chat-max);
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.state-view.visible { display: flex; }

.state-icon {
  font-size: 44px;
  line-height: 1;
}

.state-title {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -.01em;
}

.state-body {
  font-size: 15px;
  color: var(--ink-soft);
  max-width: 300px;
  line-height: 1.6;
}

.state-body a {
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
  transition: border-color .2s;
}

.state-body a:hover { border-color: var(--ink); }

/* Done badge */
.done-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 7px 16px;
  border-radius: 99px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(248, 87, 1, .28);
}

/* ---------- Focus visible ---------- */

:focus-visible {
  outline: 2px solid var(--c4);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Responsive ---------- */

@media (max-width: 375px) {
  .header-inner { padding: 0 14px; }
  .progress-wrap { padding: 12px 14px 0; }
  .chat-main { padding: 0 14px 16px; }
  .message { max-width: 95%; font-size: 14px; }
  #input { font-size: 16px; /* prevent iOS zoom */ }
}

@media (min-width: 641px) {
  .chat-main { padding-bottom: 32px; }
}
