:root {
  --red: #b51d21;
  --red-dark: #8f1518;
  --ink: #222;
  --muted: #707070;
  --line: #dedede;
  --bg: #f4f4f4;
  --panel: #fff;
  --gold: #d49b28;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.65 Arial, "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  border-radius: 4px;
  padding: 8px 14px;
}
button:hover { background: var(--red-dark); }
.wrap {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
}
.topbar {
  background: #fff;
  border-top: 4px solid var(--red);
  border-bottom: 1px solid var(--line);
}
.header-grid {
  display: grid;
  grid-template-columns: 220px 1fr 96px;
  align-items: center;
  gap: 18px;
  min-height: 82px;
}
.brand {
  color: var(--red);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
}
.search {
  display: flex;
  max-width: 520px;
  width: 100%;
  justify-self: end;
}
.search input {
  width: 100%;
  border: 2px solid var(--red);
  border-right: 0;
  border-radius: 4px 0 0 4px;
  padding: 9px 12px;
}
.search button { border-radius: 0 4px 4px 0; min-width: 82px; }
.admin-link,
.top-actions a {
  color: var(--red);
  font-weight: 700;
  text-align: right;
}
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 350px;
}
.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
   /* 🔥 防止换行（关键） */
  white-space: nowrap;
}

.welcome {
  color: #666;
}

.level {
  color: #ff9800;
  font-weight: bold;
}

.username {
  color: #333;
  font-weight: bold;
}

.points b {
  color: #e91e63;
}

.link {
  margin-left: 6px;
  text-decoration: none;
  color: #2196f3;
}

.link.logout {
  color: #f44336;
}


