/* つくりちらかす山本｜Fable版の試作
   紙と墨と 1px の罫線。動きは「コマ送り」で、なめらかにしない。
   元サイト（pj-bong-pitch/tsukurichirakasu）の見た目の決まりを引き継いでいる。 */

:root {
  --ink: #111111;
  --paper: #f4f2ed;
  --line: #bdb8ad;
  --muted: #77736a;
  --on-ink-2: rgba(244, 242, 237, .72);
  --on-ink-3: rgba(244, 242, 237, .34);

  /* 題・一覧の和文 / 英数字のラベル / 記事の本文 */
  --f-jp: "M PLUS 1", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --f-mono: "DM Mono", "TCY Arrows", "M PLUS 1", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --f-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic Medium", "Yu Gothic", "Noto Sans JP", sans-serif;

  --tick: 37.5ms;            /* 動きの最小単位。BPM100 の 16分音符（150ms）の 1/4 */
  --hd-h: 66px;
  --bar-h: 43px;
  --pad: clamp(18px, 4vw, 64px);
  --rainbow-loop: 520px;
}

/* 山本凡サイトの Fable版と同じ紙と墨にしたときの見え方（山本凡サイトの下の …/tsukurichirakasu/ で開いたとき。切り替えるのは js/enter.js） */
html[data-paper="bon"] {
  --ink: #211f1b;
  --paper: #e8e4d7;
  --line: #bab5a6;
  --muted: #76715f;
  --on-ink-2: rgba(232, 228, 215, .72);
  --on-ink-3: rgba(232, 228, 215, .34);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--hd-h) + var(--bar-h) + 8px);
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-jp);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; border: 0; background: transparent; padding: 0; margin: 0; cursor: pointer; border-radius: 0; -webkit-tap-highlight-color: transparent; }
img, canvas, svg { display: block; max-width: 100%; }
h1, h2, h3, p, figure { margin: 0; }
::selection { background: var(--ink); color: var(--paper); }
.detail ::selection, .viewer ::selection, .monitor ::selection { background: var(--paper); color: var(--ink); }
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.noscript { padding: 40px var(--pad); font-size: 14px; }

/* 英数字の小さなラベルに共通の組み方 */
.hd-name, .win-title, .bar, .item-date, .foot, .detail-meta, .monitor-meta, .viewer-bar {
  font-family: var(--f-mono);
  font-weight: 500;
  text-transform: uppercase;
  font-feature-settings: "zero" 0;
}

/* 押すと、ラベルだけが 2コマで縮む */
.lbl {
  display: inline-block;
  white-space: nowrap;
  transform: scale(1);
  transform-origin: center;
  transition: transform 90ms steps(2, end);
}
.is-pressing > .lbl, .is-pressing > .pin-mark { transform: scale(.84); }

/* ───────── ヘッダー ───────── */
.hd {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--hd-h);
  padding: 0 clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.hd-mark { display: block; position: relative; width: clamp(66px, 7vw, 96px); padding: 6px 0; }
.hd-logo { width: 100%; height: auto; overflow: visible; }
.hd-logo polygon { fill: currentColor; transition: transform 75ms steps(1, end); transform-box: fill-box; transform-origin: center; }
/* 山本凡サイトの下にあるとき（js/main.js が .hd-mark に is-home を付ける）：ロゴを指すと、左に「←」が出る。
   山本凡サイトへ戻る道だと分かるように（ぼんちゃんの案。2026-12-02）。出るときは、2 コマで左へ寄る。
   指しているあいだは、区切りの頭ごとに、左へ 3px、3 コマぶんだけ動く（is-nudge。付け外しは js/main.js） */
.hd-back {
  position: absolute; right: 100%; top: 50%; margin-right: 6px;
  font: 500 15px/1 var(--f-mono);
  visibility: hidden; transform: translate(5px, -50%);
}
@media (hover: hover) {
  .hd-mark.is-home:hover .hd-back { visibility: visible; transform: translate(0, -50%); transition: transform 75ms steps(2, end); }
}
.hd-mark.is-home:focus-visible .hd-back { visibility: visible; transform: translate(0, -50%); }
.hd-mark.is-home .hd-back.is-nudge { transform: translate(-3px, -50%); transition: none; }
.hd-name { font-size: 11px; letter-spacing: .04em; }

/* ───────── 題と、踊る人 ───────── */
.pg { padding: clamp(34px, 5vw, 58px) var(--pad) clamp(80px, 10vw, 130px); }

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 32px;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto clamp(14px, 2.4vw, 26px);
}
.title-line {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: flex-end;
  gap: clamp(10px, 1.5vw, 18px);
}
.intro h1 {
  font-family: var(--f-jp);
  font-weight: 800;
  font-size: clamp(25px, 3.4vw, 46px);
  line-height: 1.12;
  letter-spacing: -.055em;
  white-space: nowrap;
}
/* 題は、このサイトの最初の画面へ戻るリンク。詳細を開いているあいだに指すと、字が「← BACK」に変わる（js/main.js）。
   inline-block … 字を替えているあいだ、幅をもとのままに止めておけるように
   font-family … 題の書体（M PLUS 1）には「←」が入っていないので、矢印だけ、このサイトの矢印の書体（TCY Arrows）で出す。
                 入れておかないと、矢印が、見る人の端末の書体で出て、端末ごとに形が変わる */
