/* ===== カラー定義 =====
   ベース色 : 水色 (#EAF6FB)
   サブカラー: 白色 (#FFFFFF)
   アクセント: 青色 (#2F7FB8)
   設定アイコン用アクセント(紫系): #8C96F0 / #EEEDFE
*/

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #EAF6FB;
  color: #1A3A52;
  min-height: 100vh;
  --fab-bottom-offset: 86px;
  /* 画面端からのスワイプで前後のページがプレビュー表示されるOS標準ジェスチャーを無効化
     (index.html⇔tutorial.htmlの行き来で意図せずチラ見えするのを防ぐ) */
  overscroll-behavior-x: none;
}
/* PWAとして起動時はナビバーがセーフエリア分だけ浮く分、FABもそれに合わせて押し上げる */
@media (display-mode: standalone) {
  body {
    --fab-bottom-offset: calc(86px + env(safe-area-inset-bottom, 0px));
  }
}

.app {
  --app-padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--app-padding);
  padding-bottom: 0;
  position: relative;
  min-height: 100vh;
}

/* ===== テキスト選択・画像保存の抑止 =====
   ・長押し/ドラッグで文字が意図せず選択されてしまう挙動を止める(ネイティブ
     アプリらしい操作感にする目的)。入力欄・編集可能領域だけは例外的に
     通常通り選択/コピペできるようにしている。
   ・キャラクターイラストなど画像を、右クリック「名前を付けて保存」・
     ドラッグして保存・(iOSの)長押しメニューから保存、といったカジュアルな
     手段で保存されにくくする。
   【注意】あくまで操作面での抑止であり、完全に流出を防げるわけではない。
   ブラウザが画像を表示するには画像データ自体を受信する必要があるため、
   開発者ツールやネットワークタブを使うような技術的なユーザーには効果が薄い。
   通常の閲覧操作からのカジュアルな保存を防ぐのが目的と理解してほしい。 */
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* iOS Safariの長押しメニュー(画像を保存/コピー等)を無効化 */
}
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
img {
  -webkit-user-drag: none;
  -user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none; /* ドラッグ保存の起点にならないよう無効化(クリックは親のボタンが受け取るので操作上は問題ない) */
}

.screens {
  padding-bottom: 84px;
}
/* PWAとして起動時、ナビバーがセーフエリア分だけ浮く分の余白を追加
   (元の84pxはWeb版・PWA版とも共通のまま維持) */
@media (display-mode: standalone) {
  .screens {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===== 画面切り替え ===== */
.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ホーム画面だけ、カード間の余白やカード内部のサイズを機種の画面の高さ
   (dvh)に応じて拡縮する。iPhone 17 Pro(874px)を基準にしてあり、その
   機種では元のデザインと完全に同じ見た目になる。それより低い機種では
   最大20%まで縮小、高い機種では最大15%まで拡大する(下のclamp参照)。
   内容量(お気に入りの数など)は機種によらず変わるため、それでも収まり
   きらない場合は従来通り通常スクロールする。 */
#home.screen.active {
  display: flex;
  flex-direction: column;
  gap: 14px; /* dvh未対応の環境向けフォールバック(元のmargin-bottomと同じ値) */
  /* --vh-unit: 「874px(基準機種=iPhone 17 Pro)の画面で1pxだったものを表す
     長さ」。100dvh/874で「画面の高さ ÷ 基準の高さ」の比率を長さとして
     表現し、以下の各所でこれに元のpx数を掛けることで、カードの余白・
     文字・アイコン径などカード全体を機種の高さに比例して拡縮する。
     0.8〜1.15の範囲でクランプし、極端に縮む/伸びるのを防ぐ
     (=元の見た目から最大20%小さく、最大15%大きくまで)。
     基準の874px機種では var(--vh-unit) がちょうど1pxになるため、
     以下の値はすべて元のデザイン値と一致する(その機種での見た目は
     変わらない)。 */
  --vh-unit: clamp(0.8px, calc(100dvh / 874), 1.15px);
  gap: calc(var(--vh-unit) * 14);
}
#home.screen.active > section {
  margin-bottom: 0;
}

/* ===== ホーム画面カード内部の拡縮 =====
   横方向(カード幅・横パディング・文字の折返し幅)は機種の「幅」の話で
   高さには関係ないため、意図的に対象外にしている。キャラクターカードの
   画像は幅基準のアスペクト比で高さが決まる設計(以前の意図的な修正)の
   ため、ここでは対象に含めていない。 */
#home.screen.active .card {
  padding-top: calc(var(--vh-unit) * 18);
  padding-bottom: calc(var(--vh-unit) * 18);
}
#home.screen.active .card-top {
  margin-bottom: 0;
}
#home.screen.active .balance {
  font-size: calc(var(--vh-unit) * 30);
}
#home.screen.active .label {
  font-size: calc(var(--vh-unit) * 12);
  margin-bottom: calc(var(--vh-unit) * 4);
}
#home.screen.active .icon-btn:not(.icon-btn-small) {
  width: calc(var(--vh-unit) * 40);
  height: calc(var(--vh-unit) * 40);
}
#home.screen.active .icon-btn:not(.icon-btn-small) i {
  font-size: calc(var(--vh-unit) * 18);
}
#home.screen.active .setting-icon {
  width: calc(var(--vh-unit) * 22);
  height: calc(var(--vh-unit) * 22);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== 汎用カード ===== */
.card {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.label {
  font-size: 12px;
  color: #6B8A99;
  margin-bottom: 4px;
}

.sub-label {
  font-size: 12px;
  font-weight: 500;
  color: #5A8AA8;
  margin-bottom: 10px;
}

/* ===== Taskポイントカード ===== */
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.balance {
  font-size: 30px;
  font-weight: 500;
  color: #1A3A52;
}

.icon-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 0.5px solid #D8EAF2;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.icon-btn i {
  font-size: 18px;
  color: #5A8AA8;
}

.icon-btn:hover {
  background: #EAF6FB;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn-accent {
  background: #EEEDFE;
  border: 1.5px solid #8C96F0;
}

.icon-btn-accent:hover {
  background: #E1DFFC;
}

.setting-icon {
  width: 22px;
  height: 22px;
  display: block;
}

/* ===== 暖色の小ボタン(「編集」など) =====
   オリジナルタグ(.tab-chip.custom-group: #FBEAE2/#C0703F)より少し明るく鮮やかな
   暖色にして、押せるボタンだと一目で分かるようにしている。 */
.btn-warm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #FFE3D2;
  color: #D9692F;
  border: 0.5px solid #FBCDB0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.btn-warm:active { transform: scale(0.95); opacity: 0.85; }
.btn-warm i { font-size: 14px; }
body.dark-mode .btn-warm {
  background: #46301F;
  color: #F0A57B;
  border-color: #5A3B28;
}

/* ===== ご褒美画面の目標カード =====
   縦に伸びないよう2行構成。1行目=アイコン+ラベル(右上に編集ボタンを重ねる)、
   2行目=名前(長いときは名前だけ折り返す)+金額。金額の列は編集ボタンと同じ幅にして、
   編集ボタンの真下で中央揃えになるようにしている。 */
.wish-goal-card {
  --goal-side-w: 88px;
  position: relative;
  background: #FFFFFF;
  border: 0.5px solid #E3F0F6;
  border-radius: 14px;
  margin-bottom: 12px;
}
.wish-goal-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 14px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: opacity 0.1s;
}
.wish-goal-main:active { opacity: 0.7; }
.wish-goal-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px; /* 右上に重ねる編集ボタン(高さ28px)と揃える */
  padding-right: calc(var(--goal-side-w) + 8px); /* 編集ボタンの下に文字が潜らないよう空ける */
}
.wish-goal-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #EAF6FB;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wish-goal-icon i {
  font-size: 14px;
  filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg);
}
.wish-goal-label {
  font-size: 12px;
  color: #6B8A99;
}
.wish-goal-body {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wish-goal-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: #C25E2B; /* 編集ボタン(.btn-warm)と同系統の暖色。目標だけ他のご褒美名と区別する */
  overflow-wrap: anywhere; /* 長い名前でもカード幅からはみ出さず折り返す */
}
.wish-goal-amount {
  flex: 0 0 var(--goal-side-w);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #6B8A99;
}
.wish-goal-edit {
  position: absolute;
  top: 8px;
  right: 10px;
  width: var(--goal-side-w);
  height: 28px;
}
body.dark-mode .wish-goal-label,
body.dark-mode .wish-goal-amount { color: #7A9BB0; }
body.dark-mode .wish-goal-name { color: #F0A57B; }

/* タスク・ご褒美画面のTaskポイント表示: 上部が固定されるため、小さめにして
   項目の表示領域を確保する(2画面で同じ大きさ) */
#taskManage .card-top .balance,
#wish .card-top .balance {
  font-size: 20px;
}
#taskManage .card-top .label,
#wish .card-top .label {
  font-size: 12px;
  margin-bottom: 2px;
}

/* 日課の連続未達成バッジ(ホーム画面カード内)。
   3日連続で自動リセットされるため、表示されるのは1〜2日のみ。
   基本色(2日)は日課記録ページのmiss-danger(濃い赤)と揃えている。 */
.daily-miss-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
  background: #E0455A;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.daily-miss-badge i {
  font-size: 11px;
}
/* 1日未達成のときは、2日未達成(濃い赤)ほど警戒させすぎないよう、
   日課記録ページのmiss-warnと同じ薄いピンクにして段階を分けている。 */
.daily-miss-badge.miss-warn {
  color: #E0759E;
  background: #FCE4EE;
}

/* 日課の編集モーダルはタイマー設定を開くと内容が増え、標準の高さ(80vh)だと
   一番下の「閉じる」が枠に収まらないため、ここだけ高さの上限を広げる */
#dailyEditModalOverlay .modal-box {
  max-height: 92vh;
  max-height: 92dvh;
}

/* ===== ホームの日課(大きな円形グラフ) ===== */
.btn-cool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #D9EBF7;
  color: #2F7FB8;
  border: 0.5px solid #B9D6E8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.btn-cool:active { transform: scale(0.95); opacity: 0.85; }
.btn-cool i { font-size: 14px; }
body.dark-mode .btn-cool {
  background: #1E3446;
  color: #7FB8DA;
  border-color: #2D4A60;
}

.home-daily {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--vh-unit) * 10);
}
.home-daily-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.home-daily-head > :first-child { justify-self: start; }
.home-daily-head > :last-child { justify-self: end; }
#home.screen.active .home-daily-head .icon-btn-setting {
  width: calc(var(--vh-unit) * 48);
  height: calc(var(--vh-unit) * 48);
}
.home-daily-head .icon-btn-setting svg {
  width: 24px;
  height: 24px;
}
.home-daily-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
#home.screen.active .home-daily-title .label {
  margin-bottom: 0;
  font-size: calc(var(--vh-unit) * 15);
}
.icon-btn-cancel i {
  filter: invert(30%) sepia(80%) saturate(600%) hue-rotate(320deg);
}
body.dark-mode .icon-btn-cancel i {
  filter: invert(65%) sepia(40%) saturate(600%) hue-rotate(320deg);
}
.ti-ban { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%229%22%2F%3E%3Cpath%20d%3D%22M5.7%205.7l12.6%2012.6%22%2F%3E%3C%2Fsvg%3E"); }

#home .card-top {
  align-items: flex-start;
  gap: 12px;
}
.home-goal {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 62%;
  margin-left: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.1s;
}
.home-goal:active { opacity: 0.7; }
.home-goal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
}
.home-goal-row i {
  flex-shrink: 0;
  font-size: 16px;
  filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg);
}
.home-goal-name {
  font-size: calc(var(--vh-unit) * 14);
  font-weight: 500;
  line-height: 1.3;
  color: #C25E2B;
  overflow-wrap: anywhere;
}
.home-goal-amount {
  font-size: calc(var(--vh-unit) * 12);
  font-weight: 600;
  color: #6B8A99;
}
body.dark-mode .home-goal-amount { color: #7A9BB0; }
body.dark-mode .home-goal-row i { filter: invert(70%) sepia(30%) saturate(500%) hue-rotate(175deg); }
body.dark-mode .home-goal-name { color: #F0A57B; }

.btn-warm i { filter: invert(45%) sepia(60%) saturate(500%) hue-rotate(340deg) brightness(95%); }
body.dark-mode .btn-warm i { filter: invert(75%) sepia(45%) saturate(500%) hue-rotate(340deg); }
.btn-cool i { filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg); }
body.dark-mode .btn-cool i { filter: invert(70%) sepia(30%) saturate(500%) hue-rotate(175deg); }
.home-ring-done i { filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg); }
body.dark-mode .home-ring-done i { filter: invert(70%) sepia(30%) saturate(500%) hue-rotate(175deg); }
body.dark-mode .wish-goal-icon i { filter: invert(70%) sepia(30%) saturate(500%) hue-rotate(175deg); }

.home-ring-area {
  position: relative;
  width: min(calc(var(--vh-unit) * 290), 100%);
}
.home-ring-btn {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.1s;
}
.home-ring-btn:active { transform: scale(0.98); }
.home-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.home-ring-core {
  fill: transparent;
  transition: fill 0.25s;
}
.home-ring-btn.achieved .home-ring-core { fill: #D6ECF8; }
body.dark-mode .home-ring-btn.achieved .home-ring-core { fill: #1F3647; }

.home-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 17%;
  text-align: center;
}
.home-ring-name {
  font-size: calc(var(--vh-unit) * 28);
  font-weight: 700;
  line-height: 1.25;
  color: #1A3A52;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
body.dark-mode .home-ring-name { color: #D0E4EF; }
.home-ring-days {
  font-size: calc(var(--vh-unit) * 13);
  font-weight: 600;
  color: #6B8A99;
}
body.dark-mode .home-ring-days { color: #7A9BB0; }
.home-ring-done {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: calc(var(--vh-unit) * 12);
  font-weight: 700;
  color: #2F7FB8;
}
.home-ring-done i { font-size: 13px; }
body.dark-mode .home-ring-done { color: #7FB8DA; }

.home-daily-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}
.home-action-btn {
  flex: 1;
  height: calc(var(--vh-unit) * 52);
  font-size: 15px;
}
.home-action-btn i { font-size: 18px; }

/* 目標が未設定のときは、縦2段にせず「🎯 目標  未設定」を横1行にしてカードの高さを節約する */
.wish-goal-card.unset .wish-goal-main {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-right: calc(var(--goal-side-w) + 20px);
}
.wish-goal-card.unset .wish-goal-head {
  padding-right: 0;
}
.wish-goal-card.unset .wish-goal-body {
  flex: 1;
  min-width: 0;
}
.wish-goal-card.unset .wish-goal-amount {
  display: none;
}

/* ホームの「?」(使い方ガイド)。設定ボタンと同じ配色で、アイコンの代わりに文字を使う */
.home-daily-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  /* 未達成バッジをボタン2つの真下(幅の中央)に出すための基準。
     バッジは絶対配置にして、出入りでヘッダーの高さ(=リングの位置)が動かないようにしている */
  position: relative;
}
.home-daily-head-right .daily-miss-badge {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  z-index: 2;
}
/* 「?」は設定ボタン(48)より一回り小さくする */
#home.screen.active .home-daily-head .icon-btn-help {
  width: calc(var(--vh-unit) * 40);
  height: calc(var(--vh-unit) * 40);
}
.icon-btn-help {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: #6C63D4;
}
body.dark-mode .icon-btn-help { color: #9A96E0; }

/* タグ追加: 丸い＋ボタン。押すと入力欄に切り替わる(空のまま離れるとキャンセル) */
.tag-add-wrap {
  /* 追加FAB(.fab-add-btn)と同じ基準で右下に固定する。常に見えている必要があるので
     スクロール領域・カードの外に置いている */
  position: fixed;
  left: max(20px, calc(50vw - 240px + 20px));
  right: max(20px, calc(50vw - 240px + 20px));
  bottom: var(--fab-bottom-offset);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  z-index: 90;
  pointer-events: none; /* 空いている部分のタップは下の画面に通す */
}
.tag-add-wrap > * { pointer-events: auto; }
/* 入力欄はカード(枠)の中に出す */
.tag-add-row { margin-top: 12px; }
.tag-add-row .text-input { width: 100%; }
/* 追加中はキーボードの分だけ下に余白を足し、入力欄を上へスクロールできるようにする */
#taskGroupEdit.tag-adding > .card, #wishGroupEdit.tag-adding > .card { margin-bottom: 50dvh; }
/* 固定ボタンに隠れて最後のタグが操作できなくならないよう、カードの下に余白を取る */
#taskGroupEdit > .card, #wishGroupEdit > .card { margin-bottom: 96px; }
.tag-add-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(47, 127, 184, 0.45);
  transition: transform 0.1s;
}
.tag-add-btn:active { transform: scale(0.92); }
.tag-add-btn i { font-size: 26px; filter: brightness(0) invert(1); }
body.dark-mode .tag-add-btn { background: linear-gradient(135deg, #1A5F8A 0%, #2F7FB8 100%); }

/* 目標選択モーダル: タイトル・検索・タグ・下のボタンは固定し、スクロールするのは項目の一覧だけ。
   リセット:閉じる = 1:3 の幅で、リセットは赤背景(押し間違えると目標が外れるので目立たせる) */
#goalModalOverlay .modal-box {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#goalModalOverlay .modal-box > * { flex-shrink: 0; }
#goalModalOverlay #goalWishList {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-sticky-footer {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.modal-sticky-footer .btn-secondary { flex: 3; }
.modal-sticky-footer #clearGoalBtn {
  flex: 1;
  background: #D9685F;
  border-color: #D9685F;
  color: #FFFFFF;
}
body.dark-mode .modal-sticky-footer #clearGoalBtn {
  background: #B9504A;
  border-color: #B9504A;
  color: #FFFFFF;
}

/* アイコンをタップして変更する(アイコン選択ボタンの代わり) */
.icon-preview-tappable { cursor: pointer; transition: transform 0.1s; }
.icon-preview-tappable:active { transform: scale(0.94); }

/* 並び替え(ドラッグ)用のアイコン: 6つの点ではなく、横棒3本を縦に並べた形にする */
.ti-grip-vertical { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3C%2Fsvg%3E"); }

/* ===== セクション見出し ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  row-gap: 6px;
}

.section-title {
  font-size: 13px;
  font-weight: 500;
  color: #5A8AA8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}

.card .section-title {
  margin-bottom: 10px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #2F7FB8;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.link-btn i {
  font-size: 14px;
}

/* ===== お気に入り(横スライド) =====
   タスク数の上限をなくしたため、グリッドではなく件数に応じて
   横スクロールできる形に変更(タブチップと同じ横スライドの考え方)。
   カードは幅固定(flex-shrink:0)で、右端にスクロール可能を示す
   フェードを重ねている。 */
.favorites {
  margin-bottom: 14px;
}

.fav-grid-wrap {
  position: relative;
}

/* 右端にフェード(スクロール可能を示す。タブチップと同じ仕組み) */
.fav-grid-wrap::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 4px;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--fade-bg, #EAF6FB));
  pointer-events: none;
}

body.dark-mode .fav-grid-wrap { --fade-bg: #121820; }

.fav-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #B9D6E8 transparent;
  padding-bottom: 4px;
  padding-right: 32px; /* フェード分の余白 */
}

.fav-grid::-webkit-scrollbar {
  height: 3px;
}

.fav-grid::-webkit-scrollbar-track {
  background: transparent;
}

.fav-grid::-webkit-scrollbar-thumb {
  background: #B9D6E8;
  border-radius: 999px;
}

body.dark-mode .fav-grid::-webkit-scrollbar-thumb {
  background: #3A5A70;
}

.fav-card {
  flex: 0 0 auto;
  width: 78px;
  background: #FFFFFF;
  border: 0.5px solid #E3F0F6;
  border-radius: 16px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.fav-card:hover {
  background: #EAF6FB;
}

.fav-card:active {
  transform: scale(0.95);
}

.fav-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #EAF6FB;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fav-icon-circle.fav-icon-done {
  background: #2F7FB8;
}

.fav-icon-circle.fav-icon-done i {
  color: #FFFFFF !important;
}

.fav-icon-circle i {
  font-size: 22px;
  color: #2F7FB8;
}

.fav-card span {
  font-size: 12px;
  font-weight: 500;
  color: #1A3A52;
  text-align: center;
}

.fav-empty {
  flex: 1 1 auto;
  text-align: center;
  font-size: 13px;
  color: #A9C7D6;
  padding: 20px 0;
}

/* お気に入りは画面上部に固定されるため、名前が長くても固定部分が伸びすぎないよう2行までにする */
.favorites .fav-card span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* ===== 金額入力 ===== */
.amount-row {
  display: flex;
  gap: 8px;
}

.amount-row input {
  flex: 1;
  border: 0.5px solid #D8EAF2;
  background: #EAF6FB;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: #1A3A52;
  outline: none;
  transition: box-shadow 0.15s;
}

.amount-row input:focus {
  box-shadow: 0 0 0 2px #B9D6E8;
}

.btn-primary {
  background: #2F7FB8;
  color: #FFFFFF;
  border: none;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-block {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  font-size: 14px;
}

/* ===== お気に入り編集画面 ===== */
.edit-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

/* 画面上部に固定されるヘッダー(お気に入り編集画面など) */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #EAF6FB;
  padding: 12px 1rem 10px;
  margin: 0 -1rem 14px;
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.08);
}

.sticky-header .edit-title {
  flex: 1;
  /* タイトルが長くなっても1行で収まるよう省略 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 日課記録ページ: 戻るボタン・円形グラフ・年タブをまとめて上部に固定し、
   履歴一覧だけがその下でスクロールする形にする(.sticky-headerと同じ
   「はみ出させて画面端まで塗る」テクニックを、3つ分まとめて適用) */
.daily-record-sticky-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #EAF6FB;
  padding: 12px 1rem 10px;
  margin: 0 -1rem;
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.08);
}
.daily-record-sticky-top .edit-header {
  margin-bottom: 4px;
}

