/* =========================================================
   Google Calendar 風格行事曆樣式
   ========================================================= */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --bg: #ffffff;
    --bg-soft: #f1f3f4;
    --border: #dadce0;
    --text: #3c4043;
    --text-soft: #5f6368;
    --today: #1a73e8;
    --hover: #f1f3f4;
    --shadow: 0 1px 3px rgba(60, 64, 67, .3);
    --shadow-lg: 0 4px 16px rgba(60, 64, 67, .25);
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Roboto', 'Noto Sans TC', sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}
body.files-page { overflow: auto; }

.material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
    user-select: none;
}

/* ---------- 頂部工具列 ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 8px; margin: 0 8px; }
.logo-icon { color: var(--primary); font-size: 30px; }
.logo-text { font-size: 22px; color: var(--text-soft); font-weight: 400; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: none; background: transparent; border-radius: 50%;
    color: var(--text-soft); cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .material-symbols-outlined { font-size: 18px; }

.today-btn {
    padding: 8px 18px; margin-left: 8px;
    border: 1px solid var(--border); border-radius: 18px;
    background: var(--bg); color: var(--text); font-size: 14px;
    cursor: pointer; font-weight: 500; transition: background .15s;
}
.today-btn:hover { background: var(--hover); }

.nav-arrows { display: flex; }

.current-title {
    font-size: 22px; font-weight: 400; color: var(--text);
    margin-left: 8px; white-space: nowrap;
}

.view-switch {
    display: flex; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
}
.view-switch button {
    padding: 8px 16px; border: none; background: var(--bg);
    color: var(--text-soft); cursor: pointer; font-size: 14px;
    border-right: 1px solid var(--border);
}
.view-switch button:last-child { border-right: none; }
.view-switch button.active { background: #e8f0fe; color: var(--primary); font-weight: 500; }
.view-switch button:hover:not(.active) { background: var(--hover); }

/* ---------- 版面 ---------- */
.layout { display: flex; height: calc(100vh - 64px); }

/* ---------- 側邊欄 ---------- */
.sidebar {
    width: 256px; flex-shrink: 0; padding: 16px;
    border-right: 1px solid var(--border); overflow-y: auto;
    transition: margin-left .2s, width .2s;
}
.sidebar.hidden { margin-left: -288px; }

