:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #050c16;
  --surface: #0b1625;
  --surface-raised: #101d2d;
  --surface-soft: #142234;
  --line: rgba(148, 174, 202, .18);
  --line-strong: rgba(126, 201, 243, .34);
  --text: #f5f8fc;
  --muted: #95a5b8;
  --cyan: #79d9ff;
  --blue: #4f8df7;
  --lime: #b8ef55;
  --gold: #e5bd58;
  --danger: #ff5964;
  --nav-height: 68px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(81, 126, 174, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(81, 126, 174, .07) 1px, transparent 1px);
  background-size: 82px 82px;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.library-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: 22px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 12, 22, .94);
  backdrop-filter: blur(20px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; }
.brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 14px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11px; }

.library-nav nav { display: flex; align-items: stretch; height: 100%; }
.library-nav nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  color: #c8d2de;
  font-size: 13px;
  font-weight: 650;
  transition: color .18s ease;
}
.library-nav nav a:hover, .library-nav nav a.active { color: var(--cyan); }
.library-nav nav a.active::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 2px;
  background: var(--cyan);
  box-shadow: 12px 0 var(--lime);
}

.account-wrap { position: relative; justify-self: end; }
.account-button {
  min-width: 82px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.account-button:hover, .account-button:focus-visible { border-color: var(--cyan); outline: none; }
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #0c1827;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .42);
}
.account-menu strong, .account-menu span { display: block; }
.account-menu strong { margin-bottom: 4px; }
.account-menu span { margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.account-menu a, .account-menu button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dce6f2;
  cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover { background: var(--surface-soft); }

main { width: min(1560px, 100%); margin: 0 auto; padding: 24px 30px 34px; }
.library-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 22px;
}
.heading-copy { display: flex; align-items: center; gap: 14px; }
.heading-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  font-size: 24px;
}
.heading-copy h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: -.04em; }
.heading-copy p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.library-search {
  width: calc(100% - 28px);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 29, 45, .78);
  color: var(--muted);
  margin: 14px 14px 4px;
}
.library-search:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(121, 217, 255, .1); }
.library-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.library-search input::placeholder { color: #708196; }
.library-search kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; color: #8394a7; font: 11px ui-monospace, monospace; }

.library-workspace {
  min-height: calc(100vh - 148px);
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(390px, 1fr) minmax(270px, 320px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 17, 31, .9);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .25);
}
.catalog-panel, .preview-panel, .detail-panel { min-width: 0; }
.catalog-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(9, 20, 34, .92); }
.preview-panel { padding: 20px; border-right: 1px solid var(--line); }
.detail-panel { padding: 20px 22px; background: rgba(7, 17, 30, .84); }
.panel-label { margin-bottom: 16px; color: #cbd6e3; font-size: 12px; font-weight: 750; letter-spacing: .08em; }

.category-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 14px 10px;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.category-tabs button:hover { color: var(--text); }
.category-tabs button.active { border-color: var(--line-strong); background: #15243a; color: var(--cyan); }
.catalog-summary { display: flex; justify-content: space-between; padding: 10px 16px 12px; border-bottom: 1px solid var(--line); }
.catalog-summary strong { font-size: 13px; }
.catalog-summary span { color: var(--muted); font-size: 12px; }
.document-list { flex: 1; min-height: 420px; max-height: calc(100vh - 230px); overflow: auto; padding: 8px; }
.document-list::-webkit-scrollbar { width: 8px; }
.document-list::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 8px; background: #33465c; background-clip: padding-box; }
.document-item {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px 10px;
  border: 1px solid transparent;
  border-bottom-color: rgba(148, 174, 202, .12);
  border-radius: 7px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.document-item:hover { background: var(--surface); }
.document-item.active { border-color: var(--cyan); background: var(--surface-raised); box-shadow: inset 3px 0 var(--lime); }
.document-item .file-icon { color: #ff5a64; font-size: 27px; text-align: center; }
.document-item .file-copy { min-width: 0; }
.document-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.document-item small { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.document-item .file-meta { display: grid; gap: 6px; color: #a8b7c8; font-size: 11px; text-align: right; }
.loading-state, .empty-state { min-height: 300px; display: grid; place-content: center; gap: 12px; color: var(--muted); text-align: center; }

.document-stage {
  min-height: calc(100% - 32px);
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111921;
}
.document-cover {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: .72;
  overflow: hidden;
  padding: 28px;
  background: #f7f9fb;
  color: #0c1828;
  box-shadow: 0 18px 58px rgba(0, 0, 0, .38);
}
.cover-brand { display: flex; align-items: center; gap: 10px; }
.cover-brand img { width: 34px; height: 34px; border-radius: 8px; }
.cover-brand span { display: grid; font-size: 10px; font-weight: 800; }
.cover-brand small { margin-top: 2px; color: #6d7b8b; font-size: 8px; font-weight: 500; }
.cover-copy { position: relative; z-index: 2; width: 92%; margin: 18% auto 0; text-align: center; }
.cover-copy > span { color: #3d6a9d; font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.cover-copy h2 { margin: 12px 0 10px; font-size: clamp(21px, 2.2vw, 32px); line-height: 1.28; }
.cover-copy p { margin: 0 auto; max-width: 310px; color: #5f6e7e; font-size: 11px; line-height: 1.65; }
.machine-illustration { position: absolute; z-index: 1; right: -5%; bottom: 7%; width: 110%; height: auto; object-fit: contain; opacity: .82; }
.cover-foot { position: absolute; right: 26px; bottom: 20px; left: 26px; z-index: 2; padding-top: 9px; border-top: 1px solid #ccd7e1; color: #8390a0; font: 8px ui-monospace, monospace; letter-spacing: .1em; text-align: center; }

.detail-title-row { display: flex; align-items: flex-start; gap: 12px; margin: 28px 0 24px; }
.pdf-mark { flex: 0 0 auto; color: #ff5964; font-size: 31px; }
.detail-title-row h2 { margin: 2px 0 0; font-size: 17px; line-height: 1.5; }
.detail-facts { margin: 0; }
.detail-facts div { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(148, 174, 202, .1); }
.detail-facts dt { color: var(--muted); }
.detail-facts dd { margin: 0; color: #d9e3ed; }
.detail-description { margin-top: 24px; }
.detail-description h3, .detail-topics h3 { margin: 0 0 9px; font-size: 13px; }
.detail-description p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.detail-topics { margin-top: 20px; }
.detail-topics ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.detail-topics li { position: relative; padding-left: 15px; color: var(--muted); font-size: 12px; }
.detail-topics li::before { content: ""; position: absolute; top: .55em; left: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--lime); }
.download-gate { margin-top: 30px; padding: 15px; border: 1px solid rgba(229, 189, 88, .35); border-radius: 8px; background: rgba(112, 81, 13, .18); }
.download-gate strong, .download-gate span { display: block; }
.download-gate strong { color: var(--gold); font-size: 14px; }
.download-gate span { margin-top: 6px; color: #a99f86; font-size: 11px; line-height: 1.6; }
.download-button, .primary-action {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  background: #477fce;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset -90px 0 90px rgba(184, 239, 85, .22);
}
.download-button:disabled { cursor: not-allowed; opacity: .42; }
.download-button:not(:disabled):hover, .primary-action:hover { background: #5595e9; }
.device-note { margin: 11px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 7, 13, .78);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  width: min(410px, 100%);
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #0b1726;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .52);
}
.modal-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.modal-close:hover { background: var(--surface-soft); color: var(--text); }
.modal-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 9px; background: var(--surface-soft); color: var(--cyan); font-size: 20px; }
.vip-card .modal-icon { color: var(--gold); }
.modal-card h2 { margin: 0; font-size: 24px; }
.modal-card > p { margin: 8px 0 20px; color: var(--muted); }
.modal-card form { display: grid; gap: 14px; }
.modal-card label { display: grid; gap: 7px; color: #cbd7e4; font-size: 12px; }
.modal-card input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #081321; color: var(--text); }
.modal-card input:focus { border-color: var(--cyan); }
.modal-card .primary-action { margin-top: 2px; }
.member-link { display: block; margin-top: 16px; color: var(--cyan); font-size: 12px; text-align: center; }
.form-status { min-height: 18px; color: var(--muted); font-size: 12px; }
.form-status.error { color: #ff8d94; }
.form-status.success { color: var(--lime); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 120; max-width: min(380px, calc(100vw - 32px)); padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 8px; background: #122136; box-shadow: 0 18px 54px rgba(0,0,0,.38); }

@media (max-width: 1180px) {
  .library-nav { grid-template-columns: auto 1fr auto; padding: 0 20px; }
  .library-nav nav a { padding: 0 10px; }
  .library-workspace { grid-template-columns: 330px minmax(360px, 1fr); }
  .detail-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr 1fr; gap: 0 30px; border-top: 1px solid var(--line); }
  .detail-panel .panel-label { grid-column: 1 / -1; }
  .detail-title-row, .detail-facts, .detail-description, .detail-topics { grid-column: 1; }
  .download-gate, .download-button, .device-note { grid-column: 2; }
  .download-gate { grid-row: 2 / span 2; align-self: end; }
}

@media (max-width: 820px) {
  :root { --nav-height: 60px; }
  .library-nav { grid-template-columns: 1fr auto; padding: 0 14px; }
  .brand img { width: 36px; height: 36px; }
  .brand small { display: none; }
  .library-nav nav { position: absolute; top: var(--nav-height); left: 0; width: 100%; height: 42px; overflow-x: auto; border-bottom: 1px solid var(--line); background: #081321; scrollbar-width: none; }
  .library-nav nav::-webkit-scrollbar { display: none; }
  .library-nav nav a { flex: 0 0 auto; padding: 0 14px; font-size: 12px; }
  .library-nav nav a.active::after { right: 14px; left: 14px; }
  .account-button { min-width: 72px; height: 36px; }
  main { padding: 62px 12px 20px; }
  .library-heading { align-items: stretch; flex-direction: column; }
  .heading-copy h1 { font-size: 28px; }
  .library-search { width: calc(100% - 28px); }
  .library-search kbd { display: none; }
  .library-workspace { display: block; min-height: 0; }
  .catalog-panel, .preview-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .document-list { max-height: 430px; min-height: 260px; }
  .preview-panel { padding: 14px; }
  .document-stage { min-height: 500px; padding: 20px; }
  .document-cover { width: min(100%, 390px); }
  .detail-panel { display: block; padding: 20px 18px; }
  .detail-title-row { margin-top: 18px; }
  .download-gate { margin-top: 24px; }
}

@media (max-width: 480px) {
  .brand strong { max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .account-button { min-width: 40px; padding: 0 10px; }
  .account-button span { display: none; }
  .account-menu { right: -2px; }
  .heading-icon { width: 34px; height: 34px; font-size: 20px; }
  .heading-copy p { font-size: 12px; }
  .document-stage { min-height: 420px; padding: 12px; }
  .document-cover { padding: 20px; }
  .cover-copy { margin-top: 15%; }
  .cover-copy h2 { font-size: 21px; }
  .machine-illustration { bottom: 8%; }
  .modal-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
