/* Tier表メーカー：エンタメパンダ ツールズと同じ白・墨・パンダ朱 */
:root {
  --ink: #1F1D1B;
  --sub: #66615C;
  --line: #E8E3DD;
  --surface: #F6F3EF;
  --blush: #FDF0EB;
  --shu: #E5452B;
  --shu-deep: #C93A22;
  --shu-text: #C93A22;
  --dash: #CFC8C0;
  --font-gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: #FFFFFF;
  color: var(--ink);
  font-family: var(--font-gothic);
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; display: block; height: 4px; background: var(--shu); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-feature-settings: "palt"; word-break: auto-phrase; text-wrap: pretty; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 40px; }
.u { background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat; transition: background-size .35s ease; }
a.u:hover { background-size: 100% 2px; }
.skip-link { display: flex; align-items: center; min-height: 44px; position: fixed; z-index: 20; top: 10px; left: 10px; padding: 8px 14px; border-radius: 8px; background: var(--ink); color: #FFF; font-size: 14px; font-weight: 700; transform: translateY(-160%); }
.skip-link:focus { transform: none; }

/* ヘッダー（サイト共通） */
.hd { display: flex; align-items: center; gap: 8px 32px; height: 60px; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-right: auto; }
.logo img { width: 34px; height: 34px; object-fit: contain; }
.logo b { display: block; font-size: 19px; font-weight: 900; line-height: 1.1; letter-spacing: .04em; white-space: nowrap; }
.logo b span { color: var(--shu-text); }
.logo small { display: block; margin-top: 1px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--sub); }
.nav { display: flex; align-items: center; gap: 28px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 6px; min-height: 44px; transition: color .2s; }
.nav a:hover { color: var(--shu-text); }
.nav svg { width: 13px; height: 13px; }

/* パンくず */
.crumb { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 12px; color: var(--sub); }
.crumb a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--ink); }

