* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1f2328;
}

.hidden {
  display: none !important;
}

#error-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.error-box {
  max-width: 480px;
  padding: 32px;
  background: #fff;
  border: 1px solid #e2352b;
  border-radius: 8px;
  text-align: center;
}

.error-box h1 {
  color: #e2352b;
  font-size: 20px;
  margin-top: 0;
}

#app-view {
  max-width: 800px;
  margin: 0 auto;
  height: 100vh;
  /* dvh folgt der ein-/ausblendenden Adressleiste mobiler Browser; ohne das
     rutscht das Eingabefeld dort aus dem sichtbaren Bereich. 100vh bleibt als
     Rückfalloption für ältere Browser darüber stehen. */
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.persona-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #dcdfe4;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.persona-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.persona-info {
  flex: 1;
}

.persona-name {
  font-weight: 600;
  font-size: 16px;
}

.persona-age {
  font-size: 13px;
  color: #6b7280;
}

.session-info {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  text-align: right;
  line-height: 1.6;
  /* hält den Block rechts, auch wenn die Persona-Identität ausgeblendet ist */
  margin-left: auto;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
  flex-shrink: 0;
}

.message-row.assistant {
  align-self: flex-start;
}

.message-row.user {
  align-self: flex-end;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.bubble {
  max-width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-x: auto;
}

.bubble > *:first-child {
  margin-top: 0;
}

.bubble > *:last-child {
  margin-bottom: 0;
}

.bubble p {
  margin: 6px 0;
}

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
  margin: 10px 0 6px;
  line-height: 1.3;
}

.bubble h1 {
  font-size: 1.3em;
}
.bubble h2 {
  font-size: 1.15em;
}
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
  font-size: 1.05em;
}

.bubble ul,
.bubble ol {
  margin: 6px 0;
  padding-left: 22px;
}

.bubble li {
  margin: 2px 0;
}

.bubble hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  margin: 10px 0;
}

.bubble code {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.92em;
  max-width: 100%;
}

.bubble th,
.bubble td {
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 4px 8px;
  text-align: left;
}

.bubble th {
  background: rgba(0, 0, 0, 0.05);
}

.bubble a {
  color: inherit;
  text-decoration: underline;
}

.bubble.user hr,
.bubble.user th,
.bubble.user td {
  border-color: rgba(255, 255, 255, 0.35);
}

.bubble.user code {
  background: rgba(255, 255, 255, 0.2);
}

.bubble.user th {
  background: rgba(255, 255, 255, 0.12);
}

.bubble.assistant {
  background: #e9ebef;
  border-bottom-left-radius: 4px;
}

.bubble.user {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa0a8;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

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

.chat-error {
  margin: 0 16px 8px;
  padding: 8px 12px;
  background: #fdecea;
  color: #b3261e;
  border-radius: 6px;
  font-size: 13px;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #dcdfe4;
}

#chat-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  /* nicht unter 16px: iOS-Safari zoomt sonst beim Antippen automatisch hinein */
  font-size: 16px;
}

#chat-send {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

#chat-send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Smartphones: Platz sparen, damit mehr Breite für den Gesprächstext bleibt,
   und Tippziele vergrößern. Betrifft nur die Teilnehmenden-Oberfläche. */
@media (max-width: 600px) {
  .persona-header {
    padding: 10px 12px;
    gap: 10px;
  }

  .avatar {
    width: 40px;
    height: 40px;
  }

  .session-info {
    font-size: 11px;
    line-height: 1.4;
  }

  .chat-log {
    padding: 12px;
    gap: 8px;
  }

  .message-row {
    max-width: 88%;
    gap: 6px;
  }

  .chat-form {
    padding: 10px 12px;
  }

  /* 44px ist die gängige Mindestgröße für sicher treffbare Tippziele */
  #chat-input,
  #chat-send {
    min-height: 44px;
  }

  #chat-send {
    padding: 12px 16px;
  }
}

/* Öffentliche Übersichtsseite aller Personas ({BASE_PATH}/personas) */
.persona-overview {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px;
}

.persona-overview h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.persona-overview-hint {
  margin: 0 0 24px;
  color: #6b7280;
}

.persona-overview-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid #dcdfe4;
  font-size: 14px;
  text-align: center;
}

.persona-overview-footer a {
  color: #6b7280;
}

.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.persona-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: #fff;
  border: 1px solid #dcdfe4;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.persona-tile:hover,
.persona-tile:focus-visible {
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.persona-tile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
}
