/* UIパターン集（ref ジャンル）の共通スタイル。common/ref_pattern.php の部品に当てる */

/* 型の一覧（目次） */
.ref-index {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px 32px;
    padding: 20px 24px;
    background: var(--bs-tertiary-bg);
}
.ref-index-label {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin-bottom: 6px;
}
.ref-index-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ref-index-list a {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    color: var(--bs-body-color);
    text-decoration: none;
    font-weight: 700;
}
.ref-index-list a:hover { color: var(--bs-primary); }
.ref-index-num,
.ref-pattern-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--bs-primary);
}
.ref-index-num { font-size: 0.85rem; }

/* 型1つ分 */
.ref-pattern {
    padding-top: 48px;
    margin-top: 48px;
    border-top: 3px solid var(--bs-border-color);
    scroll-margin-top: 16px;
}
.ref-pattern:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.ref-pattern-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}
.ref-pattern-num {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.ref-pattern-group {
    display: block;
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}
.ref-pattern-en {
    display: block;
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}
/* 通称と英語名を1行に並べる。通称は本文の色で少しだけ強く */
.ref-pattern-alias { color: var(--bs-body-color); margin-right: 0.75em; }
.ref-pattern-summary {
    color: var(--bs-secondary-color);
    line-height: 1.9;
    margin-bottom: 16px;
}

/* 書き方・幅の切り替え */
.ref-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
}
.ref-choice {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ref-choice .btn { white-space: nowrap; }

/* AIへの指示文。ページの主役なので、見本より先に置き、見出しの帯をアクセント色の薄い面にする */
.ref-prompt { margin-bottom: 20px; }
/* 指示文の種類の切り替えと、その説明 */
.ref-kind { display: flex; margin-bottom: 8px; }
.ref-kind .btn { flex: 1 1 0; }
.ref-kind-note { margin: 0 0 10px; font-size: 0.78rem; line-height: 1.6; color: var(--bs-secondary-color); }
.ref-prompt .ref-code-head { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.ref-prompt .ref-pre { max-height: 420px; white-space: pre-wrap; font-size: 0.85rem; }
.ref-controls--device { justify-content: flex-end; }

/* 見本の枠。中の iframe は実寸で描いて transform で縮める */
.ref-stage {
    position: relative;
    overflow: hidden;
    background: repeating-linear-gradient(45deg, var(--bs-tertiary-bg) 0 10px, var(--bs-secondary-bg) 10px 20px);
}
.ref-frame {
    position: absolute;
    top: 0;
    left: 0;
    border: 0;
    background: #fff;
    transform-origin: 0 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ref-stage-note {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin: 6px 0 0;
}

.ref-list {
    padding-left: 1.2em;
    margin: 0;
    color: var(--bs-secondary-color);
    line-height: 1.85;
}
.ref-list li + li { margin-top: 4px; }
.ref-ic-ok { color: var(--bs-primary); }
.ref-ic-ng { color: var(--bs-warning-text-emphasis); }

/* コード */
.ref-code { margin-top: 24px; }
.ref-code-block + .ref-code-block { margin-top: 12px; }
.ref-code-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 6px 6px 14px;
    background: var(--bs-secondary-bg);
    font-size: 0.85rem;
    font-weight: 700;
}
.ref-copy {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border: 0;
    white-space: nowrap;
}
.ref-copy:hover { background: var(--bs-body-bg); }
.ref-copy.is-done { color: var(--bs-primary); }
.ref-pre {
    margin: 0;
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    background: var(--bs-tertiary-bg);
    font-size: 0.8rem;
    line-height: 1.6;
}
.ref-code-note {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin: 8px 0 0;
}

@media (max-width: 575.98px) {
    .ref-index { padding: 16px; }
    .ref-pattern-num { font-size: 1.5rem; }
}

/* ───────── UIパターン集の画面（common/ref_layout.php・R3b・2026-10-06 赤間さん決定） ─────────
   上：帯（パンくず＋パーツの切り替え・探す・お気に入り・指示ビルダー。PC では貼りつく）
   左：このパーツの型の一覧（PC では貼りつき、列の中だけスクロール）／右：見本 → 指示文 → 記事 */
.ref-wide { max-width: 1600px; }
:root { --ref-bar-h: 0px; }

/* 上の帯 */
.ref-bar { margin: -0.75rem 0 20px; padding: 8px 12px; background: var(--bs-tertiary-bg); border-bottom: 1px solid var(--bs-border-color); }
.ref-bar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
/* パーツのページでは「UIパターン集 › 料金表 ▾」とつなげる（トップとビルダーでは、ただのボタン） */
.ref-bar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.ref-bar-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 10px 0 12px; font-size: 0.9rem; color: var(--bs-body-color); background: var(--bs-secondary-bg); border: 0; }
.ref-bar-btn:hover, .ref-bar-btn[aria-expanded="true"] { background: var(--bs-body-bg); }
.ref-bar-count { margin-left: 6px; font-size: 0.75rem; color: var(--bs-secondary-color); }
@media (min-width: 992px) {
    .ref-bar { position: sticky; top: 0; z-index: 1030; }
}

/* 帯から開く欄（パーツの切り替え・お気に入り） */
.ref-pop { position: relative; }
.ref-pop-panel { position: absolute; z-index: 1040; top: calc(100% + 6px); left: 0; padding: 16px; background: var(--bs-body-bg); box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28); }
.ref-pop-panel[hidden] { display: none; }
.ref-parts-menu { width: min(1040px, calc(100vw - 2rem)); }
.ref-parts-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.ref-parts-group { padding: 0 8px 6px; margin-bottom: 4px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; color: var(--bs-secondary-color); border-bottom: 1px solid var(--bs-border-color); }
.ref-parts-col ul { list-style: none; margin: 0; padding: 0; }
.ref-parts-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 8px; font-size: 0.9rem; color: var(--bs-body-color); text-decoration: none; }
.ref-parts-link:hover { color: var(--bs-body-color); background: var(--bs-tertiary-bg); }
.ref-parts-link.is-current { font-weight: 700; color: #fff; background: var(--bs-primary); }
.ref-parts-thumb { flex: none; width: 48px; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12); }
.ref-parts-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.ref-parts-name { flex: 1 1 auto; }
.ref-parts-count { font-size: 0.75rem; color: var(--bs-secondary-color); }
.ref-parts-link.is-current .ref-parts-count { color: #fff; }
.ref-parts-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--bs-border-color); font-size: 0.82rem; color: var(--bs-secondary-color); }
.ref-favs { width: 300px; right: 0; left: auto; }
.ref-favs-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.ref-favs-list a { display: flex; flex-direction: column; padding: 6px 10px; color: var(--bs-body-color); text-decoration: none; }
.ref-favs-list a:hover { background: var(--bs-tertiary-bg); }
.ref-favs-list .ref-favs-name { font-size: 0.85rem; font-weight: 700; }
.ref-favs-list .ref-favs-part { font-size: 0.72rem; color: var(--bs-secondary-color); }
.ref-favs-empty { margin: 0; font-size: 0.8rem; line-height: 1.6; color: var(--bs-secondary-color); }

