/* style.css : 個人スケジュールPWA
 *
 * スキン：ダークスキン「藍色の星空」（2026-08-27）
 *   - 色は全て :root のCSS変数に集約している。今後スキンを増やす／微調整する時は
 *     この :root ブロックだけを差し替えれば済むようにしてある。
 *     以降のルールでは色を直接hexで書かないこと。
 *   - 予定の色ラベル7色（blue/green/red/orange/purple/gray/pink）は
 *     DBの値・JSのロジックとは1対1のまま。暗い背景で判別できるよう明度を上げ、
 *     チップ・帯は「明るい塗り＋濃い文字」の組み合わせにしている。
 */

:root {
  /* ネイティブUI（datetime-local / select / checkbox / スクロールバー等）を
     暗色で描かせる。これが無いと入力欄まわりだけ白いままになる。 */
  color-scheme: dark;

  /* ---- 面（背景） ---- */
  --bg-page: #0b1026;        /* ページ背景（星空の地の色） */
  --bg-cell: #141a3a;        /* 通常の日付マス */
  --bg-cell-dim: #0f142e;    /* 前後の月にまたがる空セル（ミニカレンダー） */
  --bg-cell-stripe: #101638; /* 読み込み中の週のストライプの片側 */
  --bg-cell-focus: #1b2350;  /* フォーカス中の日のマス */
  --bg-cell-today: #243066;  /* 今日のマス */
  --outline-today: #7eb6ff;  /* 今日のマスの輪郭 1px */

  --surface: #141a3a;        /* ヘッダー・タブ・カード・モーダルの面 */
  --surface-raised: #1b2350; /* 面の上にさらに乗せる面（入力欄・候補カード等） */
  --border: #2a3566;
  --shadow: rgba(0, 0, 0, 0.55);
  --scrim: rgba(3, 6, 20, 0.7);         /* モーダルの背景を覆う幕 */
  --scrim-strong: rgba(3, 6, 20, 0.94); /* 画像ビューア */

  /* ---- 文字 ---- */
  --text: #e8ecff;           /* 見出し・月表示・本文 */
  --muted: #8fa0d0;          /* 補助文字・曜日ヘッダー（平日）・ヘッダーのアイコン */
  --text-day: #a8b4d8;       /* 通常の日付数字 */
  --text-day-focus: #c5cff0; /* フォーカス中の日の日付数字 */
  --text-day-today: #ffffff; /* 今日の日付数字 */
  --text-day-dim: #5a6690;   /* 前後の月にまたがる空セルの日付数字 */

  --sun: #c86e6e;            /* 日曜の数字 */
  --sun-head: #e37b7b;       /* 日曜の曜日ヘッダー */
  --sat: #7fa8e0;            /* 土曜の数字・曜日ヘッダー（共通） */

  --primary: #7eb6ff;        /* 主要ボタン・リンク・選択中タブ */
  --primary-fg: #062a57;     /* 主要ボタンの上に乗る文字 */
  --danger: #ff8a80;
  --danger-fg: #5c0f0c;

  --month-line: #3a4780;     /* 週表示で月の変わり目（月初日）に引く線 */

  /* ---- 予定の色ラベル7色（塗り / その上の文字） ---- */
  --label-blue-bg:   #7eb6ff;  --label-blue-fg:   #062a57;
  --label-green-bg:  #6ee7a8;  --label-green-fg:  #0a3d26;
  --label-red-bg:    #ff8a80;  --label-red-fg:    #5c0f0c;
  --label-orange-bg: #ffb86b;  --label-orange-fg: #4a2b00;
  --label-purple-bg: #c9a3ff;  --label-purple-fg: #2e1a5c;
  --label-gray-bg:   #b8c0cc;  --label-gray-fg:   #2b3038;
  --label-pink-bg:   #f8bbd0;  --label-pink-fg:   #5c1b33;

  /* ---- 星（背景の質感） ----
     白 #ffffff と淡青 #cfe0ff を、点ごとに明るさ 0.5〜0.9 でばらつかせる。
     明るさが1点ずつ違うので、色と不透明度を1つの変数にまとめて8個定義している。 */
  --star-1: rgba(255, 255, 255, 0.85);
  --star-2: rgba(207, 224, 255, 0.60);
  --star-3: rgba(207, 224, 255, 0.75);
  --star-4: rgba(255, 255, 255, 0.50);
  --star-5: rgba(255, 255, 255, 0.90);
  --star-6: rgba(207, 224, 255, 0.55);
  --star-7: rgba(255, 255, 255, 0.70);
  --star-8: rgba(207, 224, 255, 0.80);

  /* ---- レイアウト（色以外。従来どおり） ---- */
  --header-h: 52px;
  --tabs-h: 44px;
  /* iPhoneのノッチ/Dynamic Island分の上部セーフエリア。非対応環境では 0。
     ヘッダーの高さと、その下に続く sticky 要素の固定位置に一貫して足し込む。 */
  --safe-top: env(safe-area-inset-top, 0px);

  /* 週表示（アジェンダOFF時）の1週=1行の高さ。JSがビューポート高から計算して上書きする。
     この初期値は、JSが実行される前の一瞬だけ使われるフォールバック。 */
  --week-row-h: 180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html { background: var(--bg-page); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg-page);
  -webkit-text-size-adjust: 100%;
}

