:root {
  --ink: #1d2433;
  --muted: #5f6b7d;
  --line: #e3e7ee;
  --paper: #ffffff;
  --paper-2: #f5f7fa;
  --accent: #3b5bdb;
  --accent-soft: #e8edfb;
  --green: #0ca678;
  --code: #f1f3f7;
  --max: 1000px;
}
@media (prefers-color-scheme: dark) {

  :root:not([data-theme="light"]) {
    --ink: #e7eaf0;
    --muted: #a3adbf;
    --line: #2b3140;
    --paper: #14171e;
    --paper-2: #1b1f28;
    --accent: #8da2ff;
    --accent-soft: #232a45;
    --green: #3ccf9f;
    --code: #1f242f;
  }
  :root:not([data-theme="light"]) img.fig { background: #ffffff; border-radius: 10px; padding: 8px; }
}

  :root[data-theme="dark"] {
    --ink: #e7eaf0;
    --muted: #a3adbf;
    --line: #2b3140;
    --paper: #14171e;
    --paper-2: #1b1f28;
    --accent: #8da2ff;
    --accent-soft: #232a45;
    --green: #3ccf9f;
    --code: #1f242f;
  }
  :root[data-theme="dark"] img.fig { background: #ffffff; border-radius: 10px; padding: 8px; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code); padding: 14px 18px; border-radius: 10px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }
kbd { background: var(--paper-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; }

header.top {
  position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--paper) 82%, transparent); border-bottom: 1px solid var(--line);
}
header.top .bar { max-width: var(--max); margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
header.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 18px; }
header.top .brand img { width: 30px; height: 30px; border-radius: 7px; }
header.top nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav a { color: var(--muted); padding: 6px 11px; border-radius: 8px; font-size: 15px; }
header.top nav a:hover { background: var(--paper-2); text-decoration: none; color: var(--ink); }
header.top nav a.current { color: var(--accent); background: var(--accent-soft); }

main { max-width: var(--max); margin: 0 auto; padding: 24px 20px 60px; }
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 36px; align-items: center; padding: 40px 0 20px; }
.hero h1 { font-size: 44px; line-height: 1.1; margin: 0 0 14px; letter-spacing: -0.02em; }
.hero h1 small { display: block; font-size: 20px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 8px; }
.hero p.lead { font-size: 20px; color: var(--muted); margin: 0 0 22px; }
.hero .icon { width: 128px; height: 128px; border-radius: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.18); margin-bottom: 18px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-block; padding: 11px 18px; border-radius: 10px; font-weight: 600; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn:hover { text-decoration: none; filter: brightness(1.04); }
.note-small { color: var(--muted); font-size: 14px; }

h2 { font-size: 30px; margin: 54px 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 21px; margin: 32px 0 10px; }
h4 { font-size: 17px; margin: 22px 0 6px; }
p, li { max-width: 78ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 20px 0; }
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 15.5px; }
figure { margin: 26px 0; }
figure img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figure.frame img { border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.10); }
figcaption { color: var(--muted); font-size: 14.5px; text-align: center; margin-top: 10px; max-width: 70ch; margin-left: auto; margin-right: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; margin: 16px 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 18px 0; }
.callout.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--paper)); }
.callout p:last-child { margin-bottom: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 46px; margin: 14px 0; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 2px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: white; font-weight: 700; display: grid; place-items: center; font-size: 15px;
}
.toc { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 20px; margin: 18px 0 30px; }
.toc ul { margin: 6px 0 0; padding-left: 18px; columns: 2; }
.toc li { margin: 3px 0; }
.ui { font-weight: 600; }
.formula { font-family: "STIX Two Text", "Times New Roman", serif; font-size: 1.1em; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer .bar { max-width: var(--max); margin: 0 auto; padding: 22px 20px; display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between; }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .hero h1 { font-size: 34px; }
  .two { grid-template-columns: 1fr; }
  .toc ul { columns: 1; }
}
header.top nav a.lang { margin-left: 8px; border: 1px solid var(--line); padding: 5px 10px; }

/* Day/night button and lightbox */
#theme-toggle { margin-left: 6px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); border-radius: 8px; width: 34px; height: 32px; font-size: 17px; cursor: pointer; }
#theme-toggle:hover { background: var(--accent-soft); }
figure img.zoomable { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; background: rgba(10, 12, 18, 0.88); cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: min(96vw, 1600px); max-height: 84vh; width: auto; height: auto; background: #fff; border-radius: 12px; padding: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox .caption { color: #dfe3ea; font-size: 15px; text-align: center; max-width: 80ch; margin: 0; }
.lightbox .close { position: fixed; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 26px; cursor: pointer; }

.btn.store { font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; letter-spacing: 0.01em; }
.btn.store:not(.primary) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 10px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 10px; padding: 8px 16px 8px 13px; font-weight: 600; font-size: 15.5px; line-height: 1.15; letter-spacing: 0.01em; }
.badge:hover { text-decoration: none; filter: brightness(1.15); }
.badge small { display: block; font-weight: 400; font-size: 11px; opacity: .8; line-height: 1; margin-bottom: 3px; }
.badge svg { width: 24px; height: 24px; fill: currentColor; flex: none; }

.actions.badges img { height: 48px; width: auto; display: block; }
.actions.badges a:has(img) { display: inline-block; line-height: 0; }
.actions.badges .btn { padding: 12px 18px; }