/* 全パーツをまたいで探す（帯の中） */
.ref-search { position: relative; width: 260px; }
.ref-search .form-control { height: 40px; border-width: 2px; font-size: 0.9rem; }
.ref-search-list {
    position: absolute; z-index: 1050; top: calc(100% + 4px); right: 0; width: max(100%, 380px);
    max-height: 360px; overflow-y: auto; margin: 0; padding: 6px 0; list-style: none;
    background: var(--bs-body-bg); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}
.ref-search-list a { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 8px 14px; color: var(--bs-body-color); text-decoration: none; }
.ref-search-list a:hover, .ref-search-list .is-active a { background: var(--bs-primary-bg-subtle); }
.ref-search-name { font-weight: 700; }
.ref-search-part { font-size: 0.8rem; color: var(--bs-secondary-color); align-self: center; }
.ref-search-en { grid-column: 1 / -1; font-size: 0.75rem; color: var(--bs-secondary-color); }
.ref-search-empty { padding: 10px 14px; font-size: 0.85rem; color: var(--bs-secondary-color); }

/* 枠：パーツのページは左に型の一覧、トップとビルダーは1列 */
.ref-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px 28px; align-items: start; }
.ref-layout--part { grid-template-columns: 280px minmax(0, 1fr); }
.ref-main { min-width: 0; }
.ref-nav-count { font-size: 0.75rem; font-weight: 400; color: var(--bs-secondary-color); }

