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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 26px;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ───── Header ───── */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .brand {
  display: inline-flex;
  align-items: center;
}

.app-header .brand img {
  height: 40px;
  width: auto;
  display: block;
}

.app-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  margin-left: auto;
}

.beta-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  padding: 2px 8px;
}

/* ───── Chat ───── */
.chat {
  flex: 1;
  padding: 16px;
  max-width: var(--max-content);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.msg {
  border-radius: var(--radius-bubble);
  padding: 12px 14px;
  font-size: 16px;
  line-height: 24px;
  word-wrap: break-word;
}

.msg p {
  margin: 0 0 8px;
}

.msg p:last-child {
  margin-bottom: 0;
}

.msg strong {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text);
}

.msg a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.msg a:hover {
  color: var(--color-accent-hover);
}

.msg.user a {
  color: var(--color-text-on-accent);
  text-decoration: underline;
}

.msg ul {
  margin: 6px 0;
  padding-left: 0;
  list-style: none;
}

.msg ul li {
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 2px solid var(--color-accent);
}

.msg ul li:last-child {
  margin-bottom: 0;
}

/* Feedback-Bar nach Bot-Antwort */
.feedback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
}

.feedback-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
}

.feedback-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  font-size: 16px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1;
}

.feedback-btn:hover:not(:disabled) {
  background: var(--color-bg);
  border-color: var(--color-accent);
}

.feedback-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.feedback-btn.selected {
  background: var(--color-accent);
  opacity: 1;
}

.msg.bot {
  background: var(--color-bg-tint);
  color: var(--color-text);
  align-self: flex-start;
  max-width: 90%;
}

.msg.user {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  align-self: flex-end;
  max-width: 80%;
}

.msg.error {
  background: #fff1f0;
  color: var(--color-error);
  align-self: flex-start;
  max-width: 90%;
}

.first-msg p:first-child {
  font-family: var(--font-display);
  font-weight: 600;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 2px;
}

.typing span {
  width: 6px;
  height: 6px;
  background: var(--color-accent-hover);
  border-radius: 50%;
  animation: blink 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .typing span {
    animation: none;
    opacity: 0.7;
  }
}

/* ───── Chips ───── */
.chips {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: var(--max-content);
  width: 100%;
  margin: 0 auto;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  padding: 8px 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
  border-radius: var(--radius-0);
}

.chip:hover,
.chip:focus-visible {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  outline: none;
}

/* ───── Composer ───── */
.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  bottom: 0;
  max-width: var(--max-content);
  width: 100%;
  margin: 0 auto;
}

.composer textarea {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 24px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-0);
  resize: none;
  max-height: 160px;
  background: var(--color-bg);
  color: var(--color-text);
}

.composer textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: var(--color-accent);
}

.composer .send {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer .send:hover {
  background: var(--color-accent-hover);
}

.composer .send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ───── Footer ───── */
.app-footer {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.app-footer a {
  color: var(--color-text-muted);
  text-decoration: underline;
}

/* ───── Desktop ───── */
@media (min-width: 768px) {
  .chat,
  .chips,
  .composer {
    max-width: var(--max-content);
  }

  .app-header {
    padding: 0 24px;
  }
}
