:root {
  --accent: #e8542a;
  --accent-dim: #fdece4;
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --border: #e7e4de;
  --text: #201d1a;
  --text-dim: #7a756e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 15, 10, 0.04), 0 8px 24px rgba(20, 15, 10, 0.05);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --accent: #ff7a4d;
  --accent-dim: #3a2015;
  --bg: #17151b;
  --surface: #201d24;
  --surface-2: #26222a;
  --border: #34303a;
  --text: #f2efe9;
  --text-dim: #a39c93;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

.app {
  display: flex;
  height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  transition: margin-left 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.sidebar.collapsed {
  margin-left: -300px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 20px;
}

.brand-mark { height: 28px; width: auto; }

.brand-tag {
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 2px;
}

.sidebar-hint {
  font-size: 13px;
  color: var(--text-dim);
  padding: 0 8px 10px;
  margin: 0;
}

.topics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.topic {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: background 0.15s ease;
}

.topic:hover { background: var(--surface-2); }
.topic:active { background: var(--accent-dim); }

.topic-icon {
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 9px;
  flex-shrink: 0;
}

.topic-text { display: flex; flex-direction: column; gap: 1px; }
.topic-text strong { font-size: 13.5px; font-weight: 600; }
.topic-text small { font-size: 11.5px; color: var(--text-dim); }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.lang-toggle {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }

/* ---------- Chat ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: none;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.chat-header-title small {
  color: var(--text-dim);
  font-size: 11.5px;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: #d0d0d0; /* checking, until the health ping resolves */
  display: inline-block;
}

.status-dot.online { background: #3bc17a; }
.status-dot.offline { background: #e05252; }

.header-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 10%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lang-review-banner {
  margin: 10px 10% 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.4;
}

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 640px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

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

.msg-bubble ul,
.msg-bubble ol {
  margin: 0 0 6px;
  padding-left: 20px;
}
.msg-bubble ul:last-child,
.msg-bubble ol:last-child { margin-bottom: 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble li:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; }

.msg-assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble img {
  max-width: 220px;
  border-radius: 10px;
  display: block;
  margin-top: 6px;
}

.msg-bubble .demo-tag {
  display: inline-block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 6px;
}

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--text-dim);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Composer ---------- */

.composer {
  padding: 16px 10%;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.attach-preview:empty { display: none; }
.attach-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px 4px 4px;
  font-size: 12px;
}

.attach-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }
.attach-chip button {
  border: none; background: transparent; cursor: pointer; color: var(--text-dim); font-size: 13px;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 10px;
}

.composer-btn {
  border: none;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s ease;
}

.composer-btn:hover { background: var(--border); color: var(--text); }
.composer-btn.recording { color: #e0473f; background: rgba(224, 71, 63, 0.12); }

.composer-input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  padding: 8px 4px;
  color: var(--text);
  outline: none;
}

.composer-send {
  border: none;
  background: var(--accent);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
}

.composer-send:hover { filter: brightness(1.08); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; height: 100vh; box-shadow: var(--shadow); }
  .sidebar.collapsed { margin-left: -300px; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .messages, .composer { padding-left: 5%; padding-right: 5%; }
}
