/* ==========================================
   🎨 テーマカラー定義（一括切り替え用）
   ========================================== */
   :root {
  --radius-lg: 24px;
  --radius-md: 16px;
}

/* 1. 今の状態（デフォルト：ライト・マイルド） */
:root, body[data-theme="default"] {
  --primary: #546e7a;
  --text-main: #333333;
  --text-sub: #777777;
  --bg: #f2f4f6;
  --card-bg: #ffffff;
  --yellow: #fff9c4;
  --red: #ff4d4d;
  --shadow: 0 12px 40px rgba(0,0,0,0.06); 

  /* 教科ごとの色（背景色 / 文字色） */
  --sub-red: #ffebee; --sub-red-text: #c62828;
  --sub-blue: #e3f2fd; --sub-blue-text: #1565c0;
  --sub-green: #e8f5e9; --sub-green-text: #2e7d32;
  --sub-yellow: #fff9c4; --sub-yellow-text: #827717;
  --sub-purple: #f3e5f5; --sub-purple-text: #6a1b9a;
  --sub-orange: #fff3e0; --sub-orange-text: #ef6c00;
  --sub-pink: #fce4ec; --sub-pink-text: #ad1457;
  --sub-teal: #e0f2f1; --sub-teal-text: #00695c;
}

/* 2. ダーク（夜間モード） */
body[data-theme="dark"] {
  --primary: #90a4ae;
  --text-main: #e0e0e0;
  --text-sub: #9e9e9e;
  --bg: #121212;
  --card-bg: #1e1e1e;
  --yellow: #373316;
  --red: #cf6679;
  --shadow: 0 12px 40px rgba(0,0,0,0.5);

  --sub-red: #3c1e1e; --sub-red-text: #ff8a80;
  --sub-blue: #1a237e; --sub-blue-text: #82b1ff;
  --sub-green: #1b5e20; --sub-green-text: #b9f6ca;
  --sub-yellow: #333000; --sub-yellow-text: #ffff8d;
  --sub-purple: #4a148c; --sub-purple-text: #ea80fc;
  --sub-orange: #e65100; --sub-orange-text: #ffd180;
  --sub-pink: #880e4f; --sub-pink-text: #ff80ab;
  --sub-teal: #004d40; --sub-teal-text: #a7ffeb;
}

/* 3. 新緑（鮮やかなグリーンと木漏れ日） */
body[data-theme="shinryoku"] {
  --primary: #2e7d32;
  --text-main: #2c3e2b;
  --text-sub: #617d5f;
  --bg: #f1f8e9;
  --card-bg: #ffffff;
  --yellow: #fffde7;
  --red: #d32f2f;
  --shadow: 0 12px 40px rgba(46,125,50,0.05);

  --sub-red: #ffebee; --sub-red-text: #c62828;
  --sub-blue: #e8f5e9; --sub-blue-text: #2e7d32; /* 新緑の主役 */
  --sub-green: #c8e6c9; --sub-green-text: #1b5e20;
  --sub-yellow: #f0f4c3; --sub-yellow-text: #33691e;
  --sub-purple: #f3e5f5; --sub-purple-text: #4a148c;
  --sub-orange: #fff3e0; --sub-orange-text: #e65100;
  --sub-pink: #fdf5e6; --sub-pink-text: #8b4513;
  --sub-teal: #d2b48c; --sub-teal-text: #5c4033;
}

/* 4. 桜（春の柔らかなピンクと淡い空） */
body[data-theme="sakura"] {
  --primary: #ec407a;
  --text-main: #4a373d;
  --text-sub: #8a7379;
  --bg: #fff5f7;
  --card-bg: #ffffff;
  --yellow: #fffde7;
  --red: #e91e63;
  --shadow: 0 12px 40px rgba(236,64,122,0.06);

  --sub-red: #ffe4e1; --sub-red-text: #b03060;
  --sub-blue: #e0f7fa; --sub-blue-text: #006064;
  --sub-green: #e8f5e9; --sub-green-text: #2e7d32;
  --sub-yellow: #fff9c4; --sub-yellow-text: #f57f17;
  --sub-purple: #f3e5f5; --sub-purple-text: #6a1b9a;
  --sub-orange: #ffe0b2; --sub-orange-text: #e65100;
  --sub-pink: #fce4ec; --sub-pink-text: #ad1457;
  --sub-teal: #e0f2f1; --sub-teal-text: #004d40;
}

