/* ===== CSS 自訂變數：亮色主題（預設） ===== */
:root {
    /* 背景層次：primary > secondary > tertiary，由深至淺 */
    --bg-primary: #e8eaf2;   /* 稍深的底色，讓白色表格區域有「浮起」感 */
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef0f6;
    --bg-card: #ffffff;
    --bg-hover: #dddff0;
    --bg-glass: rgba(255,255,255,0.88);    /* 玻璃擬態背景（搭配 backdrop-filter） */
    /* 文字層次 */
    --text-primary: #1a1a2e;
    --text-secondary: #555580;
    --text-tertiary: #6a6d90;  /* 加深：提升低階資訊（節次、時間）的對比度 */
    --text-accent: #6366f1;
    /* 主色調（Indigo） */
    --accent-primary: #6366f1;
    --accent-primary-light: #818cf8;
    --accent-primary-dark: #4f46e5;
    --accent-glow: rgba(99,102,241,0.18); /* 發光效果用半透明主色 */
    /* 狀態色 */
    --success: #10b981;
    --success-soft: rgba(16,185,129,0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245,158,11,0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239,68,68,0.12);
    /* 邊框 */
    --border: rgba(0,0,0,0.11);        /* 加深格線，提升空表時的定位能力 */
    --border-hover: rgba(0,0,0,0.20);
    --border-active: rgba(99,102,241,0.5);
    /* 陰影 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.15);
    /* 圓角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    /* 過渡動畫 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4,0,0.2,1);
    /* 控制日期輸入框的原生色彩模式（避免暗色輸入框出現白色背景） */
    --color-scheme: light;
    /* 固定課程格顏色 */
    --course-color: #64748b;
}

/* ===== 暗色主題覆蓋（在 html[data-theme="dark"] 下生效） ===== */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #161628;
    --bg-tertiary: #1e1e35;
    --bg-card: #1a1a30;
    --bg-hover: #252545;
    --bg-glass: rgba(30,30,53,0.85);
    --text-primary: #eef0ff;
    --text-secondary: #a0a3c4;
    --text-tertiary: #9499be;  /* 提高亮度：暗色背景下細體字需要更高對比 */
    --text-accent: #818cf8;
    --border: rgba(255,255,255,0.11);    /* 加亮：防止深色模式格線消失成大黑塊 */
    --border-hover: rgba(255,255,255,0.22);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 30px rgba(99,102,241,0.42); /* 強化深色模式的藍紫色發光感 */
    --color-scheme: dark;
}

/* ===== 全域重置與基礎樣式 ===== */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Noto Sans TC','Inter',-apple-system,BlinkMacSystemFont,sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* 全頁背景光暈裝飾（用 pointer-events:none 確保不影響互動） */
body::before {
    content: '';
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139,92,246,0.04) 0%, transparent 60%);
    pointer-events: none; z-index: 0;
}

/* ===== 頁首（Header） ===== */

/* 使用 sticky 搭配玻璃擬態，讓頁首在捲動時保持可見 */
#app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

.header-inner {
    max-width: 1400px; margin: 0 auto; padding: 10px 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.logo-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    border-radius: var(--radius-md); color: white;
    box-shadow: var(--shadow-glow);
}

/* 標題使用漸層文字（-webkit-background-clip 搭配 -webkit-text-fill-color） */
#app-title {
    font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary-light));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.header-center {
    display: flex; align-items: center; gap: 16px; flex: 1;
    justify-content: center; flex-wrap: wrap;
}

.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.header-divider {
    width: 1px; height: 24px; background: var(--border);
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    cursor: pointer; transition: all var(--transition-fast);
}

.header-icon-btn:hover {
    background: var(--bg-hover); color: var(--text-primary);
    border-color: var(--border-hover); transform: scale(1.05);
}

/* 依主題顯示對應圖示：亮色顯示月亮，暗色顯示太陽 */
[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun { display: block; }

/* ===== 日期導覽 ===== */
.date-navigator { display: flex; align-items: center; gap: 6px; }

.nav-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--bg-tertiary);
    color: var(--text-secondary); border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition-fast);
}

.nav-btn:hover {
    background: var(--bg-hover); color: var(--text-primary);
    border-color: var(--border-hover); transform: scale(1.05);
}

