:root {
  --bg: #f4e9d1;
  --panel: #fffcf5;
  --ink: #3a2a18;
  --muted: #8a7355;
  --accent: #c1652a;
  --border: #e3d3ab;
  --savanna-green: #5a6f36;
  --savanna-gold: #dd8a2e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Iowan Old Style", serif;
  background: var(--bg);
  color: var(--ink);
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

#login-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, #f6c667 0%, #e79a3f 45%, #cf7a30 100%);
}

.savanna-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.savanna-tree {
  position: absolute;
  bottom: 4.5rem;
  right: 8%;
  width: 110px;
  height: auto;
  opacity: 0.85;
}

.savanna-grass {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: 12px;
  width: 320px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(90, 55, 15, 0.25);
}

.lioness-icon { display: block; }
.lioness-icon-large { width: 110px; height: 110px; margin: 0 auto 1rem; }
.lioness-icon-small { width: 40px; height: 40px; }

.login-card h1 { margin: 0 0 0.25rem; letter-spacing: 0.05em; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 1.5rem; }

input[type="password"], textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; }
textarea.small { min-height: 70px; }

button {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-top: 0.75rem;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.error { color: var(--accent); min-height: 1.2em; font-size: 0.9rem; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #f6c667, #f4e9d1 60%);
}
header h1 { margin: 0; letter-spacing: 0.05em; }
.brand { display: flex; align-items: center; gap: 0.75rem; }

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  height: calc(100vh - 145px);
}

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#new-chat-btn { width: 100%; margin-top: 0; margin-bottom: 1rem; }

.chat-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* État initial (aucun message) : la saisie est centrée au milieu de la zone, comme sur un chat
   IA classique. Dès le premier message, on repasse en historique défilant + saisie en bas. */
.chat-panel.is-empty {
  justify-content: center;
}
.chat-panel.is-empty .chat-messages { flex: 0 1 auto; overflow: visible; }
.chat-panel.is-empty .chat-input-row { max-width: 640px; width: 100%; margin: 0 auto; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
}

.chat-empty {
  text-align: center;
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto 1.5rem;
}
.chat-empty .lioness-icon-medium { width: 64px; height: 64px; margin: 0 auto 1rem; }
.chat-empty h2 {
  color: var(--ink);
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
}
.chat-empty p { margin: 0; }

.chat-message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.chat-message-text { white-space: pre-wrap; }

.chat-message-user {
  align-self: flex-end;
  background: #f0e2c2;
}

.chat-message-assistant {
  align-self: flex-start;
  background: #fffcf5;
}

.chat-message-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.chat-message-actions button, .small-btn {
  margin-top: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.chat-input-row { display: flex; flex-direction: column; }
#chat-input { min-height: 90px; margin-bottom: 0.5rem; }
#send-btn { align-self: flex-end; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.file-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.75rem 0 0.25rem;
}

.file-status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }

.output-actions { display: flex; gap: 0.5rem; }
.output-actions button { margin-top: 0; }

.settings-panel { margin: 0 2rem 1.5rem; }
.settings-panel summary {
  cursor: pointer;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.settings-panel textarea { margin-top: 1rem; }

#history-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; }

#history-list li {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
#history-list li:hover { background: #f8eed9; }
#history-list li.active { background: #f0e2c2; }

.history-item-header { display: flex; justify-content: space-between; align-items: center; }
.history-date { color: var(--muted); font-size: 0.75rem; }
.history-preview { margin-top: 0.2rem; font-size: 0.9rem; }

.history-delete-btn {
  margin-top: 0;
  padding: 0 0.4rem;
  font-size: 1rem;
  line-height: 1.2;
  background: transparent;
  color: var(--muted);
  border: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#history-list li:hover .history-delete-btn { opacity: 1; }
.history-delete-btn:hover { color: var(--accent); opacity: 1; }
