:root {
  color-scheme: light;
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #2b2622;
  --muted: #6b625a;
  --accent: #7c6a58;
  --accent-dark: #574a3d;
  --border: #e3ddd4;
  --user-bubble: #eef1ec;
  --ai-bubble: #f4efe6;
  --crisis-bubble: #fdece9;
  --crisis-border: #e2a89f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  line-height: 1.7;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.app-header h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--accent-dark);
}

.app-header .lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0;
}

.disclaimer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  min-height: 80px;
}

.bubble {
  padding: 14px 16px;
  border-radius: 12px;
  max-width: 100%;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.bubble.user {
  background: var(--user-bubble);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.bubble.ai {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.bubble.crisis {
  background: var(--crisis-bubble);
  border: 1px solid var(--crisis-border);
  align-self: flex-start;
}

.bubble.loading {
  color: var(--muted);
  font-style: italic;
}

.chat-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  bottom: 12px;
}

textarea#user-input {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

button#submit-btn {
  background: var(--accent-dark);
  color: #fff;
}

button#submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

@media (max-width: 480px) {
  .bubble {
    font-size: 0.9rem;
  }
}

@media print {
  .chat-form,
  .disclaimer {
    display: none;
  }

  body {
    background: #fff;
  }

  .bubble.ai,
  .bubble.user,
  .bubble.crisis {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
