/* PFCかんたん計算ツール
   見た目のテーマは「方眼ノートに紺のペンでつける食事ノート」。
   - 紙は方眼、文字と線は紺のインク、できたことには朱のはんこ。
   - 栄養の色は「三色食品群」から：たんぱく質＝赤、炭水化物＝黄。脂質は三色に無いので、
     赤・黄と色覚の違いがあっても見分けやすい青（dataviz の validate_palette.js で明・暗とも確認済み）。
   - 見出し・大きな数字・はんこは手書き風の教科書体 Klee One（OFL、使う文字だけに絞って fonts/ に同梱）。
   スマホは1列＋下のタブ、パソコン（900px〜）は上のタブ＋2列。 */

@font-face {
  font-family: "Klee One";
  src: url("fonts/KleeOne-SemiBold-subset.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --hand: "Klee One", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --bg: #f6f8fa;          /* 方眼ノートの紙 */
  --grid: #e3e9ef;        /* 方眼の線 */
  --surface: #ffffff;
  --surface-2: #edf1f5;
  --ink: #1f2b47;         /* 紺のインク */
  --ink-2: #3e4a66;
  --muted: #5f6b84;
  --line: #c9d2dd;
  --brand: #26386b;
  --brand-strong: #1a2850;
  --brand-soft: #e2e8f3;
  --on-brand: #ffffff;
  --shu: #c9372c;         /* はんこの朱 */
  --marker: rgba(227, 167, 15, 0.32);  /* 蛍光ペン（炭水化物の黄を薄く） */
  --note: #fff1b8;        /* 付箋 */
  --p: #d6404e;
  --f: #2f6fb5;
  --c: #e3a70f;
  --target: #1f2b47;
  --radius: 10px;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141a26;
    --grid: #1c2432;
    --surface: #1a2130;
    --surface-2: #232c3d;
    --ink: #e8ecf4;
    --ink-2: #c3cbda;
    --muted: #97a2b7;
    --line: #333e54;
    --brand: #9db8f2;
    --brand-strong: #bccff7;
    --brand-soft: #243250;
    --on-brand: #10182a;
    --shu: #e5604f;
    --marker: rgba(184, 138, 16, 0.38);
    --note: #4a3f14;
    --p: #d8505d;
    --f: #4f86cc;
    --c: #b88a10;
    --target: #e8ecf4;
  }
}

