  :root {
    color-scheme: light;
    --bg: #f7f8fa;
    --bg-card: #ffffff;
    --bg-code: #f1f3f6;
    --bg-inline-code: #eceef2;
    --text: #1a2233;
    --text-sub: #5a6577;
    --accent: #1d63ed;
    --accent-soft: #e8f0fe;
    --border: #dfe3ea;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --warn-bg: #fff7e8;
    --warn-border: #f0b429;
    --note-bg: #e8f4f0;
    --note-border: #2f9e77;
    --danger-bg: #fdecec;
    --danger-border: #d64545;
    --toc-active: #1d63ed;
    --diagram-vm: #e8f0fe;
    --diagram-host: #f1f3f6;
    --diagram-net: #e8f4f0;
    --kbd-bg: #ffffff;
  }
  /* デフォルト: OS のダーク設定に追従（data-theme 未指定時） */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #0e1218;
      --bg-card: #161b24;
      --bg-code: #1b212c;
      --bg-inline-code: #232a37;
      --text: #e6eaf2;
      --text-sub: #9aa5b5;
      --accent: #5b9aff;
      --accent-soft: #17233a;
      --border: #2a3140;
      --shadow: 0 1px 3px rgba(0, 0, 0, .4);
      --warn-bg: #2b2214;
      --warn-border: #d9a324;
      --note-bg: #12261f;
      --note-border: #34a97f;
      --danger-bg: #2c1717;
      --danger-border: #e05d5d;
      --toc-active: #5b9aff;
      --diagram-vm: #17233a;
      --diagram-host: #1b212c;
      --diagram-net: #12261f;
      --kbd-bg: #232a37;
    }
  }
  /* 手動でダークを固定 */
  [data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1218;
    --bg-card: #161b24;
    --bg-code: #1b212c;
    --bg-inline-code: #232a37;
    --text: #e6eaf2;
    --text-sub: #9aa5b5;
    --accent: #5b9aff;
    --accent-soft: #17233a;
    --border: #2a3140;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --warn-bg: #2b2214;
    --warn-border: #d9a324;
    --note-bg: #12261f;
    --note-border: #34a97f;
    --danger-bg: #2c1717;
    --danger-border: #e05d5d;
    --toc-active: #5b9aff;
    --diagram-vm: #17233a;
    --diagram-host: #1b212c;
    --diagram-net: #12261f;
    --kbd-bg: #232a37;
  }
  /* 手動でライトを固定（OS がダークでも上書き） */
  [data-theme="light"] {
    color-scheme: light;
    --bg: #f7f8fa;
    --bg-card: #ffffff;
    --bg-code: #f1f3f6;
    --bg-inline-code: #eceef2;
    --text: #1a2233;
    --text-sub: #5a6577;
    --accent: #1d63ed;
    --accent-soft: #e8f0fe;
    --border: #dfe3ea;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --warn-bg: #fff7e8;
    --warn-border: #f0b429;
    --note-bg: #e8f4f0;
    --note-border: #2f9e77;
    --danger-bg: #fdecec;
    --danger-border: #d64545;
    --toc-active: #1d63ed;
    --diagram-vm: #e8f0fe;
    --diagram-host: #f1f3f6;
    --diagram-net: #e8f4f0;
    --kbd-bg: #ffffff;
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; scroll-padding-top: 76px; }
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.85;
    font-size: 16px;
    transition: background .25s, color .25s;
  }
  /* ---------- header ---------- */
  header.site {
    position: sticky; top: 0; z-index: 100;
    background: color-mix(in srgb, var(--bg-card) 85%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 10px 20px;
  }
  header.site .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; white-space: nowrap; }
  header.site .brand .logo { font-size: 20px; }
  .page-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
  .page-nav a {
    color: var(--text-sub); text-decoration: none; font-size: 13.5px; font-weight: 600;
    padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  }
  .page-nav a:hover { color: var(--text); background: var(--bg-code); }
  .page-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  #theme-toggle {
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
    border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px;
    display: flex; align-items: center; gap: 6px;
    transition: background .2s;
  }
  #theme-toggle:hover { background: var(--accent-soft); }
  @media (max-width: 760px) {
    header.site { flex-wrap: wrap; }
    .page-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; padding-top: 2px; }
    #theme-toggle { margin-left: auto; }
  }
  /* ---------- layout ---------- */
  .wrap { max-width: 1200px; margin: 0 auto; padding: 32px 20px 80px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }
  nav.toc { position: sticky; top: 80px; align-self: start; font-size: 13.5px; max-height: calc(100vh - 100px); overflow-y: auto; }
  nav.toc .toc-title { font-weight: 700; font-size: 12px; letter-spacing: .08em; color: var(--text-sub); text-transform: uppercase; margin-bottom: 10px; }
  nav.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
  nav.toc li a {
    display: block; padding: 5px 12px; color: var(--text-sub); text-decoration: none;
    border-left: 2px solid transparent; margin-left: -2px;
  }
  nav.toc li a:hover { color: var(--text); }
  nav.toc li a.active { color: var(--toc-active); border-left-color: var(--toc-active); font-weight: 600; }
  @media (max-width: 900px) {
    .wrap { grid-template-columns: 1fr; }
    nav.toc { position: static; max-height: none; border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--bg-card); }
  }
  /* ---------- article ---------- */
  article { min-width: 0; }
  .hero { margin-bottom: 48px; }
  .hero h1 { font-size: clamp(28px, 4.5vw, 42px); line-height: 1.3; margin: 0 0 14px; letter-spacing: -0.01em; }
  .hero .lede { color: var(--text-sub); font-size: 17px; max-width: 46em; }
  .hero .meta { margin-top: 14px; font-size: 13px; color: var(--text-sub); }
  .badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .badge {
    font-size: 12.5px; padding: 4px 12px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-weight: 600;
  }
  section { margin-bottom: 64px; }
  section h2 {
    font-size: 26px; margin: 0 0 6px; padding-top: 8px; letter-spacing: -0.01em;
    display: flex; align-items: baseline; gap: 10px;
  }
  section h2 .secno { color: var(--accent); font-size: 18px; font-weight: 800; }
  section h3 { font-size: 19px; margin: 36px 0 8px; }
  section h4 { font-size: 16px; margin: 28px 0 6px; }
  p { margin: 12px 0; }
  a { color: var(--accent); }
  ul, ol { padding-left: 1.5em; }
  li { margin: 4px 0; }
  strong { font-weight: 700; }
  /* 日本語では italic が読みにくいので、em は斜体にせず強調のみ */
  em {
    font-style: normal;
    font-weight: 600;
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 0 0.15em;
    border-radius: 3px;
  }
  .sub { color: var(--text-sub); font-size: 14px; }
  .sub p { margin: 0.4em 0; }
  .sub p:first-child { margin-top: 0; }
  .sub p:last-child { margin-bottom: 0; }
  .sub ul {
    margin: 0.4em 0;
    padding-left: 1.4em;
    color: inherit;
    font-size: inherit;
  }
  .sub li { margin: 0.2em 0; }
  /* titled blocks: label line + body (e.g. (A)/(B)/(C) recovery methods) */
  .labeled-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 14px 0 18px;
  }
  details.callout .labeled-list {
    margin: 10px 0 4px;
  }
  .labeled-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 12px 16px;
    box-shadow: var(--shadow);
  }
  .labeled-item .li-title {
    margin: 0 0 6px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .labeled-item > p:not(.li-title) {
    margin: 0;
    color: var(--text-sub);
    font-size: 14.5px;
    line-height: 1.75;
  }
  /* デフォルト（カード見出し・callout 見出しなど大きめの行） */
  .li-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75em;
    height: 1.75em;
    padding: 0 7px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  /* 副文など小さな本文に埋め込んだときだけ（日本語行に合わせてわずかに上げる） */
  p.sub .li-badge,
  .sub p .li-badge {
    display: inline-block;
    vertical-align: baseline;
    position: relative;
    top: -0.12em; /* 大文字+下パディング分、見かけ上やや下に見えるのを補正 */
    height: auto;
    min-width: 1.4em;
    margin: 0 0.1em;
    padding: 0.08em 0.38em 0.06em;
    border-radius: 0.35em;
    font-size: 0.9em;
    line-height: 1.15;
    text-align: center;
  }
  hr.sec { border: none; border-top: 1px solid var(--border); margin: 0 0 28px; }
  /* ---------- code ---------- */
  code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .88em; background: var(--bg-inline-code); padding: 2px 6px; border-radius: 5px;
  }
  .codeblock { position: relative; margin: 16px 0; }
  .codeblock pre {
    margin: 0; background: var(--bg-code); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px; overflow-x: auto; line-height: 1.6;
  }
  .codeblock pre code { background: none; padding: 0; font-size: 13.5px; display: block; }
  .codeblock .cb-label {
    position: absolute; top: -9px; left: 14px; font-size: 11px; font-weight: 700;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-sub); padding: 1px 8px;
  }
  .codeblock .copy-btn {
    position: absolute; top: 8px; right: 8px; font-size: 12px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-sub);
    padding: 3px 10px; opacity: 0; transition: opacity .15s;
  }
  .codeblock:hover .copy-btn { opacity: 1; }
  .codeblock .copy-btn:hover { color: var(--accent); }
  .cmt { color: var(--text-sub); }
  /* ---------- callouts ---------- */
  .callout { border-radius: 10px; padding: 14px 18px; margin: 18px 0; border-left: 4px solid; }
  .callout p { margin: 6px 0; }
  .callout .co-title { font-weight: 700; display: flex; gap: 8px; align-items: center; }
  .callout.warn { background: var(--warn-bg); border-color: var(--warn-border); }
  .callout.note { background: var(--note-bg); border-color: var(--note-border); }
  .callout.danger { background: var(--danger-bg); border-color: var(--danger-border); }
  details.callout { padding-top: 10px; padding-bottom: 10px; }
  details.callout > summary.co-title {
    list-style: none;
    cursor: pointer;
    user-select: none;
    margin: 0;
    outline: none;
  }
  details.callout > summary.co-title::-webkit-details-marker { display: none; }
  details.callout > summary.co-title::before {
    content: "▸";
    flex: 0 0 auto;
    font-size: 0.85em;
    opacity: 0.75;
    transition: transform .15s ease;
  }
  details.callout[open] > summary.co-title::before { transform: rotate(90deg); }
  details.callout[open] { padding-bottom: 14px; }
  details.callout > summary.co-title + * { margin-top: 8px; }
  /* ---------- Q&A blocks (inside callouts) ---------- */
  .qa-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 6px;
  }
  .qa-pair {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .qa-q,
  .qa-a {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
    align-items: start;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
  }
  .qa-q { border-left: 3px solid var(--accent); }
  .qa-a { border-left: 3px solid var(--note-border); }
  .qa-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    height: 1.6em;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1;
  }
  .qa-q .qa-badge {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .qa-a .qa-badge {
    background: color-mix(in srgb, var(--note-border) 22%, var(--bg-card));
    color: var(--note-border);
  }
  .qa-body {
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.7;
  }
  .qa-body > :first-child { margin-top: 0; }
  .qa-body > :last-child { margin-bottom: 0; }
  .qa-body p { margin: 0.35em 0; }
  .qa-body p:first-child { margin-top: 0; }
  .qa-body p:last-child { margin-bottom: 0; }
  .qa-q .qa-body { font-weight: 600; color: var(--text); }
  .qa-a .qa-body { color: var(--text); font-weight: 400; }
  /* ---------- tables ---------- */
  .tablewrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; }
  table { border-collapse: collapse; width: 100%; font-size: 14px; }
  th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
  td.wrapok { white-space: normal; min-width: 16em; }
  th { background: var(--bg-code); font-size: 12.5px; letter-spacing: .04em; }
  tr:last-child td { border-bottom: none; }
  /* ---------- cards ---------- */
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin: 18px 0; }
  .card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 20px; box-shadow: var(--shadow);
  }
  .card h4 { margin: 0 0 6px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
  .card p { margin: 4px 0; font-size: 14px; color: var(--text-sub); }
  .journey-card { text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
  .journey-card:hover { transform: translateY(-2px); border-color: var(--accent); }
  .journey-card .step { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  /* ---------- agent tabs ---------- */
  .tabs { margin: 20px 0; }
  .tab-btns { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--border); }
  .tab-btns button {
    border: none; background: none; color: var(--text-sub); font-size: 14.5px; font-weight: 600;
    padding: 9px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
    font-family: inherit;
  }
  .tab-btns button.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tab-panel { display: none; padding-top: 4px; }
  .tab-panel.active { display: block; }
  /* ---------- figure ---------- */
  figure { margin: 24px 0; text-align: center; }
  figure .diagram-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-x: auto; }
  figure img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
  figcaption { font-size: 13px; color: var(--text-sub); margin-top: 10px; }
  svg text { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif; }
  /* ---------- footer ---------- */
  footer { border-top: 1px solid var(--border); padding: 24px 20px 48px; text-align: center; color: var(--text-sub); font-size: 13px; }
  /* back-to-top */
  #to-top {
    position: fixed; right: 22px; bottom: 22px; width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer;
    font-size: 18px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  #to-top.show { opacity: 1; pointer-events: auto; }
