:root {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface-subtle: #F4F4F5;
  --text: #18181B;
  --text-muted: #52525B;
  --text-faint: #71717A;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --accent: #15803D;
  --accent-hover: #166534;
  --accent-soft: #F0FDF4;
  --radius: 10px;
  --header-h: 58px;
  --rail-w: 240px;
  --content-max: 860px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1C1C1E;
  --surface-subtle: #262629;
  --text: #F4F4F5;
  --text-muted: #A1A1AA;
  --text-faint: #71717A;
  --border: #2E2E32;
  --border-strong: #3F3F46;
  --accent: #16A34A;
  --accent-hover: #15803D;
  --accent-soft: rgba(22, 163, 74, 0.14);
  color-scheme: dark;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15.5px;
  line-height: 1.65;
  min-width: 0;
  overflow-x: hidden;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* ============ HEADER ============ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
}

.brand svg {
  flex-shrink: 0;
}

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

.lang-switcher {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--surface-subtle);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  min-width: 36px;
  padding: 4px 9px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.lang-btn:focus-visible,
.theme-btn:focus-visible,
.faq-q:focus-visible,
.btn:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ 3-COLUMN PAGE GRID (>= 1280px) ============
   Explicit grid-template-areas guarantees <main> stays centered in the middle
   column even when side rails are empty or hidden via display:none. */
.page-grid {
  width: 100%;
  max-width: calc(var(--content-max) + (var(--rail-w) * 2) + 48px + 32px);
  margin: 0 auto;
  padding: 40px 16px 56px;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--rail-w);
  grid-template-areas: "rail-left main rail-right";
  column-gap: 24px;
  align-items: start;
}

.content-col {
  grid-area: main;
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.side-rail-left { grid-area: rail-left; }
.side-rail-right { grid-area: rail-right; }

.side-rail {
  position: sticky;
  top: 88px;
  width: var(--rail-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rail-unit {
  width: 100%;
  min-width: 240px;
  min-height: 400px;
  background: transparent;
  border: none;
  display: block;
  overflow: hidden;
}

.rail-unit > div {
  width: 100%;
  min-height: 400px;
}

/* Collapse empty slots so no blank space or extra gap appears before code is pasted */
.rail-unit:not(:has(*)) {
  display: none;
  min-height: 0;
}

.inline-unit-wrap {
  width: 100%;
  min-width: 0;
}

.inline-unit-wrap:not(:has(.inline-unit-box > *)) {
  display: none;
}

.inline-unit-box {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ============ EDITORIAL INTRO (Left-aligned, calm, zero badges) ============ */
.intro-block {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.intro-kicker {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 500;
}

.intro-title {
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 680px;
}

.intro-desc {
  color: var(--text-muted);
  font-size: 16.5px;
  line-height: 1.6;
  max-width: 660px;
}

/* ============ NUMBERED STEPS LIST ============ */
.guide-section,
.faq-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-heading {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}

.steps-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.step-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.step-row:last-child {
  border-bottom: none;
}

.step-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.step-body h3 {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.step-body p {
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.62;
}

/* ============ FAQ ============ */
.faq-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-q {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 16px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.faq-q:hover {
  background: var(--surface-subtle);
}

.faq-q::after {
  content: '+';
  font-size: 17px;
  font-weight: 500;
  color: var(--text-faint);
  flex-shrink: 0;
}

.faq-item.open .faq-q::after {
  content: '\2212';
}

.faq-a {
  display: none;
  padding: 0 20px 16px;
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.62;
  max-width: 740px;
}

.faq-item.open .faq-a {
  display: block;
}

/* ============ DEVELOPER NOTE, RATING & COFFEE (Separated from ad slots) ============ */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.dev-note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.dev-note-card h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dev-note-card p {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: 720px;
}

.dev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.free-support-block {
  width: 100%;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.free-support-intro {
  font-size: 13.5px !important;
  color: var(--text-muted);
}

.free-support-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.share-action-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.share-feedback {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.share-feedback:empty {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 13.5px;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-subtle);
}

/* ============ FOOTER ============ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px 36px;
}

.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  color: var(--text-faint);
  font-size: 13px;
}

/* ============ RESPONSIVE (< 1280px hides side rails completely) ============ */
@media (max-width: 1279.98px) {
  .page-grid {
    max-width: calc(var(--content-max) + 32px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
  }

  .side-rail {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .page-grid { padding: 24px 14px 40px; }
  .content-col { gap: 28px; }
  .step-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 16px 18px;
  }
  .faq-q { padding: 14px 16px; }
  .faq-a { padding: 0 16px 14px; }
  .dev-note-card { padding: 20px 18px; }
  .dev-actions,
  .free-support-actions,
  .share-action-group { width: 100%; }
  .dev-actions .btn,
  .free-support-actions .btn { width: 100%; }
}
