/* パーティクルメーカー — ページ固有のスタイル。配色は /assets/css/base.css の変数を使う。
   クラス名の接頭辞は mpa-（トランジションメーカーの mtr- にあたる）。 */

.mpa {
    --mpa-ink: #14161d;
    --mpa-line: #e3eaef;
    --mpa-soft: #f4f9fc;
    --mpa-stage-h: 380px;
    padding-bottom: 56px;
}
.mpa [hidden] { display: none !important; }
.mpa-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}
.mpa button, .mpa select, .mpa textarea, .mpa input { font-family: inherit; }
.mpa :focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}
.nb { display: inline-block; }

/* ---------- OBS 用の表示（?mode=obs）：粒だけを、透明な背景に描く ---------- */
.mpa-obs-stage { display: none; }
html.mpa-obs-mode,
html.mpa-obs-mode body[class],
html.mpa-obs-mode body {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    overflow: hidden;
}
html.mpa-obs-mode body > :not(#obs-stage) { display: none !important; }
html.mpa-obs-mode .mpa-obs-stage {
    display: block;
    position: fixed;
    inset: 0;
    background: transparent;
}
html.mpa-obs-mode .mpa-obs-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- 見出し ---------- */
.mpa-intro { padding-top: 26px; padding-bottom: 14px; }
.mpa-intro .mpa-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(0, 174, 239, .11);
    color: #047da9;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}
.mpa-intro h1 {
    font-size: clamp(22px, 4.2vw, 36px);
    font-weight: 800;
    line-height: 1.5;
    letter-spacing: .02em;
}
.mpa-intro p {
    margin-top: 10px;
    color: var(--text-sub);
    font-size: 15px;
    line-height: 1.9;
}
.mpa-intro .mpa-mark { background: linear-gradient(transparent 70%, var(--accent-yellow) 70%); }

/* ---------- 全体の並び（スマホ：プレビュー → マイパーティクル → 1 → 2 → 詳細 → 保存） ---------- */
.mpa-app, .mpa-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}
.mpa-card {
    background: #fff;
    border: 1px solid var(--mpa-line);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .05);
    padding: 18px 16px;
}
.mpa-card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.4;
}
.mpa-card h2 small {
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 500;
}
.mpa-card h2 > i { color: var(--primary-color); font-size: 16px; }
.mpa .step {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-yellow);
    font-size: 15px;
    font-weight: 800;
}
.mpa-note {
    margin-top: 8px;
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1.7;
}
.mpa-note:empty { display: none; }
.mpa code {
    padding: 1px 5px;
    border-radius: 5px;
    background: #eef3f6;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .92em;
}
.mpa-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    background: none;
    color: #007ea9;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}