.intro h1 a { display: inline-block; font-family: "TCY Arrows", var(--f-jp); }

.dancer {
  --pixel: clamp(2px, .22vw, 3px);
  position: relative;
  width: calc(var(--pixel) * 9);
  height: calc(var(--pixel) * 13);
  margin-bottom: calc(var(--pixel) * 1.6);
  flex: 0 0 auto;
  color: var(--ink);
  animation: dancerHop 750ms steps(2, end) infinite;
}
.dancer span { position: absolute; display: block; background: currentColor; }
.d-head { left: calc(var(--pixel) * 3); top: 0; width: calc(var(--pixel) * 3); height: calc(var(--pixel) * 3); }
.d-body { left: calc(var(--pixel) * 4); top: calc(var(--pixel) * 3); width: var(--pixel); height: calc(var(--pixel) * 5); }
.d-arm { top: calc(var(--pixel) * 4); width: calc(var(--pixel) * 4); height: var(--pixel); animation: dancerArms 750ms steps(2, end) infinite; }
.d-arm-l { left: calc(var(--pixel) * 1); transform-origin: right center; }
.d-arm-r { right: calc(var(--pixel) * 1); transform-origin: left center; animation-name: dancerArmsR; }
.d-leg { top: calc(var(--pixel) * 8); width: var(--pixel); height: calc(var(--pixel) * 4); transform-origin: top center; animation: dancerLegs 750ms steps(2, end) infinite; }
.d-leg-l { left: calc(var(--pixel) * 3); }
.d-leg-r { right: calc(var(--pixel) * 3); animation-name: dancerLegsR; }

/* 詳細を開いているあいだは横にステップ */
body.is-detail .dancer { animation: dancerSide 675ms steps(4, end) infinite; }
body.is-detail .d-arm { animation: dancerDetailArms 675ms steps(4, end) infinite; }
body.is-detail .d-arm-r { animation-name: dancerDetailArmsR; }
body.is-detail .d-leg-l { animation: dancerDetailLegs 675ms steps(4, end) infinite; }
body.is-detail .d-leg-r { animation: dancerDetailLegsR 675ms steps(4, end) infinite; }

/* 組み替えのあいだは、手を上げたまま細かく跳ねる */
body.is-working .dancer { animation: dancerHop 150ms steps(2, end) infinite; }
body.is-working .d-arm { animation: none; transform: rotate(-58deg); }
body.is-working .d-arm-r { transform: rotate(58deg); }
body.is-working .d-leg { animation-duration: 150ms; }

/* ───────── 窓 ───────── */
.win {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.win-title {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0 12px;
  min-height: 43px;
  padding: 0 16px;
  border-bottom: 1px solid var(--ink);
  font-size: 12px;
}
.win-name { flex: 0 0 auto; letter-spacing: .01em; }
/* 名前のあとの点線。本数は、いま並んでいるログの数（JS が入れる） */
.win-dash {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: 0;
  color: var(--ink);
}
.win-dash b { font-weight: inherit; background: var(--ink); color: var(--ink); }
.win-status { display: flex; align-items: center; margin-left: auto; flex: 0 0 auto; }
.sound { position: relative; margin-right: 14px; padding: 1px 3px 2px; font-weight: 500; }
.sound, .bar button { transition: background-color 90ms steps(2, end), color 90ms steps(2, end); }
.sound.is-active { background: var(--ink); color: var(--paper); }
.mode { display: inline-flex; align-items: center; white-space: nowrap; }
.mode::before { content: ""; align-self: center; width: 1px; height: 16px; margin-right: 14px; background: var(--ink); opacity: .42; }
.mode.is-swapping { min-width: 11ch; justify-content: flex-end; }

/* ───────── 道具の帯 ───────── */
.bar {
  position: sticky;
  z-index: 30;
  top: var(--hd-h);
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  font-size: 11px;
}
/* 帯が上に貼りついているあいだも、上の線が切れないように */
.bar::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--ink); pointer-events: none; }
.bar-browse { display: flex; flex-wrap: wrap; gap: 0 18px; min-height: var(--bar-h); }
.grp { position: relative; display: flex; align-items: stretch; }
.bar-browse button { position: relative; padding: 12px 16px; min-height: var(--bar-h); }

.grp-view { border-right: 1px solid var(--ink); }
.grp-view button { width: 62px; padding-inline: 0; text-align: center; border-right: 1px solid var(--ink); }
.grp-view button:last-child { border-right: 0; }
.grp-view button.is-active { background: var(--ink); color: var(--paper); }

.grp-date button, .grp-type button, .grp-loose button { min-width: 0; padding-inline: 2px; }
.grp-type button + button { margin-left: 10px; }
.grp-date .lbl, .grp-type .lbl, .grp-loose .lbl { padding: 1px 3px 2px; }
.grp-date button.is-active .lbl, .grp-type button.is-active .lbl { background: var(--ink); color: var(--paper); }
.grp-type button sup { font-size: .82em; vertical-align: baseline; margin-left: .35em; opacity: .55; }

