:root {
  --bg: #f7f1e8;
  --bg-alt: #f2e9dc;
  --card: #fffaf3;
  --card-glass: rgba(255, 250, 243, 0.72);
  --text: #3a2b26;
  --text-soft: #6b5a52;
  --text-muted: #8a7a70;
  --primary: #8b2e2e;
  --primary-soft: #b4514f;
  --primary-deep: #5e1c1c;
  --accent: #c9a227;
  --accent-soft: #e3c66b;
  --line: rgba(139, 46, 46, 0.16);
  --line-strong: rgba(139, 46, 46, 0.3);
  --shadow-sm: 0 2px 8px rgba(58, 43, 38, 0.06);
  --shadow-md: 0 10px 30px rgba(58, 43, 38, 0.1);
  --shadow-lg: 0 20px 50px rgba(58, 43, 38, 0.16);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --header-h: 76px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #1a1512;
  --bg-alt: #221b17;
  --card: #2a211c;
  --card-glass: rgba(42, 33, 28, 0.68);
  --text: #f0e6dc;
  --text-soft: #c9b8ab;
  --text-muted: #a08f83;
  --primary: #d98a86;
  --primary-soft: #e8a9a4;
  --primary-deep: #f2c4c0;
  --accent: #e3c66b;
  --accent-soft: #f0d98f;
  --line: rgba(217, 138, 134, 0.18);
  --line-strong: rgba(217, 138, 134, 0.34);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(201, 162, 39, 0.08), transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(139, 46, 46, 0.09), transparent 46%),
    radial-gradient(circle at 50% 100%, rgba(139, 46, 46, 0.06), transparent 55%);
  background-attachment: fixed;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.25s var(--ease), opacity 0.25s var(--ease);
}

a:hover,
a:focus-visible {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: 1.35;
  color: var(--text);
  margin: 0 0 0.6em;
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(1.6rem, 3.4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.9rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
h4 { font-size: clamp(1.02rem, 1.6vw, 1.18rem); }

p {
  margin: 0 0 1.1em;
  color: var(--text-soft);
}

ul, ol {
  padding-left: 1.4em;
  color: var(--text-soft);
}

li {
  margin-bottom: 0.4em;
}

strong { color: var(--text); }

blockquote {
  margin: 1.2em 0;
  padding: 1em 1.4em;
  border-left: 3px solid var(--accent);
  background: var(--card-glass);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-soft);
  font-style: italic;
}

blockquote p:last-child { margin-bottom: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Header ===== */
#site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--card-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: background 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand a {
  font-family: var(--font-serif);
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.06em;
  line-height: 1.2;
  white-space: nowrap;
}

.brand a:hover { color: var(--accent); }

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#main-nav {
  flex: 1 1 auto;
  min-width: 0;
}

#main-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

#main-nav a {
  display: inline-block;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text-soft);
  position: relative;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

#main-nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: translateX(-50%);
  transition: width 0.3s var(--ease);
}

#main-nav a:hover,
#main-nav a:focus-visible {
  color: var(--primary);
  background: rgba(139, 46, 46, 0.06);
}

#main-nav a:hover::after { width: 60%; }

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-tools form {
  display: flex;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 3px 3px 14px;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.header-tools form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 46, 46, 0.12);
}

.header-tools input[type="search"] {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-family: inherit;
  width: 150px;
  padding: 5px 0;
  outline: none;
}

.header-tools input[type="search"]::placeholder {
  color: var(--text-muted);
}

.header-tools button {
  font-family: inherit;
  font-size: 0.84rem;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), opacity 0.25s var(--ease);
  white-space: nowrap;
}

.header-tools button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(139, 46, 46, 0.28);
}

.header-tools button:active { transform: translateY(0); }

#theme-toggle,
#menu-toggle {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line-strong);
  font-weight: 500;
}

#theme-toggle:hover,
#menu-toggle:hover {
  background: rgba(139, 46, 46, 0.08);
  box-shadow: none;
  color: var(--primary);
}

#menu-toggle { display: none; }

/* ===== Main layout ===== */
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 34px;
}

