:root {
  --bg: #f2f2f7; --card: #fff; --text: #1c1c1e; --sub: #8e8e93; --line: #e5e5ea;
  --green: #34c759; --green-d: #248a3d; --blue: #0a84ff; --red: #ff3b30;
  --morning: #ff9f0a; --noon: #0a84ff; --night: #5e5ce6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --sub: #8e8e93; --line: #38383a; --green-d: #30d158; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
main { padding: calc(env(safe-area-inset-top) + 12px) 16px calc(90px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 28px; margin: 8px 0 12px; }
h2 { font-size: 13px; color: var(--sub); font-weight: 600; margin: 20px 4px 6px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; padding: 12px 0 10px; font-size: 13px; color: var(--sub); }
#tabs button.on { color: var(--green-d); font-weight: 700; }

.card { background: var(--card); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .name { flex: 1; min-width: 0; }
.row .name b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .name small { color: var(--sub); font-size: 13px; }
.row.done .name b { color: var(--sub); text-decoration: line-through; }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: #fff; font-size: 16px; }
.row.done .check { background: var(--green); border-color: var(--green); }
.row.done .check::after { content: "✓"; }

.slot-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 4px 6px; }
.slot-head span { font-size: 15px; font-weight: 700; }
.slot-head small { color: var(--sub); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.m { background: var(--morning); } .n { background: var(--noon); } .e { background: var(--night); } .b { background: #636366; }
.empty { color: var(--sub); padding: 16px; text-align: center; font-size: 14px; }

.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.datebar button { font-size: 22px; padding: 4px 14px; color: var(--blue); }
.datebar button:disabled { color: var(--line); }
.datebar .d { font-weight: 700; font-size: 17px; text-align: center; }
.datebar .d small { display: block; color: var(--sub); font-weight: 400; font-size: 12px; }
.summary { display: flex; gap: 10px; margin: 8px 0; }
.stat { flex: 1; background: var(--card); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { font-size: 22px; display: block; }
.stat small { color: var(--sub); font-size: 12px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 10px 0 0; }
.bar i { display: block; height: 100%; background: var(--green); transition: width .25s; }
.allgood { text-align: center; color: var(--green-d); font-weight: 700; margin: 10px 0 0; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: var(--card); padding: 12px; border-radius: 14px; }
.cal .w { text-align: center; font-size: 12px; color: var(--sub); }
.cal button { aspect-ratio: 1; border-radius: 10px; font-size: 14px; background: var(--bg); position: relative; }
.cal button.none { background: transparent; pointer-events: none; }
.cal button.full { background: var(--green); color: #fff; font-weight: 700; }
.cal button.part { background: color-mix(in srgb, var(--green) 35%, var(--bg)); }
.cal button.miss { background: color-mix(in srgb, var(--red) 22%, var(--bg)); }
.cal button.today { outline: 2px solid var(--blue); }
.cal button.future { color: var(--line); pointer-events: none; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--sub); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.btn { display: block; width: 100%; padding: 14px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 700; text-align: center; margin-top: 16px; }
.btn.sec { background: var(--card); color: var(--blue); margin-top: 10px; }
.btn.danger { background: var(--card); color: var(--red); margin-top: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: 20px; background: var(--bg); border: 1.5px solid var(--line); font-size: 15px; }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.tags { display: flex; gap: 4px; }
.tags span { font-size: 11px; color: #fff; border-radius: 6px; padding: 1px 6px; }
.off { opacity: .5; }
.tabs-n { font-weight: 700; color: var(--sub); white-space: nowrap; }
.row.done .tabs-n { opacity: .5; }
.step { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); font-size: 20px; line-height: 1; flex: none; }
.num { min-width: 44px; text-align: center; font-weight: 700; }
.tags { flex-wrap: wrap; justify-content: flex-end; max-width: 55%; }

#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; display: flex; align-items: flex-end; }
#sheet[hidden], #toast[hidden] { display: none; }
#sheet .box { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
#sheet h3 { margin: 0 0 12px; }
label.f { display: block; font-size: 13px; color: var(--sub); margin: 12px 4px 4px; }
input[type=text], textarea { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 16px; }
textarea { min-height: 70px; resize: vertical; }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px; z-index: 20; }
.note { color: var(--sub); font-size: 13px; padding: 4px; }