.mpa-chip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 999px;
    background: #fff;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s, border-color .15s, background .15s;
}
.mpa-chip-btn:active { transform: scale(.95); }
.mpa-chip-btn i { color: var(--primary-color); }
.mpa-chip-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- プレビュー（スクロールしても上に残る） ---------- */
.mpa-stage {
    position: sticky;
    top: 62px;
    z-index: 30;
    margin: 0 -8px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 12px 26px rgba(30, 41, 59, .12);
}
.mpa-screen-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background: var(--mpa-ink);
}
.mpa-screen {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #1b1e27;
    cursor: pointer;
    isolation: isolate;
    touch-action: pan-y;
}
/* 確認用の背景（保存する素材には入らない） */
.mpa-screen[data-backdrop="alpha"] { background: repeating-conic-gradient(#3b3f4b 0 25%, #2a2d37 0 50%) 0 0 / 22px 22px; }
.mpa-screen[data-backdrop="black"] { background: #000; }
.mpa-screen[data-backdrop="white"] { background: #fff; }
.mpa-screen canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}
.mpa-screen[data-backdrop="alpha"] .mpa-backdrop,
.mpa-screen[data-backdrop="black"] .mpa-backdrop,
.mpa-screen[data-backdrop="white"] .mpa-backdrop,
.mpa-screen[data-out="key"] .mpa-backdrop,
.mpa-screen[data-out="solid"] .mpa-backdrop { visibility: hidden; }
/* 黒背景で保存するときは、編集ソフトで「スクリーン」にしたときの見え方で確かめる */
.mpa-screen[data-out="screen"] .mpa-canvas { mix-blend-mode: screen; }
.mpa-point {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: rgba(0, 174, 239, .55);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
    color: #fff;
    font-size: 16px;
    cursor: grab;
    touch-action: none;
}
.mpa-point:active { cursor: grabbing; }
/* ワンポイント：演出がつまみの真下に出るので、中を透かした細い輪にする（触れている間だけはっきり見せる） */
.mpa-point.is-ring {
    border: 1.5px dashed rgba(255, 255, 255, .8);
    background: transparent;
    box-shadow: none;
    opacity: .6;
}
.mpa-point.is-ring i { opacity: 0; }
.mpa-point.is-ring:hover, .mpa-point.is-ring:focus-visible, .mpa-point.is-ring:active { opacity: 1; }
.mpa-screen-msg {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 16px;
    background: var(--mpa-ink);
    color: #fff;
    font-size: 14px;
    line-height: 1.8;
    text-align: center;
}
.mpa-screen-note, .mpa-time-label {
    position: absolute;
    left: 8px;
    z-index: 2;
    max-width: calc(100% - 16px);
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(20, 22, 29, .72);
    color: #fff;
    font-size: 11px;
    line-height: 1.5;
    pointer-events: none;
}
.mpa-screen-note { top: 8px; }
.mpa-time-label { bottom: 8px; font-variant-numeric: tabular-nums; }
.mpa-export {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(20, 22, 29, .9);
    color: #fff;
    text-align: center;
    cursor: default;
}
.mpa-export strong { font-size: 14px; }
.mpa-export progress {
    width: min(78%, 360px);
    height: 10px;
    accent-color: var(--primary-color);
}
.mpa-cancel {
    min-height: 44px;
    padding: 0 16px;
    border: 1.5px solid rgba(255, 255, 255, .6);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.loading-bars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
}
.loading-bars span {
    width: 4px;
    height: 34px;
    border-radius: 999px;
    background: var(--primary-color);
    animation: mpa-wave .9s ease-in-out infinite;
}
.loading-bars span:nth-child(2) { background: var(--accent-pink); animation-delay: -.8s; }
.loading-bars span:nth-child(3) { background: var(--accent-yellow); animation-delay: -.7s; }
.loading-bars span:nth-child(4) { background: var(--accent-pink); animation-delay: -.6s; }
.loading-bars span:nth-child(5) { animation-delay: -.5s; }
@keyframes mpa-wave {
    0%, 40%, 100% { transform: scaleY(.08); }
    20% { transform: scaleY(1); }
}

/* ---------- 再生位置と操作 ---------- */
.mpa-seek {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.mpa-seek input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    margin: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}
.mpa-transport {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.mpa-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1.5px solid var(--mpa-line);
    border-radius: 999px;
    background: #fff;
    color: #445;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, background .15s, border-color .15s, color .15s;
}
.mpa-round:active { transform: scale(.93); }
.mpa-round:disabled { opacity: .4; cursor: not-allowed; }
.mpa-round.mpa-play { border-color: var(--mpa-ink); background: var(--mpa-ink); color: #fff; }
.mpa-select {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    gap: 6px;
    min-width: 0;
    color: var(--text-sub);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
}
.mpa-select span {                    /* スマホでは場所がないので、名前は読み上げ用にだけ残す */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.mpa-select select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 6px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 10px;
    background: #fff;
    color: var(--text-main);
    font-size: 16px;
}

/* ---------- 切り替えボタン ---------- */
.mpa-seg {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mpa-seg button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 12px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 999px;
    background: #fff;
    color: #445;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: transform .15s, background .15s, border-color .15s, color .15s;
}
.mpa-seg button small {
    color: #8a96a3;
    font-size: 11px;
    font-weight: 500;
}
.mpa-seg button:active { transform: scale(.95); }
.mpa-seg button[aria-pressed="true"] {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}
.mpa-seg button[aria-pressed="true"] small { color: rgba(255, 255, 255, .88); }
.mpa-seg button:disabled { opacity: .4; cursor: not-allowed; }
.mpa-seg.sm button { min-width: 56px; }
.mpa-sizes { flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; }
.mpa-sizes button {
    flex: 1 1 0;
    flex-direction: column;
    gap: 1px;
    min-width: 44px;
    padding: 0 2px;
    font-size: 12px;
    white-space: nowrap;
}
.mpa-sizes button small { font-size: 10px; }
.mpa-moods button, .mpa-lengths button { flex: 1 1 0; flex-direction: column; gap: 1px; min-width: 0; padding: 0 6px; }
.mpa-moods button small { display: none; }            /* スマホでは幅が足りないので、内訳は出さない */
.mpa-lengths .mpa-num { flex: 0 0 auto; }
.mpa-dot {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 50%;
}

/* ---------- マイパーティクル ---------- */
.mpa-shelf {
    display: flex;
    gap: 10px;
    margin: 0 -16px;
    padding: 2px 16px 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}
.mpa-item {
    flex: 0 0 216px;
    scroll-snap-align: start;
    border: 1.5px solid var(--mpa-line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.mpa-item[data-open="true"] { border-color: var(--primary-color); background: var(--mpa-soft); }
.mpa-item-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: linear-gradient(#171c3b, #33214d);
    cursor: pointer;
}
.mpa-item-open canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.mpa-item-name { padding: 8px 10px 2px; }
.mpa-item-name strong {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mpa-item-name small { display: block; color: var(--text-sub); font-size: 11px; }
.mpa-item-name input {
    width: 100%;
    min-height: 32px;
    padding: 0 8px;
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    font-size: 16px;
}
.mpa-item-tools { display: flex; }
.mpa-item-tools button {
    flex: 1 1 0;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #5a6673;
    font-size: 14px;
    cursor: pointer;
}
.mpa-item-tools button[aria-pressed="true"] { color: #e0a100; }
.mpa-item-tools button[data-sure="true"] { color: #fff; background: #e5484d; font-size: 12px; font-weight: 800; }

/* ---------- 1. 種類を選ぶ ---------- */
.mpa-editing {
    margin: -4px 0 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--mpa-soft);
    color: #0b6b8f;
    font-size: 12.5px;
    line-height: 1.6;
}
/* ジャンルごとのカード（見出しを押すと開く・閉じる） */
.mpa-genre-tools {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin: -4px 0 10px;
}
.mpa-genre-tools .mpa-chip-btn { padding: 0 12px; font-size: 12.5px; }
.mpa-genres {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}
.mpa-genre {
    border: 1px solid var(--mpa-line);
    border-radius: 14px;
    background: #fff;
    transition: border-color .15s;
}
.mpa-genre:has(.mpa-preset[aria-pressed="true"]) { border-color: #9fdcf5; }
.mpa-genre summary {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 56px;
    padding: 10px 44px 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    list-style: none;
}
.mpa-genre summary::-webkit-details-marker { display: none; }
.mpa-genre-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.mpa-genre-title i {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--mpa-soft);
    color: var(--primary-color);
    font-size: 14px;
}
.mpa-genre-title strong { font-size: 15px; font-weight: 800; line-height: 1.3; }
.mpa-genre-title small { color: var(--text-sub); font-size: 12px; font-weight: 700; white-space: nowrap; }
.mpa-genre-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding-left: 40px;
}
.mpa-genre-now {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    background: #e6f6fd;
    color: #0081b2;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.6;
    white-space: nowrap;
}
.mpa-genre-peek {
    min-width: 0;
    overflow: hidden;
    color: var(--text-sub);
    font-size: 11.5px;
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mpa-genre[open] .mpa-genre-sub { display: none; }
.mpa-genre-caret {
    position: absolute;
    top: 50%;
    right: 16px;
    margin-top: -7px;
    color: #8a96a3;
    font-size: 14px;
    transform: rotate(-90deg);
    transition: transform .2s;
}
.mpa-genre[open] .mpa-genre-caret { transform: rotate(0); }
.mpa-genre .mpa-grid { padding: 0 8px 10px; }
.mpa-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.mpa-preset {
    position: relative;
    display: block;
    width: 100%;
    padding: 4px 4px 8px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--mpa-soft);
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.mpa-preset:active { transform: scale(.97); }
.mpa-preset canvas {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    background: linear-gradient(#171c3b, #33214d);
}
.mpa-preset strong {
    display: block;
    margin: 7px 4px 0;
    font-size: 13.5px;
    font-weight: 800;
    line-height: 1.3;
}
.mpa-preset small {
    display: block;
    margin: 2px 4px 0;
    overflow: hidden;
    color: var(--text-sub);
    font-size: 11px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mpa-preset[aria-pressed="true"] { border-color: var(--primary-color); background: #fff; box-shadow: 0 6px 16px rgba(0, 174, 239, .18); }
.mpa-preset[aria-pressed="true"] strong { color: #0081b2; }
.mpa-preset[aria-pressed="true"] strong::before { content: '✓ '; }
.mpa-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    pointer-events: none;
}
.mpa-badges i {
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(20, 22, 29, .78);
    color: #fff;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    line-height: 1.5;
}
.mpa-use {
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--mpa-soft);
    color: #445;
    font-size: 12.5px;
    line-height: 1.7;
}
.mpa-use:empty { display: none; }

/* ---------- 2. 色・量・動き ---------- */
.mpa-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}
.mpa-field:last-child { margin-bottom: 0; }
.mpa-field-label {
    flex: 0 0 auto;
    min-width: 3.2em;
    padding-top: 12px;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 700;
}
.mpa-field-body { flex: 1 1 auto; min-width: 0; }
.mpa-swatches {
    display: flex;
    gap: 6px;
    margin: 0 -16px 0 0;
    padding: 3px 16px 3px 3px;
    overflow-x: auto;
    scrollbar-width: none;
}
.mpa-swatches::-webkit-scrollbar { display: none; }
.mpa-swatches button {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 44px;
    height: 44px;
    padding: 0 9px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 999px;
    background: #2a2d3a;                 /* 白い粒の色も見えるように、暗い下地にする */
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.mpa-swatches button:active { transform: scale(.93); }
.mpa-swatches button[aria-pressed="true"] { border-color: var(--primary-color); box-shadow: 0 0 0 2.5px var(--primary-color); }
.mpa-swatches button i {              /* 色の丸 */
    display: block;
    width: 16px;
    height: 16px;
    margin-left: -6px;
    border: 1.5px solid #2a2d3a;
    border-radius: 50%;
}
.mpa-swatches button i:first-child { z-index: 2; width: 22px; height: 22px; margin-left: 0; }
.mpa-swatches button i:nth-child(2) { z-index: 1; }
.mpa-swatches button span { margin-left: 6px; white-space: nowrap; }
.mpa-swatches .rainbow i {
    width: 22px;
    height: 22px;
    background: conic-gradient(#ff3b30, #ff9500, #ffcc00, #ff2bd6, #af52de, #007aff, #ff3b30);
}
.mpa-swatches .more { background: #fff; color: #445; }
.mpa-custom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--mpa-soft);
}
.mpa-pick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
}
.mpa-pick input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}
.mpa-pick input:disabled { opacity: .45; cursor: not-allowed; }
.mpa-bg-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.mpa-seed-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* スライダーの行：名前／スライダー／数値 */
.mpa-rows { margin: 0 0 12px; }
.mpa-row {
    display: grid;
    grid-template-columns: 5.2em minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    font-size: 13px;
}
.mpa-row > label { color: var(--text-sub); font-weight: 700; line-height: 1.3; }
.mpa-row > label small { display: block; color: #8a96a3; font-size: 10px; font-weight: 500; }
.mpa-row input[type="range"] {
    width: 100%;
    min-width: 0;
    height: 44px;
    margin: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}
.mpa-num {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--text-sub);
    font-size: 12px;
}
.mpa-num input {
    width: 3.9em;
    height: 40px;
    padding: 0 4px;
    border: 1.5px solid var(--input-border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-main);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}
.mpa-num input::-webkit-outer-spin-button, .mpa-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mpa-num input:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 4px var(--input-focus-ring); }
.mpa-num.wide input { width: 8.6em; }
.mpa-num i { font-style: normal; }
.mpa-rect {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin: 10px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--mpa-soft);
    font-size: 12.5px;
    font-weight: 700;
}
.mpa-rect label { display: inline-flex; align-items: center; gap: 6px; }
.mpa-rect-title { flex: 0 0 auto; color: var(--text-sub); }
.mpa-reset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 14px; }

/* ---------- 3. 保存 ---------- */
.mpa-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 8px;
    margin: 4px 0 12px;
}
.mpa-shortcuts button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 66px;
    padding: 11px 10px 7px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 12px;
    background: #fff;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.mpa-shortcuts button > i {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mpa-soft);
    color: #0081b2;
    font-size: 14px;
}
.mpa-shortcuts strong { display: block; font-size: 12.5px; font-weight: 800; line-height: 1.3; }
.mpa-shortcuts small { display: block; color: var(--text-sub); font-size: 10.5px; line-height: 1.35; }
.mpa-shortcuts button[aria-pressed="true"] { border-color: var(--primary-color); background: var(--mpa-soft); }
.mpa-shortcuts button[aria-pressed="true"] > i { background: var(--primary-color); color: #fff; }
.mpa-shortcuts em {
    position: absolute;
    top: -10px;
    right: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-yellow);
    color: var(--mpa-ink);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
    line-height: 1.6;
}
.mpa-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.mpa-check input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}
.mpa-check small { display: block; color: var(--text-sub); font-size: 11px; font-weight: 500; }
.mpa-check.sm { font-size: 12px; }
.mpa-hint {
    margin: 2px 0 12px;
    color: var(--text-sub);
    font-size: 12.5px;
    line-height: 1.75;
}
.mpa-hint:empty { display: none; }
.mpa-hint.warn {
    padding: 9px 12px;
    border: 1px solid #fbd38d;
    border-radius: 10px;
    background: #fffaf0;
    color: #975a16;
}
.mpa-hint.warn button {
    margin-left: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: #007ea9;
    font-size: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}
.mpa-summary {
    margin: 4px 0 8px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--mpa-soft);
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.7;
    font-variant-numeric: tabular-nums;
}
.mpa-save-row { display: grid; }
.mpa-keep-row { text-align: center; }
.mpa .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    font-size: 14px;
}
.mpa .btn:hover { transform: translateY(-1px); }
.mpa .btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.mpa .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.mpa .mpa-save {
    width: 100%;
    min-height: 58px;
    font-size: 17px;
    box-shadow: 0 10px 22px rgba(0, 174, 239, .3);
}
.mpa-keep { gap: 6px; font-size: 12.5px; }
.mpa-keep:disabled { opacity: .5; }
.mpa-status {
    margin-top: 10px;
    color: #0b6b8f;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.6;
}
.mpa-status:empty { display: none; }
.mpa-toast {
    position: fixed;
    z-index: 2000;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(520px, calc(100% - 32px));
    padding: 14px 18px;
    border: 1px solid #feb2b2;
    border-radius: 12px;
    background: #fff5f5;
    color: #9b2c2c;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .16);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
}
.mpa-toast[hidden] { display: none; }
.mpa-alert {
    margin-top: 12px;
    padding: 11px 14px;
    border: 1px solid #feb2b2;
    border-radius: 10px;
    background: #fff5f5;
    color: #c53030;
    font-size: 13px;
    line-height: 1.7;
}
.mpa-alert button {
    margin-left: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: #007ea9;
    font-size: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}
