:root { --ink: #efece3; --dim: #85827a; --line: #2b2b2e;
  --mincho: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans", sans-serif; --pad: clamp(16px, 2.8vw, 44px); }
* { box-sizing: border-box; }
html { background: #000; color: var(--ink); }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; font-family: var(--mincho); -webkit-font-smoothing: antialiased; overflow: hidden; }

/* ヘッダー: 1行、欧文サンセリフのみ */
.bar { display: flex; align-items: baseline; gap: 36px; padding: 16px var(--pad) 0; font: 500 10.5px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.site { color: var(--ink); text-decoration: none; }
#crumbs { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#crumbs span + span::before { content: "/"; margin: 0 .9em; opacity: .5; }
#crumbs span:last-child { color: #bdb9af; }
#code { color: var(--ink); letter-spacing: .14em; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(24px, 4vw, 64px); padding: clamp(18px, 3.2vh, 36px) var(--pad) var(--pad); }

/* 左: タイトル → 本文 */
.text { display: flex; flex-direction: column; min-height: 0; padding-left: clamp(0px, 5.5vw, 96px); container-type: inline-size; }
#title { margin: 0 0 .28em; font-weight: 200; font-size: clamp(40px, 17cqi, 128px); line-height: 1.14; letter-spacing: .01em; font-feature-settings: "palt"; word-break: auto-phrase; text-wrap: balance; }
#title span { display: block; }
#body-wrap { flex: 1; min-height: 0; overflow-y: auto; padding-right: 24px; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #5a5852 transparent;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 72px), transparent); mask-image: linear-gradient(#000 calc(100% - 72px), transparent); }
#lead { margin: 0 0 1.3em; line-break: strict; word-break: auto-phrase; font-size: clamp(22px, 2.1vw, 30px); font-weight: 300; line-height: 1.6; }
#body { padding-bottom: 96px; line-break: strict; text-wrap: pretty; font-size: 18px; font-weight: 300; line-height: 2; color: #d9d6cc; }
#body p { margin: 0 0 1.4em; text-align: left; word-break: auto-phrase; }
#body h2 { margin: 3em 0 1em; font: 500 10.5px var(--sans); letter-spacing: .2em; color: var(--dim); }
/* 本文中の図 */
#body figure { margin: 2em 0 2.2em; }
#body figure img { display: block; width: 100%; height: auto; }
#body figcaption { margin-top: .8em; font: 12.5px/1.7 var(--sans); color: var(--dim); }
/* 踏み込んだ解説 */
.deep h3 { margin: 2.2em 0 .8em; font-size: 20px; font-weight: 400; line-height: 1.5; color: var(--ink); }
.deep { margin-top: 2.6em; }
.deep h3:first-child { margin-top: 0; }
.formula { margin: 0 0 1.4em; padding: .5em 0 .5em 1.2em; border-left: 1px solid #5a5852; font: italic 21px/1.7 "Times New Roman", Times, serif; color: var(--ink); overflow-x: auto; white-space: nowrap; word-break: normal; }
#body ol { margin: 0; padding-left: 1.5em; font: 12px/1.75 var(--sans); color: #8f8c84; }
#body li { margin-bottom: .6em; }
#body li a { color: #c9c6bc; text-decoration: none; border-bottom: 1px solid #5a5852; transition: color .2s, border-color .2s; }
#body li a:hover { color: #fff; border-bottom-color: #fff; }
#body .note { margin: 1.6em 0 0; font: 11.5px/1.7 var(--sans); letter-spacing: .04em; color: var(--dim); text-align: left; }
#body .note a { color: #c9c6bc; text-decoration: none; border-bottom: 1px solid #5a5852; letter-spacing: .18em; }
#body li a i { font-style: normal; margin-left: .4em; color: var(--dim); }
.term { border-bottom: 1px solid #5a5852; transition: color .2s, border-color .2s; }
.term.live { cursor: pointer; border-bottom-color: var(--ink); }
.term.hot { color: #fff; border-bottom-color: #fff; }

/* 右: 角版 → タグ */
.figure { display: flex; flex-direction: column; gap: clamp(16px, 3vh, 30px); min-height: 0; align-items: flex-start; }
#plate { aspect-ratio: 1; width: var(--plate, 520px); flex: none; } /* --plate は article.js が画面の高さから決める */
#plate canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; cursor: crosshair; }

#tags { position: relative; flex: none; display: flex; justify-content: flex-start; align-items: center; gap: clamp(16px, 2.1vw, 30px); }
#cables { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#cables path { fill: none; stroke-width: 1.2; stroke-linecap: round; opacity: .85; transition: opacity .2s, stroke-width .2s; }
.col { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: clamp(5px, 1vh, 9px); }
.tag { position: relative; padding: 3px 8px 4px; background: #000; border: 1px solid #8d8a82; border-radius: 7px; color: #b9b6ad; font: 400 10px/1.4 var(--sans); letter-spacing: .02em; white-space: nowrap; cursor: default; transition: opacity .2s, border-color .2s, color .2s; }
.tag::before, .tag::after { content: ""; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -3.5px; border-radius: 50%; background: #000; border: 1px solid #c9c6bc; }
.tag::before { left: -4px; } .tag::after { right: -4px; }
.tag.live { color: var(--ink); border-color: var(--ink); cursor: pointer; }
.tag.current { background: var(--ink); border-color: var(--ink); color: #000; font-weight: 600; }
.tag.hot:not(.current) { color: #fff; border-color: #fff; }

.has-hot .tag:not(.near) { opacity: .3; }
.has-hot #cables path:not(.hot) { opacity: .12; }
#cables path.hot { stroke-width: 1.6; opacity: 1; }

/* 狭い画面: 1カラムで上から タイトル → 図 → タグ → 本文 */
@media (max-width: 1080px) {
  body { height: auto; overflow: visible; display: block; }
  .bar { gap: 16px; } #crumbs span:not(:last-child) { display: none; } #crumbs span::before { display: none; }
  main { display: flex; flex-direction: column; gap: 24px; }
  .text, .figure { display: contents; } #title { font-size: clamp(40px, 11vw, 96px); } #lead { font-size: 21px; } #body { font-size: 17px; }
  #title { order: 1; margin: 0; } .figure > * { order: 2; } #body-wrap { order: 3; overflow: visible; padding: 0; -webkit-mask-image: none; mask-image: none; }
  #plate { width: 100%; } #tags { align-self: stretch; max-width: 100%; overflow-x: auto; padding: 6px 4px; justify-content: flex-start; gap: 26px; }
}
