:root {
  --bg: #F5F6F8; --card: #FFFFFF; --border: #E5E7EB; --text: #111827; --text-2: #6B7280; --text-3: #6B7280;
  --primary: #0F172A; --on-primary: #FFFFFF; --water: #60A5FA; --tank-empty: #F1F5F9; --glyph-border: #CBD5E1;
  --up: #DC2626; --up-bar: #FCA5A5; --down: #16A34A; --down-bar: #86EFAC; --eq-bar: #CBD5E1;
  --warn-bg: #FEF3C7; --warn-text: #92400E; --error: #B91C1C; --ok-bg: #DCFCE7; --ok-text: #166534;
  --wa: #25D366; --wa-text: #FFFFFF;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', 'Mangal', sans-serif;
  font-size: 16px; line-height: 1.45; font-variant-numeric: tabular-nums;
}
p { margin: 0; }
main { max-width: 420px; margin: 0 auto; padding: 12px 16px 16px; }
section > * + * { margin-top: 12px; }

.bar {
  position: sticky; top: 0; z-index: 2; height: 52px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px 0 16px; background: var(--card); border-bottom: 1px solid var(--border);
}
.bar h1 { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; margin-left: -12px; border: 0; background: none; color: var(--text); display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.icon-btn:active { background: var(--tank-empty); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.banner { background: var(--warn-bg); color: var(--warn-text); font-size: 13px; padding: 10px 12px; border-radius: 10px; }
.lbl { font-size: 12px; color: var(--text-2); }
.meta { font-size: 11px; color: var(--text-3); }
.center { text-align: center; }
.h { font-size: 13px; font-weight: 600; }

.tanks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.tank { display: flex; gap: 10px; align-items: center; }
.glyph { position: relative; width: 24px; height: 56px; border: 1px solid var(--glyph-border); border-radius: 5px; background: var(--tank-empty); overflow: hidden; }
.fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--water); transition: height 400ms ease-out; }
.pct { font-size: 28px; font-weight: 600; line-height: 1.1; }

.strip { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; text-align: center; }
.sv { font-size: 15px; font-weight: 600; white-space: nowrap; }

.trend-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.trend-head .h { flex: 1; }
.trow { display: grid; grid-template-columns: 24px 1fr 60px; gap: 6px; align-items: center; height: 22px; }
.tday { font-size: 11px; color: var(--text-2); position: relative; }
.tday.today::before { content: ''; position: absolute; left: -7px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: var(--water); }
.track { position: relative; height: 10px; }
.tbar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.tbar.up { background: var(--up-bar); } .tbar.down { background: var(--down-bar); } .tbar.eq { background: var(--eq-bar); }
.tavg { position: absolute; top: -4px; bottom: -4px; border-left: 1.5px dashed var(--text); }
.tval { font-size: 12px; font-weight: 500; text-align: right; white-space: nowrap; }
.tval.up { color: var(--up); } .tval.down { color: var(--down); } .tval.eq, .tval.none { color: var(--text-2); }
.tval.anom::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 3px; border-radius: 50%; background: var(--warn-text); vertical-align: 1px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { border: 0; border-left: 1px solid var(--border); background: none; color: var(--text); font: inherit; padding: 0 10px; transition: background 120ms ease; }
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.seg button:active { transform: scale(0.97); transition: transform 80ms ease; }
.seg-sm { border-radius: 8px; border-width: 1px; }
.seg-sm button { height: 32px; font-size: 12px; white-space: nowrap; }
.lv button { height: 52px; font-size: 16px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.tag { font-size: 10px; font-weight: 400; opacity: 0.85; }
#recForm > * + *, #recDone > * + * { margin-top: 12px; }
#recForm > .lbl { margin-top: 18px; margin-bottom: -6px; }
#recForm > #meterHint { margin-top: 6px; }
#recForm > .save-row { margin-top: 16px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 600; text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible, select:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--water); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); height: 56px; }
.btn.primary:disabled { opacity: 0.7; }
.btn.wa { background: var(--wa); color: var(--wa-text); border-color: var(--wa); height: 56px; }
.sticky { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); height: 52px; }

input, select { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1.5px solid var(--border); border-radius: 12px; padding: 0 12px; }
input:focus, select:focus { border-color: var(--primary); outline: none; }
input.bad, select.bad { border-color: var(--error); }
.meter { height: 56px; font-size: 22px; font-weight: 500; }
select { height: 48px; }
.who { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 13px; color: var(--text-2); min-height: 32px; }
.link { border: 0; background: none; color: #2563EB; font: inherit; font-size: 13px; padding: 6px 4px; min-height: 32px; }
.hint-up { color: var(--down); } .hint-bad { color: var(--error); }
.preview { font-size: 13px; color: var(--text-2); text-align: center; min-height: 19px; }
.preview b { color: var(--text); font-weight: 600; }
.save-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
.save-row input { height: 56px; text-align: center; letter-spacing: 2px; }
.err { font-size: 13px; color: var(--error); min-height: 0; }
.err:empty { display: none; }

.ok { background: var(--ok-bg); color: var(--ok-text); font-size: 15px; font-weight: 600; border-radius: 12px; padding: 12px; }
.done-sum { font-size: 13px; color: var(--text-2); white-space: pre-line; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #FFFFFF; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); max-width: 90%; padding: 8px 14px; border-radius: 999px; font-size: 13px; background: var(--ok-bg); color: var(--ok-text); animation: fadein 150ms ease; z-index: 3; }
.toast.bad { background: #FEE2E2; color: var(--error); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
