/* Stack Map — 白地の「図版」。縦が層、横が「どこで動くか」。選んだ組み合わせだけが色で浮かぶ */
:root {
  --bg: #f4f5f9;
  --paper: #ffffff;
  --ink: #0f172a;
  --ink2: #334155;
  --muted: #64748b;
  --line: #e3e7ef;
  --line2: #eef1f6;
  --any-bg: #fbfbfd;
  --a: #7c3aed;
  --a-soft: #f1eaff;
  --a-ink: #3b0f8c;
  --b: #0d9488;
  --b-soft: #e2f6f3;
  --b-ink: #0b4f49;
  --radius: 10px;
  --band-w: 34px;
  --label-w: 128px;
  --col-min: 104px;
  --any-min: 230px;
  --sans: "IBM Plex Sans JP", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --latin: "IBM Plex Mono", "IBM Plex Sans JP", ui-monospace, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.6; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---- 見出し ---- */
.top { max-width: 1480px; margin: 0 auto; padding: 28px 28px 8px; }
.labs { font-family: var(--latin); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.labs:hover { color: var(--ink); }
.top h1 { font-family: var(--latin); font-size: 40px; line-height: 1.05; letter-spacing: -.02em; margin: 6px 0 8px; }
.top h1 .sub { display: block; margin-top: 6px; font-family: var(--sans); font-size: 14px; font-weight: 700; line-height: 1.4; letter-spacing: 0; color: var(--muted); }
.lead { margin: 0; color: var(--ink2); font-size: 15px; max-width: 46em; }
/* 2 つの地図の切り替え */
.tabs { display: flex; gap: 8px 18px; margin: 4px 0 12px; flex-wrap: wrap; }
.tabs .tg { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; font-size: 13.5px; text-decoration: none; color: var(--ink2); }
.tabs a:hover { border-color: #94a3b8; color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs .tgrp { align-self: center; font-size: 11px; font-weight: 700; color: var(--muted); margin-right: 1px; white-space: nowrap; }
/* 開発の流れから来たとき、関わる層を黄色で */
.rlabel.hl { background: #fef3c7; }
.cell.hl, .cell.any.hl { background: #fffbeb; }
.hl-note { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #fffbeb; border-color: #fde68a; }
.hl-note a { font-weight: 700; color: #1d4ed8; }

/* ---- 組み合わせの一覧 ---- */
.stacks { max-width: 1480px; margin: 0 auto; padding: 14px 28px 0; }
.stacks-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.stacks-head h2 { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin: 0; }
.cmp { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink2); cursor: pointer; user-select: none; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.cmp input { accent-color: var(--b); margin: 0; }
.stack-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.sgroup { min-width: 0; }
.sgroup h3 { margin: 0 0 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.srow { display: flex; flex-wrap: wrap; gap: 8px; }
.src { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; }
.src b { flex: none; font-size: 11px; color: #fff; background: var(--ink2); padding: 2px 8px; border-radius: 6px; }
.src ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.src a { color: #1d4ed8; text-decoration: underline; text-underline-offset: 2px; }
.src a:hover { color: #1e3a8a; }
.stack { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; text-align: left; transition: border-color .15s, background .15s, box-shadow .15s, transform .15s; }
.stack:hover { border-color: #c8cfdc; transform: translateY(-1px); }
.stack .nm { font-weight: 700; font-size: 14px; line-height: 1.25; }
.stack .sb { font-size: 11px; color: var(--muted); display: block; line-height: 1.2; }
.stack .dots { display: inline-flex; gap: 3px; }
.stack .dots i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.stack .tag { font-family: var(--latin); font-size: 11px; font-weight: 700; color: #fff; border-radius: 6px; padding: 1px 6px; }
.stack.on-a { border-color: var(--a); background: var(--a-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 18%, transparent); }
.stack.on-a .tag { background: var(--a); }
.stack.on-b { border-color: var(--b); background: var(--b-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--b) 18%, transparent); }
.stack.on-b .tag { background: var(--b); }
.stack.has-tool { border-style: dashed; border-color: #94a3b8; }
.stack:focus-visible, .chip:focus-visible, .mini:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

/* ---- 説明の帯 ---- */
.info { max-width: 1480px; margin: 14px auto 0; padding: 0 28px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.intro { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.intro h3 { margin: 0 0 6px; font-size: 15px; }
.intro ol { margin: 0; padding-left: 1.3em; color: var(--ink2); }
.legend { display: grid; gap: 8px; font-size: 13px; color: var(--ink2); }
.legend div { display: flex; align-items: center; gap: 10px; }
.lg-chip { display: inline-block; padding: 2px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; border: 1.5px solid var(--a); background: var(--a-soft); color: var(--a-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 18%, transparent); }
.lg-frame { display: inline-block; width: 46px; height: 22px; border-radius: 7px; border: 2.5px solid #4285f4; }
.lg-line { display: inline-block; width: 46px; height: 0; border-top: 2.5px dashed var(--a); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack-card { background: color-mix(in srgb, var(--a) 3.5%, white); border-color: color-mix(in srgb, var(--a) 30%, var(--line)); }
.stack-card.b { background: color-mix(in srgb, var(--b) 4%, white); border-color: color-mix(in srgb, var(--b) 32%, var(--line)); }
.stack-card h3 { margin: 0; font-size: 18px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stack-card h3 small { font-size: 12px; font-weight: 500; color: var(--muted); }
.stack-card .when { margin: 6px 0 4px; font-weight: 700; color: var(--ink2); }
.stack-card .when::before { content: "向いている: "; color: var(--muted); font-weight: 500; }
.stack-card p { margin: 0; color: var(--ink2); }
.places { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.place-pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px 1px 7px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink2); font-weight: 700; }
.place-pill i { width: 9px; height: 9px; border-radius: 3px; display: block; }
.diff { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.diff h4 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.diff h4 b { font-family: var(--latin); font-size: 18px; }
.mini-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mini-chip { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--line2); color: var(--ink2); border: 0; cursor: pointer; }
.mini-chip:hover { background: #e2e8f0; }

/* ---- 地図 ---- */
.mapbar { max-width: 1480px; margin: 14px auto 6px; padding: 0 28px; display: flex; align-items: center; gap: 10px; min-height: 28px; }
.mapbar-note { font-size: 12px; color: var(--muted); }
.mini { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.mapwrap { max-width: 1480px; margin: 0 auto; padding: 0 28px 28px; overflow-x: auto; }
.mapinner { position: relative; min-width: min-content; }
.map { width: 100%; }
.map { display: grid; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.map > div { border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2); }
.corner { background: var(--paper); }
.phead { padding: 10px 10px 8px; background: var(--paper); }
.phead:not(.any) .pn::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.phead .pn { font-family: var(--latin); font-weight: 700; font-size: 13px; line-height: 1.25; display: block; line-break: strict; }
.phead .ps { font-size: 10.5px; color: var(--muted); line-height: 1.3; display: block; margin-top: 2px; }
.phead.any { background: var(--any-bg); }
.phead.lit { background: color-mix(in srgb, var(--c) 9%, white); }
.band { writing-mode: vertical-rl; text-orientation: upright; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--c); background: color-mix(in srgb, var(--c) 7%, white); }
.rlabel { padding: 10px 12px; background: var(--paper); position: sticky; left: 0; z-index: 2; }
.rlabel b { display: block; font-size: 14px; line-height: 1.3; }
.rlabel span { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.c-label span { margin: 0; font-size: 11px; font-weight: 700; }
.cell { padding: 8px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; min-height: 52px; }
.cell.any { background: var(--any-bg); }
.chip { appearance: none; border: 1.5px solid #dbe1ea; background: #fff; border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-weight: 500; line-height: 1.35; cursor: pointer; text-align: left; position: relative; transition: opacity .25s, background .25s, border-color .25s, box-shadow .25s, filter .25s; }
.chip.svc { display: inline-flex; align-items: center; gap: 5px; }
.chip.svc::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.chip { line-break: strict; }
.chip:hover { border-color: #94a3b8; }
.chip.dim { opacity: .3; filter: grayscale(1); }
.chip.dim:hover { opacity: .75; filter: none; }
.chip.on-a { border-color: var(--a); background: var(--a-soft); color: var(--a-ink); font-weight: 700; box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 20%, transparent), 0 4px 14px -4px color-mix(in srgb, var(--a) 60%, transparent); animation: glow-a 1.1s ease-out 1; }
.chip.on-b { border-color: var(--b); background: var(--b-soft); color: var(--b-ink); font-weight: 700; box-shadow: 0 0 0 3px color-mix(in srgb, var(--b) 20%, transparent), 0 4px 14px -4px color-mix(in srgb, var(--b) 60%, transparent); animation: glow-b 1.1s ease-out 1; }
.chip.on-ab { border-color: var(--a) var(--b) var(--b) var(--a); background: linear-gradient(120deg, var(--a-soft) 0 50%, var(--b-soft) 50% 100%); color: var(--ink); font-weight: 700; box-shadow: 0 0 0 2px color-mix(in srgb, var(--a) 25%, transparent), 0 0 0 5px color-mix(in srgb, var(--b) 22%, transparent); }
.chip.picked { outline: 3px solid var(--ink); outline-offset: 2px; }
@keyframes glow-a { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--a) 55%, transparent); } 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 20%, transparent), 0 4px 14px -4px color-mix(in srgb, var(--a) 60%, transparent); } }
@keyframes glow-b { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--b) 55%, transparent); } 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--b) 20%, transparent), 0 4px 14px -4px color-mix(in srgb, var(--b) 60%, transparent); } }
.hidecol { display: none !important; }

/* 枠（同じ場所）と線（〜の上で動く） */
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.frame { position: absolute; border: 2.5px solid var(--c); border-radius: 14px; background: color-mix(in srgb, var(--c) 5%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 12%, transparent); }
.frame.anim { animation: frame-in .35s ease-out 1; }
.frame span { position: absolute; top: -10px; left: 8px; background: var(--c); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 4px 7px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 6px -2px rgba(15, 23, 42, .35); }
.frame.light span { color: #111827; }
@keyframes frame-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.link { fill: none; stroke-width: 2.2; stroke-dasharray: 6 5; stroke-linecap: round; animation: march 1.2s linear infinite; }
@keyframes march { to { stroke-dashoffset: -22; } }

/* ---- 道具の説明（パソコンは右下のカード、スマホは下から出る） ---- */
.sheet { position: fixed; right: 20px; bottom: 20px; width: 380px; max-height: min(70vh, 560px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px -12px rgba(15, 23, 42, .35); padding: 16px 18px 18px; z-index: 30; animation: sheet-in .2s ease-out 1; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sheet .x { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }
.sheet .x:hover { background: var(--line2); color: var(--ink); }
.sheet h3 { margin: 0 34px 2px 0; font-size: 20px; }
.sheet .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; font-size: 12px; }
.sheet .meta span { padding: 1px 8px; border-radius: 999px; background: var(--line2); color: var(--ink2); font-weight: 700; }
.sheet p { margin: 0 0 12px; color: var(--ink2); }
.sheet h4 { margin: 12px 0 6px; font-size: 12px; color: var(--muted); }
.sheet .none { font-size: 12px; color: var(--muted); }

.foot { max-width: 1480px; margin: 0 auto; padding: 0 28px 40px; font-size: 12px; color: var(--muted); }
.foot p { margin: 2px 0; }

/* ---- スマホ ---- */
@media (max-width: 760px) {
  :root { --col-min: 96px; --any-min: 150px; }
  .pc { display: none; }
  .top { padding: 18px 16px 4px; }
  .top h1 { font-size: 30px; }
  .lead { font-size: 13.5px; }
  .stacks { padding: 10px 16px 0; }
  .srow { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
  .srow::-webkit-scrollbar { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin: 4px -16px 12px; padding: 2px 16px 6px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tg { flex: none; flex-wrap: nowrap; }
  .tabs a, .tabs .tgrp { flex: none; }
  .stack { flex: none; }
  .info { padding: 0 16px; }
  .intro, .pair, .diff { grid-template-columns: 1fr; }
  .mapbar { padding: 0 16px; }
  .mapwrap { padding: 0 16px 24px; }
  .band { display: none; }
  /* スマホは層の名前を行の上の帯にして、横幅を地図に回す */
  .map .rlabel { position: static; display: flex; align-items: baseline; gap: 8px; padding: 7px 10px 5px; background: #f6f8fb; border-right: 0; }
  .map .rlabel b { font-size: 12.5px; display: inline; }
  .map .rlabel span { display: inline; margin: 0; font-size: 10.5px; }
  .cell { padding: 6px; gap: 4px; min-height: 40px; }
  .chip { font-size: 12px; padding: 3px 7px; }
  .phead { padding: 8px 8px 6px; }
  .phead .pn { font-size: 12.5px; }
  .sheet { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52vh; border-radius: 16px; }
  .foot { padding: 0 16px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip, .frame, .sheet, .stack { animation: none !important; transition: none !important; }
  .link { animation: none; }
}
.tag-a, .tag-b { font-family: var(--latin); font-size: 12px; font-weight: 700; color: #fff; padding: 1px 7px; border-radius: 6px; align-self: center; }
.tag-a { background: var(--a); }
.tag-b { background: var(--b); }

/* ---- 各タブの一番上の「まずこれだけ」（tools/first.py が入れる） ---- */
.firstlook { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 12px; margin: 12px 0 8px; }
.firstlook h2 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.firstlook h2::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #0d9488; }
.firstlook ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; counter-reset: fl; }
.firstlook li { counter-increment: fl; min-width: 0; }
.firstlook a { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 9px 12px 9px 42px; position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--any-bg); text-decoration: none; color: var(--ink); }
.firstlook a::before { content: counter(fl); position: absolute; left: 12px; top: 10px; width: 20px; height: 20px; border-radius: 50%; background: #0d9488; color: #fff; font: 600 11px/20px var(--latin); text-align: center; }
.firstlook a b { font-size: 13.5px; }
.firstlook a span { font-size: 12px; color: var(--ink2); }
.firstlook a:hover { border-color: #5eead4; background: #f0fdfa; }
.firstlook a:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.firstlook p { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* ---- 発展のタブ: 実務で出てくる所のカードと、たたんだ節（later.js） ---- */
.prgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prcard { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.prcard h3 { margin: 0; font-size: 16px; }
.prwhy { margin: 0; font-size: 13.5px; color: var(--ink2); }
.prcode { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.prcode b { display: block; font-size: 11.5px; padding: 3px 10px; }
.prcode.bad b { background: #fef2f2; color: #b91c1c; }
.prcode.good b { background: #ecfdf5; color: #047857; }
.prcode pre { margin: 0; padding: 9px 12px; background: #0f172a; color: #e2e8f0; font-family: var(--latin); font-size: 12px; line-height: 1.6; overflow-x: auto; }
.prdl { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.prdl div { display: grid; grid-template-columns: 11em minmax(0, 1fr); gap: 10px; background: var(--line2); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.prdl dt { font-weight: 700; }
.prdl dd { margin: 0; color: var(--ink2); }
.prfoot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.prlink, .prsrc, .prhint { margin: 0; font-size: 12.5px; }
.prlink a { color: #1d4ed8; font-weight: 700; text-decoration: none; }
.prlink a:hover { text-decoration: underline; }
.prsrc { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.prsrc b { font-size: 11px; color: #fff; background: var(--ink2); padding: 1px 7px; border-radius: 6px; }
.prsrc a { color: #1d4ed8; text-underline-offset: 2px; }
.prhint { color: var(--muted); }
.laterline { display: flex; align-items: center; gap: 10px; margin: 36px 0 4px; font-size: 13px; color: var(--muted); }
.laterline b { flex: none; font-size: 11px; color: var(--ink2); border: 1.5px dashed #94a3b8; border-radius: 6px; padding: 1px 8px; }
.laterline::after { content: ''; flex: 1; border-top: 1.5px dashed #cbd5e1; }
.fsec.fold { margin: 16px 0 0; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.fsec.fold .fhead p { margin-bottom: 10px; }
.fold-btn { appearance: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; color: var(--ink2); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.fold-btn::after { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.fold-btn[aria-expanded="true"]::after { transform: translateY(2px) rotate(-135deg); }
.fold-btn:hover { border-color: #94a3b8; color: var(--ink); }
.fold-btn:focus-visible, .prlink a:focus-visible, .prsrc a:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.fold-body { margin-top: 14px; }
@media (max-width: 760px) {
  .firstlook ol { grid-template-columns: 1fr; gap: 6px; }
  .prgrid { grid-template-columns: 1fr; }
  .prdl div { grid-template-columns: 1fr; gap: 2px; }
}
