:root {
  --bg: #0d1117;
  --bg-grad: radial-gradient(1100px 560px at 75% -12%, #1b2c4a 0%, rgba(13,17,23,0) 55%), #0d1117;
  --bg-card: #151c27;
  --bg-elev: #1d2733;
  --bg-hover: #232f3d;
  --bg-inset: #0f1620;          /* 內凹輸入框 / 縮圖底 */
  --border: #273140;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4f9dff;
  --accent-hi: #3d8ae6;         /* accent 漸層較深端(按鈕) */
  --accent-soft: rgba(79,157,255,.14);
  --accent-2: #38d39f;
  --danger: #ff5d6c;
  --warn: #ffb84d;
  --sidebar-bg: rgba(19,26,36,.85);
  --sticky-bg: rgba(13,17,23,.92);   /* 檔案標題列 / 手機列 磨砂底 */
  --login-grad: linear-gradient(160deg, #18212e, #131a24);
  --card2-grad: linear-gradient(160deg, #161d2b, #121826);   /* 儀表板卡片底 */
  --card-shadow: 0 6px 20px rgba(0,0,0,.3);
  --scroll-thumb: #2c3848;
  --scroll-thumb-h: #3a4858;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --shadow-hi: 0 12px 34px rgba(0,0,0,.5);
  --trans: .18s ease;
  /* 次要連結(如「忘記密碼?」)的文字色。深色主題底夠暗,直接用既有 token 就有 6.4:1 以上 */
  --link-quiet: var(--muted);
  --link-quiet-hi: var(--accent);
}

/* ===== 淺色主題(data-theme=light 由設定面板切換)===== */
:root[data-theme="light"] {
  --bg: #eef1f7;
  --bg-grad: radial-gradient(1100px 560px at 75% -12%, #d6e4ff 0%, rgba(238,241,247,0) 55%), #eef1f7;
  --bg-card: #ffffff;
  --bg-elev: #f1f4fa;
  --bg-hover: #e7ecf5;
  --bg-inset: #eef1f7;
  --border: #d9dfea;
  --text: #1b2431;
  --muted: #64748b;
  --sidebar-bg: rgba(255,255,255,.88);
  --sticky-bg: rgba(238,241,247,.92);
  --login-grad: linear-gradient(160deg, #ffffff, #eff3fa);
  --card2-grad: linear-gradient(160deg, #ffffff, #f5f8fc);
  --card-shadow: 0 6px 20px rgba(30,41,59,.08);
  --scroll-thumb: #c4cddb;
  --scroll-thumb-h: #a8b4c6;
  --shadow: 0 6px 24px rgba(30,41,59,.10);
  --shadow-hi: 0 12px 34px rgba(30,41,59,.16);
  /* 淺色底要壓深才讀得到:量測後 4.21 → 5.9、2.44 → 5.5 */
  --link-quiet: color-mix(in oklab, var(--muted) 78%, #000);
  --link-quiet-hi: color-mix(in oklab, var(--accent) 62%, #000);
}

/* ===== 主題色(data-accent 由設定面板切換)===== */
:root[data-accent="green"]  { --accent: #2fbf8f; --accent-hi: #23a87b; --accent-soft: rgba(47,191,143,.16); }
:root[data-accent="purple"] { --accent: #8b7cff; --accent-hi: #6f5eec; --accent-soft: rgba(139,124,255,.16); }
:root[data-accent="orange"] { --accent: #ff9f45; --accent-hi: #f0862a; --accent-soft: rgba(255,159,69,.16); }
:root[data-accent="pink"]   { --accent: #ff6fae; --accent-hi: #ec5194; --accent-soft: rgba(255,111,174,.18); }
:root[data-accent="red"]    { --accent: #ff5d6c; --accent-hi: #ec4657; --accent-soft: rgba(255,93,108,.16); }

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

body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* 捲動條 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-h); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 登入 ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--login-grad);
  padding: 44px 40px; border-radius: 20px; width: 360px;
  box-shadow: var(--shadow-hi); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 14px;
  animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.login-card h1 { font-size: 26px; text-align: center; letter-spacing: .5px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 10px; font-size: 14px; }
.login-card input {
  padding: 13px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-inset); color: var(--text); font-size: 15px; transition: var(--trans);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button {
  padding: 13px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; font-size: 15px; font-weight: 600;
  transition: var(--trans); margin-top: 4px;
}
.login-card button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.login-card button:active { transform: translateY(0); }
.error { color: var(--danger); text-align: center; min-height: 20px; font-size: 14px; }

/* 登入 / 註冊 切換 */
.auth-tabs { display: flex; gap: 4px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.auth-tab { flex: 1; padding: 9px; border: none; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; transition: var(--trans); }
.auth-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; }
.pw-hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: -4px; }

/* ===== 版權 ===== */
.copyright { color: var(--muted); font-size: 12px; text-align: center; letter-spacing: .3px; line-height: 1.6; }
.login-card .copyright { margin-top: 6px; opacity: .8; }
.sidebar-copyright { padding: 14px 24px 4px; }

/* ===== 主版面 ===== */
#app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 234px; background: var(--sidebar-bg); backdrop-filter: blur(8px);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 22px 0; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 22px 6px; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #6366f1, var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.brand-txt { display: flex; flex-direction: column; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; }
.nav-label { color: var(--muted); font-size: 11px; letter-spacing: 1.5px; padding: 16px 24px 6px; }
#nav { display: flex; flex-direction: column; flex: 1; gap: 4px; padding: 0 12px; }
#nav a {
  padding: 12px 16px; color: var(--muted); cursor: pointer; text-decoration: none;
  border-radius: var(--radius-sm); font-size: 15px; transition: var(--trans);
  display: flex; align-items: center; gap: 4px;
}
#nav a:hover { background: var(--bg-hover); color: var(--text); }
#nav a.active {
  color: #fff; background: linear-gradient(135deg, var(--accent-soft), rgba(79,157,255,.05));
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-foot { padding: 16px 24px 10px; display: flex; align-items: center; gap: 10px; }
.ws-text { color: var(--accent-2); font-size: 13px; }
.logout {
  margin: 0 16px 6px; padding: 11px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; transition: var(--trans);
}
.logout:hover { color: var(--danger); border-color: var(--danger); background: rgba(255,93,108,.06); }
.ws-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; transition: var(--trans); }
.ws-dot.on { background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.ws-dot.off { background: var(--muted); }

.content { flex: 1; padding: 30px 34px; max-width: 1600px; margin: 0 auto; width: 100%; }
/* 超寬螢幕:內容置中、兩側對稱留白,並讓卡片/圖表用更多空間 */
@media (min-width: 1700px) {
  .content { max-width: 1800px; padding: 38px 48px; }
}
.content h2 { font-size: 21px; margin: 6px 0 18px; letter-spacing: .3px; }
.content h3 { font-size: 14px; margin-bottom: 12px; color: var(--muted); font-weight: 600; }

/* ===== 卡片 ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); transition: var(--trans);
}
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .8; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hi); border-color: var(--accent); }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-val { font-size: 32px; font-weight: 700; margin-top: 6px; letter-spacing: .5px; }
.stat .stat-val.small { font-size: 19px; }
.stat .stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.chart-card canvas { width: 100% !important; height: 220px !important; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }

.temp-list { display: flex; flex-wrap: wrap; gap: 12px; }
.temp-chip { background: var(--bg-elev); padding: 8px 14px; border-radius: 20px; font-size: 14px; border: 1px solid var(--border); }
.temp-chip b { color: var(--accent); }

.vol-bar { height: 8px; background: var(--bg-elev); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.vol-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #6db3ff); transition: width .4s ease; }
.vol-bar span.warn { background: linear-gradient(90deg, var(--warn), #ffd07a); }
.vol-bar span.danger { background: linear-gradient(90deg, var(--danger), #ff8b96); }

.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(56,211,159,.16); color: var(--accent-2); }
.badge.bad { background: rgba(255,93,108,.16); color: var(--danger); }

/* ===== 表格 ===== */
.data-table {
  width: 100%; border-collapse: collapse; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.data-table th, .data-table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table th { color: var(--muted); font-weight: 600; background: var(--bg-elev); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: var(--trans); }
.data-table tbody tr:hover td { background: var(--bg-hover); }
.row-link { color: var(--accent); cursor: pointer; }
.row-link:hover { text-decoration: underline; }
.btn-sm {
  padding: 6px 13px; border-radius: 7px; border: 1px solid var(--border); background: transparent;
  color: var(--text); cursor: pointer; font-size: 13px; margin-right: 6px; transition: var(--trans);
}
.btn-sm:hover { background: var(--bg-hover); border-color: #3a4858; }
.btn-sm.danger { color: var(--danger); border-color: rgba(255,93,108,.4); }
.btn-sm.danger:hover { background: rgba(255,93,108,.1); }
.btn-sm.go { color: var(--accent-2); border-color: rgba(56,211,159,.4); }
.btn-sm.go:hover { background: rgba(56,211,159,.1); }

/* ===== 檔案工具列 ===== */
.file-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.breadcrumb { font-size: 14px; }
.breadcrumb a { color: var(--accent); cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--muted); margin: 0 2px; }
.file-actions { display: flex; gap: 10px; align-items: center; }
.file-actions > button, .upload-btn {
  font-size: 14px; padding: 9px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-weight: 600; transition: var(--trans);
}
#mkdir-btn { background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; }
.upload-btn { background: linear-gradient(135deg, #38d39f, #2bbf8d); color: #07241a; display: inline-flex; align-items: center; }
.upload-btn.folder { background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; }
.file-actions > button:hover, .upload-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* 檢視切換 */
.view-toggle { display: flex; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn { background: transparent; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font-size: 16px; transition: var(--trans); }
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--accent); color: #fff; }

/* ===== 上傳進度 ===== */
.upload-status {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 16px;
}
.upload-text { font-size: 13px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.upload-bar { height: 8px; background: var(--bg-elev); border-radius: 4px; overflow: hidden; }
.upload-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s ease;
}

/* ===== 檔案區標題+工具列:捲動時 sticky 釘在頂端 ===== */
/* 半透明 + backdrop-blur:捲動的檔案從底下經過會被磨砂遮住,兩側因為 content 有留白不會露出 */
.files-head {
  position: sticky; top: 0; z-index: 30;
  background: var(--sticky-bg); backdrop-filter: blur(10px);
  padding-top: 6px; padding-bottom: 12px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.files-head h2 { margin-top: 0; }
.files-head .file-toolbar { margin-bottom: 0; }

/* ===== 檔案區排版:左清單 + 右詳細面板(flex,面板關閉左側自動撐回原寬)===== */
#files { position: relative; }
.file-workspace { display: flex; gap: 18px; align-items: flex-start; }
/* .file-main 撐滿剩餘寬,並保有一段自適應高度讓下方空白仍可拖曳/框選/右鍵 */
.file-main {
  position: relative; flex: 1 1 auto; min-width: 0;
  min-height: calc(100vh - 240px);
}

/* ===== 拖曳上傳覆蓋層 ===== */
/* 只蓋 .file-main(不再覆蓋整頁 / 不覆蓋右側面板);半透明讓檔案透出(像 Google);
   pointer-events:none + 只在拖曳時 remove .hidden → 絕不擋點選檔案 / 右鍵 / 框選 */
.drop-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(13, 17, 23, .55); backdrop-filter: blur(1px);
  border: 2px dashed var(--accent); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.drop-inner {
  text-align: center; color: var(--accent); font-size: 48px; line-height: 1.3; font-weight: 700;
}
.drop-inner div { font-size: 16px; color: var(--text); margin-top: 8px; font-weight: 600; }

/* ===== 右側詳細資料面板 ===== */
.file-detail {
  flex: 0 0 320px; align-self: flex-start;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  /* sticky top 讓開低於已釘住的標題列(--files-head-h 由 JS 量測填入)*/
  position: sticky; top: calc(var(--files-head-h, 92px) + 12px);
  max-height: calc(100vh - var(--files-head-h, 92px) - 32px);
  display: flex; flex-direction: column;
  animation: fdIn .18s ease;
}
@keyframes fdIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.fd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.fd-title { font-size: 15px; font-weight: 600; }
.fd-close {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; width: 28px; height: 28px; border-radius: 7px; transition: var(--trans);
}
.fd-close:hover { background: var(--bg-hover); color: var(--text); }
.fd-body { padding: 16px; overflow-y: auto; }
.fd-preview {
  height: 150px; border-radius: 10px; background: var(--bg-elev); margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.fd-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fd-preview .fd-bigicon { font-size: 64px; }
.fd-rows { display: flex; flex-direction: column; gap: 12px; }
.fd-row { display: flex; flex-direction: column; gap: 3px; }
.fd-row .k { font-size: 12px; color: var(--muted); }
.fd-row .v { font-size: 14px; color: var(--text); word-break: break-all; }

/* 手機:面板改為滿寬堆疊在下方 */
@media (max-width: 720px) {
  /* 直向堆疊時要 stretch,否則 file-main 會按內容(560px 表格)寬度撐開、突破容器並把
     sticky 工具列一起推寬 → 手機上工具列按鈕被切出畫面。stretch 讓它撐滿容器,
     表格改在 .table-scroll(overflow-x:auto)內橫向捲動。 */
  .file-workspace { flex-direction: column; align-items: stretch; }
  .file-main { width: 100%; }
  .file-detail { flex: 1 1 auto; width: 100%; position: static; max-height: none; }
}

/* ===== 多選 / 框選 ===== */
#files { user-select: none; }                 /* 拉框時不會誤選到文字 */
.data-table tbody tr.selected td { background: var(--accent-soft); }
.data-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.grid-item.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }

.marquee {
  position: fixed; z-index: 250; pointer-events: none;
  border: 1px solid var(--accent); background: rgba(79, 157, 255, .15); border-radius: 2px;
}

/* 批次操作浮出列 */
.batch-bar {
  /* z-index 低於 modal(100)→ 開編輯器/預覽/對話框時會被遮罩蓋住,不再擋畫面 */
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 18px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 12px 10px 22px; box-shadow: var(--shadow-hi);
  animation: rise .2s ease;
}
.batch-count { font-size: 14px; font-weight: 600; white-space: nowrap; }
.batch-actions { display: flex; gap: 6px; }
.batch-actions .btn-sm { margin-right: 0; }

/* 分享管理列表操作欄 */
.shares-ops { white-space: nowrap; }

/* 排序下拉 + 貼上按鈕 */
.sort-select {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text); font-size: 14px; cursor: pointer; transition: var(--trans);
}
.sort-select:hover { border-color: #3a4858; }
.sort-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#paste-btn { background: linear-gradient(135deg, #7c5cff, #6344e6); color: #fff; }

/* 日誌頁 */
.log-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.badge.warn-badge { background: rgba(255, 184, 77, .16); color: var(--warn); }

/* ===== 右下角傳輸進度面板 ===== */
.transfer-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 130;
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-hi); overflow: hidden;
  animation: rise .2s ease;
}
.transfer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
.transfer-clear { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.transfer-clear:hover { color: var(--text); }
.transfer-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.tx-item { padding: 9px 10px; border-radius: 8px; }
.tx-item + .tx-item { margin-top: 2px; }
.tx-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tx-ico { flex: none; }
.tx-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-pct { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.tx-bar { height: 6px; background: var(--bg-elev); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.tx-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s ease; }
.tx-item.done .tx-bar span { background: var(--accent-2); }
.tx-item.fail .tx-bar span { background: var(--danger); width: 100% !important; }
.tx-item.fail .tx-pct { color: var(--danger); }
/* 不知道總量(zip 串流下載)時的跑馬燈 */
.tx-bar.indet span { width: 35% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* 輕量提示 toast */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 400;
  box-shadow: var(--shadow-hi); animation: rise .15s ease; max-width: 90vw;
}

/* ===== 懸浮對話框(取代 prompt/confirm/alert) ===== */
.ui-dialog-box { width: min(94vw, 420px); }
.ui-dialog-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.ui-dialog-msg { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.ui-dialog-input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-inset); color: var(--text); font-size: 15px; margin: 12px 0 2px;
}
.ui-dialog-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ui-dialog-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ui-dialog-btns .btn-sm { margin-right: 0; }
.ui-dialog-ok {
  padding: 8px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; font-size: 14px; transition: var(--trans);
}
.ui-dialog-ok:hover { filter: brightness(1.08); }
.ui-dialog-ok.danger { background: linear-gradient(135deg, #ff5d6c, #e8485a); }

/* ===== 文件預覽 / 編輯器:整頁全螢幕(填滿整個視窗,無邊距/圓角)===== */
/* 用 id+class 提高特異度並加 !important,確保壓過通用 .modal / .modal-box 的尺寸與邊距 */
#doc-modal.modal, #editor-modal.modal { padding: 0 !important; align-items: stretch; justify-content: stretch; }
#doc-modal .modal-box, #editor-modal .modal-box {
  width: 100vw !important; height: 100vh !important; height: 100dvh !important;
  max-width: none !important; margin: 0 !important;
  padding: 14px !important; border-radius: 0 !important; border: none !important;
  display: flex; flex-direction: column;
}
.doc-box .modal-head, .editor-box .modal-head { margin-bottom: 10px; flex: none; }
.editor-box .modal-head-btns { flex-wrap: wrap; gap: 6px; }
#editor-stats { font-size: 12px; margin-right: 4px; align-self: center; white-space: nowrap; }

.doc-stage { position: relative; flex: 1; min-height: 0; background: var(--bg-inset); border-radius: 8px; overflow: hidden; }
.doc-frame { width: 100%; height: 100%; border: none; background: #fff; }
.doc-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; color: var(--text); font-size: 16px; z-index: 1; text-align: center;
}
.doc-loading .muted { font-size: 13px; }

.editor-area {
  flex: 1; width: 100%; min-height: 0; resize: none; display: block;
  background: var(--bg-inset); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: var(--editor-font, 14px); line-height: 1.6; white-space: pre; tab-size: 4;
}
.editor-area:focus { outline: none; border-color: var(--accent); }
.editor-box .CodeMirror {
  flex: 1; min-height: 0; height: auto; border-radius: 8px;
  font-size: var(--editor-font, 14px);
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ===== 儲存頁:剩餘空間卡片 ===== */
/* 長掛載路徑(標題與「掛載於 …」子行)不要撐爆卡片,兩處都要斷行 */
.vol-card .stat-label, .vol-card .stat-sub { word-break: break-all; }
.vol-free { font-size: 22px; font-weight: 700; margin: 10px 0 2px; }
.vol-free b { color: var(--accent-2); }
.vol-card.danger .vol-free b { color: var(--danger); }
.vol-card.warn .vol-free b { color: var(--warn); }
.vol-alert { margin-top: 8px; font-size: 13px; font-weight: 600; }
.vol-alert.danger { color: var(--danger); }
.vol-alert.warn { color: var(--warn); }
.smart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; margin-top: 12px; font-size: 14px; }
.smart-grid .muted { font-size: 12px; }
@media (max-width: 560px) { .smart-grid { grid-template-columns: repeat(2, 1fr); } }

/* 多項分享結果 */
#share-links { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.share-name { font-size: 12.5px; color: var(--muted); margin-top: 6px; word-break: break-all; }
.share-fail { font-size: 13px; color: var(--danger); }

/* ===== 大圖示檢視 ===== */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 14px; }
.grid-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 8px 14px; text-align: center; cursor: pointer; transition: var(--trans);
  position: relative; box-shadow: var(--shadow);
}
.grid-item:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow-hi); }
.grid-icon { font-size: 46px; line-height: 1; height: 66px; display: flex; align-items: center; justify-content: center; }
.grid-thumb-wrap { height: 66px; border-radius: 8px; overflow: hidden; background: var(--bg-inset); }
.grid-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-name {
  font-size: 13px; margin-top: 10px; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.grid-ops {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
  opacity: 0; transition: var(--trans);
}
.grid-item:hover .grid-ops { opacity: 1; }
.grid-ops button {
  width: 26px; height: 26px; border-radius: 7px; border: none; cursor: pointer; font-size: 13px;
  background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(4px);
}
.grid-ops button:hover { background: var(--danger); }
.grid-ops button.dl:hover { background: var(--accent); }

/* ===== 右鍵 / 更多 選單 ===== */
.ctx-menu {
  position: fixed; z-index: 300; min-width: 172px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-hi);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  animation: ctxIn .12s ease;
}
@keyframes ctxIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: none; color: var(--text);
  padding: 9px 12px; border-radius: 7px; cursor: pointer;
  font-size: 14px; text-align: left; transition: var(--trans); white-space: nowrap;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(255,93,108,.12); }
.ctx-item .ctx-label { flex: 1 1 auto; }
.ctx-item .ctx-arrow { color: var(--muted); font-size: 12px; margin-left: 10px; }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 6px; }

/* 子選單:滑到帶 ▸ 的項目時,從側邊 flyout 展開 */
.ctx-sub { position: relative; }
.ctx-flyout {
  position: absolute; top: -6px; left: 100%; margin-left: 2px;
  min-width: 172px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-hi);
  padding: 6px; display: none; flex-direction: column; gap: 2px; z-index: 310;
}
.ctx-sub:hover > .ctx-flyout { display: flex; }
/* 若右側空間不足,加 .flip-left 讓子選單往左展開 */
.ctx-flyout.flip-left { left: auto; right: 100%; margin-left: 0; margin-right: 2px; }

/* ===== 影片彈窗 ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; width: min(92vw, 920px); box-shadow: var(--shadow-hi); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head span { font-weight: 600; word-break: break-all; }
.modal-head-btns { display: flex; align-items: center; gap: 10px; flex: none; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--danger); }
#video-stage { line-height: 0; }
.modal-box video { width: 100%; max-height: 72vh; border-radius: 8px; background: #000; display: block; transition: transform .3s ease; transform-origin: center center; }

/* 全螢幕的是 stage 容器(而非 video 本身),這樣套在 video 上的 CSS 旋轉才有效 */
#video-stage:fullscreen { display: flex; align-items: center; justify-content: center; width: 100vw; height: 100vh; background: #000; }
#video-stage:-webkit-full-screen { display: flex; align-items: center; justify-content: center; width: 100vw; height: 100vh; background: #000; }
#video-stage:fullscreen video { width: auto; height: auto; max-width: 100vw; max-height: 100vh; border-radius: 0; }
#video-stage:-webkit-full-screen video { width: auto; height: auto; max-width: 100vw; max-height: 100vh; border-radius: 0; }
.modal-box .muted { margin-top: 10px; font-size: 13px; }

/* ===== 分享對話框 ===== */
.share-box { width: min(94vw, 460px); }
.share-target { margin-bottom: 16px; word-break: break-all; font-size: 14px; }
.share-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.share-row label { width: 96px; flex: none; color: var(--muted); font-size: 14px; }
.share-row select, .share-row input {
  flex: 1; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-inset); color: var(--text); font-size: 14px;
}
.share-row select:focus, .share-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* 「允許上傳」列:checkbox 不該吃到上面 .share-row input 的 flex:1 與 padding */
#share-upload-row { align-items: flex-start; }
#share-upload-row label:first-child { padding-top: 2px; }
.share-check { display: flex; align-items: center; gap: 8px; width: auto !important; color: var(--text) !important; cursor: pointer; }
.share-check input[type="checkbox"] { flex: none !important; width: 16px; height: 16px; padding: 0 !important; margin: 0; cursor: pointer; }
.share-hint { font-size: 12px; margin-top: 6px; line-height: 1.5; }
.share-hint.warn { color: var(--warn); }
.badge-up {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 20px; font-size: 11px;
  background: rgba(255, 184, 77, .16); color: var(--warn); vertical-align: middle;
}
.share-create-btn {
  width: 100%; margin-top: 6px; padding: 12px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; font-size: 15px; font-weight: 600; transition: var(--trans);
}
.share-create-btn:hover { filter: brightness(1.08); }
.share-create-btn:disabled { opacity: .5; cursor: default; filter: none; }
.share-link-row { display: flex; gap: 8px; margin-top: 18px; }
.share-link-row input {
  flex: 1; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--bg-inset); color: var(--accent); font-size: 13px;
}
#share-note { margin-top: 12px; font-size: 12.5px; line-height: 1.6; }

/* ===== 照片燈箱 ===== */
.img-modal { background: rgba(0,0,0,.9); }
#image-viewer {
  max-width: 92vw; max-height: 86vh; object-fit: contain;
  border-radius: 8px; box-shadow: var(--shadow-hi); background: #000;
  transition: transform .12s ease; transform-origin: center center; will-change: transform;
}
.img-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 52px; height: 72px; border: none; cursor: pointer;
  background: rgba(0,0,0,.4); color: #fff; font-size: 40px; line-height: 1;
  border-radius: 10px; transition: var(--trans); z-index: 1;
}
.img-nav:hover { background: rgba(0,0,0,.7); }
.img-nav.prev { left: 16px; }
.img-nav.next { right: 16px; }
.img-tools { position: fixed; top: 16px; right: 18px; display: flex; gap: 10px; }
.img-tool-btn {
  width: 42px; height: 42px; border-radius: 10px; border: none; cursor: pointer;
  background: rgba(0,0,0,.45); color: #fff; font-size: 19px; line-height: 1; transition: var(--trans);
}
.img-tool-btn:hover { background: rgba(0,0,0,.8); }
.img-caption {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: #fff; padding: 7px 16px; border-radius: 20px;
  font-size: 13px; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ===== 監控儀表板 v2 ===== */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.dash-crumb { color: var(--muted); font-size: 13px; letter-spacing: .5px; margin-bottom: 6px; }
.dash-title { font-size: 28px; font-weight: 700; letter-spacing: .5px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(56,211,159,.1); border: 1px solid rgba(56,211,159,.3); color: var(--accent-2);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); animation: livepulse 1.8s ease infinite; }
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.dash-head-right { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reboot-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,93,108,.1); border: 1px solid rgba(255,93,108,.4); color: var(--danger);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.reboot-btn:hover { background: rgba(255,93,108,.2); border-color: rgba(255,93,108,.6); }
.reboot-btn:disabled { opacity: .55; cursor: default; }

.card2 {
  background: var(--card2-grad);
  border: 1px solid var(--border); border-radius: 16px; padding: 22px;
  box-shadow: var(--card-shadow); position: relative; overflow: hidden;
}

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

.sc-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.sc-cpu .sc-bar { background: linear-gradient(90deg, #4f9dff, #6db3ff); }
.sc-mem .sc-bar { background: linear-gradient(90deg, #38d39f, #6ee7b7); }
.sc-up .sc-bar { background: linear-gradient(90deg, #a78bfa, #c4b5fd); }
.sc-proc .sc-bar { background: linear-gradient(90deg, #ffb84d, #ffd07a); }
.sc-row { display: flex; justify-content: space-between; align-items: center; }
.sc-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.sc-val { font-size: 36px; font-weight: 700; margin-top: 14px; letter-spacing: .5px; line-height: 1; }
.sc-val.small { font-size: 25px; }
.sc-val i { font-size: 18px; font-weight: 600; color: var(--muted); font-style: normal; margin-left: 3px; }
.sc-sub { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.sc-icon {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: rgba(255,255,255,.04); border: 1px solid var(--border); flex: none;
}
.sc-up .sc-icon { background: rgba(167,139,250,.12); }
.sc-proc .sc-icon { background: rgba(255,184,77,.12); }

.ring { width: 46px; height: 46px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 3.2; }
.ring .ring-fg { fill: none; stroke-width: 3.2; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ring .ring-txt { font-size: 9px; fill: var(--text); font-weight: 700; transform: rotate(90deg); transform-origin: 18px 18px; }
.sc-cpu .ring .ring-fg { stroke: #4f9dff; }
.sc-mem .ring .ring-fg { stroke: #38d39f; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart2-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; flex-wrap: wrap; gap: 8px; }
.chart2-title { font-weight: 700; font-size: 15px; }
.chart2-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ""; width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.lg-cpu, .lg-down, .now-blue { color: #4f9dff; }
.lg-mem, .now-green { color: #38d39f; }
.lg-up, .now-orange { color: #ffb84d; }
.chart2-now { display: flex; gap: 18px; font-size: 13px; margin: 6px 0 10px; }
.chart2-now b { font-weight: 700; }
.chart2-body { height: 230px; }
.chart2-body canvas { width: 100% !important; height: 230px !important; }

.dash-bottom { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
@media (max-width: 900px) { .dash-bottom { grid-template-columns: 1fr; } }
.card2-h3 { font-size: 15px; font-weight: 700; margin-bottom: 18px; }
.temp-gauge-wrap { display: flex; align-items: center; gap: 22px; }
.temp-gauge { width: 120px; height: 120px; flex: none; position: relative; }
.temp-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.temp-gauge .tg-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.temp-gauge .tg-fg { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.temp-gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tg-val { font-size: 23px; font-weight: 700; }
.tg-name { font-size: 11px; color: var(--muted); margin-top: 2px; }
.temp-info-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.temp-status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 12px; border-radius: 999px; }
.temp-status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.temp-status-pill.ok { background: rgba(56,211,159,.12); color: var(--accent-2); }
.temp-status-pill.warn { background: rgba(255,184,77,.14); color: var(--warn); }
.temp-status-pill.hot { background: rgba(255,93,108,.14); color: var(--danger); }
.temp-meta { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

.dash-volumes { display: flex; flex-direction: column; gap: 20px; }
.dv-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; gap: 10px; }
.dv-name { font-weight: 700; font-size: 14px; word-break: break-all; }
.dv-fs { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.dv-stat { color: var(--muted); font-size: 12.5px; white-space: nowrap; flex: none; }
.dv-bar { height: 9px; background: var(--border); border-radius: 6px; overflow: hidden; }
.dv-bar span { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }

/* ===== 手機版面 (≤768px) ===== */
.mobile-bar { display: none; }

@media (max-width: 768px) {
  #app-view { flex-direction: column; }
  .mobile-bar {
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 50;
    background: var(--sticky-bg); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); padding: 12px 16px;
  }
  .menu-btn { background: transparent; border: none; color: var(--text); font-size: 24px; cursor: pointer; line-height: 1; padding: 0; }
  .mobile-brand { font-weight: 700; font-size: 16px; }
  /* 手機:sticky 標題列釘在 mobile-bar 底下(z-index 低於它)*/
  .files-head { top: 46px; z-index: 40; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 250px;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,.6); }
  .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 150; }

  .content { padding: 16px; max-width: 100%; }
  .content h2 { font-size: 18px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat .stat-val { font-size: 25px; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 560px; }
  .login-card { width: 100%; max-width: 360px; }
  .file-toolbar { flex-direction: column; align-items: stretch; }
  /* 手機:排序下拉獨佔一行,檢視切換固定寬,其餘動作鈕彈性換行、置中、等寬填滿,
     避免像原本靠右對齊時「上傳資料夾」寬按鈕被推出畫面右緣被切掉。 */
  .file-actions { flex-wrap: wrap; gap: 8px; }
  .file-actions .sort-select { flex: 1 1 100%; width: auto; }
  .file-actions .view-toggle { flex: 0 0 auto; }
  .file-actions > button, .file-actions .upload-btn {
    flex: 1 1 auto; min-width: 132px; justify-content: center; text-align: center;
  }
  .files-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .modal { padding: 10px; }
  .transfer-panel { right: 12px; bottom: 12px; left: 12px; width: auto; }
  /* 手機要扣掉頂部 mobile-bar 的高度,避免整頁多出捲動 */
  .file-main { min-height: calc(100vh - 300px); }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

/* ===== 側邊欄:登入者資訊卡 ===== */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 16px 8px; padding: 9px 11px;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.uc-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff;
}
.uc-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.uc-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-role { font-size: 11px; color: var(--muted); }

/* ===== 側邊欄:登出 + 設定齒輪 ===== */
.foot-actions { display: flex; align-items: stretch; gap: 8px; margin: 0 16px 6px; }
.foot-actions .logout { flex: 1; margin: 0; }
.icon-btn {
  flex: none; width: 42px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; transition: var(--trans);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ===== 歡迎訊息:懸浮小視窗 =====
   改成 position:fixed 之後不再佔用儀表板的版面高度,
   監控卡片才不會被往下推、逼得整頁要捲動。可按 × 關閉,10 秒後也會自動收起。 */
.welcome-float {
  /* z-index 低於 modal(100):登入後馬上開預覽/對話框時,歡迎視窗會被遮罩蓋住不擋畫面。
     bottom 抬高到 96px,避開右下角的傳輸進度面板(bottom:24px)。 */
  position: fixed; right: 22px; bottom: 96px; z-index: 95;
  display: flex; align-items: center; gap: 10px;
  max-width: min(90vw, 400px); padding: 12px 12px 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--accent-soft), var(--bg-elev) 70%);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-hi); backdrop-filter: blur(8px);
  font-size: 14.5px; color: var(--text); animation: rise .3s ease;
}
.welcome-float b { color: var(--accent); }
.wf-text { flex: 1; min-width: 0; }
.wf-close {
  flex: none; width: 26px; height: 26px; line-height: 1; padding: 0;
  border-radius: 50%; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 19px; cursor: pointer; transition: var(--trans);
}
.wf-close:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
/* 關閉時淡出;動畫跑完由 JS 補上 .hidden */
.welcome-float.closing { animation: wfOut .22s ease forwards; }
@keyframes wfOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }
/* 手機:改成貼齊左右兩側的橫條(右下角空間不夠放小卡),並壓到 toast(bottom:92px)下方 */
@media (max-width: 768px) {
  .welcome-float { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ===== 設定面板 ===== */
.settings-box { width: min(92vw, 440px); }
.settings-body { display: flex; flex-direction: column; gap: 20px; padding: 6px 4px 2px; }
.set-user {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.set-user .uc-avatar { width: 40px; height: 40px; font-size: 19px; }
.set-user .uc-name { font-size: 16px; }
.set-user .uc-role { font-size: 12px; }
.set-group { display: flex; flex-direction: column; gap: 9px; }
.set-label { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.set-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* 分段切換(主題 / 預設檢視)*/
.seg { display: flex; gap: 4px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.seg-btn { flex: 1; padding: 9px 6px; border: none; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; font-weight: 600; transition: var(--trans); white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-hi)); color: #fff; }

/* 主題色色票 */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; padding: 0;
  background: var(--sw); border: 2px solid var(--border); transition: var(--trans); position: relative;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 3px var(--sw); }
.swatch.active::after {
  content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.settings-body .sort-select { width: 100%; }

/* ===== 使用者權限:徽章 + 編輯彈窗 ===== */
.pbadge { display: inline-block; padding: 2px 8px; margin: 2px 2px 2px 0; border-radius: 20px; font-size: 11px;
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pbadge.on { background: rgba(79,157,255,.14); border-color: rgba(79,157,255,.35); color: var(--accent); }
.perm-cell { line-height: 1.9; }
.perm-box { width: min(94vw, 460px); }
.perm-body { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.perm-toggle { cursor: pointer; }
.perm-info { min-width: 0; }
.perm-name { font-size: 14px; font-weight: 600; color: var(--text); }
.perm-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.perm-row .sort-select { flex: none; width: auto; }
.perm-toggle input[type=checkbox] { flex: none; width: 20px; height: 20px; cursor: pointer; }
.perm-box .share-create-btn { margin-top: 14px; }

/* 檔案管理唯讀者:隱藏所有寫入入口(後端仍會二次把關 403) */
body.ro-files #mkdir-btn,
body.ro-files #paste-btn,
body.ro-files #batch-delete,
/* 壓縮與解壓都是寫入動作,唯讀使用者不該看到(後端也擋,這裡只是不要給錯誤期待) */
body.ro-files #batch-compress,
body.ro-files #zip-extract,
body.ro-files .file-actions .upload-btn { display: none !important; }
/* 無分享權限:隱藏分享入口 */
body.no-shares #batch-share { display: none !important; }

/* ===== 問題回報(管理員)===== */
/* 側邊欄未處理數紅點 */
.nav-dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 20px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center; vertical-align: 1px; }

.reports-list { display: flex; flex-direction: column; gap: 12px; }
.rep { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--card-shadow); }
.rep.done { opacity: .62; }
.rep-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 8px; }
.rep-id { font-family: monospace; color: var(--muted); font-size: 13px; }
.rep-kind { font-weight: 700; font-size: 15px; }
.rep-head .spacer { flex: 1; }
.rep-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.rep-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12.5px;
  margin-bottom: 9px; }
.rep-meta b { color: var(--text); font-weight: 600; }
.rep-msg { background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.rep-shots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rep-shots img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-inset); cursor: zoom-in; }
.rep-ops { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }

/* ===== 密碼:修改密碼 / 忘記密碼 ===== */
/* 登入頁的「忘記密碼?」—— 用 button 而非 <a>,避免空 href 造成的跳頁。
   選擇器要寫成 .login-card .linkish 才蓋得過 .login-card button 的漸層底色。

   顏色是量過對比度才定的:淺色主題直接用 --accent(#4f9dff)當文字色,
   對 #eef1f7 底只有 2.44:1,hover 反而比不 hover 還難讀(WCAG AA 要 4.5:1)。
   所以淺色時把兩種狀態都往深處壓,深色主題維持原本的 token。 */
.login-card .linkish, .linkish {
  display: block; width: auto; margin: 10px auto 0; padding: 4px 6px;
  background: none; border: none; color: var(--link-quiet); font-size: 13px; font-weight: 400;
  cursor: pointer; text-decoration: underline; font-family: inherit;
  transition: color .15s;
}
.login-card .linkish:hover, .linkish:hover {
  color: var(--link-quiet-hi); filter: none; transform: none; background: none;
}

.pw-form { display: flex; flex-direction: column; gap: 9px; }
.pw-form .ui-dialog-input { margin: 0; }
.pw-form .ui-dialog-ok { margin-top: 4px; align-self: flex-start; }
.pw-msg { font-size: 13px; min-height: 1.2em; line-height: 1.5; }
.pw-msg.err { color: var(--danger); }
.pw-msg.ok { color: var(--accent-2); }
.set-hint.warn-text { color: var(--warn); }

.forgot-box { width: min(94vw, 440px); }
.forgot-box .seg { margin-bottom: 16px; }
.forgot-pane { display: flex; flex-direction: column; gap: 10px; }
.forgot-pane .ui-dialog-input { margin: 0; }
.forgot-pane .ui-dialog-ok { margin-top: 4px; }
/* 重設碼是要用眼睛核對的隨機字串,等寬字體才不會把 l/1、O/0 看錯 */
#fc-code { font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; letter-spacing: .5px; }

/* ===== 使用者管理:後台帳號 / 搶票帳號 切換 ===== */
.admin-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.admin-head h2 { margin: 0; }
.admin-head .sort-select { min-width: 232px; }


/* ===== 壓縮檔線上檢視 ===== */
.zip-box { width: min(94vw, 820px); }
.zip-meta { font-size: 12.5px; margin: -4px 0 12px; }
/* 壓縮檔動輒上百個項目:限制高度讓它自己捲,不要把視窗撐到超出螢幕 */
.zip-scroll {
  max-height: 58vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); /* 圓角改由外層裁切 */
}
/* .data-table 原本的 overflow:hidden 會讓它自己變成捲動容器,
   底下 th 的 position:sticky 就完全失效 —— 這裡把捲動交還給 .zip-scroll。 */
.zip-scroll .data-table { overflow: visible; border: none; border-radius: 0; box-shadow: none; }
.zip-scroll .data-table th { position: sticky; top: 0; z-index: 1; }


/* ===== 軟體發佈 ===== */
.pub-drop{border:2px dashed var(--line,#2a3441);border-radius:12px;padding:26px 18px;text-align:center;
  background:var(--panel2,#121a24);transition:border-color .15s,background .15s}
.pub-drop.over{border-color:var(--accent,#3b82f6);background:#16202c}
.pub-drop-icon{font-size:30px;margin-bottom:6px}
.linkbtn{background:none;border:none;color:var(--accent,#3b82f6);cursor:pointer;font:inherit;padding:0}
.linkbtn:hover{text-decoration:underline}
.pub-queue{margin-top:12px;display:flex;flex-direction:column;gap:8px}
.pub-item{background:var(--panel2,#121a24);border:1px solid var(--line,#2a3441);border-radius:10px;padding:10px 14px}
.pub-item-head{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.pub-item-name{font-weight:600;flex:1;min-width:140px;word-break:break-all}
.pub-item-state{font-size:13px;color:var(--muted,#8b98a9);white-space:nowrap}
.pub-item.err .pub-item-state{color:var(--danger,#f85149)}
.pub-item.done .pub-item-state{color:var(--ok,#3fb950)}
.pub-bar{height:6px;border-radius:3px;background:#1f2a36;margin-top:8px;overflow:hidden}
.pub-bar>i{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--accent,#3b82f6),var(--accent2,#8b5cf6));transition:width .2s}
.field-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.pub-input{padding:8px 11px;border:1px solid var(--line,#2a3441);border-radius:8px;background:#0f1620;
  color:inherit;font:inherit;min-width:220px;flex:1}
