:root {
  --bg: #fdf8f2;
  --paper: #fffdf9;
  --ink: #3b332e;
  --muted: #8a7f76;
  --line: #efe4d8;
  --coral: #e8836f;
  --coral-deep: #d3664f;
  --coral-soft: #fbe6df;
  --sage: #7fa886;
  --sage-soft: #e7f0e6;
  --sky: #7ea7c9;
  --sky-soft: #e6eff7;
  --sun: #e3b04b;
  --sun-soft: #fbf0d6;
  --font: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.65; -webkit-text-size-adjust: 100%; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(253, 248, 242, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px 0; padding-top: calc(8px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; text-decoration: none; padding-bottom: 8px; letter-spacing: 0.03em; }
.brand .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--coral); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 2px 6px rgba(232, 131, 111, 0.35); }
.tabs { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: none; padding: 8px 14px 10px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; font-size: 15px; }
.tab.on { color: var(--coral-deep); border-bottom-color: var(--coral); }

main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 60px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; box-shadow: 0 4px 18px rgba(80, 50, 20, 0.05); }
.card h2 { font-size: 17px; color: var(--coral-deep); letter-spacing: 0.04em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ''; width: 6px; height: 18px; border-radius: 3px; background: var(--coral); }
.muted { color: var(--muted); font-size: 14px; }
.btn { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 16px; min-height: 44px; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--coral); color: #fff; border-color: var(--coral); }
.btn.primary:hover { background: var(--coral-deep); }
.btn.big { font-size: 18px; padding: 14px 24px; }
.err { color: var(--coral-deep); font-size: 14px; }