/* 5. 海（ディープブルーと澄んだスカイ） */
body[data-theme="umi"] {
  --primary: #0288d1;
  --text-main: #1c2833;
  --text-sub: #566573;
  --bg: #e1f5fe;
  --card-bg: #ffffff;
  --yellow: #fffde7;
  --red: #ff5252;
  --shadow: 0 12px 40px rgba(2,136,209,0.06);

  --sub-red: #ffecb3; --sub-red-text: #ff6f00; /* 太陽の光 */
  --sub-blue: #e3f2fd; --sub-blue-text: #0d47a1;
  --sub-green: #e0f2f1; --sub-green-text: #004d40;
  --sub-yellow: #fffde7; --sub-yellow-text: #f57f17;
  --sub-purple: #ede7f6; --sub-purple-text: #311b92;
  --sub-orange: #e1f5fe; --sub-orange-text: #01579b;
  --sub-pink: #fce4ec; --sub-pink-text: #880e4f;
  --sub-teal: #b2dfdb; --sub-teal-text: #004d40;
}

/* 6. 紅葉（深みのある赤・朱色・黄金色） */
body[data-theme="kouyou"] {
  --primary: #bf360c;
  --text-main: #3e2723;
  --text-sub: #795548;
  --bg: #fff3e0;
  --card-bg: #ffffff;
  --yellow: #fffde7;
  --red: #d84315;
  --shadow: 0 12px 40px rgba(191,54,12,0.06);

  --sub-red: #ffcc80; --sub-red-text: #d84315;
  --sub-blue: #d7ccc8; --sub-blue-text: #4e342e;
  --sub-green: #f0f4c3; --sub-green-text: #558b2f;
  --sub-yellow: #fff9c4; --sub-yellow-text: #f57f17;
  --sub-purple: #f3e5f5; --sub-purple-text: #6a1b9a;
  --sub-orange: #ffe0b2; --sub-orange-text: #e65100;
  --sub-pink: #ffeb3b; --sub-pink-text: #f57f17;
  --sub-teal: #ffe0b2; --sub-teal-text: #bf360c;
}

/* 7. 雪（冷涼なホワイトブルーと淡いグレー） */
body[data-theme="yuki"] {
  --primary: #78909c;
  --text-main: #263238;
  --text-sub: #546e7a;
  --bg: #eceff1;
  --card-bg: #ffffff;
  --yellow: #f1f8e9;
  --red: #e53935;
  --shadow: 0 12px 40px rgba(120,144,156,0.05);

  --sub-red: #ffeaf0; --sub-red-text: #c2185b;
  --sub-blue: #e8eaf6; --sub-blue-text: #283593;
  --sub-green: #e0f2f1; --sub-green-text: #004d40;
  --sub-yellow: #ffffff; --sub-yellow-text: #455a64;
  --sub-purple: #f3e5f5; --sub-purple-text: #6a1b9a;
  --sub-orange: #eceff1; --sub-orange-text: #37474f;
  --sub-pink: #fce4ec; --sub-pink-text: #ad1457;
  --sub-teal: #cfd8dc; --sub-teal-text: #263238;
}

/* 8. 枯野（落ち着いたブラウントーンとベージュ） */
body[data-theme="karano"] {
  --primary: #6d4c41;
  --text-main: #3e2723;
  --text-sub: #8d6e63;
  --bg: #efebe9;
  --card-bg: #f5f5f5;
  --yellow: #fffde7;
  --red: #c62828;
  --shadow: 0 12px 40px rgba(109,76,65,0.05);

  --sub-red: #d7ccc8; --sub-red-text: #5d4037;
  --sub-blue: #cfd8dc; --sub-blue-text: #37474f;
  --sub-green: #f5f5dc; --sub-green-text: #6d4c41;
  --sub-yellow: #fff9c4; --sub-yellow-text: #f57f17;
  --sub-purple: #e1bee7; --sub-purple-text: #4a148c;
  --sub-orange: #ffe0b2; --sub-orange-text: #e65100;
  --sub-pink: #f5f5f5; --sub-pink-text: #5d4037;
  --sub-teal: #b2dfdb; --sub-teal-text: #004d40;
}


