/* app.css — mobile-first. Big tap targets, one-handed reach, dark/light aware.
   No inline styles anywhere (the CSP forbids them), so all presentation lives
   here. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1a1c20;
  --muted: #6b7280;
  --border: #d7dbe2;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --on: #16a34a;
  --tap: 44px; /* minimum comfortable touch target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f242d;
    --text: #e8eaed;
    --muted: #9aa3b2;
    --border: #2b313c;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --on: #22c55e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

/* ---- Top bar (sticky) ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: max(env(safe-area-inset-top), 8px) 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-row { display: flex; align-items: center; gap: 8px; }
.date-input {
  flex: 1;
  min-height: var(--tap);
  font-size: 17px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.navbtn {
  min-width: var(--tap);
  min-height: var(--tap);
  font-size: 24px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.phase-pill {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
}
.upcoming-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.action-row { display: flex; gap: 8px; }
.savebtn {
  flex: 1;
  min-height: var(--tap);
  font-size: 17px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
}
.ghostbtn {
  min-height: var(--tap);
  padding: 0 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.status { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.status.ok { color: var(--on); }

/* ---- Sections ---- */
main { padding: 8px 12px 64px; display: flex; flex-direction: column; gap: 10px; }
.sec { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.sec-head {
  width: 100%;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
}
.sec-caret { width: 1em; color: var(--muted); }
.sec-count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 14px; }
.sec-body { padding: 4px 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.sec-body.hidden { display: none; }

/* ---- Generic field rows ---- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 14px; color: var(--muted); }
.field input[type="number"],
.field input[type="time"],
.field select,
.field textarea {
  min-height: var(--tap);
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
}
.field textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Tap-scale (symptoms) ---- */
.symptom { display: flex; flex-direction: column; gap: 6px; }
.symptom-head { display: flex; justify-content: space-between; font-size: 15px; }
.symptom-head .val { font-weight: 700; }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.scale-btn {
  min-height: 38px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0;
}
.scale-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }

/* ---- Toggle chips (routine / intake) ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: var(--tap);
  padding: 0 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
}
.chip.on { background: var(--on); color: #fff; border-color: var(--on); }
.chip.indent { margin-left: 18px; }
.chip .tag { font-size: 11px; opacity: 0.7; margin-left: 6px; }

.subhead { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 2px 0 -4px; }
.field.narrow input { max-width: 4.5rem; }

/* ---- Weekly schedule ---- */
.week-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.week-label { flex: 1; text-align: center; font-size: 14px; }
.navbtn.small { min-width: 36px; min-height: 36px; font-size: 20px; }
.ghostbtn.small { min-height: 36px; padding: 0 10px; font-size: 13px; }

.wgrid { display: flex; flex-direction: column; gap: 12px; }
.wcells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.whead { margin-bottom: -4px; }
.wday { display: flex; flex-direction: column; align-items: center; line-height: 1.05; color: var(--muted); }
.wday-l { font-size: 12px; }
.wday-n { font-size: 11px; opacity: 0.85; }
.wday.weekend { color: var(--accent); }
.wday.today .wday-n { color: var(--accent); font-weight: 700; }
.wrow { display: flex; flex-direction: column; gap: 5px; }
.wrow-head { font-size: 14px; }
.wcell {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.wcell.weekend { background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.wcell.planned { color: var(--muted); }
.wcell.done { background: var(--on); color: #fff; border-color: var(--on); font-weight: 700; }
.wcell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.wtypes { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.wtype { display: flex; align-items: center; gap: 8px; }
.wtype-day { font-size: 13px; color: var(--muted); width: 34px; }
.wtype input {
  flex: 1;
  min-height: 38px;
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}
.wnotes {
  width: 100%;
  min-height: 64px;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  line-height: 1.45;
}

/* ---- Data bar (import/export) ---- */
.databar {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 4px 12px max(env(safe-area-inset-bottom), 16px);
}
