:root {
  --bg: #0f1720;
  --panel: #16212c;
  --border: #26333f;
  --text: #e8edf2;
  --muted: #93a3b0;
  --accent: #2fa5c9;
  --accent-dark: #1d7d9c;
  --user-bubble: #2fa5c9;
  --assistant-bubble: #1f2c38;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.app-header h1 { margin: 0; font-size: 1.3rem; }
.badge {
  font-size: 0.65rem;
  background: var(--accent-dark);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.5rem;
}
.subtitle { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.85rem; }
.index-status { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.75rem; }
.index-status:empty { display: none; }

.app-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.chat-pane, .event-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-pane {
  flex: 1 1 45%;
  border-right: 1px solid var(--border);
  padding: 1rem;
}

.event-pane {
  flex: 1 1 55%;
  padding: 1rem 1.5rem;
  overflow-y: auto;
  background: var(--panel);
}

.event-pane-title {
  margin-top: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 1rem;
}

.msg {
  max-width: 90%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.8rem;
  white-space: pre-wrap;
  line-height: 1.4;
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 0.15rem;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border-bottom-left-radius: 0.15rem;
}
.msg.error {
  align-self: flex-start;
  background: #4a1f28;
  color: #ffb4b4;
}
.msg .event-chip {
  display: inline-block;
  margin: 0.35rem 0.3rem 0 0;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  font-size: 0.8rem;
  cursor: pointer;
}
.msg .event-chip:hover { background: var(--accent); color: #fff; }

.chat-form {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: #0c141c;
  color: var(--text);
  /* 16px minimum : évite le zoom automatique au focus sur iOS Safari */
  font-size: 16px;
}
.chat-form button {
  padding: 0.7rem 1.1rem;
  min-height: 44px;
  border-radius: 0.6rem;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chat-form button:disabled { opacity: 0.6; cursor: default; }
.chat-form button:hover:not(:disabled) { background: var(--accent-dark); }

.example-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding-bottom: 0.6rem;
  flex-shrink: 0;
}
.examples-label {
  width: 100%;
  margin: 0 0 0.1rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.example-chip {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.example-chip:hover { border-color: var(--accent); color: var(--accent); }

.event-empty { color: var(--muted); }

.event-card { display: flex; flex-direction: column; gap: 0.6rem; }
.event-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 0.6rem;
}
.event-title { margin: 0; font-size: 1.4rem; }
.event-summary {
  margin: 0;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text);
}
.event-period, .event-location { margin: 0; color: var(--muted); }
.event-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.2rem 0; }
.event-action {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.event-action:hover { background: var(--accent); color: #fff; }
.event-description { margin: 0.4rem 0; line-height: 1.5; }
.event-source a { color: var(--accent); }

@media (max-width: 800px) {
  .app-header { padding: 0.75rem 1rem; }
  .app-layout { flex-direction: column; }
  .chat-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 55vh;
    max-height: 55dvh;
    padding: 0.75rem;
  }
  .event-pane { padding: 0.75rem 1rem; }
  .msg { max-width: 96%; }
  .event-image { max-height: 200px; }
}