/* ==========================================
   🧱 以下、基本スタイル（変数を使用するように統合）
   ========================================== */
* { ms-overflow-style: none; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  margin: 0; background-color: var(--bg); color: var(--text-main); height: 100vh; overflow: hidden;
  transition: background-color 0.3s, color 0.3s; /* 切り替え時のアニメーション */
}

#loadingOverlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(15px);
  z-index: 2000; display: none; flex-direction: column; justify-content: center; align-items: center;
  font-weight: 600; color: var(--primary);
}
#loadingOverlay.active { display: flex; }

.header {
  height: 80px; display: flex; justify-content: space-between; align-items: center;
  padding: 0 40px; z-index: 500;
}
h1 { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--primary); }

.btn-action {
  border: none; padding: 10px 24px; border-radius: var(--radius-lg);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-refresh { background: var(--card-bg); color: var(--text-main); margin-right: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.btn-add { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(84, 110, 122, 0.2); }
.btn-cd { background: var(--primary); color: white; margin-right: 12px; box-shadow: 0 4px 15px rgba(84, 110, 122, 0.2); }

.container {
  display: flex; height: calc(100vh - 80px); padding: 0 40px 40px 40px; gap: 24px; box-sizing: border-box;
}
.card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 32px;
  overflow-y: auto; box-shadow: var(--shadow); border: 1.5px solid rgba(255,255,255,0.2); flex: 1;
  transition: background-color 0.3s, box-shadow 0.3s;
}
h2 { font-size: 0.9rem; font-weight: 600; color: var(--text-sub); margin-top: 0; margin-bottom: 24px; }

.tile {
  display: flex; flex-direction: column; background: var(--card-bg);
  border: 1px solid rgba(0,0,0,0.05); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 12px;
  border-left: 5px solid #ddd;
}
.tile.is-changed { border-left-color: var(--red) !important; }
.tile.has-info { background-color: var(--yellow) !important; border-color: rgba(0,0,0,0.1); }

.tile-header { display: flex; align-items: center; gap: 16px; }
.period-num { font-size: 0.95rem; font-weight: 800; color: var(--primary); width: 20px; }
.subject-name { font-size: 1.05rem; font-weight: 600; }
.sub-info { font-size: 0.85rem; color: var(--text-sub); margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,0.1); line-height: 1.5; }

.future-item { padding: 16px; border-radius: var(--radius-md); margin-bottom: 12px; background: rgba(0,0,0,0.02); cursor: pointer; border-left: 5px solid #ddd; }
.future-item.is-changed { border-left-color: var(--red); background: var(--card-bg); border: 1px solid rgba(0,0,0,0.05); border-left: 5px solid var(--red); }

.overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); z-index: 1500;
  display: none; justify-content: center; align-items: center;
}
.overlay.active { display: flex; }
.action-card {
  width: 420px; max-width: 90vw; max-height: 85vh; background: var(--card-bg); color: var(--text-main);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow-y: auto; box-sizing: border-box;
}

.tab-group { display: flex; gap: 8px; margin-bottom: 24px; background: rgba(0,0,0,0.05); padding: 6px; border-radius: 30px; }
.tab { flex: 1; padding: 10px; text-align: center; font-size: 0.85rem; border-radius: 25px; cursor: pointer; color: var(--text-sub); transition: 0.2s; }
.tab.active { background: var(--card-bg); color: var(--text-main); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; }
input, select {
  width: 100%; padding: 14px; border: 1px solid rgba(0,0,0,0.1); border-radius: var(--radius-md);
  margin-bottom: 16px; font-size: 0.95rem; outline: none; background: rgba(0,0,0,0.02); box-sizing: border-box; color: var(--text-main);
}
.btn-save {
  width: 100%; padding: 18px; background: var(--primary); color: white; border: none;
  border-radius: var(--radius-lg); font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 8px;
}

@media (max-width: 800px) {
  .container { flex-direction: column; padding: 16px; }
  .header { padding: 0 24px; }
}