/* 星空。画像・canvasを使わず、position:fixed の1枚レイヤーに radial-gradient で
   8個の点を置くだけ。fixed なので独立した合成レイヤーになり、スクロール中に
   中身を再描画しない（＝スクロールが重くならない）。
   z-index 9 は「日付マス・チップ・アジェンダのカードより手前、曜日行(11)・
   ミニカレンダー(10)・タブ(15)・ヘッダー(20)・FAB(25)・モーダル(40)より奥」。
   週表示ではマスが画面を埋め尽くすため、body の背景に置くと星が一切見えない。
   そのためコンテンツの手前に薄く重ねている。 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background-repeat: no-repeat;
  /* 点ごとに大きさ・色・明るさをばらつかせる */
  background-image:
    radial-gradient(1px 1px at 11% 14%, var(--star-1), transparent 100%),
    radial-gradient(1.5px 1.5px at 78% 9%, var(--star-2), transparent 100%),
    radial-gradient(1px 1px at 33% 41%, var(--star-3), transparent 100%),
    radial-gradient(2px 2px at 62% 33%, var(--star-4), transparent 100%),
    radial-gradient(1px 1px at 89% 57%, var(--star-5), transparent 100%),
    radial-gradient(1.5px 1.5px at 21% 72%, var(--star-6), transparent 100%),
    radial-gradient(1px 1px at 54% 86%, var(--star-7), transparent 100%),
    radial-gradient(1.5px 1.5px at 71% 94%, var(--star-8), transparent 100%);
}

button { font-family: inherit; cursor: pointer; }

/* hidden属性を常に最優先で効かせる。
   （.modal / .image-viewer に display:flex を指定しているため、
    これが無いと hidden 属性が無視され、透明オーバーレイが最前面に残って
    入力欄がクリックできなくなる） */
[hidden] { display: none !important; }

/* ---------- ログイン ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  /* ログイン画面は body::after が使えない（#app が無く全面が背景）ので、
     星をこの背景レイヤーに直接重ねる */
  background:
    radial-gradient(1px 1px at 18% 18%, var(--star-1), transparent 100%),
    radial-gradient(1.5px 1.5px at 74% 12%, var(--star-2), transparent 100%),
    radial-gradient(1px 1px at 42% 32%, var(--star-3), transparent 100%),
    radial-gradient(2px 2px at 86% 46%, var(--star-4), transparent 100%),
    radial-gradient(1px 1px at 24% 63%, var(--star-5), transparent 100%),
    radial-gradient(1.5px 1.5px at 63% 78%, var(--star-6), transparent 100%),
    radial-gradient(1px 1px at 12% 88%, var(--star-7), transparent 100%),
    radial-gradient(1.5px 1.5px at 91% 90%, var(--star-8), transparent 100%),
    linear-gradient(160deg, var(--bg-page), var(--bg-cell-focus));
  background-repeat: no-repeat;
}
.login-card {
  width: min(88vw, 340px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 12px 40px var(--shadow);
  text-align: center;
}
.login-title { margin: 0; font-size: 22px; color: var(--text); }
.login-sub { margin: 4px 0 20px; color: var(--muted); font-size: 13px; }
.login-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-fg);
  background: var(--primary);
  border: none;
  border-radius: 10px;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
}

/* ---------- レイアウト ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  /* 高さにセーフエリア分を足し、padding-top でその分だけ中身を下げる。
     box-sizing:border-box なので、ボタン等が置かれる実際の中身の領域は常に
     --header-h（52px）確保される。以前は height を 52px 固定にしたまま
     padding-top でセーフエリアを足していたため、iPhoneでは中身が数pxまで
     押し潰されてタップ位置がズレていた（下のカレンダーを誤タップしていた）。 */
  height: calc(var(--header-h) + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-nav { display: flex; align-items: center; gap: 2px; }
.period-label {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}
.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
}
.icon-btn:active { background: var(--surface-raised); }
.icon-btn.is-active { color: var(--primary); }

