:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #14171f;
  --muted: #5b6272;
  --line: #e3e6ec;
  --accent: #1f5fe0;
  --accent-text: #ffffff;
  --soft: #eaf0fd;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #181c25;
    --text: #eef0f5;
    --muted: #a3aabb;
    --line: #2a303d;
    --accent: #7aa5ff;
    --accent-text: #0b1020;
    --soft: #1c2740;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 12px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav a { margin-left: 16px; text-decoration: none; font-size: 15px; }

.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.15; margin: 0 0 12px; text-wrap: balance; }
.lead { color: var(--muted); font-size: 19px; margin: 0 auto; max-width: 620px; text-wrap: pretty; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; padding: 24px 0 48px; list-style: none; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.card-shot { display: block; background: var(--soft); aspect-ratio: 16 / 11; overflow: hidden; }
.card-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-head { display: flex; align-items: center; gap: 12px; }
.icon { width: 48px; height: 48px; border-radius: 11px; flex: none; background: var(--soft); }
.card h2 { font-size: 19px; line-height: 1.25; margin: 0; }
.card p { margin: 0; color: var(--muted); font-size: 15.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: auto; padding-top: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 600; text-decoration: none; background: var(--accent); color: var(--accent-text); }
.btn.quiet { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.soon { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 14px; font-weight: 600; }

.guide-head { padding: 36px 0 8px; display: flex; gap: 18px; align-items: flex-start; }
.guide-head .icon { width: 72px; height: 72px; border-radius: 16px; }
.guide-head h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 0 0 6px; text-wrap: balance; }
.guide-head .lead { margin: 0 0 14px; font-size: 18px; }
.meta { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 24px 0; }
.toc strong { display: block; margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; columns: 2 220px; }
.toc a { text-decoration: none; }

.guide h2 { font-size: 25px; line-height: 1.25; margin: 40px 0 10px; scroll-margin-top: 16px; }
.guide ol, .guide ul { padding-left: 24px; }
.guide li { margin: 6px 0; }
.guide figure { margin: 18px 0 26px; text-align: center; }
.guide figure img { width: min(100%, 320px); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08); }
.guide figcaption { color: var(--muted); font-size: 14.5px; margin-top: 8px; }

.cta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 40px 0; text-align: center; }
.cta h2 { margin: 0 0 6px; font-size: 22px; }
.cta p { margin: 0 0 14px; color: var(--muted); }

.more h2 { font-size: 22px; margin: 0; }
.more .grid { padding-top: 16px; }

footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 14.5px; }
footer p { margin: 4px 0; }

@media (max-width: 560px) {
  .guide-head { flex-direction: column; gap: 12px; }
  .hero { padding-top: 32px; }
}

.top nav { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.lang { position: relative; margin-inline-start: 16px; }
.lang summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14.5px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.lang summary::-webkit-details-marker { display: none; }
.lang-icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lang summary:focus-visible, .lang-menu a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lang summary::after { content: "▾"; margin-inline-start: 6px; font-size: 11px; }
.lang[open] summary { border-color: var(--accent); }
.lang-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 10; display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 2px; width: max-content; max-width: min(92vw, 320px); max-height: 70vh; overflow-y: auto; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); }
.top nav .lang-menu a { margin: 0; padding: 6px 10px; border-radius: 8px; font-size: 14.5px; }
.top nav .lang-menu a { display: flex; align-items: center; min-height: 36px; }
.top nav .lang-menu a:hover { background: var(--bg); }
.top nav .lang-menu a[aria-current] { font-weight: 700; background: var(--bg); }
.top nav .lang-menu a[aria-current]::before { content: "✓"; margin-inline-end: 6px; color: var(--accent); }

.qr { margin-left: auto; flex: none; width: 132px; text-align: center; display: none; }
.qr svg { width: 132px; height: 132px; display: block; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.qr p { margin: 6px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--muted); }
@media (min-width: 720px) { .qr { display: block; } }

.share { margin: 16px 0 0; font-size: 15px; color: var(--muted); }
.share a { margin: 0 6px; }