/* ほかのツール・フッター */
.sec { margin-top: 80px; }
.sh { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.sh h2 { font-size: 24px; font-weight: 900; line-height: 1.3; }
.more { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-left: auto; font-size: 13px; font-weight: 700; white-space: nowrap; }
.others { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.other { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface); transition: background .3s; }
a.other:hover { background: var(--blush); }
.other .mark { display: grid; flex-shrink: 0; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: #FFF; color: var(--ink); }
.other .mark svg { width: 26px; height: 26px; }
.other b { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 900; }
.other b em { padding: 0 8px; border-radius: 999px; background: #FFF; font-size: 12px; font-style: normal; font-weight: 700; color: var(--sub); }
.other span { font-size: 13px; color: var(--sub); }
.ft { margin-top: 88px; padding: 28px 0 20px; background: var(--surface); }
.ft-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 40px; }
.ft-logo { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.ft-logo img { width: 34px; height: 34px; object-fit: contain; }
.ft-logo b { font-size: 18px; font-weight: 900; letter-spacing: .04em; }
.ft-nav { display: flex; flex-wrap: wrap; gap: 4px 28px; font-size: 13px; font-weight: 700; }
.ft-nav a { display: flex; align-items: center; min-height: 44px; }
.copy { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--sub); }
.ears { display: flex; flex-shrink: 0; gap: 4px; }
.ears i { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }

/* ツールのボタン */
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
main button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 999px; background: #FFF; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.4; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
main button:hover:not(:disabled) { border-color: var(--ink); }
main button:disabled { color: var(--sub); opacity: .5; cursor: default; }
main button svg { width: 18px; height: 18px; flex: none; }
main button.primary { border-color: var(--shu-deep); background: var(--shu-deep); color: #FFF; }
main button.primary:hover:not(:disabled) { border-color: #B03119; background: #B03119; }
main button.primary:disabled { color: #FFF; }
main button.danger { color: var(--shu-text); }
main button.danger:disabled { color: var(--sub); }

/* 上部バー */
.topbar { display: grid; grid-template-columns: auto minmax(240px, 1fr) auto; align-items: center; gap: 10px 24px; margin-top: 4px; padding: 10px 14px 10px 20px; border: 1px solid var(--line); border-radius: 16px; background: #FFF; }
.topbar h1 { padding-right: 24px; border-right: 1px solid var(--line); font-size: 20px; font-weight: 900; line-height: 1.4; white-space: nowrap; }
.title-block { min-width: 0; }
.title-block input { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 6px 10px; border: 1.5px solid #8A837C; border-radius: 10px; background: transparent; font-size: 17px; font-weight: 700; color: var(--ink); }
.title-block input:hover { background: var(--surface); }
.title-block input:focus { outline: none; border-color: var(--ink); background: #FFF; }
.title-block p { margin: 0 10px; font-size: 12px; line-height: 1.6; color: var(--sub); }
.top-actions { display: flex; align-items: center; gap: 8px; }
main .icon-action { width: 44px; min-height: 44px; padding: 0; border-color: transparent; background: transparent; }
main .icon-action:hover:not(:disabled) { border-color: transparent; background: var(--surface); }
main .icon-action svg { width: 20px; height: 20px; }
.top-actions .primary { min-height: 44px; padding: 0 20px; }

/* 作業エリア */
.workspace { margin-top: 20px; }
.intro-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.hint { font-size: 13px; line-height: 1.7; color: var(--sub); }
.import-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.import-actions button { min-height: 44px; padding: 0 14px; }
.style-toggle { display: none; }
.workspace > #board { margin-top: 14px; }
/* 選択中だけ画面下に固定で出す。未選択のときは表の上に場所を取らない。 */
.edit-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; position: fixed; z-index: 15; left: 50%; bottom: 16px; width: min(1200px, calc(100% - 32px)); padding: 8px 8px 8px 16px; border: 1.5px solid var(--shu-deep); border-radius: 14px; background: var(--blush); box-shadow: 0 8px 24px rgba(31, 29, 27, .16); transform: translateX(-50%); }
body.selecting .workspace { padding-bottom: calc(var(--ep-selection-height, 80px) + 16px + 24px); }
.selection { font-size: 13px; font-weight: 700; color: var(--ink); }
.selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.selection-actions button { padding: 0 14px; font-size: 13px; }
.quick-move { display: none; flex-wrap: wrap; gap: 6px; width: 100%; }
.side-note-option { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 13px; font-weight: 700; }
.side-note-option select { min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #FFF; }

/* 表 */
#board { display: flex; flex-direction: column; gap: 6px; }
.tier-row { display: grid; grid-template-columns: 126px minmax(0, 1fr); min-height: 88px; overflow: hidden; border-radius: 12px; background: var(--surface); }
.label-cell { position: relative; display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; min-width: 0; padding: 10px 8px; background: var(--row-color, #DAD4CD); }
.label-cell textarea { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 7px 6px; overflow: hidden; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 24px; font-weight: 900; line-height: 1.25; text-align: center; overflow-wrap: anywhere; resize: none; }
.label-cell textarea.long-label { padding-right: 6px; font-size: 14px; font-weight: 700; line-height: 1.5; text-align: left; }
.label-cell textarea:hover { box-shadow: inset 0 0 0 1.5px rgba(31, 29, 27, .35); }
.label-cell textarea:focus-visible { outline: 3px solid var(--ink); outline-offset: 0; background: rgba(255, 255, 255, .5); }
/* 行名の下に専用の段を取る。選択中は同じ場所を「ここへ移動」に譲り、行の高さを変えない。 */
.row-tools { display: flex; flex-direction: column; align-items: center; margin-top: auto; }
main .move-here { display: none; width: 100%; min-height: 44px; padding: 2px 6px; border-color: var(--ink); font-size: 12px; }
body.selecting main .move-here { display: inline-flex; }
main .row-delete { gap: 4px; min-width: 44px; min-height: 44px; padding: 0 12px; border-color: rgba(31, 29, 27, .4); background: rgba(255, 255, 255, .55); color: var(--ink); font-size: 12px; }
main .row-delete:hover:not(:disabled), main .row-delete:focus-visible { border-color: var(--ink); background: rgba(255, 255, 255, .85); }
main .row-delete:disabled { display: none; }
main .row-delete svg { width: 14px; height: 14px; }
body.selecting main .row-delete { display: none; }
.row-content { display: flex; align-items: stretch; gap: 8px; min-width: 0; padding: 10px; }
.tiles { display: flex; flex-wrap: wrap; align-content: flex-start; align-items: flex-start; gap: 8px; min-width: 0; }
.row-content > .tiles { flex: 0 1 auto; }
.row-content > .tiles:empty { display: none; }
main .row-add { flex: 0 0 auto; align-self: center; min-width: 0; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; font-size: 13px; color: var(--sub); }
main .row-add:hover:not(:disabled) { border: 0; background: #FFF; color: var(--ink); }
.row-add .plus { font-size: 20px; font-weight: 400; color: var(--shu-text); }
main .tile { scroll-margin-bottom: calc(var(--ep-selection-height, 80px) + 100px); flex: 0 0 auto; flex-direction: column; justify-content: center; align-items: center; gap: 0; width: 76px; min-height: 0; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 10px; background: transparent; cursor: grab; }
main .tile.has-name { padding: 4px; gap: 4px; background: #FFF; }
main .tile:hover:not(:disabled) { border-color: var(--dash); }
.tile img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: 8px; pointer-events: none; }
.tile.has-name img { width: 68px; height: 68px; border-radius: 6px; }
.tile span { display: -webkit-box; width: 68px; overflow: hidden; font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--sub); overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
main .tile[aria-pressed="true"] { border-color: var(--shu-deep); background: var(--blush); }
main .tile[aria-pressed="true"] span { color: var(--ink); }
main .add-row { width: 100%; min-height: 46px; margin-top: 8px; border: 1px solid #E6E0D7; border-radius: 12px; background: transparent; }

/* 未分類 */
.pool { margin-top: 20px; border: 1px solid #E6E0D7; border-radius: 12px; }
.row-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.row-heading h2 { font-size: 15px; font-weight: 900; }
main .row-heading button { min-height: 44px; }
.pool > .tiles { min-height: 64px; padding: 12px; }
.pool > .tiles { scroll-margin-top: 12px; }
#pool-section { scroll-margin-top: 12px; }

/* 操作結果のトースト。選択バーが出ているときはその上に出す。 */
.toast { position: fixed; z-index: 16; left: 50%; bottom: 16px; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 12px; background: var(--ink); color: #FFF; font-size: 13px; font-weight: 700; line-height: 1.6; box-shadow: 0 8px 24px rgba(31, 29, 27, .2); opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast.show:has(button) { pointer-events: auto; }
main .toast button { min-height: 44px; padding: 0 14px; border-color: rgba(255, 255, 255, .5); background: transparent; color: #FFF; font-size: 13px; white-space: nowrap; }
main .toast button:hover:not(:disabled) { border-color: #FFF; }
body.selecting .toast { bottom: 154px; }
details { margin-top: 16px; border: 1px solid #E6E0D7; border-radius: 12px; background: transparent; }
summary { display: flex; align-items: center; min-height: 44px; padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer; }
.details-body { padding: 0 16px 12px; }
.details-body p { margin-bottom: 8px; font-size: 13px; line-height: 1.8; color: var(--sub); }
body.busy .row-add, body.busy #add-images { cursor: progress; }

/* 保存前のプレビュー */
.preview { width: min(860px, calc(100% - 32px)); height: min(850px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: 16px; background: #FFF; color: var(--ink); box-shadow: 0 16px 48px rgba(31, 29, 27, .25); }
.preview[open] { display: flex; flex-direction: column; }
.preview::backdrop { background: rgba(31, 29, 27, .55); }
.preview-head, .preview-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 12px 10px 20px; }
.preview-head { border-bottom: 1px solid var(--line); }
.preview-head h2 { font-size: 16px; font-weight: 900; }
.preview-zoom { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 12px; }
.preview-zoom { flex-wrap: wrap; }
.preview-zoom button { min-height: 36px; }
#zoom-level { min-width: 4em; font-size: 13px; font-weight: 700; color: var(--sub); text-align: center; white-space: nowrap; }
.preview-body { flex: 1 1 auto; min-height: 100px; overflow: auto; padding: 16px; background: var(--surface); overscroll-behavior: contain; }
.preview-body img { display: block; max-width: none; height: auto; margin: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(31, 29, 27, .12); }
.preview-foot { border-top: 1px solid var(--line); }
#preview-save-hint { margin: 0; font-size: 12px; }
.preview-actions { display: flex; gap: 8px; margin-left: auto; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--shu-deep); }
.preview .icon-action { width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
.preview .icon-action:hover { background: var(--surface); }
.preview .icon-action svg { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 1020px) {
  .wrap { padding: 0 28px; }
  .others { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar h1 { padding-right: 0; border-right: 0; }
  .title-block { grid-row: 2; grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); }
  .row-content { flex-wrap: wrap; }
  .row-content > .tiles { flex: 1 1 auto; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .wrap { padding: 0 18px; }
  .logo b { font-size: 16px; }
  .logo img { width: 30px; height: 30px; }
  .logo small { display: none; }
  .nav { gap: 16px; font-size: 13px; }
  .nav .hide-sp, .nav .ext { display: none; }

  main button { min-height: 44px; }
  .topbar { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .topbar h1 { font-size: 18px; }
  .top-actions { grid-row: 2; display: grid; grid-template-columns: 44px 44px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .title-block { grid-row: 3; }
  .title-block input { font-size: 16px; }
  .import-actions { width: 100%; }
  .import-actions button { flex: 1; }
  .edit-strip { align-items: stretch; flex-direction: column; bottom: 10px; width: calc(100% - 20px); padding: 10px; }
  body.selecting .workspace { padding-bottom: 230px; }
  body.selecting .toast { bottom: 232px; }
  .selection-actions button { flex: 1; padding: 0 8px; }
  /* 行見出しは幅104px。行名を全幅にし、その下の段に削除（選択中は「ここへ移動」）を置く。 */
  .tier-row { grid-template-columns: 104px minmax(0, 1fr); min-height: 80px; }
  .label-cell { gap: 8px; padding: 6px; }
  .label-cell textarea { padding: 3px; font-size: 20px; }
  .label-cell textarea.long-label { padding-right: 3px; font-size: 13px; line-height: 1.45; }
  .row-content { gap: 8px; padding: 8px; }
  main .tile { width: 64px; }
  .tile img { width: 60px; height: 60px; }
  .tile.has-name img { width: 56px; height: 56px; }
  .tile span { width: 56px; }
  .preview-actions { width: 100%; }
  .preview-zoom button { min-height: 44px; }
  .preview-actions button { flex: 1; min-height: 44px; }

  .sec { margin-top: 56px; }
  .sh { margin-bottom: 16px; padding-bottom: 10px; }
  .sh h2 { font-size: 20px; }
  .sh .more { display: none; }
  .ft { margin-top: 56px; }
  .ft-top { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* 選択画像の名前。非表示でも選択ボタンの読み上げ名は残す。 */
.item-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; flex-basis: 100%; font-size: 13px; font-weight: 700; }
.item-settings > label:not([hidden]) { display: flex; align-items: center; gap: 8px; }
.item-settings input[type="text"] { width: min(260px, 52vw); min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.tile span[hidden] { display: none; }
@media (max-width: 640px) {
  .top-actions #preview-open, .top-actions #export { min-width: 0; padding: 0 7px; font-size: 12px; }
  .top-actions #export svg { display: none; }
}

/* 操作画面の下に置く静的な使い方・FAQ */
.tool-guide { box-sizing: border-box; width: min(100% - 32px, 900px); margin: 40px auto; padding: 24px 0 48px; color: #1F1D1B; font-size: 15px; line-height: 1.9; }
.tool-guide h2 { font-size: 22px; margin: 28px 0 12px; }
.tool-guide h3 { font-size: 17px; margin: 20px 0 8px; }
.tool-guide p { margin: 0 0 14px; }
.tool-guide ul { padding-left: 1.5em; }
.tool-guide a { text-decoration: underline; text-underline-offset: .2em; }
.tool-screen { display: flex; flex-direction: column; flex: none; height: 100vh; height: 100dvh; min-height: 500px; }

/* スマホでは選択操作を残し、名前設定だけ必要なときに開く。 */
.item-settings { margin: 0; background: transparent; }
.item-settings summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.item-settings-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.item-settings-fields > label:not([hidden]) { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .edit-strip { bottom: calc(var(--ep-keyboard-inset, 0px) + 8px); max-height: calc(var(--ep-viewport-height, 100dvh) - 16px); overflow-y: auto; gap: 8px; }
  .selection { font-size: 12px; }
  .item-settings { display: block; flex-basis: auto; }
  .item-settings summary { min-height: 44px; font-size: 13px; }
  .item-settings-fields { padding-bottom: 4px; }
  body.selecting .workspace { padding-bottom: calc(var(--ep-selection-height, 136px) + 24px); }
  body.selecting .toast { bottom: calc(var(--ep-keyboard-inset, 0px) + var(--ep-selection-height, 136px) + 16px); }
}

@media (max-width:700px){
  .toast{z-index:31;bottom:calc(76px + env(safe-area-inset-bottom));width:max-content;overflow-wrap:anywhere;max-height:calc(100dvh - 100px - env(safe-area-inset-bottom));overflow-y:auto}
  body.selecting .toast{bottom:calc(max(76px, var(--ep-selection-height, 136px) + 16px) + env(safe-area-inset-bottom) + var(--ep-keyboard-inset, 0px))}
}

/* Tier用の下部バー（通常時56px）の上に選択バー・通知を置く。キーボード表示中は下部バーが消えるので詰める。 */
@media (max-width: 700px) {
  .edit-strip { bottom: calc(var(--ep-keyboard-inset, 0px) + 60px + env(safe-area-inset-bottom)); max-height: calc(var(--ep-viewport-height, 100dvh) - 84px - env(safe-area-inset-bottom)); }
  html.ep-keyboard-open .edit-strip { bottom: calc(var(--ep-keyboard-inset, 0px) + 8px); max-height: calc(var(--ep-viewport-height, 100dvh) - 16px); }
  body.selecting .workspace { padding-bottom: calc(var(--ep-selection-height, 136px) + 60px + 24px); }
  body.selecting .toast { bottom: calc(var(--ep-keyboard-inset, 0px) + var(--ep-selection-height, 136px) + 76px + env(safe-area-inset-bottom)); }
  html.ep-keyboard-open body.selecting .toast { bottom: calc(var(--ep-keyboard-inset, 0px) + var(--ep-selection-height, 136px) + 16px); }
}

/* 保存できない理由は保存ボタン（共通の操作バー）のすぐ横に出す。PCはバーの下、スマホは固定バーの真上。 */
.save-reason { max-width: 1160px; margin: -6px auto 10px; padding: 0 16px; font-size: 12px; line-height: 1.6; color: var(--sub); text-align: right; }
.sample-banner { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 4px 8px 4px 16px; border: 1px solid #E6E0D7; border-radius: 12px; background: transparent; }
.sample-banner p { flex: 1; min-width: 0; font-size: 13px; line-height: 1.6; }
.sample-banner b { font-weight: 900; }
.sample-banner button { flex: none; min-height: 44px; }
@media (max-width: 700px) {
  .save-reason { position: fixed; z-index: 29; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); max-width: none; margin: 0; padding: 4px 16px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); text-align: center; }
  body.selecting .save-reason { display: none; }
  body.save-blocked:not(.selecting) .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }
  body.save-blocked:not(.selecting) { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
}
@media (max-width: 700px) { html.ep-keyboard-open .save-reason { display: none; } }

/* ── PC（701px〜）：ランキング表・ゲーム自己紹介などと同じ構成 ──
   1行目＝ツール名と説明（1行）・自動保存・「…」。2行目＝表のタイトル・元に戻す／やり直す・プレビュー・共有・画像を保存。
   保存できない理由は保存ボタンの下に右寄せ。共通の上部操作バー（.ep-shell-actions）はPCでは出さない（tool-shell.css）。
   Tier表は表そのものが完成画像なので、右に別のプレビュー欄は置かず、表を全幅のまま使う。 */
.top-tools, #share-top { display: none; }
.more-wrap { position: relative; }
.top-more { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #FFF; color: var(--ink); cursor: pointer; }
.top-more:hover { border-color: var(--dash); background: var(--surface); }
.top-more svg { width: 18px; height: 18px; }
.more-menu { position: absolute; z-index: 18; top: calc(100% + 4px); right: 0; min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #FFF; box-shadow: 0 12px 28px rgba(31, 29, 27, .12); }
.more-menu button { display: flex; justify-content: flex-start; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; text-align: left; }
.more-menu button:hover:not(:disabled) { background: var(--surface); }
@media (max-width: 700px) { main #share-top { display: none; } }
@media (min-width: 701px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(72px, auto) auto auto; grid-template-areas: "head tools" "title acts" "reason reason"; align-items: center; gap: 0 16px; margin-top: 0; padding: 0 0 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
  .topbar h1, .topbar .ep-shell-heading h1 { padding-right: 0; border-right: 0; font-size: 22px; line-height: 1.4; white-space: nowrap; }
  .topbar > h1, .topbar > .ep-shell-heading { grid-area: head; }
  .topbar .ep-shell-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; }
  .topbar .ep-shell-heading .ep-shell-description { margin: 0; font-size: 14px; }
  .top-tools { display: flex; grid-area: tools; align-items: center; gap: 10px; justify-self: end; }
  .topbar .title-block { grid-area: title; padding: 0; border: 0; }
  .topbar .top-actions { grid-area: acts; }
  main .top-actions button { flex: none; min-height: 44px; }
  main #share-top { display: inline-flex; min-height: 44px; }
  .topbar .save-reason { grid-area: reason; max-width: none; margin: 6px 0 0; padding: 0; font-size: 13px; font-weight: 700; color: #8F2A18; text-align: right; }
  .workspace { margin-top: 14px; }
  #reset, .status-bar { display: none; }
}

/* 保存できない間のボタン（全ツール共通の無効表示）：グレーの面・枠なし・影なし。朱を薄めない。 */
main #export:disabled, main #preview-open:disabled, main #share-top:disabled, [data-ep-shell] .ep-shell-actions button:disabled { border-color: transparent; background: #E6E0D7; color: #5f5852; box-shadow: none; opacity: 1; cursor: not-allowed; }
main #export[aria-busy="true"]:disabled { cursor: progress; }
[hidden] { display: none !important; }

/* 保存できない理由は、保存できない間だけ出す。PCはタイトル欄と保存ボタンの間（ボタンの横）、スマホは固定バーの真上。 */
@media (min-width: 701px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-rows: minmax(72px, auto) auto; grid-template-areas: "head head tools" "title reason acts"; }
  .topbar .save-reason { grid-area: reason; align-self: center; margin: 0; white-space: nowrap; }
}

/* 共有ダイアログ（見た目は結果の共有と同じ ep-action-dialog。result-actions.css が当たらない単体表示でも崩れないよう最低限を持つ） */

/* 行名を押して編集。空行は必要なタップ領域だけに収める。 */
.tier-row { min-height: 60px; }
.label-cell { justify-content: center; gap: 0; padding: 4px; }
main .row-label { position: relative; width: 100%; min-width: 44px; min-height: 52px; padding: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--row-ink, var(--ink)); font-size: 24px; font-weight: 900; white-space: pre-wrap; overflow-wrap: anywhere; }
main .row-label .row-edit-icon { position: absolute; right: 4px; bottom: 4px; width: 16px; height: 16px; opacity: .82; pointer-events: none; }
main .row-label:hover .row-edit-icon { opacity: .85; }
main .row-label.long-label { font-size: 14px; }
main .row-label:hover:not(:disabled) { background: rgba(255,255,255,.22); }
.row-content { padding: 4px 8px; }
main .row-add { min-width: 44px; }
.row-settings { width: min(420px, calc(100% - 32px)); padding: 24px; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 16px 48px #0004; }
.row-settings::backdrop { background: #1f1d1b88; }
.row-settings h2 { margin: 0 0 16px; font-size: 18px; }
.row-settings label, .row-settings p { display: block; margin: 12px 0 6px; font-weight: 700; }
.row-settings textarea { width: 100%; min-height: 44px; padding: 8px; border: 1px solid #8a837c; border-radius: 8px; font-size: 16px; }
.row-colors { display: flex; flex-wrap: wrap; gap: 8px; }
main .color-choice { width: 44px; min-height: 44px; padding: 0; border: 2px solid transparent; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .14); }
main .color-choice[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px white; }
.row-order-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.row-order-actions button, main .board-row-order button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 44px;
}
.row-order-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.row-position { padding: 2px 8px; border-radius: 999px; background: var(--surface); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-row-order { display: flex; justify-content: center; }
main .board-row-order button { width: 44px; padding: 0; border: 0; background: transparent; color: var(--row-ink, var(--ink)); }
main .board-row-order button:disabled { opacity: .35; }
main .board-row-order button:hover:not(:disabled) { background: rgb(255 255 255 / .22); }
main .board-row-order button:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.row-settings-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }
.row-settings-actions button { min-height: 44px; }

/* 背景テーマ1タップ切替＋画像枠比率＋お題テンプレ＋透かしロゴON/OFF */
.board-style-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 12px; }
.theme-switcher, .ratio-switcher, .preset-switcher { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.preset-switcher { flex-basis: 100%; }
.style-label { font-size: 13px; font-weight: 700; color: var(--sub); }
.theme-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
main .theme-buttons button { min-height: 36px; padding: 0 12px; font-size: 13px; transition: none; }
main #theme-options button { padding: 0 12px 0 8px; }
main .theme-buttons button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #FFF; }
.tsw { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .2); }
.tsw-light { background: #FFFFFF; }
.tsw-cream { background: #FBF6EC; }
.tsw-pastel { background: #F8BBD0; }
.tsw-dark { background: linear-gradient(135deg, #151722 0%, #2B3046 65%, #38E8FF 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.brand-option { font-size: 13px; }
.preview-options { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }

/* 文字カード（画像なしカード）＋画像比率（正方形・縦長トレカ・元比率）＋行末追加ボタン */
main .tile.text-tile { justify-content: center; align-items: center; width: 76px; min-height: 76px; padding: 6px; background: var(--card-color, #F8BBD0); color: var(--card-ink, #1F1D1B); box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .12); }
main .tile.text-tile .text-tile-body { display: -webkit-box; width: 100%; overflow: hidden; font-size: 12px; font-weight: 900; line-height: 1.35; color: var(--card-ink, #1F1D1B); text-align: center; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
main .tile.text-tile[aria-pressed="true"] { border-color: var(--shu-deep); background: var(--card-color, #F8BBD0); box-shadow: 0 0 0 2px var(--shu-deep), inset 0 0 0 2px #FFFFFF; }
main .tile.text-tile[aria-pressed="true"] .text-tile-body { color: var(--card-ink, #1F1D1B); }
#workspace[data-card-ratio="square"] .tile:not(.text-tile) img { width: 72px; height: 72px; object-fit: cover; }
#workspace[data-card-ratio="square"] .tile.has-name:not(.text-tile) img { width: 68px; height: 68px; }
#workspace[data-card-ratio="portrait"] .tile:not(.text-tile) img { width: 72px; height: 96px; object-fit: cover; }
#workspace[data-card-ratio="portrait"] .tile.has-name:not(.text-tile) img { width: 68px; height: 90px; }
#workspace[data-card-ratio="portrait"] .tile.text-tile { min-height: 96px; }
#workspace[data-card-ratio="portrait"] .tile.text-tile .text-tile-body { -webkit-line-clamp: 5; }
#workspace[data-card-ratio="original"] .tile:not(.text-tile) img { width: auto; height: auto; max-width: 72px; max-height: 72px; object-fit: contain; }
#workspace[data-card-ratio="original"] .tile.has-name:not(.text-tile) img { max-width: 68px; max-height: 68px; }
.ratio-icons svg { width: 16px; height: 16px; flex: none; }
.row-add-actions { display: flex; flex-wrap: wrap; align-items: center; align-self: center; gap: 4px; }
.text-card-status { margin: 10px 0 0; font-size: 13px; font-weight: 700; color: var(--sub); }
.item-color-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item-colors { display: flex; flex-wrap: wrap; gap: 6px; }
main .item-colors .color-choice { width: 32px; min-height: 32px; }

/* Tier表の背景テーマ（プレビューとPNG書き出しで同じ配色） */
#board[data-board-theme="cream"] { padding: 12px; border: 1px solid #EAE0CE; border-radius: 16px; background: #FBF6EC; }
#board[data-board-theme="cream"] .tier-row { background: #F2E9D8; }
#board[data-board-theme="cream"] .tile.has-name:not(.text-tile) { background: #FFFDF9; }
#board[data-board-theme="pastel"] { padding: 12px; border: 1px solid #F6D2E0; border-radius: 16px; background: #FFF2F7; }
#board[data-board-theme="pastel"] .tier-row { background: #FBE3EC; }
#board[data-board-theme="pastel"] .tile.has-name:not(.text-tile) { background: #FFFFFF; }
#board[data-board-theme="dark"] { padding: 12px; border: 1px solid #34343A; border-radius: 16px; background: #1A1A1E; }
#board[data-board-theme="dark"] .tier-row { background: #222226; }
#board[data-board-theme="dark"] .tile.has-name:not(.text-tile) { background: #303036; color: #F5F7FF; }
#board[data-board-theme="dark"] .tile:hover:not(:disabled) { border-color: #777780; }
#board[data-board-theme="dark"] .tile:not(.text-tile)[aria-pressed="true"] { border-color: #FF5C5C; background: #3A292C; }
#board[data-board-theme="dark"] .tile.text-tile[aria-pressed="true"] { border-color: #FF5C5C; box-shadow: 0 0 0 2px #FF5C5C, inset 0 0 0 2px #1A1A1E; }
#board[data-board-theme="dark"] .tile:not(.text-tile) span { color: #E7E7EC; }
#board[data-board-theme="dark"] .tile:not(.text-tile)[aria-pressed="true"] span { color: #FFFFFF; }
#board[data-board-theme="dark"] .row-add { color: #D6D6DE; }
#board[data-board-theme="dark"] .row-add:hover:not(:disabled) { background: #303036; color: #FFFFFF; }
#board[data-board-theme="dark"] .row-add .plus { color: #FF5C5C; }
#board[data-board-theme="dark"] .move-here { border-color: #FFFFFF; background: #FFFFFF; color: #1F1D1B; }

@media (max-width: 700px) {
  [data-ep-shell="tier"] .ep-shell-actions { padding: 4px 12px calc(4px + env(safe-area-inset-bottom)); }
  [data-ep-shell="tier"] .ep-shell-actions button { min-height: 44px; padding-block: 4px; }
  .style-toggle { display: inline-flex; flex: 0 0 auto; }
  .style-toggle[aria-expanded="true"] { border-color: var(--ink); background: var(--surface); }
  .board-style-bar { display: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #FFF; }
  .board-style-bar.is-open { display: flex; }
  .import-actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; width: 100%; }
  .import-actions button { padding: 0 10px; font-size: 13px; white-space: nowrap; }
  .tier-row { grid-template-columns: 96px minmax(0,1fr); min-height: 60px; }
  main .row-label { font-size: 20px; }
  .row-content { padding: 4px 8px; }
  main .theme-buttons button { min-height: 44px; padding: 0 12px; }
  main #theme-options button { padding: 0 12px 0 8px; }
  #workspace[data-card-ratio="square"] .tile:not(.text-tile) img { width: 60px; height: 60px; }
  #workspace[data-card-ratio="square"] .tile.has-name:not(.text-tile) img { width: 56px; height: 56px; }
  #workspace[data-card-ratio="portrait"] .tile:not(.text-tile) img { width: 60px; height: 80px; }
  #workspace[data-card-ratio="portrait"] .tile.has-name:not(.text-tile) img { width: 56px; height: 75px; }
  #workspace[data-card-ratio="portrait"] .tile.text-tile { min-height: 80px; }
  #workspace[data-card-ratio="original"] .tile:not(.text-tile) img { max-width: 60px; max-height: 60px; }
  #workspace[data-card-ratio="original"] .tile.has-name:not(.text-tile) img { max-width: 56px; max-height: 56px; }
  main .tile.text-tile { width: 64px; min-height: 64px; }
  #board[data-board-theme="cream"], #board[data-board-theme="pastel"], #board[data-board-theme="dark"] { padding: 8px; }
}

@media (max-width: 390px) {
  .tier-row { grid-template-columns: 74px minmax(0, 1fr); min-height: 56px; }
  .label-cell { padding: 3px; }
  main .row-label { min-height: 48px; font-size: 18px; }
  .row-content { gap: 6px; padding: 3px 6px; }
  main .row-add { min-height: 40px; padding: 0 8px; font-size: 12px; }
  .quick-move { display: flex; }
  .quick-move button { flex: 1 0 auto; min-height: 36px; padding: 0 9px; font-size: 12px; }
  .edit-strip { gap: 6px; }
  /* 行名から開く設定ダイアログにも同じ上下移動がある。狭幅では表内の
     重複矢印だけを省き、削除・選択解除などの選択操作は残す。 */
  .board-row-order { display: none; }
  body.selecting .workspace { padding-bottom: calc(var(--ep-selection-height, 148px) + 60px + 20px); }
}
