:root {
  --bg: #f6f7f4; --surface: #ffffff; --surface-2: #eef1ec; --text: #1d2521; --muted: #5d6a63;
  --line: #dfe4dd; --accent: #1f7a66; --accent-ink: #ffffff; --accent-soft: #dcefe9;
  --warn: #9a5b00; --warn-soft: #fbefd9; --bad: #b3261e; --bad-soft: #fbe3e1; --good: #2d7a3a;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #1a201d; --surface-2: #222a26; --text: #e6ece8; --muted: #9aa8a0;
    --line: #2e3833; --accent: #5cc4a8; --accent-ink: #0d1411; --accent-soft: #1d3a32;
    --warn: #f0b458; --warn-soft: #3a2e17; --bad: #f28b82; --bad-soft: #3d1f1d; --good: #7fcf8c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Devanagari", "Noto Sans Gujarati", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.05rem; padding: .25rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.side nav a { display: block; padding: .5rem .65rem; border-radius: 9px; color: var(--text); text-decoration: none; font-size: .95rem; }
.side nav a:hover { background: var(--surface-2); }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .sep { height: 1px; background: var(--line); margin: .6rem .5rem; }
.side select, .side .who { width: 100%; }
.who { padding: .4rem .6rem; font-size: .85rem; color: var(--muted); }
main { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1200px; width: 100%; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.menu-btn { display: none; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .grid-2 > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .75rem; align-items: baseline; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.num { font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.H, .pill.bad, .pill.urgent { background: var(--bad-soft); color: var(--bad); }
.pill.L, .pill.A, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }

.alert { border-radius: 12px; padding: .8rem 1rem; margin-bottom: .6rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.alert.urgent { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--warn-soft); color: var(--warn); }
.notice { background: var(--surface-2); border-radius: 12px; padding: .75rem 1rem; font-size: .9rem; color: var(--muted); }

form.inline { display: inline; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: .5rem 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 .8rem; }
button, .btn { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; border-radius: 10px; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.link { background: none; border: 0; color: var(--muted); padding: 0; font-weight: 500; font-size: .85rem; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button[disabled] { opacity: .6; cursor: progress; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent); margin: .25rem 0; }

.prose { line-height: 1.65; }
.prose h2 { font-size: 1.1rem; margin-top: 1.4rem; }
.prose ul { padding-left: 1.2rem; }
.prose table { margin: .5rem 0; }
.ai-box { border-left: 3px solid var(--accent); padding-left: 1rem; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: .75rem; color: var(--muted); text-align: center; padding: .2rem; }
.cal .day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 92px; padding: .3rem; font-size: .78rem; overflow: hidden; }
.cal .day.out { opacity: .45; }
.cal .day.today { outline: 2px solid var(--accent); }
.cal .ev { display: block; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 4px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.lab { background: var(--warn-soft); color: var(--warn); }
.cal .ev.refill, .cal .ev.renewal { background: var(--surface-2); color: var(--text); }

.chat { display: flex; flex-direction: column; gap: .6rem; max-height: 60vh; overflow-y: auto; padding: .25rem; }
.msg { max-width: 80%; padding: .65rem .9rem; border-radius: 16px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg p { margin: .2rem 0; }
.chat-form { display: flex; gap: .5rem; margin-top: .75rem; }
.chat-form textarea { min-height: 52px; }

.spark { width: 100%; height: 220px; }
video { width: 100%; border-radius: 12px; background: #000; }

/* Her daily screen: large, calm, few choices */
body.simple { font-size: 21px; }
.simple main { max-width: 760px; margin: 0 auto; padding: 1.2rem 16px 5rem; }
.simple h1 { font-size: 2rem; }
.simple h2 { font-size: 1.35rem; margin-top: 1.6rem; }
.task { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 1rem 1.1rem; margin: .7rem 0; }
.task.done { border-color: var(--accent); background: var(--accent-soft); }
.task .t { flex: 1; }
.task .t small { display: block; color: var(--muted); font-size: .8em; }
.task button { font-size: 1rem; padding: .7rem 1.1rem; border-radius: 14px; min-width: 110px; justify-content: center; }
.big-btn { display: flex; justify-content: center; font-size: 1.2rem; padding: 1rem; border-radius: 18px; width: 100%; margin-top: 1rem; }
.simple .chat { max-height: none; }
.simple .msg { font-size: 1.05rem; }
.mic { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.mic.on { background: var(--bad); color: #fff; border-color: var(--bad); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  main { padding: 1rem 16px 4rem; }
  .cal .day { min-height: 60px; font-size: .68rem; }
  .msg { max-width: 92%; }
  .task { flex-wrap: wrap; }
}

/* caregiver view of someone else's record */
.care-banner { display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap;
  background: var(--warn-soft); color: var(--text); border:1px solid var(--warn);
  border-radius: 10px; padding:.55rem .8rem; margin-bottom:1rem; font-size:.95rem }
.care-banner form { margin:0 }
.list li.highlight { outline:2px solid var(--accent); outline-offset:2px; border-radius:8px }

.voice-btn { font-size: 1.15rem; padding: .8rem 1.3rem; }
.voice-status { margin: 0 0 .6rem; padding: .5rem .8rem; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
