* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #4f8ff7;
  --primary-dark: #3b7de8;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e8eaed;
  --text: #1f2329;
  --text-secondary: #8f959e;
  --rail-width: 72px;
  --radius: 12px;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ===== Auth ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #e8f1ff 0%, #f5f8ff 50%, #eef2f8 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(79, 143, 247, 0.12);
}

.auth-card h1 { font-size: 22px; margin-bottom: 8px; text-align: center; }
.auth-card .subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fafbfc;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 143, 247, 0.15);
  background: #fff;
}
.form-group input:disabled { background: #f0f1f3; color: var(--text-secondary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #e2e5ea; }
.btn-danger { background: #ff6b6b; color: #fff; }
.btn-danger:hover { background: #ee5a5a; }
.btn-sm { padding: 7px 14px; font-size: 13px; width: auto; }
.btn-text { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 6px; }
.btn-text:hover { background: rgba(79, 143, 247, 0.08); }
.btn-text.danger { color: #ff6b6b; }

.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 8px; text-align: center; border-radius: 10px;
  cursor: pointer; background: #f3f4f6; font-size: 14px; border: 2px solid transparent;
}
.tab.active { background: #edf4ff; border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }

.toast {
  position: fixed; top: 20px; right: 20px; padding: 12px 20px;
  border-radius: 10px; color: #fff; font-size: 14px; z-index: 9999;
  animation: slideIn 0.3s ease; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.success { background: #34c759; }
.toast.error { background: #ff6b6b; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== App Shell (Aliyun style) ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.nav-rail {
  width: var(--rail-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  flex-shrink: 0;
}

.nav-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f8ff7, #6aa8ff);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  width: 56px;
  padding: 10px 0;
  border: none;
  background: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  transition: background 0.2s, color 0.2s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { background: #f3f5f8; color: var(--text); }
.nav-item.active { background: #edf4ff; color: var(--primary); }

.nav-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #edf4ff;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-top: auto;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 20px;
}

.search-box {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3f5f8;
  border-radius: 20px;
  padding: 0 16px;
  height: 40px;
}
.search-box svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  outline: none;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-label { font-size: 14px; color: var(--text-secondary); }

.content-area {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-head h2 { font-size: 18px; font-weight: 600; }

.breadcrumb-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb-row .sep { color: var(--text-secondary); }
.breadcrumb-row h2 { font-size: 18px; }

.toolbar { display: flex; gap: 8px; }

/* Folder grid */
.folder-grid,
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.folder-card.selected,
.file-card.selected {
  border-color: var(--primary);
  background: #f0f6ff;
  box-shadow: 0 0 0 2px rgba(79, 143, 247, 0.25);
}
.select-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
}
.select-check input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.folder-card,
.file-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  border: 1px solid transparent;
}
.folder-card:hover,
.file-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border-color: var(--border);
  transform: translateY(-2px);
}

.folder-icon { margin-bottom: 12px; }
.folder-icon svg { width: 48px; height: 48px; }

.file-preview {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f5f8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.file-icon-wrap svg { width: 48px; height: 48px; }

.card-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.card-meta {
  font-size: 12px;
  color: var(--text-secondary);
}
.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #edf4ff;
  color: var(--primary);
}

.file-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
  opacity: 0;
  transition: opacity 0.2s;
}
.file-card:hover .file-card-actions { opacity: 1; }

.card-action {
  font-size: 12px;
  padding: 4px 8px;
  border: none;
  background: #f3f5f8;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.card-action:hover { background: #e8ecf0; }
.card-action.danger { color: #ff6b6b; }

.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-height: 90vh;
  overflow-y: auto;
}
.modal.modal-lg { max-width: 520px; }
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.modal h3.sub-title { font-size: 15px; margin: 20px 0 12px; color: var(--text-secondary); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.modal-actions .btn-primary { width: auto; }

.share-link-box label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 8px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; background: #fafbfc; }

.member-list { max-height: 280px; overflow-y: auto; }
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f5f8;
}
.member-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  font-size: 14px;
}
.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.member-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #edf4ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.perm-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fafbfc;
}

/* Profile */
.profile-avatar-edit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #edf4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: var(--primary);
  overflow: hidden;
}
.drop-zone {
  position: relative;
  min-height: 200px;
  border-radius: var(--radius);
  transition: background 0.2s, border-color 0.2s;
}
.drop-zone.drag-over {
  background: #edf4ff;
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}
.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(237, 244, 255, 0.92);
  color: var(--primary);
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--radius);
  z-index: 10;
  pointer-events: none;
}
.upload-menu-wrap { position: relative; display: inline-block; }
.upload-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  min-width: 140px;
  z-index: 100;
  overflow: hidden;
}
.upload-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}
.upload-menu button:hover { background: #f3f5f8; }
.subfolder-card { cursor: pointer; }
.subfolder-card .folder-icon { margin-bottom: 12px; }
.upload-progress {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 9998;
  min-width: 220px;
  font-size: 14px;
}
.upload-progress .bar {
  height: 4px;
  background: #e8eaed;
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.upload-progress .bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.2s;
}
