:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f43f5e;
  --accent-2: #38bdf8;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --maxw: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }

#app { max-width: var(--maxw); margin: 0 auto; padding: 16px 14px 100px; }

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
p { margin: 6px 0; color: var(--muted); }

button, .btn {
  appearance: none; border: none; border-radius: 10px;
  background: var(--accent); color: white; font-weight: 600;
  padding: 12px 16px; font-size: 16px; cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
button:active { transform: scale(.98); }
button.secondary { background: var(--surface-2); }
button.ghost { background: transparent; color: var(--muted); padding: 6px 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--surface-2); background: var(--surface);
  color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; margin: 12px 0;
}

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 2px 14px;
}
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.who .em { font-size: 22px; }

.tabs { display: flex; gap: 6px; background: var(--surface); padding: 4px;
  border-radius: 12px; margin: 6px 0 14px; }
.tabs button {
  flex: 1; background: transparent; color: var(--muted); padding: 10px;
  font-size: 14px; font-weight: 600;
}
.tabs button.active { background: var(--surface-2); color: var(--text); }

.profile-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-top: 12px;
}
.profile-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; text-align: center; cursor: pointer;
  border: 2px solid transparent;
}
.profile-card:active { border-color: var(--accent); }
.profile-card .em { font-size: 42px; display: block; margin-bottom: 6px; }
.profile-card .name { font-weight: 600; }

.add-profile { display: flex; gap: 8px; margin-top: 12px; }
.add-profile input[type=text] { flex: 1; }
.add-profile input.emoji { max-width: 70px; text-align: center; font-size: 22px; }

.bp-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.cat-normal   { background: rgba(34,197,94,.18); color: var(--good); }
.cat-elevated { background: rgba(245,158,11,.18); color: var(--warn); }
.cat-stage1   { background: rgba(239,68,68,.18); color: var(--bad); }
.cat-stage2   { background: rgba(239,68,68,.30); color: var(--bad); }
.cat-crisis   { background: var(--bad); color: white; }

.list { list-style: none; padding: 0; margin: 10px 0 0; }
.list li {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--surface-2);
}
.list li:last-child { border-bottom: none; }
.list .thumb {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover;
  background: var(--surface-2); flex-shrink: 0;
}
.list .meta { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.list .right { color: var(--muted); font-size: 13px; text-align: right; }
.list .del { background: transparent; color: var(--muted); padding: 6px; font-size: 14px; }

.chart-wrap { position: relative; height: 240px; }

.camera-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 18px; font-size: 17px;
}
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,.4); z-index: 10;
}

.loading {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--surface-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* ── Assistant chat ── */
.chat-intro { font-size: 13px; margin-bottom: 10px; }
.chat-log {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 220px; max-height: 52vh; overflow-y: auto;
  padding: 4px; margin-bottom: 10px;
}
.bubble {
  max-width: 85%; padding: 9px 12px; border-radius: 14px;
  font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.chat-form button { white-space: nowrap; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat-suggest button {
  background: transparent; border: 1px solid var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: 999px;
}