/* ---- UX pass: accessibility, reading comfort, phone layout ---- */
:root { --line-strong: #8d95a6; --shadow: 0 6px 24px rgba(0, 0, 0, 0.08); }
@media (prefers-color-scheme: dark) { :root { --line-strong: #6b7385; --shadow: 0 6px 24px rgba(0, 0, 0, 0.4); } }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
html { scroll-padding-top: 80px; }

a:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 30; padding: 10px 16px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none; }
.skip:focus { top: 8px; }

.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); }
.brand { overflow-wrap: anywhere; }
.top nav a:not(.btn) { padding: 8px 4px; }
.btn { transition: filter 0.15s, transform 0.15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.quiet { border-color: var(--line-strong); }
.btn.quiet:hover { background: var(--soft); filter: none; }
.lang summary { border-color: var(--line-strong); }

.card { transition: transform 0.15s, box-shadow 0.15s; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions.center { justify-content: center; }

body { line-height: 1.65; }
.guide p, .guide li { max-width: 68ch; }
.guide h2 { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); text-wrap: balance; }
.guide h2:first-child { margin-top: 24px; border-top: 0; padding-top: 0; }
.guide h3 { font-size: 19px; margin: 28px 0 6px; text-wrap: balance; }

/* Numbered steps as badges */
.guide ol { list-style: none; counter-reset: step; padding: 0; }
.guide ol > li { counter-increment: step; position: relative; padding-inline-start: 44px; margin: 14px 0; min-height: 32px; }
.guide ol > li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.guide ol ol, .guide ul ol { margin-top: 8px; }
.guide ul { padding-inline-start: 24px; }
.guide ul li::marker { color: var(--accent); }

/* Tips and notes (Markdown ">" quotes), code, tables */
.guide blockquote { margin: 20px 0; padding: 12px 16px; background: var(--soft); border-inline-start: 4px solid var(--accent); border-radius: 0 10px 10px 0; }
.guide blockquote p { margin: 4px 0; }
.guide code, .guide kbd { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.guide table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; margin: 18px 0; font-size: 15.5px; }
.guide th, .guide td { border: 1px solid var(--line); padding: 8px 12px; text-align: start; }
.guide th { background: var(--soft); }
.guide hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.guide figure img { box-shadow: var(--shadow); }

.guide-head { align-items: center; }
.guide-head .actions { margin-top: 0; padding-top: 0; }
.toc { border-inline-start: 4px solid var(--accent); }
.toc li { margin: 4px 0; }
.toc a { display: inline-block; padding: 3px 0; }

/* Wide screens: contents stay beside the guide while reading. */
@media (min-width: 1100px) {
  .guide-page { max-width: 1040px; display: grid; grid-template-columns: 230px minmax(0, 720px); column-gap: 48px; align-items: start; }
  .guide-page > * { grid-column: 2; }
  .guide-page > .toc { grid-column: 1; grid-row: 1 / span 6; position: sticky; top: 88px; margin: 36px 0 0; max-height: calc(100vh - 112px); overflow-y: auto; }
  .guide-page > .toc ol { columns: 1; }
}

@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .guide-head { flex-direction: row; align-items: flex-start; flex-wrap: wrap; }
  .guide-head .icon { width: 56px; height: 56px; border-radius: 13px; }
  .guide-head > div { flex: 1 1 200px; min-width: 0; }
  .guide-head .actions, .guide-head .btn { width: 100%; }
  .cta .actions .btn { width: 100%; }
  .lang-menu { grid-template-columns: 1fr; }
  .top .wrap { flex-wrap: wrap; padding-block: 6px; }
  .guide figure img { width: min(100%, 280px); }
}

@media print {
  .top, .skip, .lang, .toc, .cta, .more, .share, footer, .qr { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .guide figure { break-inside: avoid; }
}

/* ---- UX pass 2: contents list ---- */
.toc { padding: 0; }
.toc summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 8px 18px; font-weight: 700; border-radius: var(--radius); }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "▾"; font-size: 12px; color: var(--muted); transition: transform 0.15s; }
.toc details:not([open]) summary::after { transform: rotate(-90deg); }
.toc summary:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.toc ol { padding: 0 18px 12px; padding-inline-start: 38px; margin: 0; }
.toc a { display: block; padding: 5px 0; }
.toc a[aria-current] { font-weight: 700; color: var(--text); }
@media (min-width: 1100px) {
  .toc summary { pointer-events: none; }
  .toc summary::after { display: none; }
  .guide-page > .toc ol { padding-inline-end: 12px; }
}

/* ---- Search, language offer, picture zoom, feedback, previous/next ---- */
.search-btn, .quiet-btn { font: inherit; font-size: 14.5px; cursor: pointer; min-height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text); }
.search-btn { margin-inline-start: 16px; }
.search-btn:focus-visible, .quiet-btn:focus-visible, .zoom:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.offer { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--soft); border-bottom: 1px solid var(--line); }
.offer .btn { min-height: 44px; }
.offer .quiet-btn { min-height: 44px; }
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 16px; max-width: min(92vw, 640px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.search-dialog { width: min(92vw, 560px); max-height: 80vh; }
.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; min-width: 0; font: inherit; min-height: 44px; padding: 0 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; }
.search-box .quiet-btn { min-height: 44px; }
.search-status { color: var(--muted); margin: 12px 0 0; }
.search-results { list-style: none; margin: 8px 0 0; padding: 0; }
.search-results a { display: block; padding: 8px 6px; text-decoration: none; border-radius: 8px; }
.search-results a:hover, .search-results a:focus-visible { background: var(--bg); }
.search-results strong, .search-results .where { display: block; }
.search-results .where { color: var(--muted); font-size: 14px; }
.zoom { display: block; margin: 0 auto; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 18px; }
.zoom-dialog { padding: 12px; text-align: center; max-height: 94vh; }
.zoom-dialog img { max-width: 100%; max-height: calc(94vh - 96px); width: auto; height: auto; border-radius: 14px; display: block; margin: 0 auto 10px; }
.feedback { margin: 28px 0 0; font-size: 15px; }
.pager { display: flex; gap: 12px; justify-content: space-between; margin: 32px 0 0; }
.pager a { display: flex; flex-direction: column; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; text-decoration: none; max-width: 48%; }
.pager .next { margin-inline-start: auto; text-align: end; }
.pager small { color: var(--muted); }
@media print { .search-btn, .offer, .feedback, .pager { display: none !important; } }
