  :root {
    --bg: #f7f6f2; --surface: #ffffff; --surface-2: #f0eee8;
    --text: #16181d; --muted: #555a69; --border: #e3e1da;
    --accent: #2f3fb5; --accent-bg: #eceefc; --on-accent: #ffffff;
    --gold: #7d5800; --gold-bg: #fbf3e0;
    --risk: #b42318; --risk-bg: #fdecea;
    --ring: #2f3fb5;
    --radius: 14px; --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16,18,24,.04), 0 4px 16px rgba(16,18,24,.06);
    --maxw: 1120px;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0e1015; --surface: #161922; --surface-2: #1d212c;
      --text: #eceef3; --muted: #a3a9b8; --border: #2a2f3b;
      --accent: #9aa6ff; --accent-bg: #1c2140; --on-accent: #0e1015;
      --gold: #e5b85c; --gold-bg: #2a2214;
      --risk: #ff8a80; --risk-bg: #2a1517;
      --ring: #9aa6ff;
      --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0e1015; --surface: #161922; --surface-2: #1d212c;
    --text: #eceef3; --muted: #a3a9b8; --border: #2a2f3b;
    --accent: #9aa6ff; --accent-bg: #1c2140; --on-accent: #0e1015;
    --gold: #e5b85c; --gold-bg: #2a2214;
    --risk: #ff8a80; --risk-bg: #2a1517;
    --ring: #9aa6ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }

  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1rem; line-height: 1.6;
  }
  a { color: var(--accent); }
  :focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
  .wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .skip { position: absolute; left: 16px; top: -48px; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; z-index: 10; }
  .skip:focus { top: 12px; }

  /* Header */
  .top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; color: var(--text); letter-spacing: -.01em; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: .95rem; }
  .nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
  .nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; padding: 8px 10px; border-radius: 8px; }
  .nav a:hover { color: var(--text); background: var(--surface-2); }
  .icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }
  .icon-btn:hover { background: var(--surface-2); }
  .icon-btn svg { width: 18px; height: 18px; }
  .i-sun { display: none; }
  :root[data-theme="dark"] .i-sun { display: block; }
  :root[data-theme="dark"] .i-moon { display: none; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .i-sun { display: block; }
    :root:not([data-theme="light"]) .i-moon { display: none; }
  }

  /* Hero */
  .hero { padding: 64px 0 40px; }
  .eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-bg); padding: 6px 12px; border-radius: 999px; }
  .hero h1 { font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1.1; letter-spacing: -.03em; margin: 18px 0 16px; font-weight: 800; max-width: 18ch; }
  .hero h1 .n-good { color: var(--accent); }
  .hero h1 .n-risk { color: var(--risk); }
  .lede { font-size: clamp(1.05rem, 2.2vw, 1.2rem); color: var(--muted); max-width: 62ch; margin: 0 0 28px; }
  .scale { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); max-width: 640px; }
  .scale-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
  .scale-bar .g { background: var(--accent); width: 92.4%; }
  .scale-bar .r { background: var(--risk); width: 7.6%; }
  .scale-legend { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: .9rem; color: var(--muted); }
  .scale-legend b { color: var(--text); }
  .note { margin-top: 20px; padding: 14px 16px; border-left: 4px solid var(--gold); background: var(--gold-bg); border-radius: var(--radius-sm); font-size: .95rem; max-width: 72ch; }
  .note strong { color: var(--gold); }
  .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
  .btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 700; text-decoration: none; border: 1px solid transparent; }
  .btn-primary { background: var(--accent); color: var(--on-accent); }
  .btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
  .btn-ghost:hover { background: var(--surface-2); }

  /* Section */
  section { padding: 40px 0; }
  .sec-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
  .sec-head h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -.02em; margin: 0; line-height: 1.2; }
  .sec-head p { margin: 6px 0 0; color: var(--muted); }

  /* Tools: search + chips */
  .tools { display: grid; gap: 12px; margin-bottom: 20px; }
  .search { position: relative; max-width: 420px; }
  .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
  .search input { width: 100%; min-height: 44px; padding: 10px 14px 10px 40px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
  .search input::placeholder { color: var(--muted); }
  .chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .chip { flex: none; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
  .chip:hover { background: var(--surface-2); }
  .chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
  .count { font-size: .9rem; color: var(--muted); }

  /* Group cards */
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
  .group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
  .group h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.05rem; line-height: 1.3; }
  .roman { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); font-size: .8rem; font-weight: 800; }
  .group ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .group li { display: grid; grid-template-columns: 36px 1fr; gap: 8px; font-size: .95rem; }
  .num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: .85rem; padding-top: 2px; }
  mark { background: var(--gold-bg); color: inherit; border-radius: 3px; padding: 0 2px; outline: 1px solid var(--gold); }

  .empty { display: none; text-align: center; padding: 40px 16px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
  .empty.show { display: block; }
  .empty h3 { margin: 0 0 6px; }
  .empty p { margin: 0 0 14px; color: var(--muted); }

  /* Risks */
  .risks { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .risk-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
  .risk { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--risk); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
  .risk-head { display: flex; gap: 10px; align-items: baseline; }
  .risk-num { flex: none; font-weight: 800; color: var(--risk); font-size: 1.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
  .risk h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
  .risk p { margin: 0; font-size: .95rem; }
  .fix { margin-top: auto; font-size: .9rem; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-bg); }
  .fix b { color: var(--accent); }
  .group-final { grid-column: 1 / -1; border: 2px solid var(--gold); background: var(--gold-bg); }
  .group-final .roman { background: var(--gold); color: var(--surface); }
  .group-final li { font-size: 1.05rem; font-weight: 600; grid-template-columns: 44px 1fr; }
  .group-final .num { color: var(--gold); font-size: 1rem; }

  /* Closing */
  .closing { text-align: center; padding: 64px 0; }
  .closing .big { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; letter-spacing: -.02em; max-width: 28ch; margin: 0 auto 12px; line-height: 1.25; }
  .closing p { color: var(--muted); max-width: 60ch; margin: 0 auto; }

  footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: .85rem; }
  footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

  [hidden] { display: none !important; }

  @media (max-width: 560px) {
    .nav a { display: none; }
    .hero { padding: 40px 0 24px; }
  }
  @media (prefers-reduced-motion: no-preference) {
    .group, .risk { transition: transform .2s ease, box-shadow .2s ease; }
    .group:hover, .risk:hover { transform: translateY(-2px); }
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }
  @media print {
    .top, .tools, .cta { display: none; }
    .group, .risk { box-shadow: none; break-inside: avoid; }
  }
