/* ゼロカロ日記：理科の方眼ノート。紺のインク、赤いはんこ、黄色の蛍光ペン */
:root {
  --grid-bg: #F4F9EE;
  --grid-line: rgba(31, 42, 68, 0.07);
  --ink: #1F2A44;
  --ink-soft: #5A6680;
  --ink-faint: #8A93A8;
  --red: #E8473B;
  --red-deep: #B8322A;
  --marker: #FFE45C;
  --card: #FFFFFF;
  --line: rgba(31, 42, 68, 0.14);
  --tabs-h: 64px;
  --display: 'Mochiy Pop One', 'Zen Maru Gothic', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--grid-bg); touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink);
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif; font-weight: 500; line-height: 1.7;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--grid-bg);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 8px; }
svg { display: block; }
a { color: var(--ink); }
#app { max-width: 480px; margin: 0 auto; }
#screen { padding: calc(8px + env(safe-area-inset-top)) 14px 24px; }
.loading { text-align: center; color: var(--ink-soft); padding: 40vh 0; }

/* ===== 今日 ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px; }
.logo { margin: 0; font-family: var(--display); font-size: 20px; letter-spacing: 0.04em; }
.logo::first-letter { color: var(--red); }
.aboutLink { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); text-decoration: none; font-weight: 900; }

.hero { position: relative; display: grid; grid-template-columns: 1fr 128px; align-items: end; margin-top: 6px; padding: 16px 12px 0 18px; border-radius: 22px; background: var(--card); border: 2.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); overflow: hidden; }
.heroText { padding-bottom: 16px; }
.heroDate { margin: 0; font-size: 13px; color: var(--ink-soft); font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.titleChip { padding: 0 8px; border-radius: 6px; background: var(--marker); color: var(--ink); font-size: 11px; }
.heroLabel { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.heroZero { margin: -6px 0 0; font-family: var(--display); font-size: 26px; line-height: 1; color: var(--red); display: flex; align-items: baseline; gap: 4px; }
.heroZero span { font-size: 96px; line-height: 1.05; text-shadow: 3px 3px 0 rgba(232, 71, 59, 0.18); }
.heroReal { margin: 4px 0 0; font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.heroReal s { text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.heroHakase .hakase { width: 128px; margin-bottom: -4px; }

.eatForm { margin-top: 18px; }
.eatLabel { display: inline-block; font-family: var(--display); font-size: 17px; margin: 0 0 6px 2px; background: linear-gradient(transparent 58%, var(--marker) 58%); padding: 0 4px; }
.eatRow { display: flex; gap: 8px; }
#eat { flex: 1; min-width: 0; height: 54px; padding: 0 14px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; font-size: 17px; font-weight: 700; }
#eat::placeholder { color: #B3BACB; font-weight: 500; }
.zeroBtn { flex: none; height: 54px; padding: 0 16px; border-radius: 14px; background: var(--red); color: #fff; font-family: var(--display); font-size: 16px; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.zeroBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; }
.listChip { border-color: var(--ink); }

.todayList { margin-top: 22px; }
.listHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.listHead h2 { margin: 0; font-size: 16px; }
.shareBtn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; }
.shareBtn svg { width: 16px; height: 16px; }
.entry { position: relative; margin-bottom: 12px; padding: 12px 14px 14px; border-radius: 16px; background: #fff; border: 2px solid var(--line); border-left: 6px solid var(--k); animation: rise 0.35s backwards; animation-delay: var(--d); }
.eHead { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding-right: 26px; }
.eTime { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.eName { margin: 0; font-size: 16px; line-height: 1.4; }
.eKcal { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.eKcal s { font-size: 12px; color: var(--ink-faint); text-decoration-color: var(--red); }
.eKcal b { font-family: var(--display); font-weight: 400; color: var(--red); font-size: 16px; }
.eLaw { margin: 6px 0 0; font-weight: 900; color: var(--k); display: flex; align-items: center; gap: 6px; }
.kindDot { width: 10px; height: 10px; border-radius: 50%; background: var(--k); flex: none; }
.eTheory { margin: 2px 0 0; font-size: 14px; line-height: 1.75; }
.eDel { position: absolute; top: 10px; right: 8px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--ink-faint); border-radius: 8px; }
.eDel svg { width: 18px; height: 18px; }
.daySheet .eDel { display: none; }
.empty { text-align: center; color: var(--ink-soft); padding: 18px 12px; }
.empty p { margin: 0; }

@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

/* ===== 下のタブ ===== */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.94); border-top: 2px solid var(--ink); backdrop-filter: blur(8px); }
.tab { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border-radius: 10px; color: var(--ink-faint); font-size: 11px; font-weight: 700; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--red); }

