/* ポジショニングマップメーカー：エンタメパンダ ツールズと同じ白・墨・パンダ朱 */
:root {
  --ink: #1F1D1B;
  --sub: #66615C;
  --line: #E8E3DD;
  --surface: #F6F3EF;
  --blush: #FDF0EB;
  --shu: #E5452B;
  --shu-deep: #C93A22;
  --shu-text: #C93A22;
  --axis: #1F1D1B;
  --grid: #E3DCD3;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --shadow: 0 12px 32px rgba(31, 29, 27, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: #FFFFFF; color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.6; letter-spacing: .02em;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
/* 朱の細い線（エンタメパンダ本体のヘッダーと同じ） */
body::before { content: ""; display: block; flex-shrink: 0; height: 4px; background: var(--shu); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2 { margin: 0; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }

/* サイト共通ヘッダー */
.hd { flex-shrink: 0; display: flex; align-items: center; gap: 8px 32px; height: 60px; padding: 0 40px; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-right: auto; min-width: 0; }
.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); line-height: 1.4; }
.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; }

/* ボタン */
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #FFFFFF; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tbtn svg { width: 16px; height: 16px; }
.tbtn:hover { border-color: var(--ink); }
.tbtn.primary { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
.tbtn[aria-pressed="true"], .tbtn[aria-expanded="true"] { border-color: var(--shu-deep); background: var(--blush); color: var(--shu-text); }
.tbtn.danger { border-color: #E7B2A8; background: var(--blush); color: var(--shu-text); }
.tbtn.danger:hover { border-color: var(--shu-text); background: var(--blush); }
#savePng.primary { border-color: var(--shu-deep); background: var(--shu-deep); }
#savePng.primary:hover { border-color: var(--ink); background: var(--ink); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #FFFFFF; }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.text-btn { min-height: 44px; padding: 0; border: 0; background: none; font-size: 13px; font-weight: 700; color: var(--sub); text-decoration: underline; }
.image-row .text-btn { min-width: 44px; padding: 0 8px; }
.text-btn:disabled { opacity: .45; text-decoration: none; }
.danger { color: var(--shu-text); }

/* ツールの操作列 */
.pm-bar { position: relative; z-index: 20; flex-shrink: 0; display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 6px 40px; border-bottom: 1px solid var(--line); background: #FFFFFF; }
.pm-name { font-size: 15px; font-weight: 900; white-space: nowrap; }
.top-actions { position: relative; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-actions .icon-btn { width: 44px; height: 44px; border-color: transparent; }
.top-actions .icon-btn:hover { border-color: var(--line); }
.more-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: #FFFFFF; box-shadow: var(--shadow); }
.more-menu button { display: block; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: #FFFFFF; font-size: 14px; font-weight: 700; text-align: left; }
.more-menu button:hover { background: var(--surface); }

/* 作業面 */
.workspace { flex: 1; min-height: 0; padding: 12px 16px; background: #FFFFFF; }
.map-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; height: 100%; max-width: 1400px; margin: 0 auto; }
/* 設定の開閉で描画面が動かないよう、PCでは右側を編集専用に確保する。 */
.map { position: relative; grid-column: 1; grid-row: 1; min-width: 0; min-height: 0; height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); touch-action: none; user-select: none; cursor: crosshair; }
/* グリッドは縦横10等分（PNGも同じ） */
.map.grid { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 10% 10%; background-position: -1px -1px; }

.axis { position: absolute; background: var(--axis); pointer-events: none; }
.axis.horizontal { left: max(14%, calc(1.5% + 140px)); right: max(14%, calc(1.5% + 140px)); top: 50%; height: 3px; margin-top: -1.5px; }
.axis.vertical { top: max(12%, calc(3% + 70px)); bottom: max(12%, calc(3% + 70px)); left: 50%; width: 3px; margin-left: -1.5px; } /* 矢印を上下の軸ラベルに潜らせない */
.axis::before, .axis::after { content: ""; position: absolute; width: 9px; height: 9px; border: solid var(--axis); border-width: 3px 3px 0 0; }
.axis.horizontal::before { left: -1px; top: -4.5px; transform: rotate(-135deg); }
.axis.horizontal::after { right: -1px; top: -4.5px; transform: rotate(45deg); }
.axis.vertical::before { top: -1px; left: -4.5px; transform: rotate(-45deg); }
.axis.vertical::after { bottom: -1px; left: -4.5px; transform: rotate(135deg); }

.axis-label { position: absolute; z-index: 4; width: 140px; min-height: 44px; padding: 11px 8px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; color: var(--ink); font: 700 14px/1.35 var(--font); text-align: center; overflow: hidden; overflow-wrap: anywhere; resize: none; cursor: text; user-select: text; }
.axis-label { border-style: dashed; }
.axis-label:hover, .axis-label:focus { border-style: solid; border-color: var(--sub); }
@media (min-width: 761px) { .axis-label { padding-right: 28px; background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366615C' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9l-4-4L4 16z'/%3E%3C/svg%3E") no-repeat right 8px center / 13px; } }
.axis-label:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.axis-label.top { top: 3%; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 3%; left: 50%; transform: translateX(-50%); }
.axis-label.left { top: 50%; left: 1.5%; width: 128px; transform: translateY(-50%); }
.axis-label.right { top: 50%; right: 1.5%; width: 128px; transform: translateY(-50%); }
/* 編集中は左右ラベルを広げ、長い文字も見えるようにする */
.axis-label.left:focus, .axis-label.right:focus { z-index: 6; width: 200px; }

.map-empty { position: absolute; left: 50%; top: 50%; z-index: 3; margin: 0; padding: 6px 14px; border-radius: 999px; background: #FFFFFF; color: var(--sub); font-size: 13px; font-weight: 700; transform: translate(-50%, calc(-50% - 36px)); white-space: nowrap; pointer-events: none; }

/* アイテム */
.item { position: absolute; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 44px; min-height: 44px; padding: 2px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); transform: translate(-50%, -50%); cursor: grab; touch-action: none; }
.item:active { cursor: grabbing; }
.item.selected { z-index: 8; }
.item.dragging { z-index: 9; }
.avatar { display: grid; place-items: center; width: 64px; height: 64px; overflow: hidden; border: 3px solid var(--item-color, var(--sub)); border-radius: 50%; background: var(--item-tint, #FFFFFF); color: var(--item-color, var(--sub)); }
.avatar img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.avatar svg { width: 62%; height: 62%; margin-top: 12%; fill: currentColor; }
.item.selected .avatar { box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 5px var(--ink); }
.item-name { max-width: 160px; overflow: hidden; padding: 2px 12px; border: 1.5px solid var(--item-color, var(--line)); border-radius: 999px; background: #FFFFFF; font-size: 13px; font-weight: 700; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.item.text-mode .item-name { padding: 6px 14px; background: var(--item-fill, var(--item-tint, #FFFFFF)); color: var(--item-text, var(--ink)); font-size: 14px; }
.item.text-mode.selected .item-name { box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 5px var(--ink); }
.item:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* テンプレート */
.templates { position: absolute; z-index: 10; top: 12px; left: 12px; width: 280px; max-height: calc(100% - 24px); overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; box-shadow: var(--shadow); }
.panel-heading, .inspector-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading { padding: 6px 6px 6px 16px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .inspector-head h2 { font-size: 15px; font-weight: 900; }
.panel-heading .icon-btn, .inspector-head .icon-btn { border-color: transparent; }
.panel-heading .icon-btn:hover, .inspector-head .icon-btn:hover { border-color: var(--line); }
.template-list { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.template-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; background: #FFFFFF; text-align: left; }
.template-card:hover { background: var(--surface); }
.template-card > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.template-card strong { font-size: 14px; font-weight: 700; }
.template-card small { font-size: 12px; color: var(--sub); }
/* 十字の軸と点で描いた小さなマップ */
.template-icon { position: relative; display: block; flex: 0 0 64px; height: 48px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.template-icon::before, .template-icon::after { content: ""; position: absolute; background: var(--axis); }
.template-icon::before { left: 8px; right: 8px; top: 50%; height: 1.5px; }
.template-icon::after { top: 6px; bottom: 6px; left: 50%; width: 1.5px; }
.template-icon i { position: absolute; z-index: 1; display: block; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; background: #FFFFFF; }
.template-icon i:nth-child(1) { top: 6px; left: 12px; border-color: var(--shu); background: var(--blush); }
.template-icon i:nth-child(2) { top: 12px; right: 9px; }
.template-icon i:nth-child(3) { bottom: 6px; left: 26px; }
.template-icon.labels i { width: 18px; height: 9px; border-radius: 999px; }
.template-icon.blank { display: grid; place-items: center; border: 1.5px dashed var(--sub); background: #FFFFFF; font-size: 22px; color: var(--sub); }
.template-icon.blank::before, .template-icon.blank::after { display: none; }

/* アイテムの設定はマップと別の領域に置き、人物を覆わない。 */
.inspector { position: relative; grid-column: 2; grid-row: 1; align-self: start; z-index: 13; width: 280px; max-height: 100%; overflow: auto; padding: 4px 16px 6px; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; box-shadow: var(--shadow); }
.inspector-head { margin: 0 -10px 0 0; }
.field { display: block; margin: 4px 0; padding: 0; border: 0; font-size: 12px; font-weight: 700; color: var(--sub); }
.field legend, .field-label { display: block; padding: 0; }
.inspector input, .inspector select { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; font-size: 16px; font-weight: 400; color: var(--ink); }
.inspector input:focus-visible, .inspector select:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.image-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.avatar.preview { width: 44px; height: 44px; border-width: 2px; }
.image-row .tbtn { min-height: 44px; }
.note { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--sub); }
.color-options { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; padding: 3px; }
.color-chip { position: relative; width: 44px; height: 44px; padding: 0; border: 3px solid #FFFFFF; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .14), 0 0 0 1px var(--line); }
.color-chip.active { box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .14), 0 0 0 2px var(--ink); }
.color-chip-custom { display: inline-grid; place-items: center; overflow: hidden; flex: none; background: conic-gradient(#F8BBD0, #FFF0A6, #B8EBD4, #B3E5FC, #D8C2F5, #F8BBD0); color: #2B2326; cursor: pointer; }
.color-chip-custom:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.inspector .color-picker-input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.color-custom-mark { pointer-events: none; font-size: 16px; font-weight: 900; line-height: 1; }
.field-pos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inspector-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.inspector-close { flex: none; padding: 0 12px; }
.only-sp { display: none; }
.lbl .short { display: none; }
.title-row { flex-shrink: 0; padding: 4px 40px 0; background: #FFFFFF; }
.title-row button { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 0 12px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; }
.title-row button:hover { border-color: var(--sub); background: var(--surface); }
.title-row strong { overflow: hidden; font-size: 16px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.title-row svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--sub); }
.first-hint { flex-shrink: 0; display: flex; align-items: center; gap: 8px 12px; margin: 4px 40px 0; padding: 4px 4px 4px 14px; border: 1px solid var(--line); border-radius: 12px; background: transparent; font-size: 13px; font-weight: 700; line-height: 1.5; }
.first-hint[hidden] { display: none; }
.first-hint span { flex: 1; }
.first-hint .text-btn { flex-shrink: 0; padding: 0 12px; color: var(--shu-text); }
.inspector-actions .tbtn { min-height: 44px; padding: 0 18px; }

/* 下部バー */
.bottom-bar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 6px 40px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #FFFFFF; }
.history-actions { display: flex; gap: 8px; margin-right: auto; }
.history-actions .icon-btn { border-color: transparent; }
.history-actions .icon-btn:hover { border-color: var(--line); }
.history-actions .icon-btn:disabled { opacity: .35; border-color: transparent; }
.view-actions { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
.segmented { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.segmented button, .grid-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; font-size: 13px; font-weight: 700; white-space: nowrap; }
.segmented button:hover, .grid-btn:hover { background: var(--surface); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.grid-btn { border: 1px solid var(--line); height: 44px; }
.grid-btn[aria-pressed="true"] { border-color: var(--shu-deep); background: var(--blush); color: var(--shu-text); }
.segmented svg, .grid-btn svg { width: 18px; height: 18px; }

/* トースト・ダイアログ */
.toast { position: fixed; z-index: 50; top: auto; right: auto; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); margin: 0; border: 0; overflow: visible; display: flex; align-items: center; gap: 4px 12px; width: max-content; max-width: calc(100% - 32px); padding: 6px 14px; border-radius: 999px; background: var(--ink); color: #FFFFFF; font-size: 13px; font-weight: 700; transform: translateX(-50%); }
.toast[hidden] { display: none; }
.toast-undo { flex-shrink: 0; min-height: 44px; margin: -6px -8px -6px 0; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: #FFFFFF; font-size: 13px; font-weight: 900; text-decoration: underline; }
.toast-undo:hover { background: rgba(255, 255, 255, .16); }
.toast-undo:focus-visible { outline-color: #FFFFFF; }
.preview { width: min(860px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: 16px; background: #FFFFFF; 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; 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 { margin: 0; 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 { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(31, 29, 27, .12); }
.preview-foot { justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); }
.preview-brand-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer; user-select: none; }
.preview-brand-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--shu-deep); flex-shrink: 0; cursor: pointer; }
.preview-actions { display: flex; gap: 8px; margin-left: auto; }
.preview-foot .tbtn { min-height: 44px; padding: 0 20px; }
.app-dialog { width: min(400px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; color: var(--ink); box-shadow: 0 20px 48px rgba(31, 29, 27, .16); }
.app-dialog::backdrop { background: rgba(31, 29, 27, .2); }
.app-dialog form { padding: 20px; }
.app-dialog p { margin: 0 0 16px; font-size: 15px; font-weight: 700; line-height: 1.7; white-space: pre-line; }
.app-dialog input { display: block; width: 100%; min-height: 44px; margin: -4px 0 16px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.app-dialog input:focus-visible { border-color: var(--ink); outline: 3px solid var(--ink); outline-offset: 1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .tbtn { min-height: 44px; padding: 0 18px; }
.help-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); }
.help-dialog h2 { margin-bottom: 8px; font-size: 17px; font-weight: 900; }
.help-steps { margin: 0 0 16px; padding-left: 1.4em; font-size: 14px; line-height: 1.7; }
.help-steps li { margin: 10px 0; }
.help-steps strong { display: block; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media (max-width: 1020px) {
  .title-row { padding-right: 28px; }
  .first-hint { margin-left: 28px; margin-right: 28px; }
  .hd, .pm-bar, .bottom-bar { padding-right: 28px; }
}

@media (max-width: 760px) {
  .pm-bar { gap: 8px; min-height: 56px; padding: 6px 12px; }
  .pm-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top-actions { flex: 1; justify-content: space-between; gap: 8px; margin: 0; }
  .top-actions .tbtn { min-height: 44px; padding: 0 8px; gap: 4px; font-size: 12px; }
  .top-actions .tbtn svg { width: 18px; height: 18px; }
  .lbl .full { display: none; }
  .lbl .short { display: inline; }
  #savePng .lbl { font-size: 12px; }
  .title-row { padding: 2px 12px 0; }
  .first-hint { margin: 4px 8px 0; font-size: 12px; }
  .top-actions .icon-btn { width: 44px; height: 44px; }
  .workspace { padding: 8px; }
  .map-shell { display: flex; flex-direction: column; gap: 8px; }
  .map { flex: 1; height: auto; border-radius: 12px; }
  .axis-label { width: 108px; min-height: 44px; padding: 11px 6px; font-size: 16px; }
  .axis-label.long { font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
  .axis-label.top, .axis-label.bottom { width: 132px; }
  .axis-label.top { top: 2%; }
  .axis-label.bottom { bottom: 2%; }
  .axis-label.left, .axis-label.right { width: 80px; }
  .axis-label.left:focus, .axis-label.right:focus { width: min(200px, 52%); }
  .axis-label.left { left: 2px; }
  .axis-label.right { right: 2px; }
  .axis.horizontal { left: 28%; right: 28%; }
  .axis.vertical { top: max(9%, calc(2% + 62px)); bottom: max(9%, calc(2% + 62px)); }
  .avatar { width: 48px; height: 48px; }
  .item-name { max-width: 110px; padding: 1px 8px; font-size: 12px; }
  .item.text-mode .item-name { padding: 8px 12px; font-size: 13px; }
  .map-empty { font-size: 12px; white-space: normal; width: 80%; text-align: center; }
  .templates { top: 8px; left: 8px; width: min(280px, calc(100% - 16px)); }
  .field-color legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .only-sp { display: inline-flex; align-items: center; }
  .bottom-bar { gap: 8px; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .history-actions { gap: 8px; margin-right: auto; }
  .view-actions { gap: 8px; margin-left: 0; }
  .segmented { padding: 0; }
  .segmented button { height: 44px; padding: 0 8px; gap: 3px; font-size: 12px; }
  .grid-btn { padding: 0 10px; gap: 3px; font-size: 12px; }
  .segmented svg, .grid-btn svg { width: 16px; height: 16px; }
  .preview-foot { padding-left: 12px; }
  .preview-actions { width: 100%; }
  .preview-actions .tbtn { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .hd { padding: 0 16px; gap: 16px; }
  .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; }
}

/* 操作画面の下に置く静的な使い方・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; }
body[data-ep-shell="diagram"] .tool-screen { height: auto; }
html, body { height: auto; overflow: auto; }
body { display: block; }

@media (max-width: 760px) {
  html.ep-keyboard-open .tool-screen { position: fixed; top: var(--ep-viewport-top, 0px); left: 0; width: 100%; height: var(--ep-viewport-height, 100dvh); min-height: 0; }
  html.ep-keyboard-open .hd, html.ep-keyboard-open .pm-bar, html.ep-keyboard-open .first-hint, html.ep-keyboard-open .bottom-bar { display: none; }
  html.ep-keyboard-open .inspector { max-height: 75%; }
  html.ep-keyboard-open .app-dialog[open] { top: var(--ep-viewport-top, 0px); bottom: var(--ep-keyboard-inset, 0px); max-height: calc(var(--ep-viewport-height, 100dvh) - 16px); overflow: auto; }
}

/* 共通操作バー（スマホ）：理由文は保存ボタンの真上に1行、下に「共有」「画像を保存」。「プレビュー」はマップの編集画面と同じなので隠す。 */
[data-ep-shell="diagram"] .ep-shell-actions { flex-wrap: wrap; }
[data-ep-shell="diagram"] .ep-shell-actions > button:not(.ep-shell-primary):not([data-ep-custom]) { display: none; }
[data-ep-shell="diagram"] .ep-shell-actions > [data-ep-custom] { flex: 0 0 112px; }
[data-ep-shell="diagram"] .ep-shell-actions > .ep-shell-primary { flex: 1 1 0; }
.ep-save-reason { order: -1; flex: 0 0 100%; min-width: 0; color: #9A2412; font: 700 12.5px/1.4 var(--font); }
@media (max-width: 760px) {
  body:has(.ep-save-reason:not([hidden])) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
/* 無効ボタンの共通の見た目（赤系を薄くせず、灰みの面にする） */
[data-ep-shell="diagram"] .ep-shell-actions button:disabled, .panel-save-btn:disabled, .panel-share-btn:disabled, .tbtn.primary:disabled {
  border: 0; background: #E6E0D7; color: #5f5852; box-shadow: none; opacity: 1; cursor: not-allowed;
}
html[data-theme="dark"] [data-ep-shell="diagram"] .ep-shell-actions button:disabled, html[data-theme="dark"] .panel-save-btn:disabled, html[data-theme="dark"] .panel-share-btn:disabled, html[data-theme="dark"] .tbtn.primary:disabled { background: #2C2832; color: #B5AEA6; }
.more-menu button:disabled { color: var(--sub); cursor: default; }
.more-menu button:disabled:hover { background: #FFFFFF; }
.menu-hint { display: block; padding: 0 12px 6px; color: var(--sub); font-size: 12px; line-height: 1.4; }
.first-hint b { font-weight: 900; }
/* 保存ダイアログの注記 */
.preview > p { margin: 0; padding: 10px 20px 2px; font-size: 13px; line-height: 1.6; color: var(--sub); }

/* アイテムの設定：名前と画像を最上段に置く。画像は「画像を選ぶ」で最上段から選べる。 */
.insp-name-row { display: flex; align-items: flex-end; gap: 8px; }
.insp-name-row .field-name { flex: 1; min-width: 0; }
.insp-name-row .tbtn { flex: none; min-height: 44px; margin-bottom: 10px; }
.inspector-head .only-sp { display: none; }

/* スマホ：設定は地図を押し下げず、地図の上に重なる低い下部シートにする（選んだアイテムの反対側に出る） */
@media (max-width: 760px) {
  .inspector { position: absolute; left: 8px; right: 8px; bottom: 8px; top: auto; z-index: 13; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; width: auto; max-height: 68%; padding: 8px 8px 8px 12px; overflow: auto; overscroll-behavior: contain; border-radius: 14px; box-shadow: 0 4px 20px rgba(31, 29, 27, .22); }
  .inspector.at-top { top: 8px; bottom: auto; }
  .inspector-head { grid-column: 2; grid-row: 1; display: flex; gap: 8px; margin: 0; }
  .inspector-head h2 { display: none; }
  .inspector-head .only-sp { display: grid; }
  .inspector-head .icon-btn { border-color: var(--line); }
  .insp-name-row { grid-column: 1; grid-row: 1; min-width: 0; }
  .insp-name-row .field-name { margin: 0; }
  .insp-name-row .tbtn { margin-bottom: 0; padding: 0 12px; }
  .field-name .lt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .insp-body { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-top: 8px; }
  .inspector.collapsed .insp-body { display: none; }
  .inspector.collapsed #collapseInspector svg { transform: rotate(180deg); }
  .field-color { grid-column: 1; min-width: 0; margin: 0; }
  .color-options { flex-wrap: nowrap; gap: 8px; margin: 0; padding: 4px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .color-chip { flex: none; scroll-snap-align: start; }
  #toggleDetail { grid-column: 2; min-width: 64px; padding: 0 4px; white-space: nowrap; }
  .inspector-actions { grid-column: 1 / -1; margin-top: 0; }
  .inspector-actions .tbtn { padding: 0 12px; }
  .inspector-detail { display: none; grid-column: 1 / -1; }
  .inspector.expanded .inspector-detail { display: grid; grid-template-columns: 1.3fr 1fr 1fr; column-gap: 8px; align-items: end; }
  .inspector-detail .field-image { grid-column: 1 / -1; }
  .inspector-detail .field-mode { grid-column: 1; }
  .inspector-detail .field-pos { grid-column: 2 / 4; gap: 8px; }
  .first-hint .text-btn { min-width: 44px; }
  .preview > p { padding: 10px 16px 2px; }
}

/* ===== PC（761px以上）：新しいメーカーと同じ「タイトル行＋主パネルの見出し行」 =====
   上の操作列は使わず、タイトル行（ツール名・説明・自動保存・「…」）と、主パネルの見出し行（タイトル・画像を保存）に分ける。
   マップの道具（追加・表示・元に戻す）は見出し行の下の道具列に置く。移し替えは app.js の placeLayout()。 */
.map-panel { display: contents; }
.panel-head, .panel-tools, .pm-meta, .more-menu .menu-pc { display: none; }
@media (min-width: 761px) {
  .top-actions, .bottom-bar, .title-row { display: none; }
  /* 共通の操作バー（tool-shell）はPCでは使わない。画像を保存は主パネルの見出し行にある（#savePng は共通バー用に残す）。 */
  [data-ep-slug="positioning-map-maker"] .ep-shell-actions { display: none; }
  .more-menu .menu-pc { display: block; }
  .more-menu .menu-danger { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: var(--shu-text); }
  .pm-bar { flex-wrap: wrap; gap: 0 14px; min-height: 44px; padding: 2px max(12px, calc((100% - 1400px) / 2)); border-bottom: 0; }
  .pm-bar .ep-shell-heading { display: flex; flex: 1 1 0; align-items: baseline; gap: 0 12px; min-width: 0; }
  .pm-bar .pm-name { flex: none; font-size: 18px; font-weight: 900; line-height: 1.35; letter-spacing: 0; }
  .pm-bar .ep-shell-heading .ep-shell-description { margin: 0; min-width: 0; overflow: hidden; font-size: 13px; color: var(--sub); text-overflow: ellipsis; white-space: nowrap; }
  .pm-meta { position: relative; display: flex; flex: none; align-items: center; gap: 12px; }
  .pm-meta .icon-btn { border-radius: 10px; }
  .first-hint { margin: 0 max(12px, calc((100% - 1400px) / 2)) 8px; }
  .workspace { padding: 0 12px 10px; }
  .map-shell { grid-template-rows: minmax(0, 1fr); }
  /* 見出し、操作、出力設定を別の行に置く。設定パネルの開閉やフォントで行を切り替えない。 */
  .map-panel {
    position: relative; display: grid; grid-column: 1; grid-row: 1;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "tools" "output" "map";
    min-width: 0; min-height: 0; padding: 8px 14px 12px; border-radius: 16px; background: #F5F2ED;
  }
  .map-panel > .panel-head { grid-area: head; }
  .map-panel > .panel-tools { grid-area: tools; }
  .map-panel > .discussion-controls { grid-area: output; }
  .map-panel > .map, .map-panel > .templates { grid-area: map; }
  .map-panel > .map { height: auto; border-radius: 12px; background-color: #FFFFFF; }
  .panel-head, .panel-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
  .panel-head { margin-bottom: 6px; }
  .panel-tools { margin-bottom: 8px; }
  .panel-head-main { min-width: 0; }
  .panel-head #editTitle { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 0 12px; border: 1px dashed #CFC6BA; border-radius: 10px; background: #FFFFFF; }
  .panel-head #editTitle:hover { border-color: var(--sub); }
  .panel-head #editTitle strong { overflow: hidden; max-width: min(46vw, 520px); font-size: 16px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
  .panel-head #editTitle svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--sub); }
  .panel-save { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
  .panel-reason { color: #9A2412; font-size: 13px; font-weight: 700; line-height: 1.4; text-align: right; }
  .panel-save-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border: 1.5px solid var(--shu-deep); border-radius: 10px; background: var(--shu-deep); color: #FFFFFF; font-size: 14px; font-weight: 700; line-height: 1.4; }
  .panel-save-btn svg { width: 16px; height: 16px; }
  .panel-save-btn:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); }
  .panel-share-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #FFFFFF; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.4; }
  .panel-share-btn svg { width: 16px; height: 16px; }
  .panel-share-btn:hover:not(:disabled) { border-color: var(--ink); }
  .panel-reason { max-width: 24em; }
  .tools-main, .tools-side { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 100%; }
  .tools-side { margin-left: auto; }
  .panel-tools .history-actions { gap: 4px; margin-right: 0; }
  .panel-tools .history-actions .icon-btn, .panel-tools .history-actions .icon-btn:disabled { border-color: var(--line); }
  .panel-tools .view-actions { margin-left: 4px; }
  .panel-tools .segmented { background: #FFFFFF; }
  .panel-tools .grid-btn { background: #FFFFFF; }
  .panel-tools .grid-btn[aria-pressed="true"] { background: var(--blush); }
}
/* 900px以下（タブレット縦など）は道具列の余白とボタンの幅を詰める */
@media (min-width: 761px) and (max-width: 900px) {
  .map-panel { padding: 8px 12px 10px; }
  .panel-tools .tbtn { padding: 0 10px; gap: 4px; }
  .tools-main, .tools-side { gap: 6px; }
  .panel-tools .history-actions { gap: 2px; }
  .panel-tools .view-actions { gap: 6px; margin-left: 0; }
  .panel-tools .segmented button, .panel-tools .grid-btn { padding: 0 8px; gap: 4px; }
}

/* 共有ダイアログ：ガチャ系（result-actions.css）と同じクラス名・見た目 */
/* スマホの配置（〜760px）では、トーストを下部の行（タイトル・元に戻す・拡大）と共通操作バーの上に出す。
   --ep-sheet-bottom は app.js が共通操作バーの実際の高さ（理由文・安全領域を含む）から入れる */
@media (max-width: 760px) {
  /* 共通シェルは通常 44px ボタン + 16px 余白で61pxになる。マップではキーボード時に隠すため、通常時も56px以内に収める。 */
  [data-ep-shell="diagram"] .ep-shell-actions { box-sizing: border-box; min-height: 52px; height: 56px; padding: 4px 12px; }
  [data-ep-shell="diagram"] .ep-shell-actions button { min-height: 44px; padding-block: 4px; }
  .toast { bottom: calc(var(--ep-sheet-bottom, 61px) + 64px); }
}

/* 2026-11-04：描画範囲を画面の高さに縛らず、地図の縦横比で決める（PCは保存画像と同じ16:11、スマホは縦に少し長い10:12）。
   以前は画面の高さいっぱいに収める作りで、共通ヘッダーが入ると地図が低くなっていた。ページはふつうにスクロールする。 */
html, body { height: auto; overflow: visible; }
body { min-height: 100vh; min-height: 100dvh; }
.workspace { flex: none; }
.map-shell { height: auto; }
.map, .map-panel > .map { height: auto; aspect-ratio: 16 / 11; }
.discussion-controls { grid-column: 1; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.discussion-controls summary { min-height: 42px; padding: 11px 14px; cursor: pointer; font-weight: 700; }
.discussion-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 14px 14px; }
.discussion-grid label, .discussion-axis-notes label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; }
.discussion-grid input, .discussion-grid select, .discussion-grid textarea { width: 100%; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; color: var(--ink); font: inherit; }
.discussion-grid textarea { resize: vertical; }
.discussion-grid .wide { grid-column: 1 / -1; }
.discussion-axis-notes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; border: 0; padding: 0; }
.discussion-actions { display: flex; gap: 8px; }
.discussion-grid .check { display: flex; align-items: end; gap: 6px; padding-bottom: 9px; }
.discussion-grid .check input { width: auto; min-height: 0; }
.discussion-only { display: none; }
body:not(.discussion-mode) .discussion-grid > :not(:first-child) { display: none; }
body.discussion-mode .discussion-only { display: grid; }
body.discussion-mode .map { background: #fff; }
body.discussion-mode .axis-label { border: 0; border-radius: 999px; color: #fff; font-size: 12px; min-height: 32px; padding: 7px 10px; }
body.discussion-mode .axis-label.top { background: #e53935; } body.discussion-mode .axis-label.bottom { background: #1e88e5; color: #1f1d1b; }
body.discussion-mode .axis-label.left { background: #fb8c00; color: #1f1d1b; } body.discussion-mode .axis-label.right { background: #2e7d32; }
body.discussion-mode .item.text-mode .item-name { border: 0; border-radius: 0; background: transparent; color: #171717; font-size: 12px; font-weight: 500; }
body.discussion-mode .item.text-large .item-name { font-size: 16px; font-weight: 900; }
body.discussion-mode .item.text-small .item-name { font-size: 10px; }
.item-subtitle { color: #555; font-size: .78em; font-weight: 500; }
@media (max-width: 760px) {
  .discussion-grid { grid-template-columns: 1fr 1fr; padding: 0 10px 10px; }
  .discussion-axis-notes { grid-template-columns: 1fr 1fr; }
  body.discussion-mode .axis-label.left, body.discussion-mode .axis-label.right { top: auto; bottom: 8px; width: auto; max-width: 42%; transform: none; }
  body.discussion-mode .axis-label.left { left: 8px; } body.discussion-mode .axis-label.right { right: 8px; }
}
@media (max-width: 760px) {
  .map, .map-panel > .map { flex: none; aspect-ratio: 10 / 12; }
  /* 軸ラベルを小さくして、項目を置ける内側を広げる（押せる高さ44pxは保つ） */
  .axis-label { font-size: 14px; padding: 10px 6px; }
  .axis-label.top, .axis-label.bottom { width: 116px; }
  .axis-label.left, .axis-label.right { width: 72px; }
  .axis.horizontal { left: calc(2px + 72px + 10px); right: calc(2px + 72px + 10px); }
}

@media (min-width: 1024px) {
  /* PCでは上部の操作を残して下軸まで見せる。画面の地図も16:11のまま、
     短い画面では最低限の高さを残してページをスクロールできるようにする。 */
  .map-panel > .map {
    justify-self: center;
    width: min(100%, max(524px, calc((100dvh - 330px) * 16 / 11)));
  }
}
.title-row strong { overflow: visible; white-space: normal; overflow-wrap: anywhere; text-align: left; }