/* 原生 date input 樣式化（color-scheme 讓彈出日曆配合主題） */
.date-input-visible {
    padding: 7px 12px; background: var(--bg-tertiary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: inherit;
    font-size: 0.88rem; font-weight: 500; cursor: pointer;
    transition: all var(--transition-fast);
    color-scheme: var(--color-scheme);
}

.date-input-visible:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.date-input-visible:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.today-btn {
    padding: 7px 14px; background: transparent;
    border: 1px solid var(--accent-primary); color: var(--accent-primary);
    border-radius: var(--radius-sm); font-size: 0.83rem;
    font-weight: 600; cursor: pointer;
    transition: all var(--transition-fast); font-family: inherit;
}

.today-btn:hover { background: var(--accent-primary); color: white; box-shadow: var(--shadow-glow); }

/* ===== 教室選單 ===== */
.room-selector {
    display: flex; align-items: center; gap: 8px;
}

.room-label { color: var(--accent-primary); font-size: 0.92rem; font-weight: 700; flex-shrink: 0; white-space: nowrap; }

/* 自訂 select 外觀，以 SVG 資料 URI 取代原生下拉箭頭 */
.room-select {
    padding: 7px 36px 7px 14px; background: var(--bg-tertiary);
    border: 2px solid var(--accent-primary); border-radius: var(--radius-sm);
    color: var(--accent-primary); font-family: inherit;
    font-size: 0.92rem; font-weight: 700; cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='3'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.room-select:hover { background-color: var(--bg-hover); }
.room-select:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }

/* ===== 圖例 ===== */
.legend { display: flex; align-items: center; gap: 14px; font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; }
.legend-dot.available { background: var(--bg-tertiary); border: 1.5px solid var(--border-hover); }
.legend-dot.selected { background: var(--accent-primary); box-shadow: 0 0 6px var(--accent-glow); }
.legend-dot.booked  { background: #6366f1; opacity: 0.85; }
.legend-dot.course  { background: var(--course-color); }

/* ===== 主內容區 ===== */
#main-content {
    position: relative; z-index: 1;
    max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px;
}

/* ===== 浮動選取工具列 ===== */
/* 固定於頁首下方右側，有選取時以動畫滑入 */
.selection-bar {
    position: fixed; top: 70px; right: 24px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px;
    padding: 16px 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99,102,241,0.1);
    animation: slideInRight 0.3s cubic-bezier(0.34,1.56,0.64,1);
    min-width: 200px; max-width: 320px;
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

@keyframes slideInRight { from { opacity:0; transform:translateX(40px) scale(0.9); } to { opacity:1; transform:translateX(0) scale(1); } }
.hidden   { display: none !important; }
.modal-sm { max-width: 360px; }
.modal.modal-wide { width: min(1100px, 95vw); max-width: none; }
.selection-info { display: flex; align-items: center; gap: 8px; color: var(--accent-primary); font-size: 0.88rem; font-weight: 600; }
.selection-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== 通用按鈕樣式 ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition-fast); white-space: nowrap;
}

/* 主要按鈕：漸層背景 + 懸停上浮效果 */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-dark));
    color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-hover); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-warning { background: transparent; color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.btn-warning:hover { background: var(--warning-soft); }

.btn-lg { padding: 10px 24px; font-size: 0.95rem; }

/* ===== 時間表 ===== */
#timetable-container {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

/* 橫向捲動包裝，讓寬度不足時可左右滑動 */
.timetable-scroll { overflow-x: auto; }

.timetable { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }

/* 表頭固定在捲動區域頂端（sticky），搭配 z-index 避免被格子蓋住 */
.timetable thead th {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-secondary); padding: 12px 8px;
    font-weight: 600; font-size: 0.85rem; color: var(--text-secondary);
    border-bottom: 2px solid var(--border); text-align: center;
    transition: background var(--transition-normal);
}

.th-period { width: 50px; }
.th-time { width: 80px; }