.mpa-result {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #b2f5ea;
    border-radius: 12px;
    background: #e6fffa;
    color: #2c7a7b;
}
.mpa-result-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.5;
}
.mpa-result-title i { margin-top: 3px; }
.mpa-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.mpa-result-meta {
    margin-top: 8px;
    font-size: 12px;
    overflow-wrap: anywhere;
}
.mpa-result-tip {
    margin-top: 6px;
    color: #285e61;
    font-size: 12.5px;
    line-height: 1.75;
}
/* OBS・配信 */
.mpa-obs {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--mpa-soft);
}
.mpa-obs h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 800;
}
.mpa-obs h3 i { color: var(--primary-color); }
.mpa-obs p { color: var(--text-sub); font-size: 12.5px; line-height: 1.7; }
.mpa-obs .btn { margin-top: 8px; }
/* 次にやること */
.mpa-next {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--mpa-line);
}
.mpa-next h3 { margin-bottom: 8px; font-size: 14px; font-weight: 800; }
.mpa-next-item {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--mpa-soft);
}
.mpa-next-item + .mpa-next-item { margin-top: 8px; }
.mpa-next-item > strong { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 800; }
.mpa-next-item p { margin-bottom: 8px; color: var(--text-sub); font-size: 12.5px; line-height: 1.7; }
.mpa-next-buttons, .mpa-next-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mpa-next-row { background: none; padding: 0; }
.mpa-next-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.mpa-next-cards .mpa-preset { background: #fff; }

/* ---------- 詳細設定 ---------- */
.mpa-details { padding: 0; }
.mpa-details summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    min-height: 44px;
    padding: 14px 44px 14px 16px;
    position: relative;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}