/* ===== 演出（食べた物をゼロにする） ===== */
#layer { position: relative; z-index: 40; }
.stageFull { position: fixed; inset: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: calc(24px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom)); background: linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px, linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 22px 22px, #FBFDF7; opacity: 0; transition: opacity 0.25s; }
.stageFull.open { opacity: 1; }
.stageFull.shake .lab { animation: shake 0.4s; }
@keyframes shake { 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }
.lab { position: relative; width: 100%; max-width: 420px; margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.labFood { margin: 0; font-family: var(--display); font-size: 24px; line-height: 1.35; padding: 0 6px; background: linear-gradient(transparent 60%, var(--marker) 60%); }
.labItems { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }
.meter { margin: 8px 0 0; font-family: var(--display); display: flex; align-items: baseline; gap: 4px; color: var(--ink); }
.meter b { font-weight: 400; font-size: 64px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.meter span { font-size: 22px; }
.meter.zero { color: var(--red); animation: pop 0.4s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pop { from { transform: scale(1.4); } }
.labHakase .hakase { width: 150px; }
.labHakase.thinking { animation: think 0.9s ease-in-out infinite alternate; }
@keyframes think { from { transform: rotate(-4deg); } to { transform: rotate(4deg) translateY(-4px); } }
.labMsg { margin: 6px 0 0; font-weight: 700; color: var(--ink-soft); }
.dots i { font-style: normal; animation: dot 0.9s infinite; opacity: 0.2; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { opacity: 1; } }
.lawBox { width: 100%; margin-top: 6px; padding: 14px 16px; border-radius: 18px; background: #fff; border: 2.5px solid var(--ink); box-shadow: 4px 4px 0 var(--k, var(--ink)); text-align: left; animation: rise 0.35s; }
.lawKind { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.newTag { margin-left: auto; padding: 0 8px; border-radius: 6px; background: var(--marker); color: var(--ink); font-size: 11px; font-weight: 900; }
.lawName { margin: 2px 0 0; font-family: var(--display); font-size: 20px; line-height: 1.35; color: var(--k, var(--ink)); }
.theory { margin: 6px 0 0; font-size: 16px; font-weight: 700; line-height: 1.8; min-height: 1.8em; text-align: left; }
.labNote { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
.stampWrap { height: 0; position: relative; width: 100%; }
.stamp { position: absolute; left: 50%; top: -92px; width: 200px; margin-left: -40px; pointer-events: none; animation: stamp 0.42s cubic-bezier(.3, 1.6, .5, 1) backwards; mix-blend-mode: multiply; }
@keyframes stamp { 0% { transform: scale(2.6) rotate(10deg); opacity: 0; } 60% { opacity: 1; } }
.nextBtn { margin-top: 22px; min-width: 200px; min-height: 52px; padding: 0 28px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 17px; font-weight: 900; box-shadow: 0 4px 0 #0E1424; animation: rise 0.3s backwards; }
.nextBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0E1424; }

/* ===== シート ===== */
.sheetWrap { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.sheetBg { position: absolute; inset: 0; background: rgba(31, 42, 68, 0.45); opacity: 0; transition: opacity 0.25s; }
.sheet { position: relative; width: 100%; max-width: 480px; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 0; border-radius: 22px 22px 0 0; background: #FBFDF7; border-top: 2.5px solid var(--ink); transform: translateY(102%); transition: transform 0.28s cubic-bezier(.2, .9, .3, 1); }
.sheetWrap.open .sheetBg { opacity: 1; }
.sheetWrap.open .sheet { transform: none; }
.sheet > :last-child:not(.sheetBtns) { margin-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sheetTitle { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.sheetDesc { margin: 6px 0 12px; font-size: 14px; color: var(--ink-soft); }
.sheetBtns { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; margin: 12px -16px 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(251, 253, 247, 0), #FBFDF7 14px); }
.sheetBtns > button, .btnLike { flex: 1; min-height: 50px; border-radius: 14px; font-size: 16px; font-weight: 900; display: grid; place-items: center; text-decoration: none; }
.primary { background: var(--ink); color: #fff; }
.ghost { background: #fff; border: 2px solid var(--line); color: var(--ink-soft); }
.danger { background: var(--red); color: #fff; }
.searchRow { display: flex; align-items: center; gap: 8px; margin: 10px 0; padding: 0 12px; height: 46px; border-radius: 12px; background: #fff; border: 2px solid var(--ink); }
.searchRow svg { width: 20px; height: 20px; color: var(--ink-soft); }
.searchRow input { flex: 1; border: 0; outline: 0; background: none; font-size: 16px; }
.fGroup h3 { margin: 12px 0 6px; font-size: 14px; color: var(--ink-soft); }
.fItems { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fItem { display: flex; flex-direction: column; align-items: flex-start; padding: 8px 10px; border-radius: 12px; background: #fff; border: 2px solid var(--line); text-align: left; line-height: 1.35; }
.fItem span { font-size: 14px; font-weight: 700; }
.fItem small { font-size: 11px; color: var(--ink-faint); }
.fItem:active { border-color: var(--red); }
.cardPreview { width: 100%; border-radius: 12px; border: 2px solid var(--line); }

/* ===== 記録 ===== */
.pageHead { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 12px; }
.pageHead h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; }
.pageHead p { margin: 0; color: var(--ink-soft); }
.pageHead p b { color: var(--red); font-size: 20px; }
.pageNote { margin: 0 2px 10px; font-size: 13px; color: var(--ink-soft); }
.bigTotal { padding: 16px 18px; border-radius: 22px; background: var(--red); color: #fff; border: 2.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); }
.btLabel { margin: 0; font-size: 13px; font-weight: 700; opacity: 0.9; }
.btNum { margin: 0; font-family: var(--display); font-size: 48px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.btNum small { font-size: 18px; margin-left: 4px; }
.units { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.units span { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 10px; background: rgba(255, 255, 255, 0.16); font-size: 11px; line-height: 1.3; }
.units b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.units small { font-size: 10px; opacity: 0.9; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.facts p { margin: 0; display: flex; flex-direction: column; padding: 10px; border-radius: 14px; background: #fff; border: 2px solid var(--line); }
.facts span { font-size: 11px; color: var(--ink-soft); line-height: 1.4; }
.facts b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.facts small { font-size: 11px; margin-left: 2px; }
.cal { margin-top: 16px; padding: 12px; border-radius: 18px; background: #fff; border: 2px solid var(--line); }
.calHead { display: flex; justify-content: space-between; align-items: center; }
.calHead h2 { margin: 0; font-size: 16px; }
.calNav { width: 40px; height: 40px; border-radius: 10px; font-size: 24px; font-weight: 900; }
.week, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.week span { text-align: center; font-size: 11px; color: var(--ink-faint); }
.cell { aspect-ratio: 1 / 1.15; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 3px; border-radius: 8px; font-size: 11px; color: var(--ink-faint); }
.cell.blank { visibility: hidden; }
.cell.today { outline: 2px solid var(--ink); }
.cell.has { background: #FFF1EE; color: var(--ink); }
.cd { line-height: 1.2; }
.cz { font-family: var(--display); color: var(--red); font-size: 17px; line-height: 1.1; }
.cr { font-size: 9px; color: var(--ink-faint); line-height: 1.1; }
.calNote { margin: 8px 0 0; font-size: 11px; color: var(--ink-faint); }

/* ===== 図鑑 ===== */
.seg { display: flex; gap: 4px; margin: 0 0 14px; padding: 4px; border-radius: 12px; background: #fff; border: 2px solid var(--line); }
.seg button { flex: 1; min-height: 38px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.seg button.on { background: var(--ink); color: #fff; }
.kindSec { margin-bottom: 16px; }
.kindSec h2 { display: flex; align-items: center; gap: 6px; margin: 0 2px 8px; font-size: 15px; }
.kindSec h2 small { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
.lawGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lawCard { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; background: #fff; border: 2px solid var(--line); border-top: 5px solid var(--k); text-align: left; line-height: 1.4; }
.lawCard b { font-size: 14px; color: var(--k); }
.lawCard small { font-size: 11px; color: var(--ink-faint); }
.kindEmpty { margin: 0 2px; padding: 12px; border-radius: 12px; border: 2px dashed var(--line); color: var(--ink-faint); font-size: 13px; text-align: center; }
.lawDetail .lawName { font-size: 22px; }
.lawMeta { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); }
.titleGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tiCard { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 14px; background: #fff; border: 2px dashed var(--line); text-align: left; color: var(--ink-faint); }
.tiCard b { font-size: 14px; }
.tiCard small { font-size: 11px; }
.tiCard.has { border-style: solid; color: var(--ink); }
.tiCard.has b { background: linear-gradient(transparent 60%, var(--marker) 60%); align-self: flex-start; }
.tiCard.on { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }

/* ===== お知らせ ===== */
#toast { position: fixed; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toastItem { display: flex; align-items: center; gap: 8px; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 14px; background: #fff; border: 2.5px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-size: 14px; font-weight: 700; animation: drop 0.35s cubic-bezier(.2, 1.4, .4, 1); transition: opacity 0.4s, transform 0.4s; }
.toastItem.out { opacity: 0; transform: translateY(-10px); }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }
.tTag { flex: none; padding: 1px 8px; border-radius: 6px; background: var(--red); color: #fff; font-size: 11px; font-weight: 900; }

/* ===== はじめて開いたとき ===== */
.intro { margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 420px; }
.introLogo { margin: 0; font-family: var(--display); font-size: 40px; line-height: 1.2; }
.introLogo::first-letter { color: var(--red); }
.introLead { margin: 6px 0 0; font-weight: 700; color: var(--ink-soft); }
.introHakase .hakase { width: 190px; margin-top: 14px; animation: pop 0.45s cubic-bezier(.2, 1.6, .4, 1); }
.introTalk { margin: 12px 0 0; padding: 14px 16px; border-radius: 16px; background: #fff; border: 2.5px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-weight: 700; text-align: left; animation: rise 0.3s backwards; }

/* ===== このアプリについて（about.html） ===== */
body.aboutPage { padding-bottom: 0; }
.aboutMain { max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }
.aboutMain h1 { margin: 14px 0 6px; font-family: var(--display); font-weight: 400; font-size: 26px; }
.aboutMain h2 { margin: 24px 0 6px; font-size: 17px; background: linear-gradient(transparent 60%, var(--marker) 60%); display: inline-block; }
.aboutMain ul { margin: 0; padding-left: 1.2em; }
.aboutMain li, .aboutMain p { margin: 6px 0; }
.backLink { font-weight: 700; text-decoration: none; }
.aboutLinks { display: flex; flex-direction: column; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.listSheet { height: calc(100dvh - 24px - env(safe-area-inset-top)); }
