:root {
  --bg: #08141b;
  --bg-soft: #0f232d;
  --panel: #122730;
  --panel-strong: #17343f;
  --text: #eef7fb;
  --muted: rgba(223, 241, 248, 0.7);
  --border: rgba(145, 197, 216, 0.25);
  --accent: #21c6a0;
  --accent-strong: #14a37f;
  --highlight: #ffc857;
  --link: #70e4cd;
  --link-hover: #9af5df;
  --code-bg: rgba(6, 18, 23, 0.58);
  --radius: 16px;
  --shadow-soft: 0 20px 45px rgba(2, 12, 18, 0.35);
  --shadow-strong: 0 26px 60px rgba(2, 12, 18, 0.5);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

html[data-theme="light"] {
  --bg: #f3faf9;
  --bg-soft: #e6f4f1;
  --panel: #ffffff;
  --panel-strong: #f4f9f8;
  --text: #10222b;
  --muted: rgba(16, 34, 43, 0.7);
  --border: rgba(16, 34, 43, 0.14);
  --accent: #168f73;
  --accent-strong: #0f755f;
  --highlight: #b36500;
  --link: #0d7c64;
  --link-hover: #0f9679;
  --code-bg: rgba(15, 36, 44, 0.07);
  --shadow-soft: 0 16px 35px rgba(16, 34, 43, 0.12);
  --shadow-strong: 0 20px 40px rgba(16, 34, 43, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(8, 20, 27, 0.9), rgba(8, 20, 27, 0.9)),
    url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=2400&q=80'),
    linear-gradient(145deg, var(--bg), var(--bg-soft));
  background-size: cover, cover, auto;
  background-position: center, center, 0 0;
  background-repeat: no-repeat, no-repeat, repeat;
  background-attachment: fixed, fixed, scroll;
}

html[data-theme="light"] body {
  background-image:
    linear-gradient(rgba(243, 250, 249, 0.92), rgba(243, 250, 249, 0.92)),
    url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=2400&q=80'),
    linear-gradient(145deg, var(--bg), var(--bg-soft));
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  background: rgba(11, 29, 37, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

html[data-theme="light"] .topbar {
  background: rgba(248, 253, 252, 0.84);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.title__main {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title__sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn,
.iconbtn {
  border: 1px solid var(--border);
  background: rgba(17, 45, 56, 0.65);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

html[data-theme="light"] .btn,
html[data-theme="light"] .iconbtn {
  background: rgba(255, 255, 255, 0.88);
}

.btn {
  padding: 9px 12px;
}

.iconbtn {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
}

.btn:hover,
.iconbtn:hover {
  border-color: rgba(33, 198, 160, 0.8);
  background: rgba(21, 72, 83, 0.75);
  text-decoration: none;
}

html[data-theme="light"] .btn:hover,
html[data-theme="light"] .iconbtn:hover {
  background: rgba(240, 251, 247, 1);
}

.btn:active,
.iconbtn:active {
  transform: translateY(1px);
}

.layout {
  max-width: 1520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 22px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 70px;
  height: calc(100vh - 92px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  background: linear-gradient(180deg, rgba(22, 55, 67, 0.9), rgba(13, 34, 43, 0.94));
  box-shadow: var(--shadow-soft);
}

html[data-theme="light"] .toc {
  background: linear-gradient(180deg, #ffffff, #f5f9f8);
}

.toc__header {
  padding: 13px;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 10px;
}

.toc__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc__search {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(8, 21, 27, 0.45);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 10px;
  outline: none;
}

html[data-theme="light"] .toc__search {
  background: #ffffff;
}

.toc__search:focus {
  border-color: rgba(33, 198, 160, 0.8);
  box-shadow: 0 0 0 3px rgba(33, 198, 160, 0.18);
}

.toc__nav {
  overflow: auto;
  padding: 10px 12px 14px;
  font-size: 13px;
}

.toc__item {
  display: block;
  padding: 7px 9px;
  border-radius: 10px;
  color: var(--muted);
  line-height: 1.36;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.toc__item:hover {
  color: var(--text);
  background: rgba(33, 198, 160, 0.14);
  text-decoration: none;
}

.toc__item[aria-current="true"] {
  color: var(--text);
  background: rgba(33, 198, 160, 0.2);
  border: 1px solid rgba(33, 198, 160, 0.45);
}

.toc__item--lvl2 {
  padding-left: 18px;
}

.toc__item--lvl3 {
  padding-left: 28px;
}

.content {
  min-width: 0;
}

.content__inner {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(170deg, rgba(20, 47, 58, 0.95), rgba(12, 30, 38, 0.98));
  box-shadow: var(--shadow-strong);
  padding: 20px 22px 34px;
  overflow: hidden;
}

html[data-theme="light"] .content__inner {
  background: linear-gradient(170deg, #ffffff, #f7fbfa);
}

.hero {
  position: relative;
  margin-bottom: 18px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(145, 197, 216, 0.35);
  background: #07131a;
  animation: rise-in 500ms ease both;
}

.hero__image {
  width: 100%;
  aspect-ratio: 16 / 3;
  display: block;
  object-fit: cover;
  min-height: 168px;
  filter: saturate(1.05);
}

.hero__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 20px 24px;
  background:
    linear-gradient(105deg, rgba(6, 16, 21, 0.82) 0%, rgba(6, 16, 21, 0.3) 64%, rgba(6, 16, 21, 0.15) 100%);
}

.hero__kicker {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(238, 247, 251, 0.76);
  font-weight: 700;
}

.hero__title {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.hero__subtitle {
  color: rgba(238, 247, 251, 0.9);
  font-size: 15px;
}

.hero__desc {
  margin: 2px 0 0;
  font-size: 13px;
  max-width: min(620px, 92%);
  color: rgba(238, 247, 251, 0.78);
}

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

.hero__action {
  border: 1px solid transparent;
  background: var(--accent);
  color: #03221b;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.hero__action:hover {
  text-decoration: none;
  color: #03221b;
  background: #3ad5b3;
  transform: translateY(-1px);
}

.hero__action--ghost {
  background: transparent;
  color: rgba(238, 247, 251, 0.95);
  border-color: rgba(238, 247, 251, 0.45);
}

.hero__action--ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.insight-strip {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  animation: rise-in 620ms ease both;
}

.insight-strip__item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(16, 45, 56, 0.62);
  padding: 11px 12px;
}

html[data-theme="light"] .insight-strip__item {
  background: #ffffff;
}

.insight-strip__value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--highlight);
}

.insight-strip__label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.state {
  padding: 30px 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: rgba(17, 44, 54, 0.36);
}

html[data-theme="light"] .state {
  background: rgba(15, 62, 72, 0.04);
}

.state__title {
  font-weight: 700;
}

.state__hint {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

.markdown {
  line-height: 1.82;
  font-size: 16px;
  word-break: break-word;
  animation: rise-in 260ms ease both;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  scroll-margin-top: 84px;
}

.markdown h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  margin: 24px 0 14px;
  line-height: 1.2;
}

.markdown h2 {
  font-size: clamp(22px, 2.2vw, 30px);
  margin: 22px 0 12px;
}

.markdown h3 {
  font-size: 20px;
  margin: 18px 0 9px;
}

.markdown h4 {
  font-size: 17px;
  margin: 16px 0 7px;
}

.markdown p {
  margin: 10px 0;
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.markdown blockquote {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(33, 198, 160, 0.1);
  border-radius: 10px;
  color: color-mix(in oklab, var(--text) 93%, var(--muted));
}

.markdown code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 8px;
}

.markdown pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 14px;
  overflow: auto;
}

.markdown pre code {
  background: transparent;
  padding: 0;
}

.raw {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  display: block;
  overflow-x: auto;
}

.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 10px 10px;
  vertical-align: top;
  white-space: nowrap;
}

.markdown th {
  background: rgba(33, 198, 160, 0.14);
}

.markdown img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.footer {
  max-width: 1520px;
  margin: 0 auto;
  padding: 8px 20px 20px;
  color: var(--muted);
  font-size: 12px;
}

.auth {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 17, 23, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.auth[hidden] {
  display: none !important;
}

.auth__card {
  width: min(430px, 90vw);
  padding: 22px 24px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(175deg, rgba(21, 55, 67, 0.95), rgba(14, 34, 43, 0.98));
  box-shadow: var(--shadow-strong);
  text-align: center;
}

html[data-theme="light"] .auth__card {
  background: linear-gradient(175deg, #ffffff, #f5f9f8);
}

.auth__brand {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.auth__subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth__input {
  width: 100%;
  margin-top: 16px;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(6, 18, 23, 0.35);
  color: var(--text);
  outline: none;
}

html[data-theme="light"] .auth__input {
  background: #ffffff;
}

.auth__input:focus {
  border-color: rgba(33, 198, 160, 0.9);
  box-shadow: 0 0 0 3px rgba(33, 198, 160, 0.18);
}

.auth__btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(33, 198, 160, 0.5);
  background: rgba(33, 198, 160, 0.2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.auth__btn:hover {
  background: rgba(33, 198, 160, 0.3);
}

.auth__hint {
  min-height: 18px;
  margin-top: 8px;
  color: #ffb4b4;
  font-size: 12px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px 14px 18px;
  }

  .toc {
    position: fixed;
    inset: 64px 14px 14px;
    height: auto;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .toc[data-open="true"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .topbar {
    padding: 10px 14px;
  }

  .topbar__right .btn {
    display: none;
  }

  .topbar__right .btn#themeToggle {
    display: inline-flex;
  }

  .content__inner {
    padding: 16px 14px 24px;
  }

  .hero__overlay {
    padding: 16px;
  }

  .insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero__image {
    aspect-ratio: 16 / 5;
    min-height: 176px;
  }

  .hero__desc {
    max-width: 100%;
  }

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

  .markdown {
    font-size: 15px;
    line-height: 1.74;
  }
}

@media print {
  .topbar,
  .toc,
  .footer,
  .hero,
  .insight-strip {
    display: none !important;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .content__inner {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: #fff;
  }

  body {
    background: #fff;
    color: #000;
  }
}
