:root {
  color-scheme: dark;
  --bg: #090a18;
  --bg-soft: #111326;
  --surface: rgba(24, 26, 49, 0.88);
  --surface-strong: #17192f;
  --line: rgba(255, 255, 255, 0.11);
  --line-warm: rgba(255, 177, 71, 0.32);
  --text: #f8f8ff;
  --muted: #a8a9bd;
  --orange: #ff8a2a;
  --gold: #ffc95b;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
  --radius-lg: 24px;
  --radius-md: 18px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 8%, rgba(255, 139, 42, 0.12), transparent 29rem),
    radial-gradient(circle at 12% 72%, rgba(118, 76, 255, 0.1), transparent 34rem),
    linear-gradient(145deg, #080914 0%, #101126 52%, #090a18 100%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 14px clamp(20px, 4vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 22, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand-mark {
  width: 50px;
  height: 50px;
  object-fit: contain;
  filter: drop-shadow(0 5px 14px rgba(255, 153, 45, 0.28));
}

.brand-copy {
  display: grid;
  gap: 2px;
  text-align: left;
}

.brand-copy strong {
  font-size: 23px;
  letter-spacing: 0.12em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.member-link {
  padding: 10px 17px;
  border: 1px solid var(--line-warm);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 143, 45, 0.08);
  text-decoration: none;
  transition: 160ms ease;
}

.member-link:hover,
.member-link:focus-visible {
  border-color: var(--gold);
  background: rgba(255, 143, 45, 0.16);
  outline: none;
}

.main-content {
  width: min(1480px, calc(100% - clamp(32px, 7vw, 112px)));
  margin: 0 auto;
  flex: 1;
  padding: clamp(42px, 6vw, 82px) 0 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-heading .summary {
  max-width: 610px;
  margin: 13px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.revision {
  flex: 0 0 auto;
  color: #7e8095;
  font-size: 12px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.module-card,
.item-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  color: var(--text);
  background: linear-gradient(145deg, rgba(28, 30, 56, 0.96), rgba(17, 18, 37, 0.96));
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  isolation: isolate;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.module-card {
  min-height: 238px;
  padding: 28px;
  border-radius: var(--radius-lg);
}

.module-card::before,
.item-card::before {
  position: absolute;
  content: "";
  z-index: -1;
  inset: 0;
  background: linear-gradient(112deg, rgba(6, 7, 18, 0.52) 6%, rgba(10, 11, 26, 0.18) 56%, rgba(10, 11, 26, 0.02));
}

.module-card::after {
  position: absolute;
  content: "";
  z-index: -1;
  width: 180px;
  height: 180px;
  right: -70px;
  top: -92px;
  border-radius: 50%;
  background: rgba(255, 148, 51, 0.13);
  filter: blur(2px);
}

.module-card:hover,
.module-card:focus-visible,
.item-card:hover,
.item-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 197, 86, 0.64);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 164, 61, 0.12);
  outline: none;
}

.module-card:disabled,
.item-card:disabled {
  opacity: 0.96;
  cursor: not-allowed;
  filter: saturate(0.96);
}

.module-card:disabled:hover,
.item-card:disabled:hover {
  transform: none;
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.card-cover {
  position: absolute;
  z-index: -2;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  object-fit: cover;
  object-position: center center;
  filter: brightness(1) saturate(1.1) contrast(1.08);
}

/* 国学素材本身上下各带约22%的白色画布；桌面宽卡需额外放大后再由卡片裁切。 */
.module-card[data-module-id="guoxue"] .card-cover {
  transform: scale(1.15);
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 18px;
}

.card-icon-wrap {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 204, 102, 0.28);
  border-radius: 16px;
  color: var(--gold);
  background: rgba(9, 10, 24, 0.68);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  font-size: 26px;
}

.card-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

/* 一级应用恢复旧首页的直显 Logo：保留统一占位尺寸，但不再绘制方框。 */
.module-card .card-icon-wrap {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.module-card .card-icon-wrap.has-image .card-icon {
  width: 52px;
  height: 52px;
}

.module-card .card-icon-wrap.is-fallback {
  text-shadow: 0 4px 18px rgba(255, 182, 59, 0.34);
}

/* 四个历史模块原本就是彩色 Emoji，不是箭头/网格占位图。 */
.module-card .card-icon-wrap.is-original-symbol {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 52px;
  line-height: 1;
  text-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}

.card-type {
  position: absolute;
  z-index: 2;
  right: 24px;
  bottom: 22px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #ddddea;
  background: rgba(9, 10, 25, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.module-card h2,
.item-card h2 {
  margin: 35px 0 8px;
  font-size: 27px;
  line-height: 1.18;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.78);
}

/*
 * 一级模块名称只保存普通文字，展示端统一生成轻微的机械立体层次。
 * 这样后台改名或新增模块时，不需要再制作文字图片。
 */
.module-card h2 {
  color: #f4f1e9;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 900;
  letter-spacing: 0.015em;
  -webkit-text-stroke: 0.65px rgba(3, 5, 10, 0.96);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22),
    0 2px 0 rgba(22, 24, 31, 0.96),
    0 4px 8px rgba(0, 0, 0, 0.66);
}

.module-card p,
.item-card p {
  margin: 0;
  color: #d0d1de;
  line-height: 1.55;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.74);
}