.grp-pin { margin-left: auto; margin-right: 12px; }
.grp-pin::before { content: ""; align-self: center; width: 1px; height: calc(100% - 16px); margin-right: 14px; background: var(--ink); opacity: .42; }
.grp-pin button { display: inline-flex; align-items: center; gap: 7px; padding-inline: 13px; font-size: 12px; }
.pin-mark { width: 7px; height: 7px; border: 1px solid currentColor; background: transparent; transition: transform 90ms steps(2, end); }
.grp-pin button.is-active .pin-mark { background: currentColor; }

@media (hover: hover) {
  .win.is-live .sound:hover, .win.is-live .grp-view button:hover { background: var(--ink); color: var(--paper); }
  .win.is-live .grp-date button:hover .lbl, .win.is-live .grp-type button:hover .lbl, .win.is-live .grp-loose button:hover .lbl { background: var(--ink); color: var(--paper); }
  .win.is-live .grp-pin button:hover .pin-mark { background: currentColor; }
  .bar-detail button:hover .lbl { background: var(--ink); color: var(--paper); }
}
.win:not(.is-live) .bar-browse, .win:not(.is-live) .win-status { pointer-events: none; }
.win:not(.is-live) .bar-browse button, .win:not(.is-live) .sound { cursor: default; }

/* 詳細を開いているあいだの帯 */
.bar-detail { display: flex; align-items: stretch; justify-content: space-between; min-height: var(--bar-h); }
.bar-detail button { padding: 12px 16px; min-height: var(--bar-h); }
.bar-detail .lbl { padding: 1px 3px 2px; }
.bar-detail .back { font-size: 12px; }
.step { display: flex; align-items: center; }
.step button { padding-inline: 8px; }
.step button[disabled] { opacity: .3; cursor: default; pointer-events: none; }
.pos { padding: 0 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-detail .step { margin-right: 6px; }

/* ───────── 中身 ───────── */
.body {
  position: relative;
  min-height: var(--stable-h, 320px);
  background: var(--paper);
}
.stack {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-content: start;
}
.filler { display: none; background: var(--paper); }
.stack.is-measuring .filler { display: none !important; }
/* 高さを測るあいだだけ、指して開いている行をたたむ */
.win.is-measuring .item .item-media { height: 0 !important; margin: 0 !important; border-width: 0 !important; transition: none !important; }
.win.is-measuring[data-view="card"] .item p { max-height: 0 !important; margin-top: 0 !important; transition: none !important; }

.item {
  position: relative;
  display: grid;
  min-height: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  cursor: pointer;
  outline-offset: -2px;
  transition: background-color 120ms steps(2, end), color 120ms steps(2, end);
  -webkit-touch-callout: none;
}
.item > * { transition: opacity 140ms steps(2, end), transform 140ms steps(2, end); }
.item.is-out { display: none !important; }
.win.is-live .item.is-hot:focus-visible { outline: none; }

.item-date { position: relative; font-size: 11px; line-height: 1.4; letter-spacing: .01em; white-space: nowrap; }
.item h2 { font-family: var(--f-jp); font-weight: 700; font-size: clamp(13px, 1.22vw, 18px); line-height: 1.22; letter-spacing: -.012em; font-feature-settings: "palt"; }
.item h2 em { font-family: var(--f-mono); font-size: .72em; font-style: normal; font-weight: 500; letter-spacing: 0; opacity: .66; margin-left: .5em; font-feature-settings: normal; }
.item p { font-family: var(--f-jp); font-size: 12px; font-weight: 500; line-height: 1.48; }
.item-media { overflow: hidden; border: 0 solid currentColor; }
/* 絵は決まった大きさの箱に入れておき、外側の枠が開いて見せる（開いている途中で絵の切り取りが変わらないように） */
.item-media-in { position: relative; width: 100%; height: var(--pv-h, 100%); }
.item-media img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.12); }
.item.is-color .item-media img { filter: none; }
.item-mosaic { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.item-tile { display: none; }

/* 指した行は墨に返る。ピンどめした行は虹になる */
.win.is-live .item.is-hot { background: var(--ink); color: var(--paper); }
.win.is-live .item.is-hot .item-date, .win.is-live .item.is-hot h2 em { opacity: .72; }
.win.is-live .item[data-kind="pin"].is-hot,
.monitor.is-pin,
.detail-rainbow,
.lab-wave-rainbow,
.win-note .win-note-btn {
  background: repeating-linear-gradient(105deg,
    hsl(338 100% 64%) 0, hsl(10 100% 62%) 42px, hsl(35 100% 60%) 84px, hsl(56 100% 66%) 126px,
    hsl(104 78% 58%) 174px, hsl(154 74% 54%) 222px, hsl(188 88% 57%) 270px, hsl(220 100% 64%) 328px,
    hsl(262 96% 68%) 386px, hsl(300 96% 67%) 450px, hsl(338 100% 64%) var(--rainbow-loop));
  background: repeating-linear-gradient(105deg in oklch,
    oklch(72% .25 18) 0, oklch(75% .24 38) 42px, oklch(82% .21 62) 84px, oklch(90% .18 94) 126px,
    oklch(78% .22 138) 174px, oklch(76% .20 170) 222px, oklch(80% .18 205) 270px, oklch(70% .23 255) 328px,
    oklch(73% .24 295) 386px, oklch(74% .25 330) 450px, oklch(72% .25 378) var(--rainbow-loop));
  background-size: var(--rainbow-loop) 100%;
  color: var(--ink);
  animation: rainbowFlow 2100ms linear infinite;
}
.win.is-live .item[data-kind="pin"].is-hot .item-date, .win.is-live .item[data-kind="pin"].is-hot h2 em { opacity: 1; }

/* 文字化けのコマ */
.is-scrambling { letter-spacing: inherit; transition: none !important; white-space: nowrap; }
.slot { display: inline-block; text-align: center; vertical-align: baseline; white-space: pre; width: 1em; }
.slot.is-narrow { width: .58em; }
.slot.is-mark { width: .4em; }
.slot.is-space { width: .34em; }
.slot.is-empty { color: transparent; }
.slot.is-mask { font-size: .88em; }
.slot.is-blackout { width: auto; min-width: 0; background: currentColor; -webkit-text-fill-color: transparent; text-align: inherit; }
.item-date .slot.is-narrow, .item p .slot.is-narrow, .mode .slot.is-narrow, .pos .slot.is-narrow, .detail-meta .slot.is-narrow { width: .6em; }

/* ── LIST ── */
.win[data-view="list"] .stack {
  /* 罫線は「行と行の 1px のすきまから、下の墨が見える」方式（元サイトと同じ。1px 未満にすると環境によって消える） */
  gap: 1px 0;
  background: var(--ink);
}
.win[data-view="list"] .item {
  grid-template-columns: 0 minmax(104px, 116px) minmax(0, 1.08fr) minmax(380px, 1fr);
  align-items: baseline;
  align-content: center;
  gap: 4px 8px;
  min-height: 42px;      /* 行の高さを整数にしておく（端数があると、罫線の太さが環境によってばらつく） */
  padding: 7px 12px;
}
.win[data-view="list"] .item-date { grid-column: 2; align-self: baseline; }
.win[data-view="list"] .item[data-kind="pin"]::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 5px;
  width: 2.5px;
  height: 23px;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 2.5px 10px no-repeat,
    linear-gradient(currentColor, currentColor) 0 13px / 2.5px 10px no-repeat;
  transform: translateY(-50%);
}
.win[data-view="list"] .item h2 { grid-column: 3; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win[data-view="list"] .item p { grid-column: 4; grid-row: 1; align-self: baseline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win[data-view="list"] .item-desc-line { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: top; white-space: nowrap; }
/* はみ出すひとことは、指しているあいだ横に流す */
.win[data-view="list"].is-live .item.is-hot p.is-overflowing .item-desc-line {
  max-width: none;
  overflow: visible;
  padding-right: 3ch;
  text-overflow: clip;
  animation: descTicker var(--ticker-duration, 5s) linear infinite;
}
.win[data-view="list"] .item-media-in { --pv-h: 144px; }
.win[data-view="card"] .item-media-in { --pv-h: 56px; }
.win[data-view="list"] .item-media {
  grid-column: 3 / span 2;
  grid-row: 2;
  width: min(100%, 260px);
  height: 0;
  margin: 0;
  opacity: 0;
  transform: translateY(-7px) scaleY(.7);
  transform-origin: top;
  transition:
    height 360ms cubic-bezier(.18, .9, .12, 1),
    margin 360ms cubic-bezier(.18, .9, .12, 1),
    opacity 120ms steps(2, end),
    transform 360ms cubic-bezier(.18, .9, .12, 1);
}
.win[data-view="list"].is-live .item.is-hot .item-media {
  height: 146px;
  margin: 8px 0 4px;
  border-width: 1px;
  opacity: 1;
  transform: none;
}

/* ── CARD ── */
.win[data-view="card"] .stack {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(132px, auto);
  gap: 1px;
  background: var(--ink);
}
.win[data-view="card"] .filler { display: block; }
.win[data-view="card"] .item { display: flex; min-height: 132px; flex-direction: column; padding: 10px; }
.win[data-view="card"] .item::before {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 4px;
  border: 1px solid currentColor;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}
.win[data-view="card"] .item[data-kind="pin"]::before { content: "PINNED"; }
.win[data-view="card"] .item-date { display: block; margin-bottom: auto; padding-right: 50px; font-size: 10px; letter-spacing: .02em; }
.win[data-view="card"] .item h2 { margin: 26px 0 0; font-size: clamp(11px, .94vw, 14px); line-height: 1.34; overflow-wrap: anywhere; }
.win[data-view="card"] .item h2 em { display: none; }
.win[data-view="card"] .item h2.is-scrambling { white-space: normal; }
.win[data-view="card"] .item p {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  line-height: 1.46;
  transform: translateY(7px);
  transition:
    max-height 320ms cubic-bezier(.18, .9, .12, 1),
    margin 320ms cubic-bezier(.18, .9, .12, 1),
    opacity 120ms steps(2, end),
    transform 320ms cubic-bezier(.18, .9, .12, 1);
}
.win[data-view="card"] .item-media {
  width: 100%;
  height: 0;
  margin: 0;
  opacity: 0;
  transform: translateY(7px) scaleY(.75);
  transform-origin: bottom;
  transition:
    height 320ms cubic-bezier(.18, .9, .12, 1),
    margin 320ms cubic-bezier(.18, .9, .12, 1),
    opacity 120ms steps(2, end),
    transform 320ms cubic-bezier(.18, .9, .12, 1);
}
.win[data-view="card"].is-live .item.is-hot p { max-height: 90px; margin-top: 12px; opacity: 1; transform: none; }
.win[data-view="card"].is-live .item.is-hot .item-media { height: 58px; margin: 12px 0 0; border-width: 1px; opacity: 1; transform: none; }

/* ── LOOSE（散らかした状態） ── */
.win[data-view="loose"] .stack { display: block; height: var(--loose-h, 900px); overflow: hidden; touch-action: pan-y; }
.win[data-view="loose"] .item {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: var(--w, 160px);
  padding: 0;
  border: 1px solid var(--ink);
  transform: translate(var(--x, 0px), var(--y, 0px));
  z-index: var(--z, 1);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-y;
}
.win[data-view="loose"] .item.is-dragging { cursor: grabbing; touch-action: none; }
.win[data-view="loose"] .item-pv, .win[data-view="loose"] .item p, .win[data-view="loose"] .item h2 em { display: none; }
.win[data-view="loose"] .item-tile { display: block; }
/* 札は小さな窓の形：上に日付と題、その下に絵 */
.win[data-view="loose"] .item-date { display: block; padding: 5px 20px 0 7px; font-size: 9.5px; }
.win[data-view="loose"] .item h2 { padding: 1px 7px 6px; font-size: 11px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win[data-view="loose"] .item-media { width: 100%; border-top-width: 1px; background: var(--paper); }
.win[data-view="loose"] .item-media-in { height: auto; aspect-ratio: var(--ar, 1.5); }
.win[data-view="loose"] .item-media img { pointer-events: none; }
.win[data-view="loose"] .item.is-dragging .item-media img { filter: none; }
.win[data-view="loose"] .item.is-dragging { background: var(--ink); color: var(--paper); }
.win[data-view="loose"] .item[data-kind="pin"]::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: currentColor;
}
/* 散らかしなおすときは、新しい場所へコマ送りで飛ぶ */
.win[data-view="loose"] .item.is-flying { transition: transform 225ms steps(5, end); }

/* ── 組み替えのあいだ ── */
.win.is-redrawing .item { transition: none; }
.win.is-redrawing .stack { background: transparent; }
.win.is-redrawing[data-view="loose"] .item { border-color: transparent; }
.win.is-line-committing[data-view="list"] .stack,
.win.is-line-committing[data-view="card"] .stack { background: var(--ink); }
.win.is-line-committing[data-view="loose"] .item { border-color: var(--ink); }
.win.is-redrawing .filler { background: transparent; }
.win.is-line-committing .filler { background: var(--paper); }

/* 線が点線にほどけて消え、点線で引き直されて、実線に確定する */
.item::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.win.is-redrawing[data-view="list"] .item::after {
  background: repeating-linear-gradient(90deg, currentColor 0 7px, transparent 7px 11px) left bottom / 100% 1px no-repeat;
}
.win.is-redrawing[data-view="card"] .item::after {
  background:
    repeating-linear-gradient(90deg, currentColor 0 7px, transparent 7px 11px) left bottom / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, currentColor 0 7px, transparent 7px 11px) left top / 1px 100% no-repeat;
}
.win.is-redrawing[data-view="loose"] .item::after {
  background:
    repeating-linear-gradient(90deg, currentColor 0 7px, transparent 7px 11px) left top / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 7px, transparent 7px 11px) left bottom / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, currentColor 0 7px, transparent 7px 11px) left top / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, currentColor 0 7px, transparent 7px 11px) right top / 1px 100% no-repeat;
}
.win.is-lines-dash-out .item::after { opacity: 1; animation: lineDashOut 337ms steps(6, end) both; animation-delay: calc(var(--i, 0) * var(--stagger, 9ms)); }
.win.is-redraw-empty .item::after { opacity: 0; animation: none; }
.win.is-lines-dash-in .item::after { opacity: 1; animation: lineDashIn 225ms steps(6, end) both; animation-delay: calc(var(--i, 0) * var(--stagger, 9ms)); }
.win.is-redrawing.is-line-committing .item::after { opacity: 0; animation: none; }