/* 日課カレンダー: 横は画面いっぱい(固定部分のpaddingを打ち消して画面端まで広げる)、
   縦は画面の約2/3。常に表示し、下の年タブと履歴一覧だけがスクロールする。
   月は横スライドで切り替える(3枚のパネルを横に並べ、指に追従して動かす)。 */
.daily-cal {
  display: flex;
  flex-direction: column;
  height: 64vh;
  height: 64dvh;
  margin: 0 -1rem -10px;
}
.daily-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 1rem 6px;
}
.daily-cal-nav {
  width: 40px;
  height: 36px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.daily-cal-nav i {
  font-size: 20px;
  filter: invert(55%) sepia(20%) saturate(400%) hue-rotate(175deg);
}
.daily-cal-prev i { transform: rotate(180deg); }
.daily-cal-title {
  border: none;
  background: none;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: #1A3A52;
  padding: 4px 12px;
  cursor: pointer;
}
.daily-cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #6B8A99;
  padding-bottom: 4px;
}
.daily-cal-week span:first-child { color: #D9685F; }
.daily-cal-week span:last-child { color: #2F7FB8; }
.daily-cal-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.daily-cal-track {
  display: flex;
  width: 300%;
  height: 100%;
  transform: translateX(-33.3333%);
}
.daily-cal-panel {
  flex: 0 0 33.3333%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.daily-cal-cell {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* 数字・日課名は左上揃え */
  text-align: left;
  gap: 2px;
  padding: 4px 3px;
  border: none;
  border-radius: 6px;
  font: inherit;
  background: #FFFFFF;
  color: #2F7FB8;
  overflow: hidden;
}
.daily-cal-cell.blank { background: transparent; }
.daily-cal-cell.achieved { background: #2F7FB8; color: #FFFFFF; }
.daily-cal-cell.today { box-shadow: inset 0 0 0 2px #E0A800; }
.daily-cal-cell.tappable { cursor: pointer; }
.daily-cal-num { font-size: 12px; font-weight: 700; }
/* 同じ日課が同じ週で続く日は、マス同士の隙間(2px)をなくして色の帯としてつなぐ。
   つなぐ側の角を丸めず、隙間の分だけ右のマスへ幅を広げる(次のマスは隙間の後ろから始まるので重ならない) */
.daily-cal-cell.join-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.daily-cal-cell.join-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -2px; }
.daily-cal-name {
  max-width: 100%;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.dark-mode .daily-cal-title { color: #D0E4EF; }
body.dark-mode .daily-cal-nav i { filter: invert(70%) sepia(20%) saturate(400%) hue-rotate(175deg); }
body.dark-mode .daily-cal-week { color: #7A9BB0; }
body.dark-mode .daily-cal-cell { background: #05080C; color: #5DA9E0; }
body.dark-mode .daily-cal-cell.blank { background: transparent; }
body.dark-mode .daily-cal-cell.achieved { background: #2B6CA3; color: #FFFFFF; }

.daily-cal-picker-year {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.daily-cal-picker-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.daily-cal-picker-months .tab-chip { text-align: center; padding: 10px 0; }
#dailyHistoryListContainer { padding-bottom: 40px; }

/* 履歴画面: 戻るボタン・タスク/ご褒美タブ・グラフをまとめて上部に固定し、
   履歴一覧だけがその下でスクロールする(日課記録ページと同じ考え方)。
   グラフはタスクタブ=収入、ご褒美タブ=支出がタブに合わせて切り替わる */
.history-sticky-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #EAF6FB;
  padding: 12px 1rem 10px;
  margin: 0 -1rem 14px;
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.08);
}
.history-sticky-top .edit-header {
  margin-bottom: 10px;
}
.history-sticky-top .history-tabs {
  margin-bottom: 10px;
}
.history-sticky-top .card {
  margin-bottom: 0;
}
.hist-graph-content { display: none; }
.hist-graph-content.active { display: block; }

.edit-title {
  font-size: 16px;
  font-weight: 500;
  color: #1A3A52;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* FABが最後の項目に重なって操作しづらくならないよう、
   FABのある一覧(タスク・Wish)だけ下に1項目分ほどの余白を確保する */
#taskListContainer,
#wishList,
#taskHistoryList,
#histWishList {
  /* FABがナビバーとの間隔調整で位置が変わっても、最後の項目が
     隠れないよう「FABの下端位置 + FABの高さ + 余裕」から動的に計算する
     (固定値だとFABの位置とズレて最後の項目が隠れてしまうため)。 */
  padding-bottom: calc(var(--fab-bottom-offset) + 56px + 16px);
  /* ドラッグ並び替え中、ブラウザのscroll anchoringで意図せず
     大きくスクロールしてしまう挙動を防ぐ */
  overflow-anchor: none;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  transition: background 0.15s, opacity 0.15s;
}

.list-item.current {
  background: #EAF6FB;
  cursor: grab;
}

.list-item.current:active {
  cursor: grabbing;
}

.list-item.current.dragging {
  opacity: 0.4;
}

.list-item.pool {
  border: 0.5px solid #E3F0F6;
}

.list-item.pool.added {
  opacity: 0.4;
}

.grip {
  font-size: 16px;
  color: #A9C7D6;
  cursor: grab;
}

.item-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 0.5px solid #D8EAF2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-item.pool .item-icon-circle {
  background: #EAF6FB;
  border: none;
}

.item-icon-circle i {
  font-size: 16px;
  color: #2F7FB8;
}

.item-name {
  font-size: 14px;
  font-weight: 500;
  color: #1A3A52;
  flex: 1;
}

.remove-btn,
.add-btn {
  background: none;
  border: none;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.1s, background 0.15s;
}

.remove-btn i {
  font-size: 16px;
  color: #C97A7A;
}

.add-btn {
  background: #EAF6FB;
  width: 28px;
  height: 28px;
}

.add-btn i {
  font-size: 16px;
  color: #2F7FB8;
}

.remove-btn:active,
.add-btn:active {
  transform: scale(0.9);
}

.empty-msg {
  font-size: 13px;
  color: #A9C7D6;
  text-align: center;
  margin-top: 12px;
}

/* ===== レスポンシブ (PC向け) ===== */
@media (min-width: 600px) {
  .app {
    --app-padding: 24px;
    max-width: 520px;
    padding: var(--app-padding);
  }

  .card {
    padding: 22px 26px;
  }

}

/* ===== ボトムナビゲーション =====
   ベース色を青にし、白をアクセント(アクティブタブ)として使用
*/
/* PWAとして起動時、ナビバーの水色をセーフエリア分だけ延長する帯。
   中央に細い線を1本入れて、意図的に伸ばしたデザインだと分かるようにする
   (iOSのホームインジケーターのような見た目を意識)。 */
.safe-area-patch {
  display: none;
}
@media (display-mode: standalone) {
  .safe-area-patch {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: env(safe-area-inset-bottom, 0px);
    background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%); /* ナビバーと同じ色 */
    z-index: 99;
  }
  body.dark-mode .safe-area-patch {
    background: linear-gradient(135deg, #1A5F8A 0%, #2F7FB8 100%); /* ダークモード時のナビバーと同じ色 */
  }
  .safe-area-patch::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
  }
  body.dark-mode .safe-area-patch::after {
    background: rgba(255, 255, 255, 0.5); /* ダークモードの暗い帯上では少し控えめに */
  }
}
.bottom-btn {
  position: fixed;
  bottom: 0; /* ブラウザ版(タブ表示)はセーフエリア分の余計な浮きを作らない */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 64px;
  display: flex;
  flex-direction: row;
  background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%);
  border-radius: 20px 20px 0 0; /* 上のみ角丸(元の方針に戻す) */
  box-shadow: 0 -4px 16px rgba(47, 127, 184, 0.35);
  z-index: 100;
  padding: 6px 8px;
  gap: 6px;
}
/* ホーム画面に追加してアプリとして起動している時だけ、
   セーフエリア(ホームインジケーター)分だけバーごと押し上げる */
@media (display-mode: standalone) {
  .bottom-btn {
    bottom: env(safe-area-inset-bottom, 0px);
  }
}

.round-btn-nav {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  border: none;
  background: transparent;
  border-radius: 14px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.round-btn-nav i {
  font-size: 20px;
  transition: transform 0.15s;
}

.round-btn-nav:active {
  transform: scale(0.95);
}

.round-btn-nav.active {
  color: #2F7FB8;
  background: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.round-btn-nav.active i {
  transform: translateY(-1px);
}

/* PCサイズではナビ幅を中央寄せのapp幅に揃える */
@media (min-width: 600px) {
  .bottom-btn {
    max-width: 520px;
  }
}

/* ===== 設定アイコンボタン(ユーザー提供スタイル) ===== */
.round-btn {
  background-color: var(--button-color, #ecae9f);
  border: 1px solid rgb(65, 61, 61);
  font-size: 12px;
  border-radius: var(--border-radius, 120px);
  text-align: var(--text-align, center);
  justify-content: center;
  width: var(--width, 50px);
  height: var(--height, 50px);
  transition: 0.2s;
  align-self: center;
  cursor: pointer;
  padding: 0;
}

.round-btn:active {
  transform: scale(0.95);
}

.round-btn.set-icon {
  background-image: url("./setting_icon.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%;
  background-color: transparent;
  border: 0px solid transparent;
}

/* 新設定ボタン: アプリのicon-btnスタイルに統一 */
.icon-btn-setting {
  background: #EEEDFE;
  border: 1.5px solid #8C96F0;
}

.icon-btn-setting svg {
  color: #6C63D4;
  stroke: #6C63D4;
}

/* タグがiのときもフィルターで色を統一 */
.icon-btn-setting i {
  filter: invert(35%) sepia(60%) saturate(600%) hue-rotate(225deg) brightness(90%);
}

.icon-btn-setting:hover { background: #E1DFFC; }

body.dark-mode .icon-btn-setting {
  background: #2A2A4A;
  border-color: #5A5AB0;
}

body.dark-mode .icon-btn-setting svg { stroke: #9A96E0; }
body.dark-mode .icon-btn-setting i {
  filter: invert(70%) sepia(30%) saturate(400%) hue-rotate(210deg);
}

/* ===== 棒グラフ(月別消費金額) ===== */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 110px;
  margin-bottom: 8px;
}

.bar-chart-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  height: 100%;
}

.bar-chart-val {
  font-size: 11px;
  color: #5A8AA8;
  margin-bottom: 4px;
}

.bar-chart-bar {
  width: 32px;
  border-radius: 6px 6px 0 0;
  background: #2F7FB8;
  transition: height 0.3s;
}

.bar-chart-labels {
  display: flex;
  justify-content: space-around;
}

.bar-chart-label {
  font-size: 11px;
  color: #A9C7D6;
}

.bar-chart-label.active {
  color: #2F7FB8;
  font-weight: 500;
}

/* ===== タブチップ(タスクグループ・カテゴリ選択) ===== */
.tab-chips-wrap {
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

/* モーダル内のタブチップは overflow:hidden を解除して横スクロールを有効にする */
.modal-box .tab-chips-wrap {
  overflow: visible;
}
.modal-box .tab-chips {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 右端にフェード(スクロール可能を示す) */
.tab-chips-wrap::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--fade-bg, #FFFFFF));
  pointer-events: none;
  z-index: 1;
}

body.dark-mode .tab-chips-wrap { --fade-bg: #1E2A36; }

.tab-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* 細いスクロールバーを表示(スクロール可能であることを示す) */
  scrollbar-width: thin;
  scrollbar-color: #B9D6E8 transparent;
  margin-bottom: 0;
  padding-bottom: 4px;
  padding-right: 32px; /* フェード分の余白 */
}

.tab-chips::-webkit-scrollbar {
  height: 3px;
}

.tab-chips::-webkit-scrollbar-track {
  background: transparent;
}

.tab-chips::-webkit-scrollbar-thumb {
  background: #B9D6E8;
  border-radius: 999px;
}

body.dark-mode .tab-chips::-webkit-scrollbar-thumb {
  background: #3A5A70;
}

.tab-chip {
  flex-shrink: 0;
  background: #FFFFFF;
  border: 0.5px solid #E3F0F6;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #5A8AA8;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-chip.active {
  background: #2F7FB8;
  color: #FFFFFF;
  border-color: #2F7FB8;
}

/* カスタムグループのチップ(暖色系で区別) */
.tab-chip.custom-group {
  background: #FBEAE2;
  color: #C0703F;
  border-color: #F4D9CB;
}

.tab-chip.custom-group.active {
  background: #E07B4F;
  color: #FFFFFF;
  border-color: #E07B4F;
}

/* 「まとめ」フォルダのチップ(デフォルトタグの青より少し濃い青) */
.tab-chip.matome-chip {
  background: #DCEAF3;
  color: #1F5C8A;
  border-color: #B9D6E8;
}
.tab-chip.matome-chip.active {
  background: #1F5C8A;
  color: #FFFFFF;
  border-color: #1F5C8A;
}
body.dark-mode .tab-chip.matome-chip {
  background: #1B2E3A;
  color: #8FC3E8;
  border-color: #274152;
}
body.dark-mode .tab-chip.matome-chip.active {
  background: #1F5C8A;
  color: #FFFFFF;
  border-color: #1F5C8A;
}

.tab-chip.add-chip {
  width: 34px;
  flex: 0 0 34px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2F7FB8;
}

/* ===== 検索行 ===== */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 0 10px;
  border: 0.5px solid #E3F0F6;
}

.search-box i {
  font-size: 15px;
  color: #A9C7D6;
}

.search-box input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  outline: none;
  color: #1A3A52;
}

.count-label {
  font-size: 11px;
  color: #A9C7D6;
  margin: 0 0 10px;
  text-align: right;
}

/* ===== タスク一覧行 ===== */
/* ===== タスク行のラッパー(スワイプ削除用) ===== */
.task-row-wrapper {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
}

.task-row-wrapper.delete-mode .task-row {
  transform: translateX(46px);
  pointer-events: none;
}

.task-row {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0.5px solid #E3F0F6;
  cursor: pointer;
  transition: background 0.15s, transform 0.2s ease;
}

.task-row:hover {
  background: #EAF6FB;
}

.task-row-wrapper.dragging {
  opacity: 0.4;
}

/* ===== スワイプで削除 ===== */
/* 行の下に隠れている赤い削除ボタン。.task-rowを左にtranslateXすると覗く。
   【バグ修正】達成済みくり返し(.wish-item-done)などopacityで薄く表示される
   行の場合、単にz-indexで後ろに置いているだけだと半透明の行を通して
   赤色がうっすら透けて見えてしまっていた。visibility:hiddenをデフォルトに
   することで、スワイプ中/開いている時以外は完全に描画自体をしない
   (透過ブレンドの対象にすらならない)ようにして根本的に防ぐ。 */
.swipe-delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #D9483F;
  z-index: 0;
  visibility: hidden;
}
.task-row-wrapper.swipe-dragging .swipe-delete-bg,
.task-row-wrapper.swipe-open .swipe-delete-bg {
  visibility: visible;
}
.swipe-delete-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: none;
  color: #FFFFFF;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.task-row-wrapper .task-row {
  position: relative;
  z-index: 1;
}

/* ドラッグ並び替え用ハンドル */
.task-grip {
  font-size: 16px;
  color: #C9DCE6;
  cursor: grab;
  touch-action: none;
  padding: 4px;
  flex-shrink: 0;
}

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #B9D6E8;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  transition: background 0.15s, border-color 0.15s;
}

.task-check.checked {
  background: #2F7FB8;
  border-color: #2F7FB8;
  color: #FFFFFF;
}

.task-check.checked i {
  font-size: 13px;
}

.task-check.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.task-icon-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #EAF6FB;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-icon-circle i {
  font-size: 16px;
  color: #2F7FB8;
}

.task-row-info {
  flex: 1;
  min-width: 0;
}

.task-row-name {
  font-size: 13px;
  font-weight: 500;
  color: #1A3A52;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 一覧行のバッジ(カテゴリ・日付・時刻)は折り返さず常に横1列で表示する。
   文字が多くて収まらないときだけ横スクロールできる(スクロールバーは出さない)。
   行全体の左スワイプ削除とは、JS側(bindRowBadgeExtras)で、はみ出している時だけ
   バッジ上のスワイプを行に渡さないことで競合を避けている。 */
.task-row-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.task-row-badges::-webkit-scrollbar { display: none; }

/* 直前の達成の取り消しボタン(「並び替え」の左隣、マークだけ)。15分以内・1回使うまで表示 */
.quick-undo-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FCE4EE;
  color: #D9685F;
  justify-content: center;
  padding: 0;
}
.quick-undo-btn svg { width: 15px; height: 15px; }
.quick-undo-btn:active { transform: scale(0.9); }
body.dark-mode .quick-undo-btn { background: #3A1F28; color: #F08080; }

.task-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-habit { background: #EAF6FB; color: #2F7FB8; }
.badge-task  { background: #EEEDFE; color: #7F77DD; }
.badge-daily { background: #FAEEDA; color: #BA7517; }
/* カスタムグループは暖色系(ユーザーが追加したものと一目で分かるように) */
.badge-custom { background: #FBEAE2; color: #C0703F; }
/* 通知/カレンダーで設定した日時(一覧行のカテゴリバッジの隣に表示)。
   日付=薄緑、時刻=薄ピンクで、他のカテゴリバッジと同じ見た目に揃えている。 */
.badge-notif-date { background: #E6F5E9; color: #3E9A5C; }
.badge-notif-time { background: #FCE4EE; color: #C15C86; }

.task-row-reward {
  font-size: 12px;
  font-weight: 500;
  color: #2F7FB8;
  white-space: nowrap;
}

/* ===== Wishリスト行 ===== */
.wish-row {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0.5px solid #E3F0F6;
}

.wish-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wish-icon-circle i {
  font-size: 18px;
}

.wish-row-info {
  flex: 1;
  min-width: 0;
}

.wish-row-name {
  font-size: 13px;
  font-weight: 500;
  color: #1A3A52;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wish-row-sub {
  font-size: 11px;
  color: #A9C7D6;
  margin: 0;
}

.wish-row-cost {
  font-size: 13px;
  font-weight: 500;
  color: #1A3A52;
  white-space: nowrap;
}

.achieve-pill {
  background: #2F7FB8;
  color: #FFFFFF;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s;
}

.achieve-pill:active {
  transform: scale(0.95);
}

/* ===== 達成履歴行 ===== */
.history-row {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0.5px solid #E3F0F6;
}

.history-row-info {
  min-width: 0;
}

.history-row-name {
  font-size: 13px;
  font-weight: 500;
  color: #1A3A52;
  margin: 0 0 2px;
}

.history-row-date {
  font-size: 11px;
  color: #A9C7D6;
  margin: 0;
}

.history-row-cost {
  font-size: 13px;
  font-weight: 500;
  color: #C97A7A;
  white-space: nowrap;
}

/* ===== ボタン類追加 ===== */
.btn-with-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

/* Taskポイント横などに置く、幅を持たせない小さめのボタン */
.btn-compact {
  margin-top: 0;
  padding: 0 18px;
  height: 38px;
  white-space: nowrap;
}

/* 履歴・削除などの小さなリンクを並べるグループ */
.mini-link-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  row-gap: 6px;
}

/* 削除など、注意を促すリンク */
.link-btn-danger {
  color: #D9685F;
}

/* 削除モード中の「完了」リンク */
.link-btn-active {
  color: #2F7FB8;
  font-weight: 700;
}

/* 並び替えボタン: 古い順=赤、新しい順=青、カスタム=紫 */
.link-btn-sort-oldest {
  color: #D9685F;
  font-weight: 700;
}
.link-btn-sort-newest {
  color: #2F7FB8;
  font-weight: 700;
}
.link-btn-sort-custom {
  color: #8C96F0;
  font-weight: 700;
}

/* セカンダリボタン(キャンセル・閉じるなど) */
.btn-secondary {
  background: #FFFFFF;
  color: #5A8AA8;
  border: 1px solid #E3F0F6;
  padding: 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.btn-secondary:active {
  transform: scale(0.97);
  background: #EAF6FB;
}

.btn-danger {
  background: #FFFFFF;
  color: #C97A7A;
  border: 1px solid #F0D5D5;
  padding: 14px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.btn-danger:active {
  transform: scale(0.97);
  background: #FBEFEF;
}

.edit-action-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== タスク編集画面の入力欄 ===== */
.text-input {
  width: 100%;
  border: 0.5px solid #D8EAF2;
  background: #EAF6FB;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: #1A3A52;
  outline: none;
  transition: box-shadow 0.15s;
}

.text-input:focus {
  box-shadow: 0 0 0 2px #B9D6E8;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  color: #1A3A52;
  cursor: pointer;
}

.option-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2F7FB8;
  cursor: pointer;
}

/* ===== Wish画面のTaskポイント表示(小さめ) ===== */
#wishBalanceDisplay {
  font-size: 22px;
}

/* ご褒美画面右上の「単発のご褒美項目を残す」ミニトグル。
   Taskポイント表示と縦に並べたとき見た目が揃うよう、ラベル行の幅を
   トグル本体(44px)に合わせて中央寄せしている(=2行が同じ幅になる)。 */
.wish-keepgoal-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.wish-keepgoal-mini-label {
  font-size: 11px;
  color: #6B8A99;
  width: 44px;
  text-align: center;
}

/* ===== 数値専用入力欄 =====
   type="text" + inputmode="numeric" + JSでのフィルタリングと組み合わせて使用
*/
.numeric-input {
  font-variant-numeric: tabular-nums;
}

/* ===== 達成演出オーバーレイ =====
   テーマ別カラー:
     task  = 寒色(青系)
     wish  = 暖色(オレンジ系)
     daily = 緑系
     goal  = 黄系
*/
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.celebration-overlay.show {
  display: flex;
}

.celebration-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 45, 0.45);
}

.celebration-box {
  position: relative;
  z-index: 2;
  background: #FFFFFF;
  border-radius: 24px;
  padding: 32px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  border: 3px solid var(--celeb-color, #2F7FB8);
  animation: celebration-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes celebration-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.celebration-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  /* 背景をテーマカラー本体(薄色ではなくアクセントカラー)に */
  background: var(--celeb-color, #2F7FB8);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: celebration-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes celebration-bounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-7px) scale(1.05); }
}

.celebration-icon {
  font-size: 36px;
  width: 36px;
  height: 36px;
  /* アイコンは常に白で、濃い背景上で目立つ */
  filter: brightness(0) invert(1) !important;
}

.celebration-title {
  font-size: 18px;
  font-weight: 700;
  color: #1A3A52;
  margin: 0;
}

.celebration-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--celeb-color, #2F7FB8);
  margin: 0;
}

/* テーマカラー定義 */
.celebration-overlay.theme-task {
  --celeb-color: #2F7FB8;
  --celeb-bg: #E6F1FB;
}

.celebration-overlay.theme-wish {
  --celeb-color: #E07B4F;
  --celeb-bg: #FBEAE2;
}

.celebration-overlay.theme-daily {
  --celeb-color: #1D9E75;
  --celeb-bg: #E1F5EE;
}

.celebration-overlay.theme-goal {
  --celeb-color: #E0A800;
  --celeb-bg: #FBF2D5;
}

/* フラッシュ(達成時に中心から光が広がる効果) */
.celebration-flash-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.celebration-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--celeb-color, #2F7FB8);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0.55;
  animation: celebration-flash 0.7s ease-out forwards;
}

@keyframes celebration-flash {
  0%   { transform: translate(-50%, -50%) scale(0);  opacity: 0.55; }
  100% { transform: translate(-50%, -50%) scale(16); opacity: 0; }
}

/* 紙吹雪(中心からバースト→落下) */
.confetti-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  opacity: 0;
  animation: confetti-burst ease-out forwards;
  will-change: transform, opacity;
}

.confetti-piece.shape-circle {
  border-radius: 50%;
}

.confetti-piece.shape-strip {
  border-radius: 2px;
}

@keyframes confetti-burst {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(0.4);
    opacity: 1;
  }
  18% {
    transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) rotate(var(--rot1)) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--fx), var(--fy)) rotate(var(--rot2)) scale(0.8);
    opacity: 0;
  }
}

/* ===== トースト通知 ===== */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A3A52;
  color: #FFFFFF;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1100;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== グループ管理モーダル =====
   タスク画面の「+」チップ・タスク編集画面の「グループを編集」から開く。
*/
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.show {
  display: flex;
}

.modal-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 45, 0.45);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: #FFFFFF;
  border-radius: 20px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  animation: celebration-pop 0.25s ease-out;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #1A3A52;
  margin: 0;
}

.modal-group-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FBEAE2;
  border-radius: 8px;
  padding: 10px 12px;
}

