:root {
    --bg: #171717;
    --panel: #212121;
    --panel2: #2a2a2a;
    --border: #454545;
    --text: #f0f0ed;
    --dim: #aaa9a3;
    --accent: #67b7ff;
    --ok: #65ce83;
    --warn: #f1bd55;
    --err: #ff7b72;
    --emerald: #50c878; /* 選択中タブの文字色（2026-07-12 ボタン配色統一） */
    --brand-gold: #f5a623;
    --brand-red: #e94560;
    --brand-bg: #0d0d1a;
    --nav-height: 64px;
    --sidebar-width: 250px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--nav-height);
    padding-left: var(--sidebar-width);
    transition: padding-left 0.25s ease;
}
.tool-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 18px;
    height: var(--nav-height);
    padding: 0 20px;
    background: rgba(13, 13, 26, 0.96);
    border-bottom: 1px solid rgba(245, 166, 35, 0.28);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(14px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
.tool-header h1 { font-size: 16px; text-align: center; letter-spacing: 0.08em; }
.header-left { justify-self: start; display: flex; align-items: center; gap: 13px; min-width: 0; }
.nav-logo {
    color: var(--brand-gold);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}
.nav-logo span, .footer-logo span, .sidebar-brand > span { color: var(--brand-red); }
.nav-logo:hover { filter: brightness(1.15); }
.sidebar-toggle, .sidebar-close {
    display: inline-grid;
    place-items: center;
    color: var(--brand-gold);
    background: transparent;
    border: 1px solid rgba(245, 166, 35, 0.38);
    border-radius: 7px;
}
.sidebar-toggle { width: 36px; height: 36px; padding: 0; font-size: 18px; }
.sidebar-toggle:hover, .sidebar-close:hover { color: #11111c; background: var(--brand-gold); }
.header-actions { justify-self: end; display: flex; gap: 8px; }
main { width: 100%; flex: 1 0 auto; padding: 20px; max-width: 1100px; margin: 0 auto; }

/* 公式サイトと同じ開閉パターンの制作メニュー。PC は初期表示、モバイルはオーバーレイ表示。 */
.tool-sidebar {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    z-index: 90;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow: auto;
    color: #f5f2ea;
    background:
        radial-gradient(circle at 15% 0%, rgba(245, 166, 35, 0.16), transparent 30%),
        linear-gradient(165deg, rgba(22, 22, 42, 0.99), rgba(8, 8, 18, 0.99));
    border-right: 1px solid rgba(245, 166, 35, 0.27);
    box-shadow: 14px 0 36px rgba(0, 0, 0, 0.32);
    transform: translateX(0);
    transition: transform 0.25s ease;
}
body.sidebar-closed { padding-left: 0; }
body.sidebar-closed .tool-sidebar { transform: translateX(-101%); }
.sidebar-hero { position: relative; padding: 23px 18px 17px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-hero::after {
    content: '';
    position: absolute;
    left: 18px;
    bottom: -1px;
    width: 64px;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-gold), var(--brand-red));
}
.sidebar-eyebrow { color: var(--brand-gold); font-size: 9px; font-weight: 800; letter-spacing: 0.17em; }
.sidebar-title { margin-top: 3px; font-size: 16px; font-weight: 750; }
.sidebar-hero p { margin-top: 9px; color: #9c9aaa; font-size: 11px; line-height: 1.55; }
.sidebar-close { position: absolute; top: 16px; right: 13px; width: 28px; height: 28px; padding: 0; font-size: 19px; }
.sidebar-nav { display: grid; gap: 5px; padding: 17px 12px 10px; }
.sidebar-section-title { padding: 0 9px 6px; color: #727083; font-size: 9px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
button.sidebar-link {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    justify-items: start;
    gap: 1px;
    width: 100%;
    padding: 10px 12px;
    color: #d8d5de;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    text-align: left;
}
button.sidebar-link::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: transparent;
}
button.sidebar-link > svg { grid-row: 1 / 3; align-self: center; width: 17px; height: 17px; }
button.sidebar-link > span:not(.nav-ico) { grid-column: 2; }
button.sidebar-link small { grid-column: 2; color: #777587; font-size: 9px; font-weight: 500; }
button.sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.055); border-color: rgba(255,255,255,0.07); }
button.sidebar-link.is-active {
    color: var(--brand-gold);
    background: linear-gradient(90deg, rgba(245,166,35,0.13), rgba(233,69,96,0.045));
    border-color: rgba(245,166,35,0.18);
}
button.sidebar-link.is-active::before { background: var(--brand-red); box-shadow: 0 0 12px rgba(233,69,96,0.65); }
button.sidebar-link.is-active small { color: #bc9b68; }
.sidebar-lower { margin-top: auto; padding: 13px 12px; border-top: 1px solid rgba(255,255,255,0.07); }
.sidebar-language {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    color: #d8d5de;
}
.sidebar-language-icon { font-size: 14px; }
.sidebar-language-copy { display: grid; line-height: 1.3; font-size: 11px; }
.sidebar-language-copy small { color: #777587; font-size: 9px; }
.sidebar-language select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 10px; }
button.sidebar-account { grid-template-columns: auto 1fr; align-items: center; margin-top: 3px; }
button.sidebar-account[hidden] { display: none; }
.sidebar-account .nav-account-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.sidebar-account > .nav-ico, .sidebar-account > .nav-account-avatar { grid-column: 1; grid-row: 1; }
.sidebar-account > span:last-child { grid-column: 2; grid-row: 1; }
.sidebar-brand { padding: 14px 20px 19px; color: var(--brand-gold); font-size: 15px; font-weight: 800; }
.sidebar-brand small { display: block; margin-top: 2px; color: #5f5d70; font-size: 7px; letter-spacing: 0.19em; }
.sidebar-backdrop { display: none; position: fixed; inset: var(--nav-height) 0 0; z-index: 80; background: rgba(0,0,0,0.62); backdrop-filter: blur(2px); }
h2 { font-size: 18px; margin: 8px 0 14px; }
h3 { font-size: 15px; margin: 14px 0 8px; color: var(--accent); }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.card h3:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
button {
    background: var(--accent);
    color: #08121f;
    border: none;
    border-radius: 6px;
    /* 2026-07-11 指示: 全ボタンの上下左右余白を従来（7px 14px・min-height 36px）の半分へ統一 */
    padding: 4px 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
/* ── ボタン配色の統一（2026-07-12 指示・4 パターン）──────────────────
   (1) 黒背景＋黄色文字   = 有料コストが発生する処理（class "cost"。ラベル一致で JS が自動付与）
   (2) 水色背景＋黒文字   = コスト非発生の処理（既定。secondary も同色へ統一）
   (3) 黒背景＋白文字     = タブ等の選択項目の未選択状態（.tabs button / header nav）
   (4) 黒背景＋エメラルド = 選択項目のアクティブ状態（.tabs button.active）
   例外: button.danger（削除等の破壊的操作）は誤操作防止のため赤背景を維持 */
button.secondary { background: var(--accent); color: #08121f; border: none; }
button.cost { background: var(--panel2); color: #ffd400; border: 1px solid var(--border); }
button.danger { background: var(--err); color: #1c0808; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 3px solid rgba(103, 183, 255, 0.55);
    outline-offset: 2px;
}
input[type="text"], input[type="password"], textarea, select {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 9px;
    font-size: 13px;
    width: 100%;
}
input[type="text"], input[type="password"], select { min-height: 38px; }
textarea { font-family: Consolas, "Cascadia Mono", monospace; min-height: 160px; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; color: var(--dim); font-size: 12px; margin-bottom: 3px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.actions + .actions { margin-top: 8px; } /* ③キャストカード等の複数段ボタンは行間を詰める */
/* カード見出しの右にボタンを並べる行（例: プロンプト表示カードの「英語プロンプトをコピー」） */
.head-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.head-row h3 { margin: 0; }
.head-row form[method="dialog"] { margin-left: auto; } /* ダイアログの「閉じる」は右寄せ */
/* ③キャストカードの画像・GLB 情報テーブル（項目｜内容｜操作の 3 列・罫線つき） */
table.cast-info { display: table; width: 100%; margin: 6px 0; color: var(--dim); }
.cast-info th { width: 1%; white-space: nowrap; font-weight: 600; }
.cast-info th, .cast-info td { padding: 3px 8px; font-size: 12px; }
.cast-info td { overflow-wrap: anywhere; }
.cast-info td.cast-info-action { width: 1%; white-space: nowrap; text-align: right; vertical-align: middle; padding: 2px 4px; }
button.btn-xs { min-height: 0; padding: 2px 8px; font-size: 12px; font-weight: 500; }
button.btn-xs .btn-ico { width: 12px; height: 12px; }
/* ⑤-2 JSON生成一覧（選択｜項目｜ファイル｜状態｜操作） */
.generate-unit-table-wrap { overflow-x: auto; }
table.generate-unit-table { display: table; width: 100%; margin: 8px 0; }
.generate-unit-table th, .generate-unit-table td { vertical-align: middle; }
.generate-unit-table .generate-unit-check { width: 1%; white-space: nowrap; text-align: center; }
.generate-unit-table .generate-unit-check label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.generate-unit-table .generate-unit-action { width: 1%; white-space: nowrap; text-align: center; }
.json-edit-dialog { width: min(1000px, calc(100vw - 32px)); }
.json-edit-dialog textarea { height: min(65vh, 680px); min-height: 360px; resize: vertical; }
.game-settings-edit { margin-left: auto; }
.game-settings-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
.game-settings-dialog textarea { min-height: 92px; resize: vertical; }
.game-settings-dialog small { display: block; margin-top: 4px; text-align: right; }
.game-settings-dialog .actions form { margin: 0; }
/* 生成ログ表示ダイアログのログ欄（ReadOnly・スクロール可） */
textarea.log-box { background: #0d1117; font-size: 12px; min-height: 120px; height: 190px; margin: 4px 0 12px; white-space: pre; overflow: auto; }
.generation-log-dialog textarea.log-box { width: min(80vw, 980px); height: min(65vh, 620px); }
pre.log {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 12px;
    max-height: 380px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.dim { color: var(--dim); }
.badge {
    display: inline-block;
    font-size: 11px;
    border-radius: 4px;
    padding: 1px 9px;
    margin-left: 6px;
    border: 1px solid var(--border);
    color: var(--dim);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.err { color: var(--err); border-color: var(--err); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
/* 選択項目（タブ）: 未選択 = 黒背景＋白文字 ／ 選択中 = 黒背景＋エメラルドグリーン文字 */
.tabs button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.tabs button.active { background: var(--panel2); color: var(--emerald); border-color: var(--emerald); font-weight: 700; }
table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
th { background: var(--panel2); color: var(--dim); font-weight: 600; }
ul.plain { list-style: none; }
ul.plain li { padding: 3px 0; border-bottom: 1px dashed #2a323d; }
.checklist label { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; cursor: pointer; }
.checklist .checklist-master { font-weight: 600; border-bottom: 1px solid #2a3646; padding-bottom: 6px; margin-bottom: 2px; }
a { color: var(--accent); }
.muted-note { color: var(--dim); font-size: 12px; margin-top: 6px; }
.project-status { display: grid; gap: 8px; margin-top: 10px; min-width: 0; }
.project-status-steps, .project-status-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.project-status-steps .badge { margin-left: 0; }
/* 進捗チップはクリックで該当工程タブへ移動できる */
.project-status-steps .step-chip { cursor: pointer; }
.project-status-steps .step-chip:hover { filter: brightness(1.35); text-decoration: underline; }
.project-status-actions:empty { display: none; }

/* ── 物語ドキュメント駆動モード（F13〜F17）── */
textarea.tall { min-height: 300px; }
textarea.mono { font-size: 12px; line-height: 1.5; }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.card.warn { border-color: var(--warn); }
iframe.viewer { width: 100%; height: 440px; border: 1px solid var(--border); border-radius: 8px; background: #151515; }
details summary { cursor: pointer; color: var(--dim); padding: 4px 0; }
details[open] summary { color: var(--text); }
input[type="file"] { color: var(--dim); }
/* キャラ表示画像: 2026-07-13 指示で縦横 30% 縮小（max-height 260px → 182px） */
img.prompt-thumb { display: block; max-width: 100%; max-height: 182px; margin: 6px 0; border: 1px solid var(--border); border-radius: 8px; background: #151515; object-fit: contain; }
/* キャラ画像（左セル）とプロンプト・ログ操作（右セル）を固定分離するテーブル */
table.cast-visual { width: 100%; border-collapse: collapse; margin: 6px 0; }
table.cast-visual td { vertical-align: top; }
table.cast-visual .cast-visual-image { width: 1%; white-space: nowrap; }
/* max-width:100% のままだと幅1%セル基準で画像が0幅へ潰れる（2026-07-13 実障害）。
   セル内では解除し、高さ182px（元260pxの30%減）×縦横比どおりの実寸で表示する */
table.cast-visual .cast-visual-image img.prompt-thumb { margin: 0; max-width: none; width: auto; }
table.cast-visual .cast-visual-actions { padding-left: 12px; }
table.cast-visual .cast-visual-actions button { display: block; margin: 0 0 8px; }
.cast-cost-summary { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; margin-top: 4px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cast-cost-summary > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; padding: 5px 6px; font-size: 12px; color: var(--dim); }
.cast-cost-summary > div + div { border-top: 1px solid var(--border); }
.cast-cost-summary .cast-cost-title { min-width: 0; font-size: 80%; white-space: nowrap; }
.cast-cost-summary strong { color: var(--text); font-weight: 600; white-space: nowrap; }
.cast-cost-summary .glb-cost-row { gap: 2px; }
.cast-cost-summary .glb-cost-value { min-width: 0; }
.cast-cost-summary .glb-cost-estimate { font-size: 90%; }
img.model-thumb { display: block; width: 72px; height: 72px; border: 1px solid var(--border); border-radius: 8px; background: #151515; object-fit: contain; }
/* API キー入力欄: 画面幅の約80%を常時確保（OpenRouter / Meshy 共通） */
label.field.key-field { width: 80%; max-width: none; }
/* label.field span（display:block）より詳細度を上げないと flex が上書きされ、入力欄がデフォルト幅（約20文字）に縮む */
label.field span.key-input-wrap { display: flex; gap: 6px; align-items: center; }
.key-input-wrap input { flex: 1; width: auto; min-width: 0; }
.key-input-wrap .key-eye { display: inline-flex; align-items: center; justify-content: center; padding: 3px 5px; background: var(--accent); color: #08121f; border: none; border-radius: 6px; cursor: pointer; line-height: 1; }
.key-input-wrap .key-eye:hover { filter: brightness(1.1); }

/* API設定: OpenRouterの用途別モデル。入力欄の右に保存／既定値ボタンを固定し、
   コスト情報は次の行を全幅で表示する。 */
.openrouter-model-settings { margin: 18px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.openrouter-model-settings h4 { margin: 0 0 6px; color: var(--accent); font-size: 14px; }
.model-setting-row {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    gap: 7px 10px;
    align-items: end;
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.model-setting-row:first-of-type { margin-top: 10px; }
label.field.model-setting-field { min-width: 0; margin: 0; }
label.field.model-setting-field > small { display: block; min-height: 1.5em; margin: 0 0 4px; color: var(--dim); font-size: 10px; }
.model-setting-actions { display: flex; gap: 6px; align-items: center; padding-bottom: 1px; white-space: nowrap; }
.model-pricing {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 3px 14px;
    min-width: 0;
    padding: 6px 8px;
    color: var(--dim);
    background: rgba(0,0,0,0.14);
    border-radius: 5px;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 10px;
    overflow-wrap: anywhere;
}
.model-pricing b { color: var(--text); font-weight: 600; }
.model-pricing .model-image-metric { flex-basis: 100%; }
.model-pricing .model-image-metric b { color: var(--text); font-size: 12px; }
.model-price-source { flex-basis: 100%; color: var(--dim); font-family: inherit; }
.model-active-row { margin-top: 4px; border-top-color: rgba(103,183,255,0.32); }

/* ── 実行中ロック（スピナー＋誤操作防止オーバーレイ）── */
@keyframes busy-spin { to { transform: rotate(360deg); } }
/* 処理待ちメッセージの点滅（目立たせる） */
@keyframes busy-blink {
    0%, 49% { opacity: 1; filter: brightness(1.2); }
    50%, 100% { opacity: 0.08; filter: brightness(0.5); }
}
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,212,0,0.3); border-top-color: #ffd400; border-radius: 50%; animation: busy-spin 0.8s linear infinite; vertical-align: -3px; }
/* 中央の処理待ちアイコンは進行中であることを伝える状態表示なので、動きの抑制設定でも回転を維持する。 */
.busy-spinner { animation: busy-spin 0.8s linear infinite !important; will-change: transform; }
.file-change-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.file-change-dialog::backdrop { background: rgba(0, 0, 0, 0.68); }
.glb-change-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 1fr) auto; gap: 10px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); }
.glb-change-row [data-glb-status] { grid-column: 1 / -1; }
@media (max-width: 680px) { .glb-change-row { grid-template-columns: 1fr; } .glb-change-row [data-glb-status] { grid-column: 1; } }
button.loading { opacity: 0.65; pointer-events: none; position: relative; }
button.loading::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 8px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: busy-spin 0.8s linear infinite; vertical-align: -1px; }
#busy-lock { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 11, 18, 0.25); cursor: wait; }
/* 処理待ちメッセージ: 画面中央にセンタリング */
#busy-chip { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 30px; background: #1c2030; border: 2px solid var(--accent, #7aa2ff); border-radius: 24px; box-shadow: 0 10px 32px rgba(0,0,0,0.6); }
.busy-chip-row { display: flex; align-items: center; gap: 12px; }
/* 一括実行の進捗バー（バーが上段・メッセージが下段） */
#busy-progress { display: flex; align-items: center; gap: 8px; width: min(260px, 36vw); }
#busy-progress-track { flex: 1; height: 14px; background: rgba(255,255,255,0.12); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
#busy-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #67b7ff, #65ce83); border-radius: 999px; transition: width 0.5s ease; }
#busy-progress-pct { font-weight: 700; font-size: 10px; color: #ffd400; min-width: 3.2em; text-align: right; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
/* 重要な処理状態なので、OSの動き抑制設定にかかわらず明確にON/OFF点滅させる。
   サイズは全処理待ちメッセージ共通の 10px（2026-07-11 指示: 従来 20px の半分・PC/モバイル統一）。 */
#busy-label { font-weight: 700; font-size: 10px; color: #ffd400; text-shadow: 0 1px 3px rgba(0,0,0,0.6); animation: busy-blink 1s step-end infinite !important; will-change: opacity, filter; }

@media (max-width: 768px) {
    body, body.sidebar-closed { padding-left: 0; }
    .tool-header { grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 0 12px; }
    .tool-header h1 { font-size: 13px; letter-spacing: 0.03em; }
    .header-left { gap: 6px; }
    .nav-logo { display: block; font-size: 13px; }
    .header-actions { display: none; }
    .tool-sidebar { width: min(300px, 86vw); transform: translateX(-101%); }
    body.sidebar-open .tool-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; }
    main { padding: 12px; }
    .card { padding: 12px; }
    .grid { grid-template-columns: minmax(0, 1fr); }
    .row { display: grid; grid-template-columns: minmax(0, 1fr); }
    .row > * { min-width: 0; }
    .actions > button { flex: 1 1 auto; }
    label.field.key-field { width: 100%; }
    .model-setting-row { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
    .model-setting-actions { flex-wrap: wrap; }
    .model-setting-actions > button { flex: 1 1 auto; }
    .project-status-actions > button { flex: 1 1 180px; min-width: 0; white-space: normal; }
    iframe.viewer { height: 58vh; min-height: 300px; }
    #busy-chip { width: calc(100% - 32px); max-width: 440px; padding: 14px 18px; border-radius: 8px; }
    #busy-label { overflow-wrap: anywhere; } /* フォントサイズは PC と統一（共通 10px） */
}
@media (max-width: 360px) {
    .tool-header { gap: 4px; padding: 0 8px; }
    .tool-header h1 { font-size: 12px; }
    .nav-logo { font-size: 11px; }
    .sidebar-toggle { width: 32px; height: 32px; }
}

/* 動きの抑制設定: 装飾的な回転だけを止める。中央の .busy-spinner と #busy-label は処理状態表示なので維持する。 */
@media (prefers-reduced-motion: reduce) {
    .spinner, button.loading::after { animation: none; }
}

/* 認証画面（ログイン・登録・再設定・アカウント）: フォームは読みやすい幅に絞って中央寄せ */
.auth-card { max-width: 460px; margin-left: auto; margin-right: auto; }
.auth-card .field input { width: 100%; }

/* プロフィールのアバターURLは、保存前にも実画像を確認できるよう同じカード内へ表示する。 */
.profile-avatar-preview {
    min-height: 108px;
    margin: 2px 0 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel2);
    display: flex;
    align-items: center;
    gap: 12px;
}
.profile-avatar-preview-image {
    width: 90px;
    height: 90px;
    flex: none;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
}
.profile-avatar-preview-image[hidden] { display: none; }

/* SNS ログインボタン: 先頭にブランドアイコン（一般的な OAuth ボタンの標準形） */
.oauth-btn { display: inline-flex; align-items: center; gap: 8px; }
.oauth-btn svg { flex: none; }

/* 認証画面の標準レイアウト: 主ボタン・SNSボタンは全幅、パスワード直下に補助リンク、区切り線つき導線 */
.auth-card form button[type="submit"] { width: 100%; }
.auth-card .oauth-btn { width: 100%; justify-content: center; }
.auth-subactions { text-align: right; margin: -4px 0 10px; font-size: 12px; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; margin: 16px 0 10px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.auth-card .actions > .secondary { width: 100%; }

/* 公式サイトと同じ構成のフッター。 */
.tool-footer {
    flex: none;
    padding: 3rem 2rem;
    color: #555;
    background: #080812;
    border-top: 1px solid rgba(255,255,255,0.05);
    text-align: center;
}
.footer-logo {
    color: var(--brand-gold);
    font-size: 19px;
    font-weight: 800;
}
.tool-footer p { margin-top: 8px; font-size: 11px; }
.tool-footer .footer-links { margin-top: 10px; }
.footer-links a { color: #666; text-decoration: none; transition: color 0.18s ease; }
.footer-links a:hover { color: var(--brand-gold); }
.footer-links span { color: #383845; }
@media (max-width: 560px) {
    .tool-footer { padding: 2.4rem 1rem; }
    .footer-links { display: grid; gap: 6px; }
    .footer-links span { display: none; }
}

/* 全ボタン「アイコン＋ボタン名」統一 */
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
button > svg.btn-ico { flex: none; }

/* ヘッダ右上: 全ボタン「1行目アイコン・2行目タイトル」で統一。
   タイトルは 1 行に収まる幅を確保し、フォントは本文の約半分（13px→7px） */
.tool-header .header-actions { align-items: stretch; }
.tool-header .header-actions button, .tool-header .header-actions .nav-lang {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 4px 7px; min-width: 54px; min-height: 44px;
    font-size: 7px; line-height: 1.2; white-space: nowrap;
    background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px;
}
.tool-header .header-actions button:hover { background: var(--accent); color: #101010; }
.tool-header .header-actions button > svg.btn-ico { width: 16px; height: 16px; }
.tool-header .header-actions .nav-ico { font-size: 15px; line-height: 1; }
.tool-header .header-actions .nav-account-avatar {
    display: block;
    width: 16px;
    height: 16px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
    background: var(--panel2);
}
.tool-header .header-actions .nav-lang select {
    background: transparent; color: inherit; border: none; font-size: 7px; padding: 0;
    min-height: 0; width: auto; cursor: pointer; text-align: center;
}
.tool-header .header-actions .nav-lang select:focus-visible { outline: 2px solid rgba(103,183,255,0.55); }
@media (max-width: 768px) {
    .tool-header .header-actions > button[data-nav] { display: none; }
}
/* 画面タイトルのアイコン */
h2 .h2-ico { margin-right: 8px; }

/* 一括実行リスト: 実行中の行全体を黄色フォントで点滅表示 */
li.batch-running { color: #ffd400; font-weight: 700; animation: busy-blink 0.9s ease-in-out infinite; }
li.batch-running .badge { color: inherit; border-color: currentColor; }

/* ⑤ 開始画面設計（背景・立ち絵の生成/差し替え/配置調整） */
.ss-slot-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); }
.ss-slot-row:first-of-type { border-top: none; }
.ss-thumb-box { display: flex; align-items: center; justify-content: center; min-height: 90px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ss-thumb { display: block; max-width: 100%; max-height: 170px; object-fit: contain; }
.ss-thumb-bg { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; }
.ss-thumb-empty { color: var(--dim); font-size: 12px; padding: 30px 0; }
.ss-slot-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* ⑤ 配置プレビューの調整バー: テーブル（罫線つき一覧表）で「タイトル（数値）｜バー」を整列（2026-07-19 指示） */
.ss-adjust-table { width: 100%; border-collapse: collapse; margin: 2px 0 6px; }
.ss-adjust-table td { border: 1px solid var(--border); padding: 5px 12px; vertical-align: middle; }
.ss-adjust-table td:first-child { width: 1%; white-space: nowrap; color: var(--dim); font-size: 12px; }
.ss-adjust-table td:last-child input[type="range"] { display: block; width: 100%; min-width: 110px; }
label.file-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 6px; color: var(--accent); cursor: pointer; font-size: 13px; }
label.file-btn:hover { background: var(--accent); color: #101010; }
.ss-preview-box { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 8px 0; background-color: #0d1226; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
/* エンジンの .start-menu-background と同じ拡大（inset -3% + scale 1.025）を再現し、クロップ位置の効き方を一致させる */
.ss-preview-bg { position: absolute; inset: -3.1%; background-size: cover; background-position: 10% 50%; transform: scale(1.025); }
.ss-preview-panel { position: absolute; top: 14%; right: 4%; width: 30%; height: 74%; border: 1px dashed rgba(245, 166, 35, 0.75); border-radius: 12px; background: rgba(10, 18, 39, 0.42); }
.ss-preview-panel::after { content: '操作パネル位置'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(245, 166, 35, 0.85); font-size: 11px; }
.ss-preview-stage { position: absolute; left: 14%; bottom: 8%; width: 22%; height: 7%; border: 1px dashed rgba(103, 183, 255, 0.65); border-radius: 50%; }
#ss-preview-char { position: absolute; left: 25%; bottom: 4%; transform: translateX(-50%); max-width: 45%; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.5)); }
.ss-preview-title { position: absolute; top: 5%; left: 50%; transform: translateX(-50%); padding: 2px 14px; border: 1px dashed rgba(240, 240, 237, 0.4); border-radius: 999px; color: rgba(240, 240, 237, 0.65); font-size: 11px; white-space: nowrap; }
.ss-preview-char.active { border-color: var(--brand-gold); color: var(--brand-gold); }
.ss-preview-adjust { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 28px; margin: 6px 0 2px; }
.ss-preview-adjust h4 { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; color: var(--dim); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.ss-thumb-box a { display: contents; }
