/* 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 transparent; 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: 6px; }
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; }
.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: 80px; }
.selection { font-size: 13px; font-weight: 700; color: var(--ink); }
.selection-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.selection-actions button { padding: 0 14px; font-size: 13px; }

/* 表 */
#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: center; gap: 8px; min-width: 0; padding: 10px 8px; background: var(--row-color, #DAD4CD); }
.label-cell textarea { display: block; width: 100%; min-width: 0; padding: 4px 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: 24px; 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: contents; }
main .move-here { display: none; width: 100%; min-height: 34px; padding: 2px 6px; border-color: var(--ink); font-size: 12px; }
body.selecting main .move-here { display: inline-flex; }
main .row-delete { position: absolute; top: 4px; right: 4px; width: 28px; min-height: 28px; padding: 0; border-color: transparent; background: transparent; color: var(--ink); opacity: .45; }
main .row-delete:hover:not(:disabled), main .row-delete:focus-visible { border-color: transparent; background: rgba(255, 255, 255, .6); opacity: 1; }
main .row-delete:disabled { display: none; }
main .row-delete svg { width: 16px; height: 16px; }
.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: 1 1 220px; min-width: 160px; min-height: 68px; border: 1.5px dashed var(--dash); border-radius: 10px; background: transparent; font-size: 13px; color: var(--sub); }
main .row-add:hover:not(:disabled) { background: #FFF; color: var(--ink); }
.row-add .plus { font-size: 20px; font-weight: 400; color: var(--shu-text); }
main .tile { flex: 0 0 80px; flex-direction: column; justify-content: flex-start; gap: 4px; width: 80px; min-height: 92px; padding: 4px; border: 2px solid transparent; border-radius: 10px; background: #FFF; cursor: grab; }
main .tile:hover:not(:disabled) { border-color: var(--dash); }
.tile img { width: 68px; height: 60px; object-fit: contain; border-radius: 6px; pointer-events: none; }
.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: 1.5px dashed var(--dash); border-radius: 12px; background: transparent; }

/* 未分類 */
.pool { margin-top: 20px; border: 1.5px dashed var(--dash); 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; }
.pool > .tiles { min-height: 104px; padding: 12px; }
.empty { margin: auto; padding: 16px; font-size: 13px; line-height: 1.7; color: var(--sub); text-align: center; }

/* 状態・説明 */
.status-bar { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.status-bar p { font-size: 12px; line-height: 1.6; color: var(--sub); }
/* 操作結果のトースト。選択バーが出ているときはその上に出す。 */
.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); }
body.selecting .toast { bottom: 84px; }
#saved { margin-left: auto; }
#saved { text-align: right; }
#saved.error { font-weight: 700; color: var(--shu-text); }
details { margin-top: 16px; border-radius: 12px; background: var(--surface); }
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)); 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-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px; background: var(--surface); }
.preview-body img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(31, 29, 27, .12); }
.preview-foot { border-top: 1px solid var(--line); }
.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; }
  main .row-add { flex-basis: 100%; min-height: 60px; }
}

@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); gap: 6px; }
  .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: 130px; }
  body.selecting .toast { bottom: 132px; }
  .selection-actions button { flex: 1; padding: 0 8px; }
  .tier-row { grid-template-columns: 88px minmax(0, 1fr); min-height: 80px; }
  .label-cell { padding: 8px 5px; }
  .label-cell textarea { padding: 3px; font-size: 20px; }
  main .move-here { min-height: 44px; }
  main .row-delete { top: 2px; right: 2px; width: 32px; min-height: 32px; }
  .row-content { gap: 6px; padding: 8px; }
  main .row-add { min-width: 0; min-height: 52px; }
  main .tile { flex-basis: 70px; width: 70px; }
  .tile img { width: 58px; height: 54px; }
  .tile span { width: 58px; }
  #saved { margin-left: 0; text-align: left; }
  .preview-actions { width: 100%; }
  .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; }
}
