:root {
  --c-primary: #f6821f;
  --c-primary-dark: #d96d0e;
  --c-bg: #f5f6f8;
  --c-panel: #ffffff;
  --c-border: #e3e6ea;
  --c-text: #24292f;
  --c-text-2: #6b7280;
  --c-danger: #d93025;
  --c-danger-bg: #fdecea;
  --c-success: #188038;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; }

/* ============ 通用按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--c-border);
  background: var(--c-panel); color: var(--c-text);
  border-radius: 8px; font-size: 13.5px; line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: #f0f1f3; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #b3251c; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn-link { background: none; border: none; color: var(--c-text-2); font-size: 12.5px; margin-top: 14px; text-decoration: underline; }
.btn-link:hover { color: var(--c-danger); }

/* ============ 登录 / 配置 ============ */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--c-panel);
  border-radius: 14px; box-shadow: var(--shadow); padding: 36px 32px; text-align: center;
}
.auth-card-wide { max-width: 440px; text-align: left; }
.auth-card-wide h1 { text-align: center; }
.auth-logo { margin-bottom: 10px; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-sub { color: var(--c-text-2); font-size: 12.5px; margin-bottom: 22px; line-height: 1.5; text-align: center; }
.auth-card label { display: block; font-size: 12.5px; color: var(--c-text-2); margin: 13px 0 5px; font-weight: 500; }
.auth-card .req { color: var(--c-danger); }
.auth-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--c-border);
  border-radius: 8px; outline: none; transition: border-color 0.15s;
}
.auth-card input:focus { border-color: var(--c-primary); }
.auth-card form > .btn { margin-top: 20px; }
#form-unlock input { text-align: center; }
.form-error { color: var(--c-danger); font-size: 12.5px; margin-top: 10px; text-align: center; }