.text-btn {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--primary);
  padding: 6px 6px;
  border-radius: 8px;
  text-decoration: none;
}

.view-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.switch-btn {
  border: none;
  background: var(--surface-raised);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}
.switch-btn.is-active { background: var(--primary); color: var(--primary-fg); font-weight: 600; }

.logout-link { color: var(--muted); }

/* タブ */
.tabs {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 15;
  height: var(--tabs-h);
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.view { flex: 1; }

/* ---------- 月表示 ---------- */
/* 曜日の行はどちらのモードでも常に上部に固定表示する */
.weekday-row {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top) + var(--tabs-h));
  z-index: 11;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.weekday {
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.weekday.sun { color: var(--sun-head); }
.weekday.sat { color: var(--sat); }

/* アジェンダ表示中の月パネル（ミニカレンダー）。
   高さ固定（曜日行＋約3週分）の独立スクロール枠にし、その中に月ブロックを縦に積んで
   月をまたいでスクロールできるようにする。overscroll-behavior:contain により、
   パネル内のフリックが端まで達してもページ全体（アジェンダ）のスクロールには波及しない。
   → 「上半分をフリックしたら月だけが動き、下のアジェンダは動かない」を実現する。 */
.month-view.is-collapsed {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top) + var(--tabs-h));
  z-index: 10;
  height: 280px; /* 曜日行(約26px) + 週84px×3 */
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-page);
}

/* 独立スクロール枠の中では、曜日行の sticky の基準が「ページ」から「パネル自身」に変わる。
   ページ基準の top 値のままだと枠の中で1段下にズレて見えるため、枠の一番上を基準にする。 */
.month-view.is-collapsed .weekday-row {
  top: 0;
}

/* パネル内に積む月ブロックの見出しは、月タブの連続スクロールと共通（.month-block-label） */

/* 月の連続スクロール表示（アジェンダOFF時）の月ごとの区切り */
.month-block-label {
  padding: 12px 10px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.month-grid-inner {
  display: flex;
  flex-direction: column;
}

.month-grid {
  display: flex;
  flex-direction: column;
}

/* 1週間分の行。帯(week-bars)は日付セルの上に絶対配置で重ねる */
.week-row {
  position: relative;
}
.week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.day-cell {
  min-height: 84px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 3px 3px 4px;
  background: var(--bg-cell);
  overflow: hidden;
}
.day-cell:nth-child(7n) { border-right: none; }

/* ---------- 週の連続スクロール表示（アジェンダOFF時） ----------
   2026-08-20改修：月ブロックを積む方式から、1週=1行・全ての行が同じ高さの
   週リストに変更した（#monthGridに.week-scrollが付いている間だけこのスコープが効く。
   ミニカレンダー側は.week-scrollを付けないので、上の.day-cell{min-height:84px}等の
   既存ルールのまま変更なし）。行の高さはJSがビューポート高から計算し、
   --week-row-h に反映する。 */
#monthGrid.week-scroll {
  display: flex;
  flex-direction: column;
}
#monthGrid.week-scroll > .week-row {
  height: var(--week-row-h);
}
#monthGrid.week-scroll > .week-row > .week-days {
  height: 100%;
}
#monthGrid.week-scroll .day-cell {
  height: 100%;
  min-height: 0;
}
/* 月の初日。日付を「M/1」にし、上辺に線を入れて月の変わり目が分かるようにする
   （高さを変えないよう border ではなく内側の影で描く） */
#monthGrid.week-scroll .day-cell.is-month-start {
  box-shadow: inset 0 3px 0 var(--month-line);
}
#monthGrid.week-scroll .day-cell.is-month-start .day-num {
  width: auto;
  padding: 0 5px;
  font-weight: 700;
  border-radius: 11px;
}
/* まだデータを取得していない週（読み込み中）。行そのものは即座に描画されるので
   スクロールは止まらない。取得完了後に paintWeekRow() が中身を描き直す。 */
#monthGrid.week-scroll .week-row.is-loading .day-cell {
  background: repeating-linear-gradient(
    180deg, var(--bg-cell), var(--bg-cell) 10px,
    var(--bg-cell-stripe) 10px, var(--bg-cell-stripe) 20px);
}
#monthGrid.week-scroll .week-row.is-loading .day-cell.is-today {
  background: var(--bg-cell-today);
}

