/* ============================================================
   资源下载中心 · 设计系统
   - 浅色 / 深色自动 + 手动切换
   - 卡片式布局，留白与层次
   - 手机 / 平板 / 桌面三档响应式
   ============================================================ */

:root {
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  --success-bg: #ecfdf5;
  --success-fg: #047857;
  --warn-bg: #fffbeb;
  --warn-fg: #b45309;
  --danger-bg: #fef2f2;
  --danger-fg: #b91c1c;
  --info-bg: #eff6ff;
  --info-fg: #1d4ed8;

  --bg: #f5f7fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --header-h: 64px;
  --maxw: 1200px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

[data-theme='dark'] {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --surface: #111c33;
  --surface-2: #0f1a2e;
  --surface-hover: #16233f;
  --border: #1e2b47;
  --border-strong: #2b3b5c;
  --text: #e6edf7;
  --text-soft: #a9b7cc;
  --text-muted: #8595ad;
  --text-faint: #6b7c96;
  --brand-50: #16233f;
  --brand-100: #1a2a4a;
  --brand-200: #24365c;
  --brand-500: #60a5fa;
  --brand-600: #3b82f6;
  --brand-700: #2563eb;
  --success-bg: #052e26;
  --success-fg: #34d399;
  --warn-bg: #2c1f06;
  --warn-fg: #fbbf24;
  --danger-bg: #321018;
  --danger-fg: #f87171;
  --info-bg: #131f3d;
  --info-fg: #93c5fd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

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

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

::selection {
  background: var(--brand-200);
}

/* ----------------------------- 布局 ----------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.page {
  padding: 28px 0 72px;
  min-height: calc(100vh - var(--header-h));
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* ----------------------------- 顶部导航 ----------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  height: 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-soft);
  transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-link.is-active {
  color: var(--brand-600);
  background: var(--brand-50);
  font-weight: 600;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 220px;
  height: 38px;
  padding: 0 38px 0 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, width 0.2s;
}

.search-box input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

.mobile-menu-btn {
  display: none;
}

/* ----------------------------- 按钮 ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, background-color 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.32);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: color-mix(in srgb, var(--danger-fg) 25%, transparent);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: color-mix(in srgb, var(--success-fg) 25%, transparent);
}

.btn-icon {
  width: 38px;
  padding: 0;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

/* ----------------------------- 卡片 ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-body {
  padding: 18px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 650;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

/* ----------------------------- 项目卡片 ----------------------------- */
.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.project-cover {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--brand-100), var(--surface-2));
  position: relative;
  overflow: hidden;
}

.project-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-cover .cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--brand-600);
  background-image: radial-gradient(circle at 18% 22%, color-mix(in srgb, var(--brand-500) 16%, transparent), transparent 62%),
    radial-gradient(circle at 82% 78%, color-mix(in srgb, var(--brand-700) 14%, transparent), transparent 58%);
}

.project-cover .cover-fallback svg {
  width: 40px;
  height: 40px;
  opacity: 0.9;
  stroke-width: 1.6;
}

.project-cover .cover-fallback .cover-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-cover .cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--brand-600);
  background-image: radial-gradient(circle at 20% 25%, color-mix(in srgb, var(--brand-500) 18%, transparent), transparent 60%),
    radial-gradient(circle at 80% 75%, color-mix(in srgb, var(--brand-700) 16%, transparent), transparent 58%);
}

.detail-cover .cover-fallback svg {
  width: 56px;
  height: 56px;
  stroke-width: 1.5;
}

.detail-cover {
  position: relative;
}

.project-cover {
  position: relative;
}

.project-badges {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  gap: 6px;
}

.project-card-body {
  padding: 15px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.project-card h3 {
  font-size: 15.5px;
  font-weight: 650;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card .summary {
  color: var(--text-muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}

.project-meta {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
  gap: 8px;
}

/* ----------------------------- 徽标 / 标签 ----------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge-brand {
  background: var(--brand-50);
  color: var(--brand-600);
  border: 1px solid color-mix(in srgb, var(--brand-500) 22%, transparent);
}
.badge-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid color-mix(in srgb, var(--success-fg) 22%, transparent);
}
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid color-mix(in srgb, var(--warn-fg) 22%, transparent);
}
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border: 1px solid color-mix(in srgb, var(--danger-fg) 22%, transparent);
}
.badge-info {
  background: var(--info-bg);
  color: var(--info-fg);
  border: 1px solid color-mix(in srgb, var(--info-fg) 22%, transparent);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ----------------------------- 表单 ----------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-soft);
}

.field .hint {
  font-size: 12px;
  color: var(--text-faint);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 16%, transparent);
}

.input[aria-invalid='true'] {
  border-color: var(--danger-fg);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field-error {
  font-size: 12.5px;
  color: var(--danger-fg);
  min-height: 18px;
}

.form-note {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--text-soft);
  font-size: 12.5px;
  border: 1px solid color-mix(in srgb, var(--brand-500) 18%, transparent);
}

/* ----------------------------- 表格（列表容器，非堆砌） ----------------------------- */
.data-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, background-color 0.15s;
}

.data-row:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 720px;
}

table.data-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

table.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover {
  background: var(--surface-2);
}

/* ----------------------------- 弹窗 ----------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 15, 30, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.18s ease;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.2s ease;
}

.modal-lg {
  max-width: 760px;
}

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

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ----------------------------- Toast ----------------------------- */
.toast-wrap {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slide-in 0.22s ease;
  pointer-events: auto;
}

.toast-success {
  border-left: 3px solid var(--success-fg);
}
.toast-error {
  border-left: 3px solid var(--danger-fg);
}
.toast-warn {
  border-left: 3px solid var(--warn-fg);
}
.toast-info {
  border-left: 3px solid var(--brand-500);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ----------------------------- 空状态 / 骨架 ----------------------------- */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  border: 1px solid var(--border);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* ----------------------------- 分页 ----------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--brand-500);
  color: var(--brand-600);
}