.module-card > p {
  max-width: calc(100% - 118px);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.back-button:hover,
.back-button:focus-visible {
  border-color: var(--gold);
  outline: none;
}

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

.collection-grid.layout-nine {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.collection-grid.layout-twelve,
.collection-grid.layout-auto {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.item-card {
  min-height: 185px;
  padding: 22px;
  border-radius: var(--radius-md);
}

.item-card h2 {
  margin-top: 26px;
  font-size: 20px;
}

.landing-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 32px;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid var(--line-warm);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(27, 28, 53, 0.96), rgba(14, 15, 31, 0.98));
  box-shadow: var(--shadow);
}

.landing-hero {
  width: 100%;
  max-height: 390px;
  margin: 28px 0 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  object-fit: cover;
}

.landing-panel h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
}

.landing-summary {
  max-width: 750px;
  color: #cacbd9;
  font-size: 17px;
  line-height: 1.8;
}

.download-stack {
  display: grid;
  align-content: start;
  gap: 14px;
}

.download-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 15px;
  width: 100%;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

button.download-card:not(:disabled) {
  cursor: pointer;
}

button.download-card:not(:disabled):hover,
button.download-card:not(:disabled):focus-visible {
  border-color: var(--gold);
  background: rgba(255, 149, 50, 0.09);
  outline: none;
}

.download-card:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.download-card small,
.system-note,
.status-note {
  color: var(--muted);
}

.download-state {
  grid-row: span 2;
  align-self: center;
  color: var(--gold);
  font-size: 13px;
}

.qr-card {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: #171829;
}

.qr-card img {
  width: min(190px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
}

.empty-state,
.error-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 48vh;
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.error-report-button {
  margin-top: 10px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 174, 71, 0.48);
  border-radius: 999px;
  background: rgba(255, 138, 42, 0.12);
  color: #fff4e8;
  font: inherit;
  cursor: pointer;
}

.error-report-button:disabled {
  cursor: default;
  opacity: 0.76;
}

.loading-orbit {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 25px;
  color: #9293a8;
  font-size: 14px;
}

.footer-slogan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.footer-slogan span {
  color: var(--gold);
}

.footer-slogan p {
  margin: 0;
}

.footer-compliance {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 9px;
  color: #b5b6c7;
  font-size: 12px;
  line-height: 1.6;
}

.footer-compliance[hidden] {
  display: none;
}

.footer-compliance > :not(:first-child)::before {
  content: "|";
  margin-right: 9px;
  color: #5d5f73;
}

.footer-compliance a {
  color: inherit;
  text-decoration: none;
}

.footer-compliance a:hover,
.footer-compliance a:focus-visible {
  color: var(--gold);
  outline: none;
}

.footer-police-link {
  display: inline-flex;
  align-items: center;
}

.footer-police-badge {
  width: 18px;
  height: 18px;
  margin-right: 5px;
  object-fit: contain;
}

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

@media (max-width: 1040px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .collection-grid.layout-twelve,
  .collection-grid.layout-auto {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 700px) {
  .site-header {
    min-height: 68px;
    padding: 10px 18px;
  }

  .brand-mark {
    width: 43px;
    height: 43px;
  }

  .brand-copy strong {
    font-size: 19px;
  }

  .brand-copy small {
    display: none;
  }

  .member-link {
    padding: 9px 12px;
    font-size: 13px;
  }

  .main-content {
    width: min(100% - 28px, 1480px);
    padding-top: 32px;
  }

  .page-heading {
    display: block;
  }

  .revision {
    display: block;
    margin-top: 14px;
  }

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

  .collection-grid.layout-nine,
  .collection-grid.layout-twelve,
  .collection-grid.layout-auto {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-card {
    min-height: 214px;
  }

  .card-type {
    right: 20px;
    bottom: 18px;
  }

  .module-card .card-icon-wrap.is-original-symbol {
    font-size: 42px;
  }

  .landing-panel {
    padding: 24px 20px;
  }
}

@media (max-width: 430px) {
  .collection-grid.layout-nine,
  .collection-grid.layout-twelve,
  .collection-grid.layout-auto {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