/* 左：型の一覧 */
/* 見出し（パーツの切り替え）は列の上にとどめ、型の並びだけを列の中でスクロールする。切り替えの欄が列で切れないように、列そのものは overflow させない */
.ref-types { position: sticky; z-index: 5; top: calc(var(--ref-bar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--ref-bar-h) - 32px); }
.ref-types-box { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 6px; }
.ref-types-head { flex: none; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin-bottom: 2px; }
.ref-types-switch { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 8px 0 6px; font: inherit; color: var(--bs-body-color); text-align: left; background: transparent; border: 0; }
.ref-types-switch:hover, .ref-types-switch[aria-expanded="true"] { color: #fff; background: var(--bs-primary); }
.ref-types-switch:hover .ref-types-count { color: inherit; }
@media (min-width: 992px) { .ref-types-head .ref-pop-panel { top: calc(100% + 4px); } }
.ref-types-summary { display: none; }
/* ページの見出し（h1）は左の列のいちばん上。右の列には置かない（2026-10-06 精査：帯・左の列と重なるため） */
.ref-types-h1 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.4; }
.ref-types-count { font-size: 0.75rem; font-weight: 400; color: var(--bs-secondary-color); }
.ref-types-list { list-style: none; margin: 0; padding: 0; }
.ref-types-group { padding: 12px 6px 4px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; color: var(--bs-secondary-color); }
.ref-type { display: flex; align-items: center; gap: 10px; padding: 5px 6px; color: var(--bs-body-color); text-decoration: none; }
.ref-type:hover { color: var(--bs-body-color); background: var(--bs-tertiary-bg); }
.ref-type[aria-current="true"] { color: #fff; background: var(--bs-primary); }
.ref-type-thumb { position: relative; flex: none; width: 72px; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12); }
.ref-type-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: top center; display: block; }
.ref-type-text { display: flex; flex-direction: column; min-width: 0; }
.ref-type-name { font-size: 0.85rem; font-weight: 700; line-height: 1.35; }
.ref-type-num { margin-right: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; color: var(--bs-primary); }
.ref-type[aria-current="true"] .ref-type-num { color: #fff; }
.ref-type-en { font-size: 0.7rem; line-height: 1.35; color: var(--bs-secondary-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-type[aria-current="true"] .ref-type-en { color: rgba(255, 255, 255, 0.82); }

/* 右の上：見出し（左寄せで1段に詰める） */
/* 上は限りなく詰める（2026-10-06 赤間さん）：ページの見出しと説明を細い1行に */
.ref-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 10px; }
.ref-h1 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.4; }
.ref-h1 .mach-mi { font-size: 1.1em; vertical-align: -0.15em; }
.ref-lead { margin: 0; font-size: 0.78rem; color: var(--bs-secondary-color); }

/* 選んだ型：見出し → 見本 → 指示文・コード・選び方（縦に並べる） */
.ref-panel { min-width: 0; }
.ref-item { display: block; scroll-margin-top: calc(var(--ref-bar-h) + 16px); }
.ref-item[hidden] { display: none; }
.ref-item-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin-bottom: 6px; }
.ref-item-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ref-copy-head { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; font-size: 0.85rem; font-weight: 700; color: #fff; background: #7c5ac3; border: 0; }
.ref-copy-head:hover, .ref-copy-head:focus-visible { color: #fff; background: #7c5ac3; filter: brightness(1.08); }
.ref-copy-head.is-done { color: #fff; background: var(--bs-success); }
/* 前の型・次の型 */
.ref-step { display: flex; align-items: center; gap: 2px; }
.ref-step-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 10px; font-size: 0.82rem; color: var(--bs-body-color); text-decoration: none; background: var(--bs-tertiary-bg); border: 0; white-space: nowrap; }
.ref-step-btn:hover { color: var(--bs-body-color); background: var(--bs-secondary-bg); }
.ref-step-btn.is-disabled, .ref-step-btn:disabled { opacity: 0.4; }
.ref-step-btn--icon { justify-content: center; width: 36px; min-height: 36px; padding: 0; font-size: 1.1rem; }
.ref-step-pos { min-width: 3.5em; text-align: center; font-size: 0.8rem; color: var(--bs-secondary-color); white-space: nowrap; }
/* 見本のすぐ上：幅の切り替えと、実寸で見る2つ */
.ref-stage-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.ref-stage-bar .btn-sm { --bs-btn-padding-y: 0.15rem; --bs-btn-font-size: 0.8rem; }
.ref-open { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; font-size: 0.82rem; color: var(--bs-body-color); background: var(--bs-tertiary-bg); border: 0; white-space: nowrap; }
.ref-open:hover { background: var(--bs-secondary-bg); }
/* 縮めた割合は、見本の枠の右下に小さく */
.ref-stage > .ref-scale { position: absolute; z-index: 1; right: 6px; bottom: 4px; margin: 0; padding: 0 6px; font-size: 0.7rem; line-height: 1.6; color: #475569; background: rgba(255, 255, 255, 0.85); }
[data-bs-theme="dark"] .ref-stage > .ref-scale { color: #cbd5e1; background: rgba(15, 23, 42, 0.7); }
/* 型の名前の行：名前と☆だけ（番号・まとまり・英語名は左の列で見えている） */
.ref-item-title { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ref-item-name { margin: 0; font-size: 1.25rem; font-weight: 700; }
/* 通称と英語名：名前の下に小さく1行（ref-item-title を折り返させて、次の行に置く） */
.ref-item-title:has(.ref-item-alias) { flex-wrap: wrap; }
.ref-item-alias { flex-basis: 100%; margin: 0; font-size: 0.8rem; line-height: 1.4; color: var(--bs-secondary-color); }
.ref-item-alias [lang="en"] { margin-left: 0.75em; }
.ref-item-alias-note { display: block; }
.ref-fav--head { width: 36px; height: 36px; background: transparent; }
.ref-item-show .ref-pattern-summary { margin-top: 8px; }

.ref-item-copy { margin-top: 24px; padding: 16px; background: var(--bs-tertiary-bg); }
/* タブ。下線は行全体に引く */
.ref-item-copybar { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; border-bottom: 1px solid var(--bs-border-color); margin-bottom: 12px; }
.ref-tabs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: -1px; }
.ref-tab {
    padding: 6px 0; font-size: 0.85rem; color: var(--bs-secondary-color); background: none;
    border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.ref-tab[aria-selected="true"] { font-weight: 700; color: var(--bs-body-color); border-bottom-color: var(--bs-primary); }
.ref-tab:hover { color: var(--bs-body-color); }
.ref-item-copy .ref-prompt { margin-bottom: 0; }
.ref-item-copy .ref-pre { max-height: 52vh; font-size: 0.78rem; background: var(--bs-body-bg); }
.ref-item-copy .ref-code-head { background: var(--bs-secondary-bg); }
.ref-item-copy .ref-prompt .ref-code-head { background: var(--bs-primary-bg-subtle); }
.ref-item-copy .ref-code { margin-top: 0; }
.ref-item-copy .ref-list { font-size: 0.85rem; }
.ref-item-copy .ref-kind { max-width: 420px; }
.ref-copy--main { background: var(--bs-primary); color: #fff; font-weight: 700; }
.ref-copy--main:hover { background: var(--bs-primary); color: #fff; filter: brightness(1.08); }

/* 実寸で見るモーダル（画像／デモ） */
.ref-modal { position: fixed; inset: 0; z-index: 1060; display: flex; flex-direction: column; background: #15171a; color: #dee2e6; }
.ref-modal[hidden] { display: none; }
.ref-modal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; background: #212529; border-bottom: 1px solid #343a40; }
.ref-modal-title { display: flex; flex-direction: column; min-width: 0; }
.ref-modal-meta { font-size: 0.72rem; font-weight: 700; color: #8fb8ff; }
.ref-modal-title strong { font-size: 1rem; }
.ref-modal .ref-step-btn { color: #dee2e6; background: #2b3035; }
.ref-modal .ref-step-btn:hover { background: #3a4047; }
.ref-modal .ref-step-pos { color: #adb5bd; }
.ref-modal-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.ref-seg { display: inline-flex; gap: 2px; }
.ref-seg button { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; font-size: 0.82rem; color: #dee2e6; background: #2b3035; border: 0; white-space: nowrap; }
.ref-seg button[aria-pressed="true"] { font-weight: 700; color: #fff; background: #4263eb; }
.ref-seg button[hidden] { display: none; }
.ref-modal-sub { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; font-size: 0.82rem; color: #dee2e6; background: #2b3035; border: 0; white-space: nowrap; }
.ref-modal-sub[aria-pressed="true"], .ref-modal-sub[aria-expanded="true"] { color: #fff; background: #3a4047; box-shadow: inset 0 -3px 0 #9d83d9; }
.ref-modal-sub[hidden] { display: none; }
.ref-modal .ref-scale { margin: 0; color: #9aa0a6; }
.ref-modal-copy { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; font-size: 0.85rem; font-weight: 700; color: #fff; background: #7c5ac3; border: 0; white-space: nowrap; }
.ref-modal-copy.is-done { background: var(--bs-success); }
.ref-modal-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: #dee2e6; background: #2b3035; border: 0; font-size: 1.3rem; }
.ref-modal-close:hover { background: #3a4047; }
.ref-modal-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; }
.ref-modal-img { min-height: 100%; padding: 20px; display: flex; justify-content: center; align-items: flex-start; box-sizing: border-box; }
.ref-modal-img img { display: block; max-width: none; background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.ref-modal-img.is-fit img { max-width: 100%; height: auto; }
.ref-modal-none { margin: 40px auto; color: #adb5bd; }
.ref-modal-demo { position: absolute; inset: 0; overflow: hidden; }
.ref-modal-demo[hidden], .ref-modal-img[hidden] { display: none; }
.ref-modal-demo .ref-frame { position: absolute; top: 16px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.ref-modal-drawer { flex: 0 0 auto; height: 42vh; display: flex; flex-direction: column; background: #212529; border-top: 3px solid #7c5ac3; }
.ref-modal-drawer[hidden] { display: none; }
.ref-modal-drawer .ref-pre { flex: 1 1 auto; max-height: none; margin: 0; white-space: pre-wrap; font-size: 0.8rem; color: #dee2e6; background: #212529; }
html.ref-modal-open { overflow: hidden; }

/* お気に入りの星 */
.ref-fav {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
    color: var(--bs-secondary-color); background: var(--bs-body-bg); border: 0; flex: none;
}
.ref-fav:hover { color: var(--bs-primary); }
/* オン＝面を塗らず、星だけを塗る（2026-10-06 赤間さん「オンがかっこわるい」：青い四角に白抜きの星だった） */
.ref-fav .ref-fav-on { display: none; width: 1.35em; height: 1.35em; fill: #f2b01e; }
.ref-fav[aria-pressed="true"] { background: transparent; }
.ref-fav[aria-pressed="true"] .mach-mi { display: none; }
.ref-fav[aria-pressed="true"] .ref-fav-on { display: block; }
.ref-fav[aria-pressed="true"]:hover .ref-fav-on { fill: #d99a0c; }
.ref-fav[disabled] { display: none; }

/* 下段：型のカード */
.ref-cards-col { min-width: 0; margin-top: 36px; padding-top: 8px; border-top: 3px solid var(--bs-border-color); }
.ref-cards-title { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 2px; font-size: 1.1rem; font-weight: 700; }
.ref-cards-title span { font-size: 0.85rem; font-weight: 400; color: var(--bs-secondary-color); }
.ref-cards-hint { font-size: 0.8rem; color: var(--bs-secondary-color); margin: 0 0 12px; }
.ref-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
.ref-card-wrap { position: relative; }
.ref-card {
    display: flex; flex-direction: column; height: 100%; padding: 0;
    color: var(--bs-body-color); text-decoration: none; background: var(--bs-tertiary-bg); box-sizing: border-box;
}
.ref-card:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.ref-card[aria-current="true"] { box-shadow: inset 0 0 0 3px var(--bs-primary); background: var(--bs-body-bg); }
/* 星は絵に重ねない。絵（16:10）のすぐ下、型名の行の右に置く */
.ref-card-wrap { container-type: inline-size; }
.ref-fav--card { position: absolute; top: calc(62.5cqw + 6px); right: 6px; background: transparent; }
.ref-card-meta { padding-right: 40px; }
/* サムネイル：形を見せる。比率は 16:10 にそろえ、縦長（SP で撮ったもの）は中央に置く */
.ref-card-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 10; overflow: hidden; background: #e9ebef; }
.ref-card-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: top center; display: block; }
.ref-card-body { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; }
.ref-card-meta { display: flex; gap: 8px; font-size: 0.72rem; font-weight: 700; color: var(--bs-primary); }
.ref-card-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ref-card-name { font-size: 1rem; font-weight: 700; line-height: 1.4; }
.ref-card-en { font-size: 0.72rem; color: var(--bs-secondary-color); }
.ref-card-sum {
    margin-top: 6px; font-size: 0.8rem; line-height: 1.65; color: var(--bs-secondary-color);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.ref-frame { color-scheme: light; }

/* 狭い画面：左の型の一覧は「型を選ぶ」で畳み、見本の上に置く（ref-layout.js）。帯は貼りつけない */
@media (max-width: 991.98px) {
    .ref-layout--part { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .ref-types { position: static; display: block; max-height: none; }
    .ref-types-box { overflow: visible; padding-right: 0; }
    .ref-types-summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; font-weight: 700; cursor: pointer; list-style: none; background: var(--bs-tertiary-bg); }
    .ref-types-summary::-webkit-details-marker { display: none; }
    .ref-types-summary .ref-types-count { margin-left: auto; }
    .ref-types-box[open] .ref-types-summary .mach-mi, .ref-types-box[open] .ref-types-summary .material-symbols-outlined { transform: rotate(180deg); }
    .ref-types-head { margin-bottom: 8px; }
    .ref-types-head > .ref-types-count { display: none; } /* 数は下の「型を選ぶ」に出ている */
    .ref-types-list { padding: 4px 0 8px; background: var(--bs-tertiary-bg); }
    .ref-bar-tools { margin-left: 0; width: 100%; flex-wrap: nowrap; }
    .ref-bar-text { display: none; }
    .ref-bar-btn { flex: none; padding: 0 10px; }
    .ref-search { flex: 1 1 auto; width: auto; min-width: 0; }
    .ref-search-list { width: 100%; }
    .ref-pop-panel { position: fixed; left: 8px; right: 8px; top: 64px; width: auto; max-height: calc(100vh - 80px); overflow-y: auto; }
    .ref-parts-cols { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .ref-item-head { align-items: flex-start; }
    .ref-modal-tools { margin-left: 0; }
}
}

/* ───────── 一覧ページ（/ref/） ───────── */
.ref-top { min-width: 0; }
.ref-top-series + .ref-top-series { margin-top: 48px; }
/* 全体のトップ：3つの集の入口（タブを兼ねる）。選んだ集は太い下線と太字、面をアクセントでうっすら塗る */
.ref-top-entry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 32px; }
.ref-top-entry-tab { display: flex; flex-direction: column; gap: 4px; padding: 12px 12px 16px; text-align: left; color: var(--bs-body-color); background: #eef0f3; border: 0; border-bottom: 4px solid transparent; cursor: pointer; }
[data-bs-theme="dark"] .ref-top-entry-tab { background: var(--bs-tertiary-bg); }
.ref-top-entry-tab:hover { background: rgba(124, 90, 195, 0.08); }
.ref-top-entry-tab[aria-selected="true"] { background: rgba(124, 90, 195, 0.1); border-bottom-color: #7c5ac3; }
[data-bs-theme="dark"] .ref-top-entry-tab[aria-selected="true"] { background: rgba(157, 131, 217, 0.16); border-bottom-color: #9d83d9; }
.ref-top-entry-tab:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.ref-top-entry-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.ref-top-entry-thumbs img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--bs-body-bg); }
.ref-top-entry-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 1.2rem; font-weight: 400; }
.ref-top-entry-tab[aria-selected="true"] .ref-top-entry-title { font-weight: 700; }
.ref-top-entry-count { font-size: 0.85rem; font-weight: 400; color: var(--bs-secondary-color); }
.ref-top-entry-en { font-size: 0.75rem; color: var(--bs-secondary-color); }
.ref-top-entry-lead { font-size: 0.8rem; line-height: 1.6; color: var(--bs-secondary-color); }
/* スマホでは入口を横長の行にし、説明と絵を省いて3つが1画面に並ぶようにする */
@media (max-width: 767.98px) {
  .ref-top-entry { grid-template-columns: 1fr; gap: 8px; margin-bottom: 24px; }
  .ref-top-entry-tab { padding: 10px 12px; border-bottom-width: 0; border-left: 0; }
  .ref-top-entry-tab[aria-selected="true"] { box-shadow: inset 0 -4px 0 #7c5ac3; }
  [data-bs-theme="dark"] .ref-top-entry-tab[aria-selected="true"] { box-shadow: inset 0 -4px 0 #9d83d9; }
  .ref-top-entry-thumbs, .ref-top-entry-lead { display: none; }
  .ref-top-entry-title { font-size: 1.05rem; }
}
.ref-top-series-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 4px; font-size: 1.4rem; font-weight: 700; }
.ref-top-series-title span { font-size: 0.85rem; font-weight: 400; color: var(--bs-secondary-color); }
.ref-top-group { margin: 28px 0 12px; font-size: 0.95rem; font-weight: 700; color: var(--bs-secondary-color); }
.ref-top-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.ref-top-part { display: flex; flex-direction: column; background: var(--bs-tertiary-bg); }
.ref-top-link { display: flex; flex-direction: column; color: var(--bs-body-color); text-decoration: none; }
.ref-top-link:hover { color: var(--bs-body-color); }
.ref-top-link:hover .ref-card-thumb img { opacity: 0.92; }
.ref-top-name { display: flex; align-items: center; gap: 4px; padding: 12px 14px 4px; font-size: 1.05rem; font-weight: 700; }
.ref-top-name .ref-nav-count { margin-left: auto; }
.ref-top-types { display: flex; flex-wrap: wrap; gap: 4px 6px; list-style: none; margin: 0; padding: 6px 14px 14px; }
.ref-top-types a { display: inline-block; padding: 2px 8px; font-size: 0.75rem; color: var(--bs-body-color); background: var(--bs-body-bg); text-decoration: none; }
.ref-top-types a:hover { color: #fff; background: var(--bs-primary); }

/* ───────── ライトモードで境目と大きさが分かるように（2026-10-06 赤間さん指摘） ───────── */
/* 見本：灰色の地の上に、縁取りと影のある「画面」として置く */
.ref-stage { background: #dfe3e8; }
[data-bs-theme="dark"] .ref-stage { background: #3a3f47; }
.ref-frame { box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16), 0 8px 24px rgba(15, 23, 42, 0.14); }
.ref-scale { margin-left: auto; font-size: 0.75rem; color: var(--bs-secondary-color); white-space: nowrap; align-self: center; }
.ref-item-head .ref-choice { flex: none; }

/* カード：絵をカードの地の中に収め、どの絵とどの文が組なのかを見せる */
.ref-cards, .ref-top-parts { gap: 20px; }
.ref-card, .ref-top-part { padding: 10px; background: #eef0f3; }
[data-bs-theme="dark"] .ref-card, [data-bs-theme="dark"] .ref-top-part { background: var(--bs-tertiary-bg); }
.ref-card:hover { background: #e3e6ea; }
[data-bs-theme="dark"] .ref-card:hover { background: var(--bs-secondary-bg); }
.ref-card-thumb { background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12); }
.ref-card-body { padding: 10px 4px 4px; }
.ref-top-link { color: var(--bs-body-color); }
.ref-top-name { padding: 10px 4px 4px; }
.ref-top-types { padding: 6px 4px 4px; }
.ref-fav--card { top: calc(62.5cqw - 6.25px + 16px); right: 10px; }

/* ───────── 指示ビルダー（/ref/builder/） ───────── */
.rb-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; min-width: 0; }
.rb-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 4px; }
.rb-hint { font-size: 0.82rem; color: var(--bs-secondary-color); margin: 0 0 10px; }
.rb-pick-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.rb-count { font-size: 0.85rem; font-weight: 700; }
.rb-summary { margin-bottom: 16px; padding: 12px; background: var(--bs-secondary-bg); border-top: 3px solid #9d83d9; }
.rb-summary .ref-basket-list { max-height: none; margin-bottom: 0; }
.rb-summary .ref-basket-empty { margin-bottom: 0; }
.rb-summary-go { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px; color: var(--bs-body-color); text-align: left; background: transparent; border: 0; }
.rb-summary-go:hover { background: var(--bs-secondary-bg); }
/* 副の操作：枠なしの薄い灰色の面 */
.rb-sub { background: var(--bs-tertiary-bg); color: var(--bs-body-color); border: 0; }
.rb-sub:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }

.rb-sec { margin-top: 26px; }
.rb-sec-title { font-size: 0.95rem; font-weight: 700; color: var(--bs-secondary-color); margin: 0 0 8px; padding-bottom: 6px; border-bottom: 3px solid var(--bs-border-color); }
.rb-sec-note { font-size: 0.78rem; color: var(--bs-secondary-color); margin: -2px 0 10px; }

.rb-part { position: relative; margin: 0 0 14px; padding: 12px; background: #eef0f3; border: 0; min-width: 0; }
[data-bs-theme="dark"] .rb-part { background: var(--bs-tertiary-bg); }
.rb-part.is-picked { box-shadow: inset 3px 0 0 var(--bs-primary); }
/* 見出し（legend）は枠の線にまたがって描かれ、枠と左の線からズレて見えていた（2026-10-06 赤間さん指摘）。float で枠の中に入れる */
.rb-part-head { display: flex; align-items: center; gap: 6px; float: left; width: 100%; margin: 0 0 8px; padding: 0; font-size: 0.95rem; font-weight: 700; }
.rb-part > :not(.rb-part-head):not(.rb-part-link) { clear: both; }
.rb-part-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; color: var(--bs-primary); }
.rb-part-picked { font-size: 0.8rem; font-weight: 700; color: var(--bs-primary); }
.rb-part-picked:not(:empty)::before { content: "→ "; color: var(--bs-secondary-color); font-weight: 400; }
.rb-part-link { position: absolute; top: 12px; right: 12px; font-size: 0.75rem; }

.rb-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.rb-tile { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; cursor: pointer; background: var(--bs-body-bg); }
.rb-tile:hover { background: var(--bs-secondary-bg); }
.rb-radio { position: absolute; opacity: 0; pointer-events: none; }
.rb-tile-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12); color: var(--bs-secondary-color); }
.rb-tile-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: top center; display: block; }
.rb-tile--none .rb-tile-thumb { background: var(--bs-tertiary-bg); box-shadow: none; font-size: 1.6rem; }
/* どれか1つを選ぶ＝丸の印。選んだものだけ塗る */
.rb-tile-name { display: flex; gap: 6px; align-items: flex-start; font-size: 0.75rem; line-height: 1.4; }
.rb-tile-name::before { content: ""; flex: none; width: 12px; height: 12px; margin-top: 2px; border: 2px solid var(--bs-secondary-color); border-radius: 50%; }
.rb-tile:has(.rb-radio:checked) { box-shadow: inset 0 0 0 2px var(--bs-primary); }
.rb-tile:has(.rb-radio:checked) .rb-tile-name { font-weight: 700; }
.rb-tile:has(.rb-radio:checked) .rb-tile-name::before { border-color: var(--bs-primary); background: radial-gradient(circle, var(--bs-primary) 45%, transparent 50%); }
.rb-tile:has(.rb-radio:focus-visible) { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

.rb-out { position: sticky; top: calc(var(--ref-bar-h) + 16px); max-height: calc(100vh - var(--ref-bar-h) - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.rb-box { padding: 14px; background: #eef0f3; }
[data-bs-theme="dark"] .rb-box { background: var(--bs-tertiary-bg); }
.rb-box-title { font-size: 1rem; font-weight: 700; margin: 0 0 10px; }
.rb-field { margin-bottom: 10px; }
.rb-label { display: block; margin-bottom: 3px; font-size: 0.78rem; color: var(--bs-secondary-color); }
.rb-opt { margin-left: 6px; font-size: 0.7rem; }
.rb-color { display: flex; align-items: center; gap: 10px; }
.rb-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.rb-color .form-control-color { width: 44px; height: 32px; padding: 2px; }
.rb-color .form-control-color:disabled { opacity: 0.35; }
.rb-color-code { font-size: 0.8rem; }
.rb-mode { display: flex; }
.rb-mode .btn { flex: 1 1 0; }
.rb-mode-hint { min-height: 3em; margin: 6px 0 0; font-size: 0.78rem; line-height: 1.6; }
.rb-note { margin: 4px 0 0; font-size: 0.72rem; color: var(--bs-secondary-color); }
.rb-prompt { margin-bottom: 0; }
.rb-prompt .ref-pre { max-height: 52vh; }
.rb-len { margin-left: 6px; font-size: 0.75rem; font-weight: 400; opacity: 0.8; }
[data-rb-out].is-empty { color: var(--bs-secondary-color); }

.rb-jump { display: none; }
@media (max-width: 1199.98px) {
    .rb-main { grid-template-columns: minmax(0, 1fr); }
    .rb-out { position: static; max-height: none; overflow: visible; }
    .rb-prompt .ref-pre { max-height: 70vh; }
    .rb-jump {
        position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 1030;
        display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 44px;
        font-size: 0.9rem; font-weight: 700; color: #fff; text-decoration: none; background: var(--bs-primary);
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
    }
    .rb-jump:hover { color: #fff; }
    .rb-jump.is-hidden { display: none; }
}
@media (max-width: 575.98px) {
    .rb-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rb-part-link { position: static; display: inline-block; margin: -4px 0 8px; }
}

/* 指示ビルダーの履歴：一覧は見るだけ。戻す＝副の操作、消す＝赤い文字 */
.rb-hist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.rb-hist-list { list-style: none; margin: 0 0 8px; padding: 0; }
.rb-hist-item { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--bs-border-color); }
.rb-hist-title { font-size: 0.88rem; font-weight: 700; overflow-wrap: anywhere; }
.rb-hist-meta { font-size: 0.72rem; color: var(--bs-secondary-color); }
.rb-hist-types { margin-top: 2px; font-size: 0.75rem; line-height: 1.5; overflow-wrap: anywhere; }
.rb-hist-ops { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rb-hist-del { padding: 2px 8px; color: var(--bs-danger-text-emphasis); background: transparent; border: 0; }
.rb-hist-del:hover { color: var(--bs-danger-text-emphasis); background: var(--bs-danger-bg-subtle); }
.rb-hist-empty { margin: 0 0 4px; font-size: 0.8rem; color: var(--bs-secondary-color); }
.rb-danger { color: var(--bs-danger-text-emphasis); background: var(--bs-danger-bg-subtle); border: 0; }
.rb-danger:hover { color: var(--bs-danger-text-emphasis); background: var(--bs-danger-bg-subtle); filter: brightness(0.96); }
/* 履歴の「戻す」は欄の地と色を分ける（ダークで地と同じ色になり、ボタンの形が見えなかった） */
.rb-hist .rb-sub { background: var(--bs-body-bg); }
.rb-hist .rb-sub:hover { background: var(--bs-secondary-bg); }
.rb-hist-more { width: 100%; margin-bottom: 8px; }
.rb-hist-item.is-folded { display: none; }

/* 指示ビルダーのプレビュー（2026-10-06 赤間さん「大きくプレビュー」）。右の欄を広げ、プレビュー／指示文のタブにする */
.rb-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.rb-tabs { border-bottom: 1px solid var(--bs-border-color); margin-bottom: 12px; }
.rb-tab-len { margin-left: 4px; font-size: 0.75rem; font-weight: 400; color: var(--bs-secondary-color); }
.rb-pane[hidden] { display: none; }
.rb-pane { display: flex; flex-direction: column; gap: 12px; }
#rb-p-preview { gap: 6px; }
.rb-pv-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.rb-pv-caption { display: flex; align-items: baseline; gap: 8px; min-height: 1.4em; font-size: 0.85rem; font-weight: 700; }
.rb-stage { position: relative; height: max(380px, calc(100vh - 220px)); overflow: hidden; background: #dfe3e8; }
[data-bs-theme="dark"] .rb-stage { background: #3a3f47; }
.rb-frame { position: absolute; top: 0; left: 0; border: 0; background: #fff; transform-origin: 0 0; color-scheme: light; opacity: 0; transition: opacity 0.22s ease; }
.rb-frame.is-shown { opacity: 1; }
.rb-stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 24px; text-align: center; font-size: 0.9rem; color: var(--bs-secondary-color); }
@media (max-width: 1199.98px) {
    .rb-main { grid-template-columns: minmax(0, 1fr); }
    .rb-stage { height: 70vh; }
}

/* ───────── 組み立てかご（B1・2026-10-06）：見ながら「＋ ページに入れる」で集め、指示ビルダーで仕上げる ───────── */
.ref-basket-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; margin-left: 6px; padding: 0 6px; font-size: 0.75rem; font-weight: 700; color: #2b1f4d; background: #d6c8f5; }
.ref-basket-count[hidden] { display: none; }
.ref-basket-count.is-bump { animation: ref-bump 0.5s ease; }
@keyframes ref-bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .ref-basket-count.is-bump { animation: none; } }
.ref-basket { width: 360px; right: 0; left: auto; border-top: 3px solid #9d83d9; }
.ref-basket-head { font-weight: 700; margin-bottom: 8px; }
.ref-basket-sub { margin-left: 6px; font-size: 0.75rem; font-weight: 400; color: var(--bs-secondary-color); }
.ref-basket-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.ref-basket-item { display: flex; align-items: center; gap: 4px; background: var(--bs-tertiary-bg); }
.ref-basket-item a { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px; color: var(--bs-body-color); text-decoration: none; }
.ref-basket-item a:hover { background: var(--bs-secondary-bg); }
.ref-basket-thumb { flex: none; width: 56px; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12); }
.ref-basket-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: top center; display: block; }
.ref-basket-text { display: flex; flex-direction: column; min-width: 0; }
.ref-basket-part { font-size: 0.72rem; color: var(--bs-secondary-color); }
.ref-basket-name { font-size: 0.88rem; font-weight: 700; }
.ref-basket-del { flex: none; width: 36px; height: 36px; font-size: 1.1rem; color: var(--bs-danger-text-emphasis); background: transparent; border: 0; }
.ref-basket-del:hover { background: var(--bs-danger-bg-subtle); }
.ref-basket-empty { margin: 0 0 10px; font-size: 0.82rem; line-height: 1.7; color: var(--bs-secondary-color); }
.ref-basket-go { display: flex; align-items: center; justify-content: center; min-height: 42px; font-weight: 700; color: #fff; text-decoration: none; background: #7c5ac3; }
.ref-basket-go:hover { color: #fff; filter: brightness(1.08); }
/* 型の見出しの「＋ ページに入れる」：副の操作（枠だけ）。入っているときは塗る */
.ref-basket-add { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; font-size: 0.85rem; color: var(--bs-body-color); background: transparent; border: 2px solid #9d83d9; white-space: nowrap; }
.ref-basket-add:hover { background: rgba(157, 131, 217, 0.12); }
.ref-basket-add[aria-pressed="true"] { color: #2b1f4d; background: #d6c8f5; border-color: #d6c8f5; font-weight: 700; }
/* 左の列：お気に入り＝絵の右上の★（見返す印）。かごに入っている型＝名前の後ろの「入れた」（使う印）。意味が違うので形も場所も分ける */
.ref-type.is-fav .ref-type-thumb::after { content: "★"; position: absolute; top: 0; right: 0; padding: 0 3px; font-size: 0.75rem; line-height: 1.3; color: #f2b01e; background: rgba(15, 23, 42, 0.78); }
/* 左の列：かごに入っている型に印 */
.ref-type.is-in-basket .ref-type-name::after { content: "入れた"; margin-left: 6px; padding: 0 5px; font-size: 0.65rem; font-weight: 700; color: #2b1f4d; background: #d6c8f5; vertical-align: 0.1em; }
@media (max-width: 991.98px) {
    /* 狭い画面では、帯から開く欄は画面の下から出す（上だとサイトのヘッダーに重なり、右にはみ出していた） */
    .ref-pop-panel, .ref-pop-panel.ref-basket, .ref-pop-panel.ref-favs { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 75vh; overflow-y: auto; }
}

/* 説明チップ（ref-layout.js の [data-ref-tip]）：マウスを重ねる・キーボードで選ぶと、短い説明を出す。タッチの画面では出さない */
.ref-tip { position: fixed; z-index: 2000; max-width: 300px; padding: 6px 10px; font-size: 0.78rem; line-height: 1.6; color: #f8f9fa; background: #1f2329; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35); pointer-events: none; opacity: 0; transition: opacity 0.12s ease; }
.ref-tip.is-on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .ref-tip { transition: none; } }

/* 変化の動き：入った行はすべり込み、外す行は畳む。押した型・星・「ページに入れる」は一瞬弾む。新しく付いた ★・「入れた」は出てくる */
@keyframes ref-row-in { 0% { opacity: 0; transform: translateX(-12px); background: rgba(157, 131, 217, 0.45); } 60% { opacity: 1; transform: none; } 100% { background: var(--bs-tertiary-bg); } }
@keyframes ref-row-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes ref-pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes ref-mark-in { 0% { opacity: 0; transform: scale(0.4); } 70% { transform: scale(1.15); } 100% { opacity: 1; transform: scale(1); } }
.ref-basket-item.is-new { animation: ref-row-in 0.6s ease; }
.ref-basket-item.is-leaving { animation: ref-row-out 0.2s ease forwards; pointer-events: none; }
.rb-tile.is-pop, .ref-basket-add.is-pop { animation: ref-pop 0.3s ease; }
.ref-fav.is-pop .ref-fav-on { animation: ref-mark-in 0.35s ease; }
.ref-motion-ready .ref-type.is-fav .ref-type-thumb::after, .ref-motion-ready .ref-type.is-in-basket .ref-type-name::after { animation: ref-mark-in 0.35s ease; }
.ref-type-name::after { display: inline-block; }
@media (prefers-reduced-motion: reduce) {
    .rb-frame { transition: none; }
    .ref-basket-item.is-new, .ref-basket-item.is-leaving, .rb-tile.is-pop, .ref-basket-add.is-pop, .ref-fav.is-pop .ref-fav-on,
    .ref-motion-ready .ref-type.is-fav .ref-type-thumb::after, .ref-motion-ready .ref-type.is-in-basket .ref-type-name::after { animation: none; }
}

/* ビルダーの組み立て中：数が増えても場所を取らないよう、1行を低くし、広いときは2列に並べる */
.rb-summary .ref-basket-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px; }
.rb-summary .ref-basket-item { min-width: 0; }
.rb-summary-go { gap: 8px; padding: 3px 4px; }
.rb-summary .ref-basket-thumb { width: 40px; }
.rb-summary .ref-basket-text { flex-direction: row; align-items: baseline; gap: 6px; overflow: hidden; white-space: nowrap; }
.rb-summary .ref-basket-part { flex: none; }
.rb-summary .ref-basket-name { overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; }
.rb-summary .ref-basket-del { width: 30px; height: 30px; font-size: 1rem; }

/* ビルダーのプレビューを大きく見る：画面いっぱいに広げる（Esc か「閉じる」で戻る） */
.rb-pane.is-large { position: fixed; inset: 0; z-index: 1060; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; background: var(--bs-body-bg); }
.rb-pane.is-large .rb-stage { flex: 1 1 auto; height: auto; }
.rb-pane.is-large .rb-note { display: none; }
.rb-large-btn { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; font-size: 0.8rem; color: var(--bs-body-color); background: var(--bs-secondary-bg); border: 0; }
.rb-large-btn:hover { background: var(--bs-tertiary-bg); }
html.rb-large-open { overflow: hidden; }
/* 見出し｜サイズとボタンのまとまり。まとまりの中は折り返さず、入らなければまとまりごと次の行へ送る */
.rb-pv-caption { align-items: center; flex-wrap: wrap; row-gap: 6px; }
.rb-pv-title { flex: 1 1 12em; min-width: 0; }
.rb-pv-tools { flex: none; max-width: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; margin-left: auto; }
.rb-pv-tools > * { white-space: nowrap; }
/* 貼りつく右の列は重なりの層を作るので、大きく見るあいだは列ごと帯より上に出す */
.rb-out:has(.rb-pane.is-large) { z-index: 1070; }

/* 帯：UIパターン集の入口｜2つの場所（型を見る／ページを組む）｜探す・お気に入り（2026-10-06 案A） */
.ref-bar-home { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; font-size: 0.9rem; font-weight: 700; color: var(--bs-secondary-color); }
/* AI指示の見本帳 › いまの集（2026-10-07）。全体の名前は薄く、いまの集は本文の色 */
.ref-bar-home { gap: 2px; white-space: nowrap; }
.ref-bar-home a, .ref-bar-home span[aria-current] { display: inline-flex; align-items: center; min-height: 40px; padding: 0 4px; color: inherit; text-decoration: none; }
.ref-bar-home a:hover { text-decoration: underline; }
.ref-bar-home a[aria-current], .ref-bar-home .ref-bar-sep ~ a, .ref-bar-home span[aria-current] { color: var(--bs-body-color); }
.ref-bar-sep { color: var(--bs-secondary-color); font-weight: 400; }
.ref-modes { display: flex; align-items: stretch; gap: 2px; padding: 3px; background: var(--bs-body-bg); }
.ref-mode-build { display: flex; align-items: stretch; }
.ref-mode { display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding: 0 14px; font-size: 0.9rem; font-weight: 700; color: var(--bs-body-color); text-decoration: none; white-space: nowrap; }
.ref-mode:hover { color: var(--bs-body-color); background: var(--bs-secondary-bg); }
.ref-mode[aria-current="page"] { color: #fff; background: var(--bs-primary); }
.ref-mode--build > .mach-mi:first-child { color: #7c5ac3; }
[data-bs-theme="dark"] .ref-mode--build > .mach-mi:first-child { color: #b9a4ec; }
.ref-mode--build[aria-current="page"] > .mach-mi:first-child { color: inherit; }
.ref-mode-more { display: inline-flex; align-items: center; padding: 0 6px; color: var(--bs-body-color); background: transparent; border: 0; border-left: 1px solid var(--bs-border-color); }
.ref-mode-more:hover, .ref-mode-more[aria-expanded="true"] { background: var(--bs-secondary-bg); }
@media (max-width: 991.98px) {
    .ref-modes { flex: 1 1 auto; }
    .ref-modes > .ref-mode, .ref-mode-build { flex: 1 1 0; }
    .ref-mode-build > .ref-mode { flex: 1 1 auto; justify-content: center; }
    .ref-modes > .ref-mode { justify-content: center; }
    .ref-mode { padding: 0 8px; }
}

/* 指示ビルダーから来たときの戻り道（右の列の頭。型の見出しのすぐ上） */
.ref-back-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 12px; scroll-margin-top: calc(var(--ref-bar-h, 0px) + 16px); }
.ref-back { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px 0 8px; font-size: 0.9rem; font-weight: 700; color: #fff; text-decoration: none; background: #7c5ac3; }
.ref-back:hover { color: #fff; filter: brightness(1.08); }
.ref-back-note { font-size: 0.78rem; color: var(--bs-secondary-color); }
/* ビルダーへ戻ってきたとき、貼りつく帯の下にパーツの見出しが来るように */
.rb-part { scroll-margin-top: calc(var(--ref-bar-h, 0px) + 16px); }

/* ───────── 動きの系統：見本の下の調整欄（common/ref_pattern.php の mach_ref_render_motion_bar・2026-10-07） */
/* もう一度動かす＝灰色の面のボタン（紫の塗りは「指示文をコピー」専用）、切り替え＝四角のチェック、数字＝つまみ。項目名は小さく薄く、値は本文の色 */
.ref-motion { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; padding: 12px 14px; background: var(--bs-tertiary-bg); }
.ref-motion-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.ref-replay { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; font-size: 0.85rem; font-weight: 600; color: var(--bs-body-color); background: var(--bs-secondary-bg); border: 0; }
.ref-replay:hover { background: var(--bs-border-color); }
.ref-calm { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.ref-calm input { width: 18px; height: 18px; accent-color: #7c5ac3; }
.ref-params { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.ref-param { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.ref-param-preset { flex-basis: 100%; }
.ref-param-k { font-size: 0.75rem; color: var(--bs-secondary-color); white-space: nowrap; }
.ref-param input[type="range"] { width: 140px; accent-color: #7c5ac3; }
.ref-param-text { width: 11em; min-height: 30px; padding: 2px 8px; font-size: 0.85rem; color: var(--bs-body-color); background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); }
.ref-param-v { min-width: 4.2em; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--bs-body-color); }
.ref-param .btn-sm { --bs-btn-padding-y: 0.15rem; --bs-btn-font-size: 0.8rem; }
.ref-param-reset { min-height: 30px; padding: 0 10px; font-size: 0.78rem; color: var(--bs-body-color); background: var(--bs-secondary-bg); border: 0; }
@media (max-width: 575.98px) {
    .ref-param input[type="range"] { width: 120px; }
}