main > section,
main > nav {
  animation: fadeUp 0.7s var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@supports (animation-timeline: view()) {
  main > section {
    animation: none;
    animation-timeline: view();
    animation-range: entry 0% entry 24%;
  }
}

/* ===== Breadcrumb ===== */
#breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

#breadcrumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: var(--accent);
  font-weight: 700;
}

#breadcrumb a { color: var(--text-soft); }
#breadcrumb a:hover { color: var(--primary); }

#breadcrumb [aria-current="page"] {
  color: var(--primary);
  font-weight: 600;
}

/* ===== Hero ===== */
#hero {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(139, 46, 46, 0.94) 0%, rgba(94, 28, 28, 0.92) 46%, rgba(58, 43, 38, 0.94) 100%);
  box-shadow: var(--shadow-lg);
  color: #fdf6ec;
}

#hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(227, 198, 107, 0.35), transparent 42%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.16), transparent 40%),
    radial-gradient(circle at 62% 92%, rgba(201, 162, 39, 0.22), transparent 46%);
  pointer-events: none;
}

#hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 22px);
  pointer-events: none;
  opacity: 0.6;
}

.hero-slider {
  position: relative;
  z-index: 1;
  padding: clamp(28px, 4.5vw, 56px);
  min-height: 320px;
}

.slide {
  display: none;
  animation: slideIn 0.6s var(--ease) both;
}

.slide.active { display: block; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}

#hero h1,
#hero h2 {
  color: #fff8ee;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.28);
  margin-bottom: 0.5em;
}

#hero p {
  color: rgba(255, 248, 238, 0.88);
  max-width: 82ch;
  font-size: clamp(0.94rem, 1.3vw, 1.02rem);
}

.hero-note {
  display: inline-block;
  font-size: 0.8rem !important;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 248, 238, 0.92) !important;
}

.cta {
  display: inline-block;
  margin-top: 8px;
  padding: 12px 30px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--primary-deep);
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
  box-shadow: 0 8px 22px rgba(201, 162, 39, 0.35);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), filter 0.3s var(--ease);
}

.cta:hover,
.cta:focus-visible {
  color: var(--primary-deep);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 32px rgba(201, 162, 39, 0.5);
  filter: brightness(1.05);
}

.slider-controls {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}

.slider-controls button {
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 7px 18px;
  border-radius: 999px;
  color: #fff8ee;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}

.slider-controls button:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.16);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.stat {
  padding: 18px 12px;
  text-align: center;
  background: rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.3s var(--ease);
}

.stat:hover { background: rgba(0, 0, 0, 0.22); }

.stat .num {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 700;
  color: var(--accent-soft);
  line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.stat .label {
  display: block;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: rgba(255, 248, 238, 0.82);
  margin-top: 2px;
}

/* ===== TOC ===== */
#toc {
  background: var(--card-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

#toc h2 {
  font-size: 1.1rem;
  margin-bottom: 0.8em;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

#toc h2::before {
  content: "";
  width: 4px;
  height: 1.1em;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

#toc ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

#toc a {
  display: block;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-soft);
  background: rgba(139, 46, 46, 0.04);
  border: 1px solid transparent;
  transition: all 0.25s var(--ease);
}

#toc a:hover,
#toc a:focus-visible {
  color: var(--primary);
  background: rgba(139, 46, 46, 0.09);
  border-color: var(--line-strong);
  transform: translateX(4px);
}

/* ===== Generic sections ===== */
main > section:not(#hero):not(#toc) {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 3.4vw, 44px);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.35s var(--ease), transform 0.35s var(--ease), border-color 0.35s var(--ease);
}

main > section:not(#hero):not(#toc):hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

main > section > h2 {
  position: relative;
  padding-bottom: 0.55em;
  margin-bottom: 1.1em;
  color: var(--primary);
}

main > section > h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 68px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent), transparent);
}

main > section h3 {
  margin-top: 1.6em;
  color: var(--text);
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  line-height: 1.4;
}

main > section h4 {
  margin-top: 1.3em;
  color: var(--primary);
}

