:root {
  --bg: #ffffff;
  --surface: #f6f6f7;
  --surface-strong: #eeeff1;
  --text: #34343a;
  --text-strong: #242429;
  --muted: #6e6e76;
  --faint: #9898a1;
  --line: #e6e6e9;
  --brand: #4f75d8;
  --brand-dark: #3f61bd;
  --brand-soft: #e8edfc;
  --brand-foreground: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.88);
  --shadow: 0 18px 50px rgba(35, 39, 47, 0.1);
  --shell: 1150px;
}

:root[data-theme="dark"] {
  --bg: #1b1b1f;
  --surface: #252529;
  --surface-strong: #303036;
  --text: #d6d6dc;
  --text-strong: #f1f1f3;
  --muted: #a2a2aa;
  --faint: #7d7d86;
  --line: #35353b;
  --brand: #86a5ff;
  --brand-dark: #a2b8ff;
  --brand-soft: #28334d;
  --header-bg: rgba(27, 27, 31, 0.9);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 38%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--text-strong);
  color: var(--bg);
  transform: translateY(-140%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(calc(100% - 48px), var(--shell));
  margin: 0 auto;
}

.site-header {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  width: 100%;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.site-header.is-scrolled {
  border-color: var(--line);
  background: var(--header-bg);
  box-shadow: 0 8px 28px rgba(31, 35, 43, 0.05);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  width: min(calc(100% - 48px), 1200px);
  height: 64px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.brand,
.footer-brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 700;
}

.brand img,
.footer-brand img {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
}

.brand span,
.footer-brand span {
  white-space: nowrap;
}

.brand small {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
}

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

.home-link {
  display: inline-flex;
  min-height: 38px;
  padding: 0 13px;
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  gap: 5px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.home-link:hover {
  background: var(--surface);
  color: var(--text-strong);
}

.home-link svg {
  width: 17px;
  height: 17px;
}

.theme-toggle {
  position: relative;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle::before {
  position: absolute;
  z-index: 0;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 4px rgba(30, 34, 41, 0.18);
  content: "";
  transition: transform 0.25s ease;
}

.theme-toggle svg {
  position: absolute;
  z-index: 1;
  top: 6px;
  width: 11px;
  height: 11px;
  transition: opacity 0.2s ease;
}

.theme-toggle .sun-icon {
  left: 5px;
  opacity: 1;
}

.theme-toggle .moon-icon {
  right: 5px;
  opacity: 0.38;
}

[data-theme="dark"] .theme-toggle::before {
  transform: translateX(18px);
}

[data-theme="dark"] .theme-toggle .sun-icon {
  opacity: 0.35;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  opacity: 1;
}

main.page-shell {
  min-height: calc(100vh - 96px);
  padding-top: 120px;
  padding-bottom: 88px;
}

.page-heading {
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

.heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.heading-row h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 48px;
  font-weight: 760;
  line-height: 1.15;
  letter-spacing: 0;
}

.heading-row p {
  max-width: 580px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.tutorial-total,
.sidebar-heading span {
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
}

.loading-state {
  display: flex;
  min-height: 280px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 16px;
}

.loading-state strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-strong);
  font-size: 16px;
}

.loading-state p {
  margin: 0;
  font-size: 14px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--surface-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.state-panel {
  display: flex;
  min-height: 330px;
  padding: 50px 24px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.state-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 17px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}

.state-icon svg {
  width: 26px;
  height: 26px;
}

.state-panel h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 21px;
}

.state-panel p {
  max-width: 430px;
  margin: 9px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-foreground);
  cursor: pointer;
  font-weight: 650;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.primary-button:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.tutorial-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 46px;
}

.tutorial-sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.sidebar-heading {
  display: flex;
  min-height: 53px;
  padding: 0 17px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 14px;
}

.tutorial-list {
  max-height: calc(100vh - 166px);
  margin: 0;
  padding: 7px;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--surface-strong) transparent;
  scrollbar-width: thin;
}

.tutorial-list li + li {
  margin-top: 3px;
}

.tutorial-item {
  display: grid;
  width: 100%;
  min-height: 86px;
  padding: 10px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  text-align: left;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.tutorial-item:hover {
  background: var(--surface-strong);
}

.tutorial-item.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.item-image,
.item-placeholder {
  width: 76px;
  height: 62px;
  border-radius: 5px;
}

.item-image {
  object-fit: cover;
  background: var(--surface-strong);
}

.item-placeholder {
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  color: var(--faint);
}

.tutorial-item.is-active .item-placeholder {
  background: color-mix(in srgb, var(--brand) 12%, var(--bg));
  color: var(--brand);
}

.item-placeholder svg {
  width: 24px;
  height: 24px;
}

.item-copy {
  min-width: 0;
}

.item-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tutorial-item.is-active .item-title {
  color: var(--brand);
}

.item-date {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tutorial-detail {
  min-width: 0;
  padding: 2px 0 36px;
}

.back-to-list {
  display: none;
  min-height: 38px;
  margin: -4px 0 23px;
  padding: 0 11px 0 7px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  gap: 3px;
}

.back-to-list svg {
  width: 18px;
  height: 18px;
}

.detail-heading {
  max-width: 760px;
}

.detail-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-strong);
  font-size: 40px;
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: 0;
}

.tutorial-body {
  display: grid;
  max-width: 780px;
  margin-top: 32px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.95;
  gap: 28px;
}

.tutorial-content-text {
  white-space: pre-wrap;
}

.tutorial-content-image {
  width: 100%;
  margin: 0;
}

.tutorial-content-image img {
  display: block;
  width: 100%;
  max-height: 680px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  object-fit: contain;
}

.tutorial-content-image figcaption {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.footer-inner {
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.footer-brand {
  font-size: 14px;
}

.footer-brand img {
  width: 26px;
  height: 26px;
}

.footer-inner p {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}

@media (max-width: 860px) {
  .heading-row h1 {
    font-size: 42px;
  }

  .tutorial-layout {
    grid-template-columns: 1fr;
    gap: 42px;
  }

  .tutorial-sidebar {
    position: static;
    max-height: none;
  }

  .tutorial-list {
    max-height: none;
  }

  .tutorial-item {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .item-image,
  .item-placeholder {
    width: 96px;
    height: 68px;
  }

  .back-to-list {
    display: inline-flex;
  }

  .detail-heading h2 {
    font-size: 36px;
  }
}

@media (max-width: 620px) {
  .page-shell,
  .header-inner {
    width: min(calc(100% - 36px), var(--shell));
  }

  .brand small,
  .home-link span {
    display: none;
  }

  .home-link {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .header-actions {
    gap: 6px;
  }

  main.page-shell {
    padding-top: 98px;
    padding-bottom: 62px;
  }

  .page-heading {
    margin-bottom: 26px;
  }

  .heading-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .heading-row h1 {
    font-size: 34px;
  }

  .heading-row p {
    font-size: 15px;
  }

  .tutorial-total {
    align-self: flex-start;
  }

  .tutorial-layout {
    gap: 36px;
  }

  .tutorial-item {
    min-height: 82px;
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .item-image,
  .item-placeholder {
    width: 82px;
    height: 62px;
  }

  .detail-heading h2 {
    font-size: 29px;
  }

  .tutorial-body {
    margin-top: 25px;
    font-size: 15px;
    line-height: 1.9;
    gap: 22px;
  }

  .footer-inner {
    min-height: 88px;
  }
}

@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;
  }
}
