:root {
  --ink: #1c1917;
  --ink-soft: #44403c;
  --muted: #78716c;
  --paper: #f7f1e8;
  --paper-2: #efe6d8;
  --sand: #e4d5c1;
  --line: #d6c8b4;
  --clay: #c45c3e;
  --clay-deep: #9a3f28;
  --sage: #4a6b5c;
  --sage-deep: #2f4a3e;
  --sage-soft: #d7e4dc;
  --gold: #b8923a;
  --good: #3d6b4f;
  --warn: #b45309;
  --alert: #9f1239;
  --white: #fffdf8;
  --shadow: 0 10px 30px rgba(47, 74, 62, 0.08);
  --radius: 18px;
  --nav-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #f3e6d4 0%, transparent 55%),
    radial-gradient(800px 400px at 100% 0%, #dce8e1 0%, transparent 50%),
    var(--paper);
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 560; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(145deg, var(--sage) 0%, var(--sage-deep) 100%);
  display: grid; place-items: center; color: #f7f1e8;
  box-shadow: 0 6px 16px rgba(47,74,62,.22);
}
.brand-name { font-family: ui-serif, Georgia, serif; font-size: 1.2rem; }
.brand-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.icon-btn {
  border: 0; background: var(--white); width: 40px; height: 40px; border-radius: 12px;
  box-shadow: var(--shadow); display: grid; place-items: center;
}

.screen { display: none; padding: 4px 18px 24px; }
.screen.active { display: block; }

.hero-card, .card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.hero-card h2 { font-size: 1.55rem; margin-bottom: 6px; }
.lede { color: var(--ink-soft); font-size: 0.95rem; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 6px 11px; font-size: 0.82rem; color: var(--ink-soft);
}
.pill.accent { background: var(--sage-soft); border-color: #b7cfc3; color: var(--sage-deep); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat {
  background: var(--paper-2); border-radius: 14px; padding: 10px;
  text-align: center;
}
.stat b { display: block; font-family: ui-serif, Georgia, serif; font-size: 1.25rem; }
.stat span { font-size: 0.72rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 600;
}
.btn.primary { background: var(--sage-deep); color: #f4efe6; width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.clay { background: var(--clay); color: white; }
.btn.small { padding: 8px 12px; font-size: 0.85rem; width: auto; }
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions .btn { flex: 1; }

.sym-list { display: flex; flex-direction: column; gap: 10px; }
.sym {
  background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
}
.sym-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.sym-name { font-weight: 650; }
.sym-val { font-size: 0.78rem; color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.scale button {
  border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 0;
  font-size: 0.78rem;
}
.scale button.on { background: var(--sage-deep); color: #f4efe6; border-color: var(--sage-deep); }
.scale button.on.sev1 { background: #6b8f7c; border-color: #6b8f7c; }
.scale button.on.sev2 { background: #c27a3a; border-color: #c27a3a; }
.scale button.on.sev3 { background: var(--clay); border-color: var(--clay); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 7px 12px; font-size: 0.85rem;
}
.tag.on { background: var(--sage-soft); border-color: #9fbfb0; color: var(--sage-deep); font-weight: 600; }

label.field { display: block; font-size: 0.82rem; color: var(--muted); margin: 8px 0 6px; }
input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--white);
  border-radius: 12px; padding: 10px 12px;
}
textarea { min-height: 72px; resize: vertical; }

.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 150px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.bubble {
  max-width: 88%; padding: 11px 13px; border-radius: 16px; font-size: 0.95rem;
  white-space: pre-wrap;
}
.bubble.bot { background: var(--white); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--sage-deep); color: #f6f1e8; align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble .cite { display: block; margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
.suggests { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.suggests button {
  border: 1px solid var(--line); background: var(--white); border-radius: 999px;
  padding: 7px 11px; font-size: 0.8rem;
}
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; }
.composer button { border: 0; background: var(--sage-deep); color: #f4efe6; border-radius: 12px; padding: 0 14px; font-weight: 650; }

.insight { border-left: 3px solid var(--sage); padding-left: 10px; margin: 8px 0; }
.insight h3 { font-size: 1rem; margin-bottom: 4px; }
.flag {
  background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239;
  border-radius: 14px; padding: 12px; margin: 8px 0;
}
.care-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.care-item:last-child { border-bottom: 0; }
.care-item strong { display: block; margin-bottom: 3px; }

.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(480px, 100%);
  background: rgba(247,241,232,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(8px + var(--safe-b));
  z-index: 20;
}
.nav button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.68rem; font-weight: 600;
}
.nav button.active { color: var(--sage-deep); }
.nav svg { width: 22px; height: 22px; }

.overlay {
  position: fixed; inset: 0; background: rgba(28,25,23,.45);
  z-index: 40; display: none; align-items: flex-end; justify-content: center;
}
.overlay.show { display: flex; }
.sheet {
  width: min(480px, 100%); background: var(--paper); border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(24px + var(--safe-b)); max-height: 92dvh; overflow: auto;
}
.sheet h2 { margin-bottom: 8px; }
.choice-grid { display: grid; gap: 8px; margin: 12px 0; }
.choice {
  text-align: left; border: 1px solid var(--line); background: var(--white);
  border-radius: 14px; padding: 12px;
}
.choice.on { border-color: var(--sage-deep); box-shadow: inset 0 0 0 1px var(--sage-deep); }
.choice small { display: block; color: var(--muted); }

.sheet ul { padding-left: 1.15rem; margin: 8px 0 12px; color: var(--ink-soft); }
.sheet li { margin: 4px 0; }
.tiny { font-size: 0.75rem; color: var(--muted); }
.disclaimer {
  font-size: 0.75rem; color: var(--muted); background: var(--paper-2);
  border-radius: 12px; padding: 10px; margin-top: 10px;
}

.day-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper-2); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem;
}

.trend-bar { height: 8px; background: var(--sand); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.trend-bar > span { display: block; height: 100%; background: var(--sage); }

.history-item {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.consent-card {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.consent-card label { display: block; margin: 4px 0; }
.hidden { display: none !important; }
.wrap { max-width: 480px; margin: 0 auto; padding: 24px 18px 48px; }
.wrap h1 { font-size: 2rem; margin: 12px 0 8px; }
.pass { color: #3d6b4f; }
.fail { color: #9f1239; }
