  /* === base === */
  :root{
    --bg1:#fff4d6; --bg2:#ffe1ec; --card:#ffffff; --ink:#5b4636;
    --pink:#ff7fa8; --pink-d:#ff5a8c; --yellow:#ffc94d; --mint:#7fd6c2;
    --line:#f0d9c0; --shadow:rgba(180,120,90,.25);
  }
  *{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
  html,body{ margin:0; height:100%; }
  /* 文脈タグの既定スタイルを無効化する（當山式・規律5）。
     見出しの大きさは、外側の div の class で決める */
  h1,h2,h3,h4,h5,h6{ font-size:inherit; font-weight:inherit; margin:0; }
  figure{ margin:0; }
  body{
    font-family:-apple-system,BlinkMacSystemFont,"Hiragino Maru Gothic ProN","Hiragino Sans","Yu Gothic UI",sans-serif;
    color:var(--ink); background:linear-gradient(160deg,var(--bg1),var(--bg2));
    min-height:100%; overflow-x:hidden; user-select:none; -webkit-user-select:none;
  }
  .app{ max-width:560px; margin:0 auto; padding:16px 14px max(24px,env(safe-area-inset-bottom)); }
  .small{ font-size:11px; }
  .file_in{ display:none; }

  .app_title{ font-size:26px; font-weight:900; text-align:center; margin:8px 0 16px; text-shadow:0 2px 0 #fff; }

  /* === list === */
  .card_list{ display:flex; flex-direction:column; gap:12px; }
  .list_item{ background:var(--card); border-radius:20px; padding:12px 14px; box-shadow:0 5px 14px var(--shadow);
    display:flex; align-items:center; gap:12px; cursor:pointer; position:relative; transition:transform .12s;
    border-left:7px solid transparent; }
  .list_item:active{ transform:scale(.98); }
  .list_item.done{ background:linear-gradient(135deg,#fff,#fff0f5); border:2px solid var(--pink); }
  .l_thumb{ width:56px; height:56px; flex:0 0 auto; border-radius:14px; background:#fff7ec; border:2px dashed var(--line);
    display:flex; align-items:center; justify-content:center; font-size:26px; overflow:hidden; }
  .l_thumb img{ width:100%; height:100%; object-fit:cover; }
  .l_mid{ flex:1; min-width:0; }
  .l_title{ font-size:17px; font-weight:900; line-height:1.25;
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
  .l_prog{ font-size:13px; font-weight:800; color:var(--pink-d); margin:2px 0 4px; }
  .l_dots{ font-size:14px; letter-spacing:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#cab39c; }
  .l_dots .f{ color:inherit; }
  .l_del{ display:none; position:absolute; top:8px; right:10px; width:32px; height:32px; border:none; border-radius:50%;
    background:#e05a5a; color:#fff; font-size:16px; font-weight:900; cursor:pointer; line-height:1;
    align-items:center; justify-content:center; box-shadow:0 2px 8px rgba(224,90,90,.5); }
  .card_list.delmode .l_del{ display:flex; }
  .card_list.delmode .list_item{ animation:wiggle .4s ease-in-out infinite; }
  @keyframes wiggle{ 0%,100%{transform:rotate(-0.6deg);} 50%{transform:rotate(0.6deg);} }
  .l_del:active{ transform:scale(.9); }
  .del_fab{ position:fixed; right:18px; bottom:max(20px,calc(env(safe-area-inset-bottom) + 8px)); z-index:14;
    min-width:56px; height:56px; padding:0 16px; border:none; border-radius:999px; cursor:pointer;
    background:#fff; color:#e05a5a; font-size:24px; font-weight:900; box-shadow:0 6px 18px var(--shadow); }
  .del_fab.is_on{ background:#e05a5a; color:#fff; font-size:16px; }
  .del_fab:active{ transform:scale(.94); }
  .empty{ text-align:center; color:#b39c87; font-size:14px; padding:40px 10px; line-height:1.9; }
  .add_card{ width:100%; margin-top:16px; border:none; cursor:pointer; background:var(--pink-d); color:#fff;
    font-weight:900; font-size:18px; padding:15px; border-radius:16px; box-shadow:0 6px 16px rgba(255,90,140,.4); }
  .add_card:active{ transform:scale(.97); }

  /* === card detail header === */
  .head_row{ display:flex; align-items:center; gap:8px; margin-bottom:6px; }
  .title{ flex:1; min-width:0; font-size:21px; font-weight:900; line-height:1.2; text-align:center; text-shadow:0 2px 0 #fff;
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
  .icon_btn{ flex:0 0 auto; width:44px; height:44px; border:none; cursor:pointer;
    background:#fff; border-radius:50%; font-size:22px; box-shadow:0 3px 8px var(--shadow); }
  .icon_btn:active{ transform:scale(.92); }

  /* === reward === */
  .reward{ background:var(--card); border-radius:22px; padding:12px; margin:10px 0 14px;
    box-shadow:0 6px 16px var(--shadow); display:flex; align-items:center; gap:14px; }
  .reward_img{ width:74px; height:74px; border-radius:16px; object-fit:cover; background:#fff7ec;
    display:flex; align-items:center; justify-content:center; font-size:38px; border:2px dashed var(--line); flex:0 0 auto; overflow:hidden; cursor:pointer; position:relative; }
  .reward_img.has::after{ content:"🔍"; position:absolute; right:-4px; bottom:-4px; font-size:16px;
    background:#fff; border-radius:50%; width:22px; height:22px; display:flex; align-items:center; justify-content:center; box-shadow:0 2px 5px var(--shadow); }
  .reward_img img{ width:100%; height:100%; object-fit:cover; border-radius:14px; }
  .reward_text{ flex:1; }
  .reward_text .big{ font-size:18px; font-weight:900; }
  .reward_text .sub{ font-size:13px; color:#a8917c; margin-top:2px; }
  .progress{ font-size:13px; font-weight:800; color:var(--pink-d); }

  /* === grid === */
  .grid{ display:grid; grid-template-columns:repeat(5,1fr); gap:10px; }
  .cell{ position:relative; aspect-ratio:1/1; border-radius:50%;
    background:#fff; border:3px solid var(--line); display:flex; align-items:center; justify-content:center;
    font-size:30px; cursor:pointer; box-shadow:inset 0 -3px 8px rgba(0,0,0,.04); transition:transform .12s; }
  .cell .num{ color:#d9c3aa; font-size:16px; font-weight:800; }
  .cell.filled{ background:#fff0f5; border-color:var(--pink); animation:pop .35s cubic-bezier(.2,1.6,.4,1); }
  .cell.filled .num{ display:none; }
  .cell.next{ border-color:var(--yellow); border-style:dashed; animation:breathe 1.1s ease-in-out infinite; }
  .cell.next::after{ content:"ここ！"; position:absolute; bottom:-7px; left:50%; transform:translateX(-50%);
    background:var(--yellow); color:#7a5a10; font-size:10px; font-weight:900; padding:1px 7px; border-radius:8px; white-space:nowrap; }
  .cell:active{ transform:scale(.9); }
  @keyframes pop{ 0%{transform:scale(.3);} 70%{transform:scale(1.15);} 100%{transform:scale(1);} }
  @keyframes breathe{ 0%,100%{transform:scale(1); box-shadow:0 0 0 0 rgba(255,201,77,.5);}
    50%{transform:scale(1.06); box-shadow:0 0 0 7px rgba(255,201,77,0);} }

  .hint{ text-align:center; font-size:12px; color:#b39c87; margin-top:16px; line-height:1.8; }

  /* === celebrate === */
  .cel{ position:fixed; inset:0; z-index:30; display:flex; align-items:center; justify-content:center;
    flex-direction:column; text-align:center; padding:24px;
    background:radial-gradient(120% 120% at 50% 30%, rgba(255,255,255,.92), rgba(255,236,180,.9)); }
  /* ★ canvas は置換要素なので、inset:0 だけでは幅が実寸（canvas.width）のままになり、
     ビューポートより広くなって横にはみ出す。width/height を明示して抑える */
  .cel_canvas{ position:fixed; inset:0; width:100%; height:100%; pointer-events:none; z-index:31; }
  .cel .inner{ position:relative; z-index:32; }
  .cel .star{ font-size:64px; animation:spin 2s linear infinite; }
  .cel h2{ font-size:40px; font-weight:900; color:var(--pink-d); margin:8px 0; text-shadow:0 3px 0 #fff; }
  .cel p{ font-size:18px; font-weight:800; margin:0 0 14px; }
  .cel_reward{ width:140px; height:140px; border-radius:20px; object-fit:cover; box-shadow:0 8px 24px var(--shadow); margin:6px auto 16px; }
  .cel button{ border:none; cursor:pointer; background:var(--pink-d); color:#fff; font-weight:900;
    font-size:18px; padding:14px 40px; border-radius:999px; box-shadow:0 6px 16px rgba(255,90,140,.5); }
  .cel button:active{ transform:scale(.95); }
  @keyframes spin{ from{transform:rotate(0);} to{transform:rotate(360deg);} }

  /* === reward zoom === */
  .reward_zoom{ position:fixed; inset:0; z-index:35; display:flex; align-items:center; justify-content:center;
    flex-direction:column; background:rgba(20,12,8,.88); padding:24px; }
  .reward_zoom img{ max-width:92%; max-height:70%; border-radius:18px; box-shadow:0 12px 40px rgba(0,0,0,.5); object-fit:contain; }
  .reward_zoom .cap{ color:#fff; font-weight:900; font-size:20px; margin-top:18px; text-align:center; }
  .reward_zoom .sub{ color:#ffe6a8; font-size:15px; font-weight:800; margin-top:6px; }
  .reward_zoom .x{ position:absolute; top:max(16px,env(safe-area-inset-top)); right:18px; width:44px; height:44px;
    border:none; border-radius:50%; background:rgba(255,255,255,.22); color:#fff; font-size:22px; font-weight:900; cursor:pointer; }

  /* === settings === */
  .set_wrap{ position:fixed; inset:0; z-index:40; display:flex; align-items:flex-end; justify-content:center; background:rgba(80,50,40,.45); }
  .settings{ width:100%; max-width:560px; background:#fff; border-radius:22px 22px 0 0; padding:20px 18px max(24px,env(safe-area-inset-bottom));
    max-height:88vh; overflow-y:auto; box-shadow:0 -8px 30px rgba(0,0,0,.2); }
  .settings h3{ margin:0 0 14px; font-size:20px; font-weight:900; text-align:center; }
  .field{ margin-bottom:18px; }
  .field label{ display:block; font-size:13px; font-weight:800; color:#9a8270; margin-bottom:7px; }
  .field input[type=text]{ width:100%; font-size:17px; padding:11px 13px; border:2px solid var(--line);
    border-radius:12px; font-family:inherit; color:var(--ink); }
  .count_row{ display:flex; align-items:center; gap:14px; }
  .count_row button{ width:46px; height:46px; border:none; border-radius:12px; background:#ffe1ec; color:var(--pink-d);
    font-size:26px; font-weight:900; cursor:pointer; }
  .count_row button:active{ transform:scale(.92); }
  .count_row .cnt{ font-size:26px; font-weight:900; min-width:46px; text-align:center; }
  .emojis{ display:grid; grid-template-columns:repeat(7,1fr); gap:8px; }
  .emojis button{ aspect-ratio:1/1; font-size:26px; border:2px solid var(--line); background:#fff; border-radius:12px; cursor:pointer; }
  .emojis button.is_sel{ border-color:var(--pink); background:#fff0f5; }
  .swatches{ display:flex; gap:12px; flex-wrap:wrap; }
  .swatches button{ width:46px; height:46px; border-radius:50%; border:3px solid #fff; cursor:pointer; box-shadow:0 2px 6px var(--shadow); transition:transform .1s; }
  .swatches button.is_sel{ transform:scale(1.12); box-shadow:0 0 0 3px #fff,0 0 0 6px #999; }
  .walls{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
  .wall_cat{ grid-column:1/-1; font-size:12px; font-weight:800; color:#9a8270; margin:6px 0 0; }
  .walls button{ aspect-ratio:1/1; border:2px solid var(--line); border-radius:12px; cursor:pointer;
    font-size:24px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px;
    background-size:cover; background-position:center; }
  .walls button .wn{ font-size:9px; color:#7a6552; background:rgba(255,255,255,.7); border-radius:5px; padding:0 3px; }
  .walls button.is_sel{ border-color:var(--pink); box-shadow:0 0 0 2px var(--pink); }
  .up_row{ display:flex; align-items:center; gap:12px; }
  .up_row .prev{ width:60px; height:60px; border-radius:12px; background:#fff7ec; border:2px dashed var(--line);
    display:flex; align-items:center; justify-content:center; font-size:26px; overflow:hidden; flex:0 0 auto; }
  .up_row .prev img{ width:100%; height:100%; object-fit:cover; }
  .file_btn{ background:var(--mint); color:#fff; font-weight:800; padding:11px 16px; border-radius:12px; border:none; cursor:pointer; font-size:14px; }
  .link_btn{ background:none; border:none; color:#c98; font-size:13px; cursor:pointer; text-decoration:underline; }
  .settings .done{ width:100%; border:none; cursor:pointer; background:var(--pink-d); color:#fff; font-weight:900;
    font-size:18px; padding:15px; border-radius:14px; margin-top:4px; }
  .reset{ width:100%; border:2px solid #ffc1c1; background:#fff; color:#e05a5a; font-weight:800;
    font-size:14px; padding:12px; border-radius:12px; margin-top:12px; cursor:pointer; }
  .share_btn{ width:100%; border:2px solid var(--mint); background:#fff; color:#2bbf9f; font-weight:800;
    font-size:14px; padding:12px; border-radius:12px; margin-top:12px; cursor:pointer; }

  /* === install / version === */
  .install_bar{ text-align:center; margin-bottom:12px; display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
  .install_btn{ border:none; cursor:pointer; background:var(--mint); color:#fff; font-weight:800;
    font-size:14px; padding:10px 20px; border-radius:999px; box-shadow:0 4px 12px rgba(127,214,194,.5); }
  .install_btn:active{ transform:scale(.95); }
  .update_btn{ border:1px solid var(--line); cursor:pointer; background:#fff; color:#9a8270; font-weight:800;
    font-size:13px; padding:10px 16px; border-radius:999px; box-shadow:0 3px 8px var(--shadow); }
  .update_btn:active{ transform:scale(.95); }
  .backup_btn{ border:1px solid var(--line); cursor:pointer; background:#fff; color:#9a8270; font-weight:800;
    font-size:13px; padding:10px 16px; border-radius:999px; box-shadow:0 3px 8px var(--shadow); }
  .backup_btn:active{ transform:scale(.95); }
  .ver_info{ text-align:center; font-size:11px; color:#b39c87; margin-top:18px; }

  /* === modals (ovl / ios_help) === */
  .ovl{ position:fixed; inset:0; z-index:44; display:flex; align-items:center; justify-content:center; background:rgba(80,50,40,.5); padding:24px; }
  .ovl .box{ background:#fff; border-radius:20px; padding:22px; max-width:360px; width:100%; min-width:0; text-align:center; box-shadow:0 12px 30px rgba(0,0,0,.3); }
  .ovl h3{ margin:0 0 10px; font-size:18px; font-weight:900; }
  .ovl p{ font-size:13px; color:#9a8270; margin:0 0 14px; line-height:1.7; }
  .ovl .act{ width:100%; border:none; cursor:pointer; background:var(--pink-d); color:#fff; font-weight:800; font-size:15px; padding:13px; border-radius:12px; margin-top:8px; }
  .ovl .sub2{ width:100%; border:2px solid var(--line); background:#fff; color:var(--ink); font-weight:800; font-size:14px; padding:12px; border-radius:12px; margin-top:8px; cursor:pointer; }
  .ovl .qr{ width:220px; height:220px; margin:4px auto 10px; background:#fff; border-radius:10px; }
  .ovl .lnk{ font-size:11px; color:#9a8270; word-break:break-all; background:#f6f0e8; border-radius:8px; padding:8px; margin-bottom:6px; }
  .ios_help{ position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center; padding:24px; background:rgba(80,50,40,.5); }
  .ios_help .box{ background:#fff; border-radius:20px; padding:24px 22px; max-width:340px; text-align:center; box-shadow:0 12px 30px rgba(0,0,0,.3); }
  .ios_help .big{ font-size:40px; }
  .ios_help h3{ margin:6px 0 10px; font-size:19px; font-weight:900; }
  .ios_help p{ font-size:14px; line-height:2; color:var(--ink); margin:0 0 18px; }
  .ios_help button{ border:none; cursor:pointer; background:var(--pink-d); color:#fff; font-weight:800; font-size:15px; padding:11px 30px; border-radius:999px; }

  /* === 保存の失敗を知らせる帯（2026-08-13） ===
     localStorage は容量上限やプライベートモードで書けなくなる。
     黙って落ちると、ためたスタンプが消えたことに誰も気づけない。
     子を責める文言にはしない。おうちのひとに伝わればいい */
  .save_err{
    position:fixed; left:8px; right:8px; top:8px; z-index:60;
    display:flex; gap:8px; align-items:center;
    background:#fff3cd; color:#7a4b00; border:2px solid #e0a800;
    border-radius:14px; padding:10px 12px; font-size:14px; line-height:1.45;
    box-shadow:0 4px 14px rgba(0,0,0,.15);
  }
  .save_err_msg{ flex:1; }
  .save_err_x{ border:0; background:transparent; color:#7a4b00; font-size:18px; padding:4px 8px; }

  /* === おもいでカード（段3・2026-08-13） === */
  /* ★ canvas の実寸は 1080px。max-width を付けないと、flex item である .ovl .box の
     min-width:auto が canvas の実寸に引っ張られ、max-width:360px を無視して画面をはみ出す */
  .album_prev{ margin:10px 0 14px; min-width:0; }
  .album_prev canvas{ display:block; width:100%; max-width:100%; height:auto;
    border-radius:14px; box-shadow:0 5px 16px var(--shadow); }

  /* === 棚（しまってあるカード・段4b・2026-08-13） === */
  .shelf_head{ width:100%; margin-top:18px; border:2px dashed var(--line); background:transparent;
    color:#a8917c; font-weight:800; font-size:14px; padding:11px; border-radius:14px; cursor:pointer; text-align:left; }
  .shelf_head:active{ transform:scale(.98); }
  .list_item.shelved{ opacity:.62; }
  .list_item.shelved .l_thumb{ filter:grayscale(.6); }

  /* === ごほうび写真の複数サムネ（段4b） === */
  .reward_thumbs{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
  .reward_thumbs .rt{ position:relative; width:64px; height:64px; border-radius:12px; overflow:hidden;
    border:2px solid var(--line); background:#fff7ec; }
  .reward_thumbs .rt img{ width:100%; height:100%; object-fit:cover; display:block; }
  .reward_thumbs .rt_main{ border-color:var(--pink-d); }
  .reward_thumbs .rt_tag{ position:absolute; left:0; bottom:0; right:0; background:rgba(255,90,140,.85);
    color:#fff; font-size:9px; font-weight:800; text-align:center; padding:1px 0; }
  .reward_thumbs .rt_x{ position:absolute; top:2px; right:2px; width:18px; height:18px; border:none; border-radius:50%;
    background:rgba(0,0,0,.45); color:#fff; font-size:10px; line-height:1; cursor:pointer; padding:0; }
  .reward_thumbs .rt_empty{ font-size:13px; color:#b39c87; padding:8px 2px; }

  /* === おうえんの知らせ（家族共有・段D・2026-08-13） === */
  .cheer_toast{ position:fixed; left:50%; transform:translateX(-50%);
    bottom:max(24px, env(safe-area-inset-bottom)); z-index:70;
    background:#fff; border:3px solid var(--yellow); color:var(--ink);
    border-radius:999px; padding:12px 22px; font-size:16px; font-weight:900;
    box-shadow:0 8px 22px var(--shadow); white-space:nowrap;
    animation:cheer_in .4s cubic-bezier(.2,1.4,.4,1); }
  @keyframes cheer_in{ from{ transform:translateX(-50%) translateY(30px); opacity:0; }
    to{ transform:translateX(-50%) translateY(0); opacity:1; } }
  @media (prefers-reduced-motion: reduce){ .cheer_toast{ animation:none; } }

  /* === 保護者ゲートと保護者ページ（段2・2026-08-13） === */
  .gate_q{ font-size:28px; font-weight:900; text-align:center; margin:8px 0 14px; }
  .gate_in{ width:100%; font-size:24px; font-weight:800; text-align:center; padding:10px;
    border:2px solid var(--line); border-radius:12px; margin-bottom:4px; }
  .pp_cards{ display:flex; flex-wrap:wrap; gap:8px; }
  .pp_cards button{ border:2px solid var(--line); background:#fff; border-radius:10px;
    padding:8px 12px; font-weight:800; font-size:13px; cursor:pointer; color:var(--ink); }
  .pp_cards button.is_sel{ border-color:var(--pink-d); color:var(--pink-d); }
  .pp_share{ display:flex; flex-direction:column; gap:8px; }
  .pp_share .pp_btn{ border:none; background:var(--pink-d); color:#fff; font-weight:800;
    font-size:14px; padding:12px; border-radius:12px; cursor:pointer; }
  .pp_share .pp_sub{ border:2px solid var(--line); background:#fff; color:var(--ink);
    font-weight:800; font-size:13px; padding:11px; border-radius:12px; cursor:pointer; }
  .pp_share .pp_danger{ border:2px solid #e0a800; background:#fff8e8; color:#7a4b00;
    font-weight:800; font-size:13px; padding:10px; border-radius:12px; cursor:pointer; }
  .pp_note{ font-size:12px; color:#9a8270; line-height:1.8; }
  .pp_row{ display:flex; gap:8px; }
  .pp_row input{ flex:1; min-width:0; font-size:14px; padding:9px;
    border:2px solid var(--line); border-radius:10px; }
  .pp_row select{ font-size:13px; padding:9px 6px; border:2px solid var(--line);
    border-radius:10px; background:#fff; color:var(--ink); }
  .pp_seat{ display:flex; align-items:center; gap:8px; background:#fff;
    border:2px solid var(--line); border-radius:12px; padding:8px 10px;
    font-size:13px; font-weight:800; }
  .pp_seat .nm{ flex:1; min-width:0; }
  .pp_seat button{ border:none; background:#e05a5a; color:#fff; border-radius:8px;
    padding:6px 10px; font-size:12px; font-weight:800; cursor:pointer; }

  /* QRにできなかった時の注記（段：2026-08-16） */
  .qr_note{ font-size:12px; line-height:1.7; color:#9a8270; background:#fff8e8;
    border:2px dashed var(--line); border-radius:12px; padding:10px; margin-bottom:8px; }

  /* おとなの よびな えらび（パパ/ママ/そのほか・2026-08-21） */
  .label_pick{ display:flex; gap:8px; justify-content:center; margin:0 0 12px; }
  .label_pick button{ flex:1; border:2px solid var(--line); background:#fff; border-radius:12px;
    padding:12px 4px; font-size:15px; font-weight:800; color:var(--ink); cursor:pointer; }
  .label_pick button.is_sel{ border-color:var(--pink-d); color:var(--pink-d); background:#fff0f5; }
  .label_in{ width:100%; font-size:16px; font-weight:800; text-align:center; padding:10px;
    border:2px solid var(--line); border-radius:10px; margin-bottom:10px; }
  .pp_share .pp_btn:disabled{ opacity:.55; cursor:default; }

  /* ★ ユーティリティは最後＝コンポーネントの display にカスケードで勝たせる
     （2026-08-13、この行の下にコンポーネントを足して is_hidden を殺した。
       新しい見た目は必ずこのコメントより上に書くこと） */
  .is_hidden{ display:none; }
