:root {
  --accent: #2f6feb;
  --accent-dark: #1f4fb8;
  --ink: #16181d;
  --ink-soft: #5b6472;
  --surface: #ffffff;
  --surface-sunk: #f6f7f9;
  --border: #e3e6ea;
  --bg: #eef1f5;
  --danger: #c93a3a;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.screen.hidden { display: none; }

/* ---------- Disclaimer / start screen ---------- */

.card {
  background: var(--surface);
  max-width: 480px;
  width: 100%;
  padding: 36px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 45px rgba(22, 24, 29, 0.08);
  border: 1px solid var(--border);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 16px;
}

h1 { font-size: 21px; font-weight: 600; margin: 0 0 2px 0; letter-spacing: -0.01em; }
.subtitle { color: var(--ink-soft); font-size: 14px; margin: 0 0 22px 0; }

.lang-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-sunk);
  border-radius: 999px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
}
.lang-btn {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.disclaimer-box {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 18px;
  max-height: 220px;
  overflow-y: auto;
}
.disclaimer-title { font-weight: 600; margin-top: 0; font-size: 13px; }
.disclaimer-box p { font-size: 13px; line-height: 1.6; color: var(--ink-soft); margin: 0 0 0 0; }
.disclaimer-box .disclaimer-title { color: var(--ink); }

.ack-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.ack-row input { margin-top: 2px; accent-color: var(--accent); }

.primary-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-dark); }
.primary-btn:disabled { background: #c7cbd1; cursor: not-allowed; }

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

#chat-screen.screen { padding: 0; align-items: stretch; }

.chat-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 0 60px rgba(22, 24, 29, 0.06);
}

.chat-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header .brand-mark { width: 32px; height: 32px; font-size: 13px; margin-bottom: 0; }
.chat-header-title { display: flex; flex-direction: column; line-height: 1.25; }
.chat-header-title strong { font-size: 14.5px; font-weight: 600; }
.chat-header-status { font-size: 11.5px; color: #3fa860; display: flex; align-items: center; gap: 5px; }
.chat-header-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #3fa860; }

.chat-header-right { display: flex; align-items: center; gap: 8px; }

.lang-toggle-sm {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-sunk);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.lang-toggle-sm .lang-btn { padding: 4px 10px; font-size: 11.5px; }

.icon-btn {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: #eceff2; }
.icon-btn.enabled { border-color: var(--accent); color: var(--accent); }
.icon-btn.listening { background: var(--accent); color: #fff; border-color: var(--accent); animation: pulse 1.4s infinite; }
.icon-btn.speaking { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-btn[hidden] { display: none; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47, 111, 235, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(47, 111, 235, 0); }
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
}

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

.msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(22,24,29,0.04);
}
.msg.system {
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  padding: 4px 10px;
}

.msg.assistant.typing { display: flex; align-items: center; gap: 4px; padding: 14px 16px; }
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-soft);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.meet-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff !important;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.meet-link:hover { background: var(--accent-dark); }

.chat-form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-form input {
  flex: 1;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 14.5px;
  background: var(--surface-sunk);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chat-form input:focus { border-color: var(--accent); background: var(--surface); }
.chat-form .primary-btn { width: auto; border-radius: 999px; padding: 11px 22px; }

@media (max-width: 480px) {
  .chat-shell { max-width: 100%; }
  .msg { max-width: 86%; }
  .chat-header-status span:last-child { display: none; }
}