.page-btn.is-active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  font-weight: 600;
}

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

/* ----------------------------- 头像 / 下拉 ----------------------------- */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 14px;
  text-transform: uppercase;
  flex: none;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  animation: pop-in 0.16s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 0;
}

/* ----------------------------- 侧边栏（后台） ----------------------------- */
.admin-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 0 64px;
}

.admin-side {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

.side-group-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 10px 10px 6px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--text-soft);
  transition: background-color 0.15s, color 0.15s;
}

.side-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.side-link.is-active {
  background: var(--brand-50);
  color: var(--brand-600);
  font-weight: 600;
}

.side-link .side-icon {
  width: 18px;
  display: grid;
  place-items: center;
  color: currentColor;
}

/* ----------------------------- 统计卡 ----------------------------- */
.stat-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.stat-icon {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-faint);
}

/* ----------------------------- 详情页 ----------------------------- */
.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.detail-cover {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  aspect-ratio: 16 / 9;
}

.detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-title {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-desc {
  color: var(--text-soft);
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 文件列表 */
/* ----------------------------- 文件树（还原分享的文件夹结构） ----------------------------- */
.file-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tree-node {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tree-dir {
  cursor: pointer;
  user-select: none;
}

.tree-dir:hover {
  background: var(--surface-hover);
}

.tree-caret {
  width: 18px;
  height: 18px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: transform 0.18s ease;
}

.tree-caret.is-open {
  transform: rotate(0deg);
}

.tree-caret:not(.is-open) {
  transform: rotate(-90deg);
}

.tree-children {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 22px;
  padding-left: 12px;
  border-left: 1px dashed var(--border);
}

.tree-node.is-collapsed > .tree-children {
  display: none;
}

/* 层级缩进由嵌套的 .tree-children 自带（margin-left + 虚线），
   这里保证文件行与同级目录行左对齐（都留出箭头位）。
   根目录卡片去掉多余左侧留白，视觉更接近原分享页。 */
.tree-node > .tree-children > .tree-node > .tree-dir,
.tree-node > .tree-children > .tree-file {
  border-radius: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s, background-color 0.15s;
}

.file-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.file-main {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 下载提示条 */
.download-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-50), var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand-500) 24%, transparent);
}

/* ----------------------------- 认证页 ----------------------------- */
.auth-wrap {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
}

.auth-tip {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
}

.alert {
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-bottom: 14px;
  border: 1px solid transparent;
  line-height: 1.6;
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: color-mix(in srgb, var(--info-fg) 20%, transparent);
}
.alert-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: color-mix(in srgb, var(--warn-fg) 20%, transparent);
}
.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: color-mix(in srgb, var(--danger-fg) 20%, transparent);
}
.alert-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: color-mix(in srgb, var(--success-fg) 20%, transparent);
}

/* ----------------------------- 其它 ----------------------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--brand-500);
  color: var(--brand-600);
}

.chip.is-active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  font-weight: 550;
}

.kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 13.5px;
}

.kv dt {
  color: var(--text-muted);
}
.kv dd {
  margin: 0;
  color: var(--text);
  word-break: break-all;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.text-muted {
  color: var(--text-muted);
}
.text-faint {
  color: var(--text-faint);
}
.text-danger {
  color: var(--danger-fg);
}
.text-success {
  color: var(--success-fg);
}
.text-sm {
  font-size: 13px;
}
.text-xs {
  font-size: 12px;
}
.fw-600 {
  font-weight: 600;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mb-8 {
  margin-bottom: 8px;
}
.mb-16 {
  margin-bottom: 16px;
}
.w-full {
  width: 100%;
}
.nowrap {
  white-space: nowrap;
}

.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-soft);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(2px);
  z-index: 70;
  display: grid;
  place-items: center;
}

/* ----------------------------- 响应式 ----------------------------- */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .detail-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .admin-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .admin-shell main {
    min-width: 0;
  }
  .admin-side {
    position: static;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .admin-side > * {
    flex: 0 0 auto;
  }
  .admin-side .side-group-label {
    display: none;
  }
  .admin-side .side-link {
    white-space: nowrap;
  }
}

@media (max-width: 860px) {
  .main-nav,
  .search-box {
    display: none;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .header-actions .btn-ghost span.btn-label {
    display: none;
  }
}

@media (max-width: 720px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
  .page {
    padding: 18px 0 56px;
  }
  .container {
    padding: 0 14px;
  }
  .detail-title {
    font-size: 21px;
  }
  .stat-value {
    font-size: 23px;
  }
  .toast-wrap {
    left: 12px;
    right: 12px;
    top: 70px;
  }
  .toast {
    max-width: none;
  }
  .auth-card {
    padding: 24px 20px;
  }
  .modal {
    max-height: 92vh;
  }
  .kv {
    grid-template-columns: 84px minmax(0, 1fr);
  }
  .file-item {
    flex-wrap: wrap;
  }
  .logo span.logo-text {
    display: none;
  }
}

/* 移动端抽屉导航 */
.mobile-nav {
  position: fixed;
  inset: var(--header-h) 0 0;
  z-index: 45;
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  animation: fade-in 0.15s ease;
}

.mobile-nav .nav-link {
  padding: 13px 14px;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* 打印/无障碍 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
