/* ---------- Tokens: light is the base; both dark states redefine values only ---------- */
  :root {
    --ground: #ffffff; --panel: #f3f6fa; --ink: #0d1726; --ink-strong: #040a12;
    --muted: #586a81; --line: #dfe5ee; --line-strong: #c7d1e0;
    --accent: #10439f; --accent-hover: #0a2e72; --accent-soft: #e9effc; --on-accent: #ffffff; --sun: #e3a90c;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ground: #070c13; --panel: #0e1620; --ink: #e6edf7; --ink-strong: #ffffff;
      --muted: #94a4b8; --line: #1a2432; --line-strong: #2a3747;
      --accent: #7ea6ff; --accent-hover: #a5c2ff; --accent-soft: #101d35; --on-accent: #050d1c; --sun: #f2c23e;
    }
  }
  :root[data-theme="dark"] {
    --ground: #070c13; --panel: #0e1620; --ink: #e6edf7; --ink-strong: #ffffff;
    --muted: #94a4b8; --line: #1a2432; --line-strong: #2a3747;
    --accent: #7ea6ff; --accent-hover: #a5c2ff; --accent-soft: #101d35; --on-accent: #050d1c; --sun: #f2c23e;
  }

  html { scroll-behavior: smooth; }
  body {
    background: var(--ground); color: var(--ink);
    font-family: 'Noto Sans JP', 'Inter', system-ui, sans-serif;
    font-size: 16px; line-height: 1.75; font-feature-settings: "palt" 1; -webkit-font-smoothing: antialiased;
  }
  :root[data-lang="en"] body { font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif; line-height: 1.65; font-feature-settings: normal; }
  :root[data-lang="en"] .display { letter-spacing: -0.035em; line-height: 1.05; }

  .wrap { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 20px; }
  @media (min-width: 768px) { .wrap { padding-inline: 32px; } }

  .display { letter-spacing: -0.01em; line-height: 1.3; text-wrap: balance; }
  .eyebrow { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; font-weight: 500;
    letter-spacing: 0.14em; color: var(--muted); }
  :root[data-lang="en"] .eyebrow { text-transform: uppercase; letter-spacing: 0.16em; }
  .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

  section[id], #project-sale { scroll-margin-top: 92px; }

  .site-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--ground);
    background: color-mix(in srgb, var(--ground) 90%, transparent);
    backdrop-filter: saturate(170%) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  main { padding-top: 64px; }

  .flag-bar { display: inline-block; width: 4px; height: 15px; vertical-align: -2px;
    background: linear-gradient(to bottom, var(--accent) 0 50%, var(--sun) 50% 100%); border-radius: 1px; }

  .navlink { position: relative; color: var(--muted); transition: color .18s ease; white-space: nowrap; }
  .navlink:hover, .navlink[data-active="true"] { color: var(--ink); }
  .navlink[data-active="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -21px; height: 2px; background: var(--accent); }

  .lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
  .lang-btn { font-size: 12px; font-weight: 500; padding: 5px 10px; color: var(--muted); background: transparent;
    transition: background .16s ease, color .16s ease; white-space: nowrap; }
  .lang-btn + .lang-btn { border-left: 1px solid var(--line-strong); }
  .lang-btn:hover { color: var(--ink); }
  .lang-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-size: 14px; font-weight: 500;
    padding: 12px 20px; border-radius: 3px; transition: background .16s ease, border-color .16s ease, color .16s ease; }
  .btn-primary { background: var(--accent); color: var(--on-accent); }
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-ghost { border: 1px solid var(--line-strong); color: var(--ink); }
  .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

  /* Figures: full-fidelity diagrams, horizontally scrollable on narrow screens */
  .fig { margin: 0; }
  .fig-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 3px; background: var(--ground); padding: 18px 16px; }
  .fig-scroll svg { display: block; min-width: 700px; width: 100%; height: auto; color: var(--ink);
    font-family: 'Noto Sans JP', 'Inter', system-ui, sans-serif; }
  :root[data-lang="en"] .fig-scroll svg { font-family: 'Inter', system-ui, sans-serif; }
  .fig figcaption { margin-top: 12px; font-size: 13px; line-height: 1.8; color: var(--muted); max-width: 76ch; }

  /* Solutions: tab list mirrors the case study's own five subsections */
  .sol-tab {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    text-align: left; font-size: 14px; font-weight: 500; line-height: 1.5; color: var(--ink);
    padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--ground);
    transition: border-color .16s ease, background .16s ease, color .16s ease;
  }
  .sol-tab:hover { border-color: var(--accent); }
  .sol-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .sol-tab .sol-num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; opacity: .75; }
  .sol-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
  .sol-list .sol-tab { width: auto; min-width: 210px; flex: none; }
  @media (min-width: 1024px) {
    .sol-list { flex-direction: column; overflow: visible; padding-bottom: 0; }
    .sol-list .sol-tab { width: 100%; min-width: 0; }
  }
  @media print { .sol-panel[hidden] { display: block !important; margin-top: 48px; } }

  .metric-tile { border-top: 2px solid var(--accent); padding-top: 18px; }
  .metric { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums;
    font-size: 38px; font-weight: 500; letter-spacing: -0.02em; color: var(--ink-strong); line-height: 1.1; }

  .step-row { display: flex; gap: 14px; align-items: baseline; }
  .step-num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; color: var(--accent); flex: none; }

  .mat-row { display: grid; gap: 10px 22px; padding: 22px 0; border-top: 1px solid var(--line); grid-template-columns: 1fr; transition: background .16s ease; }
  .mat-row:last-child { border-bottom: 1px solid var(--line); }
  @media (min-width: 860px) {
    .mat-row { grid-template-columns: 76px minmax(0, 1fr) 200px 130px; align-items: start; padding-inline: 14px; }
    .mat-row:hover { background: var(--panel); }
    .mat-row .mat-cta { justify-self: end; }
  }
  .mat-chip { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; letter-spacing: 0.08em;
    padding: 4px 8px; border: 1px solid var(--line-strong); color: var(--muted); border-radius: 2px; justify-self: start; }
  .mat-row:hover .mat-chip { border-color: var(--accent); color: var(--accent); }
  .mat-cta { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--accent); }

  .src-chip { display: inline-flex; align-items: center; gap: 5px; font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px; letter-spacing: 0.04em; padding: 3px 7px; border-radius: 2px; white-space: nowrap; }
  .src-ind { background: var(--accent-soft); color: var(--accent); }
  .src-part { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }
  .src-self { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); }
  .src-link { font-size: 12px; color: var(--accent); word-break: break-all; }
  .src-link:hover { text-decoration: underline; }

  .tech-chip { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; padding: 5px 9px;
    border: 1px solid var(--line); border-radius: 2px; color: var(--muted); }

  .contact-row { display: flex; align-items: center; gap: 15px; padding: 15px 0; border-top: 1px solid var(--line); }
  .copy-btn { color: var(--muted); padding: 6px; border-radius: 3px; transition: color .16s ease, background .16s ease; }
  .copy-btn:hover { color: var(--accent); background: var(--accent-soft); }

  .icon-tile { width: 40px; height: 40px; border-radius: 3px; background: var(--accent-soft); color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center; }

  a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
  }

/* keep the HTML hidden attribute authoritative (svg/flex elements) */
[hidden]:not([hidden=until-found i]){display:none!important}
