/* デザイン「ダーク」(2026-10-19 ユーザー: 見本 docs/samples/dark_design.html の案B=黒に近いグレー)。
   個人設定の「画面のデザイン」でダークを選んだ端末だけ(Cookie design=dark → <html class="theme-dark">)。当面は管理者だけ。
   見やすさ(老眼の人が多い): 字は真っ白にせず明るいグレー・薄い字も読める明るさ・線と入力欄の枠ははっきり。
   印刷には効かない(@media screen の中だけ。印刷の画面は別のレイアウトなので印も付かない)。
   色は :root の変数を入れ替え、白などを直に書いている所だけ下で上書きする */
@media screen {
  .theme-dark {
    color-scheme: dark;
    --color-bg: #141517;
    --color-surface: #1d1f22;
    --color-border: #3a3e44;
    --color-text: #e6e9ee;
    --color-muted: #aab3bf;
    --color-text-muted: #aab3bf;
    --color-primary: #2f6fb5;
    --color-primary-dark: #8cb8ee;
    --band: #26292d;
    --frame: #8cb8ee;
    --color-accent: #e0a46e;
    --color-danger: #f09a92;
    --color-warning: #e8c06a;
    --input-border: #8a95a5;
    --side-bg: #101113;
    --dk-row: #212327;
    --dk-hover: #2b2e33;
    --dk-input: #17181b;
  }
  .theme-dark body { background: var(--color-bg); color: var(--color-text); }
  .theme-dark a { color: var(--frame); }
  .theme-dark input::placeholder, .theme-dark textarea::placeholder { color: #7d8794; }

  /* ---- 左のメニュー・下の帯 ---- */
  .theme-dark .app-shell { --side-bg: #101113; --side-line: rgba(255, 255, 255, 0.12); --side-hover: rgba(255, 255, 255, 0.07); }
  .theme-dark .app-shell .sidebar { border-right: 1px solid var(--color-border); }
  .theme-dark .app-shell .sidebar .font-scale__option.is-active { background: var(--color-text); color: #101113; }
  .theme-dark .tab-bar { background: rgba(20, 21, 23, 0.92); border-top-color: var(--color-border); box-shadow: none; }
  .theme-dark .tab-bar { border-color: #3a3d42; }
  .theme-dark .tab-bar__item { color: var(--color-text); }

  /* ---- 見出し・項目名 ---- */
  .theme-dark .page-title { color: var(--frame); }
  .theme-dark .section-title { color: var(--frame); }
  .theme-dark .field label { color: var(--color-text); }
  .theme-dark .search-form .field label { color: var(--color-muted); }
  .theme-dark .tabs__count { background: #3a3e44; color: var(--color-text); }
  .theme-dark .mail-folders__item .tabs__count { background: #3b7be8; color: #fff; } /* メールのフォルダの未読の数(2026-10-27)は青の地に白 */
  .theme-dark .mail-folders__item.is-active .tabs__count { background: #fff; color: #1f2933; }

  /* ---- 窓・帯・表 ---- */
  .theme-dark .card,
  .theme-dark .toast,
  .theme-dark .delete-reason,
  .theme-dark dialog { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
  .theme-dark dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
  .theme-dark .table th { background: var(--band); color: var(--color-text); }
  .theme-dark .table td { border-color: var(--color-border); }
  .theme-dark .table tbody tr:hover td,
  .theme-dark tr[data-href]:hover td { background: var(--dk-hover); }
  .theme-dark .search-form { background: var(--band); }
  .theme-dark .flash--notice { background: #1f3350; color: #cfe0f7; }
  .theme-dark .flash--alert, .theme-dark .errors { background: #3b1f1f; color: #f6c0bb; border-color: #7a3b36; }
  .theme-dark .toast__close:hover { background: var(--dk-hover); }

  /* ---- ボタン ---- */
  .theme-dark .btn { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
  .theme-dark .btn--secondary { background: transparent; color: var(--frame); border-color: var(--frame); }
  .theme-dark .btn--secondary:hover { background: #22303f; }
  .theme-dark .btn--danger { background: #a8413a; border-color: #a8413a; color: #fff; }
  .theme-dark .btn--danger-outline { background: transparent; color: var(--color-danger); border-color: #e07a72; }
  .theme-dark .font-scale__option { background: transparent; color: var(--color-text); border-color: var(--color-border); }
  .theme-dark .font-scale__option.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

  /* ---- 入力欄(中を一段暗く・枠は明るいグレー) ---- */
  .theme-dark input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=file]),
  .theme-dark select,
  .theme-dark textarea { background-color: var(--dk-input); color: var(--color-text); border-color: var(--input-border); }
  /* 時刻の箱と、押すと出る時・分の窓(time_picker_controller.js) */
  .theme-dark .tp-box, .theme-dark .tp-panel { background: var(--dk-input); color: var(--color-text); }
  .theme-dark .tp-box__clock { color: var(--color-muted); }
  .theme-dark .tp-item:hover { background: #2a3038; }
  .theme-dark .tp-item.is-on { background: #3d8bf0; }
  .theme-dark input[type=file] { color: var(--color-text); }
  .theme-dark .search-form .field input[type=text], .theme-dark .search-form .field input[type=date],
  .theme-dark .search-form .field input[type=number], .theme-dark .search-form .field select { background-color: var(--dk-input); border-color: var(--input-border); color: var(--color-text); }

  /* ---- 見積書・請求書の明細の表 ---- */
  .theme-dark .items-table thead th { background: var(--band); color: var(--color-muted); }
  .theme-dark .items-table tbody tr:hover td { background: var(--dk-hover); }

  /* ---- 損益計算書の「営業損益」の行は Excel と同じ黄色の帯のまま、字を濃い色に(2026-11-24: 黄色に白い字で読めなかった) ---- */
  .theme-dark .pl-row--result td { color: #222020; }

  /* ---- 書類の見本(請求書・見積書の画面の下の紙)は白い紙のまま。中の色の決まりを元に戻す ---- */
  .theme-dark .print-page {
    --color-surface: #ffffff; --color-border: #c9d2de; --color-text: #222020; --color-muted: #5c5852; --color-text-muted: #5c5852;
    --color-primary: #113961; --color-primary-dark: #0d2d4e; --band: #edf0f5; --frame: #2f5f93; --color-accent: #a06a3c; --color-danger: #b3453d;
    /* 行の交互色などもノーマルの色に(2026-11-23 ユーザー: 請求書の明細が1行おきに黒くなり、料理などの品名が読めなかった。design.css.erb の
       「1行おきに色を付ける」がダークの色のまま紙の中にも効いていた) */
    --rn-row-alt: #f8fafc; --rn-row-hover: #eaf1f8; --rn-cell-line: #e3e8ee; --rn-amount: #f1f4f8;
    background: #fff; color: #222020; border-color: #c9d2de;
  }
  .theme-dark .print-page .table th { background: var(--band); color: var(--color-primary); }
  .theme-dark .print-page .table td { border-color: var(--color-border); }
  .theme-dark .print-page .table tbody tr:hover td, .theme-dark .print-page tr[data-href]:hover td { background: #f3f6fa; }
  .theme-dark .print-page .page-title, .theme-dark .print-page .section-title { color: inherit; }

  /* ---- スケジュール ---- */
  .theme-dark .schedule-week__name { background: #1a1c1f; }
  .theme-dark .schedule-week__funerals td { background: #2a2418; }
  .theme-dark .schedule-week__funerals th { background: #33291a; }
  .theme-dark .schedule-week tr.is-me th { background: #1f2a3a; }
  .theme-dark .schedule-week thead th.is-sat, .theme-dark .schedule-month thead th.is-sat { background: #1d2a3d; }
  .theme-dark .schedule-week thead th.is-sun, .theme-dark .schedule-month thead th.is-sun { background: #3a2222; }
  .theme-dark th.is-sat, .theme-dark td.is-sat .schedule-day__date, .theme-dark th.is-sat .schedule-day__date { color: #8cb8ee; }
  .theme-dark th.is-sun, .theme-dark td.is-sun .schedule-day__date, .theme-dark th.is-sun .schedule-day__date { color: #f09a92; }
  .theme-dark .schedule-week tbody td.is-today, .theme-dark .schedule-month td.is-today { background: #2a2a1c; }
  .theme-dark .schedule-week thead th.is-today, .theme-dark .schedule-month td.is-today { box-shadow: inset 0 0 0 2px #8cb8ee; }
  .theme-dark .schedule-week td.is-conflict { background: #3a2422; }
  .theme-dark .schedule-item { background: #26303d; color: var(--color-text); }
  .theme-dark .schedule-item:hover { background: #2f3b4b; }
  .theme-dark .schedule-item--funeral { background: #3a2f1c; }
  .theme-dark .schedule-item--kind-0 { background: #1f3344; }
  .theme-dark .schedule-item--colored { background: color-mix(in srgb, var(--menu-color) 26%, #1d1f23); }
  .theme-dark .schedule-item--colored:hover { background: color-mix(in srgb, var(--menu-color) 36%, #1d1f23); }
  .theme-dark .schedule-item--funeral:hover { background: #46391f; }
  .theme-dark .schedule-item--provisional { background: #2a2618; }
  .theme-dark .dash-table tr.is-today td { background: #2a2a1c; }

  /* ---- ホームのお知らせ ---- */
  .theme-dark .home__notice { background: #3a2f17; border-color: #8a6b2a; color: #f4dfae; }
  .theme-dark .home__notice:hover { background: #45381c; }
  .theme-dark .home__notice-icon { background: #1d1f22; }
  .theme-dark .home__notice-text strong { color: #ffcf6b; }
  .theme-dark .home__notice-arrow { color: #c9b98d; }
  .theme-dark .home__notice--error { background: #3b1f1f; border-color: #7a3b36; color: #f6c0bb; }
  .theme-dark .home__notice--error:hover { background: #462424; }
  .theme-dark .home__notice--error .home__notice-text strong { color: #ffb3ab; }
  /* スマホのホームの小さな札(2026-11-20)。ホームの帯と同じ色に・丸の中の絵が見えるように・会員確認は赤い縞のまま */
  .theme-dark .home__tile { background: #3a2f17; border-color: #8a6b2a; color: #f4dfae; }
  .theme-dark .home__tile-icon { background: #1d1f22; color: #ffcf6b; }
  .theme-dark .home__tile-text strong { color: #ffcf6b; }
  .theme-dark .home__tile--error { background: #3b1f1f; border-color: #7a3b36; color: #f6c0bb; }
  .theme-dark .home__tile--error .home__tile-icon { color: #ff8f84; }
  .theme-dark .home__tile--error strong { color: #ffb3ab; }
  .theme-dark .home__tile--member { background: repeating-linear-gradient(-45deg, #b3271a 0 14px, #c2382a 14px 28px); border-color: #e04a3a; color: #fff; }
  .theme-dark .home__tile--member .home__tile-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }
  .theme-dark .home__tile--member strong { color: #fff; }

  /* ---- 色の印(バッジ)。暗い下地に明るい字 ---- */
  .theme-dark .badge--pre_consultation, .theme-dark .badge--estimate_target, .theme-dark .badge--new_consultation { background: #1f3b61; color: #a9cdf7; }
  .theme-dark .badge--funeral_customer, .theme-dark .badge--deceased_target, .theme-dark .badge--set, .theme-dark .badge--following_up { background: #4a3218; color: #f6c48f; }
  .theme-dark .badge--member_only, .theme-dark .badge--member, .theme-dark .badge--issued, .theme-dark .badge--paid,
  .theme-dark .badge--contracted, .theme-dark .badge--ok, .theme-dark .badge--added { background: #1d4430; color: #9fe0b5; }
  .theme-dark .badge--retail_customer, .theme-dark .badge--partially_paid, .theme-dark .badge--considering, .theme-dark .badge--retail_target,
  .theme-dark .badge--warn, .theme-dark .badge--name-change { background: #45391a; color: #f0d58a; }
  .theme-dark .badge--deceased, .theme-dark .badge--muted, .theme-dark .badge--draft, .theme-dark .badge--completed { background: #33363b; color: #c7ccd3; }
  .theme-dark .badge--legacy { background: #352d4d; color: #cbbcf2; }
  .theme-dark .badge--voided, .theme-dark .badge--unpaid, .theme-dark .badge--complaint { background: #4d2222; color: #f6a6a0; }

  /* ---- ホーム ---- */
  .theme-dark .home-card__title a { color: var(--color-text); }

  /* ---- 白を直に書いている部品 ---- */
  .theme-dark .file-list__eye:hover, .theme-dark .schedule-files__photo { background: var(--dk-hover); }
  .theme-dark .m-list { background: var(--color-surface); border-color: var(--color-border); }
  /* メールの本文(HTML)はお客様のメールの色のまま読めるよう白い紙のまま */
  .theme-dark .mail-html { background: #fff; }
}

/* アイコン(2026-10-19 ユーザー: ガラスのように線の枠にして、色ではなく白に)。左のメニューと下の帯。
   今いる画面はうすく白で塗って枠を明るく(下の帯は枠を太く) */
@media screen {
  .theme-dark .sidebar__top-link > .icon-tile,
  .theme-dark .sidebar__group > summary > .icon-tile,
  .theme-dark .tab-bar__item > .icon-tile {
    background: transparent; border: 1.8px solid #c9ced6; color: #e6e9ee; stroke: #e6e9ee; border-radius: 9px; box-shadow: none;
  }
  .theme-dark .sidebar__top-link > .icon-tile [stroke="#fff"],
  .theme-dark .sidebar__group > summary > .icon-tile [stroke="#fff"],
  .theme-dark .tab-bar__item > .icon-tile [stroke="#fff"] { stroke: #e6e9ee; }
  .theme-dark .sidebar__top-link--current > .icon-tile,
  .theme-dark .sidebar__group--current > summary > .icon-tile { background: rgba(255, 255, 255, 0.14); border-color: #ffffff; }
  .theme-dark .tab-bar__item { color: #c9ced6; }
  .theme-dark .tab-bar__item.is-active { color: #ffffff; font-weight: 700; }
  .theme-dark .tab-bar__item.is-active > .icon-tile { border-width: 2.4px; border-color: #ffffff; background: rgba(255, 255, 255, 0.14); }
}

/* スマホの上の帯の「…」の中の気をつける項目(2026-10-27) */
.theme-dark .mbar-pop__item--danger { color: #f0a39c; }
.theme-dark .mobile-bar.mobile-bar--page.is-scrolled { background: rgba(30, 29, 27, 0.97); }

/* メモ(2026-10-28 ノートの形): 題名・本文・やることの欄は地の色のまま(枠のない紙に書く形) */
.theme-dark :is(.memo-b__title, .memo-b__body, .memo-b__item-text, .memo-b__add-item input) { background: transparent !important; } /* 入力欄の決まり(.theme-dark input:not(...))より強く */
.theme-dark .memo-b__row.is-active { background: #34322e; }
@media (hover: hover) { .theme-dark .memo-b__row:hover, .theme-dark .memo-b__row.is-active:hover { background: #2e2c29; } }
.theme-dark .memo-b__tool:hover { background: #2e2c29; }
/* 顧客の画面の請求書の売上区分の見出し(2026-10-29): 紺などの暗い色の線が黒地で見えないので白を混ぜる */
.theme-dark .invoice-group-row > td:first-child { box-shadow: inset 4px 0 0 color-mix(in srgb, var(--group-color, #8a8f96) 60%, #ffffff); }
.theme-dark .invoice-actions.is-floating { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
/* スマホのメニューの窓の題名(2026-11-14): 紺の字が黒地で見えないので明るく */
.theme-dark .mobile-menu__head { color: #d7e2ee; }
.theme-dark .mobile-menu__group.is-on { box-shadow: 5px 6px 10px rgba(0, 0, 0, 0.65), 2px 2px 3px rgba(0, 0, 0, 0.5), inset 1px 1px 0 rgba(255, 255, 255, 0.12); }

/* TODO の「灰」は白のカードと見分けやすく少し明るく(2026-11-18) */
.theme-dark .todo-card--gray { background: #313338; }

/* スマホのホームの「今日」「明日」の押している方(2026-11-18) */
.theme-dark .home-day__btn.is-active { background: #a2c0e1; color: #14171c; }