/* ============ 主界面布局 ============ */
#screen-main { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--c-panel); border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bucket-badge {
  background: #fff3e6; color: var(--c-primary-dark); border: 1px solid #f8d7b3;
  padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.breadcrumb { display: flex; align-items: center; gap: 2px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.breadcrumb::-webkit-scrollbar { display: none; }
.crumb {
  background: none; border: none; color: var(--c-text-2); font-size: 13.5px;
  padding: 4px 6px; border-radius: 6px;
}
.crumb:hover { background: #f0f1f3; color: var(--c-text); }
.crumb.current { color: var(--c-text); font-weight: 600; cursor: default; }
.crumb-sep { color: #c3c8ce; font-size: 12px; }
.searchbox {
  display: flex; align-items: center; gap: 6px; background: var(--c-bg);
  border: 1px solid var(--c-border); border-radius: 8px; padding: 0 10px; color: var(--c-text-2);
}
.searchbox input { border: none; background: none; outline: none; padding: 8px 0; width: 150px; }
.select {
  padding: 8px 8px; border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-panel); color: var(--c-text); outline: none; font-size: 13px;
}

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; background: var(--c-panel); border-bottom: 1px solid var(--c-border); flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.view-toggle { display: flex; border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.view-btn { padding: 8px 11px; background: var(--c-panel); border: none; color: var(--c-text-2); display: flex; }
.view-btn.active { background: #fff3e6; color: var(--c-primary-dark); }

.selection-bar {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  background: #fff8f0; border-bottom: 1px solid #f8d7b3; flex-wrap: wrap;
}
.chk-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.sel-count { font-size: 13px; color: var(--c-primary-dark); font-weight: 600; }
.sel-actions { display: flex; gap: 8px; margin-left: auto; }

.content { flex: 1; overflow: auto; position: relative; padding-bottom: 30px; }
.statusbar {
  padding: 6px 16px; background: var(--c-panel); border-top: 1px solid var(--c-border);
  font-size: 12px; color: var(--c-text-2);
}

/* ============ 状态块 ============ */
.state-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 70px 20px; color: var(--c-text-2); text-align: center;
}
.state-sub { font-size: 12.5px; opacity: 0.75; }
.state-err { color: var(--c-danger); max-width: 520px; word-break: break-all; }
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--c-border);
  border-top-color: var(--c-primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-light { border-color: rgba(255,255,255,0.25); border-top-color: #fff; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 列表视图 ============ */
.file-table { width: 100%; border-collapse: collapse; background: var(--c-panel); }
.file-table th {
  text-align: left; font-size: 12px; color: var(--c-text-2); font-weight: 600;
  padding: 9px 10px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: var(--c-panel); z-index: 2; user-select: none;
}
.file-table th.sortable { cursor: pointer; }
.file-table th.sortable:hover { color: var(--c-text); }
.sort-mark { margin-left: 3px; font-size: 10px; }
.file-table td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; font-size: 13.5px; vertical-align: middle; }
.file-table tbody tr { transition: background 0.1s; }
.file-table tbody tr:hover { background: #fafbfc; }
.file-table tbody tr.row-selected { background: #fff8f0; }
.col-chk { width: 36px; text-align: center; }
.col-size { width: 100px; }
.col-time { width: 170px; }
.col-ops { width: 150px; }
.name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.name-cell .fname {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw;
  cursor: pointer;
}
.name-cell .fname:hover { color: var(--c-primary-dark); text-decoration: underline; }
.ficon { width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 10px; font-weight: 700; color: #fff; }
.ficon-folder { background: #fbbc04; }
.ficon-image { background: #34a853; padding: 0; overflow: hidden; }
.ficon-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ficon-file { background: #9aa0a6; }
.ficon-video { background: #7b61c9; }
.ficon-audio { background: #e0669b; }
.ficon-zip { background: #b07b4f; }
.ficon-doc { background: #4285f4; }
.ops-cell { display: flex; gap: 2px; }
.op-btn {
  background: none; border: none; padding: 5px 6px; border-radius: 6px;
  color: var(--c-text-2); display: inline-flex; font-size: 12px;
}
.op-btn:hover { background: #f0f1f3; color: var(--c-text); }
.op-btn.op-danger:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.cell-muted { color: var(--c-text-2); font-size: 12.5px; }

/* ============ 网格视图 ============ */
.grid-view {
  display: grid; gap: 12px; padding: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.gcard {
  background: var(--c-panel); border: 1px solid var(--c-border); border-radius: var(--radius);
  overflow: hidden; position: relative; transition: box-shadow 0.15s, border-color 0.15s;
}
.gcard:hover { box-shadow: var(--shadow); }
.gcard.row-selected { border-color: var(--c-primary); box-shadow: 0 0 0 1px var(--c-primary); }
.gthumb {
  height: 110px; display: flex; align-items: center; justify-content: center;
  background: #f0f1f3; cursor: pointer; overflow: hidden; position: relative;
}
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-fill { width: 100%; height: 100%; }
.thumb-fill img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gthumb .big-icon { width: 44px; height: 44px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.gname {
  padding: 8px 10px 2px; font-size: 12.5px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.gname:hover { color: var(--c-primary-dark); }
.gmeta { padding: 0 10px 8px; font-size: 11px; color: var(--c-text-2); display: flex; justify-content: space-between; gap: 4px; }
.gchk { position: absolute; top: 7px; left: 7px; z-index: 3; transform: scale(1.15); accent-color: var(--c-primary); display: none; }
.gcard:hover .gchk, .gcard.row-selected .gchk, .grid-view.selecting .gchk { display: block; }
.gops {
  position: absolute; top: 5px; right: 5px; z-index: 3; display: none; gap: 2px;
  background: rgba(255,255,255,0.92); border-radius: 7px; padding: 2px;
}
.gcard:hover .gops { display: flex; }
input[type="checkbox"] { accent-color: var(--c-primary); cursor: pointer; }

/* ============ 拖拽上传遮罩 ============ */
.drop-overlay {
  position: absolute; inset: 0; z-index: 30; background: rgba(246, 130, 31, 0.08);
  border: 2.5px dashed var(--c-primary); border-radius: 10px; margin: 8px;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.drop-inner {
  background: var(--c-primary); color: #fff; padding: 12px 26px;
  border-radius: 10px; font-size: 15px; font-weight: 600;
}

/* ============ Lightbox ============ */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(12, 12, 14, 0.93);
  display: flex; flex-direction: column; user-select: none;
}
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.lb-stage img {
  max-width: 92vw; max-height: calc(100vh - 90px);
  transition: transform 0.25s ease; object-fit: contain;
  box-shadow: 0 6px 40px rgba(0,0,0,0.6);
}
.lb-btn {
  position: absolute; z-index: 5; background: rgba(255,255,255,0.1); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.lb-btn:hover { background: rgba(255,255,255,0.24); }
.lb-close { top: 16px; right: 16px; font-size: 17px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); font-size: 30px; padding-bottom: 4px; }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); font-size: 30px; padding-bottom: 4px; }
.lb-bar {
  display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  color: #e8eaed; font-size: 13px;
}
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.lb-counter { color: #9aa0a6; }
.lb-tools { margin-left: auto; display: flex; gap: 6px; }
.lb-tool {
  background: rgba(255,255,255,0.1); border: none; color: #fff; width: 36px; height: 36px;
  border-radius: 8px; font-size: 17px;
}
.lb-tool:hover { background: rgba(255,255,255,0.24); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 150; background: rgba(15, 17, 20, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: 100%; max-width: 430px; background: var(--c-panel); border-radius: 14px;
  padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,0.22);
  max-height: 86vh; display: flex; flex-direction: column;
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.modal h3 { font-size: 16px; margin-bottom: 14px; }
.modal-body { font-size: 13.5px; line-height: 1.6; color: var(--c-text); overflow-y: auto; }
.modal-body input[type="text"], .modal-body input[type="password"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 8px;
  outline: none; margin-top: 4px;
}
.modal-body input:focus { border-color: var(--c-primary); }
.modal-body .warn-text { color: var(--c-danger); font-size: 12.5px; margin-top: 10px; }
.modal-body .hint-text { color: var(--c-text-2); font-size: 12.5px; margin-top: 8px; word-break: break-all; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.folder-pick { border: 1px solid var(--c-border); border-radius: 8px; max-height: 230px; overflow-y: auto; margin-top: 8px; }
.fp-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid #f0f1f3;
}
.fp-item:last-child { border-bottom: none; }
.fp-item:hover { background: #fafbfc; }
.fp-item.selected { background: #fff3e6; color: var(--c-primary-dark); font-weight: 600; }
.fp-indent { display: inline-block; }

/* ============ 上传面板 ============ */
.upload-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  width: 330px; max-width: calc(100vw - 32px);
  background: var(--c-panel); border-radius: 12px; box-shadow: 0 6px 28px rgba(0,0,0,0.18);
  overflow: hidden;
}
.up-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #24292f; color: #fff; font-size: 13px;
}
.up-head span { flex: 1; }
.up-mini { background: none; border: none; color: #cbd1d8; font-size: 13px; padding: 2px 6px; }
.up-mini:hover { color: #fff; }
.up-list { max-height: 250px; overflow-y: auto; }
.up-item { padding: 9px 14px; border-bottom: 1px solid #f0f1f3; font-size: 12.5px; }
.up-item:last-child { border-bottom: none; }
.up-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.up-fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { color: var(--c-text-2); flex-shrink: 0; }
.up-status.ok { color: var(--c-success); }
.up-status.err { color: var(--c-danger); }
.up-bar { height: 4px; background: #eef0f2; border-radius: 4px; overflow: hidden; }
.up-fill { height: 100%; background: var(--c-primary); border-radius: 4px; width: 0%; transition: width 0.2s; }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: #24292f; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13.5px; box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  animation: toastIn 0.22s ease; max-width: 92vw; word-break: break-all;
}
.toast.success { background: var(--c-success); }
.toast.error { background: var(--c-danger); }
@keyframes toastIn { from { transform: translateY(-14px); opacity: 0; } }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .topbar { padding: 8px 10px; }
  .toolbar { padding: 8px 10px; }
  .searchbox input { width: 95px; }
  .col-time { display: none; }
  .file-table th.col-time, .file-table td.col-time { display: none; }
  .col-ops { width: 90px; }
  .ops-cell .op-btn.op-secondary { display: none; }
  .name-cell .fname { max-width: 38vw; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 9px; padding: 10px; }
  .gthumb { height: 88px; }
  .btn { padding: 8px 10px; }
  .lb-name { max-width: 30vw; }
  .sel-actions { margin-left: 0; }
  .upload-panel { right: 8px; bottom: 8px; }
}
@media (max-width: 460px) {
  .col-size { display: none; }
  .file-table th.col-size, .file-table td.col-size { display: none; }
  .topbar-right { width: 100%; }
  .searchbox { flex: 1; }
  .searchbox input { width: 100%; }
}
