:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f9fafc;
  --border: #e3e8f0;
  --border-strong: #cfd8e5;
  --text: #1f2937;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e8f0fe;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fdecec;
  --success: #15803d;
  --warning: #b45309;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-small: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- 通用控件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: #b8c4d6;
}

.btn:focus-visible,
.sort-btn:focus-visible,
input:focus-visible,
.name-btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.08);
  border-color: transparent;
}

.btn-small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  min-height: 40px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
  appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--border);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

/* ---------- 登录 ---------- */

.login-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.12), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(21, 128, 61, 0.1), transparent 45%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.brand-mark-small {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 14px;
}

.login-title {
  margin: 16px 0 4px;
  font-size: 22px;
  font-weight: 650;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.password-row {
  position: relative;
  display: flex;
}

.password-row input {
  flex: 1;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.password-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  padding: 4px 8px;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.password-toggle:hover::after,
.password-toggle:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.eye-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.form-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.login-footnote {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- 主界面 ---------- */

.main-view {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 650;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-user {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 13px;
}

.badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--warning);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.path-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
}

.btn-back {
  flex: 0 0 auto;
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.crumb {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.crumb:hover {
  background: var(--primary-soft);
}

.crumb-current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.crumb-current:hover {
  background: transparent;
}

.crumb-sep {
  color: #94a3b8;
}

.error-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 20px 0;
  padding: 10px 14px;
  border: 1px solid #f3c9c9;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 13px;
}

.error-text {
  flex: 1;
  min-width: 0;
}

.list-wrap {
  position: relative;
  flex: 1;
  margin: 16px 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: auto;
  min-height: 240px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.list-wrap.dragover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 2;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.file-table th,
.file-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.file-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.file-table tbody tr:hover {
  background: #f8fafc;
}

.file-table tbody tr.is-selected,
.file-table tbody tr.is-selected:hover {
  background: var(--primary-soft);
}

.file-table tbody tr.is-dragging {
  opacity: 0.5;
}

.file-table tbody tr.drop-target td {
  background: var(--primary-soft);
  box-shadow: inset 0 1px 0 var(--primary), inset 0 -1px 0 var(--primary);
}

body[data-view="cards"] .file-table tbody tr.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

body[data-view="cards"] .file-table tbody tr.drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.file-table tbody tr:last-child td {
  border-bottom: 0;
}

.col-name {
  width: auto;
}

.col-size {
  width: 110px;
}

.col-mtime {
  width: 170px;
}

.col-actions {
  width: 300px;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--text);
}

.sort-mark {
  min-width: 12px;
  color: var(--primary);
  font-size: 12px;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.name-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-check {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
  cursor: pointer;
}

.name-drag {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.file-table tbody tr[draggable="true"] .name-drag {
  cursor: grab;
}

.file-table tbody tr.is-dragging .name-drag {
  cursor: grabbing;
}

.name-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.name-btn:hover .name-text {
  color: var(--primary);
  text-decoration: underline;
}

.name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.file-icon--label {
  border-radius: 7px;
  background: #f1f5f9;
  color: #475569;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.size-cell,
.mtime-cell {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.icon-btn {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 16px;
  font-size: 14px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ---------- 上传与下载 ---------- */

.upload-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.upload-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.upload-list {
  margin: 0;
  padding: 6px 14px 12px;
  list-style: none;
  overflow: auto;
}

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}

.upload-item:last-child {
  border-bottom: 0;
}

/* 第一行：仅文件名 */
.upload-item-head {
  display: flex;
  min-width: 0;
  font-size: 13px;
}

.upload-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 第二行：进度条（内嵌状态文字）+ 操作按钮，始终同一行 */
.upload-item-body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-bar {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  height: 22px;
}

.upload-bar progress {
  width: 100%;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.upload-bar progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-muted);
}

.upload-bar progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.2s linear, background-color 0.2s linear;
}

.upload-bar progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

/* 写入 NAS：不可测进度 → 条纹流动的不确定态，不显示任何百分比 */
.upload-bar.is-finalizing progress {
  border-color: var(--primary);
}

.upload-bar.is-finalizing progress::-webkit-progress-bar {
  border-radius: 999px;
  background-image: repeating-linear-gradient(
    45deg,
    var(--primary-soft) 0 8px,
    #d7e4fb 8px 16px
  );
  background-size: 32px 100%;
  animation: upload-stripes 1.2s linear infinite;
}

.upload-bar.is-finalizing progress::-moz-progress-bar {
  background: var(--primary-soft);
}

@keyframes upload-stripes {
  from { background-position: 0 0; }
  to { background-position: 32px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .upload-bar.is-finalizing progress::-webkit-progress-bar {
    animation: none;
  }
}

/* 状态色：执行中蓝、等待黄、失败红、完成绿、暂停灰 */
.upload-bar.is-waiting progress {
  background: #fef3c7;
}

.upload-bar.is-waiting progress::-webkit-progress-value {
  background: var(--warning);
}

.upload-bar.is-waiting progress::-moz-progress-bar {
  background: var(--warning);
}

.upload-bar.is-error progress {
  background: #fee2e2;
}

.upload-bar.is-error progress::-webkit-progress-value {
  background: var(--danger);
}

.upload-bar.is-error progress::-moz-progress-bar {
  background: var(--danger);
}

.upload-bar.is-done progress {
  background: #dcfce7;
}

.upload-bar.is-done progress::-webkit-progress-value {
  background: var(--success);
}

.upload-bar.is-done progress::-moz-progress-bar {
  background: var(--success);
}

.upload-bar.is-paused progress::-webkit-progress-value {
  background: var(--border-strong);
}

.upload-bar.is-paused progress::-moz-progress-bar {
  background: var(--border-strong);
}

/* 条内文字：绝对定位居中；未过中点用深色，过了中点用白字+阴影，浅色轨道与彩色填充上都清晰 */
.upload-item-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.upload-item-status[data-onfill="1"] {
  color: #fff;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.45);
}

.upload-item-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.upload-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.upload-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-action:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-action[data-action="remove"]:hover,
.upload-action[data-action="cancel"]:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

@media (pointer: coarse) {
  .upload-action {
    width: 32px;
    height: 32px;
  }
}

.upload-notice {
  margin: 10px 14px 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.download-progress {
  position: fixed;
  left: 50%;
  bottom: 24px;
  width: 320px;
  max-width: calc(100vw - 40px);
  padding: 12px 16px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
}

.download-progress span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Toast ---------- */

.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 480px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
}

.toast-success {
  border-color: #b7e4c7;
  background: #f0fdf4;
  color: #166534;
}

.toast-error {
  border-color: #f3c9c9;
  background: var(--danger-soft);
  color: #991b1b;
}

.toast-info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 模态框 ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.modal-wide {
  max-width: 900px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.modal-message {
  margin: 0 0 10px;
  color: #334155;
  word-break: break-word;
}

.modal-message:last-child {
  margin-bottom: 0;
}

.modal-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 13px;
}

.modal-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.modal-field-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 12px;
}

/* ---------- 移动目录选择 ---------- */

.move-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.move-picker-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  word-break: break-all;
}

.move-picker-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.move-picker-crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 13px;
}

.move-picker-crumb {
  padding: 3px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
}

.move-picker-crumb:hover {
  background: var(--primary-soft);
}

.move-picker-crumb.is-current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.move-picker-crumb.is-current:hover {
  background: transparent;
}

.move-picker-sep {
  color: #94a3b8;
}

.move-picker-list {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.move-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.move-picker-item:last-child {
  border-bottom: 0;
}

.move-picker-item:hover,
.move-picker-item:focus-visible {
  background: var(--primary-soft);
}

.move-picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-picker-empty {
  margin: 0;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.move-picker-current {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
  word-break: break-all;
}

.move-picker-current.is-invalid {
  color: var(--warning);
}

.move-picker-error {
  margin: 0;
  color: var(--danger);
  font-size: 12.5px;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  object-fit: contain;
}

.preview-text {
  margin: 0;
  padding: 14px;
  max-height: 65vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: #0f172a;
  color: #e2e8f0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-frame {
  display: block;
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: #fff;
}

.preview-media {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin: 0 auto;
}

.preview-hint {
  margin: 0 0 12px;
  color: var(--warning);
  font-size: 13px;
}

/* ---------- 响应式与视图模式 ---------- */

@media (max-width: 860px) {
  .col-mtime,
  .mtime-cell {
    display: none;
  }

  .col-actions {
    width: 230px;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 54px;
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-brand {
    min-width: 0;
    font-size: 14px;
  }

  .topbar-brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .current-user {
    max-width: 84px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
  }

  .path-bar {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .breadcrumb {
    width: auto;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .crumb {
    flex: 0 0 auto;
    max-width: 60vw;
  }

  .btn-back {
    flex: 0 0 auto;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }

  .list-wrap {
    margin: 8px 8px 12px;
    border-radius: 10px;
  }

  /* 未设置视图偏好时的移动端回退：隐藏大小/时间列 */
  .file-table thead .col-size,
  .file-table thead .col-mtime,
  .file-table tbody .size-cell,
  .file-table tbody .mtime-cell {
    display: none;
  }

  .col-actions {
    width: 180px;
  }

  .login-view {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px;
  }

  .login-card {
    padding: 24px;
  }

  input[type="text"],
  input[type="password"] {
    font-size: 16px;
  }

  .main-view {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }

  .modal-root {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .modal {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .modal-body {
    padding: 14px;
  }

  .upload-panel {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    max-height: 45vh;
    max-height: 45dvh;
  }

  /* 面板头按钮增至四个（全部重试/暂停当前/收起/清除已完成），窄屏允许换行 */
  .upload-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .upload-head-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .upload-notice {
    margin-inline: 10px;
  }

  .download-progress {
    width: calc(100% - 20px);
    max-width: 360px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .toast-container {
    left: 10px;
    right: 10px;
    transform: none;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .preview-image,
  .preview-media {
    max-height: 60vh;
    max-height: 60dvh;
  }

  .preview-text {
    max-height: 55vh;
    max-height: 55dvh;
  }

  .preview-frame {
    height: 65vh;
    height: 65dvh;
  }
}

@media (max-width: 380px) {
  .current-user {
    display: none;
  }
}

/* ---------- 卡片视图：移动端单列，桌面端自适应多列 ---------- */

body[data-view="cards"] .file-table {
  display: block;
}

body[data-view="cards"] .file-table thead {
  display: block;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
}

body[data-view="cards"] .file-table thead tr {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}

body[data-view="cards"] .file-table thead th {
  display: block;
  position: static;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

body[data-view="cards"] .file-table thead .col-actions {
  display: none;
}

body[data-view="cards"] .file-table tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
}

body[data-view="cards"] .file-table tbody tr {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name name"
    "size time"
    "actions actions";
  gap: 6px 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

body[data-view="cards"] .file-table tbody tr:last-child {
  border-bottom: 1px solid var(--border);
}

body[data-view="cards"] .file-table tbody td {
  display: block;
  padding: 0;
  border: 0;
}

body[data-view="cards"] .file-table tbody td:nth-child(1) {
  grid-area: name;
}

body[data-view="cards"] .file-table tbody td:nth-child(2) {
  grid-area: size;
}

body[data-view="cards"] .file-table tbody td:nth-child(3) {
  grid-area: time;
  text-align: right;
}

body[data-view="cards"] .file-table tbody td:nth-child(4) {
  grid-area: actions;
}

body[data-view="cards"] .file-table tbody .size-cell,
body[data-view="cards"] .file-table tbody .mtime-cell {
  display: block;
  font-size: 12px;
}

body[data-view="cards"] .actions-cell {
  gap: 6px;
}

body[data-view="cards"] .icon-btn {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0 7px;
  font-size: 13px;
}

@media (max-width: 640px) {
  body[data-view="cards"] .file-table tbody {
    grid-template-columns: 1fr;
  }
}

/* ---------- 表格视图：手机端保留完整列并横向滚动 ---------- */

body[data-view="table"] .file-table {
  display: table;
}

body[data-view="table"] .file-table thead {
  display: table-header-group;
  position: static;
}

body[data-view="table"] .file-table tbody {
  display: table-row-group;
}

body[data-view="table"] .file-table tr {
  display: table-row;
  padding: 0;
  border: 0;
  background: transparent;
}

body[data-view="table"] .file-table th,
body[data-view="table"] .file-table td {
  display: table-cell;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

body[data-view="table"] .file-table .col-size,
body[data-view="table"] .file-table .size-cell,
body[data-view="table"] .file-table .col-mtime,
body[data-view="table"] .file-table .mtime-cell {
  display: table-cell;
}

body[data-view="table"] .file-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
}

@media (max-width: 640px) {
  body[data-view="table"] .file-table {
    min-width: 720px;
  }
}

/* ---------- 触控设备 ---------- */

@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .btn-small {
    min-height: 36px;
  }

  .icon-btn {
    min-height: 40px;
  }

  .password-toggle {
    width: 40px;
    height: 40px;
    top: 2px;
    right: 2px;
  }

  input[type="text"],
  input[type="password"] {
    min-height: 44px;
    font-size: 16px;
  }

  .btn,
  .icon-btn,
  .name-btn,
  .crumb,
  .sort-btn {
    touch-action: manipulation;
  }
}