.item.is-absent > * { opacity: 0 !important; }
.item.is-dissolved .item-media { opacity: .08; transform: translateX(8px); }
.win.is-rebuilding .item > * { animation: none; opacity: 1; transform: none; }
.win.is-rebuilding[data-view="list"] .item-media, .win.is-rebuilding[data-view="card"] .item-media { opacity: 0; }
.win.is-rebuilding[data-view="loose"] .item-media { animation: tileIn 300ms steps(4, end) both; animation-delay: calc(var(--i, 0) * var(--stagger, 9ms)); }

.win.is-filtering .item {
  transition:
    height 220ms cubic-bezier(.2, .8, .18, 1),
    padding 220ms cubic-bezier(.2, .8, .18, 1),
    opacity 160ms steps(3, end),
    background-color 120ms steps(2, end),
    color 120ms steps(2, end);
}
.item.is-folding { overflow: hidden; pointer-events: none; }
.item.is-enter { animation: filterEnter 260ms steps(5, end) both; }

/* 一覧より短くなったときの、いちばん下の線 */
.win.is-short:not(.is-redrawing):not([data-view="loose"]) .stack { padding-bottom: 1px; }

/* ───────── 窓のいちばん下の帯 ───────── */
.foot {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 6px 18px;
  flex-wrap: wrap;
  padding: 9px 16px 10px;
  border-top: 1px solid var(--ink);
  font-size: 10.5px;
  letter-spacing: .02em;
  color: var(--ink);
}
.foot-count { font-variant-numeric: tabular-nums; }
.foot-hint { color: var(--muted); }
@media (hover: none) { .foot-hint { display: none; } }