.nav {
  background: var(--red);
  color: #fff;
}
.nav .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
.nav a {
  padding: 12px 18px;
  border-left: 1px solid rgba(255,255,255,.18);
}
.nav a:hover, .nav a.active { background: var(--red-dark); }
.layout {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 18px;
  padding: 18px 0 34px;
}
.notice {
  background: #fff8e7;
  border: 1px solid #edd8a2;
  color: #77530b;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.panel h2, .block-title {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 2px solid var(--red);
  color: var(--red);
  font-size: 18px;
}
.hero-list ul, .category-list, .rank-list {
  margin: 0;
  padding: 8px 14px 14px;
  list-style: none;
}
.related-panel ul {
  margin: 0;
  padding: 8px 14px 14px;
  list-style: none;
}
.catalog-list {
  margin: 0;
  padding: 4px 16px 10px;
  list-style: none;
}
.catalog-item {
  border-bottom: 1px dashed var(--line);
  padding: 11px 0;
}
.catalog-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 15px;
}
.catalog-title a:hover,
.catalog-item p a:hover {
  color: var(--red);
}
.catalog-title span,
.catalog-item p {
  color: var(--muted);
}
.catalog-title span {
  white-space: nowrap;
}
.catalog-item p {
  margin: 3px 0 0;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px 18px;
}
.pagination a,
.pagination span {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}
.pagination span {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.post-row {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px dashed var(--line);
  padding: 8px 0;
}
.post-row:last-child { border-bottom: 0; }
.post-row a:hover { color: var(--red); }
.thumb {
  width: 52px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  background: #efefef;
  border: 1px solid #e4e4e4;
}
.tag {
  color: var(--red);
  background: #fff0f0;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.date { color: var(--muted); white-space: nowrap; }
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.category-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}
.category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.category-head h3 { margin: 0; color: var(--red); font-size: 17px; }
.category-head button {
  padding: 4px 10px;
  background: #f5f5f5;
  color: var(--muted);
}
.category-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #e8e8e8;
}
.category-list li:last-child { border-bottom: 0; }
.contact { padding-bottom: 14px; }
.contact h2 { margin-bottom: 10px; }
.contact p { margin: 6px 14px; }
.qr {
  margin: 12px 14px 0;
  height: 150px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background:
    linear-gradient(90deg, #222 10px, transparent 10px) 18px 18px/28px 28px,
    linear-gradient(#222 10px, transparent 10px) 18px 18px/28px 28px,
    #fafafa;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.tabs button {
  border-radius: 0;
  background: #f7f7f7;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 10px 4px;
}
.tabs button.active {
  background: var(--red);
  color: #fff;
}
.rank-list {
  counter-reset: rank;
}
.rank-list li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.rank-list li::before {
  content: counter(rank);
  background: #eee;
  color: #555;
  text-align: center;
  border-radius: 3px;
  height: 22px;
  line-height: 22px;
}
.rank-list li:nth-child(-n+3)::before {
  background: var(--gold);
  color: #fff;
}
dialog {
  width: min(860px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.detail { padding: 24px; position: relative; }
.close {
  position: absolute;
  top: 14px;
  right: 14px;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}
.crumb, .risk { color: var(--muted); }
.detail h1 {
  margin: 8px 42px 8px 0;
  font-size: 25px;
}
.detail-cover {
  display: block;
  width: 100%;
  max-height: 450px;
  object-fit: cover;
  border-radius: 6px;
  margin: 14px 0;
}
pre {
  white-space: pre-wrap;
  overflow: auto;
  background: #171717;
  color: #f2f2f2;
  border-radius: 6px;
  padding: 14px;
}
.detail-actions { display: flex; gap: 10px; }
.article {
  padding: 18px 22px 22px;
}
.article h1 {
  margin: 4px 0 10px;
  text-align: center;
  font-size: 25px;
  line-height: 1.35;
}
.article-meta {
  text-align: center;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.article-content {
  margin: 14px 0;
}
.formula-code {
  min-height: 180px;
}
.watermark-figure {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 18px auto;
}
.article-image {
  display: block;
  max-width: 100%;
  max-height: 430px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}
.future-check {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 18px 0;
  padding: 12px 0;
}
.future-check h2 {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 18px;
}
.article-contact {
  color: var(--red);
  font-weight: 700;
}
.paid-box {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border: 1px solid #f0c36d;
  background: #fff8e7;
  border-radius: 6px;
  padding: 16px;
  margin: 16px 0;
}
.paid-box h2 {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 20px;
}
.paid-box p {
  margin: 4px 0;
}
.paid-box b {
  color: #f00;
  font-size: 20px;
}
.paid-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.outline-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 4px;
  padding: 8px 14px;
  background: #fff;
}
.muted {
  color: var(--muted);
}
.preview-code {
  margin: 14px 0 18px;
}
.preview-title {
  color: var(--red);
  font-weight: 700;
  margin-bottom: 6px;
}

.admin-body {
  background: linear-gradient(180deg, #f4f7fb 0%, #e7edf4 100%);
}
.admin-shell {
  width: min(1220px, calc(100% - 24px));
  margin: 28px auto 34px;
}
.hidden { display: none !important; }
.login-card {
  width: min(480px, 100%);
  margin: 80px auto;
  background: #ffffff;
  border-radius: 18px;
  padding: 32px;
  border: 1px solid rgba(31, 41, 55, .08);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .08);
}
.login-card h1,
.admin-head h1 {
  margin: 0 0 10px;
  color: #17212e;
}
label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
input,
textarea,
select {
  border: 1px solid #d7dde8;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(181, 29, 33, .75);
  box-shadow: 0 0 0 4px rgba(181, 29, 33, .12);
}
textarea { resize: vertical; }
.error { color: var(--red); min-height: 20px; }
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  gap: 16px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stat {
  background: linear-gradient(180deg, #ffffff 0%, #fff6f4 100%);
  border-radius: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(217, 66, 76, .16);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .05);
}
.stat strong {
  display: block;
  font-size: 28px;
  color: #1f2937;
}
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.category-panel {
  grid-column: 1 / -1;
  max-height: 700px;
  display: flex;
  flex-direction: column;
}
.category-panel .table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 140px;
}
.category-panel h2 {
  margin: 0 0 14px;
  flex-shrink: 0;
}
.admin-panel {
  background: #ffffff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .06);
  border: 1px solid rgba(15, 23, 42, .08);
}
.admin-panel h2 {
  margin: 0 0 18px;
  font-size: 21px;
  color: #111827;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.checks,
.actions,
.table-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
}
.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  border: 1px dashed rgba(120, 138, 159, .32);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  color: var(--muted);
  background: #f8fafc;
}
.image-preview img {
  width: 148px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
}
.image-preview.empty {
  justify-content: center;
}
.actions {
  margin-top: 12px;
}
button {
  border: 0;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
button:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(181, 29, 33, .18);
}
.actions button:nth-child(2),
#logoutBtn,
.table-wrap button.secondary {
  background: #5d6672;
}
.table-wrap {
  overflow: auto;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .08);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th,
td {
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  padding: 14px 10px;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}
tr:hover td {
  background: #f8fbff;
}
.status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #eef6ec;
  color: #2f7d32;
  font-size: 13px;
}
.status.draft {
  background: #fff3d7;
  color: #8a5a00;
}
.row-actions {
  display: flex;
  gap: 10px;
}
.row-actions button {
  padding: 6px 14px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  min-width: 72px;
}
.row-actions button:hover {
  background: #e2e8f0;
}
.row-actions .delete {
  background: #fee2e2;
  color: #b91c1c;
}
.site-panel,
.user-admin-panel {
  margin-top: 18px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0;
}
.section-head input {
  max-width: 260px;
}
.user-level {
  width: 120px;
}
.user-points {
  width: 100px;
}
.site-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.site-form label {
  margin: 0;
}
.site-form button {
  align-self: end;
}

input[name="views"],
input[name="downloads"] {
  width: 100px !important;
}

.user-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  padding: 10px 0 0;
}
.user-layout .notice {
  grid-column: 1 / -1;
  margin-bottom: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.user-menu {
  background: #eee;
  border: 1px solid #d4d4d4;
  align-self: start;
}
.user-menu button {
  display: block;
  width: 100%;
  border-radius: 0;
  background: #eee;
  color: #111;
  padding: 11px 8px;
  font-size: 16px;
}
.user-menu button.active {
  background: #1f97e7;
  color: #fff;
  font-weight: 700;
}
.user-panel {
  background: #fff;
  border: 1px solid #d7d7d7;
  border-radius: 6px;
  padding: 20px;
  min-height: 510px;
}
.user-login { margin: 40px auto; }
.auth-switch {
  margin: 12px 0 0;
  text-align: center;
}
.auth-switch a {
  color: #0056b8;
  font-weight: 700;
}
.member-head {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.member-head b { color: var(--red); }
.charge-card { padding: 8px 0 0; }
.red { color: #f00; }
.blue { color: #00f; }
.green { color: #008000; }
.purple { color: #8000a0; }
.charge-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  border: 1px solid #cfcfcf;
}
.charge-table th {
  width: 100px;
  text-align: right;
  background: #eee;
  font-weight: 400;
}
.charge-table th,
.charge-table td {
  border: 1px solid #cfcfcf;
  padding: 8px;
}
.amount-input {
  width: 74px;
  color: #f00;
  font-weight: 700;
  font-size: 20px;
  text-align: center;
}
.money {
  background: #f3f3f3;
  color: #000;
  border: 1px solid #999;
  padding: 7px 10px;
  margin-left: 4px;
}
.points-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  background: #0056b8;
  color: #fff;
  font-weight: 700;
}
.risk-lines {
  font-size: 13px;
  font-weight: 700;
}
.small-form { max-width: 420px; }
.user-table {
  width: 100%;
  border-collapse: collapse;
}
.user-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
}
.footer {
  text-align: center;
  color: #003a8c;
  padding: 22px 10px;
}

@media (max-width: 900px) {
  .header-grid, .layout, .admin-grid, .site-form {
    grid-template-columns: 1fr;
  }
  .search { justify-self: stretch; max-width: none; }
  .admin-link { text-align: left; }
  .top-actions { justify-content: flex-start; }
  .category-grid, .stats { grid-template-columns: 1fr; }
  .post-row { grid-template-columns: 1fr auto; }
  .post-row .thumb { display: none; }
  .post-row .date { grid-column: 2; }
  .user-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .brand { font-size: 24px; }
  .nav a { padding: 10px 12px; }
  .form-row { grid-template-columns: 1fr; }
  .detail { padding: 18px; }
  .detail h1 { font-size: 20px; }
}
