/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: 1px solid transparent; border-radius: 10px;
  font-size: 14px; font-weight: 600; line-height: 1.4;
  transition: all .15s ease; user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* ============ 表单 ============ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-weight: 400; color: #9ca3af; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border);
  border-radius: 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-error { color: var(--danger); font-size: 13px; margin: -6px 0 12px; }

/* ============ 登录页 ============ */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  position: relative; overflow: hidden;
}
.login-view::before, .login-view::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.login-view::before { width: 420px; height: 420px; top: -160px; right: -120px; }
.login-view::after { width: 320px; height: 320px; bottom: -140px; left: -100px; }
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--card);
  border-radius: 20px; padding: 36px 32px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.login-icon { font-size: 44px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; }
.login-sub { text-align: center; color: var(--text-2); font-size: 13px; margin: 4px 0 24px; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand span { background: linear-gradient(90deg, var(--primary), #8b5cf6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; overflow-x: auto; }
.nav-tab {
  padding: 7px 14px; border: none; background: transparent; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.nav-tab.active { background: var(--primary-light); color: var(--primary-dark); }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge.admin { background: #ede9fe; color: #7c3aed; }
.badge.user { background: #e0f2fe; color: #0284c7; }

/* ============ 内容区 ============ */
.content { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-title { font-size: 17px; font-weight: 700; }
.search-box {
  flex: 1; min-width: 160px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 10px; padding: 0 12px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.search-box input { flex: 1; border: none; outline: none; background: transparent; padding: 9px 0; }
.search-icon { opacity: .5; font-size: 13px; }
.new-note-btn .btn-icon { display: none; }

/* ============ 便签卡片墙 ============ */
.note-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.note-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm); border-top: 4px solid var(--note-color, #fbbf24);
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s, box-shadow .15s;
  animation: fadeIn .25s ease;
}
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.note-content {
  font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
}
.note-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.note-time { font-size: 12px; color: #9ca3af; }
.note-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.note-card:hover .note-actions, .note-card:focus-within .note-actions { opacity: 1; }
.note-action {
  border: none; background: var(--bg); border-radius: 7px; width: 30px; height: 30px;
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2);
}
.note-action:hover { background: var(--primary-light); color: var(--primary-dark); }
.note-action.del:hover { background: #fee2e2; color: var(--danger); }

/* 空状态 */
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-2); }
.empty-icon { font-size: 52px; margin-bottom: 12px; opacity: .6; }
.empty-state p { font-size: 14px; }

/* ============ 用户列表 ============ */
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.user-info { flex: 1; min-width: 140px; }
.user-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-name-row b { font-size: 15px; }
.user-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.expire-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.expire-tag.ok { background: #ecfdf5; color: #059669; }
.expire-tag.warn { background: #fffbeb; color: #d97706; }
.expire-tag.bad { background: #fef2f2; color: #dc2626; }
.user-actions { display: flex; gap: 6px; }

/* ============ 模态框 ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17,24,39,.55); animation: fadeIn .15s; }
.modal-card {
  position: relative; background: var(--card); width: 100%; max-width: 560px;
  border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
  padding: 22px; animation: slideUp .2s ease; max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; }
.modal-close { border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 8px; color: var(--text-2); font-size: 14px; }
.modal-close:hover { background: #fee2e2; color: var(--danger); }
.note-editor {
  width: 100%; min-height: 180px; padding: 14px; border: 1.5px solid var(--border);
  border-radius: 12px; resize: vertical; outline: none; line-height: 1.7; font-size: 15px;
}
.note-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 10px; }
.char-count { font-size: 12px; color: #9ca3af; }
.modal-actions { display: flex; gap: 8px; }
.confirm-text { color: var(--text-2); font-size: 14px; line-height: 1.7; }

/* ============ 私有云盘 ============ */
.files-head { justify-content: space-between; }
.files-stat { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.upload-btn .btn-icon { display: none; }

.drop-zone {
  border: 2px dashed var(--border); background: var(--card); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--text-2); cursor: pointer;
  margin-bottom: 16px; transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
.drop-icon { font-size: 34px; margin-bottom: 6px; }
.drop-zone p { font-size: 14px; }
.drop-zone .drop-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }

.upload-progress {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.progress-bar { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #8b5cf6); transition: width .2s;
}
.progress-text { font-size: 12px; color: var(--text-2); white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }

.file-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.file-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden; display: flex; flex-direction: column; animation: fadeIn .25s ease;
  transition: transform .15s, box-shadow .15s;
}
.file-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.file-thumb {
  position: relative; height: 140px; cursor: pointer;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb .thumb-icon { font-size: 44px; opacity: .85; }
.file-size-badge {
  position: absolute; right: 8px; bottom: 8px; background: rgba(17,24,39,.65); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
.file-info { padding: 10px 12px 4px; flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 6px; padding: 8px 12px 12px; }
.file-action {
  flex: 1; border: none; background: var(--bg); border-radius: 8px; padding: 7px 0;
  font-size: 12px; font-weight: 600; color: var(--text-2); transition: background .15s, color .15s;
}
.file-action:hover { background: var(--primary-light); color: var(--primary-dark); }
.file-action.del:hover { background: #fee2e2; color: var(--danger); }

/* 文件预览模态框 */
.viewer-card { max-width: 1080px; }
.viewer-title { font-size: 14px; font-weight: 600; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body {
  display: flex; align-items: center; justify-content: center; min-height: 220px;
  background: #0f172a; border-radius: 12px; overflow: hidden;
}
.viewer-img { max-width: 100%; max-height: 70vh; display: block; }
.viewer-video { width: 100%; max-height: 70vh; display: block; background: #000; }
.viewer-tip { color: #cbd5e1; font-size: 14px; padding: 30px 20px; text-align: center; line-height: 1.8; }

/* 文档预览（白底、可滚动） */
.viewer-body.doc-mode {
  display: block; align-items: initial; justify-content: initial;
  background: #fff; color: #1e293b; overflow: auto; max-height: 74vh; padding: 14px;
}
.viewer-body.doc-mode .viewer-tip { color: #64748b; }
.viewer-pdf { width: 100%; height: 74vh; border: 0; background: #52525b; display: block; }
.viewer-text {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.8; color: #1e293b;
}
.sheet-wrap { margin-bottom: 18px; }
.sheet-name { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.sheet-box { overflow: auto; max-height: 60vh; border: 1px solid #e2e8f0; border-radius: 8px; }
.sheet-box table { border-collapse: collapse; font-size: 13px; background: #fff; }
.sheet-box td, .sheet-box th { border: 1px solid #e2e8f0; padding: 5px 10px; white-space: nowrap; color: #1e293b; }
.sheet-box th { background: #f1f5f9; font-weight: 600; position: sticky; top: 0; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 200;
  max-width: 90vw; text-align: center; animation: fadeIn .2s;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warn { background: #d97706; }

/* ============ 动画 ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 响应式 ============ */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .topbar-inner { height: 52px; padding: 0 10px; }
  .brand { font-size: 15px; }
  .brand span { display: none; }
  .user-name { display: none; }
  .btn { padding: 9px 14px; font-size: 13px; }
  .content { padding: 14px 12px 90px; }
  .note-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .note-card { padding: 12px; }
  .note-content { -webkit-line-clamp: 7; font-size: 13px; }
  .note-actions { opacity: 1; }
  .new-note-btn .btn-text { display: none; }
  .new-note-btn .btn-icon { display: inline; font-size: 18px; font-weight: 700; }
  .new-note-btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
  .user-row { padding: 12px; gap: 10px; }
  .modal-card { padding: 18px; border-radius: 16px; }
  .panel-head { margin-bottom: 14px; }
  .upload-btn .btn-text { display: none; }
  .upload-btn .btn-icon { display: inline; font-size: 18px; font-weight: 700; }
  .upload-btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
  .drop-zone { padding: 26px 14px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .file-thumb { height: 110px; }
  .viewer-img, .viewer-video { max-height: 60vh; }
  .viewer-body.doc-mode { max-height: 62vh; padding: 10px; }
  .viewer-pdf { height: 62vh; }
}
@media (max-width: 380px) {
  .note-grid { grid-template-columns: 1fr 1fr; }
}