.day-header { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.day-name { font-size: 0.95rem; color: var(--text-primary); }
.day-date { font-size: 0.7rem; color: var(--text-tertiary); font-family: 'Inter',sans-serif; font-weight: 400; }

/* 今日欄位高亮（主色文字） */
.th-day.is-today .day-name,
.th-day.is-today .day-date { color: var(--accent-primary); }

/* 今日欄位底部小橫線裝飾 */
.th-day.is-today::after {
    content: ''; display: block; width: 20px; height: 3px;
    margin: 4px auto 0; background: var(--accent-primary); border-radius: 2px;
}

/* 目前選取日欄位高亮：底部內縮橫線作為醒目指示器 */
.th-day.is-selected-day {
    background: rgba(99,102,241,0.12) !important;
    box-shadow: inset 0 -3px 0 var(--accent-primary);
}
.th-day.is-selected-day .day-name { color: var(--accent-primary); font-weight: 700; }
.th-day.is-selected-day .day-date { color: var(--accent-primary); }

.timetable tbody tr { transition: background var(--transition-fast); }

.timetable tbody td {
    padding: 0; border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border); text-align: center;
    vertical-align: middle; height: 44px; position: relative;
}

/* 節次欄（第一欄）固定寬度，背景與表頭一致 */
.timetable tbody td:first-child {
    font-weight: 700; font-size: 0.85rem; color: var(--text-secondary);
    background: var(--bg-secondary); width: 50px;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* 時間欄（第二欄）固定寬度，顯示開始/結束時間 */
.timetable tbody td:nth-child(2) {
    font-size: 0.7rem; line-height: 1.5; color: var(--text-secondary);
    background: var(--bg-secondary); width: 80px;
    white-space: nowrap; font-family: 'Inter',sans-serif; font-weight: 500;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* ===== 時間格（可點擊的借用格子） ===== */
.time-slot {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition-fast);
    padding: 4px; user-select: none; -webkit-user-select: none;
}

.time-slot:hover { background: rgba(99,102,241,0.08); }

/* 選取中的空格：內框線 + 選取脈衝動畫 */
.time-slot.selected {
    background: rgba(99,102,241,0.18);
    box-shadow: inset 0 0 0 2px rgba(99,102,241,0.5);
    animation: selectPulse 0.3s ease;
}

@keyframes selectPulse { 0%{transform:scale(0.95)} 50%{transform:scale(1.02)} 100%{transform:scale(1)} }

/* 已借用格：顯示彩色活動標籤 */
.time-slot.booked { cursor: pointer; position: relative; }
.time-slot.booked:hover { filter: brightness(1.1); }
/* 已借用格被選取時改為白色內框線（原本的主色框在彩色背景上不明顯） */
.time-slot.booked.selected { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7); }
.time-slot.booked.selected .slot-content { opacity: 1; }
.time-slot.booked .slot-content { opacity: 0.92; }

/* ===== 格子共用內容（借用格與固定課程格共用） ===== */
.slot-content {
    display: flex; flex-direction: column;
    align-items: flex-start; justify-content: center;
    width: 100%; height: 100%; padding: 2px 6px;
    border-radius: 4px; font-size: 0.72rem; line-height: 1.3;
    color: white; overflow: hidden;
}

/* 名稱行：超出寬度時省略 */
.slot-name {
    font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* 副標行（申請人 / 教師）：比名稱更小，超出時省略 */
.slot-applicant {
    font-size: 0.65rem; opacity: 0.8; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* 今日欄與已選取日欄的輕微背景 */
.today-column { background: rgba(99,102,241,0.05); }
.selected-day-column { background: rgba(99,102,241,0.09); }

/* ===== 模態視窗 ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-xl); width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99,102,241,0.08);
    animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

@keyframes modalIn { from{opacity:0;transform:scale(0.9) translateY(20px)} to{opacity:1;transform:scale(1) translateY(0)} }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 600; }
.modal-header h3 svg { color: var(--accent-primary-light); }

.modal-close {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: var(--radius-sm);
    color: var(--text-tertiary); cursor: pointer; transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-selected-info {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 12px;
    background: var(--bg-tertiary); border-radius: var(--radius-sm);
    margin-bottom: 20px; max-height: 100px; overflow-y: auto;
}

.selected-slot-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.25); border-radius: 4px;
    font-size: 0.75rem; color: var(--accent-primary);
}

/* ===== 表單元件 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); }
.required { color: var(--danger); }

.form-input {
    width: 100%; padding: 10px 14px; background: var(--bg-tertiary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: inherit; font-size: 0.9rem;
    transition: all var(--transition-fast);
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.form-textarea { resize: vertical; min-height: 70px; }
/* 雙欄表單版面 */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== 顏色選擇器 ===== */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-option {
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer;
    transition: all var(--transition-fast); position: relative;
}
.color-option:hover { transform: scale(1.15); }
/* 選取中的顏色：顯示外框線與發光效果 */
.color-option.active { border-color: var(--text-primary); box-shadow: 0 0 0 3px var(--accent-glow); transform: scale(1.1); }

.modal-footer {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; padding: 0 24px 20px;
}

/* ===== 教室管理列表 ===== */
.room-add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.room-add-row .form-input { flex: 1; }

.rooms-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }

.room-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--bg-tertiary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.room-item:hover { border-color: var(--border-hover); }
.room-item-name { font-size: 0.9rem; font-weight: 500; color: var(--text-primary); }
.room-item-actions { display: flex; gap: 6px; }
.room-item-actions .btn { padding: 4px 10px; font-size: 0.75rem; }

/* ===== 固定課程格 ===== */
.time-slot.course-slot { cursor: default; }
.time-slot.course-slot:hover { background: transparent; }
.course-slot-content { background: var(--course-color); }

/* 課程管理格（可點擊編輯）加 cursor 提示 */
#course-timetable .time-slot.course-slot { cursor: pointer; }
#course-timetable .time-slot.course-slot:hover .course-slot-content { filter: brightness(1.12); }

/* 課程管理日期列 */
.course-date-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.course-date-row label { font-size: 0.88rem; font-weight: 600; color: var(--accent-primary); white-space: nowrap; }
.course-date-input { width: auto; color-scheme: var(--color-scheme); }

/* ===== 刪除教室確認區塊 ===== */
.delete-confirm-step {
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius-sm);
    padding: 14px 16px; margin-top: 14px;
}