/* 手書き風フォント（Klee One）は日本語の文字だけに絞ってあり、簡体字が入っていない。中国語のときは端末のゴシックにする */
:lang(zh-Hans) {
  --hand: "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  /* 5mm 方眼（24px ごとの細い線） */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.65;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

a { color: var(--brand); }

/* ---------- ヘッダーとタブ ---------- */
.header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.brand {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.dot-p { background: var(--p); }
.dot-f { background: var(--f); }
.dot-c { background: var(--c); }

.today-label { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* 言語の切り替え（日本語・English・中文）。紺の枠線で、いまの言語だけ蛍光ペンを引く */
.lang-switch { display: inline-flex; }
.lang-switch button {
  margin: 0 0 0 -1.5px;
  padding: 2px 9px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  cursor: pointer;
}
.lang-switch button:first-child { margin-left: 0; border-radius: 6px 0 0 6px; }
.lang-switch button:last-child { border-radius: 0 6px 6px 0; }
.lang-switch button[aria-pressed="true"] { background: var(--marker); font-weight: 700; }
.lang-switch button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; position: relative; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1.5px solid var(--ink);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.tab {
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--hand);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
}

/* 今のタブは、蛍光ペンを引いたように */
.tab[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--marker);
  text-decoration-thickness: 0.5em;
  text-underline-offset: -0.28em;
  text-decoration-skip-ink: none;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.panel { display: grid; gap: 16px; align-items: start; }
.panel[hidden] { display: none; }

/* ---------- 区切り ----------
   ふだんの区切りは、方眼の紙にそのまま書く（枠なし）。
   今日のお皿と「食品を追加」だけは、ノートに貼った白い紙（.sheet）にする。 */
.card { min-width: 0; padding: 4px 2px 8px; }
.sheet {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 20px 18px;
}

.card h2 {
  display: inline;
  margin: 0;
  font-family: var(--hand);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.5;
  background: linear-gradient(transparent 60%, var(--marker) 60%);
}
.card > h2 + * { margin-top: 14px; }

.subhead { margin: 28px 0 10px; font-family: var(--hand); font-size: 1.08rem; font-weight: 600; }

/* Pro の印：朱の角はん */
.tag {
  display: inline-block;
  border: 1.5px solid var(--shu);
  color: var(--shu);
  border-radius: 3px;
  padding: 0 6px;
  font-family: var(--hand);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: 3px;
  transform: rotate(-4deg);
}

.note { font-size: 0.84rem; color: var(--muted); margin: 12px 0 0; }
.empty { color: var(--muted); font-size: 0.92rem; }
/* 隠す指定は、あとに書いた display の指定より常に勝たせる */
.hidden { display: none !important; }

/* ---------- はじめに（付箋に書いた注意書き） ---------- */
.notice { background: var(--note); padding: 18px 18px 16px; border-radius: 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
.notice h2 { background: none; }
.notice-list { margin: 12px 0 0; padding-left: 1.2em; font-size: 0.92rem; color: var(--ink); }
.notice-list li { margin-bottom: 8px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- 今日のお皿 ---------- */
/* 右上にマスキングテープを1枚 */
.hero::before {
  content: "";
  position: absolute;
  top: -11px;
  right: 28px;
  width: 92px;
  height: 22px;
  background: var(--marker);
  transform: rotate(4deg);
}
.hero-title { margin: 0; }
.hero-grid { display: grid; gap: 16px; margin-top: 12px; align-items: center; }
.plate-fig { margin: 0 auto; width: 100%; max-width: 236px; }
.plate-svg { display: block; width: 100%; height: auto; }
.plate-svg circle { fill: none; transition: stroke-dasharray 0.45s ease, stroke-dashoffset 0.45s ease; }
.rim-track { stroke: var(--surface-2); stroke-width: 10; }
.rim { stroke: var(--ink); stroke-width: 10; stroke-linecap: round; }
.rim-over { stroke: var(--shu); stroke-width: 5; stroke-linecap: round; }
.plate-svg .dish { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.seg-track { stroke: var(--surface-2); stroke-width: 26; }
.seg { stroke-width: 26; }
.seg-p { stroke: var(--p); }
.seg-f { stroke: var(--f); }
.seg-c { stroke: var(--c); }
.plate-kcal { font-family: var(--hand); font-weight: 600; font-size: 30px; fill: var(--ink); }
.plate-unit { font-size: 13px; fill: var(--muted); }
.plate-legend { display: flex; justify-content: center; gap: 14px; margin-top: 6px; font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.share { display: inline-flex; align-items: center; gap: 5px; }

.hero-remaining { margin: 0; font-family: var(--hand); font-size: 1.7rem; font-weight: 600; line-height: 1.3; color: var(--ink); }
.hero-remaining.is-over { color: var(--shu); }
.hero-target { margin: 2px 0 14px; color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }

@media (min-width: 480px) {
  .hero-grid { grid-template-columns: minmax(170px, 220px) 1fr; gap: 22px; }
}

/* 食品のパッケージにある「栄養成分表示」の形 */
.nf { border: 1.5px solid var(--ink); padding: 0 12px 4px; background: var(--surface); font-variant-numeric: tabular-nums; }
.nf-head { margin: 0; padding: 6px 0; border-bottom: 1.5px solid var(--ink); font-weight: 800; font-size: 0.95rem; }
.nf-head small { margin-left: 8px; font-weight: 600; color: var(--muted); font-size: 0.78rem; }
.nf-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 8px; padding: 7px 0 6px; border-bottom: 1px solid var(--line); }
.nf-row:last-child { border-bottom: none; }
.nf-name { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 700; }
.nf-value { text-align: right; font-weight: 800; font-size: 1.02rem; }
.nf-value small { margin-left: 6px; font-weight: 600; font-size: 0.76rem; color: var(--muted); }
.nf-row .bar { grid-column: 1 / -1; margin: 5px 0 0; }

.key { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.macro-p .key, .key-p { background: var(--p); }
.macro-f .key, .key-f { background: var(--f); }
.macro-c .key, .key-c { background: var(--c); }
.key-target { width: 14px; height: 0; border-top: 2px dashed var(--target); border-radius: 0; }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.bar-fill { height: 100%; width: 0; border-radius: 3px; background: var(--ink); transition: width 0.35s ease; }
.macro-p .bar-fill { background: var(--p); }
.macro-f .bar-fill { background: var(--f); }
.macro-c .bar-fill { background: var(--c); }

/* 目標を超えたら、色だけに頼らず斜線でも分かるようにする */
.bar-fill.over {
  background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.28) 0 3px, transparent 3px 7px);
}

/* ---------- フォーム ---------- */
label { display: block; margin: 12px 0 4px; font-size: 0.86rem; font-weight: 700; color: var(--ink-2); }
label:first-child { margin-top: 0; }

select, input[type="number"], input[type="text"], input[type="search"], input[type="date"] {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
  min-height: 46px;
}

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
select:focus, input:focus { outline: 3px solid var(--brand); outline-offset: 0; border-color: transparent; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span-2 { grid-column: span 2; }

.btn-primary, .btn-secondary {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  min-height: 48px;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--ink); }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; min-width: 0; }
.btn-inline { width: auto; margin-top: 0; padding: 10px 16px; flex-shrink: 0; }

.check-label { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 0.9rem; font-weight: 600; }
.file-label { display: block; margin-top: 16px; }
#backup-import { margin-top: 8px; max-width: 100%; }

/* ---------- 最近食べたもの ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  min-height: 40px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.chip:hover { border-color: var(--brand); }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14em; }
.chip-grams { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.pro-callout { padding: 12px 14px; background: var(--surface); border: 1.5px dashed var(--line); color: var(--ink-2); border-radius: 6px; margin-top: 28px; }

/* ---------- 一覧 ---------- */
.entries { list-style: none; margin: 0; padding: 0; }

.entries li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}

.entries li:last-child { border-bottom: none; }
.entries li > div { min-width: 0; }
.entry-name { font-weight: 700; overflow-wrap: anywhere; }
.entry-detail { font-size: 0.83rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.entry-delete, .entry-add {
  flex-shrink: 0;
  border-radius: 8px;
  padding: 6px 12px;
  min-height: 36px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.entry-delete { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.entry-add { border: none; background: var(--brand); color: var(--on-brand); }

/* ---------- 14日グラフ（PFC の積み上げ） ---------- */
.chart-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 200px;
  border-bottom: 1px solid var(--line);
}

.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; }

.chart-bar {
  width: 72%;
  max-width: 28px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.chart-bar span { display: block; width: 100%; }
.chart-col:hover .chart-bar, .chart-col.is-active .chart-bar { outline: 2px solid var(--ink); outline-offset: 1px; }
.chart-bar.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }

.chart-target-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--target);
  pointer-events: none;
}

.chart-labels { display: flex; gap: 2px; margin-top: 6px; }
/* 日付は5日おき。幅の狭い列からはみ出しても読めるよう、はみ出しを許す */
.chart-labels span { flex: 1; min-width: 0; text-align: center; font-size: 0.66rem; color: var(--muted); white-space: nowrap; overflow: visible; display: flex; justify-content: center; }
/* 右端（今日）は、はみ出さないよう右にそろえる */
.chart-labels span:last-child { justify-content: flex-end; color: var(--ink); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 0.8rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.chart-tip {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- からだの記録 ---------- */
.weight-chart { margin-top: 8px; }
.weight-svg { width: 100%; height: auto; display: block; }

.plan-result { margin-top: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.plan-result:empty { display: none; }
.plan-row { margin: 4px 0; font-size: 0.9rem; }

.volume-list { display: grid; gap: 8px; }
.volume-row { display: grid; grid-template-columns: 3em 1fr 4.5em; align-items: center; gap: 10px; font-size: 0.9rem; }
.volume-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.volume-bar { display: block; height: 100%; background: color-mix(in srgb, var(--brand) 45%, transparent); }
.volume-bar.enough { background: var(--brand); }
.volume-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- スコア ---------- */
.score-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.score-big { font-family: var(--hand); font-size: 3rem; font-weight: 600; letter-spacing: -0.03em; color: var(--brand-strong); font-variant-numeric: tabular-nums; line-height: 1; }
.score-unit { font-size: 0.9rem; font-weight: 700; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.score-side { font-size: 0.9rem; text-align: right; color: var(--ink-2); }
.score-side strong { font-size: 1.2rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.score-items { list-style: none; padding: 0; margin: 14px 0 0; font-size: 0.9rem; color: var(--muted); }
.score-items li { padding: 3px 0; }
.score-items li.got { color: var(--ink); font-weight: 700; }

/* ---------- Pro ---------- */
.pro { }
.pro-features { margin: 0 0 12px; padding-left: 20px; }
.pro-features li { margin-bottom: 4px; }

.buy {
  margin: 16px 0;
  padding: 18px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
}

.price { margin: 0 0 12px; }
.price strong { font-family: var(--hand); font-size: 2rem; font-weight: 600; color: var(--ink); }
.price-sub { display: block; font-size: 0.8rem; color: var(--muted); }
.btn-buy { display: block; margin-top: 0; text-align: center; text-decoration: none; }
#license-key { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.8rem; }

.legal dt { font-weight: 700; margin-top: 12px; }
.legal dd { margin: 4px 0 0; }

/* ---------- フッター ---------- */
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px 32px;
  font-size: 0.84rem;
  color: var(--muted);
}

.footer nav { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer a { font-weight: 700; }
.kindle-note { margin: 12px 0 0; }
.credit { margin: 16px 0 0; font-size: 0.8rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- パソコン：上のタブ・2列 ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }

  .header { padding-top: 28px; }
  .brand { font-size: 1.3rem; }

  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    max-width: 1120px;
    margin: 12px auto 0;
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: var(--bg);
    border-top: none;
    border-bottom: 1.5px solid var(--ink);
  }

  .tab { padding: 8px 18px; font-size: 1.05rem; }

  main { padding-top: 20px; }

  .panel { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px 36px; }
  .panel > .card:only-child, .panel[data-panel="body"] > .card { grid-column: 1 / -1; }
  .panel[data-panel="body"] > .card { justify-self: center; width: 100%; max-width: 860px; }
  /* 今日のタブ：左に合計・食べたもの・スコア、右に「食品を追加」を固定して並べる */
  .panel[data-panel="today"] > .card { grid-column: 1; }
  .panel[data-panel="today"] > .card-add {
    grid-column: 2;
    grid-row: 1 / span 3;
    position: sticky;
    top: 72px;
  }

  .form-row { grid-template-columns: repeat(4, 1fr); }
  .chart-plot { height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 種目欄の見出しと「種目を探す」リンクを横に並べる */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row label { margin-top: 0; }
.find-link { font-size: 0.82rem; font-weight: 700; color: var(--brand); }

/* ---------- 今日のスタンプ・連続記録・はんこ ---------- */
.checkin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.streak { margin: 0; font-family: var(--hand); font-size: 0.95rem; font-weight: 600; color: var(--muted); }
.streak.is-on { color: var(--ink); }
.streak strong { font-size: 1.5rem; font-weight: 600; margin-right: 2px; font-variant-numeric: tabular-nums; }

.checks { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 12px; }
.check {
  padding: 5px 12px;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  font-size: 0.92rem;
  color: var(--muted);
  white-space: nowrap;
}
.check-tick { display: none; }
/* できたことは、先生の赤ペンのように朱で丸をつける（形を少しずつ崩して手描きに見せる） */
.check.done {
  border: 2px solid var(--shu);
  border-radius: 52% 48% 55% 45% / 58% 46% 54% 42%;
  color: var(--ink);
  font-weight: 700;
}
.check.done:nth-child(odd) { transform: rotate(-2deg); }
.check.done:nth-child(even) { transform: rotate(1.5deg); }
.check-next-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.check-next { margin: 0; flex: 1; font-size: 0.95rem; color: var(--ink); }

/* 目標を満たした瞬間に押す「よくできました」のはんこ */
.celebrate { display: flex; align-items: center; gap: 16px; margin-top: 16px; padding-left: 6px; }
.hanko {
  flex-shrink: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 3px solid var(--shu);
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4.5px var(--shu);
  color: var(--shu);
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(-12deg);
  animation: stamp 520ms cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
.celebrate-title { margin: 0; font-family: var(--hand); font-size: 1.2rem; font-weight: 600; }
.celebrate-sub { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink-2); }
@keyframes stamp {
  0% { opacity: 0; transform: rotate(-4deg) scale(1.7); }
  60% { opacity: 1; transform: rotate(-12deg) scale(0.94); }
  100% { transform: rotate(-12deg) scale(1); }
}

/* ---------- 週のふり返り（スタンプカード） ---------- */
.week-days { list-style: none; margin: 14px 0 10px; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); border: 1.5px solid var(--ink); background: var(--surface); }
.week-day { text-align: center; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; border-left: 1px solid var(--line); padding: 4px 0 6px; }
.week-day:first-child { border-left: none; }
.week-label { display: block; }
.week-day.today .week-label { color: var(--ink); font-weight: 800; }
/* 目標内＝◎、記録した日＝○、記録なし＝・（朱のペンで書いたように少し傾ける） */
.week-dot { display: block; height: 40px; font-family: var(--hand); font-weight: 600; font-size: 1.9rem; line-height: 40px; color: var(--line); }
.week-dot::after { content: "・"; }
.week-day.logged .week-dot, .week-day.hit .week-dot { color: var(--shu); }
.week-day.logged .week-dot::after { content: "○"; }
.week-day.hit .week-dot::after { content: "◎"; }
.week-day:nth-child(odd) .week-dot { transform: rotate(-6deg); }
.week-day:nth-child(even) .week-dot { transform: rotate(5deg); }
.week-range { margin: 0 0 4px; font-size: 0.84rem; color: var(--muted); }
/* 数字はノートの罫線の上に1行ずつ */
.stat { display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.stat-label { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--ink-2); grid-column: 1; grid-row: 1; }
.stat-value { margin: 0; grid-column: 2; grid-row: 1 / span 3; font-family: var(--hand); font-size: 1.6rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; text-align: right; }
.stat-value small { font-family: inherit; font-size: 0.85rem; color: var(--ink-2); margin-left: 3px; }
.stat-delta { margin: 0; grid-column: 1; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- お知らせ（付箋） ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%) rotate(-1.5deg); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 2px;
  background: var(--note); color: var(--ink); font-family: var(--hand); font-size: 1rem; font-weight: 600;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
}
@media (min-width: 900px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  .hanko { animation: none; }
}

/* ---------- 使い方ガイド（4つの手順） ----------
   ノートの上に、鉛筆の点線でつないだ4つの駅を描く。できた駅は朱の丸、次の駅は蛍光ペン。 */
.guide-open {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  margin-left: auto;
}
.guide-open:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.guide-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.guide-close {
  font: inherit; font-size: 0.85rem; color: var(--muted); background: none; border: none;
  text-decoration: underline; cursor: pointer; padding: 4px;
}
.guide-steps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  position: relative;
}
/* 駅と駅をつなぐ鉛筆の点線（丸の中心の高さ） */
.guide-steps::before {
  content: "";
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  top: 27px;
  border-top: 2px dashed var(--line);
}
.guide-step button {
  font: inherit;
  color: var(--ink);
  background: none;
  border: none;
  width: 100%;
  padding: 0 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
}
.guide-step button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.guide-step svg {
  width: 54px;
  height: 54px;
  padding: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--line);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
}
.guide-step svg .fill { fill: currentColor; stroke: none; }
.guide-num {
  position: absolute;
  top: -4px;
  left: calc(50% - 36px);
  z-index: 1;
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1rem;
  color: var(--muted);
}
.guide-name { font-size: 0.82rem; font-weight: 700; line-height: 1.35; text-align: center; color: var(--muted); }
/* 次にやる手順：紺の線と蛍光ペン */
.guide-step.is-next svg { border: 2px solid var(--ink); stroke: var(--ink); color: var(--ink); }
.guide-step.is-next .guide-name { color: var(--ink); background: linear-gradient(transparent 55%, var(--marker) 55%); }
.guide-step.is-next .guide-num { color: var(--ink); }
/* できた手順：先生の赤ペンの丸（形を少し崩す） */
.guide-step.done svg {
  border: 2px solid var(--shu);
  border-radius: 52% 48% 55% 45% / 58% 46% 54% 42%;
  stroke: var(--ink);
  color: var(--ink);
  transform: rotate(-3deg);
}
.guide-step.done .guide-name { color: var(--ink); }
.guide-step.done .guide-num { color: var(--shu); }
.guide-next {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--surface);
  border-left: 3px solid var(--ink);
  font-size: 0.92rem;
  color: var(--ink);
}
@media (min-width: 900px) {
  .panel[data-panel="today"] > .guide { grid-column: 1 / -1; grid-row: 1; }
  .panel[data-panel="today"].has-guide > .card-add { grid-row: 2 / span 3; }
  .guide-name { font-size: 0.92rem; }
}
/* ガイドから移った先を一瞬だけ光らせる（押したことへの返事なので、ここだけ動かす） */
.flash { animation: guide-flash 1.4s ease-out 1; }
@keyframes guide-flash {
  0%, 30% { box-shadow: 0 0 0 4px var(--marker); }
  100% { box-shadow: 0 0 0 4px transparent; }
}
