  :root {
    --bg: #f2f5f7;
    --surface: #ffffff;
    --surface-2: #eef2f5;
    --ink: #243139;
    --muted: #5b6b75;
    --faint: #8a98a2;
    --line: #dbe3e8;
    --line-strong: #c2d0d8;
    --accent: #0082c1;
    --accent-ink: #005487;
    --accent-wash: #e4f1f9;
    --btn-bg: #0082c1;
    --btn-bg-hover: #005487;
    --btn-text: #ffffff;
    --good: #0e7c53;
    --good-wash: #e6f4ec;
    --warn: #a65a00;
    --warn-wash: #f7efe1;
    --shadow: 0 1px 2px rgba(0,72,120,.07), 0 6px 20px rgba(0,72,120,.07);
    --radius: 12px;
    --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;
    --sans: "Helvetica Neue", Helvetica, Arial, "Segoe UI", Roboto, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0b1319;
      --surface: #111d25;
      --surface-2: #0e1820;
      --ink: #e5edf2;
      --muted: #94a6b1;
      --faint: #63757f;
      --line: #22333d;
      --line-strong: #33454f;
      --accent: #49a8e2;
      --accent-ink: #bfe0f4;
      --accent-wash: #0f2a3b;
      --btn-bg: #1f6fa8;
      --btn-bg-hover: #17608f;
      --btn-text: #ffffff;
      --good: #4cc38a;
      --good-wash: #10241b;
      --warn: #e0a154;
      --warn-wash: #28200f;
      --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.35);
    }
  }
  :root[data-theme="light"] {
    --bg: #f2f5f7; --surface: #ffffff; --surface-2: #eef2f5; --ink: #243139;
    --muted: #5b6b75; --faint: #8a98a2; --line: #dbe3e8; --line-strong: #c2d0d8;
    --accent: #0082c1; --accent-ink: #005487; --accent-wash: #e4f1f9;
    --btn-bg: #0082c1; --btn-bg-hover: #005487; --btn-text: #ffffff;
    --good: #0e7c53; --good-wash: #e6f4ec; --warn: #a65a00; --warn-wash: #f7efe1;
    --shadow: 0 1px 2px rgba(0,72,120,.07), 0 6px 20px rgba(0,72,120,.07);
  }
  :root[data-theme="dark"] {
    --bg: #0b1319; --surface: #111d25; --surface-2: #0e1820; --ink: #e5edf2;
    --muted: #94a6b1; --faint: #63757f; --line: #22333d; --line-strong: #33454f;
    --accent: #49a8e2; --accent-ink: #bfe0f4; --accent-wash: #0f2a3b;
    --btn-bg: #1f6fa8; --btn-bg-hover: #17608f; --btn-text: #ffffff;
    --good: #4cc38a; --good-wash: #10241b; --warn: #e0a154; --warn-wash: #28200f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.35);
  }

  * { box-sizing: border-box; }
  body { margin: 0; }
  .app {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding: 32px 20px 80px;
  }
  .wrap { max-width: 820px; margin: 0 auto; }

  .eyebrow {
    font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--accent); font-weight: 700; margin: 0 0 10px;
  }
  h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -.02em; text-wrap: balance; font-weight: 700; color: var(--accent-ink); }
  h2 { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0 0 14px; }
  h3 { font-size: 17px; margin: 0 0 6px; font-weight: 700; letter-spacing: -.01em; }
  p { margin: 0 0 12px; }
  .lede { font-size: 17px; color: var(--muted); max-width: 62ch; }
  code, .mono { font-family: var(--mono); font-size: .9em; }

  .site-header {
    display: flex; align-items: center; gap: 12px;
    padding-bottom: 18px; margin-bottom: 26px;
    border-bottom: 1px solid var(--line);
  }
  .brand-logo {
    background: #ffffff; border-radius: 8px; padding: 7px 11px; flex: 0 0 auto;
    display: flex; align-items: center; box-shadow: 0 0 0 1px var(--line);
  }
  .brand-logo img { height: 24px; width: auto; display: block; }
  .brand-name { font-weight: 700; font-size: 15px; }
  .brand-sub { color: var(--faint); font-size: 13px; }

  .hero { margin-bottom: 30px; }

  /* progress */
  .progress { display: flex; gap: 8px; margin: 26px 0 20px; }
  .progress .dot { height: 4px; flex: 1; border-radius: 3px; background: var(--line); transition: background .3s ease; }
  .progress .dot.done { background: var(--accent); }

  /* question cards */
  .step { margin-bottom: 22px; }
  .step[hidden] { display: none; }
  .step-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
  .step-num {
    font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent);
    background: var(--accent-wash); border-radius: 6px; padding: 2px 7px; flex: 0 0 auto;
  }
  .q { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0; }

  .options { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
  @media (max-width: 620px) { .options { grid-template-columns: 1fr; } }

  .opt {
    text-align: left; font: inherit; color: inherit; cursor: pointer;
    background: var(--surface); border: 1.5px solid var(--line);
    border-radius: var(--radius); padding: 16px 16px 15px; position: relative;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .08s ease;
    display: flex; flex-direction: column; gap: 4px;
  }
  .opt:hover { border-color: var(--line-strong); background: var(--surface-2); }
  .opt:active { transform: translateY(1px); }
  .opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .opt[aria-pressed="true"] {
    border-color: var(--accent); background: var(--accent-wash);
    box-shadow: 0 0 0 1px var(--accent) inset;
  }
  .opt .opt-title { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .opt .opt-desc { color: var(--muted); font-size: 13.5px; }

  .pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  }
  .pill.rec { background: var(--good-wash); color: var(--good); }
  .pill.fixed { background: var(--warn-wash); color: var(--warn); }
  .pill.mapped { background: var(--surface-2); color: var(--muted); }
  .pill.req { background: var(--accent-wash); color: var(--accent-ink); }

  .helper { margin-top: 12px; }
  .helper summary {
    cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px;
    list-style: none; display: inline-flex; align-items: center; gap: 6px;
  }
  .helper summary::-webkit-details-marker { display: none; }
  .helper summary::before { content: "＋"; font-family: var(--mono); }
  .helper[open] summary::before { content: "−"; }
  .helper .helper-body {
    margin-top: 10px; padding: 14px 16px; background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
  }
  .helper table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .helper th, .helper td { text-align: left; padding: 7px 8px; vertical-align: top; border-bottom: 1px solid var(--line); }
  .helper th { color: var(--muted); font-weight: 600; }
  .helper tr:last-child td { border-bottom: none; }

  /* sequence diagrams */
  .seqwrap { display: grid; gap: 14px; margin: 14px 0 4px; }
  .seqfig { margin: 0; }
  /* Scale up freely on desktop, but never shrink below the drawing's natural size:
     below ~460px the figure scrolls sideways instead of rendering ~7px labels.
     The scroll is contained here, so the page itself never scrolls horizontally. */
  .seqfig .seqscroll { overflow-x: auto; }
  .seqfig svg.seq { width: 100%; min-width: 460px; height: auto; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; }
  .seqfig figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
  .seq .lane { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
  .seq .lane-t { fill: var(--ink); font-family: var(--sans); font-size: 12px; font-weight: 600; }
  .seq .life { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
  .seq .msg { stroke: var(--muted); stroke-width: 1.5; fill: none; }
  .seq .msg-t { fill: var(--muted); font-family: var(--sans); font-size: 11px; }
  .seq .msg-k { stroke: var(--accent); stroke-width: 2; fill: none; }
  .seq .msg-kt { fill: var(--accent-ink); font-family: var(--sans); font-size: 11px; font-weight: 600; }
  .seq .ah { fill: var(--muted); }
  .seq .ah-k { fill: var(--accent); }
  .seq .note { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 1; }
  .seq .note-t { fill: var(--accent-ink); font-family: var(--sans); font-size: 10.5px; font-weight: 600; }

  /* results */
  .results { margin-top: 14px; }
  .results[hidden] { display: none; }
  .result-hero {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 22px 22px 20px; box-shadow: var(--shadow); margin-bottom: 20px;
  }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
  .chip {
    display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
    padding: 6px 11px; border-radius: 999px;
  }
  .chip .k { color: var(--faint); font-weight: 500; }

  .card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 16px;
  }
  .card > h2 { margin-bottom: 16px; }

  ol.flow { margin: 0; padding: 0; list-style: none; counter-reset: f; display: grid; gap: 10px; }
  ol.flow li { counter-increment: f; padding-left: 40px; position: relative; }
  ol.flow li::before {
    content: counter(f); position: absolute; left: 0; top: -1px;
    width: 26px; height: 26px; border-radius: 7px; background: var(--accent-wash);
    color: var(--accent-ink); font-family: var(--mono); font-weight: 700; font-size: 13px;
    display: grid; place-items: center;
  }

  ul.check { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  ul.check li { display: flex; gap: 11px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
  ul.check li:last-child { border-bottom: none; }
  ul.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; cursor: pointer; }
  ul.check .ci-main { font-size: 14.5px; }
  ul.check .ci-note { color: var(--muted); font-size: 13px; }

  .subhead { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 18px 0 8px; }
  .subhead:first-child { margin-top: 0; }

  .table-scroll { overflow-x: auto; }
  table.attrs { width: 100%; border-collapse: collapse; font-size: 14px; }
  table.attrs th, table.attrs td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
  table.attrs th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
  table.attrs td:first-child { white-space: nowrap; }
  table.attrs .attr-name { font-family: var(--mono); font-weight: 600; font-size: 13.5px; }
  table.attrs tr:last-child td { border-bottom: none; }

  .give { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
  .give li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
  .give li::before { content: "→"; color: var(--accent); font-weight: 700; flex: 0 0 auto; }

  .note {
    font-size: 13.5px; color: var(--muted); background: var(--surface-2);
    border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 12px 14px; margin-top: 4px;
  }
  .note.rec { border-left-color: var(--good); }

  .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
  .btn {
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    border-radius: 9px; padding: 10px 16px; border: 1.5px solid var(--line-strong);
    background: var(--surface); color: var(--ink); transition: background .15s, border-color .15s, transform .08s;
  }
  .btn:hover { background: var(--surface-2); border-color: var(--accent); }
  .btn:active { transform: translateY(1px); }
  .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-text); }
  .btn.primary:hover { background: var(--btn-bg-hover); border-color: var(--btn-bg-hover); }

  .footer-note { color: var(--faint); font-size: 13px; margin-top: 26px; text-align: center; }
  .footer-note a { color: var(--accent); }

  .toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
    padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow);
    opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; z-index: 50;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* knowledge base */
  .kb { margin-top: 44px; padding-top: 30px; border-top: 1px solid var(--line); }
  .kb-title { font-size: 22px; color: var(--ink); text-transform: none; letter-spacing: -.01em; font-weight: 700; margin: 2px 0 6px; }
  .kb-intro { color: var(--muted); font-size: 15px; margin: 0 0 16px; max-width: 62ch; }
  .kb-search { width: 100%; font: inherit; font-size: 15px; padding: 11px 14px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
  .kb-search::placeholder { color: var(--faint); }
  .kb-search:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
  .kb-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0; }
  .kb-chip { font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); transition: border-color .12s, color .12s, background .12s; }
  .kb-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
  .kb-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .kb-chip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
  .kb-meta { font-size: 12.5px; color: var(--faint); margin: 16px 0 8px; }
  .kb-list { display: grid; gap: 8px; }
  .kb-item { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .kb-item > summary { cursor: pointer; list-style: none; padding: 13px 15px; display: flex; align-items: center; gap: 10px; }
  .kb-item > summary::-webkit-details-marker { display: none; }
  .kb-q { flex: 1; font-weight: 600; font-size: 14.5px; color: var(--ink); }
  .kb-item > summary::after { content: "+"; font-family: var(--mono); color: var(--muted); font-weight: 400; flex: 0 0 auto; }
  .kb-item[open] > summary::after { content: "\2013"; }
  .kb-topic { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent-wash); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
  .kb-a { padding: 0 15px 14px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
  .kb-a code { font-family: var(--mono); font-size: .9em; }
  .kb-empty { display: none; color: var(--muted); font-size: 14.5px; padding: 18px 2px; }

  /* sample SAML */
  .samples { margin-top: 44px; padding-top: 30px; border-top: 1px solid var(--line); }
  .samples-title { font-size: 22px; color: var(--ink); text-transform: none; letter-spacing: -.01em; font-weight: 700; margin: 2px 0 6px; }
  .samples-intro { color: var(--muted); font-size: 15px; margin: 0 0 16px; max-width: 62ch; }
  .sample-item { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
  .sample-item > summary { cursor: pointer; list-style: none; padding: 13px 15px; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; color: var(--ink); }
  .sample-item > summary::-webkit-details-marker { display: none; }
  .sample-item > summary::after { content: "+"; font-family: var(--mono); color: var(--muted); font-weight: 400; margin-left: auto; flex: 0 0 auto; }
  .sample-item[open] > summary::after { content: "\2013"; }
  .sample-item .sample-note { padding: 0 15px 10px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
  .sample-item .sample-note code { font-family: var(--mono); font-size: .9em; }
  .sample-item pre { margin: 0 15px 15px; padding: 14px; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--ink); white-space: pre; }

  .print-title { display: none; }

  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
  }

  @media print {
    .app { padding: 0; background: #fff; color: #000; }
    .site-header, .hero, .progress, .step, .actions, .footer-note, .toast, .kb, .samples { display: none !important; }
    .results { margin: 0; }
    .card, .result-hero { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
    .print-title { display: block; margin-bottom: 16px; }
    .print-title h1 { font-size: 22px; }
  }