/* 複数日予定の帯（Googleカレンダー風）。day-numの高さ分だけ下げて重ねる */
.week-bars {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 20px;
  row-gap: 2px;
  pointer-events: none;
}
.bars-spacer { pointer-events: none; }
.event-bar {
  pointer-events: auto;
  height: 20px;
  line-height: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  margin: 0 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.event-bar.cap-start { border-radius: 4px 0 0 4px; margin-left: 2px; }
.event-bar.cap-end { border-radius: 0 4px 4px 0; margin-right: 2px; }
.event-bar.cap-start.cap-end { border-radius: 4px; }
.day-cell.other-month { background: var(--bg-cell-dim); }
.day-cell.other-month .day-num { color: var(--text-day-dim); }

.day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  color: var(--text-day);
  margin-bottom: 2px;
  border-radius: 50%;
}
.day-cell.sun .day-num { color: var(--sun); }
.day-cell.sat .day-num { color: var(--sat); }
/* 祝日（国民の祝日・振替休日・国民の休日）。日曜と同じ赤。色だけで、大きさ・余白は変えない
   （週表示はマスの高さから予定の表示件数を計算しているため、日付行の高さを変えてはいけない）。
   土曜の祝日も赤にするため .sat より後に書く。今日・フォーカスの色はこの後のルールが優先する */
.day-cell.holiday .day-num { color: var(--sun); }

/* 現在アジェンダで表示中の日（ミニカレンダー側）。スクロールに連動して移動する */
.day-cell.is-focus { background: var(--bg-cell-focus); }
.day-cell.is-focus.other-month { background: var(--bg-cell-focus); }
.day-cell.is-focus .day-num { color: var(--text-day-focus); }

/* 今日（セル全体を一段明るい藍にし、1pxの輪郭で囲む）。
   曜日色・フォーカス色より優先させたいので、必ずそれらより後に書く。
   outline はレイアウトに影響せず、.is-month-start の inset box-shadow とも競合しない。 */
.day-cell.is-today {
  background: var(--bg-cell-today);
  outline: 1px solid var(--outline-today);
  outline-offset: -1px;
}
.day-cell.is-today .day-num { color: var(--text-day-today); font-weight: 500; }
/* 今日とフォーカス中の日が重なった場合は、今日の色を優先する */
.day-cell.is-today.is-focus { background: var(--bg-cell-today); }
.day-cell.is-today.is-focus .day-num { color: var(--text-day-today); }

.chip {
  display: block;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 600;
  padding: 1px 5px;
  margin-bottom: 2px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chip.has-img::after { content: " 📷"; }
.more-chip { font-size: 10px; color: var(--muted); padding-left: 4px; }

/* 色（チップ・帯の塗り。暗い背景で沈まないよう「明るい塗り＋濃い文字」の対で指定する） */
.bg-blue   { background: var(--label-blue-bg);   color: var(--label-blue-fg); }
.bg-green  { background: var(--label-green-bg);  color: var(--label-green-fg); }
.bg-red    { background: var(--label-red-bg);    color: var(--label-red-fg); }
.bg-orange { background: var(--label-orange-bg); color: var(--label-orange-fg); }
.bg-purple { background: var(--label-purple-bg); color: var(--label-purple-fg); }
.bg-gray   { background: var(--label-gray-bg);   color: var(--label-gray-fg); }
.bg-pink   { background: var(--label-pink-bg);   color: var(--label-pink-fg); }

/* ---------- アジェンダ（日毎リスト） ---------- */
.agenda-wrap {
  padding: 4px 10px 28px;
  border-top: 1px solid var(--border);
}
.agenda-list { display: flex; flex-direction: column; }
.agenda-day { margin-top: 10px; }
.agenda-day-head {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top) + var(--tabs-h));
  z-index: 5;
  background: var(--bg-page);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 2px;
}
/* 祝日の見出し（日付＋祝日名）。日曜の曜日ヘッダーと同じ赤 */
.agenda-day-head.holiday { color: var(--sun-head); }
/* 祝日名は、今日・フォーカスで見出しの色が変わっても赤のまま残す */
.agenda-holiday-name {
  margin-left: 6px;
  color: var(--sun-head);
}
/* 月表示の「今日のマス」と同じ配色（面＋1pxの輪郭）に揃える */
.agenda-day-head.is-today {
  background: var(--bg-cell-today);
  color: var(--text-day-today);
  box-shadow: inset 0 0 0 1px var(--outline-today);
  border-radius: 6px;
  padding: 6px 8px;
}

/* 現在アジェンダで表示中の日（アジェンダ側）。ミニカレンダーの is-focus と連動する */
.agenda-day.is-focus .agenda-day-head {
  background: var(--bg-cell-focus);
  color: var(--text-day-focus);
  border-radius: 6px;
  padding: 6px 8px;
}
/* 今日とフォーカス中の日が重なった場合は、今日の色を優先する */
.agenda-day.is-focus .agenda-day-head.is-today {
  background: var(--bg-cell-today);
  color: var(--text-day-today);
}
.agenda-day .event-card { margin-bottom: 8px; }
.agenda-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 2px 2px 4px;
}

