:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #131728;
  --muted: #6b7280;
  --line: #e6e8f0;
  --primary: #6366f1;
  --primary-deep: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 60, .05);
  --shadow-md: 0 20px 44px -22px rgba(46, 49, 146, .38);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 6% -10%, #e3e6ff 0%, transparent 62%),
    radial-gradient(820px 480px at 102% -4%, #e0f2fe 0%, transparent 58%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
svg { flex-shrink: 0; }

.wrap {
  width: min(1240px, 100% - 40px);
  margin-inline: auto;
}

/* ---------------------------------------------------------------- 通用品牌 */

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 10px 20px -8px rgba(99, 102, 241, .75);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: .2px;
}

.brand-text small {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 顶栏 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 246, 251, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(230, 232, 240, .8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 70px;
}

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

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, .2);
  background: rgba(99, 102, 241, .08);
  color: var(--primary-deep);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}

.pill-link:hover { background: rgba(99, 102, 241, .14); }

/* ---------------------------------------------------------------- Hero */

.hero {
  padding: 66px 0 6px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, .18);
  background: rgba(99, 102, 241, .09);
  color: #4f46e5;
  font-size: 13px;
  font-weight: 600;
}

.hero h1 {
  margin: 20px 0 14px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.16;
  letter-spacing: -.6px;
}

.grad {
  background: linear-gradient(118deg, #6366f1 0%, #a855f7 55%, #06b6d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 640px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 30px;
}

.stat {
  min-width: 118px;
  padding: 14px 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.stat strong {
  display: block;
  font-size: 26px;
  letter-spacing: -.5px;
  background: linear-gradient(120deg, #4f46e5, #9333ea);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------- 资源区 + 二维码侧边栏 */

.resource-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 26px;
  align-items: start;
  margin-top: 36px;
}

.resource-main { min-width: 0; }

.qr-sidebar {
  position: sticky;
  top: 94px;
  scroll-margin-top: 94px;
}

.qr-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 40px -26px rgba(46, 49, 146, .35);
  text-align: center;
}

.sidebar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sidebar-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid #dfe3ff;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.qr-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
}

.sidebar-info { text-align: center; }

.qr-title {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.qr-sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------------------------------------------------------------- 筛选工具栏 */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 0;
  scroll-margin-top: 90px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 14px;
  cursor: pointer;
  transition: .2s;
}

.chip:hover {
  border-color: #c7c9f5;
  color: var(--primary-deep);
}

.chip.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 10px 20px -12px rgba(99, 102, 241, .9);
}

.search { position: relative; }

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.search input {
  width: 280px;
  max-width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: .2s;
}

.search input::placeholder { color: #9ca3af; }

.search input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

/* ---------------------------------------------------------------- 资源卡片 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #06b6d4);
  opacity: 0;
  transition: opacity .22s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: #d9dcf2;
  box-shadow: var(--shadow-md);
}

.card:hover::before { opacity: 1; }

.card[hidden] { display: none; }

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

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #dfe3ff;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 600;
}

.card-num {
  color: #c0c4d4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.card-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
}

.card-desc {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: .2s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 12px 22px -12px rgba(99, 102, 241, .95);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px -12px rgba(99, 102, 241, 1);
}

.btn-ghost {
  border-color: var(--line);
  background: #fff;
  color: #374151;
}

.btn-ghost:hover {
  border-color: #c7c9f5;
  background: #f8f8ff;
  color: var(--primary-deep);
}

.btn-danger {
  border-color: #fecaca;
  background: #fff;
  color: #b91c1c;
}

.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- 空状态 / 页脚 */

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

.site-footer {
  margin-top: 70px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .55);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 24px 0;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner p { margin: 0; }

.footer-admin {
  padding: 4px 10px;
  border-radius: 8px;
  color: #9ca3af;
  transition: .2s;
}

.footer-admin:hover {
  background: #eef0ff;
  color: var(--primary-deep);
}

/* ---------------------------------------------------------------- 收藏本站弹窗 */

.bookmark-pop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, .45);
  backdrop-filter: blur(2px);
}

.bookmark-pop[hidden] { display: none; }

