:root {
  --bg: #f4f2ec; --surface: #ffffff; --ink: #1c211d; --muted: #6a7068; --line: #e2dfd5; --line-strong: #c9c5b8;
  --accent: #2c5a4c; --accent-ink: #ffffff; --accent-soft: #e4ede7; --brass: #9a7b3f; --brass-soft: #f3ecdc;
  --warn: #a8461f; --warn-soft: #fbe9df; --ok: #2c5a4c; --shadow: 0 1px 2px rgba(28,33,29,.06), 0 8px 24px rgba(28,33,29,.06);
  --r: 14px; --r-sm: 10px; --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 24px; line-height: 1.15; }
h3 { font-size: 18px; line-height: 1.2; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

#app { min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.screen.wide { max-width: 720px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.back { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 600; cursor: pointer; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.card.flat { box-shadow: none; }
.card.accent { background: var(--accent-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: #efc9b5; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 380px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 12px 18px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 46px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .chip:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #9cc3b4; outline-offset: 2px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
label.field span.hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=tel], select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 12px; background: #fff; min-height: 46px; }
textarea { min-height: 96px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 15px; min-height: 40px; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.warnon { background: var(--warn); color: #fff; border-color: var(--warn); }

.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex: none; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 26px; color: var(--accent); overflow: hidden; }
.avatar.lg { width: 96px; height: 96px; font-size: 40px; }
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.today { font-family: var(--font-display); font-size: 18px; line-height: 1.35; }
.checkin { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.checkin button { border: 1px solid var(--line-strong); background: #fff; border-radius: var(--r-sm); padding: 12px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; }
.checkin button .dot { width: 14px; height: 14px; border-radius: 50%; }
.checkin button.on { border-color: var(--accent); background: var(--accent-soft); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 5; }
.tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 0; border-radius: 8px; }
.tabbar a.on { color: var(--accent); }
.tabbar a svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }

.msgs { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 12px 14px; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.updates { display: flex; flex-direction: column; gap: 6px; align-self: flex-start; max-width: 92%; }
.update { font-size: 13px; background: var(--brass-soft); color: #5f4a1f; border-radius: 999px; padding: 6px 12px; }
.composer { position: fixed; left: 0; right: 0; bottom: 64px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer form { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.composer textarea { min-height: 46px; max-height: 140px; border-radius: 22px; padding: 12px 16px; }
.composer button { flex: none; width: 46px; height: 46px; border-radius: 50%; padding: 0; }

.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .when { flex: none; width: 64px; font-size: 13px; color: var(--muted); padding-top: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.brass { background: var(--brass-soft); color: #5f4a1f; }
.pill.muted { background: var(--line); color: var(--muted); }

.section { border-top: 1px solid var(--line); padding-top: 14px; }
.section > .row.between { cursor: pointer; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 15px; }
.kv b { font-weight: 600; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos figure { margin: 0; border-radius: 10px; overflow: hidden; background: var(--line); aspect-ratio: 1; position: relative; }
.photos figure img { width: 100%; height: 100%; object-fit: cover; }
.photos figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; background: rgba(0,0,0,.45); color: #fff; padding: 3px 6px; }
.scale { display: flex; gap: 6px; }
.scale button { flex: 1; min-height: 40px; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; cursor: pointer; }
.scale button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 9; box-shadow: var(--shadow); max-width: 90%; }
.wordmark { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.hero { padding: 24px 0 8px; display: flex; flex-direction: column; gap: 14px; }
.hero h1 { font-size: 38px; }
.badge-demo { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brass); background: var(--brass-soft); border-radius: 999px; padding: 3px 8px; }
ul.clean { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.sheet { position: fixed; inset: 0; background: rgba(28,33,29,.35); z-index: 8; display: flex; align-items: flex-end; justify-content: center; }
.sheet > .card { width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; max-height: 88vh; overflow: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.err { color: var(--warn); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .tabbar, .composer, .noprint { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

input[type=range] { accent-color: var(--accent); width: 100%; margin: 6px 0; }
