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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ============================================================
   登录 / 注册
   ============================================================ */

#authPage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-card h1 {
  font-size: 26px;
  text-align: center;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.auth-card .subtitle {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-bottom: 28px;
}

.tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 2px solid #eef0f4;
}

.tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  font-size: 15px;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tabs button.active {
  color: #4a6cf7;
  border-bottom-color: #4a6cf7;
  font-weight: 600;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #fafbfc;
}

.form-group input:focus {
  outline: none;
  border-color: #4a6cf7;
  background: #fff;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
  margin-top: 6px;
}

.btn-primary:hover { background: #3a5ce5; }
.btn-primary:disabled { background: #a5b4fc; cursor: not-allowed; }

.forgot-link {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
}

.forgot-link a { color: #4a6cf7; text-decoration: none; }
.forgot-link a:hover { text-decoration: underline; }

.msg {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: none;
}

.msg.error { background: #fef2f2; color: #dc2626; display: block; }
.msg.success { background: #f0fdf4; color: #16a34a; display: block; }

.modal-content .msg {
  margin-top: 12px;
  margin-bottom: 0;
}

/* ============================================================
   主页面
   ============================================================ */

#mainPage {
  display: none;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}

.topbar h1 { font-size: 20px; color: #1a1a2e; }

.topbar .user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #666;
}

.user-name {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
}

.user-name:hover { color: #4a6cf7; }

.account-menu {
  position: fixed;
  z-index: 10000;
  min-width: 150px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 6px;
}

.account-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  border-radius: 7px;
  font-family: inherit;
}

.account-menu button:hover { background: #f3f4f6; }

.btn-logout {
  background: #f3f4f6;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-logout:hover { background: #e5e7eb; color: #dc2626; }

/* ============================================================
   上传
   ============================================================ */

.drop-zone {
  background: #fff;
  border: 2px dashed #d0d5dd;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 24px;
}

.drop-zone:hover { border-color: #4a6cf7; background: #f8f9ff; }
.drop-zone.dragover { border-color: #4a6cf7; background: #eef2ff; transform: scale(1.01); }
.drop-zone .icon { font-size: 40px; display: block; margin-bottom: 10px; }
.drop-zone .main-text { font-size: 15px; color: #4a6cf7; font-weight: 500; margin-bottom: 4px; }
.drop-zone .sub-text { font-size: 12px; color: #999; }

.upload-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.upload-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  animation: slideIn 0.25s ease;
}

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

.upload-item .file-icon { font-size: 22px; flex-shrink: 0; }
.upload-item .info { flex: 1; min-width: 0; }

.upload-item .file-name {
  font-size: 14px;
  color: #333;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item .meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #eef0f4;
  border-radius: 3px;
  overflow: hidden;
}

.upload-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a6cf7, #6b8afd);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.status {
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.upload-bytes {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-pct {
  flex-shrink: 0;
  font-size: 12px;
  color: #4a6cf7;
  font-weight: 500;
}

.upload-cancel {
  flex-shrink: 0;
  align-self: center;
  font-size: 12px;
  color: #666;
  background: #f3f4f6;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
}

.upload-cancel:hover { background: #fee2e2; color: #dc2626; }
.status.waiting { color: #f59e0b; }
.status.uploading { color: #4a6cf7; }
.status.done { color: #22c55e; }
.status.error { color: #ef4444; }
.status.duplicate { color: #8b5cf6; }

/* ============================================================
   文件列表
   ============================================================ */

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #555;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title .count { font-size: 13px; font-weight: 400; color: #999; }

.section-tools { display: flex; align-items: center; gap: 10px; }

.btn-newdir {
  font-size: 13px;
  color: #4a6cf7;
  background: #eef2ff;
  border: 1px solid #dbe4ff;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-newdir:hover { background: #4a6cf7; color: #fff; }

.file-list { display: flex; flex-direction: column; gap: 8px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.breadcrumb a {
  color: #4a6cf7;
  text-decoration: none;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #c0c4cc; }

.dir-item { cursor: pointer; }

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fafbfc;
}

.search-bar input:focus {
  outline: none;
  border-color: #4a6cf7;
  background: #fff;
}

.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.btn-search {
  flex-shrink: 0;
  font-size: 13px;
  color: #fff;
  background: #4a6cf7;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-family: inherit;
}

.btn-search:hover { background: #3a5ce5; }

.btn-clear-search {
  flex-shrink: 0;
  font-size: 13px;
  color: #666;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font-family: inherit;
}

.btn-clear-search:hover { background: #f3f4f6; }

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.sort-bar button {
  font-size: 12px;
  color: #666;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.sort-bar button:hover { background: #f3f4f6; }
.sort-bar button.active {
  background: #eef2ff;
  color: #4a6cf7;
  border-color: #c7d2fe;
  font-weight: 500;
}
.sort-bar button.active:hover { background: #dbe4ff; }

.file-actions { display: flex; gap: 8px; flex-shrink: 0; }

.file-item .preview-btn { color: #0f766e; background: #ecfdf5; }
.file-item .preview-btn:hover { background: #0f766e; color: #fff; }

.file-item .more-btn { color: #666; background: #f3f4f6; }
.file-item .more-btn:hover { background: #666; color: #fff; }

/* ============================================================
   预览浮层
   ============================================================ */

button:focus { outline: none; }
button:focus-visible { outline: 2px solid #4a6cf7; outline-offset: 2px; }

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.preview-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.preview-title {
  font-size: 14px;
  color: #333;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.preview-close,
.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  border: none;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
}

.preview-close:hover,
.modal-close:hover { background: #e5e7eb; }

.preview-body {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 78vh;
  display: block;
}

.preview-body audio { width: 90%; margin: 40px 0; }

.preview-body iframe {
  width: 100%;
  height: 78vh;
  border: none;
  background: #fff;
}

.preview-body pre {
  width: 100%;
  height: 78vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  background: #fff;
  color: #222;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-preview {
  width: 100%;
  height: 78vh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.text-preview pre {
  flex: 1;
  min-height: 0;
  height: auto;
}

.text-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid #eee;
  background: #fff;
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
}

.text-more {
  font-size: 12px;
  color: #4a6cf7;
  background: #eef2ff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
}

.text-more:hover { background: #4a6cf7; color: #fff; }
.text-more:disabled { opacity: 0.5; cursor: not-allowed; }

.preview-msg {
  color: #ddd;
  text-align: center;
  padding: 40px 24px;
  font-size: 14px;
}

.preview-action {
  margin: 16px 6px 0;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #4a6cf7;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.preview-action:hover { background: #3a5ce5; }

.file-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s;
}

.file-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.file-item .file-icon { font-size: 22px; flex-shrink: 0; }
.file-item .info { flex: 1; min-width: 0; }

.file-item .file-name {
  font-size: 14px;
  color: #333;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item .file-meta { font-size: 12px; color: #999; }

.file-item .file-path {
  font-size: 12px;
  color: #888;
  margin-top: 3px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.file-item .download-btn {
  flex-shrink: 0;
  font-size: 13px;
  color: #4a6cf7;
  background: #eef2ff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}

.file-item .download-btn:hover { background: #4a6cf7; color: #fff; }

.empty-tip {
  text-align: center;
  font-size: 13px;
  color: #bbb;
  padding: 30px 0;
  background: #fff;
  border-radius: 10px;
}

.footer-status {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: #aaa;
  line-height: 1.8;
  padding-bottom: 20px;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 5px;
  vertical-align: middle;
}

#fileInput { display: none; }

/* ============================================================
   冲突弹窗
   ============================================================ */

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px;
  max-width: 460px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-content h3 {
  font-size: 18px;
  color: #1a1a2e;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 { margin-bottom: 0; }

.modal-content h4 {
  font-size: 15px;
  color: #333;
  margin: 16px 0 10px;
}

.modal-content p {
  font-size: 14px;
  color: #555;
  margin-bottom: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.modal-content .modal-sub {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  padding-left: 8px;
  border-left: 3px solid #e5e7eb;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.modal-buttons button {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.modal-buttons .btn-overwrite { background: #4a6cf7; color: #fff; }
.modal-buttons .btn-overwrite:hover { background: #3a5ce5; }
.modal-buttons .btn-rename { background: #eef2ff; color: #4a6cf7; }
.modal-buttons .btn-rename:hover { background: #dbe4ff; }
.modal-buttons .btn-cancel { background: #f3f4f6; color: #666; }
.modal-buttons .btn-cancel:hover { background: #e5e7eb; }

.modal-buttons .danger { background: #dc2626; color: #fff; }
.modal-buttons .danger:hover { background: #b91c1c; }

.dialog-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  margin: 6px 0 4px;
  background: #fafbfc;
}

.dialog-input:focus {
  outline: none;
  border-color: #4a6cf7;
  background: #fff;
}

/* ============================================================
   文件详情
   ============================================================ */

.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.detail-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
  align-items: flex-start;
}

.detail-label {
  flex-shrink: 0;
  width: 72px;
  color: #888;
}

.detail-value {
  flex: 1;
  min-width: 0;
  color: #333;
  word-break: break-all;
}

.detail-hash {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: #f5f6f8;
  padding: 5px 7px;
  border-radius: 6px;
  user-select: all;
  word-break: break-all;
}

.detail-copy {
  flex-shrink: 0;
  min-width: 64px;
  text-align: center;
  white-space: nowrap;
  font-size: 12px;
  color: #4a6cf7;
  background: #eef2ff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}

.detail-copy:hover { background: #4a6cf7; color: #fff; }
.detail-copy.done { background: #ecfdf5; color: #0f766e; }

/* ============================================================
   备注编辑
   ============================================================ */

.note-editor { width: 100%; }

.note-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  background: #fafbfc;
  resize: vertical;
}

.note-input:focus {
  outline: none;
  border-color: #4a6cf7;
  background: #fff;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.note-save,
.note-clear {
  font-size: 12px;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
}

.note-save { background: #4a6cf7; color: #fff; }
.note-save:hover { background: #3a5ce5; }
.note-clear { background: #f3f4f6; color: #666; }
.note-clear:hover { background: #e5e7eb; }
.note-save:disabled,
.note-clear:disabled { opacity: 0.5; cursor: not-allowed; }
.note-tip { font-size: 12px; color: #888; }