:root {
  --bg: #f6f1ea; --card: #fffdf9; --ink: #3b3330; --sub: #8a7f78; --line: #e7ddd2;
  --accent: #d9825b; --accent-soft: #f6dfd2; --ok: #6a9a6f; --warn: #d0605a;
  --karubi: #d9825b; --akubi: #6f8fb8;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif; font-size: 16px; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 16px 6px; }
#title { font-size: 13px; color: var(--sub); margin-top: 4px; }
#title:empty { display: none; }
main { padding: 4px 16px 24px; max-width: 640px; margin: 0 auto; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card > .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-weight: 600; }
.muted { color: var(--sub); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
label.f { display: block; font-size: 13px; color: var(--sub); margin: 10px 0 4px; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 72px; resize: vertical; }
button { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent-soft); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: 13px; }
button.danger { background: transparent; color: var(--warn); }
button:disabled { opacity: .5; }
.wide { width: 100%; margin-top: 12px; padding: 13px; }
.seg { display: flex; background: #ece3d8; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; white-space: nowrap; background: transparent; padding: 8px 6px; border-radius: 9px; font-weight: 600; color: var(--sub); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 8px 11px; background: #fff; border: 1px solid var(--line); font-size: 15px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale { display: grid; gap: 4px; }
.scale button { padding: 10px 0; background: #fff; border: 1px solid var(--line); font-weight: 600; }
.scale button.on { color: #fff; border-color: transparent; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); margin-top: 3px; }
.datebar { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; }
.datebar .d { flex: 1; text-align: center; font-weight: 600; }
.datebar input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.todo { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: #fff; padding: 0; flex: none; font-size: 15px; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); }
.log { padding: 9px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.log:first-child { border-top: 0; }
.log .t { color: var(--sub); font-size: 13px; width: 42px; flex: none; padding-top: 1px; }
.log .x { margin-left: auto; flex: none; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs .th { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.thumbs img, .thumbs video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .th.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.thumbs .badge { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--sub); padding: 4px 0; }
.cal .c { min-height: 64px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px; font-size: 11px; overflow: hidden; }
.cal .c.out { opacity: .35; }
.cal .c.today { border-color: var(--accent); border-width: 2px; }
.cal .n { font-weight: 600; font-size: 12px; display: flex; justify-content: space-between; }
.cal .itch { display: inline-block; min-width: 18px; text-align: center; border-radius: 5px; color: #fff; font-size: 11px; padding: 0 3px; }
.cal .bar { height: 4px; border-radius: 2px; margin-top: 2px; }
.cal .ic { font-size: 10px; line-height: 1.2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0; font-size: 12px; }
.legend i { display: inline-block; width: 14px; height: 5px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stat .k { font-size: 12px; color: var(--sub); }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.cmp { display: grid; grid-template-columns: 76px 1fr 1fr; gap: 0; font-size: 14px; }
.cmp div { padding: 8px 6px; border-top: 1px solid var(--line); }
.cmp .h { font-weight: 600; color: var(--sub); font-size: 12px; border-top: 0; }
.better { color: var(--ok); font-weight: 700; }
.worse { color: var(--warn); font-weight: 700; }
canvas.chart { width: 100%; height: 170px; display: block; }
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav#tabs button { flex: 1; background: transparent; border-radius: 0; padding: 9px 0 8px; font-size: 11px; color: var(--sub); }
nav#tabs button b { display: block; font-size: 21px; font-weight: 400; }
nav#tabs button.on { color: var(--accent); font-weight: 600; }
.sheet { position: fixed; inset: 0; background: rgba(40,30,25,.35); z-index: 10; display: flex; align-items: flex-end; }
.sheet-body { background: var(--bg); width: 100%; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; max-width: 90vw; }
.empty { text-align: center; color: var(--sub); padding: 24px 0; font-size: 14px; }
.preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.readonly-note { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 6px 0; }