/* ───────── 詳細 ───────── */
.cover {
  position: absolute;
  z-index: 12;
  inset: 0;
  background: var(--ink);
  pointer-events: none;
  visibility: hidden;
}
.cover.is-on { visibility: visible; }

.detail {
  position: relative;
  z-index: 10;
  min-height: 62svh;
  padding: clamp(22px, 3.2vw, 42px) clamp(18px, 3.2vw, 42px) clamp(40px, 5vw, 72px);
  background: var(--ink);
  color: var(--paper);
  cursor: default;
}
.win.is-detail-open .stack { display: none; }
.win.is-detail-open .body { min-height: 0; }

.detail-rainbow { position: absolute; left: 0; right: 0; top: 0; height: 4px; }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: clamp(10px, 2.4vw, 30px) 0 18px;
  color: var(--on-ink-2);
  font-size: 12px;
}
.detail-title {
  max-width: 940px;
  margin: 0 0 clamp(28px, 4vw, 56px);
  font-family: var(--f-jp);
  font-weight: 800;
  font-size: clamp(27px, 4.9vw, 66px);
  line-height: 1.1;
  letter-spacing: -.045em;
  font-feature-settings: "palt";
  overflow-wrap: anywhere;
  line-break: strict;
}
.detail-title.is-scrambling { white-space: normal; }