main > section > h2 + p,
main > section > h3 + p {
  margin-top: 0.4em;
}

/* ===== About / contact cards ===== */
#about,
#contact {
  position: relative;
  overflow: hidden;
}

#about::before,
#contact::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.14), transparent 70%);
  pointer-events: none;
}

.contact-info,
.author-info,
.security-info {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.contact-info:hover,
.author-info:hover,
.security-info:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.contact-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.contact-info li {
  position: relative;
  padding-left: 22px;
  font-size: 0.94rem;
  color: var(--text-soft);
}

.contact-info li::before {
  content: "◆";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.7em;
  top: 0.5em;
}

/* ===== Cases / blockquote ===== */
#cases blockquote p {
  font-size: 0.95rem;
}

/* ===== HowTo ===== */
#howto ol {
  counter-reset: step;
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
}

#howto ol li {
  counter-increment: step;
  position: relative;
  padding: 14px 18px 14px 56px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}

#howto ol li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  box-shadow: 0 3px 10px rgba(139, 46, 46, 0.3);
}

#howto ol li:hover {
  transform: translateX(6px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

/* ===== Articles ===== */
#articles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

#articles > h2 {
  grid-column: 1 / -1;
}

#articles article {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px 24px 20px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease), background 0.35s var(--ease);
  overflow: hidden;
}

#articles article::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
}

#articles article:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
  background: var(--card);
}

#articles article:hover::before { transform: scaleX(1); }

#articles article h3 {
  margin-top: 0;
  border-left: none;
  padding-left: 0;
  font-size: 1.08rem;
  color: var(--text);
}

#articles article:hover h3 { color: var(--primary); }

#articles .meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 0.9em;
  padding-bottom: 0.7em;
  border-bottom: 1px dashed var(--line);
}

#articles article p {
  font-size: 0.9rem;
  flex: 1;
}

#articles article a {
  align-self: flex-start;
  margin-top: auto;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--primary);
  transition: all 0.28s var(--ease);
}

#articles article a:hover,
#articles article a:focus-visible {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  border-color: transparent;
  transform: translateX(4px);
}

/* ===== News ===== */
#news ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}

#news ul li {
  position: relative;
  padding: 12px 18px 12px 42px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  transition: all 0.28s var(--ease);
}

#news ul li::before {
  content: "●";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 0.6rem;
}

#news ul li:hover {
  background: rgba(139, 46, 46, 0.06);
  border-color: var(--line-strong);
  transform: translateX(4px);
}

/* ===== FAQ ===== */
#faq details {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}

#faq details:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

#faq details[open] {
  background: var(--card);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

#faq summary {
  cursor: pointer;
  padding: 16px 52px 16px 22px;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  position: relative;
  list-style: none;
  transition: color 0.25s var(--ease);
}

#faq summary::-webkit-details-marker { display: none; }

#faq summary::after {
  content: "+";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--primary);
  background: rgba(139, 46, 46, 0.08);
  transition: transform 0.35s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}

#faq details[open] summary::after {
  content: "−";
  transform: translateY(-50%) rotate(180deg);
  background: var(--primary);
  color: #fff;
}

#faq summary:hover { color: var(--primary); }

#faq details > p {
  padding: 0 22px 18px;
  margin: 0;
  font-size: 0.93rem;
  animation: faqOpen 0.4s var(--ease) both;
}

@keyframes faqOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Notice / sitemap / links ===== */
#notice {
  border-left: 4px solid var(--accent) !important;
}

#sitemap ul,
#links ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 14px;
}

#sitemap a,
#links a {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-soft);
  background: rgba(139, 46, 46, 0.04);
  border: 1px solid transparent;
  transition: all 0.25s var(--ease);
}

#sitemap a:hover,
#links a:hover,
#sitemap a:focus-visible,
#links a:focus-visible {
  color: var(--primary);
  background: rgba(139, 46, 46, 0.09);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