.mpa-details summary::-webkit-details-marker { display: none; }
.mpa-details summary span {
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 500;
}
.mpa-details summary::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -7px;
    border-right: 2.5px solid #8a96a3;
    border-bottom: 2.5px solid #8a96a3;
    transform: rotate(-45deg);
    transition: transform .2s;
}
.mpa-details[open] summary::after { transform: rotate(45deg); }
.mpa-details-body { padding: 0 16px 18px; }
.mpa-details-body > .mpa-seg { margin-bottom: 8px; }

/* ---------- 説明コンテンツ ---------- */
.mpa-doc {
    max-width: 860px;
    margin-top: 46px;
}
.mpa-doc section { margin-bottom: 38px; }
.mpa-doc h2 {
    margin-bottom: 14px;
    font-size: clamp(19px, 3vw, 23px);
    font-weight: 800;
    line-height: 1.5;
}
.mpa-doc h3 {
    margin: 22px 0 10px;
    font-size: 16px;
    font-weight: 800;
}
.mpa-doc p {
    color: #444;
    font-size: 15px;
    line-height: 2;
}
.mpa-doc p + p { margin-top: 10px; }
.mpa-doc .mpa-small { color: var(--text-sub); font-size: 13px; }
.mpa-related { margin-bottom: 38px; }
.mpa-related .image-movie-links {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}
.mpa-steps {
    display: grid;
    gap: 12px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: mpa-step;
}
.mpa-steps li {
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: 14px;
    background: var(--mpa-soft);
    counter-increment: mpa-step;
}
.mpa-steps li::before {
    content: counter(mpa-step);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-yellow);
    font-weight: 800;
}
.mpa-steps strong { font-size: 15px; }
.mpa-steps p { margin-top: 2px; font-size: 13.5px; line-height: 1.8; }
.mpa-bullets, .mpa-numbers {
    margin: 12px 0;
    padding-left: 1.3em;
    list-style: disc;
    color: #444;
    font-size: 14.5px;
    line-height: 2;
}
.mpa-numbers { padding-left: 1.6em; list-style: decimal; }
/* 種類の一覧（名前を押すと、その種類を選ぶ） */
.mpa-kinds {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: #444;
    font-size: 14px;
    line-height: 1.8;
}
.mpa-kinds li {
    padding: 8px 12px 10px;
    border-radius: 12px;
    background: var(--mpa-soft);
}
.mpa-kinds button, .mpa-table button, .mpa-sample button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-right: 10px;
    padding: 0 14px;
    border: 1.5px solid var(--mpa-line);
    border-radius: 999px;
    background: #fff;
    color: #0081b2;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
}
.mpa-kinds button { display: flex; width: max-content; max-width: 100%; margin: 0 0 4px; }
/* 代表的な種類の見本（実際の素材の1コマ） */
.mpa-samples {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 6px;
}
.mpa-sample {
    margin: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--mpa-soft);
}
.mpa-sample img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background: linear-gradient(#141a3a, #3a2456);
}
.mpa-sample figcaption {
    padding: 8px 12px 10px;
    color: #444;
    font-size: 13px;
    line-height: 1.7;
}
.mpa-sample button { display: flex; width: max-content; max-width: 100%; margin: 0 0 4px; }
.mpa-terms { text-align: center; }
.mpa-terms a { color: #0081b2; text-decoration: underline; }
.mpa-table button { margin: 2px 6px 2px 0; }
.mpa-table-wrap {
    margin-top: 14px;
    overflow-x: auto;
    border: 1px solid var(--mpa-line);
    border-radius: 14px;
}
.mpa-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.75;
}
.mpa-table th, .mpa-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--mpa-line);
    text-align: left;
    vertical-align: top;
}
.mpa-table thead th { background: var(--mpa-soft); font-size: 12.5px; }
.mpa-table tbody th { white-space: nowrap; }
.mpa-table tbody tr:last-child th, .mpa-table tbody tr:last-child td { border-bottom: 0; }
.mpa-table small { color: var(--text-sub); font-weight: 500; }
.faq-list {
    overflow: hidden;
    border: 1px solid #eee;
    border-radius: 16px;
}
.faq-list details { border-bottom: 1px solid #eee; }
.faq-list details:last-child { border: 0; }
.faq-list summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::before {
    content: 'Q';
    color: var(--primary-color);
    font-size: 18px;
}
.faq-list summary::after {
    content: '+';
    margin-left: auto;
    color: #666;
    font-size: 20px;
}
.faq-list details[open] { background: var(--bg-light); }
.faq-list details[open] summary::after { content: '−'; }
.faq-list p {
    margin: 0 20px 20px 46px;
    color: #666;
    font-size: 13px;
    line-height: 1.9;
}
.mpa-related-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 24px;
    margin-top: 28px;
    color: #007ea9;
    font-size: 13px;
}
.mpa-related-links a { text-decoration: underline; }