.delete-confirm-step.warn {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.35);
}

.delete-confirm-step p {
    margin: 0 0 12px;
    font-size: 0.88rem; line-height: 1.6;
    color: var(--text-primary);
}

.delete-confirm-actions {
    display: flex; gap: 8px; justify-content: flex-end;
}

.delete-password-row {
    display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}

.delete-password-row .form-input { flex: 1; }

.btn-full-width { width: 100%; justify-content: center; }
.spacer { flex: 1; }

/* ===== 吐司通知 ===== */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 20px;
    background: var(--bg-glass); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: 0.85rem; color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
    max-width: 360px;
}

.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success svg { color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.error svg { color: var(--danger); }
/* toast-exit 由 JS 在 3 秒後加入，觸發淡出動畫 */
.toast-exit { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from{opacity:0;transform:translateX(40px) scale(0.9)} to{opacity:1;transform:translateX(0) scale(1)} }
@keyframes toastOut { to{opacity:0;transform:translateX(40px) scale(0.9)} }

/* ===== 自訂捲軸（Webkit 瀏覽器） ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.35); }

/* ===== 深色模式專屬強化 ===== */

/* Logo 在深色背景下加強發光，成為更明顯的視覺焦點 */
[data-theme="dark"] .logo-icon {
    box-shadow: 0 0 40px rgba(99,102,241,0.55), 0 0 15px rgba(139,92,246,0.35);
}

/* 深色模式下選取日的辨識度需要更強的對比 */
[data-theme="dark"] .th-day.is-selected-day {
    background: rgba(99,102,241,0.22) !important;
}

/* 深色模式下今日欄與選取日欄背景加深，避免消失在純黑中 */
[data-theme="dark"] .today-column { background: rgba(99,102,241,0.08); }
[data-theme="dark"] .selected-day-column { background: rgba(99,102,241,0.14); }

/* 深色模式下已借用格懸停時發光感更明顯 */
[data-theme="dark"] .time-slot.booked:hover { filter: brightness(1.18); }

/* 深色模式下「今天」按鈕與教室選單增加輕微外光 */
[data-theme="dark"] .today-btn:hover,
[data-theme="dark"] .room-select:focus {
    box-shadow: 0 0 14px rgba(99,102,241,0.4);
}

/* ===== 響應式設計（螢幕寬度 ≤ 900px） ===== */
@media (max-width: 900px) {
    /* 頁首換行：導覽列移至第三行 */
    .header-inner { padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
    .header-center { order: 3; width: 100%; justify-content: center; gap: 10px; }
    /* 隱藏分隔線以節省空間 */
    .header-divider { display: none; }
    #main-content { padding: 16px; }
    /* 雙欄表單改為單欄 */
    .form-row { grid-template-columns: 1fr; }
    /* 小螢幕隱藏圖例（操作方式不言而喻） */
    .legend { display: none; }
}
