:root {
  --bg: #f2f5f7; --card: #ffffff; --ink: #18232b; --muted: #637380; --line: #dde4e9;
  --accent: #1f6f8b; --accent-ink: #ffffff; --bar: #1d3b4f; --bar-ink: #f2f5f7;
  --good: #1f7a45; --good-bg: #e1f4e8; --warn: #8a5a00; --warn-bg: #fff1d1;
  --bad: #b3261e; --bad-bg: #fde6e4; --blue: #1f4e8c; --blue-bg: #e3edfb; --grey-bg: #e9eef1;
  --gold: #b7791f; --sys: #c0392b; --dia: #2c6fb7; --wcol: #1f7a45;
  --radius: 16px; --shadow: 0 1px 3px rgba(0,0,0,.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1519; --card: #182128; --ink: #e6edf1; --muted: #93a3ae; --line: #26323a;
    --accent: #5fb3cf; --accent-ink: #0b1418; --bar: #0a1013; --bar-ink: #e6edf1;
    --good: #85d6a2; --good-bg: #15301f; --warn: #f2c063; --warn-bg: #3a2c0d;
    --bad: #ff8a80; --bad-bg: #3b1714; --blue: #9cc1f5; --blue-bg: #17263b; --grey-bg: #222d34;
    --gold: #f0c36a; --sys: #ff8a80; --dia: #8cbcf5; --wcol: #85d6a2; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.center { text-align: center; padding: 40px 16px; }
.center-text { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--good); font-weight: 600; }
[hidden] { display: none !important; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink);
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; display: flex; align-items: center; gap: 4px; }
.bar h1 { font-size: 19px; margin: 0 6px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar button { background: transparent; border: 0; color: var(--bar-ink); padding: 6px 12px; font-size: 22px;
  border-radius: 10px; min-height: 42px; min-width: 42px; cursor: pointer; }
.bar button.pill { font-size: 14px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; min-height: 32px; padding: 4px 12px; }
.bar button:disabled { opacity: .25; }
.bar button:active { background: rgba(255,255,255,.12); }

.wrap { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px;
  font-size: 11px; color: var(--muted); text-decoration: none; }
.tabs a span { font-size: 21px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--accent); font-weight: 700; }
.tabs a.on span { filter: none; opacity: 1; }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { font-size: 54px; }
.login h1 { font-size: 26px; margin: 4px 0; }
.login form { text-align: left; margin-top: 14px; }

/* cards */
.card { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; color: inherit; text-decoration: none; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }

.hero { display: flex; gap: 14px; align-items: center; }
.hero-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-txt b { font-size: 20px; }
.saved { color: var(--muted); min-height: 1em; }
.ring { width: 64px; height: 64px; flex: none; }
.ring-bg { fill: none; stroke: var(--grey-bg); stroke-width: 7; }
.ring-fg { fill: none; stroke: var(--good); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .3s; }
.ring text { font-size: 14px; font-weight: 700; fill: var(--ink); }

.quote { position: relative; padding-left: 40px; background: linear-gradient(135deg, var(--card), var(--blue-bg)); }
.quote .qmark { position: absolute; left: 12px; top: 2px; font-size: 44px; color: var(--accent); font-family: Georgia, serif; }
.quote .qt { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.45; }
.quote .qs, .bigquote .qs { display: block; font-size: 13px; color: var(--muted); margin-top: 6px; }
.quote .qmore { display: block; font-size: 13px; color: var(--accent); margin-top: 8px; font-weight: 600; }

/* inputs */
label.f, div.f { display: block; margin: 0 0 12px; }
label.f > span, .lbl, .edrow label > span, .bpin label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; font-size: 16px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); border-radius: 12px; padding: 10px 14px; min-height: 46px; cursor: pointer; text-decoration: none; color: inherit; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 6px 12px; border-radius: 10px; min-width: 50px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.nowrap { flex-wrap: nowrap; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--card); padding: 10px 6px; min-height: 44px; cursor: pointer; font-size: 15px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg button.on.good { background: var(--good); }
.seg button.on.ok { background: var(--gold); }
.seg button.on.poor { background: var(--bad); }

/* tags */
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--grey-bg); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.blue { background: var(--blue-bg); color: var(--blue); }

