/* Shared navigation and restrained controls; tool canvases and dialogs keep their own styles. */
[data-ep-shell]{--shell-accent:#c0341d;--shell-ink:#302b2d;--shell-line:#e8dfe1}
[data-ep-shell] h1{font-size:clamp(23px,2.4vw,30px);line-height:1.4}
.ep-shell-actions{display:flex;justify-content:flex-end;gap:8px;max-width:1160px;margin:12px auto;padding:10px 16px;border-block:1px solid var(--shell-line);background:white}
.ep-shell-actions button{min-height:44px;min-width:120px;padding:9px 16px;border:1px solid var(--shell-accent);border-radius:6px;background:#fff;color:var(--shell-accent);font:600 14px/1.4 system-ui,sans-serif;cursor:pointer}
.ep-shell-actions .ep-shell-primary{background:var(--shell-accent);color:#fff}
.ep-shell-actions button:disabled{opacity:.5;cursor:not-allowed}
.ep-shell-actions button:focus-visible{outline:3px solid #bb6378;outline-offset:3px}
[data-ep-shell="diagram"] #savePng{display:none!important}
/* ランキング・Tier表：スマホは下部バーに集約。PC（701px〜）は上部バーを出さず、各ツールのプレビュー見出し／上の行に保存・プレビューを置く。 */
@media(max-width:700px){[data-ep-shell="ranking"] #exportPng,[data-ep-shell="tier"] #preview-open,[data-ep-shell="tier"] #export{display:none!important}}
@media(min-width:701px){[data-ep-shell="ranking"] .ep-shell-actions,[data-ep-shell="tier"] .ep-shell-actions{display:none}}
[data-ep-shell="fan"] .ep-workspace-nav{border-radius:0;box-shadow:none;border-inline:0;border-color:var(--shell-line);--ep-control:#c0341d}
[data-ep-shell="fan"] .ep-workspace-nav .ep-save-image,[data-ep-shell="fan"] .ep-mobile-bar .ep-save-image,[data-ep-shell="fan"] .ep-panel-actions .ep-save-image{background:#c0341d;border-color:#c0341d}
[data-ep-shell="fan"] .ep-workspace-nav button,[data-ep-shell="fan"] .ep-mobile-bar button,[data-ep-shell="fan"] .ep-panel-actions button{border-color:#c0341d;color:#c0341d}
[data-ep-shell="fan"] .ep-workspace-nav .ep-save-image,[data-ep-shell="fan"] .ep-mobile-bar .ep-save-image,[data-ep-shell="fan"] .ep-panel-actions .ep-save-image{color:white}
[data-ep-shell="fan"] [data-ep-panel]{box-shadow:none;border-color:#eee7e9;border-radius:6px}
@media(max-width:700px){
 .ep-shell-actions{position:fixed;z-index:30;left:0;right:0;bottom:0;margin:0;padding:8px 12px calc(8px + env(safe-area-inset-bottom));border:0;border-top:1px solid var(--shell-line)}
 /* 360pxでも「プレビュー」が折り返さないよう1行に収める */
 .ep-shell-actions button{flex:1;min-width:0;padding:9px 4px;white-space:nowrap}
 [data-ep-shell="ranking"],[data-ep-shell="tier"],[data-ep-shell="diagram"]{padding-bottom:calc(72px + env(safe-area-inset-bottom))}
 .ep-keyboard-open .ep-shell-actions{display:none}
 [data-ep-shell="fan"] .ep-workspace-nav{position:static;border:0;margin:0;padding:0 16px}
 /* 入力中は縮小プレビューを画面上部に固定する（ep-mini-preview は workspace.js が入れる） */
 [data-ep-shell="fan"][data-ep-view="input"] .ep-workspace-nav:has(.ep-mini-preview:not([hidden])){position:sticky;top:var(--ep-viewport-top,0px);z-index:20;padding:6px 16px 8px;background:#fff;border-bottom:1px solid var(--shell-line)}
 [data-ep-shell="fan"] .ep-view-tabs{display:none}
 /* スマホではツール名を1行に収め、説明文は省いて入力とプレビューを上へ詰める */
 [data-ep-shell="fan"] > header h1{font-size:19px;line-height:1.35;margin:0 0 2px}
 [data-ep-shell="fan"] > header h1 + p{display:none}
 [data-ep-shell="fan"] .ep-workspace-grid{padding-left:0;padding-right:0}
}
@media print{.ep-shell-actions{display:none!important}}

[data-ep-shell="fan"] [data-ep-panel] section,[data-ep-shell="fan"] [data-ep-panel] .group{box-shadow:none}

/* The source controls remain in the DOM for their original handlers. */
[data-ep-shell="fan"].ep-shell-ready [data-ep-panel="preview"] [data-png],
[data-ep-shell="fan"].ep-shell-ready[data-ep-tool="itabag"] #save,
[data-ep-shell="fan"].ep-shell-ready[data-ep-tool="catalog"] #png,
[data-ep-shell="fan"].ep-shell-ready[data-ep-tool="festival"] #png{display:none!important}
[data-ep-shell="fan"] .ep-draft-bar{border:0;background:transparent;box-shadow:none;padding:0;gap:0 12px;font-size:12px}
[data-ep-shell="fan"] .ep-workspace-title{display:none}
[data-ep-shell="fan"] [data-ep-panel]{border:0;box-shadow:none;background:#fff}

/* PC: ツール名と短い説明、自動保存の表示を1行に収める（収まらないときだけ折り返す）。完成イメージは薄い地に置く。 */
@media(min-width:701px){
  [data-ep-shell="fan"] > header:not(.ep-shell-header),[data-ep-shell="fan"] .intro{display:flex;flex-wrap:wrap;align-items:center;gap:0 14px;padding-top:6px;padding-bottom:0;margin-bottom:0}
  [data-ep-shell="fan"] > header:not(.ep-shell-header) h1,[data-ep-shell="fan"] .intro h1{font-size:22px;line-height:1.4;margin:0}
  [data-ep-shell="fan"] > header:not(.ep-shell-header) h1 + p,[data-ep-shell="fan"] .intro h1 + p{flex:0 1 auto;min-width:0;margin:0;font-size:14px;color:#6b645c}
  [data-ep-shell="fan"] > header:not(.ep-shell-header) .ep-draft-bar,[data-ep-shell="fan"] .intro .ep-draft-bar{margin:0 0 0 auto}
  [data-ep-shell="fan"] .ep-draft-bar:has(details[open]){flex-basis:100%}
  [data-ep-shell="fan"] [data-ep-panel="preview"]{background:#f5f2ed;border-radius:16px}
}

/* サイト共通のヘッダー／フッターは site-chrome.css。ここにはツール固有の操作だけを置く。 */
/* 戻りリンク（共通ヘッダーの直下・見出し行の上）。tool-shell.mjs がビルド時に全ツールへ1つだけ入れる。位置はロゴの左端にそろえる */
.ep-back{box-sizing:border-box;width:100%;margin:0;padding:0 max(16px,calc((100% - 1200px)/2))}
.ep-back .ep-back-link,.ep-back .ep-back-link:visited{display:inline-flex;align-items:center;min-height:44px;padding-right:16px;color:#5f5852;font-size:14px;font-weight:700;line-height:1.4;font-family:inherit;text-decoration:none}
.ep-back .ep-back-link:hover{color:#c0341d;text-decoration:underline;text-underline-offset:3px}
.ep-back .ep-back-link:focus-visible{outline:3px solid #266bba;outline-offset:2px;border-radius:6px}
@media(max-width:559px){.ep-back{padding:0 12px}}
/* 全画面アプリ（相関図・ポジショニングマップ・エディタ）は、戻りリンク（.ep-back）が実在するときだけその高さ分を差し引く */
body[data-ep-shell="diagram"]:has(> .ep-back),body[data-ep-shell="editor"]:has(> .ep-back){--ep-chrome-h:calc(var(--ep-header-h,64px) + 44px)}
/* PC（761px以上）の図表・エディタは共通ヘッダーを50pxにスリム化し、リンクの44pxタップ高を保ったまま上下余白を詰める */
@media(min-width:761px){
  body[data-ep-shell="diagram"],body[data-ep-shell="editor"]{--ep-header-h:50px;--ep-chrome-h:50px}
  body[data-ep-shell="diagram"]:has(> .ep-back),body[data-ep-shell="editor"]:has(> .ep-back){--ep-chrome-h:calc(50px + 44px)}
  html body[data-ep-shell="diagram"] > header.ep-shell-header,html body[data-ep-shell="editor"] > header.ep-shell-header{padding-top:0;padding-bottom:0}
  html body[data-ep-shell="diagram"] > header.ep-shell-header .ep-chrome-a,html body[data-ep-shell="editor"] > header.ep-shell-header .ep-chrome-a{min-height:44px}
}
html.ep-keyboard-open .ep-back,body.is-focus > .ep-back{display:none}
@media print{.ep-back{display:none!important}}
/* ダーク表示（AIキャラチャット系）。ai-dark.css の汎用リンク色より強く指定する */
html[data-theme="dark"] body nav.ep-back a.ep-back-link.ep-back-link{color:#b5aea6!important}
html[data-theme="dark"] body nav.ep-back a.ep-back-link.ep-back-link:hover{color:#f0846c!important}
[data-ep-slug="ai-chat-plot-gacha"] > header .top{display:none}
[data-ep-shell="fan"] > header{padding-top:10px;padding-bottom:4px}
[data-ep-shell="fan"] > header h1{margin:0 0 4px}
[data-ep-shell="fan"] > header p{margin:0 0 4px}
[data-ep-shell="fan"] .ep-draft-bar{margin:0;padding:0}
[data-ep-shell="fan"] .ep-workspace-grid{padding-top:4px}
[data-ep-shell="fan"] [data-ep-panel] h2{margin-top:0}
[data-ep-slug="character-gacha"] .gacha{padding-top:10px}
[data-ep-slug="character-gacha"] .gacha header{padding:4px 0 12px}
[data-ep-slug="ai-chat-plot-gacha"] .intro .eyebrow{display:none}
[data-ep-slug="character-gacha"] .gacha header h1{margin:0 0 4px}
[data-ep-slug="character-gacha"] .gacha header p{margin:0}
[data-ep-slug="character-gacha"] .gacha .panel{border-radius:6px;background:#fff;border-color:#e8e3df}
[data-ep-slug="character-gacha"] .primary{background:#c0341d}
[data-ep-slug="ai-chat-plot-gacha"] .intro{padding-top:8px;padding-bottom:8px;margin-bottom:0}
[data-ep-slug="ai-chat-plot-gacha"] .intro h1{margin:0 0 4px}
[data-ep-slug="ai-chat-plot-gacha"] .intro p{margin:0}
[data-ep-slug="simple-plot-gacha"]{background:#fff}
[data-ep-slug="simple-plot-gacha"] .intro{padding:16px 0}
[data-ep-slug="simple-plot-gacha"] .intro h1{font-size:clamp(23px,2.4vw,30px)}
[data-ep-slug="simple-plot-gacha"] .lead{margin:4px 0 0;line-height:1.5}
[data-ep-slug="simple-plot-gacha"] .machine{border-radius:6px;box-shadow:none}
[data-ep-slug="simple-plot-gacha"] .result{min-height:110px}
[data-ep-shell="text"] .title{margin-top:16px}
[data-ep-shell="context"] main h1{margin-top:16px}
@media(max-width:700px){[data-ep-shell="fan"] > header{padding:10px 16px 4px}[data-ep-shell="fan"] .ep-draft-bar{margin:0;padding:0}[data-ep-shell="fan"] .ep-workspace-grid>[data-ep-panel]{padding:10px 16px}[data-ep-slug="simple-plot-gacha"] .intro{padding:14px 0}[data-ep-slug="simple-plot-gacha"] .mobile-break{display:none}}

[data-ep-slug="simple-plot-gacha"] .mode-row{padding:0 0 12px}
[data-ep-slug="simple-plot-gacha"] .draw{min-height:48px;box-shadow:none;margin-bottom:12px}
[data-ep-slug="simple-plot-gacha"] .arrow{top:11px}
[data-ep-slug="simple-plot-gacha"] .result{padding:14px 20px}
[data-ep-slug="simple-plot-gacha"] .teaser p{margin:0;font-size:14px}

/* Reset inherited page-header rules without affecting tool toolbars. */
body[data-ep-shell]{margin:0;background:#fff;color:#302b2d;font-family:system-ui,-apple-system,"Hiragino Sans",sans-serif}
[data-ep-slug="ai-chat-plot-gacha"] > main{padding-top:8px}
[data-ep-shell] .ep-shell-description{margin:3px 0 0;font-size:14px;line-height:1.5;color:#5f5955;font-weight:400;letter-spacing:normal}
[data-ep-shell] .ep-shell-heading{min-width:0}
[data-ep-shell] .ep-shell-heading h1{margin:0}
[data-ep-shell="fan"] button.primary,[data-ep-shell="gacha"] button.primary,[data-ep-shell="context"] button.primary{background:#c0341d;border-color:#c0341d;color:#fff}
[data-ep-slug="simple-plot-gacha"] .draw{background:#c0341d}
@media(max-width:700px){
  [data-ep-shell="diagram"] .rm-bar,[data-ep-shell="diagram"] .pm-bar{flex-wrap:wrap;gap:4px;padding:10px 12px 6px}
  [data-ep-slug="relationship-maker"] #widenCanvas{min-height:44px}
  [data-ep-shell="diagram"] .ep-shell-heading{flex:0 0 100%;width:100%}
  [data-ep-shell="diagram"] .ep-shell-heading h1{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;font-size:23px;line-height:1.35}
  [data-ep-shell="diagram"] .top-actions{flex:1 1 100%;min-width:0}
}

/* Keep both image-save actions inside narrow relationship previews. */
@media(max-width:700px){
  [data-ep-slug="relationship-maker"] #preview .preview-actions{min-width:0;flex-wrap:wrap}
  [data-ep-slug="relationship-maker"] #preview .preview-actions .tbtn{flex:1 1 170px;min-width:0;max-width:100%;white-space:normal;padding:8px 12px}
}

[data-ep-shell] .tool-context{display:block;margin:12px 0 2px;color:#655e58;font-size:12px;font-weight:700;line-height:1.4}[data-ep-slug="character-gacha"] .gacha header .tool-context{margin:12px 0 2px}[data-ep-shell] .tool-context + h1{margin-top:0}
@media(prefers-reduced-motion:reduce){[data-ep-shell] *,[data-ep-shell] *::before,[data-ep-shell] *::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}

/* 全画面アプリ（相関図・ポジショニングマップ）は、共通ヘッダーの高さ（とスマホで画面下に固定する操作バー）を引いて1画面に収める */
[data-ep-shell="diagram"] .tool-screen{height:calc(100vh - var(--ep-chrome-h,64px));height:calc(100dvh - var(--ep-chrome-h,64px))}
@media(max-width:700px){[data-ep-shell="diagram"] .tool-screen{height:calc(100vh - var(--ep-chrome-h,64px) - 61px - env(safe-area-inset-bottom));height:calc(100dvh - var(--ep-chrome-h,64px) - 61px - env(safe-area-inset-bottom))}}

/* ツール名は「・」の区切りでだけ折り返す（語の途中で切れないように） */
h1 .ep-nb{display:inline-block}

/* A5: ベージュ（#F5F2ED系）は結果・プレビュー枠だけ。注記・ヒント・特徴の枠は無色の細罫にする */
[data-ep-shell="text"] .counter-facts li,[data-ep-shell="editor"] .ed-hint{background:none;border:1px solid #e6e0d7}
[data-ep-shell="editor"] .ed-hint{padding-block:0}
[data-ep-shell="editor"] .ed-stats{grid-template-columns:repeat(2,minmax(0,1fr))}

/* 相関図・ポジショニングマップは 760px までスマホ用の配置になる。701〜760px も、操作バーを画面下に固定するスマホの組み方にそろえる */
@media(min-width:701px) and (max-width:760px){
  [data-ep-shell="diagram"] .ep-shell-actions{position:fixed;z-index:30;left:0;right:0;bottom:0;max-width:none;margin:0;padding:8px 12px calc(8px + env(safe-area-inset-bottom));border:0;border-top:1px solid var(--shell-line)}
  [data-ep-shell="diagram"] .ep-shell-actions button{flex:1;min-width:0;padding:9px 4px;white-space:nowrap}
  [data-ep-shell="diagram"]{padding-bottom:calc(72px + env(safe-area-inset-bottom))}
  .ep-keyboard-open [data-ep-shell="diagram"] .ep-shell-actions{display:none}
  [data-ep-shell="diagram"] .rm-bar,[data-ep-shell="diagram"] .pm-bar{flex-wrap:wrap;gap:4px;padding:10px 12px 6px}
  [data-ep-shell="diagram"] .ep-shell-heading{flex:0 0 100%;width:100%}
  [data-ep-shell="diagram"] .ep-shell-heading h1{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;font-size:23px;line-height:1.35}
  [data-ep-shell="diagram"] .top-actions{flex:1 1 100%;min-width:0}
  [data-ep-shell="diagram"] .tool-screen{height:calc(100vh - var(--ep-chrome-h,64px) - 61px - env(safe-area-inset-bottom));height:calc(100dvh - var(--ep-chrome-h,64px) - 61px - env(safe-area-inset-bottom))}
}

/* 操作対象は44px以上。小さな表示の復元札は既存仕様を維持する。 */
[data-ep-shell] button:has(>svg),[data-ep-shell] .icon-btn{min-width:44px;min-height:44px}
[data-ep-shell] :is(button,input,select,textarea,summary,a):focus-visible{outline:3px solid #266bba;outline-offset:3px}
html[data-theme="dark"] [data-ep-shell] :is(button,input,select,textarea,summary,a):focus-visible{outline-color:#8bbcff}
[data-ep-shell] button:disabled{background:#e6e0d7!important;color:#5f5852!important;border-color:transparent!important;box-shadow:none!important;opacity:1!important;cursor:not-allowed}
html[data-theme="dark"] [data-ep-shell] button:disabled{background:#2c2832!important;color:#b5aea6!important}
[data-ep-shell="fan"] .ep-output-empty{align-self:start}
[data-ep-shell="fan"] .ep-output-empty .ep-preview-scroll{max-height:160px;min-height:0}
[data-ep-shell="fan"][data-ep-tool="catalog"].ep-shell-ready #print{display:none!important}
[data-ep-tool="catalog"] #tag-settings summary{min-height:44px;align-content:center;cursor:pointer}