.event-card {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.event-card .ec-time { font-size: 12px; color: var(--muted); min-width: 46px; }
.event-card .ec-body { flex: 1; min-width: 0; }
.event-card .ec-title { font-weight: 600; font-size: 15px; color: var(--text); word-break: break-word; }
.event-card .ec-memo {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.event-card .ec-thumbs { display: flex; gap: 4px; margin-top: 6px; }
.event-card .ec-thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

.bd-blue   { border-left-color: var(--label-blue-bg); }
.bd-green  { border-left-color: var(--label-green-bg); }
.bd-red    { border-left-color: var(--label-red-bg); }
.bd-orange { border-left-color: var(--label-orange-bg); }
.bd-purple { border-left-color: var(--label-purple-bg); }
.bd-gray   { border-left-color: var(--label-gray-bg); }
.bd-pink   { border-left-color: var(--label-pink-bg); }

/* ---------- ToDo ---------- */
#todoView { padding: 12px; }
.todo-add { display: flex; gap: 8px; margin-bottom: 12px; }
.todo-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.todo-add-btn {
  padding: 0 16px;
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
  border: none;
  border-radius: 10px;
  font-size: 14px;
}
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.todo-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.todo-item .todo-title { flex: 1; font-size: 15px; color: var(--text); word-break: break-word; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-del {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; padding: 4px 6px; border-radius: 6px;
}
.todo-empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 6px 18px var(--shadow);
  z-index: 25;
}

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.modal-card {
  position: relative;
  width: min(100%, 520px);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px var(--shadow);
  animation: slideUp .18s ease-out;
}
@media (min-width: 560px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 16px; border-bottom: 1px solid var(--border); }
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: .6; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-title { margin: 0; font-size: 18px; color: var(--text); }

.field { margin-bottom: 14px; }
.field-row { display: flex; align-items: center; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
}
textarea.field-input { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.checkbox input { width: 20px; height: 20px; accent-color: var(--primary); }

.color-picker { display: flex; gap: 10px; }
.color-dot {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; background: var(--c);
  padding: 0;
}
/* 選択中は明るい輪郭で囲む。内側の影は、暗い面の上で丸と輪郭を切り離すためのもの */
.color-dot.is-active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

.image-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.image-thumb { position: relative; width: 72px; height: 72px; }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.image-thumb .thumb-del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: var(--danger); color: var(--danger-fg); font-size: 14px; line-height: 1;
}
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.modal-foot .spacer { flex: 1; }
.primary-btn {
  background: var(--primary); color: var(--primary-fg); font-weight: 600;
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 15px;
}
.primary-btn:disabled { opacity: .45; }
.secondary-btn {
  background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px;
}
.danger-btn {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 10px; padding: 10px 14px; font-size: 14px;
}

/* チラシから予定を追加 */
.flyer-card { width: min(100%, 560px); }
.flyer-step + .flyer-step { margin-top: 0; }
.flyer-preview-wrap { margin-top: 12px; }
.flyer-preview-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
.flyer-error { color: var(--danger); }
.flyer-candidate-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
/* AI抽出の候補カード。モーダルの面より一段暗くして「くぼみ」として見せる */
.flyer-candidate {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-page);
}
/* くぼみの中の入力欄は逆に一段明るくしないと沈んで見えなくなる */
.flyer-candidate .field-input { background: var(--surface-raised); }
.flyer-candidate.is-unused { opacity: .55; }
.flyer-candidate .field:last-child { margin-bottom: 0; }
.flyer-candidate-times { display: flex; gap: 10px; }
.flyer-candidate-times .field { flex: 1; margin-bottom: 14px; }

/* 画像ビューア */
.image-viewer {
  position: fixed; inset: 0; z-index: 60;
  background: var(--scrim-strong);
  display: flex; align-items: center; justify-content: center;
}
.image-viewer img { max-width: 96vw; max-height: 92vh; border-radius: 6px; }

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 6px 20px var(--shadow);
  z-index: 80;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* 下端セーフエリア（ホームバー等）の実測用。measureWeekRowHeight() がこの要素の
   offsetHeight を読んで、週表示の1マスの高さ計算からその分を差し引く。画面には出さない。 */
.safe-probe {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 0;
  height: env(safe-area-inset-bottom, 0px);
  pointer-events: none;
  visibility: hidden;
}