/* BP */
.bpbig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.bpbig .num { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.readings, .notes, .summary { list-style: none; margin: 0 0 12px; padding: 0; }
.readings li, .notes li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.readings li:last-child, .notes li:last-child { border-bottom: 0; }
.readings .rt, .notes li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 6px 8px; cursor: pointer; border-radius: 8px; }
.bpin { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.bpin label { flex: 1; }
.bpin input { font-size: 30px; font-weight: 700; text-align: center; min-height: 64px; }
.bpin b { font-size: 32px; color: var(--muted); padding-bottom: 10px; }
.result { text-align: center; padding: 24px 16px; }
.result .num { font-size: 52px; font-weight: 800; }
.result .tag { font-size: 16px; padding: 6px 12px; margin: 8px 0; }
.result.bad { box-shadow: inset 0 0 0 2px var(--bad); }
.tips ul { margin: 8px 0 0; padding-left: 20px; }
.tips li { margin-bottom: 4px; font-size: 14px; }
.tips summary { font-weight: 600; cursor: pointer; }

/* toggles */
.toggle { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line);
  background: var(--card); border-radius: 12px; padding: 10px 12px; min-height: 50px; margin-bottom: 8px; cursor: pointer; }
.toggle.big { min-height: 62px; }
.toggle .box { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center;
  font-weight: 800; color: var(--accent-ink); }
.toggle .tl { flex: 1; display: flex; flex-direction: column; }
.toggle.on { border-color: var(--good); background: var(--good-bg); }
.toggle.on .box { background: var(--good); border-color: var(--good); color: #fff; }

/* exercise */
.ex { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ex:last-of-type { border-bottom: 0; }
.exhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.exval { border: 0; background: var(--grey-bg); border-radius: 8px; padding: 4px 10px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.ex.met .exval { background: var(--good-bg); color: var(--good); font-weight: 700; }
.meter { height: 7px; background: var(--grey-bg); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.ex.met .meter i { background: var(--good); }
.exbtns { display: flex; gap: 6px; }
.exbtns .btn { flex: 1; }

.water { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0 12px; flex-wrap: wrap; }
.rate { display: flex; flex-direction: column; gap: 6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; border: 1px solid var(--line);
  background: var(--card); border-radius: 14px; padding: 12px; min-height: 104px; cursor: pointer; font-weight: 600; }
.tile .ic { font-size: 26px; }
.tile .tk { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: auto; }
.tile.on { border-color: var(--good); background: var(--good-bg); }
.tile.on .tk { color: var(--good); font-weight: 700; }

/* progress */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stats div { background: var(--grey-bg); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .target { stroke: var(--good); stroke-width: 1.2; stroke-dasharray: 4 3; }
.chart .ax { fill: var(--muted); font-size: 9px; }
.chart path { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .l-sys { stroke: var(--sys); } .chart .p-sys { fill: var(--sys); opacity: .55; }
.chart .l-dia { stroke: var(--dia); } .chart .p-dia { fill: var(--dia); opacity: .55; }
.chart .l-w { stroke: var(--wcol); } .chart .p-w { fill: var(--wcol); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); margin-top: 4px; }
.legend .k { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend .k.sys { background: var(--sys); } .legend .k.dia { background: var(--dia); }
.legend .k.tgt { background: repeating-linear-gradient(90deg, var(--good) 0 4px, transparent 4px 7px); }
.habits { width: 100%; border-collapse: collapse; font-size: 14px; }
.habits th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 0 0 6px; }
.habits td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.habits td + td { text-align: right; white-space: nowrap; padding-left: 8px; font-weight: 600; }
.dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 5px; }
.dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--grey-bg); }
.dots i.y { background: var(--good); }
.dots i.t { outline: 1px solid var(--muted); outline-offset: 1px; }
dl { margin: 0; }
dl div { display: grid; grid-template-columns: 42% 58%; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
dl div:last-child { border-bottom: 0; }
dt { color: var(--muted); font-size: 14px; }
dd { margin: 0; }

/* encouragement */
.bigquote { padding: 26px 20px; text-align: center; min-height: 180px; display: flex; flex-direction: column; justify-content: center; }
.bigquote p { font-family: Georgia, "Times New Roman", serif; font-size: 21px; line-height: 1.5; margin: 0; }
.bigquote.bible { background: linear-gradient(160deg, var(--card), var(--warn-bg)); }
.bigquote.health { background: linear-gradient(160deg, var(--card), var(--good-bg)); }
.bigquote.ukraine { background: linear-gradient(160deg, var(--blue-bg), var(--warn-bg)); }
.bigquote.motivation, .bigquote.mine { background: linear-gradient(160deg, var(--card), var(--blue-bg)); }
#next { margin-bottom: 12px; }
.summary li { padding: 7px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.summary li:last-child { border-bottom: 0; }

/* settings */
.edrow { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.edrow label { flex: 1 1 90px; min-width: 0; }
.edrow label.w2 { flex: 2 1 160px; }
.edrow label.w3 { flex: 1 1 100%; }
.edrow label.w0 { flex: 0 0 64px; }
.edrow label.w0 input { text-align: center; }
.edbtns { display: flex; gap: 6px; width: 100%; justify-content: flex-end; }
.ed { margin-bottom: 10px; }
.savebar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; padding: 6px 0 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: 90vw; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