.bookmark-card {
  width: min(390px, 100%);
  padding: 26px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 60px -24px rgba(30, 27, 75, .5);
}

.bookmark-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.bookmark-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.bookmark-card kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #f8f9ff;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

.bookmark-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* ---------------------------------------------------------------- 闪存提示 */

.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 16px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 14px;
}

.flash-success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.flash-error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.flash-info { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }

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

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 40px 20px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 60px -30px rgba(30, 27, 75, .38);
}

.auth-brand { margin-bottom: 26px; }

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -.3px;
}

.auth-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.auth-back {
  display: inline-block;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.auth-back:hover { color: var(--primary-deep); }

/* ---------------------------------------------------------------- 表单 */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}

.field em {
  color: #ef4444;
  font-style: normal;
}

.field input,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  outline: none;
  transition: .2s;
}

.field input:focus,
.field textarea:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

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

.field .hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 14px;
}

.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #374151;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.switch-field input {
  width: 18px;
  height: 18px;
  accent-color: #6366f1;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------- 后台 */

.admin-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.admin-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  min-height: 70px;
  padding: 10px 0;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.admin-nav > a,
.admin-nav .link-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: none;
  color: #4b5563;
  font-size: 14px;
  cursor: pointer;
  transition: .18s;
}

.admin-nav > a:hover,
.admin-nav .link-btn:hover {
  background: #f1f2fa;
  color: var(--primary-deep);
}

.admin-nav > a.is-active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}

.admin-nav .nav-home { color: var(--primary-deep); }

.admin-main {
  flex: 1;
  padding: 36px 0 70px;
}

.admin-main.narrow { max-width: 760px; }

.admin-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.admin-title-row h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -.3px;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-card {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: #fafbff;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #f1f2f8;
  vertical-align: middle;
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #fbfbfe; }

.row-dim { opacity: .55; }

.cell-title {
  font-weight: 600;
  color: var(--text);
}

.cell-sub {
  max-width: 340px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-links {
  display: flex;
  gap: 10px;
  font-size: 13px;
}

.cell-links a { color: var(--primary-deep); }
.cell-links a:hover { text-decoration: underline; }

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-on { background: #ecfdf5; color: #047857; }
.status-off { background: #f3f4f6; color: #6b7280; }

/* 上移 / 下移 */
.order-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-num {
  min-width: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.order-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: .15s;
}

.order-btn:hover:not(:disabled) {
  border-color: #c7c9f5;
  background: #f8f8ff;
  color: var(--primary-deep);
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ta-right { text-align: right; }

.empty-cell {
  padding: 44px 18px !important;
  color: var(--muted);
  text-align: center;
}

.card-form {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

/* 新增资源 · 一键识别 */
.scan-card {
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px dashed #c7c9f5;
  border-radius: 20px;
  background: linear-gradient(180deg, #f7f8ff, #fff);
}

.scan-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.scan-head .muted { font-size: 13px; }

.scan-card textarea {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  transition: .2s;
}

.scan-card textarea:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.scan-tip {
  color: var(--muted);
  font-size: 13px;
}

.scan-tip.is-success { color: #047857; }
.scan-tip.is-error { color: #b91c1c; }

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 980px) {
  .resource-layout { grid-template-columns: 1fr; gap: 0; }
  .qr-sidebar { order: -1; position: static; margin-bottom: 20px; }
  .sidebar-card {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px;
    text-align: left;
  }
  .sidebar-card .sidebar-eyebrow { display: none; }
  .sidebar-card .qr-img { width: 96px; flex-shrink: 0; }
  .sidebar-info { text-align: left; }
  .sidebar-card .qr-sub br { display: none; }
}

@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }

  .hero { padding-top: 44px; }
  .hero-sub { font-size: 15px; }

  .toolbar { margin-top: 0; }
  .search { width: 100%; }
  .search input { width: 100%; }

  .grid { grid-template-columns: 1fr; }

  .header-actions .pill-link { display: none; }

  .field-row { grid-template-columns: 1fr; }

  .admin-header-inner { padding: 12px 0; }
  .admin-main { padding-top: 24px; }

  .card-form { padding: 20px; }

  .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