/* ---------- 画面の高さが足りないときは、プレビューを固定しない ---------- */
@media (max-height: 560px) {
    .mpa-stage { position: static; }
}

/* ---------- タブレット以上 ---------- */
@media (min-width: 620px) {
    .mpa-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mpa-steps li { flex-direction: column; gap: 8px; }
    .mpa-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
    .mpa-next-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mpa-swatches { flex-wrap: wrap; overflow: visible; }
    .mpa-kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mpa-samples { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mpa-sizes { flex: 0 1 auto; }
    .mpa-sizes button { padding: 0 12px; }
    .mpa-transport { justify-content: space-between; }
    .mpa-moods button small { display: block; }
    .mpa-select span { position: static; width: auto; height: auto; max-width: 4.2em; overflow: visible; clip-path: none; white-space: normal; }
    .mpa-row { grid-template-columns: 6.4em minmax(0, 1fr) auto; }
}

/* ---------- PC：左に 1・2・詳細設定、右にプレビューと保存を固定表示 ---------- */
@media (min-width: 980px) {
    .mpa-intro { padding-top: 34px; padding-bottom: 20px; }
    .mpa-app {
        grid-template-columns: minmax(0, 1fr) minmax(0, 430px);
        gap: 18px 26px;
        align-items: start;
    }
    .mpa-main { grid-column: 1; grid-row: 1; gap: 18px; }
    .mpa-stage {
        grid-column: 2;
        grid-row: 1;
        top: 98px;
        margin: 0;
        padding: 12px;
        border: 1px solid var(--mpa-line);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .05);
    }
    /* 保存はプレビューのすぐ下に固定する。画面の高さに収まらないぶんは、カードの中でスクロールする */
    .mpa-save-card {
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: calc(98px + var(--mpa-stage-h) + 14px);
        margin-top: calc(var(--mpa-stage-h) + 14px);
        max-height: max(240px, calc(100vh - 98px - var(--mpa-stage-h) - 26px));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    /* 保存ボタンは、カードの中をスクロールしても下に残す */
    .mpa-save-row {
        position: sticky;
        bottom: -20px;
        z-index: 2;
        margin: 0 -20px;
        padding: 12px 20px 14px;
        background: linear-gradient(rgba(255, 255, 255, 0), #fff 12px);
    }
    .mpa-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
    .mpa-card { padding: 20px; }
    .mpa-swatches { margin: 0; padding: 3px; }
    .mpa-shelf { margin: 0 -20px; padding: 2px 20px 8px; }
    .mpa-details { padding: 0; }
    .mpa-details-body { padding: 0 20px 20px; }
    .mpa-details summary { padding: 16px 48px 16px 20px; }
    .mpa-sizes { flex: 1 1 auto; }
    .mpa-sizes button { padding: 0 2px; }
    .mpa-next-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 980px) and (max-height: 620px) {
    .mpa-stage, .mpa-save-card { position: static; }
    .mpa-save-card { max-height: none; margin-top: 0; overflow: visible; grid-row: 2; }
    .mpa-save-row { position: static; }
}

@media (hover: hover) {
    .mpa-chip-btn:not(:disabled):hover, .mpa-seg button:not(:disabled):hover, .mpa-round:not(:disabled):hover,
    .mpa-shortcuts button:hover, .mpa-kinds button:hover, .mpa-table button:hover, .mpa-sample button:hover { border-color: var(--primary-color); }
    .mpa-seg button[aria-pressed="true"]:hover { border-color: var(--primary-hover); }
    .mpa-round.mpa-play:hover { border-color: var(--mpa-ink); }
    .mpa-genre summary:hover { background: var(--mpa-soft); }
    .mpa-genre summary:hover .mpa-genre-caret { color: var(--primary-color); }
    .mpa-preset:hover { border-color: #9fdcf5; }
    .mpa-preset[aria-pressed="true"]:hover { border-color: var(--primary-color); }
    .mpa-swatches button:hover { transform: scale(1.06); }
    .mpa-item-tools button:hover { background: var(--mpa-soft); color: var(--text-main); }
    .mpa-item-tools button[data-sure="true"]:hover { background: #c53030; color: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    .loading-bars span { animation-duration: 2.4s; }
    .mpa *, .mpa *::after { transition: none !important; }
}
