/* 明るいテーマで、薄すぎる文字と戻るボタンをテーマの色に合わせる（dark クラスの有無で切り替え） */
html:not(.dark) #app-shell .text-slate-400, html:not(.dark) #sidebar .text-slate-400 { color: rgb(var(--n-500)); }
html .back-btn { color: rgb(var(--p-700)); border-color: rgb(var(--p-500) / .45); background: rgb(var(--p-500) / .1); }
html .back-btn:hover { background: rgb(var(--p-500) / .2); border-color: rgb(var(--p-500) / .75); }
html .back-btn:focus-visible { outline-color: rgb(var(--p-500)); }
html.dark .back-btn { color: rgb(var(--p-200)); border-color: rgb(var(--p-300) / .45); background: rgb(var(--p-400) / .14); }
html.dark .back-btn:hover { background: rgb(var(--p-400) / .28); }

/* 模様付きテーマの背景＆サイドバーパターン（単色テーマでは none で変化なし） */
body {
    background-image: var(--theme-bg-image, none);
    background-size: var(--theme-bg-size, auto);
    background-repeat: repeat;
    background-attachment: fixed;
}
#sidebar {
    background-image: var(--theme-side-image, none);
    background-size: var(--theme-side-size, auto);
    background-repeat: repeat;
}
/* 模様付きテーマ時はカードの縁を少し引き締め、背景パターンが美しく映えるように */
html[data-theme-pattern="1"] .card {
    background-color: rgb(255 255 255 / 0.93);
    backdrop-filter: blur(4px);
}
html.dark[data-theme-pattern="1"] .card {
    background-color: rgb(var(--n-900) / 0.92);
    backdrop-filter: blur(4px);
}
@media (max-width: 767px) {
    /* モバイルのスクロール性能のため fixed は外す */
    body { background-attachment: scroll; }
}

/* メニューのページ（日程・チャット・立て替え・タスク・ShareFile など）は、本文の面を塗らずにテーマの背景（色・模様）を見せる。
   タスク（planner.css）と ShareFile（files/index）はページ内で色を決めているので、その変数だけを上書きする */
html body .pl-shell { --pl-canvas: transparent; }
html.dark body .pl-shell { --pl-canvas: transparent; }
html body .sf-shell { --sf-bg: transparent; --sf-side: rgb(var(--n-100) / .55); --sf-bar: rgb(var(--n-50) / .72); }
html.dark body .sf-shell { --sf-bg: transparent; --sf-side: rgb(var(--n-950) / .45); --sf-bar: rgb(var(--n-900) / .6); }
/* 模様付きテーマでは、管理画面などの白いパネルもカードと同じく少し透かす */
html[data-theme-pattern="1"] .portal-panel {
    background-color: rgb(255 255 255 / 0.93);
    backdrop-filter: blur(4px);
}
html.dark[data-theme-pattern="1"] .portal-panel {
    background-color: rgb(var(--n-900) / 0.92);
    backdrop-filter: blur(4px);
}

/* ===== 読みやすさ: 補足の小さい文字（日付・件数・説明など）が、色付きのテーマや模様の上で薄くなりすぎないようにする ===== */
/* 明るいテーマ: 薄い灰色の文字を一段濃く（本文の濃い文字との差は残す） */
html:not(.dark) #app-shell .text-slate-400, html:not(.dark) #app-shell .text-slate-500,
html:not(.dark) #sidebar .text-slate-400, html:not(.dark) #sidebar .text-slate-500,
html:not(.dark) .adm-del, html:not(.dark) .portal-title small,
html:not(.dark) .acc-nav-sub, html:not(.dark) .acc-switch-desc, html:not(.dark) .adm-note { color: rgb(var(--n-600)); }
html:not(.dark) #app-shell .text-slate-300 { color: rgb(var(--n-500)); }
/* 色付きの小さい文字（土曜の青・日曜祝日の赤・未回答のオレンジ・オンラインの緑など）も一段濃く */
html:not(.dark) #app-shell .text-sky-500, html:not(.dark) #app-shell .text-sky-600 { color: #0369a1; }
html:not(.dark) #app-shell .text-rose-500, html:not(.dark) #app-shell .text-rose-600 { color: #be123c; }
html:not(.dark) #app-shell .text-amber-600 { color: #b45309; }
html:not(.dark) #app-shell .text-emerald-600 { color: #047857; }
html:not(.dark) #sidebar .text-amber-700 { color: #92400e; }
/* 見出しの帯（主役の色の上）の薄い白文字は、透かさずに出す */
#app-shell .text-indigo-100\/80, #app-shell .text-indigo-100\/70 { color: #fff; }
/* タスク・ShareFile の補足の文字とテーマアクセント連動 */
html body .pl-shell { --pl-muted: rgb(var(--n-600)); }
html body .sf-shell {
    --sf-muted: rgb(var(--n-600));
    --sf-accent: rgb(var(--p-600));
    --sf-accent-hover: rgb(var(--p-700));
    --sf-accent-soft: rgb(var(--p-500) / .12);
    --sf-accent-border: rgb(var(--p-500) / .32);
}
html.dark body .pl-shell, html.dark body .sf-shell { --pl-muted: rgb(var(--n-300)); --sf-muted: rgb(var(--n-300)); }
html.dark body .sf-shell {
    --sf-accent: rgb(var(--p-400));
    --sf-accent-hover: rgb(var(--p-500));
    --sf-accent-soft: rgb(var(--p-400) / .16);
    --sf-accent-border: rgb(var(--p-400) / .35);
}
html body .sf-brand-mark {
    background: linear-gradient(135deg, rgb(var(--p-700)) 0%, rgb(var(--p-600)) 55%, rgb(var(--p-400)) 100%);
    box-shadow: 0 4px 12px rgb(var(--p-600) / .30);
}
html body .sf-storage-fill {
    background: linear-gradient(90deg, rgb(var(--p-600)), rgb(var(--p-400)));
}

/* 暗いテーマ: 暗い用の色の指定がない薄い灰色の文字を一段明るく */
html.dark #app-shell .text-slate-500:not([class*="dark:text-"]), html.dark #sidebar .text-slate-500:not([class*="dark:text-"]) { color: rgb(var(--n-400)); }
html.dark #app-shell .text-slate-400:not([class*="dark:text-"]), html.dark #sidebar .text-slate-400:not([class*="dark:text-"]) { color: rgb(var(--n-300)); }
html.dark #app-shell .dark\:text-slate-500 { color: rgb(var(--n-400)); }
html.dark #app-shell .dark\:text-slate-600 { color: rgb(var(--n-400)); }
html.dark .acc-switch-desc, html.dark .portal-title small { color: rgb(var(--n-400)); }
/* 暗いテーマの主ボタン（白い文字）は、明るすぎる地の色を一段濃くする */
html.dark .adm-btn { background-color: rgb(var(--p-600)); }
html.dark .adm-btn:hover { background-color: rgb(var(--p-500)); }
/* 在席の文字（オンライン・取り込み中など）とマイアカウントの「編集する」も、明るいテーマでは一段濃く */
html:not(.dark) .pr-text[data-status="available"] { color: #047857; }
html:not(.dark) .pr-text[data-status="busy"] { color: #be123c; }
html:not(.dark) .pr-text[data-status="away"] { color: #b45309; }
html:not(.dark) .pr-text[data-status="offline"] { color: rgb(var(--n-600)); }
html:not(.dark) .acc-quick-link { color: rgb(var(--p-700)); }
