:root {
  --bg: #f6f0e4;
  --ink: #2e2a24;
  --muted: #7a7064;
  --card: #fffaf0;
  --line: #e2d6c2;
  --accent: #6a8f9c;
  --sel: #d7a85b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171c; --ink: #ece6da; --muted: #9c948a; --card: #222229; --line: #34343d; --accent: #8fb3c0; --sel: #d7a85b;
  }
}
:root[data-theme="dark"] {
  --bg: #17171c; --ink: #ece6da; --muted: #9c948a; --card: #222229; --line: #34343d; --accent: #8fb3c0; --sel: #d7a85b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Zen Maru Gothic", system-ui, sans-serif; }
main { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 28px; letter-spacing: .08em; }
.pages { display: flex; gap: 14px; margin-top: 6px; font-size: 14px; }
.pages a { color: var(--muted); text-decoration: none; padding-bottom: 2px; border-bottom: 2px solid transparent; }
.pages a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs { display: flex; gap: 6px; }
.tabs button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.tabs button span { font-size: 11px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.controls { margin: 16px 0 8px; color: var(--muted); }
select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.stage { display: grid; grid-template-columns: 120px 1fr 120px; gap: 16px; align-items: center; }
.pick { display: flex; flex-direction: column; gap: 8px; }
.pick button { border: 2px solid transparent; padding: 0; border-radius: 12px; overflow: hidden; background: var(--card); cursor: pointer; position: relative; }
.pick button img { width: 100%; display: block; aspect-ratio: 1; }
.pick button span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 12px; background: rgba(0,0,0,.45); color: #fff; padding: 2px 0; text-align: center; }
.pick button[aria-pressed="true"] { border-color: var(--sel); }
.view { position: relative; width: 100%; max-width: 512px; margin: 0 auto; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: var(--card); border: 1px solid var(--line); }
.frame img, .view canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame img { opacity: 0; }
.status { position: absolute; left: 8px; bottom: 8px; font-size: 12px; color: #fff; background: rgba(0,0,0,.5); border-radius: 6px; padding: 2px 8px; }
.status:empty { display: none; }
.slider { display: grid; grid-template-columns: 80px 1fr 80px; align-items: center; gap: 12px; max-width: 760px; margin: 20px auto 0; }
.slider span { text-align: center; font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.dev { margin-top: 24px; color: var(--muted); font-size: 14px; }
/* 2軸パッド */
.padstage { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 24px; align-items: center; }
.padwrap { display: grid; grid-template-columns: 64px 1fr 64px; grid-template-rows: 64px auto 1fr auto 64px; gap: 4px; align-items: center; justify-items: center; }
.corner { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; position: relative; background: var(--card); border: 1px solid var(--line); }
.corner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.corner span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; background: rgba(0,0,0,.5); color: #fff; text-align: center; }
.c00 { grid-area: 1 / 1; } .c10 { grid-area: 1 / 3; } .c01 { grid-area: 5 / 1; } .c11 { grid-area: 5 / 3; }
.ax { font-size: 13px; color: var(--muted); font-weight: 700; }
.ax-t { grid-area: 2 / 2; } .ax-b { grid-area: 4 / 2; } .ax-l { grid-area: 3 / 1; writing-mode: vertical-rl; } .ax-r { grid-area: 3 / 3; writing-mode: vertical-rl; }
.ax-l, .ax-r { writing-mode: horizontal-tb; }
.padwrap .ax-t, .padwrap .ax-b { justify-self: center; }
.pad { grid-area: 3 / 2; width: 100%; aspect-ratio: 1; position: relative; border-radius: 12px; border: 1px solid var(--line); cursor: crosshair; touch-action: none;
  background: linear-gradient(to bottom, rgba(106,143,156,.18), rgba(215,120,80,.18)), var(--card); }
.pad:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--sel); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: none; }
.weights { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.padstage .view canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (max-width: 640px) { .padstage { grid-template-columns: 1fr; } }

/* 解説ページ */
.doc article { max-width: 760px; margin: 24px auto 0; line-height: 1.85; }
.doc h2 { font-size: 24px; line-height: 1.5; margin: 8px 0 12px; }
.doc h3 { font-size: 19px; margin: 44px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.doc h4 { font-size: 16px; margin: 18px 0 6px; }
.doc .lead { font-size: 16px; color: var(--muted); }
.doc ul { padding-left: 1.3em; }
.doc li { margin: 6px 0; }
.doc figure { margin: 18px 0; }
.doc figure img.wide { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; }
.doc figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.doc .note { font-size: 13px; color: var(--muted); }
.toc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; margin: 18px 0; }
.toc ol { margin: 0; padding-left: 1.4em; }
.toc a { color: var(--ink); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.card h4 { margin-top: 4px; }
.card p { margin: 6px 0; font-size: 14px; line-height: 1.75; }
.tablewrap { overflow-x: auto; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc th, .doc td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.doc td:nth-child(2) { font-variant-numeric: tabular-nums; }
.diagram svg { width: 100%; height: auto; display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.d-box rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.d-main rect { stroke: var(--accent); stroke-width: 2; }
.diagram text { fill: var(--ink); font-size: 14px; text-anchor: middle; font-family: inherit; }
.diagram .d-sub { fill: var(--muted); font-size: 12px; }
.d-line { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.d-dash { stroke-dasharray: 5 5; }
.d-arrowhead { fill: var(--muted); }
.d-tag rect { stroke: none; }
.d-tag text { font-size: 12px; font-weight: 700; fill: #fff; }
.d-tag-c rect { fill: var(--accent); }
.d-tag-a rect { fill: var(--sel); }
.d-space { fill: var(--bg); stroke: var(--line); }
.d-dot circle { stroke: #fff; stroke-width: 2; }
.d-animal circle { fill: var(--accent); }
.d-human circle { fill: var(--sel); }
.d-mid { fill: var(--muted); }
.try { margin-top: 44px; }
.trybox { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.trybox img { width: 100%; max-width: 360px; aspect-ratio: 1; border-radius: 10px; display: block; margin: 0 auto; }
.trybox .slider { margin-top: 10px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } .doc h2 { font-size: 20px; } }

.credits { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.7; }
.credits p { margin: 4px 0; }
.credits a { color: var(--accent); }
@media (max-width: 640px) {
  .stage { grid-template-columns: 1fr; }
  .pick { flex-direction: row; overflow-x: auto; }
  .pick button { flex: 0 0 64px; }
  .slider { grid-template-columns: 56px 1fr 56px; }
}
