/* Theme changes affect interface surfaces only; receipt images/canvases keep their colors. */
:root { color-scheme: light; }
body { background: var(--paper); }
.theme-settings { margin: 20px 0 24px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.theme-settings h3 { margin: 0; }
.theme-settings label { margin-top: 12px; }
.theme-settings .help { margin-bottom: 0; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e3e9e3;
  --muted: #a1b2a6;
  --green: #9fd9b5;
  --leaf: #1d3326;
  --paper: #0b120e;
  --line: #2b3d32;
  --white: #131d17;
  --amber: #f0cc89;
  --red: #ffaca0;
  --theme-surface: #131d17;
  --theme-raised: #19271f;
  --theme-hover: #213328;
  --theme-accent-ink: #0d2016;
}

[data-theme="dark"] button,
[data-theme="dark"] .card,
[data-theme="dark"] .review-inbox,
[data-theme="dark"] .expense-item,
[data-theme="dark"] .ap-card,
[data-theme="dark"] .ap-list,
[data-theme="dark"] .ap-close,
[data-theme="dark"] .scan-busy-card,
[data-theme="dark"] dialog {
  background: var(--theme-surface);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme="dark"] button:hover:not(:disabled) { background: var(--theme-hover); }
[data-theme="dark"] .quiet,
[data-theme="dark"] .nav button,
[data-theme="dark"] .quick button { background: transparent; }
[data-theme="dark"] .quiet:hover:not(:disabled),
[data-theme="dark"] .nav button:hover:not(:disabled),
[data-theme="dark"] .quick button:hover:not(:disabled) { background: var(--theme-hover); }
[data-theme="dark"] .primary,
[data-theme="dark"] .filters .active,
[data-theme="dark"] .camera-shot,
[data-theme="dark"] .camera-pick,
[data-theme="dark"] .nav .count,
[data-theme="dark"] .today-tag {
  background: var(--green);
  color: var(--theme-accent-ink);
  border-color: var(--green);
}
[data-theme="dark"] .primary:hover:not(:disabled),
[data-theme="dark"] .filters .active:hover:not(:disabled),
[data-theme="dark"] .camera-shot:hover:not(:disabled) { background: #c0efd0; color: var(--theme-accent-ink); }
[data-theme="dark"] .danger,
[data-theme="dark"] .error { color: var(--red); }
[data-theme="dark"] .sidebar { background: var(--theme-surface); border-color: var(--line); }
[data-theme="dark"] .nav button.active { background: var(--leaf); color: var(--green); }
[data-theme="dark"] .profile { border-color: var(--line); }
[data-theme="dark"] .avatar,
[data-theme="dark"] .quick .iconbox { background: var(--leaf); color: var(--green); }
[data-theme="dark"] .mark { background: #325e44; color: #d8f4cf; }
[data-theme="dark"] .mobilebrand span,
[data-theme="dark"] .clocksec,
[data-theme="dark"] .clockdate,
[data-theme="dark"] .punchmeta,
[data-theme="dark"] .arrow,
[data-theme="dark"] .footnote,
[data-theme="dark"] .requestnote,
[data-theme="dark"] .approval-stats { color: var(--muted); }
[data-theme="dark"] .punchmeta strong,
[data-theme="dark"] .approval-stats strong,
[data-theme="dark"] .empty strong { color: var(--green); }
[data-theme="dark"] .clockcard,
[data-theme="dark"] .punch-first .clockcard { background: #1d3427; border-color: var(--line); }
[data-theme="dark"] .punchmeta { border-color: var(--line); }
[data-theme="dark"] .pill { background: var(--theme-raised); color: #c4d2c5; }
[data-theme="dark"] .pill.green { background: #214331; color: #b0e5bc; }
[data-theme="dark"] .pill.amber { background: #443720; color: #f0ce88; }
[data-theme="dark"] .pill.red { background: #482d2b; color: #ffc1b6; }
[data-theme="dark"] .notice { background: var(--theme-raised); color: #c1d4bd; border-color: #8caa7a; }
[data-theme="dark"] th { background: var(--theme-raised); }
[data-theme="dark"] td { border-color: var(--line); }
[data-theme="dark"] .month-attendance .is-weekend { background: #19272a; }
[data-theme="dark"] .month-attendance .is-today { background: #233f2c; }
[data-theme="dark"] .attendance-totals>div,
[data-theme="dark"] .pattern-list>div,
[data-theme="dark"] .schedule-grid th:first-child { background: var(--theme-raised); }
[data-theme="dark"] .schedule-grid .scheduled { background: #254331; color: var(--ink); }
[data-theme="dark"] .schedule-grid .scheduled:hover:not(:disabled) { background: #335c43; }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .ap-filter select,
[data-theme="dark"] .camera-pick input {
  background: #121e17;
  color: var(--ink);
  border-color: #49634f;
  accent-color: var(--green);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #9aad9f; opacity: 1; }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus { outline-color: #a5d897; }
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] a:focus-visible { outline-color: #f0ce88; }
[data-theme="dark"] .auth-art { background: #1d3023; }
[data-theme="dark"] .auth-art:after { border-color: #486240; box-shadow: 0 0 0 70px #283e29, 0 0 0 140px #233726; }
[data-theme="dark"] .auth-title p,
[data-theme="dark"] .auth-art footer { color: var(--muted); }
[data-theme="dark"] .auth-form { background: var(--paper); }
[data-theme="dark"] dialog { box-shadow: 0 20px 100px #0008; }
[data-theme="dark"] dialog::backdrop { background: #030905aa; }
[data-theme="dark"] dialog .scan-busy { background: #07110bbf; }
[data-theme="dark"] .scan-panel { background: #14271c; border-color: var(--line); }
[data-theme="dark"] .scan-pick-sub button { background: var(--theme-surface); }
[data-theme="dark"] .scan-pick-sub button:hover:not(:disabled) { background: var(--theme-hover); }
[data-theme="dark"] .scan-stage,
[data-theme="dark"] .scan-preview { border-color: #607865; }
[data-theme="dark"] .records-image-scroll { background: #07110b; border-color: var(--line); }
[data-theme="dark"] .scan-stage [data-corner] { background: #087f72; color: #fff; border-color: #fff; }
[data-theme="dark"] .add-receipt { background: var(--theme-raised); color: var(--green); border-color: #718f78; }
[data-theme="dark"] .add-receipt:hover:not(:disabled) { background: var(--theme-hover); }
[data-theme="dark"] .ap-card.pick { background: #253e2b; border-color: var(--green); }
[data-theme="dark"] #toast { background: #d0edd4; color: #142a1b; }
[data-theme="dark"] .demo-banner { background: #463c25; color: #f0dca5; }

/* トップ画面の変数（ダーク） */
[data-theme="dark"] .home {
  --home-hero-bg: linear-gradient(160deg, #1d3427 0%, #142a1e 100%);
  --home-hero-line: var(--line);
  --home-accent: var(--green);
  --home-accent-ink: var(--theme-accent-ink);
  --home-brass: #d8bd85;
  --home-surface: var(--theme-surface);
  --home-danger-bg: #3a2522;
  --home-danger-line: #7a4a42;
  --home-warn-bg: #3a3020;
  --home-warn-line: #7a6136;
  --home-info-bg: var(--theme-raised);
  --home-info-line: var(--line);
}
[data-theme="dark"] .home .home-clock { background: var(--home-hero-bg); border-color: var(--home-hero-line); }
[data-theme="dark"] .home-punch .home-punch-main { background: var(--home-accent); color: var(--home-accent-ink); border-color: var(--home-accent); }
[data-theme="dark"] .home-tile .count,
[data-theme="dark"] .home-more .count { color: #2a120e; }

/* ===== 配色（data-palette）=====
   theme.js が data-palette に komorebi / light / dark を入れる。
   Komorebi は data-theme="dark" の上に重ねるため、上のダーク用の調整（入力欄・表・モーダル・状態色など）をそのまま使い、色だけを変える。
   画像は使わず、木漏れ日は静的なグラデーションだけで表す（アニメーション・backdrop-filter なし）。 */

/* --- Komorebi：深い森・生成り・控えめな真鍮 --- */
:root[data-palette="komorebi"] {
  --ink: #efe9da;
  --muted: #b8bca7;
  --green: #a8dbb1;
  --leaf: #1f3b2b;
  --paper: #0e1f17;
  --line: #2e4837;
  --white: #15291f;
  --amber: #ebc97f;
  --red: #ffb3a3;
  --brass: #d3b26c;
  --theme-surface: #15291f;
  --theme-raised: #1b3427;
  --theme-hover: #234030;
  --theme-accent-ink: #0d1f15;
}
[data-palette="komorebi"] body {
  background:
    radial-gradient(70% 45% at 12% -8%, rgba(255, 226, 158, .13), rgba(255, 226, 158, 0) 70%),
    linear-gradient(118deg, rgba(255, 236, 190, 0) 30%, rgba(255, 236, 190, .035) 40%, rgba(255, 236, 190, 0) 50%),
    linear-gradient(180deg, #11251b 0%, #0b1912 100%);
  background-color: var(--paper);
}
[data-palette="komorebi"] .sidebar { background: linear-gradient(180deg, #13291e 0%, #0c1c14 100%); border-color: rgba(211, 178, 108, .18); }
[data-palette="komorebi"] .mark { background: linear-gradient(145deg, #e2c98c, #b8914a); color: #14281c; }
[data-palette="komorebi"] .nav button.active { background: rgba(211, 178, 108, .12); color: #f3e4bb; box-shadow: inset 3px 0 0 var(--brass); }
[data-palette="komorebi"] .card,
[data-palette="komorebi"] .review-inbox { background: linear-gradient(180deg, rgba(255, 240, 200, .035), rgba(255, 240, 200, 0) 45%), var(--theme-surface); border-color: var(--line); }
[data-palette="komorebi"] .primary,
[data-palette="komorebi"] .home-punch .home-punch-main { background: linear-gradient(180deg, #367650, #275e3d); color: #fbf6e7; border-color: #4a8d63; }
[data-palette="komorebi"] .primary:hover:not(:disabled),
[data-palette="komorebi"] .home-punch .home-punch-main:hover:not(:disabled) { background: linear-gradient(180deg, #3a7d54, #2b6542); color: #fff; }
[data-palette="komorebi"] input,
[data-palette="komorebi"] select,
[data-palette="komorebi"] textarea { background: #10231a; border-color: #40604a; }
[data-palette="komorebi"] th { background: #1a3225; }
[data-palette="komorebi"] .clockcard { background: #1a3426; }
[data-palette="komorebi"] .notice { border-color: #a4884e; }
[data-palette="komorebi"] .home {
  --home-hero-bg:
    radial-gradient(110% 85% at 88% -18%, rgba(255, 222, 150, .30), rgba(255, 222, 150, 0) 58%),
    linear-gradient(112deg, rgba(255, 236, 190, 0) 38%, rgba(255, 236, 190, .07) 46%, rgba(255, 236, 190, 0) 56%),
    linear-gradient(165deg, #25462f 0%, #142b1f 100%);
  --home-hero-line: rgba(211, 178, 108, .28);
  --home-accent: #a8dbb1;
  --home-brass: var(--brass);
  --home-surface: var(--theme-surface);
  --home-line: var(--line);
}
[data-palette="komorebi"] .home-clock .clock { color: #f5eedb; }
[data-palette="komorebi"] .home-tile-icon svg { color: var(--brass); }
[data-palette="komorebi"] .home-punch .home-punch-main { box-shadow: 0 8px 22px rgba(0, 0, 0, .28); }

/* --- Light：生成り・淡い緑・柔らかな木漏れ日 --- */
:root[data-palette="light"] {
  --ink: #243a30;
  --muted: #5d6a5a;
  --green: #2e6a4b;
  --leaf: #e6eddb;
  --paper: #f5f1e6;
  --line: #e2dccb;
  --white: #fffdf8;
}
[data-palette="light"] body {
  background:
    radial-gradient(60% 40% at 10% -10%, rgba(255, 224, 150, .30), rgba(255, 224, 150, 0) 70%),
    linear-gradient(180deg, #f7f3ea 0%, #f1efe3 100%);
  background-color: var(--paper);
}
[data-palette="light"] .sidebar { background: linear-gradient(180deg, #f1eee1 0%, #e9eddd 100%); }
[data-palette="light"] .nav button.active { background: #e1e9d4; color: #275a3f; box-shadow: inset 3px 0 0 #b8954f; }
[data-palette="light"] .card { background: var(--white); }
[data-palette="light"] .home {
  --home-hero-bg:
    radial-gradient(100% 80% at 90% -20%, rgba(255, 224, 150, .45), rgba(255, 224, 150, 0) 60%),
    linear-gradient(160deg, #f8f5ec 0%, #e5ede0 100%);
  --home-hero-line: #dcd6c2;
  --home-brass: #a5823f;
}
