:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #22201d;
  --muted: #6b6660;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --bubble-teen: #2f6f5e;
  --bubble-bot: #eceae5;
  --border: #ddd8d0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.card {
  max-width: 480px;
  margin: 40px auto;
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

h1 { margin-top: 0; }

.lead { color: var(--muted); }

.notice {
  background: #f0efe9;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.92em;
  margin: 18px 0;
}
.notice ul { margin: 6px 0 0; padding-left: 20px; }

.error { color: #b3261e; font-weight: 600; }

form label { display: block; margin-top: 14px; font-size: 0.92em; }
form .hint { color: var(--muted); font-weight: normal; }

select, input[type=text], input[type=email], textarea {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1em;
  font-family: inherit;
}
textarea { resize: vertical; }

button {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
}
button:hover { opacity: 0.92; }

/* Chat page */
.chat-wrap {
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.end-link { color: var(--muted); font-size: 0.85em; text-decoration: none; }
.end-link:hover { text-decoration: underline; }

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

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.bubble.teen {
  align-self: flex-end;
  background: var(--bubble-teen);
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border-bottom-left-radius: 4px;
}
.bubble.system {
  align-self: center;
  background: #fdecea;
  color: #b3261e;
  font-size: 0.9em;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 1em;
  font-family: inherit;
}
.chat-form button {
  margin-top: 0;
  width: auto;
  padding: 0 18px;
  border-radius: 20px;
}

.status {
  text-align: center;
  color: var(--muted);
  font-size: 0.85em;
  min-height: 18px;
  margin: 4px 0 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --card: #26241f;
    --ink: #f2f0ec;
    --muted: #9b9690;
    --bubble-bot: #33312b;
    --border: #3a3830;
  }
}