.detail-stack { display: grid; max-width: 960px; gap: clamp(26px, 3.4vw, 46px); }
.sec { display: grid; gap: 16px clamp(20px, 3vw, 40px); align-items: start; min-width: 0; }
.sec-text { display: grid; gap: 1.05em; min-width: 0; max-width: 37em; }
.detail-body {
  font-family: var(--f-body);
  font-size: clamp(14px, 1.3vw, 16px);
  font-weight: 300;
  line-height: 1.95;
  letter-spacing: .02em;
  overflow-wrap: anywhere;
}
.detail-body a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; word-break: break-all; transition: opacity 120ms steps(2, end); }
.detail-body a:hover, .detail-body a:focus-visible { opacity: .62; }

/* 絵とひとことを横に並べる（広い画面で、ひとことが短いとき） */
@media (min-width: 900px) {
  .sec.is-pair { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); }
  .sec.is-pair .sec-text { padding-top: 2px; }
  .sec.is-pair .sec-text::before { content: ""; display: block; width: 28px; height: 1px; margin-bottom: 4px; background: var(--on-ink-3); }
}
.sec-run { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; align-items: start; }
.sec-run .media { width: 100%; }

.media {
  position: relative;
  width: min(100%, var(--mw, 640px));
  border: 1px solid currentColor;
  background: rgba(244, 242, 237, .08);
}
.media-open { display: block; width: 100%; cursor: zoom-in; }
.media-shell { position: relative; overflow: hidden; aspect-ratio: var(--ar, 1.777); }
.media-shell > img { width: 100%; height: 100%; object-fit: cover; opacity: .88; filter: grayscale(1) contrast(1.12); }
.media.is-done .media-shell > img { opacity: 1; filter: none; }
.media-mosaic { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.media figcaption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 9px;
  border-top: 1px solid currentColor;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--on-ink-2);
}
.media figcaption span:last-child { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.media.is-hero { --mw: 960px; }

/* 動画：押すまでは外につながらない。枠だけ先に見せる */
.video { position: relative; width: min(100%, 640px); border: 1px solid currentColor; }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  width: 100%;
  color: var(--paper);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  background:
    repeating-linear-gradient(90deg, var(--on-ink-3) 0 7px, transparent 7px 11px) left 50% / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, var(--on-ink-3) 0 7px, transparent 7px 11px) 50% top / 1px 100% no-repeat,
    var(--ink);
}
.video-play i { display: block; width: 46px; height: 46px; border: 1px solid currentColor; background: var(--ink); position: relative; transition: background-color 90ms steps(2, end); }
.video-play i::after { content: ""; position: absolute; left: 50%; top: 50%; border-left: 13px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; transform: translate(-36%, -50%); }
.video-play span { padding: 1px 4px 2px; background: var(--ink); }
.video-play:hover i, .video-play:focus-visible i { background: var(--paper); color: var(--ink); }
.video figcaption { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px 9px; border-top: 1px solid currentColor; font-family: var(--f-mono); font-size: 11px; font-weight: 500; line-height: 1.35; text-transform: uppercase; color: var(--on-ink-2); }