/* ---------- gate ---------- */
.gate { min-height: calc(100dvh - 70px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: min(100%, 400px); background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px; text-align: center; box-shadow: 0 10px 40px rgba(80, 50, 20, 0.1); }
.gate-icon { font-size: 44px; }
.gate-card h1 { font-size: 22px; margin: 6px 0; }
.gate-card p { color: var(--muted); font-size: 14px; }
.gate-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.gate-card input { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 18px; text-align: center; background: #fff; }
.gate-card input:focus { outline: none; border-color: var(--coral); }

/* ---------- now ---------- */
.hero { position: relative; border-radius: 22px; overflow: hidden; min-height: 300px; background: #ddd; box-shadow: 0 10px 30px rgba(80, 50, 20, 0.15); }
.hero img { width: 100%; height: 460px; object-fit: cover; object-position: center 35%; display: block; }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(40, 20, 10, 0.72) 100%); }
.hero .text { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 24px; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.5); }
.hero .text h1 { font-size: 30px; letter-spacing: 0.08em; }
.hero .text p { margin: 4px 0 0; font-size: 15px; opacity: 0.95; }
.hero .when { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,0.85); color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: 0 4px 18px rgba(80, 50, 20, 0.05); }
.stat .lab { color: var(--muted); font-size: 13px; letter-spacing: 0.06em; }
.stat .val { font-size: 28px; font-weight: 700; color: var(--coral-deep); line-height: 1.2; margin-top: 4px; }
.stat .val small { font-size: 15px; color: var(--ink); font-weight: 500; margin-left: 4px; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.sage .val { color: #4f7a58; }
.stat.sky .val { color: #4b79a1; }
.stat.sun .val { color: #b3841c; }
.story p { margin: 0 0 8px; }
.mini-miles { display: flex; flex-direction: column; gap: 6px; }
.mini-miles .row { display: flex; gap: 10px; align-items: baseline; }
.mini-miles .d { color: var(--muted); font-size: 13px; flex-shrink: 0; width: 5.5em; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.strip .ph { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: #eee; cursor: pointer; }
.strip .ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.strip .ph:hover img { transform: scale(1.04); }
.strip .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 12px; color: #fff; background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.6)); }

/* ---------- diary ---------- */
.monthnav { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; top: 58px; z-index: 5; background: rgba(253, 248, 242, 0.95); padding: 6px 0; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer; font-weight: 700; color: var(--muted); }
.chip.on, .chip:hover { border-color: var(--coral); color: var(--coral-deep); }
.month { scroll-margin-top: 110px; }
.month h2 { font-size: 20px; margin: 14px 0 10px; color: var(--ink); }
.month h2 small { font-size: 13px; color: var(--muted); margin-left: 8px; font-weight: 500; }
.day { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; margin-bottom: 12px; box-shadow: 0 4px 18px rgba(80, 50, 20, 0.04); scroll-margin-top: 110px; }
.day.photo-only { background: transparent; box-shadow: none; border-style: dashed; }
.day-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.day-head .date { font-size: 18px; font-weight: 700; }
.day-head .date small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.day-head .age { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.badge.w { background: var(--coral-soft); color: var(--coral-deep); }
.badge.c-呼吸 { background: var(--sky-soft); color: #4b79a1; }
.badge.c-栄養 { background: var(--sun-soft); color: #9a6f12; }
.badge.c-治療 { background: #f1e6f5; color: #7d5a93; }
.badge.c-家族 { background: var(--sage-soft); color: #4f7a58; }
.day p { margin: 4px 0; }
.day .extra { color: var(--muted); font-size: 14px; border-left: 3px solid var(--line); padding-left: 10px; }
.day .photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.day .photos .ph { width: 92px; height: 92px; border-radius: 10px; overflow: hidden; background: #eee; cursor: pointer; }
.day .photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.day .photos .more { width: 92px; height: 92px; border-radius: 10px; background: var(--coral-soft); color: var(--coral-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; }

/* ---------- chart ---------- */
.chart-wrap { overflow-x: auto; }
svg.chart { width: 100%; height: auto; display: block; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--coral); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#g); }
.chart .dot { fill: #fff; stroke: var(--coral); stroke-width: 2.5; }
.chart .dot.hi { fill: var(--coral); }
.chart .lbl { font-size: 11px; fill: var(--ink); font-weight: 700; }
.chart .ms { stroke: var(--sage); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .ms-t { font-size: 10px; fill: #4f7a58; }
.chart .due { stroke: var(--sun); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .dis { stroke: var(--coral-deep); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .dot.ph { stroke-dasharray: 2 2; }
.chart .dot.hi.ph { fill: #fff; }
.badge.ph { background: #efe9e2; color: #7a6a5a; }
table.w { width: 100%; border-collapse: collapse; font-size: 14px; }
table.w th, table.w td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.w th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.w td:first-child, table.w th:first-child, table.w td:nth-child(2), table.w th:nth-child(2) { text-align: left; }
table.w .up { color: #4f7a58; }
table.w .down { color: var(--coral-deep); }
.measure { display: flex; gap: 14px; flex-wrap: wrap; }
.measure div { background: var(--sun-soft); border-radius: 12px; padding: 10px 14px; }
.measure b { font-size: 20px; display: block; }

/* ---------- milestones ---------- */
.tl { position: relative; padding-left: 34px; }
.tl::before { content: ''; position: absolute; left: 13px; top: 8px; bottom: 8px; width: 3px; background: var(--line); border-radius: 2px; }
.tl .item { position: relative; margin-bottom: 16px; }
.tl .ic { position: absolute; left: -34px; top: 0; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid var(--coral); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.tl .item .d { color: var(--muted); font-size: 13px; }
.tl .item .t { font-size: 16px; font-weight: 700; }
.tl .item .photos { display: flex; gap: 6px; margin-top: 6px; }
.tl .item .photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* ---------- album ---------- */
.album-month h2 { font-size: 18px; margin: 10px 0 8px; }
.album-month h2 small { color: var(--muted); font-size: 13px; margin-left: 8px; font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; cursor: pointer; }
.grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .ph .d { position: absolute; left: 6px; bottom: 5px; font-size: 11px; color: #fff; background: rgba(0,0,0,0.45); border-radius: 6px; padding: 1px 6px; }
.grid .ph .est { position: absolute; right: 6px; top: 5px; font-size: 10px; color: #fff; background: rgba(0,0,0,0.4); border-radius: 6px; padding: 1px 5px; }
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.videos video { width: 100%; border-radius: 12px; background: #000; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(20, 12, 8, 0.94); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lb-stage { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; padding: 48px 12px 8px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
.lb-cap { color: #fff; padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); text-align: center; max-width: 720px; font-size: 14px; }
.lb-cap b { display: block; font-size: 16px; }
.lb-cap .txt { color: #ddd; font-size: 13px; }
.lb-close { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,0.15); color: #fff; font-size: 20px; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: none; background: rgba(255,255,255,0.12); color: #fff; font-size: 34px; cursor: pointer; border-radius: 10px; }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; font-size: 15px; }

@media (max-width: 640px) {
  .top { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 17px; }
  .tabs { margin-left: 0; width: 100%; }
  .tab { padding: 6px 12px 9px; font-size: 14px; }
  main { padding: 12px 12px 60px; }
  .hero img { height: 300px; }
  .hero .text h1 { font-size: 24px; }
  .stat .val { font-size: 24px; }
  .monthnav { top: 92px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .lb-nav { width: 40px; height: 56px; font-size: 28px; }
  .card { padding: 14px 16px; }
}
