:root {
  --bg: #0f1318; --panel: #171d25; --panel2: #1f2833; --line: #2c3745; --ctl: #5b6b80;
  --text: #e8edf3; --mute: #9aa7b8; --accent: #ff7a2f; --accent-ink: #1a0d03;
  --ok: #3ecf8e; --bad: #ff6b6b;
  --nav-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; }
.screen { padding: 14px 14px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.5rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
h4 { font-size: .85rem; margin: 14px 0 6px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 4px 0 8px; }
.mute { color: var(--mute); font-size: .9rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.center { text-align: center; display: block; margin: 12px auto; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.big { font-size: 2rem; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card.today { border-color: var(--accent); }
.note { background: var(--panel2); border-radius: 10px; padding: 10px 12px; color: var(--mute); }
.msg { font-size: 1.05rem; margin: 0 0 12px; padding: 0 2px; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; align-items: center; }
.trow > .btn { flex: 1; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 0 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 42px; padding: 0 14px; font-size: .92rem; }
.btn.wide { width: 100%; margin: 6px 0; display: block; }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; color: var(--accent); font: inherit; padding: 10px 4px; cursor: pointer; min-height: 44px; }
.link.bad { color: var(--bad); }
.icon { background: none; border: 0; color: var(--mute); width: 44px; height: 44px; font-size: 1.1rem; cursor: pointer; border-radius: 10px; flex: none; }
.icon.bad { color: var(--bad); }
.chip { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; min-height: 44px; padding: 0 16px; font: inherit; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

label { display: block; font-size: .85rem; color: var(--mute); margin: 8px 0; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; min-height: 44px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--ctl); border-radius: 10px; min-height: 46px; padding: 8px 12px; font: inherit; margin-top: 4px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.set { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.set .idx { width: 22px; text-align: center; color: var(--mute); flex: none; }
.set .fld { flex: 1; margin: 0; position: relative; min-width: 0; }
.set .fld input { margin: 0; text-align: center; font-size: 1.1rem; font-weight: 600; min-height: 48px; }
.set .fld small { position: absolute; right: 8px; top: 3px; font-size: .62rem; color: var(--mute); pointer-events: none; }
.chk { width: 48px; height: 48px; border-radius: 12px; border: 2px solid var(--ctl); background: var(--bg); color: var(--accent-ink); font-size: 1.4rem; font-weight: 800; flex: none; cursor: pointer; }
.set.done .chk { background: var(--ok); border-color: var(--ok); }
.set.done input { color: var(--ok); }

.energy { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.en { min-height: 48px; border-radius: 12px; border: 1px solid var(--ctl); background: var(--panel2); color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.en.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.energy-l { display: flex; justify-content: space-between; font-size: .75rem; color: var(--mute); margin-top: 4px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0; }
.wd { text-align: center; font-size: .72rem; color: var(--mute); }
.wd i { display: block; width: 100%; aspect-ratio: 1; max-width: 40px; margin: 4px auto 0; border-radius: 50%; border: 2px solid var(--line); font-style: normal; line-height: 32px; font-weight: 800; }
.wd.plan i { border-color: var(--accent); }
.wd.miss i { border-color: var(--bad); color: var(--bad); }
.wd.ok i { background: var(--ok); border-color: var(--ok); color: var(--accent-ink); }
.wd.now span { color: var(--text); font-weight: 700; }

.meter { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 8px 0 2px; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--accent); }
.goal { padding: 8px 0; border-top: 1px solid var(--line); }
.goal:first-of-type { border-top: 0; }
.badge-svg { width: 44px; height: 44px; flex: none; }
.badge-svg circle { fill: var(--panel2); stroke: var(--line); stroke-width: 2; }
.badge-svg path { fill: var(--line); }
.badge-svg.on circle { fill: var(--accent); stroke: var(--accent); }
.badge-svg.on path { fill: var(--accent-ink); }
.bgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bd { text-align: center; font-size: .78rem; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--mute); }
.bd b { color: var(--mute); font-size: .8rem; }
.bd.on b { color: var(--text); }
.bd small { font-size: .68rem; }

.picklist { max-height: 46vh; overflow: auto; margin: 8px 0; }
.pickrow { display: flex; justify-content: space-between; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); font: inherit; padding: 0 4px; min-height: 48px; align-items: center; cursor: pointer; text-align: left; }

.chart { width: 100%; height: auto; margin: 6px 0; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart circle { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
.chart .ax { fill: var(--mute); font-size: 10px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 118px; margin-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .7rem; color: var(--mute); }
.bar i { display: block; width: 100%; background: var(--line); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar i.ok { background: var(--ok); }
.bar .bn { color: var(--text); font-weight: 700; }
.hist { padding: 8px 0; border-top: 1px solid var(--line); }
.hist:first-of-type { border-top: 0; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; max-width: 520px; margin: 0 auto; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { flex: 1; min-height: var(--nav-h); background: none; border: 0; color: var(--mute); font: inherit; font-size: .8rem; cursor: pointer; }
.nav button.on { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

.timer { position: fixed; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.tpill { min-width: 84px; min-height: 52px; border-radius: 26px; border: 2px solid var(--accent); background: var(--panel); color: var(--text); font: inherit; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; padding: 0 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); cursor: pointer; }
.tpill.run { background: var(--accent); color: var(--accent-ink); }
.tpill.fin { background: var(--ok); border-color: var(--ok); color: var(--accent-ink); animation: pulse 1s ease-in-out infinite; }
.tpanel { width: min(320px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .6); }
.tpanel[hidden] { display: none; }
.tbig { text-align: center; font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tbig.fin { color: var(--ok); }
.tpanel .trow { justify-content: center; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .85; } }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--panel); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 80px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; z-index: 60; max-width: 90vw; text-align: center; transition: opacity .2s, transform .2s; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.filebtn { display: flex; align-items: center; justify-content: center; margin: 0; color: var(--text); font-size: .92rem; }