/* 外へのリンク */
.detail-links { display: grid; width: min(100%, 620px); gap: 9px; }
.detail-links a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 43px;
  border: 1px solid var(--paper);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  overflow: hidden;
  transition: background-color 100ms steps(2, end), color 100ms steps(2, end), transform 120ms steps(2, end);
}
.detail-links a span:first-child { display: flex; align-items: center; align-self: stretch; padding: 0 12px; background: var(--ink); color: var(--paper); white-space: nowrap; transition: background-color 100ms steps(2, end), color 100ms steps(2, end); }
.detail-links a span:first-child::before { content: ">"; margin-right: .42em; }
.detail-links a span:last-child { min-width: 0; padding: 0 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-links a:hover, .detail-links a:focus-visible { background: var(--ink); color: var(--paper); transform: translateX(3px); }
.detail-links a:hover span:first-child, .detail-links a:focus-visible span:first-child { background: var(--paper); color: var(--ink); }

/* 近いログ */
.detail-related { max-width: 960px; margin: clamp(40px, 6vw, 84px) 0 0; padding-top: 16px; border-top: 1px solid var(--on-ink-3); }
.detail-related-head, .detail-loose { font-family: var(--f-mono); font-size: 12px; font-weight: 500; text-transform: uppercase; color: var(--on-ink-2); }
.rel-list { display: grid; margin: 14px 0 22px; border-top: 1px solid var(--on-ink-3); }
.rel {
  display: grid;
  grid-template-columns: minmax(96px, 116px) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 8px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--on-ink-3);
  transition: background-color 120ms steps(2, end), color 120ms steps(2, end);
}
.rel span:first-child { font-family: var(--f-mono); font-size: 11px; font-weight: 500; }
.rel span:nth-child(2) { font-weight: 700; font-size: clamp(13px, 1.2vw, 16px); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel span:last-child { font-family: var(--f-mono); font-size: 11px; font-weight: 500; opacity: .66; }
.rel:hover, .rel:focus-visible { background: var(--paper); color: var(--ink); }

/* 詳細の中身は、開いたときに上から順にコマ送りで出る */
.detail.is-entering .detail-stack > *, .detail.is-entering .detail-related { animation: blockIn 150ms steps(2, end) both; animation-delay: calc(var(--n, 0) * 37.5ms + 150ms); }
.detail.is-leaving > * { animation: blockOut 112ms steps(2, end) both; }

/* ───────── スマホ：読み取り位置に来た行の絵を出す小さなモニター ───────── */
body.has-monitor .pg { padding-bottom: 170px; }
.monitor {
  position: fixed;
  z-index: 35;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 46%) minmax(0, 1fr);
  background: var(--ink);
  color: var(--paper);
  border-top: 1px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(101%);
  transition: transform 150ms steps(4, end);
  pointer-events: none;
}
.monitor.is-on { transform: none; }
/* 幅のある画面（タブレットなど）では、右下に小さく置く */
@media (min-width: 600px) {
  .monitor { left: auto; right: 0; width: 440px; border-left: 1px solid var(--ink); }
}
.monitor-img { aspect-ratio: 16 / 9; overflow: hidden; background: var(--ink); border-right: 1px solid currentColor; }
.monitor-img img { width: 100%; height: 100%; object-fit: cover; }
.monitor-txt { display: grid; align-content: space-between; gap: 6px; min-width: 0; padding: 9px 11px 10px; }
.monitor-meta { font-size: 10px; display: flex; justify-content: space-between; gap: 8px; }
.monitor-desc { font-family: var(--f-jp); font-size: 11.5px; font-weight: 500; line-height: 1.5; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }

/* ───────── 画像を大きく見る ───────── */
.viewer { position: fixed; z-index: 60; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--ink); color: var(--paper); }
.viewer.is-entering { animation: viewerIn 150ms steps(4, end) both; }
.viewer-bar { display: flex; align-items: stretch; justify-content: space-between; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--on-ink-3); font-size: 11px; }
.viewer-bar button { padding: 12px 16px; }
.viewer-bar .lbl { padding: 1px 3px 2px; }
.viewer-bar button:hover .lbl, .viewer-bar button:focus-visible .lbl { background: var(--paper); color: var(--ink); }
.viewer-cap { align-self: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--on-ink-2); }
.viewer-stage { display: grid; place-items: center; min-height: 0; padding: clamp(12px, 3vw, 40px); cursor: zoom-out; }
.viewer-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
html.is-locked, html.is-locked body { overflow: hidden; }

