/* Health Tracker — dark, mobile-first UI */
:root {
  --bg: #0e131a;
  --bg-2: #151d28;
  --card: #1a2432;
  --card-2: #202d3d;
  --line: #2b3a4e;
  --text: #e8eef5;
  --muted: #8ea0b5;
  --accent: #3ddc97;
  --accent-dim: #1f6b4d;
  --green: #2ecc71;
  --amber: #f4b740;
  --red: #e74c3c;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  padding-bottom: 90px;
  overscroll-behavior-y: contain;
}
.app { max-width: 620px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-weight: 650; letter-spacing: .2px; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* Header */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(14,19,26,.85));
  padding: 14px 16px 10px; max-width: 620px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
header.top .date { font-size: 1.15rem; font-weight: 650; }
header.top .date small { display:block; color: var(--muted); font-weight: 500; font-size: .75rem; }
.status-dots { display: flex; gap: 6px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }

/* Cards & hub */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.hub button {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--r); padding: 20px 14px; text-align: left; cursor: pointer;
  min-height: 104px; display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .06s, border-color .2s;
}
.hub button:active { transform: scale(.97); }
.hub button .ico { font-size: 1.8rem; }
.hub button .lbl { font-weight: 650; }
.hub button .sub { color: var(--muted); font-size: .8rem; }
.hub button.primary { background: linear-gradient(160deg, #1c3a2c, #16283a); border-color: var(--accent-dim); }
.hub .wide { grid-column: 1 / -1; min-height: 64px; flex-direction: row; align-items: center; gap: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 12px; padding: 13px 16px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #06231a; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.danger { color: var(--red); border-color: #4a2a2a; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* Form fields */
.field { margin: 16px 0; }
.field > label { display: block; font-weight: 600; margin-bottom: 8px; }
.field .hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
input[type=number], input[type=text], input[type=time], textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 14px; font-size: 1.05rem; }
textarea { min-height: 78px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }

/* Segmented control */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { flex: 1 1 auto; min-width: 72px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--text); border-radius: 12px; padding: 12px 10px; font-size: .95rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #06231a; border-color: transparent; font-weight: 700; }
.seg.stack button { flex-basis: 100%; text-align: left; }

/* Toggle pill */
.toggle { display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.toggle .sw { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.toggle .sw::after { content:""; position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:#fff; transition: transform .2s; }
.toggle[aria-pressed="true"] .sw { background: var(--accent); }
.toggle[aria-pressed="true"] .sw::after { transform: translateX(18px); }

/* Peak flow zone chip */
.zone { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: .8rem; margin-left: 8px; }
.zone.green { background: rgba(46,204,113,.15); color: var(--green); }
.zone.amber { background: rgba(244,183,64,.15); color: var(--amber); }
.zone.red   { background: rgba(231,76,60,.15);  color: var(--red); }
.pf-row { display: flex; gap: 10px; align-items: flex-end; }
.pf-row .pf-num { flex: 1.2; }
.pf-row .pf-dev { flex: 1; }

/* Lists (events / puffs / recent) */
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.item .meta { font-size: .82rem; color: var(--muted); }
.item .x { color: var(--red); background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.pill { display:inline-block; padding: 2px 8px; border-radius: 999px; font-size:.72rem; background: var(--card-2); color: var(--muted); margin-right:4px; }

/* Recent table */
.recent { width:100%; border-collapse: collapse; font-size: .85rem; }
.recent th, .recent td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.recent th { color: var(--muted); font-weight: 600; }
.reliever-hi { color: var(--amber); font-weight: 700; }

/* Bottom nav */
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg-2);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 30; }
nav.bottom button { background: none; border: none; color: var(--muted); font-size: .72rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 12px; }
nav.bottom button .ni { font-size: 1.3rem; }
nav.bottom button.active { color: var(--accent); }

/* Login */
.login { min-height: 82vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; text-align:center; }
.login .pin { letter-spacing: 12px; text-align: center; font-size: 1.6rem; max-width: 220px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #06231a; padding: 12px 18px; border-radius: 999px; font-weight: 700;
  opacity: 0; transition: all .25s; z-index: 50; pointer-events: none; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); color: #fff; }

/* Reference guide render */
.doc h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 22px; }
.doc table { width:100%; border-collapse: collapse; font-size:.88rem; margin: 8px 0; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 8px; text-align:left; }
.section-title { display:flex; align-items:center; gap:10px; margin: 6px 0 2px; }
.back { background:none; border:none; color: var(--accent); font-size: 1rem; cursor:pointer; padding: 6px 0; }