.create-btn {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 22px 14px 14px; margin-bottom: 18px;
    border: 1px solid #dadce0; border-radius: 28px;
    background: var(--bg); cursor: pointer;
    font-size: 15px; font-weight: 500; color: var(--text);
    box-shadow: var(--shadow); transition: box-shadow .15s, background .15s;
}
.create-btn:hover { box-shadow: var(--shadow-lg); background: #fafafb; }
.create-btn .material-symbols-outlined { color: var(--primary); }

/* 迷你月曆 */
.mini-calendar { margin-bottom: 24px; }
.mini-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px; margin-bottom: 6px;
}
.mini-header span { font-size: 14px; font-weight: 500; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-grid .dow {
    font-size: 10px; color: var(--text-soft);
    text-align: center; padding: 4px 0;
}
.mini-grid .day {
    font-size: 12px; text-align: center; padding: 6px 0;
    border-radius: 50%; cursor: pointer; aspect-ratio: 1; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.mini-grid .day:hover { background: var(--hover); }
.mini-grid .day.other { color: #b0b3b8; }
.mini-grid .day.today { background: var(--primary); color: #fff; }
.mini-grid .day.selected:not(.today) { background: #e8f0fe; color: var(--primary); }

/* 圖例 */
.legend h3 { font-size: 14px; color: var(--text); margin-bottom: 10px; }
.legend ul { list-style: none; }
.legend li {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 4px; font-size: 14px; color: var(--text);
}
.legend .dot { width: 16px; height: 16px; border-radius: 4px; }

/* ---------- 主檢視區 ---------- */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#calendarView { flex: 1; overflow: auto; }

/* ===== 月檢視 ===== */
.month-grid { display: flex; flex-direction: column; height: 100%; min-height: 600px; }
.month-dow {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}
.month-dow div {
    text-align: center; padding: 8px 0; font-size: 11px;
    color: var(--text-soft); font-weight: 500; text-transform: uppercase;
}
.month-body { flex: 1; display: grid; grid-template-rows: repeat(6, 1fr); }
.month-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-cell {
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
    padding: 4px; min-height: 90px; cursor: pointer; position: relative;
    overflow: hidden;
}
.month-cell:hover { background: #fafafb; }
.month-cell.other { background: #fafafb; color: #b0b3b8; }
.month-cell .cell-date {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; font-size: 12px; border-radius: 50%;
    margin: 2px auto; font-weight: 500;
}
.month-cell .date-wrap { text-align: center; }
.month-cell.today .cell-date { background: var(--primary); color: #fff; }
.month-cell .events { margin-top: 2px; display: flex; flex-direction: column; gap: 2px; }

.event-chip {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; padding: 2px 6px; border-radius: 4px;
    color: #fff; cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.event-chip .chip-time { font-size: 11px; opacity: .9; }
.event-chip.timed {
    background: transparent !important; color: var(--text);
}
.event-chip.timed .chip-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.event-chip:hover { filter: brightness(.95); }
.more-link { font-size: 11px; color: var(--text-soft); padding: 1px 6px; cursor: pointer; }
.more-link:hover { text-decoration: underline; }

/* ===== 週 / 日 檢視 ===== */
.time-grid { display: flex; flex-direction: column; }
.tg-header {
    display: grid; position: sticky; top: 0; z-index: 5;
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.tg-corner { border-right: 1px solid var(--border); }
.tg-dayhead {
    text-align: center; padding: 8px 0; border-right: 1px solid var(--border);
    cursor: pointer;
}
.tg-dayhead .dow-name { font-size: 11px; color: var(--text-soft); text-transform: uppercase; }
.tg-dayhead .dow-num {
    font-size: 24px; font-weight: 400; margin-top: 2px;
    width: 44px; height: 44px; line-height: 44px; border-radius: 50%;
    display: inline-block;
}
.tg-dayhead.today .dow-num { background: var(--primary); color: #fff; }
.tg-dayhead.today .dow-name { color: var(--primary); font-weight: 700; }

.tg-body { display: grid; position: relative; }
.tg-times { border-right: 1px solid var(--border); }
.tg-time-label {
    height: 48px; font-size: 10px; color: var(--text-soft);
    text-align: right; padding-right: 8px; position: relative; top: -6px;
}
.tg-col { border-right: 1px solid var(--border); position: relative; }
.tg-slot { height: 48px; border-bottom: 1px solid #f1f3f4; cursor: pointer; }
.tg-slot:hover { background: #fafafb; }

.tg-event {
    position: absolute; left: 2px; right: 2px;
    border-radius: 4px; color: #fff; padding: 2px 6px;
    font-size: 12px; overflow: hidden; cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.2); z-index: 2;
}
.tg-event .te-title { font-weight: 500; }
.tg-event .te-time { font-size: 11px; opacity: .9; }
.tg-event:hover { filter: brightness(.95); }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ea4335; z-index: 4; }
.now-line::before {
    content: ''; position: absolute; left: -5px; top: -4px;
    width: 10px; height: 10px; border-radius: 50%; background: #ea4335;
}

/* ---------- 彈窗 ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: none; align-items: center; justify-content: center; z-index: 100;
    padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
    width: 460px; max-width: 92vw; background: var(--bg);
    border-radius: 12px; box-shadow: var(--shadow-lg);
    max-height: 90vh; overflow-y: auto; overflow-x: hidden;
    animation: pop .15s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 12px 4px 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 400; color: var(--text); }
.modal-body { padding: 8px 20px 20px; }

.field { display: flex; align-items: flex-start; gap: 16px; padding: 10px 0; min-width: 0; }
.field > *:not(.field-icon) { flex: 1; min-width: 0; }
.field-icon { color: var(--text-soft); margin-top: 6px; min-width: 22px; flex-shrink: 0; }
.field input[type=text],
.field input[type=date],
.field textarea,
.field select,
.field input[type=datetime-local] {
    width: 100%; min-width: 0; max-width: 100%; border: none; border-bottom: 1px solid transparent;
    padding: 6px 4px; font-size: 15px; font-family: inherit;
    background: transparent; color: var(--text); outline: none;
    box-sizing: border-box;
}
.field input[type=text]:focus,
.field input[type=date]:focus,
.field textarea:focus,
.field select:focus,
.field input[type=datetime-local]:focus {
    border-bottom: 2px solid var(--primary);
}
#title { font-size: 20px; }
.time-row { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; flex-wrap: wrap; }
.time-row input { flex: 1 1 160px; min-width: 0; }
.time-row .dash { color: var(--text-soft); flex: 0 0 auto; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin-top: 6px; }

.color-picker { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.color-swatch {
    width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; transition: transform .1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }

.modal-footer { display: flex; align-items: center; gap: 8px; padding-top: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn-primary {
    padding: 9px 24px; border: none; border-radius: 6px;
    background: var(--primary); color: #fff; cursor: pointer;
    font-size: 14px; font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-text {
    padding: 9px 16px; border: none; background: transparent;
    color: var(--primary); cursor: pointer; font-size: 14px; font-weight: 500; border-radius: 6px;
}
.btn-text:hover { background: #e8f0fe; }
.btn-danger {
    padding: 9px 16px; border: none; background: transparent;
    color: #d93025; cursor: pointer; font-size: 14px; font-weight: 500; border-radius: 6px;
}
.btn-danger:hover { background: #fce8e6; }

/* ---------- 提示 ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
    background: #323232; color: #fff; padding: 12px 24px; border-radius: 6px;
    font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0;
    transition: transform .25s, opacity .25s; z-index: 200;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- 響應式 ---------- */
@media (max-width: 768px) {
    .sidebar { position: absolute; z-index: 50; background: var(--bg); height: 100%; box-shadow: var(--shadow-lg); }
    .current-title { font-size: 18px; }
    .logo-text { display: none; }
}

/* 彈窗在窄螢幕：時間欄位改為垂直堆疊，避免橫向捲動 */
@media (max-width: 520px) {
    .modal { width: 100%; max-width: 96vw; }
    .modal-header { padding-left: 16px; }
    .modal-body { padding: 8px 16px 16px; }
    .field { gap: 12px; }
    .time-row { flex-direction: column; align-items: stretch; gap: 4px; }
    .time-row input { flex: 1 1 auto; width: 100%; }
    .time-row .dash { display: none; }
    #title { font-size: 18px; }
}

/* =========================================================
   導覽列 (行事曆 / 檔案)
   ========================================================= */
.main-nav { display: flex; gap: 4px; margin-left: 12px; }
.main-nav a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 18px; text-decoration: none;
    color: var(--text-soft); font-size: 14px; font-weight: 500;
}
.main-nav a .material-symbols-outlined { font-size: 20px; }
.main-nav a:hover { background: var(--hover); }
.main-nav a.active { background: #e8f0fe; color: var(--primary); }

/* =========================================================
   檔案管理頁面
   ========================================================= */
.files-main {
    max-width: 1100px; margin: 0 auto; padding: 24px 24px 60px;
}

/* 拖放上傳區 */
.dropzone {
    border: 2px dashed var(--border); border-radius: 12px;
    padding: 40px 20px; text-align: center; transition: all .15s;
    background: var(--bg-soft);
}
.dropzone.drag { border-color: var(--primary); background: #e8f0fe; }
.dz-icon { font-size: 48px; color: var(--primary); }
.dz-title { font-size: 16px; margin: 10px 0 6px; color: var(--text); }
.dz-sub { font-size: 13px; color: var(--text-soft); }
.link-btn {
    border: none; background: none; color: var(--primary);
    font-size: 16px; font-weight: 500; cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* 上傳進度 */
.upload-status { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.upload-status:empty { display: none; }
.up-progress { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.up-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.upload-status span { font-size: 13px; color: var(--text-soft); }

/* 工具列 */
.files-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin: 28px 0 14px; gap: 12px; flex-wrap: wrap;
}
.files-toolbar h2 { font-size: 18px; font-weight: 500; }
.files-toolbar .count { color: var(--text-soft); font-weight: 400; font-size: 14px; }
.search-box {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-soft); border-radius: 8px; padding: 6px 12px;
}
.search-box .material-symbols-outlined { font-size: 20px; color: var(--text-soft); }
.search-box input { border: none; background: none; outline: none; font-size: 14px; width: 200px; max-width: 50vw; }

/* 檔案卡片網格 */
.file-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.file-card {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--border); border-radius: 10px; padding: 12px;
    transition: box-shadow .15s, border-color .15s; background: var(--bg);
}
.file-card:hover { box-shadow: var(--shadow); border-color: #c4c7c5; }
.fc-icon {
    width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.fc-icon .material-symbols-outlined { font-size: 24px; }
.fc-info { flex: 1; min-width: 0; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.fc-name {
    font-size: 14px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-meta { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.fc-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* 空狀態 */
.empty-state {
    flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; color: var(--text-soft); gap: 12px;
}
.empty-state .material-symbols-outlined { font-size: 56px; color: #c4c7c5; }
.empty-state p { font-size: 15px; }

/* =========================================================
   預覽彈窗
   ========================================================= */
.preview-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: none; flex-direction: column; z-index: 150; padding: 24px;
}
.preview-overlay.open { display: flex; }
.preview-modal {
    background: var(--bg); border-radius: 12px; width: 100%; max-width: 1000px;
    margin: auto; height: 100%; max-height: 92vh; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: var(--shadow-lg);
}
.preview-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.preview-title {
    font-size: 16px; font-weight: 500; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-right: 12px;
}
.preview-actions { display: flex; gap: 2px; flex-shrink: 0; }
.preview-actions a { text-decoration: none; }
.preview-body { flex: 1; overflow: auto; background: #f5f5f5; }
.pv-frame { width: 100%; height: 100%; border: none; }
.pv-doc {
    max-width: 820px; margin: 24px auto; background: #fff; padding: 48px 56px;
    box-shadow: var(--shadow); line-height: 1.7; font-size: 15px;
}
.pv-doc img { max-width: 100%; }
.pv-doc table { border-collapse: collapse; }
.pv-doc td, .pv-doc th { border: 1px solid var(--border); padding: 6px 10px; }
.pv-pptx { padding: 20px; }
.pv-loading {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    height: 100%; color: var(--text-soft); font-size: 15px;
}
.spinner {
    width: 22px; height: 22px; border: 3px solid #d0d0d0; border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pv-unsupported {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 14px; color: var(--text-soft); text-align: center; padding: 24px;
}
.pv-unsupported .material-symbols-outlined { font-size: 56px; color: #c4c7c5; }
.pv-buttons { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pv-buttons a { text-decoration: none; }
.pv-hint { font-size: 12px; }

@media (max-width: 600px) {
    .files-main { padding: 16px 14px 50px; }
    .preview-overlay { padding: 0; }
    .preview-modal { max-height: 100vh; border-radius: 0; }
    .pv-doc { padding: 24px 20px; margin: 0; }
}

/* =========================================================
   日格的文件數量標記
   ========================================================= */
.month-cell .date-wrap { position: relative; }
.file-badge {
    position: absolute; right: 4px; top: 4px;
    display: inline-flex; align-items: center; gap: 1px;
    font-size: 11px; color: var(--text-soft);
    background: var(--bg-soft); border-radius: 10px; padding: 1px 6px 1px 3px;
    line-height: 1.4;
}
.file-badge .material-symbols-outlined { font-size: 13px; }

/* 週/日 檢視日表頭的文件標記 */
.tg-dayhead { position: relative; }
.tg-filebadge {
    position: static; margin: 4px auto 0; cursor: pointer;
    color: #b0b3b8; background: transparent;
}
.tg-filebadge:hover { background: var(--bg-soft); color: var(--text-soft); }
.tg-filebadge.has { color: var(--primary); background: #e8f0fe; }

/* =========================================================
   每日詳情彈窗
   ========================================================= */
.day-modal { width: 520px; }
.day-section { padding: 8px 0 12px; border-bottom: 1px solid var(--border); }
.day-section:last-child { border-bottom: none; }
.ds-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.ds-head > span {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 500; color: var(--text);
}
.ds-head .material-symbols-outlined { font-size: 18px; color: var(--text-soft); }
.btn-text.sm { padding: 4px 10px; font-size: 13px; }

.day-events { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.day-event {
    display: flex; align-items: center; gap: 10px; padding: 7px 8px;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.day-event:hover { background: var(--hover); }
.de-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.de-time { font-size: 12px; color: var(--text-soft); min-width: 42px; flex-shrink: 0; }
.de-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.de-owner { color: var(--text-soft); }
.de-owner::before { content: '· '; }
.day-empty { font-size: 13px; color: var(--text-soft); padding: 8px; }

/* 小型拖放區 */
.dropzone.sm {
    padding: 16px; font-size: 13px; display: flex; align-items: center;
    justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center;
}
.dropzone.sm .material-symbols-outlined { font-size: 22px; }

/* 每日文件清單 */
.day-files { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.df-loading { font-size: 13px; color: var(--text-soft); padding: 8px; }
.df-item {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}
.df-item:hover { background: #fafafb; }
.df-icon {
    width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.df-icon .material-symbols-outlined { font-size: 20px; }
.df-info { flex: 1; min-width: 0; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.df-name {
    font-size: 13px; font-weight: 500; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.df-meta { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.df-actions { display: flex; gap: 0; flex-shrink: 0; }

@media (max-width: 560px) {
    .day-modal { width: 100%; }
}

/* =========================================================
   登入頁
   ========================================================= */
body.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; overflow: auto;
    background: linear-gradient(135deg, #e8f0fe 0%, #f8f9fa 100%);
}
.auth-card {
    width: 380px; max-width: 92vw; background: #fff;
    border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 40px 36px; text-align: center;
}
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 16px;
    background: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.auth-logo .material-symbols-outlined { font-size: 34px; color: #fff; }
.auth-card h1 { font-size: 22px; font-weight: 500; color: var(--text); }
.auth-sub { font-size: 14px; color: var(--text-soft); margin: 6px 0 24px; }
.auth-error {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    background: #fce8e6; color: #c5221f; font-size: 13px;
    padding: 10px 14px; border-radius: 8px; margin-bottom: 18px;
}
.auth-error .material-symbols-outlined { font-size: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border); border-radius: 8px; padding: 0 14px;
    transition: border-color .15s;
}
.auth-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px #e8f0fe; }
.auth-field .material-symbols-outlined { color: var(--text-soft); font-size: 20px; }
.auth-field input {
    flex: 1; border: none; outline: none; background: none;
    padding: 13px 0; font-size: 15px; font-family: inherit;
}
.auth-submit { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.auth-hint {
    font-size: 12px; color: var(--text-soft); margin-top: 20px;
    background: var(--bg-soft); padding: 10px; border-radius: 8px;
}

/* =========================================================
   使用者選單 (右上角)
   ========================================================= */
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 8px;
    border: none; background: transparent; cursor: pointer;
    padding: 4px 8px 4px 4px; border-radius: 20px;
}
.user-btn:hover { background: var(--hover); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff; font-weight: 500;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.user-name { font-size: 14px; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .material-symbols-outlined { font-size: 20px; color: var(--text-soft); }

.user-dropdown {
    position: absolute; top: 52px; right: 0; width: 240px;
    background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border); padding: 8px; display: none; z-index: 120;
}
.user-dropdown.open { display: block; }
.ud-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.ud-name { font-size: 15px; font-weight: 500; }
.ud-role { font-size: 12px; color: var(--primary); margin-top: 2px; }
.ud-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border: none; background: none; cursor: pointer;
    font-size: 14px; color: var(--text); text-decoration: none; border-radius: 6px;
    font-family: inherit; text-align: left;
}
.ud-item:hover { background: var(--hover); }
.ud-item .material-symbols-outlined { font-size: 20px; color: var(--text-soft); }

/* =========================================================
   後台資料表
   ========================================================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.data-table thead th {
    text-align: left; padding: 12px 16px; background: var(--bg-soft);
    color: var(--text-soft); font-weight: 500; font-size: 13px;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafb; }
.data-table .muted { color: var(--text-soft); font-size: 13px; }
.row-actions { display: flex; gap: 2px; }
.row-actions .icon-btn[disabled] { opacity: .3; cursor: not-allowed; }

.tag {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.tag-admin { background: #e8f0fe; color: var(--primary); }
.tag-user { background: var(--bg-soft); color: var(--text-soft); }
.tag-active { background: #e6f4ea; color: #137333; }
.tag-disabled { background: #fce8e6; color: #c5221f; }
.tag-me { background: #fef7e0; color: #b06000; }

/* =========================================================
   日曆分享
   ========================================================= */
.legend-empty { font-size: 12px; color: var(--text-soft); padding: 4px; }
.owner-tag {
    display: inline-block; background: #fef7e0; color: #b06000;
    padding: 0 6px; border-radius: 8px; font-size: 11px;
}
.icon-btn[disabled] { opacity: .3; cursor: not-allowed; pointer-events: none; }

/* ---------- 區分「別人的活動」 ---------- */
/* 標題可縮短，擁有者名稱不縮短，確保長標題時 username 仍看得見 */
.chip-txt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-owner {
    flex: 0 0 auto; font-weight: 400; opacity: .9;
    max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.event-chip.shared .ev-owner::before { content: '· '; }

/* 月檢視：別人的活動 = 純色塊 + 人物圖示 */
.event-chip.shared {
    background: var(--c) !important;
    color: #fff !important;
}
.event-chip.shared .chip-person { font-size: 13px; color: #fff; flex-shrink: 0; }
.event-chip.shared .chip-time { color: rgba(255,255,255,.85); }
.event-chip.shared .ev-owner { color: rgba(255,255,255,.9); }

/* 週/日檢視：別人的活動 = 純色塊 + 人物標示 */
.tg-event.shared {
    background: var(--c) !important;
    color: #fff;
}
.tg-event.shared .te-time { color: rgba(255,255,255,.9); }
.tg-event.shared .te-owner {
    display: flex; align-items: center; gap: 2px;
    color: #fff; opacity: .95; font-weight: 500;
}
.tg-event.shared .te-owner .material-symbols-outlined { font-size: 12px; }

/* 每日彈窗：別人的活動 (純色人物圖示) */
.de-person { font-size: 16px; color: var(--c, var(--text-soft)); width: 10px; }
.te-owner { font-size: 11px; opacity: .9; margin-top: 2px; }

/* 圖例：我的 vs 他人 */
.own-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ol-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-soft); }
.ol-swatch {
    width: 20px; height: 14px; border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.ol-swatch.mine { background: var(--primary); }
.ol-swatch.other { background: var(--primary); }
.ol-swatch.other .material-symbols-outlined { font-size: 10px; color: #fff; }

/* 區段標題列 (含編輯按鈕) */
.legend-head { display: flex; align-items: center; justify-content: space-between; }
.legend-head h3 { margin-bottom: 0; }

/* 分類管理 */
.cat-edit-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-color {
    width: 38px; height: 34px; padding: 0; border: 1px solid var(--border);
    border-radius: 8px; background: none; cursor: pointer; flex-shrink: 0;
}
.cat-color::-webkit-color-swatch { border: none; border-radius: 6px; }
.cat-color::-webkit-color-swatch-wrapper { padding: 2px; }
.cat-name {
    flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; font-family: inherit; outline: none;
}
.cat-name:focus { border-color: var(--primary); }
.cat-del { color: #d93025; }
.cat-add { display: inline-flex; align-items: center; gap: 4px; }
.cat-add .material-symbols-outlined { font-size: 18px; }

/* 顯示的日曆 (勾選清單) */
.owner-filter { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.owner-item { border-radius: 6px; }
.owner-item:hover { background: var(--hover); }
.owner-check {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 6px; cursor: pointer; font-size: 14px;
}
.owner-check input[type=checkbox] {
    width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}
.oc-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.oc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.share-btn {
    display: flex; align-items: center; gap: 8px; width: 100%;
    margin-top: 10px; padding: 9px 12px; border: 1px solid var(--border);
    background: var(--bg); border-radius: 8px; cursor: pointer;
    font-size: 13px; color: var(--primary); font-weight: 500;
}
.share-btn:hover { background: #e8f0fe; }
.share-btn .material-symbols-outlined { font-size: 18px; }

.share-tip { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; line-height: 1.6; }
.share-search {
    display: flex; align-items: center; gap: 8px; background: var(--bg-soft);
    border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
}
.share-search .material-symbols-outlined { font-size: 20px; color: var(--text-soft); }
.share-search input { border: none; background: none; outline: none; flex: 1; font-size: 14px; }

.share-users { list-style: none; max-height: 320px; overflow-y: auto; }
.share-user { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.su-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff; font-weight: 500;
    display: flex; align-items: center; justify-content: center;
}
.su-name { flex: 1; min-width: 0; font-size: 14px; }
.su-name small { display: block; color: var(--text-soft); font-size: 12px; }

/* 開關 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; background: #ccc; border-radius: 22px;
    cursor: pointer; transition: .2s;
}
.switch .slider::before {
    content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* 唯讀事件表單 */
#eventForm.readonly input,
#eventForm.readonly select,
#eventForm.readonly textarea { color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; }

/* =========================================================
   ✦ 主題強化 (Premium Theme) — 精緻質感升級
   覆寫於最後，提升整體視覺層次，不更動結構
   ========================================================= */
:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --brand-grad: linear-gradient(135deg, #1a73e8 0%, #5b5bff 100%);
    --border: #e9ecf2;
    --text: #2b2f33;
    --text-soft: #6b7280;
    --hover: #f3f5fa;
    --bg-soft: #f4f6fb;
    --app-bg: radial-gradient(1200px 600px at 100% -10%, #eef3ff 0%, rgba(238,243,255,0) 55%),
              linear-gradient(180deg, #fbfcfe 0%, #f3f6fb 100%);
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --shadow-lg: 0 10px 30px -8px rgba(16,24,40,.22), 0 4px 12px -4px rgba(16,24,40,.12);
    --shadow-soft: 0 1px 0 rgba(16,24,40,.03), 0 6px 20px -10px rgba(16,24,40,.18);
    --radius: 10px;
    --radius-lg: 16px;
}

body {
    background: var(--app-bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: .1px;
}

/* 毛玻璃頂列 */
.topbar {
    background: rgba(255, 255, 255, .72);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid rgba(16, 24, 40, .06);
    box-shadow: 0 1px 0 rgba(16, 24, 40, .02), 0 6px 20px -16px rgba(16, 24, 40, .4);
    position: relative; z-index: 30;
}
.logo-icon {
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.logo-text { color: var(--text); font-weight: 600; letter-spacing: .2px; }

/* 主檢視維持純白卡片感，浮在漸層背景上 */
.main { background: var(--bg); }
.sidebar {
    background: rgba(255, 255, 255, .55);
    border-right: 1px solid rgba(16, 24, 40, .05);
    backdrop-filter: blur(6px);
}

/* 按鈕：品牌漸層 + 懸停微浮起 */
.btn-primary, .auth-submit {
    background: var(--brand-grad);
    box-shadow: 0 6px 16px -6px rgba(26, 115, 232, .6);
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-primary:hover, .auth-submit:hover {
    background: var(--brand-grad); filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -6px rgba(26, 115, 232, .7);
}
.btn-primary:active, .auth-submit:active { transform: translateY(0); }

.create-btn {
    border: 1px solid rgba(16, 24, 40, .08);
    border-radius: 26px; box-shadow: var(--shadow-soft);
    transition: transform .14s ease, box-shadow .18s ease, background .15s ease;
}
.create-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); background: #fff; }

.today-btn { border-radius: 20px; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .15s ease, background .15s; }
.today-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }

/* 分段切換 (月/週/日) 更精緻 */
.view-switch { border-radius: 12px; background: var(--bg-soft); border-color: transparent; padding: 3px; gap: 2px; }
.view-switch button { border: none; border-radius: 9px; background: transparent; transition: background .15s, color .15s, box-shadow .15s; }
.view-switch button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.view-switch button:hover:not(.active) { background: rgba(255,255,255,.6); }

/* 月檢視：今日強調與懸停層次 */
.month-cell { transition: background .15s ease; }
.month-cell:hover { background: #f7f9ff; }
.month-cell.today { background: linear-gradient(180deg, #f3f7ff 0%, rgba(243,247,255,0) 60%); }
.month-cell.today .cell-date { background: var(--brand-grad); box-shadow: 0 4px 10px -3px rgba(26,115,232,.55); }
.mini-grid .day.today { background: var(--brand-grad); }
.tg-dayhead.today .dow-num { background: var(--brand-grad); box-shadow: 0 4px 10px -3px rgba(26,115,232,.5); }

/* 事件晶片：圓潤 + 細緻陰影 */
.event-chip { border-radius: 7px; box-shadow: 0 1px 2px rgba(16,24,40,.12); transition: transform .1s ease, filter .15s ease, box-shadow .15s ease; }
.event-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px -3px rgba(16,24,40,.28); filter: none; }
.tg-event { border-radius: 8px; box-shadow: 0 4px 12px -4px rgba(16,24,40,.35); transition: transform .1s ease, box-shadow .15s ease; }
.tg-event:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -5px rgba(16,24,40,.4); filter: none; }

/* 彈窗：更大圓角 + 柔和陰影 + 背景模糊 */
.modal-overlay, .preview-overlay { background: rgba(16, 24, 40, .45); backdrop-filter: blur(3px); }
.modal { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.preview-modal { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* 卡片類元件懸停浮起 */
.file-card { border-radius: 14px; border-color: rgba(16,24,40,.08); transition: transform .14s ease, box-shadow .18s ease, border-color .15s; }
.file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: rgba(26,115,232,.35); }

/* 使用者頭像 / 分享頭像：品牌漸層 */
.user-avatar, .su-avatar, .auth-logo { background: var(--brand-grad); box-shadow: 0 6px 16px -6px rgba(26,115,232,.55); }
.user-dropdown { border-radius: 14px; box-shadow: var(--shadow-lg); border-color: rgba(16,24,40,.06); }

/* 導覽列 active 用漸層字色 */
.main-nav a { transition: background .15s, color .15s; }
.main-nav a.active { background: rgba(26,115,232,.1); }

/* 登入頁更有層次 */
body.auth-page {
    background: radial-gradient(900px 500px at 50% -5%, #dfe9ff 0%, rgba(223,233,255,0) 60%),
                linear-gradient(135deg, #eef3ff 0%, #f7f9fc 100%);
}
.auth-card { border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid rgba(16,24,40,.05); }

/* 後台表格圓潤化 */
.table-wrap { border-radius: 14px; border-color: rgba(16,24,40,.08); box-shadow: var(--shadow); }

/* 精緻捲軸 */
* { scrollbar-width: thin; scrollbar-color: #c7ccd6 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c7ccd6; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #aeb4c0; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