/* ───────── コマ送りの動き ───────── */
@keyframes lineDashOut { 0%, 22% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 0 0 100%); } }
@keyframes lineDashIn { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }
@keyframes descTicker { 0% { transform: translateX(0); } 100% { transform: translateX(calc(-1 * var(--ticker-distance, 0px))); } }
@keyframes filterEnter { 0% { opacity: 0; transform: translateY(3px); } 42% { opacity: 1; transform: translateY(0); } 66% { opacity: .76; transform: translateX(1px); } 100% { opacity: 1; transform: none; } }
@keyframes rainbowFlow { 0% { background-position: 0 50%; } 100% { background-position: calc(var(--rainbow-loop) * -1) 50%; } }
@keyframes tileIn { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes blockIn { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: none; } }
@keyframes blockOut { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes viewerIn { 0% { clip-path: inset(50% 0 50% 0); } 100% { clip-path: inset(0 0 0 0); } }

@keyframes dancerHop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(var(--pixel) * -1)); } }
@keyframes dancerArms { 0%, 100% { transform: rotate(-22deg); } 50% { transform: rotate(26deg); } }
@keyframes dancerArmsR { 0%, 100% { transform: rotate(22deg); } 50% { transform: rotate(-26deg); } }
@keyframes dancerLegs { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-20deg); } }
@keyframes dancerLegsR { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(20deg); } }
@keyframes dancerSide {
  0%, 100% { transform: translateY(0) translateX(0); }
  25% { transform: translateY(calc(var(--pixel) * -1)) translateX(calc(var(--pixel) * 1)); }
  50% { transform: translateY(0) translateX(calc(var(--pixel) * 2)); }
  75% { transform: translateY(calc(var(--pixel) * -1)) translateX(calc(var(--pixel) * 1)); }
}
@keyframes dancerDetailArms { 0%, 100% { transform: rotate(-48deg); } 25%, 75% { transform: rotate(18deg); } 50% { transform: rotate(-12deg); } }
@keyframes dancerDetailArmsR { 0%, 100% { transform: rotate(48deg); } 25%, 75% { transform: rotate(-18deg); } 50% { transform: rotate(12deg); } }
@keyframes dancerDetailLegs { 0%, 100% { transform: rotate(28deg); } 25%, 75% { transform: rotate(-8deg); } 50% { transform: rotate(10deg); } }
@keyframes dancerDetailLegsR { 0%, 100% { transform: rotate(-28deg); } 25%, 75% { transform: rotate(8deg); } 50% { transform: rotate(-10deg); } }

/* ───────── 幅ごとの組み方 ───────── */
@media (max-width: 980px) {
  .win[data-view="card"] .stack { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .win[data-view="list"] .item { grid-template-columns: 0 minmax(96px, 108px) minmax(0, 1.08fr) minmax(0, 1fr); }
}

@media (max-width: 720px) {
  :root { --bar-h: 42px; }
  .title-line { align-items: center; }
  .dancer { margin-bottom: 0; }
  /* せまい画面では、スクロールしても、窓の題の行（LOG_STORAGE.DB と Sound）が上に残る。その下に、切り替えの帯が残る
     （前は、帯だけが残って、Sound のスイッチが流れていった。2026-12-03。ぼんちゃんの希望）。44px は、題の行の高さ（43px）と下の線 */
  .win-title { padding: 0 12px; position: sticky; top: var(--hd-h); z-index: 31; background: var(--paper); box-shadow: 0 -1px 0 var(--ink); }
  .bar { top: calc(var(--hd-h) + 44px); }
  html { scroll-padding-top: calc(var(--hd-h) + 44px + var(--bar-h) + 8px); }
  .sound { margin-right: 10px; }
  .mode::before { margin-right: 10px; }
  .bar-browse { gap: 0 12px; }
  .grp-view button { width: 56px; }
  .grp-pin { margin-right: 4px; }
  .grp-pin::before { margin-right: 6px; }
  .grp-type { order: 5; flex: 1 0 100%; border-top: 1px solid var(--ink); padding: 0 12px; overflow-x: auto; }
  .grp-type button + button { margin-left: 6px; }
  .bar-detail button { padding-inline: 12px; }
  .step button { padding-inline: 6px; }
  .pos { padding: 0 4px; }

  .win[data-view="list"] .item { grid-template-columns: 0 minmax(0, 1fr); gap: 1px 8px; min-height: 55px; padding: 9px 12px 10px; }
  .win[data-view="list"] .item-date, .win[data-view="list"] .item h2 { grid-column: 2; grid-row: auto; }
  .win[data-view="list"] .item h2 { font-size: 14.5px; }
  .win[data-view="list"] .item p, .win[data-view="list"] .item-media { display: none; }

  .win[data-view="card"] .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(118px, auto); }
  .win[data-view="card"] .item { min-height: 118px; }
  .win[data-view="card"] .item h2 { font-size: 12.5px; }

  .win[data-view="loose"] .item h2 { font-size: 10.5px; }

  .foot { padding-inline: 12px; }
  .detail-title { letter-spacing: -.035em; }
  .rel { grid-template-columns: minmax(0, 1fr) auto; }
  .rel span:first-child { grid-column: 1 / -1; }
}

@media (max-width: 400px) {
  .hd-name { font-size: 10px; }
  .win-name { font-size: 11px; }
  .win-title { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-delay: 0ms !important; }
  .dancer, .dancer span { animation: none !important; }
}

/* となりのサイトから演出つきで移ってきたとき：最初のひとコマから墨色で覆う（js/enter.js が印を付け、js/transit.js が開ける） */
/* まんなかに、行き先の名前の絵も出しておく（前のページが作った絵を、js/enter.js が渡す。js/transit.js が出す絵と、同じ絵・同じ位置）。
   字ではなく絵にしてあるのは、書体が届いた瞬間に字がずれるのを避けるため。スクロールバーは、はじめから出しておく
   （あとから出ると、そのぶん、まんなかがずれる）。2026-12-03 */
html.is-entering::before {
  content: ""; position: fixed; inset: 0; z-index: 2147483000;
  background: #211f1b var(--enter-label, none) center / var(--enter-label-size, auto) no-repeat;
}
html.is-entering { overflow-y: scroll; }