/* ===== Footer ===== */
#site-footer {
  position: relative;
  margin-top: 20px;
  padding: 48px 24px 28px;
  background:
    linear-gradient(160deg, var(--primary-deep) 0%, #3a2b26 60%, #241a17 100%);
  color: rgba(255, 248, 238, 0.82);
  border-top: 3px solid var(--accent);
}

#site-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(227, 198, 107, 0.14), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(255, 255, 255, 0.06), transparent 50%);
  pointer-events: none;
}

.footer-inner {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}

.footer-col h3 {
  font-size: 1rem;
  color: var(--accent-soft);
  margin-bottom: 0.7em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid rgba(227, 198, 107, 0.24);
}

.footer-col p {
  font-size: 0.84rem;
  line-height: 1.8;
  color: rgba(255, 248, 238, 0.68);
  margin: 0;
}

.footer-meta {
  position: relative;
  max-width: 1240px;
  margin: 32px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 248, 238, 0.14);
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 248, 238, 0.55);
  letter-spacing: 0.03em;
}

#back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--primary);
  background: var(--card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease), visibility 0.35s, background 0.3s var(--ease), color 0.3s var(--ease);
}

#back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  border-color: transparent;
  transform: translateY(-3px);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .header-inner { gap: 14px; }
  .header-tools input[type="search"] { width: 120px; }
  #main-nav a { padding: 5px 9px; font-size: 0.86rem; }
}

@media (max-width: 860px) {
  :root { --header-h: 68px; }

  .header-inner {
    flex-wrap: wrap;
    padding: 10px 16px;
    min-height: 0;
  }

  .brand { flex: 1 1 auto; }
  .brand a { font-size: 1.1rem; }
  .brand-sub { font-size: 0.66rem; }

  #menu-toggle { display: inline-block; }

  #main-nav {
    order: 4;
    flex-basis: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s var(--ease);
  }

  #main-nav.is-open { max-height: 520px; }

  #main-nav ul {
    flex-direction: column;
    gap: 2px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--line);
  }

  #main-nav a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
  }

  #main-nav a::after { display: none; }

  .header-tools {
    order: 3;
    width: 100%;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    margin-top: 4px;
  }

  .header-tools form { flex: 1 1 auto; }
  .header-tools input[type="search"] { width: 100%; }

  main { padding: 20px 16px 32px; gap: 24px; }

  #hero { border-radius: var(--radius-lg); }
  .hero-slider { padding: 26px 22px; min-height: 0; }

  .hero-stats { grid-template-columns: repeat(2, 1fr); }

  #toc { padding: 20px; }
  #toc ul { grid-template-columns: repeat(2, 1fr); gap: 6px 10px; }
  #toc a { padding: 7px 10px; font-size: 0.82rem; }

  main > section:not(#hero):not(#toc) {
    padding: 24px 20px;
    border-radius: var(--radius-md);
  }

  #articles { grid-template-columns: 1fr; gap: 16px; }

  #sitemap ul,
  #links ul { grid-template-columns: 1fr 1fr; }

  #site-footer { padding: 36px 18px 24px; }
  .footer-inner { gap: 22px; }

  #back-to-top { right: 14px; bottom: 14px; padding: 9px 15px; font-size: 0.76rem; }
}

@media (max-width: 520px) {
  body { font-size: 15px; line-height: 1.8; }

  .brand a { font-size: 1rem; }
  .brand-sub { display: none; }

  .header-tools button { padding: 6px 11px; font-size: 0.78rem; }

  .hero-stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px 8px; }

  #toc ul { grid-template-columns: 1fr; }

  #sitemap ul,
  #links ul { grid-template-columns: 1fr; }

  #articles article { padding: 20px 18px 16px; }

  #faq summary { padding: 14px 46px 14px 16px; font-size: 0.94rem; }
  #faq details > p { padding: 0 16px 16px; font-size: 0.9rem; }

  #howto ol li { padding: 12px 14px 12px 50px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  main > section,
  .slide,
  #faq details > p {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ===== Print ===== */
@media print {
  #site-header,
  .header-tools,
  .slider-controls,
  #back-to-top,
  #site-footer {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  main > section {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
  a { color: #000; text-decoration: underline; }
}