#countdownModal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: 2500; backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--card-bg); color: var(--text-main); margin: 20px auto; padding: 35px 15px 20px 15px; width: 92%;
  max-width: 800px; border-radius: 24px; position: relative; max-height: 85vh;
  overflow-y: auto; animation: slideDown 0.3s ease-out; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.close-btn {
  position: absolute; top: 15px; right: 15px; width: 32px; height: 32px;
  background: rgba(0,0,0,0.05); border-radius: 50%; display: flex; align-items: center;
  justify-content: center; cursor: pointer; font-weight: bold; font-size: 18px; color: var(--text-sub); transition: 0.2s;
}
.close-btn:hover { background: rgba(0,0,0,0.1); }

.countdown-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px;
}
@media (max-width: 350px) {
  .countdown-grid { grid-template-columns: repeat(2, 1fr); }
}
.cd-item {
  padding: 12px 4px; border-radius: 16px; text-align: center; border: 1px solid rgba(0,0,0,0.03);
  display: flex; flex-direction: column; justify-content: center;
}
.cd-subject { font-size: 0.75rem; font-weight: bold; margin-bottom: 2px; }
.cd-date { font-size: 1rem; font-weight: 800; } 
.cd-days { font-size: 0.7rem; opacity: 0.8; font-weight: 600; }

/* 🌟 各教科の色定義もテーマの変数と連動するように書き直しました */
.bg-red { background-color: var(--sub-red); color: var(--sub-red-text); }    
.bg-blue { background-color: var(--sub-blue); color: var(--sub-blue-text); }   
.bg-green { background-color: var(--sub-green); color: var(--sub-green-text); }  
.bg-yellow { background-color: var(--sub-yellow); color: var(--sub-yellow-text); }
.bg-purple { background-color: var(--sub-purple); color: var(--sub-purple-text); } 
.bg-orange { background-color: var(--sub-orange); color: var(--sub-orange-text); } 
.bg-pink { background-color: var(--sub-pink); color: var(--sub-pink-text); }   
.bg-teal { background-color: var(--sub-teal); color: var(--sub-teal-text); }   

.tile.is-past {
  opacity: 0.25; filter: grayscale(0.9); background-color: rgba(0,0,0,0.05) !important;
  border-left-color: #bbb !important; pointer-events: none;  
}
.cd-item:active { transform: scale(0.95); transition: transform 0.1s; }

.chrome-tab {
  padding: 6px 14px; font-size: 0.95rem; color: var(--text-sub);
  background: transparent; margin-right: 12px; cursor: pointer;
  border: none; font-weight: 600; border-radius: 0; transition: color 0.2s;
}
.chrome-tab.active {
  color: var(--primary) !important; font-weight: 800; background: transparent !important;
  border-bottom: 3px solid var(--primary); 
}
.tab-link { color: var(--primary); text-decoration: underline; cursor: pointer; font-weight: bold; }
/* 🌟 カウントダウンモーダル内のデザイン調整（テーマへの馴染ませ） */
#cdModeSelect, #cdTargetDate {
  background-color: var(--bg) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  font-family: inherit;
  outline: none;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* ダークモードなど、背景が暗いテーマの時は枠線を少し明るく調整 */
body[data-theme="dark"] #cdModeSelect,
body[data-theme="dark"] #cdTargetDate {
  border-color: rgba(255, 255, 255, 0.15) !important;
}

#cdModeSelect:focus, #cdTargetDate:focus {
  border-color: var(--primary) !important;
}

/* 詳細スケジュール表示部分の調整 */
#cdDetailCard {
  background-color: var(--bg) !important;
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
  /* 点線を無くし、テーマに馴染む薄い境界線に変更 */
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

#cdDetailList span {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="dark"] #cdDetailList span {
  border-color: rgba(255, 255, 255, 0.08) !important;
}
#cdDetailList span {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  cursor: pointer; /* 重ねたときに指マークにする */
  transition: transform 0.1s, background-color 0.2s;
  user-select: none;
}

#cdDetailList span:hover {
  background-color: var(--primary) !important;
  color: white !important;
}

#cdDetailList span:active {
  transform: scale(0.95);
}
/* 🌟 「あと0回」モードで授業数が0のタイルを暗くする */
.cd-item.is-zero-classes {
  opacity: 0.35;        /* タイル全体を薄くする */
  filter: grayscale(0.6); /* 色味を少し抑えて目立たなくする */
  cursor: default;       /* カーソルを通常の矢印に戻す */
}