.modal-group-item .item-name {
  color: #C0703F;
}

/* グループ名インライン編集 */
.modal-group-item .group-name-input {
  flex: 1;
  font-size: 16px; /* iOSのズーム防止(全テキスト入力共通の統一値) */
  font-weight: 600;
  color: #C0703F;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid #E8A6A0;
  outline: none;
  padding: 2px 0;
  min-width: 0;
}

/* iOSのzoom防止: 全テキスト入力のfont-sizeを16px以上に */
.text-input,
.numeric-input {
  font-size: 16px !important;
}

/* 検索入力もzoom防止 */
input[type="text"],
input[type="email"],
input[type="search"],
textarea {
  font-size: 16px;
}

/* グループ削除用の⊖ボタン(タスク行の削除ボタンと統一したデザイン) */
.modal-remove-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1.5px solid #E8A6A0;
  color: #D9685F;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.modal-remove-btn:active {
  transform: scale(0.9);
}

.modal-add-row {
  display: flex;
  gap: 8px;
}

.modal-add-row .text-input {
  flex: 1;
}

.modal-add-row .btn-primary {
  padding: 0 18px;
  white-space: nowrap;
}

/* ===== Phase 3 追加スタイル ===== */


/* 保存ボタンを画面下部に固定(お気に入り編集画面) */
/* モーダルの補足テキスト */
.modal-desc {
  font-size: 13px;
  color: #5A8AA8;
  margin: -6px 0 8px;
}

/* 日課モーダル: タイトル行（タイトル＋ヒントボタン） */
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}
.modal-title-row .modal-title {
  margin-bottom: 0;
}

/* ヒントボタン */
.hint-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #5A8AA8;
  background: transparent;
  color: #5A8AA8;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.hint-btn:hover {
  background: #5A8AA8;
  color: #fff;
}

/* ヒントパネル */
.hint-panel {
  display: none;
  background: #F0F8FF;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0 4px;
}
.hint-panel.open {
  display: block;
}
.hint-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: #2B6CB0;
  margin: 0 0 10px;
}
.hint-panel-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.hint-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hint-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 56px;
  text-align: center;
}
.hint-badge-orange {
  background: #FEF0E0;
  color: #B7650A;
}
.hint-badge-red {
  background: #FDE8E8;
  color: #C53030;
}
.hint-panel-text {
  font-size: 13px;
  color: #2D4A6A;
}
.hint-panel-note {
  font-size: 11px;
  color: #7A9BB0;
  margin: 0;
}

