/* ══════════════════════════════════════════
   COVEN — Base Styles
   Mobile-first, dark default, config-driven colours
   ══════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --bg-card: #1E1E24;
  --bg-card-light: #2D2D35;
  --text: #EDE3D3;
  --text-muted: #8A8A95;
  --accent: #C4973B;
  --accent-light: #D4B06A;
  --danger: #e55;
  --success: #6B8F62;
  --radius: 12px;
  --header-height: 56px;
  --input-height: 60px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Header ── */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--bg-card-light);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  z-index: 100;
  gap: 0.5rem;
}

.header-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 500;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  padding: 0.4rem;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}

.icon-btn:hover { background: var(--bg-card-light); }

/* ── Sidebar ── */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#sidebar-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--bg-card-light);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

#sidebar.open { transform: translateX(0); }

.sidebar-header {
  padding: 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--bg-card-light);
}

#sidebar-chats {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-chat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.95rem;
}

.sidebar-chat:hover { background: var(--bg-card-light); }
.sidebar-chat.active { background: var(--bg-card-light); color: var(--accent); }

.chat-emoji { font-size: 1.1rem; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--bg-card-light);
}

.sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}

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

/* ── Messages ── */
#messages-container {
  position: fixed;
  top: var(--header-height);
  bottom: var(--input-height);
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.75rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 100%;
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 82%;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  word-wrap: break-word;
  line-height: 1.45;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-bubble.user {
  align-self: flex-end;
  background: var(--sender-colour, #7c5cbf);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble.companion {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-light);
  border-bottom-left-radius: 4px;
}

.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
}

.msg-text {
  font-size: 0.92rem;
}

.system-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 1rem;
}

/* ── Input bar ── */
#input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: auto;
  min-height: var(--input-height);
  background: var(--bg-card);
  border-top: 1px solid var(--bg-card-light);
  display: flex;
  align-items: flex-end;
  padding: 0.6rem 0.75rem;
  gap: 0.5rem;
  z-index: 100;
}

#message-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--bg-card-light);
  border-radius: 20px;
  padding: 0.55rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s;
}

#message-input:focus { border-color: var(--accent); }

#message-input::placeholder { color: var(--text-muted); }

#send-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#send-btn:hover { opacity: 0.85; }

/* ── Utilities ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-card-light); border-radius: 4px; }

/* ── Safe area for mobile ── */
@supports (padding: env(safe-area-inset-bottom)) {
  #input-bar { padding-bottom: calc(0.6rem + env(safe-area-inset-bottom)); }
}
