* { box-sizing: border-box; }
:root {
  --primary: #0F6E56;
  --primary-dark: #0b5643;
  --primary-tint: #e4f0ec;
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
body {
  font-family: "Lato", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #ECF0F1;
  display: flex;
  flex-direction: column;
}
#navbar {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#navbar .navbar-sub {
  font-weight: 400; font-size: 12px; opacity: 0.85; margin-top: 1px;
}
#navbar a.navbar-link {
  color: #fff; opacity: 0.9; font-weight: 400; font-size: 13px;
  text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.5);
}
#navbar a.navbar-link:hover { opacity: 1; }
#body-row { flex: 1; display: flex; overflow: hidden; }
#sidebar {
  display: none;
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #dee2e6;
  padding: 16px 12px;
  overflow-y: auto;
  transition: width 0.2s ease, padding 0.2s ease;
}
#sidebar.collapsed {
  width: 0;
  padding: 16px 0;
  overflow: hidden;
  border-right: none;
}
#sidebar-toggle {
  background: none; border: none; color: #fff; font-size: 18px;
  cursor: pointer; padding: 0 10px 0 0; line-height: 1;
}
#new-chat-btn {
  width: 100%; padding: 10px; border-radius: 4px;
  border: 1px solid var(--primary); background: #fff; color: var(--primary);
  font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; margin-bottom: 14px;
}
#new-chat-btn:hover { background: var(--primary-tint); }
.conv-item {
  padding: 8px 10px; border-radius: 4px; cursor: pointer; font-size: 13px;
  margin-bottom: 4px; color: #333; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item:hover { background: #f0f0f0; }
.conv-item.active { background: var(--primary-tint); color: var(--primary-dark); font-weight: 700; }
#main {
  flex: 1; max-width: 640px; margin: 0 auto; padding: 16px;
  min-width: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
h1 { font-size: 24px; font-weight: 700; margin: 4px 0 6px; color: var(--primary-dark); flex-shrink: 0; }
p.sub { color: #666; font-size: 13px; margin-top: 0; margin-bottom: 16px; flex-shrink: 0; }
#login-screen { flex-shrink: 0; }
#chat-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#log {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 12px;
  flex: 1; min-height: 0;
  overflow-y: auto;
  margin-bottom: 12px;
}
.msg { margin-bottom: 12px; line-height: 1.5; }
.msg.user .bubble { white-space: pre-wrap; }
.msg.assistant .bubble p { margin: 0 0 8px; }
.msg.assistant .bubble p:last-child { margin-bottom: 0; }
.msg.assistant .bubble strong { font-weight: 700; }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { margin: 4px 0 8px 20px; }
.msg.user { text-align: right; }
.msg.user .bubble {
  background: var(--primary); color: #fff; display: inline-block;
  padding: 8px 12px; border-radius: 10px 10px 2px 10px; max-width: 85%;
  overflow-x: auto; overflow-wrap: break-word;
}
.msg.assistant .bubble {
  background: #eee; color: #111; display: inline-block;
  padding: 8px 12px; border-radius: 10px 10px 10px 2px; max-width: 85%;
  overflow-x: auto; overflow-wrap: break-word;
}
form { display: flex; gap: 8px; flex-shrink: 0; }
#photo-btn {
  flex-shrink: 0; width: 40px; padding: 0; background: #fff;
  border: 1px solid #ccc; color: inherit; font-size: 18px;
}
#photo-btn:hover { background: #f0f0f0; }
#photo-preview-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-shrink: 0;
}
#photo-preview {
  height: 56px; border-radius: 6px; border: 1px solid #dee2e6;
}
#remove-photo-btn {
  width: 24px; height: 24px; border-radius: 50%; padding: 0;
  background: #c0392b; font-size: 14px; line-height: 1;
}
.msg-photo {
  display: block; max-width: 100%; max-height: 220px;
  border-radius: 6px; margin-bottom: 6px;
}
textarea {
  flex: 1; resize: none; padding: 10px; border-radius: 4px;
  border: 1px solid #ccc; font-size: 14px; font-family: inherit;
}
button {
  padding: 0 18px; border: none; border-radius: 4px;
  background: var(--primary); color: #fff; font-size: 14px;
  font-family: inherit; cursor: pointer;
}
button:hover:not(:disabled) { background: var(--primary-dark); }
button:disabled { background: #a9c9c0; cursor: default; }
#login-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
#login-row input {
  flex: 1 1 120px; min-width: 0; padding: 10px; border-radius: 4px; border: 1px solid #ccc; font-size: 14px;
}
p.error { color: #c0392b; font-size: 13px; margin: 4px 0 0; min-height: 16px; }
.audio-controls-wrap {
  display: flex; justify-content: center; align-items: center;
  gap: 14px; flex-wrap: wrap; margin: 14px 0; flex-shrink: 0;
}
.voice-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #333; cursor: pointer; user-select: none; }
.voice-toggle input { display: none; }
.voice-toggle-slider {
  width: 34px; height: 18px; border-radius: 10px; background: #ccc;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.voice-toggle-slider::before {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: transform 0.2s;
}
.voice-toggle input:checked + .voice-toggle-slider { background: var(--primary); }
.voice-toggle input:checked + .voice-toggle-slider::before { transform: translateX(16px); }
.audio-controls {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid #dee2e6; background: #fff;
  border-radius: 20px; padding: 6px 14px;
}
.audio-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #cfd8d5; display: inline-block; transition: background 0.2s;
}
.audio-dot.speaking {
  background: var(--primary);
  animation: pulse-dot 1.2s infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(15,110,86,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(15,110,86,0); }
  100% { box-shadow: 0 0 0 0 rgba(15,110,86,0); }
}
.audio-controls button {
  width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: #333; color: #fff; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.audio-controls button:disabled { background: #bbb; }

/* About page specific */
.about-content { background: #fff; border: 1px solid #dee2e6; border-radius: 4px; padding: 20px 24px; }
.about-content h2 { font-size: 16px; color: var(--primary-dark); margin: 20px 0 8px; }
.about-content h2:first-child { margin-top: 0; }
.about-content p, .about-content li { font-size: 14px; line-height: 1.6; color: #333; }
.about-content ul { margin: 6px 0 12px 20px; padding: 0; }
.placeholder-note {
  background: #fff8e1; border-left: 3px solid #f0ad4e; padding: 8px 12px;
  font-size: 12px; color: #7a5b00; margin: 8px 0 16px;
}
body.about-page { overflow-y: auto; height: auto; min-height: 100vh; }
body.about-page #main { overflow-y: visible; }