/* ダークモード対応 */
body.dark-mode .hint-btn {
  border-color: #5A8AA8;
  color: #5A8AA8;
}
body.dark-mode .hint-btn:hover {
  background: #5A8AA8;
  color: #1A2A3A;
}
body.dark-mode .hint-panel {
  background: #1A2E40;
}
body.dark-mode .hint-panel-title { color: #7ABFDF; }
body.dark-mode .hint-panel-text  { color: #A8CCDF; }
body.dark-mode .hint-panel-note  { color: #5A7A8A; }
body.dark-mode .hint-badge-orange { background: #3A2510; color: #F0A855; }
body.dark-mode .hint-badge-red    { background: #3A1515; color: #F08080; }

/* くり返し(当日達成済み)/ 達成一度きり(達成済み・二度と達成不可) */
.wish-item-done {
  opacity: 0.55;
}
/* 打ち消し線は「二度と達成できない」方(達成一度きり)だけに付ける。
   くり返しは翌日リセットされるだけなので付けない。 */
.wish-item-done-permanent .task-row-name {
  text-decoration: line-through;
}

/* 月内再設定コスト注記 */
.modal-cost-note {
  font-size: 12px;
  color: #C0703F;
  background: #FBEAE2;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.6;
  margin-top: 4px;
}

/* 日課の初回設定モーダル: ペナルティ説明を目立たせる注意書き
   (?ヒントパネルの奥に隠さず、設定時に必ず目に入るようにする) */
.daily-setup-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #A8462F;
  background: #FDECE4;
  border: 1px solid #F3C4AE;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.6;
  margin: 4px 0 12px;
}
.daily-setup-notice i {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}
.daily-setup-notice p {
  margin: 0;
}
body.dark-mode .daily-setup-notice {
  color: #F0A88F;
  background: #3A241C;
  border-color: #5A3626;
}

/* Drive復元ポイントへの導線: 目立たせすぎないよう、控えめな青字テキストリンクにする */
.drive-revisions-link {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  padding: 6px;
  margin-top: 2px;
  font-size: 13px;
  color: #5A8AA8;
  cursor: pointer;
}
body.dark-mode .drive-revisions-link { color: #7FB8DA; }

/* Drive復元ポイント一覧 */
.revisions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 8px;
}
.revision-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0.5px solid #E3F0F6;
}
.revision-info {
  min-width: 0;
}
.revision-time {
  font-size: 14px;
  font-weight: 700;
  color: #2C4A5A;
}
.revision-summary {
  font-size: 12px;
  color: #6B8A99;
  margin-top: 2px;
}
.revision-restore-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #2F7FB8;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.revision-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.revision-delete-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: none;
  color: #C0703F;
  cursor: pointer;
}
.revision-delete-btn i { font-size: 16px; }
body.dark-mode .revision-delete-btn { color: #E0A98C; }
.revisions-empty {
  font-size: 13px;
  color: #6B8A99;
  text-align: center;
  padding: 20px 0;
}
body.dark-mode .revision-item { border-color: #22323C; }
body.dark-mode .revision-time { color: #E4F1F8; }
body.dark-mode .revision-summary { color: #7A9BB0; }
body.dark-mode .revisions-empty { color: #7A9BB0; }

/* 目標選択モーダルのリスト項目 */
.goal-wish-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 0.5px solid #E3F0F6;
  cursor: pointer;
  transition: background 0.15s;
}

.goal-wish-item:hover {
  background: #EAF6FB;
}

.goal-wish-item.selected {
  border-color: #E0A800;
  background: #FBF2D5;
}

.goal-wish-item-info {
  flex: 1;
  min-width: 0;
}

.goal-wish-item-name {
  font-size: 13px;
  font-weight: 500;
  color: #1A3A52;
  margin: 0 0 2px;
}

.goal-wish-item-cost {
  font-size: 11px;
  color: #A9C7D6;
  margin: 0;
}

/* お気に入り編集のグループチップ */
#favGroupChips {
  margin-bottom: 8px;
}

/* ===== アイコン選択UI ===== */
.icon-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.icon-preview-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #EAF6FB;
  border: 1.5px solid #D8EAF2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 24px;
}

.icon-preview-circle i {
  font-size: 24px;
  width: 24px;
  height: 24px;
  filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg);
}

/* アイコンピッカーグリッド */
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.icon-picker-item {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid #E3F0F6;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-size: 20px;
}

.icon-picker-item i {
  width: 20px;
  height: 20px;
  font-size: 20px;
  filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg);
}

.icon-picker-item:hover {
  background: #EAF6FB;
  border-color: #B9D6E8;
}

.icon-picker-item.selected {
  background: #2F7FB8;
  border-color: #2F7FB8;
}

.icon-picker-item.selected i {
  filter: brightness(0) invert(1);
}

.icon-picker-item:active {
  transform: scale(0.9);
}

/* ===== Phase 4 / UI修正 ===== */

/* 行右端の編集ボタン */
.row-edit-btn {
  background: none;
  border: none;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.row-edit-btn i {
  font-size: 16px;
  width: 16px;
  height: 16px;
  filter: invert(55%) sepia(20%) saturate(400%) hue-rotate(175deg);
}

.row-edit-btn:hover { background: #EAF6FB; }
.row-edit-btn:active { transform: scale(0.9); }

.row-timer-btn {
  background: none;
  border: none;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.row-timer-btn i {
  font-size: 16px;
  width: 16px;
  height: 16px;
  filter: invert(55%) sepia(60%) saturate(500%) hue-rotate(345deg);
}
.row-timer-btn:hover { background: #FBEFEA; }
.row-timer-btn:active { transform: scale(0.9); }

/* --- 達成チェックの視認性改善 --- */

/* 1日1回 達成済み: 白チェックマーク on 濃い青 */
.task-check.checked {
  background: #1A5F8A;
  border-color: #1A5F8A;
}

.task-check.checked i {
  font-size: 14px;
  width: 14px;
  height: 14px;
  /* 白 */
  filter: brightness(0) invert(1);
}

/* Task達成(removeOnDone=true だが一瞬表示): 水色チェック on 薄い水色 */
.task-check.done-task {
  background: #B9D6E8;
  border-color: #7FBCD8;
}

.task-check.done-task i {
  font-size: 14px;
  width: 14px;
  height: 14px;
  /* 白 */
  filter: brightness(0) invert(1);
}

/* ドラッグハンドルを細めに(editボタンと干渉しない) */
.task-grip {
  padding: 4px 2px;
}

/* お気に入り達成済みアイコン: もっと濃い青で強調 */
.fav-icon-circle.fav-icon-done {
  background: #1A5F8A;
  box-shadow: 0 2px 6px rgba(26,95,138,0.35);
}


/* 周回・Task達成済みのお気に入りアイコン(水色) */
.fav-icon-circle.fav-icon-soft {
  background: #B9D6E8;
  border: 1.5px solid #7FBCD8;
}
.fav-icon-circle.fav-icon-soft i {
  filter: brightness(0) invert(1);
}

/* ===== Wish行のアイコン =====
   タスクアイコンより少し小さめでWishテーマ色(暖色系) */
.wish-icon-circle {
  background: #FBEAE2 !important;
}
.wish-icon-circle i {
  filter: invert(45%) sepia(60%) saturate(500%) hue-rotate(340deg) brightness(95%) !important;
}

/* Wish金額(消費=暖色、無料=薄グレー) */
.wish-cost { color: #C0703F !important; }

/* Wishグループバッジ(デフォルトグループは薄い暖色) */
.badge-wish-group {
  background: #FBF2D5;
  color: #9A7214;
}

/* Wishカテゴリ表示 */
.badge-wish-goal  { background: #EEEDFE; color: #7F77DD; }

/* ===== 設定画面 ===== */
.setting-desc {
  font-size: 11px;
  color: #A9C7D6;
  margin: 2px 0 10px;
}

.drive-sync-status {
  font-size: 11px;
  margin: -4px 0 10px;
  min-height: 14px;
  transition: color .2s ease;
  color: #A9C7D6;
}
.drive-sync-status.is-saving { color: #A9C7D6; }
.drive-sync-status.is-saved  { color: #1D9E75; }
.drive-sync-status.is-error  { color: #D9685F; }

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid #F0F7FC;
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
  font-size: 13px;
  color: #1A3A52;
  flex: 1;
}

.setting-value {
  font-size: 12px;
  color: #5A8AA8;
  min-width: 32px;
  text-align: right;
}

/* ===== 設定画面「タブ表示」: タスク/ご褒美と各タブを一目で区別できるように =====
   以前はどの行も同じ.setting-labelの文字だけで並んでいて、タスク側と
   ご褒美側の境目や、タブの種類が読み取りにくかった。左のカラーバー+見出し
   アイコンでタスク/ご褒美のグループを分け、各行にもカテゴリ色のアイコンを
   添えて見分けやすくした。 */
.tab-display-group {
  padding-left: 10px;
  border-left: 3px solid transparent;
  margin-top: 18px;
}
.tab-display-group:first-child { margin-top: 0; }
.tab-display-group--task { border-left-color: #E07B4F; }
.tab-display-group--wish { border-left-color: #E37FA0; }

.tab-display-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.tab-display-group--task .tab-display-heading { color: #E07B4F; }
.tab-display-group--wish .tab-display-heading { color: #E37FA0; }

.tab-row-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
/* 色はタスク/Wishの既存カテゴリバッジ(.badge-task/.badge-habit/.badge-daily)と揃えている */
.tab-row-icon.icon-neutral { background: #EEF4F8; color: #6B8A99; }
.tab-row-icon.icon-task    { background: #EEEDFE; color: #7F77DD; }
.tab-row-icon.icon-habit   { background: #EAF6FB; color: #2F7FB8; }
.tab-row-icon.icon-daily   { background: #FAEEDA; color: #BA7517; }

/* トグルスイッチ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #D8EAF2;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

.toggle-switch input:checked + .toggle-slider {
  background: #2F7FB8;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* 音量スライダー */
.volume-slider {
  flex: 1;
  accent-color: #2F7FB8;
  height: 4px;
}

/* 危険ゾーンカード */
.card-danger {
  border: 1px solid #FBDDD9;
}

/* ===== 履歴画面 ===== */
.history-tabs {
  display: flex;
  gap: 0;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  border: 0.5px solid #E3F0F6;
}

.history-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 500;
  color: #A9C7D6;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.history-tab.active {
  background: #2F7FB8;
  color: #FFFFFF;
}

.hist-tab-content { display: none; }
.hist-tab-content.active { display: block; }

/* LocalStorage保存ステータス表示 */
.save-status {
  font-size: 11px;
  color: #A9C7D6;
  text-align: right;
  padding: 4px 0 8px;
}

/* ===== ダークモード ===== */
body.dark-mode {
  background: #121820;
  color: #D0E4EF;
}

body.dark-mode .app { background: #121820; }

body.dark-mode .card,
body.dark-mode .modal-box,
body.dark-mode .history-tabs,
body.dark-mode .task-row,
body.dark-mode .wish-row,
body.dark-mode .list-item.current,
body.dark-mode .wish-goal-card,
body.dark-mode .history-row,
body.dark-mode .fav-card {
  background: #1E2A36;
  border-color: #2D3D4E;
}

body.dark-mode .history-row-name { color: #D0E4EF; }
body.dark-mode .history-row-date { color: #6B8CA0; }

body.dark-mode .icon-btn,
body.dark-mode .search-box,
body.dark-mode .tab-chip {
  background: #1E2A36;
  border-color: #2D3D4E;
  color: #A9C7D6;
}

body.dark-mode .tab-chip.active { background: #2F7FB8; color: #FFFFFF; border-color: #2F7FB8; }

/* フォルダ・自作タグ(暖色系)はダークモードでも青にせず、暖色のまま保つ */
body.dark-mode .tab-chip.custom-group {
  background: #3A2A1E;
  color: #E0956B;
  border-color: #4A3527;
}
body.dark-mode .tab-chip.custom-group.active {
  background: #C77B48;
  color: #FFFFFF;
  border-color: #C77B48;
}
body.dark-mode .tab-chip.folder-chip i:not(.folder-caret) {
  background-color: #E0956B;
}

body.dark-mode .balance,
body.dark-mode .task-row-name,
body.dark-mode .item-name,
body.dark-mode .edit-title,
body.dark-mode .modal-title,
body.dark-mode .history-tab,
body.dark-mode .setting-label,
body.dark-mode .option-row span,
body.dark-mode .fav-card span,
body.dark-mode .goal-wish-item-name { color: #D0E4EF; }

body.dark-mode .label,
body.dark-mode .sub-label,
body.dark-mode .section-title,
body.dark-mode .count-label,
body.dark-mode .bar-chart-val,
body.dark-mode .bar-chart-label { color: #7A9BB0; }

body.dark-mode .task-icon-circle,
body.dark-mode .fav-icon-circle,
body.dark-mode .wish-goal-icon,
body.dark-mode .icon-preview-circle { background: #243140; }

body.dark-mode .bar-chart-bar { filter: brightness(0.85); }

body.dark-mode .text-input,
body.dark-mode .search-box input { background: #243140; border-color: #2D3D4E; color: #D0E4EF; }
body.dark-mode .text-input::placeholder { color: #4A6A80; }

body.dark-mode .bottom-btn { background: linear-gradient(135deg, #1A5F8A 0%, #2F7FB8 100%); }

body.dark-mode .sticky-header { background: #121820; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.dark-mode .daily-record-sticky-top,
body.dark-mode .history-sticky-top { background: #121820; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

body.dark-mode .modal-overlay::before { background: rgba(0,10,20,0.65); }

body.dark-mode .setting-row { border-bottom-color: #2D3D4E; }
body.dark-mode .card-danger { border-color: #4A2A2A; }

body.dark-mode .history-tab { color: #7A9BB0; }
body.dark-mode .history-tab.active { background: #2F7FB8; color: #FFFFFF; }

/* ダークモード: add-chip(+)を白に */
body.dark-mode .tab-chip.add-chip { color: #FFFFFF; }
body.dark-mode .tab-chip.add-chip i { filter: brightness(0) invert(1); }

/* 通常モード: 追加ボタン(+追加)のアイコンも白に */
.btn-primary .ti,
.btn-primary i { filter: brightness(0) invert(1) !important; }

/* 設定・履歴画面: .appのpaddingを上側だけ無効化してsticky-headerが最上部に */
#settings.screen.active,
#historyScreen.screen.active,
#dailyRecord.screen.active {
  margin-top: calc(-1 * var(--app-padding));
  padding-top: 0;
}
/* .screensの外(.app直下)にある画面(設定・履歴・日課の記録・使い方ガイド・タグ編集など)では、
   空になった.screensの下余白(ナビバー用の84px)がそのまま画面の上部の空白になってしまう。
   これらの画面を表示中は0にする。(以前は日課の記録ページだけに指定していたため、他の画面で上が空いていた) */
.screens:has(~ .screen.active) {
  padding-bottom: 0;
}
/* 使い方ガイドの3画面: ヘッダーが画面上端の青い帯なので、.appの上padding(16px)も打ち消して最上部に詰める
   (設定・履歴と同じ手法) */
#tutorial.screen.active,
#tutorialSubmenu.screen.active,
#tutorialDetail.screen.active {
  margin-top: calc(-1 * var(--app-padding));
  padding-top: 0;
}

/* sticky-headerは.appのpadding分だけ左右の計算がずれるので補正 */
#settings .sticky-header,
#historyScreen .sticky-header,
#historyScreen .history-sticky-top {
  margin-left: calc(-1 * var(--app-padding));
  margin-right: calc(-1 * var(--app-padding));
  padding-left: var(--app-padding);
  padding-right: var(--app-padding);
  width: calc(100% + var(--app-padding) * 2);
  box-sizing: border-box;
}

/* タスク・ご褒美画面: Taskポイント〜履歴/削除の行までをまとめて上に固定し、
   項目の一覧だけがスクロールする(履歴画面の .history-sticky-top と同じ考え方)。
   画面上端の余白(.appのpadding)ごと覆うため、画面側の上paddingを0にして
   この固定部分の上paddingに移している(下の「設定・履歴画面」の上書きと同じ手法)。 */
#wish.screen.active,
#taskManage.screen.active {
  margin-top: calc(-1 * var(--app-padding));
  padding-top: 0;
}
.list-sticky-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #EAF6FB;
  margin-left: calc(-1 * var(--app-padding));
  margin-right: calc(-1 * var(--app-padding));
  width: calc(100% + var(--app-padding) * 2);
  box-sizing: border-box;
  padding: var(--app-padding) var(--app-padding) 2px;
  margin-bottom: 8px;
}
body.dark-mode .list-sticky-top { background: #121820; }

/* ===== ログイン画面 ===== */
#loginScreen.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin-top: 0;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 24px 0;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2F7FB8, #4FA0D8);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 32px;
  box-shadow: 0 6px 20px rgba(47,127,184,0.35);
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-logo-icon i {
  width: 32px;
  height: 32px;
  font-size: 32px;
  filter: brightness(0) invert(1);
}

.login-app-name {
  font-size: 26px;
  font-weight: 700;
  color: #1A3A52;
  margin: 0 0 4px;
}

.login-app-sub {
  font-size: 13px;
  color: #6B8A99;
  margin: 0;
}

.login-tabs {
  display: flex;
  gap: 0;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  border: 0.5px solid #E3F0F6;
}

.login-tab {
  flex: 1;
  padding: 9px 0;
  font-size: 13px;
  font-weight: 500;
  color: #A9C7D6;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.login-tab.active {
  background: #2F7FB8;
  color: #FFFFFF;
}

.login-error {
  font-size: 12px;
  color: #D9685F;
  background: #FBEFEF;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #A9C7D6;
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #E3F0F6;
}

/* ログイン画面のチュートリアル案内(小さく・でも目に留まりやすい位置) */
.login-tutorial-hint {
  margin-top: 16px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: #6B7C8C;
}
.login-tutorial-hint a {
  color: #2F7FB8;
  font-weight: 700;
  text-decoration: none;
}
body.dark-mode .login-tutorial-hint { color: #7A9BB0; }
body.dark-mode .login-tutorial-hint a { color: #6FB5E0; }

/* 設定画面のチュートリアル導線カード */
.settings-tutorial-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.settings-tutorial-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2F7FB8, #4FA0D8);
  font-size: 18px;
  flex-shrink: 0;
}
.settings-tutorial-link-icon i { filter: brightness(0) invert(1); } /* SVGアイコンはcurrentColor非対応のため反転で白にする */
.settings-tutorial-link-title { font-size: 14px; font-weight: 700; color: #1A3A52; }
.settings-tutorial-link-sub { font-size: 11.5px; color: #6B7C8C; margin-top: 2px; }
.settings-tutorial-link-arrow { color: #B9D6E6; font-size: 16px; margin-left: auto; flex-shrink: 0; }
body.dark-mode .settings-tutorial-link-title { color: #EAF6FB; }
body.dark-mode .settings-tutorial-link-sub { color: #7A9BB0; }

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px;
  border: 1.5px solid #E3F0F6;
  border-radius: 10px;
  background: #FFFFFF;
  font-size: 14px;
  font-weight: 500;
  color: #1A3A52;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-google:hover { background: #F5F9FC; }
.btn-google:active { transform: scale(0.98); }

.btn-skip {
  width: 100%;
  padding: 10px;
  background: none;
  border: none;
  font-size: 12px;
  color: #A9C7D6;
  cursor: pointer;
  margin-top: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ダークモード対応 */
body.dark-mode .login-app-name  { color: #D0E4EF; }
body.dark-mode .login-app-sub   { color: #7A9BB0; }
body.dark-mode .btn-google      { background: #1E2A36; border-color: #2D3D4E; color: #D0E4EF; }
body.dark-mode .login-tabs      { background: #1E2A36; border-color: #2D3D4E; }
body.dark-mode .login-tab       { color: #7A9BB0; }

/* ===== ダークモード追加修正 ===== */

/* 目標選択: 選択中の項目テキストを暗めに(黄背景上で読めるよう) */
body.dark-mode .goal-wish-item.selected {
  background: #3A3000;
  border-color: #C8940A;
}
body.dark-mode .goal-wish-item.selected .goal-wish-item-name {
  color: #E8C840 !important;
}
body.dark-mode .goal-wish-item.selected .goal-wish-item-cost {
  color: #A88E30;
}

/* グループ管理モーダルの項目テキスト(暖色背景上で読めるよう) */
body.dark-mode .modal-group-item {
  background: #3A1E10;
  border: 0.5px solid #6A3820;
}
body.dark-mode .modal-group-item .item-name {
  color: #E8A070 !important;
}

/* タスク/Wishの追加・編集モーダルのラベル */
body.dark-mode .modal-box .sub-label,
body.dark-mode .modal-box .modal-desc { color: #7A9BB0; }

/* ===== 履歴取り消しボタン ===== */
.history-undo-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.history-undo-btn i {
  font-size: 18px;
  width: 18px;
  height: 18px;
  filter: invert(55%) sepia(20%) saturate(400%) hue-rotate(175deg);
}

.history-undo-btn:hover { background: #EAF6FB; }
.history-undo-btn:active { transform: scale(0.9); }

body.dark-mode .history-undo-btn:hover { background: #243140; }

/* ===== グループタブのドラッグ並び替え ===== */
.tab-chip.dragging-chip { opacity: 0.4; }
.tab-chip.chip-armed {
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(23, 56, 74, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

/* ===== グループの「フォルダ」機能 ===== */

/* タブバー上のフォルダチップ */
.tab-chip.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-chip.folder-chip i:not(.folder-caret) {
  background-image: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M5%204h4l3%203h7a1%201%200%200%201%201%201v8a1%201%200%200%201-1%201h-14a1%201%200%200%201-1-1v-11a1%201%200%200%201%201-1%22%2F%3E%3C%2Fsvg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M5%204h4l3%203h7a1%201%200%200%201%201%201v8a1%201%200%200%201-1%201h-14a1%201%200%200%201-1-1v-11a1%201%200%200%201%201-1%22%2F%3E%3C%2Fsvg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  background-color: #C0703F; /* フォルダタイトル(未選択)と同じ橙色 */
}
.tab-chip.folder-chip.active i:not(.folder-caret) {
  background-color: #FFFFFF; /* フォルダタイトル(選択時)と同じ白色 */
}
.tab-chip.matome-chip i:not(.folder-caret) {
  background-color: #1F5C8A; /* まとめフォルダは専用の濃い青 */
}
.tab-chip.matome-chip.active i:not(.folder-caret) {
  background-color: #FFFFFF;
}
.tab-chip.folder-chip .folder-chip-name {
  white-space: nowrap;
}
.tab-chip.folder-chip .folder-caret {
  font-size: 12px;
  opacity: 0.7;
}

/* フォルダ展開時に出てくる2段目のサブグループ行 */
.folder-sub-wrap {
  margin-top: -6px;
}
.tab-chips.folder-sub-chips {
  padding-left: 8px;
  border-left: 2px solid #F4D9CB;
}
.tab-chip.sub-chip {
  font-size: 11px;
  padding: 6px 12px;
}
.folder-empty-hint {
  font-size: 11px;
  color: #9BB6C4;
  white-space: normal;
  padding: 6px 4px;
  line-height: 1.5;
}

/* タスク/Wish行をドラッグしてグループタブの上に来た時のハイライト */
.tab-chip.chip-drop-target {
  background: #2F7FB8 !important;
  color: #FFFFFF !important;
  border-color: #2F7FB8 !important;
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.4);
}
.tab-chip.custom-group.chip-drop-target,
.tab-chip.folder-chip.chip-drop-target {
  background: #E07B4F !important;
  border-color: #E07B4F !important;
  box-shadow: 0 2px 8px rgba(224, 123, 79, 0.4);
}

/* グループ編集モーダル: フォルダのヘッダー行 */
.modal-folder-header {
  background: #FFF3EC;
  border: 1px solid #F4D9CB;
  margin-bottom: 4px;
}
.modal-folder-header.dragging { opacity: 0.4; }

/* グループ編集モーダル: フォルダの中身ボックス(インデント表示) */
.modal-folder-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px 20px;
  padding: 8px;
  border-left: 2px dashed #E8C4B0;
  min-height: 12px;
}
.modal-folder-body.modal-root-list {
  margin-left: 0;
  border-left: none;
  padding: 0;
}
.modal-folder-body .modal-group-item { margin: 0; }
.modal-folder-body .folder-empty-hint {
  color: #B49B8C;
  font-size: 12px;
  padding: 4px 2px;
}
.modal-root-label {
  margin: 4px 0 4px 2px !important;
}

body.dark-mode .modal-folder-header {
  background: #3A1E10;
  border-color: #6A3820;
}
body.dark-mode .modal-folder-body {
  border-left-color: #6A3820;
}
body.dark-mode .folder-sub-chips {
  border-left-color: #6A3820;
}

/* ===== ドラッグ中に指/カーソルへ追従する「浮くゴースト」 ===== */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -130%) rotate(-3deg);
  pointer-events: none;
  z-index: 9999;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(20, 60, 90, 0.25);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #2F7FB8;
  border: 1.5px solid #2F7FB8;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.08s ease-out;
}
.drag-ghost i { font-size: 16px; flex-shrink: 0; }
.drag-ghost.ghost-drop-ready {
  transform: translate(-50%, -130%) rotate(-3deg) scale(1.12);
  background: #2F7FB8;
  color: #FFFFFF;
}
.drag-ghost.ghost-folder,
.drag-ghost.ghost-group {
  color: #C0703F;
  border-color: #E8A6A0;
}

body.dark-mode .drag-ghost {
  background: #1E2A36;
  color: #7FC4EE;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
body.dark-mode .drag-ghost.ghost-folder,
body.dark-mode .drag-ghost.ghost-group {
  color: #E8A070;
}

/* グループ管理モーダル: ドラッグ中に重なっているフォルダの中身エリアを強調 */
.modal-folder-body.folder-body-target {
  border-left-color: #2F7FB8;
  background: #EAF6FB;
}
body.dark-mode .modal-folder-body.folder-body-target {
  background: #1E2A36;
  border-left-color: #7FC4EE;
}

/* ===== 右下固定の追加ボタン(FAB) ===== */
.fab-add-btn {
  position: fixed;
  right: max(20px, calc(50vw - 240px + 20px));
  bottom: var(--fab-bottom-offset);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%);
  color: #FFFFFF;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(47, 127, 184, 0.45);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.1s;
}
.fab-add-btn:active { transform: scale(0.92); }
.fab-add-btn .ti-plus {
  /* アイコンはbackground-image(SVG)方式なのでcolorでは効かない。
     filterで常に白にする(ダークモードでも白のまま)。 */
  filter: brightness(0) invert(1);
}

/* ===== 一括削除ボタン(FABの左隣に固定、削除モード中のみ表示) ===== */
.bulk-delete-btn {
  position: fixed;
  right: max(20px, calc(50vw - 240px + 20px));
  transform: translateX(-72px);
  bottom: var(--fab-bottom-offset);
  height: 56px;
  padding: 0 18px;
  border-radius: 28px;
  border: none;
  background: #D9685F;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(217, 104, 95, 0.45);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.1s;
}
.bulk-delete-btn:active { transform: translateX(-72px) scale(0.94); }

body.dark-mode .fab-add-btn {
  background: linear-gradient(135deg, #1A5F8A 0%, #2F7FB8 100%);
}

/* ===== タイマーモードボタン(左下に固定) =====
   追加ボタン(右下)のすぐ近くだと誤タップしやすいため、Wish画面の
   「使用金額」ボタン(.fab-amount-btn)と同じく画面左下に独立して配置する。
   使用頻度が低いボタンなので、あえて追加ボタンから離す方針。
   位置の基準(--amount-fab-left / --fab-bottom-offset)もfab-amount-btnと共通。
   サイズはfab-add-btnと同一(56px角の円形)。色は追加ボタンより少し薄めの水色。 */
.fab-timer-btn {
  position: fixed;
  left: var(--amount-fab-left);
  bottom: var(--fab-bottom-offset);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6FB6E0 0%, #9FD3ED 100%);
  color: #FFFFFF;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(111, 182, 224, 0.4);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.1s;
}
.fab-timer-btn:active { transform: scale(0.92); }
.fab-timer-btn i {
  /* アイコンはbackground-image(SVG)方式なのでcolorでは効かない。
     filterで常に白にする(ダークモードでも白のまま)。 */
  filter: brightness(0) invert(1);
}
body.dark-mode .fab-timer-btn {
  background: linear-gradient(135deg, #3E7FA8 0%, #6FB6E0 100%);
}

/* ===== 連続入力(クイック追加)行 ===== */
.quick-add-row-wrapper { display: flex; align-items: center; }
.quick-add-row {
  flex: 1;
  border: 1.5px dashed #B9D6E8;
  background: #F5FBFD;
}
body.dark-mode .quick-add-row {
  border-color: #3A5A70;
  background: #16232E;
}
.quick-add-info { flex: 1; min-width: 0; }
.quick-add-name-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px; /* iOSのズーム防止 */
  font-weight: 600;
  color: #17384A;
  padding: 4px 0;
}
.quick-add-name-input:focus { outline: none; }
body.dark-mode .quick-add-name-input { color: #DCEEF7; }

.quick-add-reward-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  background: #EAF6FB;
  border-radius: 8px;
  padding: 4px 8px;
}
body.dark-mode .quick-add-reward-wrap { background: #1E2A36; }
.quick-add-yen { font-size: 13px; color: #6E96A8; }
.quick-add-reward-input {
  width: 64px;
  border: none;
  background: transparent;
  font-size: 16px; /* iOSのズーム防止 */
  font-weight: 600;
  color: #2F7FB8;
  text-align: right;
  padding: 2px 0;
}
.quick-add-reward-input:focus { outline: none; }

/* ===== 「ファイル」機能(タグごとに項目を直接まとめる入れ物、リマインダー風の縦並びリスト) ===== */
.file-strip-wrap {
  position: relative;
  margin-bottom: 12px;
}
.file-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.file-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #EAF6FB;
  border: 1px solid #D2E9F3;
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #17384A;
  cursor: pointer;
  user-select: none;
  text-align: left;
  width: 100%;
  min-width: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.file-row-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2F7FB8;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-row-icon i { font-size: 14px; filter: brightness(0) invert(1); }
.file-row-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row-count {
  flex-shrink: 0;
  font-size: 12px;
  color: #6E96A8;
}
.file-row-chevron {
  flex-shrink: 0;
  font-size: 14px;
  color: #A9C7D6;
}
.file-row.active {
  background: #2F7FB8;
  border-color: #2F7FB8;
  color: #FFFFFF;
}
.file-row.active .file-row-icon { background: #FFFFFF; }
.file-row.active .file-row-icon i { filter: none; }
.file-row.active .file-row-count,
.file-row.active .file-row-chevron { color: #EAF6FB; }
.file-row-chevron { transition: transform 0.15s; }
.file-row.active .file-row-chevron { transform: rotate(90deg); }

/* 名前をその場で編集中の行(作成直後・メニューの「名前を変更」) */
.file-row.renaming {
  cursor: default;
  background: #FFFFFF;
  border-color: #B9D6E8;
}
.file-row .file-name-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  border-bottom: 1px solid #B9D6E8;
  background: transparent;
  font-size: 16px; /* iOSのズーム防止(全テキスト入力共通の統一値) */
  color: #17384A;
  padding: 4px 0;
}
.file-row .file-name-input:focus { outline: none; border-bottom-color: #2F7FB8; }

/* 長押しが成立した行(離すとメニュー、動かすと並び替え) */
.file-row.file-pressing { transform: scale(1.02); box-shadow: 0 4px 12px rgba(23, 56, 74, 0.2); }
.file-row.dragging { opacity: 0.85; z-index: 5; }
.file-row { touch-action: pan-y; -webkit-touch-callout: none; }

/* 削除モード中: ファイル行にもチェックボックスを出す(行全体のタップでも切り替わる) */
.file-delete-checkbox {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  accent-color: #D9685F;
  cursor: pointer;
}

.file-row.chip-drop-target {
  background: #2F7FB8 !important;
  color: #FFFFFF !important;
  border-color: #2F7FB8 !important;
  transform: scale(1.02);
}

/* 長押しで出すファイルのメニュー(名前変更 + 色の選択) */
.file-color-picker {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 172px;
  padding: 8px;
  background: #FFFFFF;
  border: 1px solid #D2E9F3;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(23, 56, 74, 0.18);
  top: calc(100% + 4px);
  left: 0;
}
.file-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.file-menu-rename {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: #EAF6FB;
  color: #2F7FB8;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.file-menu-rename i { font-size: 15px; filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg); }
body.dark-mode .file-menu-rename { background: #1E2A36; color: #7FC4EE; }
body.dark-mode .file-menu-rename i { filter: invert(70%) sepia(30%) saturate(500%) hue-rotate(175deg); }
.file-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}
.file-color-swatch.selected {
  border-color: #17384A;
}
body.dark-mode .file-color-picker {
  background: #16232E;
  border-color: #2B4256;
}
body.dark-mode .file-color-swatch.selected { border-color: #DCEEF7; }

body.dark-mode .file-row {
  background: #16232E;
  border-color: #2B4256;
  color: #DCEEF7;
}
body.dark-mode .file-row-count { color: #6E96A8; }
body.dark-mode .file-row-chevron { color: #3A5A70; }
body.dark-mode .file-row.active {
  background: #2F7FB8;
  color: #FFFFFF;
}
body.dark-mode .file-row.renaming {
  background: #1E2A36;
  border-color: #2B4256;
}
body.dark-mode .file-row .file-name-input {
  color: #DCEEF7;
  border-bottom-color: #3A5A70;
}
/* ＋ボタン長押しで、その真上に出るファイル追加ボタン(FABと同サイズ・同じ右端)
   ＋の上に重ねて出すので、押したまま上へスライドして離すだけで作れる */
.fab-file-btn {
  position: fixed;
  right: max(20px, calc(50vw - 240px + 20px));
  bottom: calc(var(--fab-bottom-offset) + 72px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6FB6E0 0%, #9FD3ED 100%);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(111, 182, 224, 0.45);
  cursor: pointer;
  z-index: 91;
  transition: transform 0.12s;
}
.fab-file-btn.show { display: flex; }
.fab-file-btn.hover { transform: scale(1.18); }
.fab-file-btn i {
  font-size: 24px;
  /* アイコンはbackground-image(SVG)方式なのでcolorでは効かない。常に白にする */
  filter: brightness(0) invert(1);
}
body.dark-mode .fab-file-btn { background: linear-gradient(135deg, #3E7FA8 0%, #6FB6E0 100%); }
.fab-add-btn { touch-action: none; -webkit-touch-callout: none; user-select: none; }
.fab-add-btn.fab-pressing { transform: scale(0.92); }

/* タスク/Wish行: 削除モード中のチェックボックス(一括削除用)
   誤操作防止のため即削除ではなくチェック→まとめて削除の方式にする */
.task-delete-checkbox {
  position: absolute;
  left: -44px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  z-index: 1;
  transition: left 0.2s ease;
  accent-color: #D9685F;
  cursor: pointer;
}
.task-row-wrapper.delete-mode .task-delete-checkbox { left: 6px; }


/* =========================================================
   通知設定UI (notification.js)
   ========================================================= */

/* 通知カード */
.notif-card {
  margin-top: 0;
}

/* 【追加】常時通知/常時カレンダー追加ONでクイック追加した直後、
   通知セクションへスクロールしたときに軽く知らせるハイライト */
@keyframes notifHighlightPulse {
  0%   { box-shadow: 0 0 0 0 rgba(47,127,184,0.35); }
  70%  { box-shadow: 0 0 0 10px rgba(47,127,184,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,127,184,0); }
}
.notif-highlight-pulse {
  animation: notifHighlightPulse 0.9s ease-out 2;
}

/* 通知ヘッダー行（ラベル + トグル） */
.notif-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 展開ボディ */
.notif-body {
  padding-top: 2px;
}

/* 日付・時刻 input 共通ベース
   .text-input を継承せず独自定義（はみ出し防止）
   width:100% + box-sizing:border-box でカード内に収める */
.notif-date-input,
.notif-time-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid #D8EAF2;
  border-radius: 10px;
  background: #F5FBFE;
  color: #1A3A52;
  outline: none;
  color-scheme: light;
  /* iOS のデフォルト装飾をリセット */
  -webkit-appearance: none;
  appearance: none;
}

.notif-date-input:focus,
.notif-time-input:focus {
  border-color: #2F7FB8;
}

/* 複数日程リスト(繰り返し「なし」のとき) */
.notif-dates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.notif-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-date-row .notif-date-input { flex: 1; }
.notif-date-remove-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1.5px solid #E8A6A0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
}
.notif-date-remove-btn i { filter: invert(30%) sepia(80%) saturate(600%) hue-rotate(320deg); }
body.dark-mode .notif-date-remove-btn {
  background: #1E2A36;
  border-color: #5A3B3B;
}

/* 設定画面のデフォルト時刻 inputは幅を auto に */
#settingDefaultReminderTime {
  display: inline-block;
  width: auto;
  min-width: 130px;
}

/* カレンダー追加行 */
.notif-calendar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.notif-divider {
  height: 0.5px;
  background: #F0F7FC;
  margin: 14px 0;
}
body.dark-mode .notif-divider { background: #2D3D4E; }

.notif-memo-input {
  width: 100%;
  border: 0.5px solid #D8EAF2;
  background: #EAF6FB;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px; /* iOSのズーム防止 */
  color: #17384A;
  resize: vertical;
  font-family: inherit;
}
.notif-memo-input:focus { outline: none; border-color: #2F7FB8; }
body.dark-mode .notif-memo-input {
  background: #1A2A38;
  border-color: #2D3D4E;
  color: #C8DFE8;
}

.notif-calendar-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0; /* flex子要素のテキスト折り返し保証 */
}

.notif-calendar-hint {
  font-size: 11px;
  color: #A9C7D6;
  line-height: 1.4;
}

/* ダークモード対応 */
body.dark-mode .notif-date-input,
body.dark-mode .notif-time-input {
  background: #1A2A38;
  border-color: #2D3D4E;
  color: #C8DFE8;
  color-scheme: dark;
}

/* 時間入力の読み上げ欄(「5時間0分」/「25分」)。
   type="time" のダイヤルは「05:00」が5分か5時間か紛らわしく、取り違えた人がいたため、
   ダイヤルは変えずに下へ設定値を日本語で表示する。
   1時間以上のときだけ色と太さを変えるのは、取り違えると影響が大きい(5分のつもりが5時間)
   側を目立たせるため。分だけのときは控えめにして普段の操作の邪魔をしない。 */
.duration-readout {
  margin: 6px 2px 0;
  font-size: 14px;
  color: #6B8A9C;
}
.duration-readout.is-hours {
  color: #C2571A;
  font-weight: 700;
}
body.dark-mode .duration-readout { color: #7A9BB0; }
body.dark-mode .duration-readout.is-hours { color: #F0A57B; }

body.dark-mode .notif-date-input:focus,
body.dark-mode .notif-time-input:focus {
  border-color: #5BA3D0;
}

body.dark-mode .notif-calendar-hint {
  color: #4D6B80;
}

/* =========================================================
   キャラクターナビ
   ---------------------------------------------------------
   1枚の白カード(.character-timer-card)を横2カラムに分割:
   左=画像(縦いっぱい、flexのstretchでセリフ側の高さに自動追従)
   右=セリフ。
   画像とセリフ、両方タップでセリフが切り替わる(character.js側で
   #characterBar と #characterBubbleBtn の両方にリスナーを張っている)。

   【タイマーモードボタンについて】
   以前はこのカードの右上に同居していたが、タスク画面の左下
   (.fab-timer-btn、追加ボタンとは逆側の誤タップしにくい位置)に
   移動した。カード自体の大きさは変えない方針のため、min-heightで
   以前と同程度の高さを保っている。
   ========================================================= */
/* 【バグ修正1】以前はmin-heightだけを指定していたため、右のcharacter-imgが
   持つheight:100%が親の高さを正しく参照できず、画像の縦横比から逆算した
   高さがカードの高さとして採用され、異常に縦長になっていた。
   → heightを明示的な固定値にして解決済み。
   【バグ修正2】.character-bubbleにwidth:100%を指定していたが、flexアイテムの
   width:100%は「兄弟(画像)を除いた残り幅」ではなく「カード全体の幅」を
   基準に解決されてしまうため、セリフの箱が画像の分だけ右にはみ出して
   横に伸びてしまっていた。→ width指定をやめ、flex:1(残り幅を埋める)+
   min-width:0(縮小を妨げないため)に変更して解決。 */
.character-timer-card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  background: #FFFFFF;
  border-radius: 18px;
  padding: 0px 12px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(47, 127, 184, 0.12);
}
body.dark-mode .character-timer-card { background: #16232D; }

/* 左: 画像(セリフ側の高さに合わせて縦いっぱいに伸びる) */
.character-visual-btn {
  flex: 0 0 28%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s;
}
.character-visual-btn:active { transform: scale(0.97); }

.character-img {
  /* カードの高さを168px固定にしていたのをやめ、画像の縦横比に
     ぴったり合わせる形にした。幅(42%カラム)を基準に、高さは
     画像自身の比率から自動計算される(object-fitでの余白なし)。
     カード全体の高さもこの画像の実際の高さに自動で追従する。 */
  width: 100%;
  height: auto;
  display: block;
}

/* 右: セリフ(キャラクター画像より一回り小さく、最大3行分程度の高さに抑える。
   flex:1は「残り幅を埋める」ためのもの(横方向)。縦方向はalign-self:centerで
   画像の高さいっぱいに伸ばさず中央揃えにしている) */
.character-bubble {
  align-self: center;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  max-height: 88px;
  overflow-y: auto;
  background: #EAF6FB;
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  min-height: 44px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s;
}
.character-bubble:active { transform: scale(0.98); }
body.dark-mode .character-bubble { background: #1E2A36; }

.character-bubble-text {
  font-size: 14px;
  line-height: 1.4;
  color: #1A3A52;
}
body.dark-mode .character-bubble-text { color: #EAF6FB; }

/* =========================================================
   初回チュートリアル(オンボーディング)オーバーレイ
   ---------------------------------------------------------
   全画面固定(bootLoadingと同じinset:0の考え方)。
   上部=スクリーンショット、下部=キャラクターナビと同じ配色・構成
   (画像+吹き出し)で説明文を添える。色は既存の青(#2F7FB8)+白基調に揃えている。
   ========================================================= */
.onboarding-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  /* 【バグ修正】.onboarding-overlayは.appの外(兄弟要素)にあるため、
     .appのmax-width:480pxが効かず、PCの広いウィンドウ幅いっぱいに
     間延びしていた。.onboarding-slide-char-imgが幅26%指定(height:auto)
     のため、幅が広がるほどheightも比例して巨大化し、キャラ+吹き出しが
     画面を埋め尽くしてスクショ側(flex:1)がほぼ0pxに潰れて見えなく
     なっていた。.appと同じ480px幅に揃えて中央寄せすることで解消。 */
  max-width: 480px;
  z-index: 1150;
  background: #EAF6FB;
  display: flex;
  flex-direction: column;
}
body.dark-mode .onboarding-overlay { background: #121820; }

.onboarding-close-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #2F7FB8;
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.18);
  cursor: pointer;
}
.onboarding-close-btn:active { transform: scale(0.96); }
body.dark-mode .onboarding-close-btn { background: rgba(22, 35, 45, 0.92); color: #6FB6E0; }

.onboarding-track-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.onboarding-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}

.onboarding-slide {
  flex: 0 0 100%;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 68px 20px 16px;
}

.onboarding-slide-img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.onboarding-slide-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(47, 127, 184, 0.18);
}

/* 下部=キャラクターナビ(.character-timer-card)と同じ配色・構成の使い回し */
.onboarding-slide-char {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 10px;
  background: #FFFFFF;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(47, 127, 184, 0.12);
}
body.dark-mode .onboarding-slide-char { background: #16232D; }

.onboarding-slide-char-img {
  flex: 0 0 26%;
  width: 26%;
  height: auto;
  object-fit: contain;
  display: block;
}

.onboarding-slide-bubble {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: #EAF6FB;
  border-radius: 14px;
  padding: 10px 14px;
}
body.dark-mode .onboarding-slide-bubble { background: #1E2A36; }

.onboarding-slide-bubble-text {
  font-size: 14px;
  line-height: 1.5;
  color: #1A3A52;
}
body.dark-mode .onboarding-slide-bubble-text { color: #EAF6FB; }

.onboarding-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 4px 0 12px;
}

.onboarding-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #C7E0EE;
  transition: background 0.2s, width 0.2s;
}
.onboarding-dot.active { background: #2F7FB8; width: 18px; }
body.dark-mode .onboarding-dot { background: #2D3D4E; }
body.dark-mode .onboarding-dot.active { background: #6FB6E0; }

.onboarding-next-btn {
  flex: 3;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: #2F7FB8;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.onboarding-next-btn:active { transform: scale(0.98); }

/* 「戻る」ボタン。次へ(flex:3)に対して幅の比率が1:3になるようflex:1。
   間違って達成/離脱操作と混同しないよう、控えめな薄い赤系の配色にしている。 */
.onboarding-prev-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: #FBDCDC;
  color: #B84A4A;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.onboarding-prev-btn:active { transform: scale(0.98); }
.onboarding-prev-btn.is-disabled {
  opacity: 0.4;
  cursor: default;
}
.onboarding-prev-btn.is-disabled:active { transform: none; }
body.dark-mode .onboarding-prev-btn { background: #3A2323; color: #E08A8A; }

/* 戻る/次への行 + 「- ○○の詳細 -」リンクをまとめて1つの下部エリアとして扱い、
   セーフエリア分のボトムマージンをここでまとめて確保する
   (リンクボタンの有無でボトムの余白が変わってしまわないようにするため)。 */
.onboarding-footer {
  margin: 0 20px max(20px, env(safe-area-inset-bottom));
}

.onboarding-btn-row {
  display: flex;
  gap: 10px;
}

/* 使い方ガイドの該当セクションへジャンプするリンク(スライドにlinkが
   設定されているときだけJSでdisplay:blockにする)。ボタンというより
   テキストリンクに近い見た目にしてある。 */
.onboarding-link-btn {
  width: 100%;
  margin-top: 10px;
  padding: 6px;
  border: none;
  background: none;
  color: #2F7FB8;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.onboarding-link-btn:active { opacity: 0.6; }
body.dark-mode .onboarding-link-btn { color: #6FB6E0; }

/* タイマー形式: 時/分 入力 */


/* 設定画面: 「細かい設定」折りたたみ */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.collapsible-header i {
  transition: transform 0.2s;
}
.collapsible-header.open i {
  transform: rotate(180deg);
}

/* =====  実行中画面(集中モード/タイマーモード共通) ===== */
.mode-active-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 24px;
}

.mode-active-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary, #6B7C8C);
  letter-spacing: 1px;
}

.mode-timer-ring-wrap {
  position: relative;
  width: 240px;
  height: 240px;
}
.mode-timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.mode-timer-ring-bg {
  fill: none;
  stroke: rgba(120, 140, 160, 0.18);
  stroke-width: 14;
}
.mode-timer-ring-fg {
  fill: none;
  stroke: #2F7FB8;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 628.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear;
}
.mode-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mode-timer-time {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.mode-timer-reward {
  font-size: 15px;
  font-weight: 700;
  color: #E0A800;
}

/* 日課の連続未達成日数(日課名のすぐ下に表示)。
   1日未達成=薄いピンク、2日未達成=濃い赤で警戒度を表す
   (3日連続で自動リセットされるため、2日が最大表示)。 */
.daily-miss-indicator {
  font-size: 12.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}
.daily-miss-indicator.miss-warn {
  color: #E0759E;
  background: #FCE4EE;
}
.daily-miss-indicator.miss-danger {
  color: #FFFFFF;
  background: #E0455A;
}

/* ===== 日課記録ページ・詳細モーダル: 円形グラフの流用 ===== */
.daily-ring-section {
  display: flex;
  justify-content: center;
  padding: 20px 0 14px;
}
/* 詳細モーダル内は少し小さめに */
.daily-ring-wrap-small {
  width: 160px;
  height: 160px;
}
.daily-detail-rows {
  margin-top: 4px;
}

.mode-active-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
}
.mode-pause-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 28px;
  border: none;
  background: #EDF3F7;
  color: #2F7FB8;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.mode-pause-btn i { filter: invert(45%) sepia(30%) saturate(700%) hue-rotate(175deg); }
.mode-pause-btn:active { transform: scale(0.96); }

.mode-paused-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.mode-resume-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 28px;
  border: none;
  background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.mode-resume-btn i { filter: brightness(0) invert(1); }
.mode-abort-btn {
  padding: 14px 24px;
  border-radius: 28px;
  border: 1.5px solid #E8A6A0;
  background: #FFFFFF;
  color: #D9685F;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

body.dark-mode .mode-active-wrap { background: #0F1B24; }
body.dark-mode .mode-pause-btn { background: #16232E; color: #7FB8DA; }
body.dark-mode .mode-abort-btn { background: #16232E; border-color: #4A2E2C; color: #E8968C; }
body.dark-mode .mode-timer-ring-bg { stroke: rgba(120, 140, 160, 0.28); }

body.dark-mode .daily-miss-indicator.miss-warn {
  color: #F4A9C4;
  background: rgba(224, 117, 158, 0.18);
}
body.dark-mode .daily-miss-indicator.miss-danger {
  color: #FFFFFF;
  background: #C23A4C;
}
body.dark-mode .daily-miss-badge {
  background: #C23A4C;
}
body.dark-mode .daily-miss-badge.miss-warn {
  color: #F4A9C4;
  background: rgba(224, 117, 158, 0.18);
}

/* ===== Wish画面: 使用金額の固定ボタン+ポップアップパネル ===== */
:root {
  --amount-fab-left: max(20px, calc(50vw - 240px + 20px));
  --amount-fab-right-margin: max(20px, calc(50vw - 240px + 20px));
}
.fab-amount-btn {
  position: fixed;
  left: var(--amount-fab-left);
  bottom: var(--fab-bottom-offset);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #E07B4F 0%, #F2A65A 100%);
  color: #FFFFFF;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(224, 123, 79, 0.45);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.1s;
}
.fab-amount-btn:active { transform: scale(0.92); }
.fab-amount-btn i { filter: brightness(0) invert(1); }

/* ボタンの右側に開く。left/rightの両方を指定して幅を画面に自動フィットさせる
   (別途widthを指定しないことで、はみ出し・入りきらない問題を防ぐ) */
.amount-fab-panel {
  position: fixed;
  left: calc(var(--amount-fab-left) + 56px + 10px);
  right: var(--amount-fab-right-margin);
  bottom: var(--fab-bottom-offset);
  background: #FFFFFF;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  z-index: 91;
}
.amount-fab-panel .amount-row { gap: 6px; }
.amount-fab-panel .amount-row input { min-width: 0; }
.amount-fab-title {
  font-size: 12px;
  font-weight: 700;
  color: #6B7C8C;
  margin: 0 0 6px;
}

body.dark-mode .amount-fab-panel {
  background: #16232E;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
body.dark-mode .amount-fab-title { color: #7FA0B8; }


/* =========================================================
   チュートリアル画面(旧tutorial.html)専用スタイル
   ---------------------------------------------------------
   以前は別ページ(tutorial.html)だったが、PWAとしてアプリ化した状態で
   ページ間を行き来すると画面端スワイプ時に不自然な挙動が出ていたため、
   他の画面と同じくindex.html内の1画面(#tutorial)に統合した。
   このクラス群は#tutorial画面だけで使う。
   ========================================================= */
.tutorial-wrap {
  padding-bottom: 24px;
}

/* ガイドが準備中(TUTORIAL_READY=false)のときの一文。ヘッダーの下ではなく画面全体の中央に置くため
   fixedで画面いっぱいに広げて中央寄せしている。ヘッダーの戻るボタンを塞がないよう、クリックは通す。
   「もうしばらくお待ちください」を付けると待てば使えると誤解されるので、一文だけにしている。 */
.tutorial-preparing {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  margin: 0;
  padding: 0 24px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: #A9C7D6;
  pointer-events: none;
}
.tutorial-preparing p { margin: 0; }
/* 補足の一文は主文より控えめにして、「準備中」が先に目に入るようにする */
.tutorial-preparing-sub { font-size: 13px; font-weight: 400; }

/* ヘッダー: .sticky-headerと同じ「はみ出させて画面端まで塗る」技法
   (.appのpadding分をmargin:-1remで打ち消し、その分をpaddingで戻す)。
   本体アプリのボトムナビと同系の配色で統一感を出す */
.tutorial-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 1rem;
  margin: 0 -1rem 18px;
  background: linear-gradient(135deg, #2F7FB8 0%, #4FA0D8 100%);
  color: #fff;
}
.tutorial-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.tutorial-back-btn i { filter: brightness(0) invert(1); }
.tutorial-header-title { font-size: 17px; font-weight: 700; }
.tutorial-header-sub   { font-size: 12px; opacity: 0.85; }

/* 使い方ガイドの1番上: 初回チュートリアル(オンボーディング)を再表示するボタン */
.tutorial-replay-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: none;
  border-radius: 14px;
  background: #EAF6FB;
  color: #2F7FB8;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.tutorial-replay-btn i:first-child { font-size: 18px; }
.tutorial-replay-btn span { flex: 1; }
.tutorial-replay-btn i:last-child { font-size: 16px; opacity: 0.7; }
.tutorial-replay-btn:active { transform: scale(0.98); }
body.dark-mode .tutorial-replay-btn { background: #1E2A36; color: #6FB6E0; }

/* セクションへのジャンプチップ(旧: 全セクション1ページ表示だった頃の名残)
   は使い方ガイドのメニュー画面化に伴い不要になったため削除済み。
   メニューのボタン一覧は下の .tutorial-menu-grid / .tutorial-menu-btn を参照。 */
.tutorial-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tutorial-menu-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(47,127,184,0.08);
  font-size: 14px;
  font-weight: 700;
  color: #1A3A52;
  text-align: left;
  cursor: pointer;
}
.tutorial-menu-btn:active { transform: scale(0.98); }
.tutorial-menu-btn span { flex: 1; }
.tutorial-menu-btn > i { font-size: 16px; opacity: 0.5; flex-shrink: 0; }
.tutorial-menu-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 18px;
  flex-shrink: 0;
  color: #fff;
}
.tutorial-menu-btn-icon i { filter: brightness(0) invert(1); }
body.dark-mode .tutorial-menu-btn { background: #1E2A36; color: #D0E4EF; }

/* サブメニュー(subsections形式)のラベル一覧。アイコンは出さず、
   ラベルの文字色だけをTUTORIAL_SECTIONS側のlabelColorで変える。 */
.tutorial-submenu-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(47,127,184,0.08);
  text-align: left;
  cursor: pointer;
}
.tutorial-submenu-btn:active { transform: scale(0.98); }
.tutorial-submenu-btn span { flex: 1; font-size: 14px; font-weight: 700; }
.tutorial-submenu-btn > i { font-size: 16px; opacity: 0.5; flex-shrink: 0; color: #1A3A52; }
body.dark-mode .tutorial-submenu-btn { background: #1E2A36; }
body.dark-mode .tutorial-submenu-btn > i { color: #D0E4EF; }

/* セクションカード */
.tutorial-section {
  background: #fff;
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 6px rgba(47,127,184,0.08);
}
.tutorial-section-body p { font-size: 13.5px; line-height: 1.75; color: #3C5A6E; margin-bottom: 8px; }
.tutorial-section-body p:last-child { margin-bottom: 0; }

/* アイコン背景色バリエーション(セクションごとに変えて単調にしない) */
.tone-blue   { background: linear-gradient(135deg, #2F7FB8, #4FA0D8); }
.tone-orange { background: linear-gradient(135deg, #E07B4F, #F2A65A); }
.tone-purple { background: linear-gradient(135deg, #8C96F0, #B3A9F5); }
.tone-green  { background: linear-gradient(135deg, #4FAE7E, #7FCB9F); }
.tone-pink   { background: linear-gradient(135deg, #E37FA0, #F2A6BE); }

/* OS切り替えタブ(iOS/Android) */
.tutorial-os-tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
}
.tutorial-os-tab {
  flex: 1;
  padding: 9px 0;
  text-align: center;
  border-radius: 10px;
  background: #F0F6FA;
  color: #6B7C8C;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.tutorial-os-tab.active {
  background: #2F7FB8;
  color: #fff;
}

/* 手順ステップ */
.tutorial-steps { display: none; flex-direction: column; gap: 10px; }
.tutorial-steps.active { display: flex; }
.tutorial-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.tutorial-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2F7FB8;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.tutorial-step-text { font-size: 13.5px; line-height: 1.6; color: #1A3A52; padding-top: 2px; }
.tutorial-step-note {
  font-size: 12px;
  color: #6B7C8C;
  margin-top: 6px;
}

/* コールアウトボックス(ヒント/注意) */
.tutorial-callout {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.6;
}
.tutorial-callout i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.tutorial-callout-tip {
  background: #FFF6E9;
  color: #8A5A1E;
}
.tutorial-callout-warn {
  background: #FDEDEE;
  color: #9A3B42;
}
.tutorial-callout-info {
  background: #EAF6FB;
  color: #2A5A78;
}

/* 用語のミニ比較カード(フォルダ/ファイルなど) */
.tutorial-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}
.tutorial-compare-card {
  background: #F5FBFE;
  border: 1.5px solid #D8EAF2;
  border-radius: 12px;
  padding: 12px;
}
.tutorial-compare-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #2F7FB8;
  margin-bottom: 4px;
}
.tutorial-compare-card p { font-size: 12px; color: #4A6B80; line-height: 1.55; }

/* スクリーンショット差し込み用プレースホルダー
   (実際の画像が用意でき次第、data-src相当を<img>に差し替える想定) */
.tutorial-screenshot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed #B9D6E6;
  border-radius: 12px;
  padding: 28px 12px;
  margin: 10px 0;
  color: #8FADC2;
  font-size: 12px;
  background: #F5FBFE;
}
.tutorial-screenshot i { font-size: 22px; }
.tutorial-screenshot img { width: 100%; border-radius: 10px; display: block; }

/* 目次内の小見出し(箇条書きより一段強調したい時) */
.tutorial-subhead {
  font-size: 13px;
  font-weight: 700;
  color: #2F7FB8;
  margin: 14px 0 6px;
}
.tutorial-subhead:first-child { margin-top: 0; }

.tutorial-list { padding-left: 18px; margin-bottom: 8px; }
.tutorial-list li { font-size: 13.5px; line-height: 1.75; color: #3C5A6E; margin-bottom: 2px; }

.tutorial-footer-note {
  text-align: center;
  font-size: 11.5px;
  color: #8FADC2;
  margin-top: 8px;
}

/* 汎用の左寄せ小さい注記(tutorial-footer-noteの中央寄せ版とは別に用意) */
.tutorial-inline-note {
  text-align: left;
  font-size: 11.5px;
  color: #8FADC2;
  margin-top: 6px;
}

/* 開け閉めできるブロック(collapsible)。設定画面の折りたたみと同じ見た目 */
.tutorial-collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #F4F9FC;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #2F7FB8;
  text-align: left;
}
.tutorial-collapsible-header i:first-child { margin-right: 6px; }
.tutorial-collapsible-header i:last-child { transition: transform 0.2s; }
.tutorial-collapsible-header.open i:last-child { transform: rotate(180deg); }
.tutorial-collapsible-body { padding-top: 10px; }


/* ===== 上下スクロールの目印(タスク/ご褒美画面) =====
   固定エリアの下に隠れている項目・ファイルがあるとき、↑(上に隠れている)を
   固定エリアのすぐ下に、上まで戻ったら↓(下に続きがある)を下側に出す。
   全部見えているときは出さない。タップでその端までスクロールする。 */
.scroll-hint-btn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #B9D6E8;
  background: rgba(255, 255, 255, 0.92);
  color: #2F7FB8;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(47, 127, 184, 0.25);
  cursor: pointer;
  z-index: 85;
  padding: 0;
}
.scroll-hint-btn.show { display: flex; }
.scroll-hint-btn svg { width: 20px; height: 20px; }
.scroll-hint-btn .hint-down { display: none; }
.scroll-hint-btn.down .hint-up { display: none; }
.scroll-hint-btn.down .hint-down { display: block; }
.scroll-hint-btn:active { transform: translateX(-50%) scale(0.92); }
body.dark-mode .scroll-hint-btn {
  background: rgba(22, 35, 46, 0.92);
  border-color: #2B4256;
  color: #7FC4EE;
}


/* ===== 検索ボタン(タスク/ご褒美の画面右上) + 検索ページ ===== */
.card-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.item-search-open { flex-shrink: 0; }

/* 履歴と削除は強調のため、ひとつの背景色でまとめて区切る */
.link-pill-group {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #DCEBF5;
}
body.dark-mode .link-pill-group { background: #1E2F3E; }

/* 検索ページ: 上部(戻る + 丸い検索ボックス + 年月の並び替え)を常時表示 */
.item-search-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #EAF6FB;
  padding: 12px 1rem 10px;
  margin: 0 -1rem;
  box-shadow: 0 2px 8px rgba(47, 127, 184, 0.08);
}
body.dark-mode .item-search-sticky { background: #121820; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.item-search-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid #D2E9F3;
  border-radius: 999px; /* 左右の角を丸く */
  padding: 0 14px;
  height: 40px;
}
body.dark-mode .item-search-box { background: #16232E; border-color: #2B4256; }
.item-search-box i { font-size: 15px; flex-shrink: 0; }
.item-search-box input {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOSのズーム防止 */
  outline: none;
  color: #1A3A52;
}
body.dark-mode .item-search-box input { color: #DCEEF7; }
.item-search-sort { flex-shrink: 0; white-space: nowrap; font-size: 12px; }
#itemSearch .task-grip { display: none; }

/* 検索ページは.screensの外にあるので、日課の記録ページと同じ上余白の調整が要る */
#itemSearch.screen.active {
  margin-top: calc(-1 * var(--app-padding));
  padding-top: 0;
}
.screens:has(~ #itemSearch.screen.active) { padding-bottom: 0; }


/* ===== 達成後の見た目をタスク/ご褒美で統一 =====
   ・ロック(1日1回 / 達成一度きり の達成済み): 濃い青のチェック + 行を少し薄くする
     → 「もう押せない」ことが分かる
   ・何度でも達成できる(周回 / くり返し): 行は薄くしない + 「今日 ×N」バッジ
     → 「また押せる」ことが分かる */
.task-row-locked { opacity: 0.6; }
.badge-today-count {
  background: #D9EBF7;
  color: #2F7FB8;
  font-weight: 700;
}
body.dark-mode .badge-today-count { background: #1E3446; color: #7FB8DA; }


/* =========================================================
   カレンダー
   ---------------------------------------------------------
   青基調のアプリ本体と喧嘩しないよう、カレンダーだけ緑系で統一する。
   色はすべて#calendar上のCSS変数にまとめ、ダークモードでは変数だけ
   差し替える(各パーツ側にダークモード用の指定を散らさないため)。
   ========================================================= */

/* ホームの「カレンダー」ボタン(編集/記録の青・暖色と並んでも喧嘩しない薄緑) */
.btn-green {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #DDF1E6;
  color: #2E8A5E;
  border: 0.5px solid #BDE2CE;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.btn-green:active { transform: scale(0.95); opacity: 0.85; }
.btn-green i {
  font-size: 14px;
  filter: invert(50%) sepia(70%) saturate(500%) hue-rotate(120deg) brightness(95%);
}
body.dark-mode .btn-green { background: #1C3328; color: #7FD0A5; border-color: #2A4A39; }
body.dark-mode .btn-green i { filter: invert(75%) sepia(40%) saturate(500%) hue-rotate(110deg); }
/* .home-action-btn は flex:1 だが、#homeの日課カードは縦並びflexのため、そのままだと
   高さ方向に潰れる。縦並びでは伸縮させず、横幅だけいっぱいにする。 */
.home-calendar-btn { flex: none; width: 100%; }
.home-calendar-btn i { font-size: 18px; }

#calendar, #calThemes, #calThemeEdit, #calEvent, .notif-card {
  --cal-row-h: 92px; /* 初期値。カレンダー画面を開くとapp.jsのcalApplyRowHeight()が画面の高さから決めた値で上書きする(CAL_ROW_Hと必ず同じ値になる) */
  /* ヘッダー: 白文字が読めるよう、標準の緑より明度を落として彩度を少し上げた緑 */
  --cal-head-bg: #268C5A;
  --cal-head2-bg: #34A56E;   /* テーマ編集画面のヘッダー: メインのヘッダーより少し明るい緑 */
  --cal-foot-bg: #FFFFFF;
  --cal-bg: #DCEBE2;
  --cal-weekrow-bg: #F3FAF6;
  --cal-line: #CFE3D8;
  --cal-this: #FFFFFF;       /* 今月: 明るめの白 */
  --cal-other: #E8F5EE;      /* 今月以外: うっすら薄緑 */
  --cal-today: #BFE4CE;      /* 今日: 薄緑をさらに少し濃く */
  --cal-text: #1A3A52;
  --cal-sun: #D9534F;
  --cal-sat: #2F7FB8;
  --cal-month-bg: rgba(38, 140, 90, 0.13);
  --cal-month-line: #268C5A;
}
body.dark-mode #calendar, body.dark-mode #calThemes, body.dark-mode #calThemeEdit, body.dark-mode #calEvent, body.dark-mode .notif-card {
  --cal-head-bg: #1B4D37;
  --cal-head2-bg: #266A4B;
  --cal-foot-bg: #0B0E12;
  --cal-bg: #0E1318;
  --cal-weekrow-bg: #10171A;
  --cal-line: #0C1210;
  --cal-this: #26323D;       /* ダークでも今月は他の月より明るく */
  --cal-other: #141C1A;
  --cal-today: #2F5E48;
  --cal-text: #D0E4EF;
  --cal-sun: #F08080;
  --cal-sat: #6FB6E0;
  --cal-month-bg: rgba(255, 255, 255, 0.07);
  --cal-month-line: #4FA57C;
}

/* 画面全体を使うため、他の.screenのような通常フローではなく画面に固定する。
   幅は.appと同じ上限(480px/PCは520px)に揃えて中央寄せする。 */
#calendar.screen.active, #calThemes.screen.active, #calThemeEdit.screen.active, #calEvent.screen.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 95;
  background: var(--cal-bg);
}
@media (min-width: 600px) {
  #calendar.screen.active, #calThemes.screen.active, #calThemeEdit.screen.active, #calEvent.screen.active { max-width: 520px; }
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* ヘッダーを少し大きくした。ラベルとボタンはどちらも上下中央に揃える(align-items:center)。
     高さはpaddingではなくmin-heightで決め、中身が増えても中央揃えが崩れないようにする */
  min-height: 64px;
  box-sizing: content-box;
  padding: env(safe-area-inset-top) 18px 0;
  background: var(--cal-head-bg);
  color: #FFFFFF;
}
.cal-title {
  margin: 0;
  font-size: 13px; /* 日付の数字(.cal-cell-num)と同じ大きさ */
  font-weight: 700;
  line-height: 1;
}
.cal-theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.92); /* ヘッダーの緑と同系色のテーマ色でも見分けがつくよう白縁を付ける */
  background: #2F7FB8;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.cal-theme-btn:active { transform: scale(0.92); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 0;
  background: var(--cal-weekrow-bg);
  color: var(--cal-text);
  border-bottom: 1px solid var(--cal-line);
}
.cal-weekdays span:first-child { color: var(--cal-sun); }
.cal-weekdays span:last-child { color: var(--cal-sat); }

.cal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* 端まで来てもページ全体が引っ張られないように */
  position: relative;
}

/* 1行=1週間。月をまたぐ週もそのまま1行にして、月の境目をスクロールで繋げる */
.cal-week-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  height: var(--cal-row-h);
}
.cal-cell {
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* 日付は左上、ラベルは横いっぱいにするため中央寄せにしない */
  gap: 1px;
  padding: 1px; /* マスの内側に1pxだけ余白 */
  background: var(--cal-other);
  color: var(--cal-text);
  border-right: 1px solid var(--cal-line);
  border-bottom: 1px solid var(--cal-line); /* gapではなく罫線にしておく(行の高さがCAL_ROW_Hとずれないように) */
  overflow: hidden;
}
.cal-cell.this-month { background: var(--cal-this); } /* 月ごとに明るい/暗いを交互に(今月基準) */
/* 月の境目の強調線。ボーダーは1pxの罫線に使っているので、内側のbox-shadowで太く重ねて、行の高さを変えない */
.cal-cell.bd-left { box-shadow: inset 2px 0 0 var(--cal-month-line); }
.cal-cell.bd-top { box-shadow: inset 0 2px 0 var(--cal-month-line); }
.cal-cell.bd-left.bd-top { box-shadow: inset 2px 0 0 var(--cal-month-line), inset 0 2px 0 var(--cal-month-line); }
/* 予定バーを開いている日: オレンジで囲む(境目線より優先) */
.cal-cell.selected, .cal-cell.selected.bd-left, .cal-cell.selected.bd-top, .cal-cell.selected.bd-left.bd-top {
  box-shadow: inset 0 0 0 2px #F28C28;
}
.cal-cell.today { background: var(--cal-today); }
.cal-cell-num {
  font-size: 15px; /* 1か月を画面に収める表示にしたので、日付も読みやすい大きさに(以前13px) */
  font-weight: 700;
  line-height: 1.2;
  text-align: left; /* 日付は左上 */
  padding-left: 2px;
}
.cal-cell:not(.this-month) .cal-cell-num { opacity: 0.65; }
.cal-cell-num.cal-red { color: var(--cal-sun); }
.cal-cell-num.cal-blue { color: var(--cal-sat); }

/* 祝日名のラベル。背景色は「日本の祝日」のテーマ色(文字色はJS側で背景に合わせて決める)。
   予定のラベルと同じく「横いっぱい・1行」。長い名前は折り返さず、入り切らない部分は
   「…」も付けずにそのまま切り捨てる(text-overflow:clip)。 */
.cal-holiday {
  display: block;
  box-sizing: border-box;
  width: 100%;
  font-size: 11px; /* マスが大きくなったぶんラベルも大きく(以前9px。読みづらかったため)。入り切らない文字は従来どおり切り捨て */
  font-weight: 700;
  line-height: 1.35;
  padding: 0 3px;
  border-radius: 3px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* 背景にうっすら出す月の数字。第3水曜日の行の左右中央に置く。
   2桁でも枠からはみ出してよいので、行(セル)の外へも描画できるようにしてあり、
   セルの背景色に隠れないよう前面に置いて、クリックは邪魔しない(pointer-events:none)。 */
.cal-month-bg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  color: var(--cal-month-bg);
  pointer-events: none;
  z-index: 2;
}

.cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* 下の余白は 8px + ホームバー分(safe-area)。
     PWAでは画面の最下部に、safe-area分の高さの青い帯(.safe-area-patch, z-index 99)が重なる。
     フッターはその帯の下まで続いているので、帯に隠れる分を余白として足しておかないと、
     見える部分の中でボタンが下に寄る(以前の不具合)。足すと、見える部分は上8px・下8pxになり上下中央に揃う。
     (一度「safe-areaを4割だけ」にしたが、帯がボタンに被って悪化した。safe-areaが0のブラウザ表示では上下とも8px) */
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--cal-foot-bg);
  border-top: 1px solid var(--cal-line);
}
/* 戻るボタンと追加ボタンは同じ大きさにして、フッターの中で上下中央に揃える */
.cal-footer .icon-btn { width: 48px; height: 48px; flex: none; }
.cal-add-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--cal-head-bg); /* ヘッダー背景色と必ず同じ色にする(ダークモードも変数で追従) */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.cal-add-btn:active { transform: scale(0.92); }
.cal-add-btn i { font-size: 24px; filter: brightness(0) invert(1); }


/* =========================================================
   カレンダー: テーマ編集まわり(段階2)
   ========================================================= */
/* テーマ名/色の編集画面は「下から開くシート」風にする: 上に12pxだけ余白を残し、
   上の角を丸くする。角の外側が透けるのでbodyの背景が見える(画面全体の切り替えは従来通り)。 */
#calThemeEdit.screen.active {
  top: 12px;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
}

.cal-subheader {
  display: grid;
  grid-template-columns: 44px 1fr 44px; /* 左右を同じ幅にしてタイトルを必ず左右中央に置く */
  align-items: center;                  /* 戻る/保存ボタンはタイトルと上下中央揃え */
  min-height: 64px;
  padding: 0 12px;
  background: var(--cal-head2-bg);
  color: #FFFFFF;
}
.cal-subtitle {
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
/* 緑のヘッダー上では、白丸ではなく透明地に白いアイコンにして馴染ませる */
.cal-subheader .icon-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
}
.cal-subheader .icon-btn:hover { background: rgba(255, 255, 255, 0.15); }
.cal-subheader .icon-btn i { font-size: 24px; filter: brightness(0) invert(1); }

/* --- テーマ一覧 --- */
.cal-themes-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* 右下の+ボタンに最後の行が隠れないように(+ボタンの分に加えて、青い帯の高さも足す) */
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
.cal-section-label {
  margin: 0;
  padding: 14px 16px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cal-text);
  opacity: 0.75;
}
.cal-section-gap { padding-top: 26px; } /* 「少し間をあけて」 */
.cal-theme-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 56px;
  background: var(--cal-this);
  border-bottom: 1px solid var(--cal-line);
  color: var(--cal-text);
  cursor: pointer;
}
.cal-theme-row:first-child { border-top: 1px solid var(--cal-line); }
.cal-theme-radio {
  flex: none;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--cal-head-bg);
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-theme-radio::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cal-head-bg);
  transform: scale(0);
  transition: transform 0.12s;
}
.cal-theme-radio.selected::after { transform: scale(1); }
.cal-theme-chip {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); /* 白に近い色でも輪郭が見えるように */
}
.cal-theme-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-theme-row > .ti-chevron-right { font-size: 18px; opacity: 0.45; }
body.dark-mode .cal-theme-row > .ti-chevron-right { filter: invert(1); }

.cal-fab {
  position: absolute;
  right: 20px;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2FA06C 0%, #4DBB86 100%); /* 他の画面の+と同じ形で、緑 */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(38, 140, 90, 0.45);
  cursor: pointer;
}
.cal-fab:active { transform: scale(0.92); }
.cal-fab i { font-size: 26px; filter: brightness(0) invert(1); }

/* --- テーマ名/色の編集 --- */
.cal-edit-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* 下の余白: 帯(.safe-area-patch)の高さ + 約2行分(40px)。以前の max(24px, safe-area) だと、
     機種によっては最後の入力欄が帯のすぐ上に張り付き、帯に隠れているように見えていた。 */
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom, 0px));
}
.cal-preview {
  border: 1px solid var(--cal-line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--cal-this);
}
.cal-preview .cal-week-row { height: 64px; } /* プレビューは実物よりやや低く */
.cal-preview .cal-cell { background: var(--cal-this); border-bottom: none; }
.cal-preview .cal-cell:last-child { border-right: none; }
.cal-preview-label {
  display: block;
  box-sizing: border-box;
  width: 100%;
  font-size: 11px; /* 本物のカレンダーのラベル(.cal-holiday)と同じ大きさにそろえる(プレビューが実物と違って見えないように) */
  font-weight: 700;
  line-height: 1.35;
  padding: 0 3px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
/* 「テーマ名+文字色」のカード と 「ラベルカラー」のカード を別々の枠にして、
   テーマカラーとは別物であることが一目で分かるようにする。枠の中にも左右の余白を取る。 */
.cal-card {
  margin-top: 16px;
  padding: 0 16px;
  border: 1px solid var(--cal-line);
  border-radius: 12px;
  background: var(--cal-this);
}
.cal-card-title {
  margin: 0;
  padding: 14px 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--cal-text);
}
.cal-name-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 14px 0;
  font-size: 16px;
  border: none;
  border-bottom: 1px solid var(--cal-line);
  border-radius: 0;
  background: transparent;
  color: var(--cal-text);
}
.cal-name-input:focus { outline: none; border-bottom-color: var(--cal-head-bg); }
.cal-card > .cal-name-input:only-child { border-bottom: none; } /* タイトルだけのカードでは区切り線を出さない */

/* ラベルカラー内の「シンプル/パステル/カスタマイズ」は、色の種類ごとに線で区切る */
.cal-color-group { padding: 0 0 14px; }
.cal-color-group + .cal-color-group { border-top: 1px solid var(--cal-line); padding-top: 2px; }
.cal-name-input:focus { outline: 2px solid var(--cal-head-bg); outline-offset: -1px; }
.cal-color-label {
  margin: 12px 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--cal-text);
  opacity: 0.7;
}
.cal-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  justify-items: center;
}
.cal-swatch {
  position: relative;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.cal-swatch i { font-size: 22px; display: none; }
.cal-swatch.selected i { display: block; filter: brightness(0) invert(1); }       /* 選択中は白いチェック */
.cal-swatch.selected.is-light i { filter: invert(39%) sepia(73%) saturate(500%) hue-rotate(175deg); } /* 白に近い色は青いチェック */
.cal-swatch-custom {
  background: conic-gradient(#F28C28, #F2C830, #7CC576, #4FB3E8, #8E5BC9, #F28C28);
  overflow: hidden;
}
.cal-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.cal-delete-btn {
  /* 赤い丸ボタン。文字が「削除」の2文字なので64pxの円に収まる */
  display: none; /* 既存テーマの編集時だけJSがflexにする */
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 28px auto 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #D9534F;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(217, 83, 79, 0.4);
  cursor: pointer;
}
.cal-delete-btn:active { transform: scale(0.94); }


/* =========================================================
   カレンダー: 予定(段階3)
   ========================================================= */
/* 予定の追加・編集もテーマ編集と同じ「上角が丸いシート」 */
#calEvent.screen.active {
  top: 12px;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
}
.cal-ev-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--cal-line);
}
.cal-ev-row:last-child { border-bottom: none; }
.cal-ev-label { flex: none; font-size: 14px; font-weight: 600; color: var(--cal-text); }
.cal-ev-theme { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cal-ev-select, .cal-ev-input {
  font-size: 15px;
  font-family: inherit;
  color: var(--cal-text);
  background: transparent;
  border: none;
  padding: 6px 0;
  max-width: 100%;
}
.cal-ev-select { text-align: right; }
.cal-ev-dt { display: flex; align-items: center; gap: 10px; }
.cal-ev-input { text-align: right; }
/* 開始・終了は「日付」と「時刻」が別々に選べると一目で分かるよう、それぞれ薄い色の背景(日付=緑系、時刻=青系)を付ける */
.cal-ev-dt .cal-ev-input { padding: 7px 10px; border-radius: 8px; background: rgba(38, 140, 90, 0.13); }
.cal-ev-dt .cal-ev-time { background: rgba(47, 127, 184, 0.14); }
.cal-ev-time.hidden { display: none; } /* 終日のときは時刻を表示しない */
body.dark-mode #calEvent input, body.dark-mode #calEvent select, body.dark-mode #calEvent textarea { color-scheme: dark; }
.cal-ev-memo {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 14px 0;
  border: none;
  background: transparent;
  color: var(--cal-text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
}
.cal-ev-memo:focus { outline: none; }

/* 終日のON/OFFスイッチ */
.cal-switch { position: relative; width: 50px; height: 30px; flex: none; }
.cal-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.cal-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #C7D3CC;
  transition: background 0.15s;
}
.cal-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.cal-switch input:checked + .cal-switch-track { background: var(--cal-head-bg); }
.cal-switch input:checked + .cal-switch-track::after { transform: translateX(20px); }

/* --- 日付タップで下から出るバー --- */
.cal-bar-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}
.cal-bar-backdrop.open { opacity: 1; pointer-events: auto; }
.cal-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /* 高さは固定(予定の数で伸び縮みさせない)。多いときは一覧だけが縦スクロールする。
     以前の約2.2倍。画面が低い端末でも画面からはみ出さないようmax-heightで上限を付ける */
  height: 355px;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  background: var(--cal-this);
  color: var(--cal-text);
  border-radius: 16px 16px 0 0; /* 上角が丸い小さなヘッダー */
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(105%);
  transition: transform 0.22s ease-out;
  z-index: 11;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.cal-bar.open { transform: translateY(0); }
.cal-bar-header {
  display: flex;
  align-items: center;      /* 年月日とバツは上下中央揃え */
  justify-content: space-between;
  min-height: 36px;
  padding: 0 4px 0 16px;
  border-radius: 16px 16px 0 0;
  background: var(--cal-head2-bg);
  color: #FFFFFF;
  flex: none;
}
.cal-bar-title { margin: 0; font-size: 13px; font-weight: 700; line-height: 1; }
.cal-bar-close {
  width: 34px;
  height: 34px;
  flex: none;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cal-bar-close i { font-size: 18px; filter: brightness(0) invert(1); }
.cal-bar-list { flex: 1; min-height: 0; overflow-y: auto; }
/* 予定同士に余白は入れない。行は全体がタップで編集できる。
   行の見た目はタスク/ご褒美の行(.task-row)の仕組みを流用しているので、
   角丸・枠線・ホバー色など予定バーに要らない部分をここで打ち消す。
   背景は不透明にしておく(左スワイプで後ろの赤い削除ボタンが透けないように)。 */
.cal-bar-wrap { border-radius: 0; }
.cal-bar-row {
  background: var(--cal-this);
  border: none;
  border-radius: 0;
  align-items: stretch;
  gap: 10px;
  padding: 8px 14px 8px 16px;
  touch-action: pan-y; /* 縦はスクロール、横はスワイプ削除に使う */
}
.cal-bar-row:hover { background: var(--cal-this); }
.cal-bar-row.static { cursor: default; } /* 祝日は編集対象ではない */
.cal-bar-time {
  flex: none;
  width: 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* 開始が上、終了が下 */
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-align: right;
}
.cal-bar-time.allday { justify-content: center; }
.cal-bar-time span:last-child { opacity: 0.6; }
.cal-bar-color { flex: none; width: 4px; border-radius: 1px; } /* 角を1pxだけ丸くしたテーマ色の縦棒 */
.cal-bar-name { flex: 1; min-width: 0; align-self: center; }
.cal-bar-ttl { font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* メモは1行目だけ。入り切らない分は「…」を付けずに切る */
.cal-bar-memo { margin-top: 2px; font-size: 11px; opacity: 0.6; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.cal-bar-row > .ti-player-play { align-self: center; font-size: 12px; opacity: 0.5; }
body.dark-mode .cal-bar-row > .ti-player-play { filter: invert(1); }
/* 「予定を追加」は一覧のいちばん最後に置く(下に固定せず、予定の数に追従する)。
   一覧の末尾との間にある程度の余白を取る。予定が無いときは一番上に来るので、上にも広めの余白を取る。 */
.cal-bar-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* 「予定を追加」は横を2回り・縦をひと回り大きくした(左右の余白 44px→24px) */
  margin: 18px 24px 16px;
  padding: 15px 0;
  width: calc(100% - 48px);
  border: none;
  border-radius: 999px;
  background: var(--cal-head-bg);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.cal-bar-add.first { margin-top: 28px; }
.cal-bar-add i { font-size: 18px; filter: brightness(0) invert(1); }
.cal-bar-add:active { transform: scale(0.97); }


/* ---------------------------------------------------------
   予定画面の「ジャンル」(タスク/ご褒美)
   ---------------------------------------------------------
   タスク/Wishの編集フォームのカードを、そのまま予定画面の中に移して使う(JS側で移動)。
   移したカードは通常のカード(.card)のままなので、予定画面の .cal-card と
   同じ縦の間隔になるよう、ここで余白だけ揃える。
   ジャンルが「なし」のときは枠ごと非表示にして、ふだんの予定画面と見た目を変えない。 */
#calGenreSlot:empty { display: none; }
#calGenreSlot > .card { margin: 16px 0 0; } /* 予定画面のカード(.cal-card)と同じ上の間隔 */
/* タイトルはタスク/ご褒美の「名前」欄が担うので隠す。テーマ(カレンダー上の色)はタスク/ご褒美でも
   選べる必要があるため、ここでは隠さない。 */
#calEvent .cal-edit-body.genre-on #calEventTitleCard,
/* メモもタイトルと同じ理由で隠す: ジャンルがタスク/ご褒美のときは、移してきた編集フォーム側の「メモ」欄が
   その項目のメモそのものになる。予定用のメモ欄まで出すと、同じ内容を入れる欄が2つ並んでしまう。 */
#calEvent .cal-edit-body.genre-on #calEventMemoCard { display: none; }
#calEvent .cal-edit-body:not(.genre-on) #calEventIcsCard { display: none; }

/* ---------------------------------------------------------
   カレンダーの検索ボタン(ヘッダー、テーマ色ボタンの左隣)
   ---------------------------------------------------------
   テーマ色ボタン(40px)と同じ大きさの丸にして、2つが並んだときに揃って見えるようにする。
   背景は透過の白(ヘッダーの緑に馴染ませる)。 */
.cal-header-btns { display: flex; align-items: center; gap: 12px; }
.cal-search-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  font-size: 20px;
  cursor: pointer;
}
.cal-search-btn:active { transform: scale(0.92); }

/* カレンダー検索ページ: 他のカレンダー画面と同じく画面全体に固定して重ねる
   (通常の画面は上に余白が付くため、検索ボックスが下がって見えてしまう)。
   結果は予定バーの行と同じ見た目で出す。日付欄は「年/月/日」が入る幅にする */
#calSearch.screen.active {
  display: block;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 95;
  overflow-y: auto;
  padding: 0 1rem;
  background: #EAF6FB;
}
body.dark-mode #calSearch.screen.active { background: #121820; }
@media (min-width: 600px) { #calSearch.screen.active { max-width: 520px; } }
#calSearch { --cal-text: #1A3A52; }
body.dark-mode #calSearch { --cal-text: #D0E4EF; }
/* 年月日は「2026/12/28」のように月・日が2桁になると約67px。以前の64pxでは入り切らず、
   右隣の色の棒に文字がかかっていた。2桁が最長なのでそれが収まる幅(72px、余裕5px)にしてある。
   折り返しても色棒との重なりは解消しないので、折り返さない指定も付ける。 */
.cal-search-date { min-width: 72px; white-space: nowrap; }


/* 日課の詳細(モーダル)右上の色ボタン。カレンダーのテーマ色ボタンと同じ丸+白縁にする。
   背景色は日課の色(JSが入れる)。タイトルと重ならないよう右上の角に置く */
#dailyDetailModalOverlay .modal-box { position: relative; }
.daily-detail-color-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid #FFFFFF;
  padding: 0;
  background: #2F7FB8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}
.daily-detail-color-btn:active { transform: scale(0.92); }

/* 未達成バッジ(赤地・白文字)のアイコン。.ti は黒い画像なので、文字に合わせて白にする。
   薄いピンク版(.miss-warn)は文字がピンクなのでここでは触らない */
.daily-miss-badge:not(.miss-warn) i { filter: brightness(0) invert(1); }


/* ペナルティの日(日課の記録カレンダー): 赤いマス(色はJSが設定の色を入れる)に、日付の下へドクロを置く。
   ドクロは線の色=文字色(currentColor)なので、ホワイト/ブラックの設定にそのまま従う */
.daily-cal-skull { width: 20px; height: 20px; display: block; margin-top: 1px; }
.daily-cal-cell.penalty .daily-cal-name { overflow: visible; }

/* 設定の「ペナルティの日の色」ボタン: 日課の詳細の色ボタンと同じ丸+白縁(こちらは行の中に置く) */
.setting-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid #FFFFFF;
  padding: 0;
  background: #D9534F;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  flex: none;
}
.setting-color-btn:active { transform: scale(0.92); }
body.dark-mode .setting-color-btn { border-color: #3A4A5A; }


/* 一覧行のメモ(項目名の下、バッジの上)。行の高さを「名前・メモ・バッジ」の3行に収めるため、
   メモは1行だけ表示し、入り切らない部分は切り捨てる(…は付けず単純に切る)。
   改行は空白として扱い、1行に詰めて見せる。 */
.task-row-memo {
  font-size: 11px;
  color: #7A9BB0;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
body.dark-mode .task-row-memo { color: #7F99A8; }

/* メモ欄のスクロールバー。iPhoneなど標準のスクロールバーは触っている間しか出ず、
   「続きがある」ことに気づきにくい。::-webkit-scrollbar を指定すると常に表示される(Safari/Chrome)。
   Firefox向けには scrollbar-width / scrollbar-color を併記している。 */
.notif-memo-input,
.cal-ev-memo {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #9DBBCB transparent;
}
.notif-memo-input::-webkit-scrollbar,
.cal-ev-memo::-webkit-scrollbar { width: 6px; }
.notif-memo-input::-webkit-scrollbar-track,
.cal-ev-memo::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.notif-memo-input::-webkit-scrollbar-thumb,
.cal-ev-memo::-webkit-scrollbar-thumb { background: #9DBBCB; border-radius: 3px; }
body.dark-mode .notif-memo-input,
body.dark-mode .cal-ev-memo { scrollbar-color: #4A6173 transparent; }
body.dark-mode .notif-memo-input::-webkit-scrollbar-thumb,
body.dark-mode .cal-ev-memo::-webkit-scrollbar-thumb { background: #4A6173; }


/* 設定画面の一番下のバージョン表示。左右中央揃え。
   バージョンは「いつもの青字」で、下の更新メモより2〜3px大きくして主役にする(14px / 11px)。
   アプリ名とバージョンの間に半角スペース2つを入れているので、pre-wrapで詰めずにそのまま見せる。 */
.app-version-info {
  text-align: center;
  margin: 24px 0 8px;
}
.app-version-info p { margin: 0; }
.app-version-name {
  font-size: 14px;
  font-weight: 700;
  color: #2F7FB8;
  white-space: pre-wrap;
}
.app-version-note {
  font-size: 11px;
  color: #A5ADB3;
  margin-top: 6px;
}
body.dark-mode .app-version-name { color: #6FB6E0; }
body.dark-mode .app-version-note { color: #6B7680; }


/* =====  画面の一番下の余白(青い帯対策) =====
   PWAでは画面の最下部に、ホームバー分(safe-area)の高さの青い帯(.safe-area-patch, z-index 99)が
   重なる。.app は padding-bottom:0 なので、.app直下の画面(設定・履歴など)は、スクロールの一番下で
   最後の項目が帯に隠れてしまっていた。帯の高さ + 約2行分(40px)を下に足して、最後まで見えるようにする。
   safe-areaが0のブラウザ表示では、40pxだけ余白になる。
   (.screens の中の画面は、元から84px + safe-areaの余白があるので対象外) */
:root { --screen-bottom-gap: calc(40px + env(safe-area-inset-bottom, 0px)); }
#settings, #historyScreen, #dailyRecord, #taskGroupEdit, #wishGroupEdit,
#tutorial, #tutorialSubmenu, #tutorialDetail,
#itemSearch.screen.active, #calSearch.screen.active {
  padding-bottom: var(--screen-bottom-gap);
}

/* 通知から開いた項目の行を一時的に光らせる。
   一覧のどこに飛んだのかが一目で分かるようにするため。2.5秒で自然に消える(JS側で外す)。
   box-shadowにしたのは、行のレイアウト(高さ・余白)を動かさず、他の表示を崩さないため。 */
.task-row-wrapper.notif-highlight {
  animation: notif-highlight-pulse 1.2s ease-in-out 2;
  border-radius: 14px;
}
@keyframes notif-highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 165, 123, 0); background: transparent; }
  50% { box-shadow: 0 0 0 3px rgba(240, 165, 123, 0.9); background: rgba(240, 165, 123, 0.18); }
}
