/* TRPG室内図メーカー
 * 観測所の共通デザイン（文字画像APNGメーカーと同じ色・ヘッダー・ボタン）に、エディター用の部品を足したもの */
:root {
  --bg: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.6);
  --field: #ffffff;
  --ink: #1f2a3a;
  --muted: #66758a;
  --line: rgba(76, 100, 132, 0.18);
  --line-strong: rgba(76, 100, 132, 0.32);
  --blue: #3a78d8;
  --blue-deep: #245bb0;
  --blue-soft: rgba(58, 120, 216, 0.1);
  --cyan: #6ad6ff;
  --accent: #e0703c;
  --accent-deep: #c4541f;
  --ok: #1f9d6b;
  --warn: #c97a00;
  --danger: #cf3d3d;
  --shadow: 0 18px 44px rgba(25, 43, 76, 0.12);
  --shadow-soft: 0 6px 18px rgba(25, 43, 76, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
}

body.is-dark {
  --bg: #07111f;
  --panel: rgba(12, 25, 43, 0.9);
  --panel-solid: #0d1b2f;
  --panel-soft: rgba(255, 255, 255, 0.04);
  --field: rgba(255, 255, 255, 0.05);
  --ink: #eef6ff;
  --muted: #9fb0c6;
  --line: rgba(168, 204, 255, 0.16);
  --line-strong: rgba(168, 204, 255, 0.3);
  --blue: #69a8ff;
  --blue-deep: #377de0;
  --blue-soft: rgba(105, 168, 255, 0.14);
  --accent: #f08a55;
  --accent-deep: #d86a33;
  --ok: #3cc98f;
  --warn: #f0b046;
  --danger: #ff7272;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(106, 214, 255, 0.2), transparent 32%),
    radial-gradient(circle at 90% 12%, rgba(58, 120, 216, 0.18), transparent 28%),
    var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h1, h2, h3, p { margin-top: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.app-header, .drawer, .editor, .legal-footer {
  width: 100%;
  max-width: 1680px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- ヘッダー ---------- */

.app-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  /* 説明文はボタン列の下まで使い、版表記と同じ行に並べてヘッダーを低くする */
  grid-template-areas: "title actions" "lead lead";
  column-gap: 1rem;
  row-gap: 0;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(235, 244, 255, 0.74));
  box-shadow: var(--shadow);
}

body.is-dark .app-header { background: linear-gradient(135deg, rgba(16, 32, 55, 0.95), rgba(9, 18, 32, 0.8)); }

.title-block { grid-area: title; min-width: 0; }

.eyebrow, .panel-kicker {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1.1;
}

.lead {
  grid-area: lead;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.6;
  font-feature-settings: "palt";
  padding-right: 11em;
}

.header-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  align-content: flex-start;
  gap: 8px;
}

.header-nav-link, .ghost-button, .x-share-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  padding: 0.38rem 0.78rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 5px 12px rgba(25, 43, 76, 0.06);
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

.header-nav-link:hover, .ghost-button:not(:disabled):hover, .x-share-link:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--blue) 58%, transparent);
  color: var(--blue-deep);
  background: var(--blue-soft);
}

body.is-dark .header-nav-link:hover, body.is-dark .ghost-button:not(:disabled):hover, body.is-dark .x-share-link:hover { color: #dfeeff; }

.x-share-link { min-width: 2.1rem; padding: 0; font-size: 1rem; }

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 2.1rem;
  padding: 0 0.5rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.lang-choice-button {
  padding: 0.25rem 0.35rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.lang-choice-button.is-active { color: var(--blue); }
.lang-divider { color: var(--line-strong); font-size: 0.78rem; }

.theme-button { min-width: 56px; padding: 0 3px; }

.theme-toggle-track {
  position: relative;
  display: block;
  width: 48px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.theme-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ffffff;
  color: #f59e0b;
  font-size: 0.72rem;
  box-shadow: 0 2px 7px rgba(25, 43, 76, 0.18);
  transition: transform .18s ease;
}

body.is-dark .theme-toggle-track { background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(30, 64, 175, 0.72)); }
body.is-dark .theme-toggle-thumb { transform: translateX(24px); background: #e2e8f0; color: #334155; }

.version-engrave {
  /* 説明文と同じ行の右端に重ね、説明文の右側に版表記ぶんの余白をとる */
  grid-row: 2;
  grid-column: 1 / -1;
  justify-self: end;
  align-self: end;
  /* 説明文の最終行と同じ高さ（line-height 1.6 × 0.93rem）に縦中央をそろえる */
  line-height: calc(0.93rem * 1.6);
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

/* ---------- ドロワー ---------- */

.drawer {
  position: relative;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.drawer h2 { margin-bottom: 12px; font-size: 1rem; }

.drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(106, 214, 255, 0.16);
  color: var(--blue);
  font-size: 1.15rem;
  font-weight: 900;
}

.guide-list, .guide-notes { display: grid; gap: 7px; }
.guide-notes { margin-top: 10px; }

.guide-list p, .guide-notes p {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  font-size: 0.84rem;
  line-height: 1.5;
}

.guide-list p { font-weight: 700; }
.guide-notes p { color: var(--muted); }

.shortcut-grid {
  display: grid;
  grid-template-columns: minmax(260px, auto) 1fr;
  gap: 7px 9px;
}

.shortcut-grid > div, .shortcut-grid > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.shortcut-grid kbd {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid rgba(106, 214, 255, 0.42);
  border-radius: 999px;
  background: rgba(106, 214, 255, 0.14);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 900;
}

.shortcut-grid b { color: var(--muted); }


/* ---------- 利用ルール ---------- */

.rules-body { display: grid; gap: 10px; font-size: 0.84rem; line-height: 1.65; }
.rules-body p { margin: 0; }
.rules-intro { font-weight: 700; }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rules-card { padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-soft); }
.rules-card h3 { margin: 0 0 6px; font-size: 0.86rem; }
.rules-card ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.rules-card li { display: grid; grid-template-columns: 1.3em minmax(0, 1fr); }
.rules-mark { font-weight: 900; }
.rules-card.is-allow h3, .rules-card.is-allow .rules-mark { color: var(--ok); }
.rules-card.is-deny h3, .rules-card.is-deny .rules-mark { color: var(--danger); }
.rules-note, .rules-where { color: var(--muted); }
.rules-credit { padding: 10px 13px; border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line)); border-radius: 13px; background: var(--blue-soft); }
.rules-credit h3 { margin: 0 0 4px; color: var(--blue-deep); font-size: 0.86rem; }
body.is-dark .rules-credit h3 { color: var(--blue); }
.rules-credit-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 7px 0; }
.rules-credit-line code { padding: 5px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); font-family: inherit; font-weight: 800; user-select: all; }
.rules-copy { min-height: 1.9rem; padding: 0.25rem 0.8rem; font-size: 0.78rem; }
.rules-where { font-size: 0.8rem; }

/* フッター・書き出しの文中にある「利用ルール」「クレジットをコピー」 */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.export-credit .link-button { margin-left: 0.6em; }

/* ---------- フィールド ---------- */

.control-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  overflow: hidden;
}

.control-section.is-off { background: transparent; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
}

.section-title { margin: 0; font-size: 0.88rem; font-weight: 900; }

.section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.field-heading {
  margin: 6px 0 -2px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 0.86rem;
  font-weight: 900;
}

.field-note {
  margin: 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-line;
}

.field-note.is-dynamic { background: color-mix(in srgb, var(--warn) 12%, transparent); }

.text-input, .select-input, .number-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.88rem;
}

textarea.text-input { resize: vertical; min-height: 60px; line-height: 1.6; }
.text-input:focus, .select-input:focus, .number-input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.select-input { padding-right: 28px; }
body.is-dark .select-input option, body.is-dark .select-input optgroup { background: #0d1b2f; color: #eef6ff; }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.number-box { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.number-box .number-input { width: 72px; min-height: 28px; padding: 3px 6px; text-align: right; font-size: 0.8rem; }
.number-suffix { color: var(--muted); font-size: 0.72rem; font-weight: 700; min-width: 1.6em; }

.range-input { width: 100%; margin: 0; accent-color: var(--blue); }

.segment-group, .chip-group { display: flex; flex-wrap: wrap; gap: 5px; }

.segment-group {
  flex-wrap: nowrap;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
}

.segment {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.segment.is-active { background: var(--blue); color: #ffffff; box-shadow: var(--shadow-soft); }

.chip {
  padding: 5px 10px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  transition: border-color .15s ease, background .15s ease;
}

.chip:hover { border-color: var(--line-strong); }
.chip.is-active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-deep); }
body.is-dark .chip.is-active { color: #dfeeff; }
.chip-group.compact .chip { padding: 3px 8px; font-size: 0.74rem; }

.toggle-field, .toggle-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.switch { position: relative; display: inline-flex; flex: none; }
.switch-input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }

.switch-track {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .15s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform .15s ease;
}

.switch-input:checked + .switch-track { background: var(--blue); }
.switch-input:checked + .switch-track::after { transform: translateX(16px); }
.switch-input:focus-visible + .switch-track { outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent); outline-offset: 2px; }
.switch-input:disabled { cursor: not-allowed; }
.switch-input:disabled + .switch-track { opacity: 0.5; }
.toggle-inline.is-disabled { color: var(--muted); cursor: not-allowed; }

.color-row { display: flex; flex-wrap: wrap; gap: 8px; }

.color-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 128px;
  padding: 5px 8px 5px 5px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  cursor: pointer;
}

.color-input {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 7px; }
.color-input::-moz-color-swatch { border: 1px solid var(--line-strong); border-radius: 7px; }
.color-meta { display: flex; flex-direction: column; line-height: 1.2; }
.color-label { color: var(--muted); font-size: 0.7rem; font-weight: 800; }
.color-hex { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.76rem; font-weight: 700; }
.color-field.is-empty .color-input { opacity: 0.25; }
.color-field.is-empty .color-hex { color: var(--muted); font-family: inherit; }

.color-clear {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
  line-height: 1;
}

.swatch-group { display: flex; flex-wrap: wrap; gap: 6px; }

.swatch {
  width: 30px;
  height: 30px;
  border: 2px solid var(--panel-solid);
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px var(--line-strong);
  transition: transform .15s ease;
}

.swatch:hover { transform: scale(1.1); }

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.mini-button:hover { border-color: var(--blue); color: var(--blue-deep); }


/* ---------- ボタン ---------- */

.primary-button, .accent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 900;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.primary-button { background: linear-gradient(135deg, var(--blue), var(--blue-deep)); box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 30%, transparent); }
.accent-button { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 32%, transparent); }
.primary-button:not(:disabled):hover, .accent-button:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.05); }
/* ナイトモードでは暗い背景に光がにじんで見えやすいので、ボタンの下の光を控えめにする */
body.is-dark .accent-button { box-shadow: 0 4px 10px color-mix(in srgb, var(--accent) 14%, transparent); }
body.is-dark .accent-button:not(:disabled):hover { filter: brightness(1.03); }

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  font-size: 1.05rem;
  font-weight: 900;
}

.icon-button:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- トースト ---------- */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.has-action { display: flex; align-items: center; gap: 12px; pointer-events: auto; }

.toast-action {
  flex: none;
  padding: 6px 12px;
  border: 1.5px solid var(--blue);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.toast-action:hover { background: var(--blue); color: #ffffff; }
body.is-dark .toast-action { color: #dfeeff; }
body.is-dark .toast-action:hover { color: #ffffff; }
.toast-success { border-left-color: var(--ok); }
.toast-warning { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--blue); }

/* ---------- フッター ---------- */

.legal-footer {
  padding: 16px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.7;
}

.legal-footer h2 { margin-bottom: 6px; color: var(--ink); font-size: 0.88rem; }
.legal-footer p { margin: 0; }
.legal-footer p + p { margin-top: 4px; }
.legal-footer a { color: var(--blue); font-weight: 800; text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }



/* ---------- エディター（3列: 素材 / キャンバス / プロパティ） ---------- */

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor {
  display: grid;
  grid-template-columns: minmax(224px, 264px) minmax(0, 1fr) minmax(250px, 292px);
  gap: 14px;
  height: clamp(560px, calc(100vh - 214px), 1400px);
}

.editor > .panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
}

.panel-kicker { margin: 0; }

/* 素材パネル */

.lib-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--field);
}

.lib-tab {
  flex: 1 1 auto;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.2;
}

.lib-tab:hover { color: var(--ink); }
.lib-tab.is-active { background: var(--blue); color: #ffffff; box-shadow: var(--shadow-soft); }

.lib-body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 10px -6px 0 0;
  padding-right: 6px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.lib-note { margin: 0 0 8px; color: var(--muted); font-size: 0.72rem; line-height: 1.5; }
.lib-section { margin: 14px 0 6px; color: var(--blue); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; }
.lib-section:first-child { margin-top: 0; }

.lib-search { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.lib-search .text-input { min-height: 32px; padding: 5px 10px; font-size: 0.82rem; }
.lib-search-row { display: flex; gap: 6px; }
.lib-search-row .text-input { flex: 1 1 auto; min-width: 0; }
.tag-select { flex: 0 1 auto; width: auto; min-width: 0; max-width: 46%; min-height: 32px; padding: 4px 8px; font-size: 0.78rem; }
.lib-search.is-sticky { position: sticky; top: 0; z-index: 2; margin: 0 0 8px; padding-bottom: 8px; background: var(--panel-solid); }
.lib-group-select { width: 100%; min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 0.78rem; }
.lib-groups { display: flex; flex-wrap: wrap; gap: 4px; }
.lib-groups .chip { padding: 2px 8px; font-size: 0.7rem; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 5px 3px 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.lib-card:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.lib-card.is-active { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 18%, transparent); }

.lib-icon {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(76, 100, 132, 0.12);
  pointer-events: none;
}

.lib-icon.is-wide { width: 58px; }

.lib-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  font-feature-settings: "palt";
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.room-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }

.room-card {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 5px 7px;
  border: 1.5px solid rgba(46, 50, 58, 0.16);
  border-radius: 11px;
  background: var(--room-color, #ffffff);
  color: #2e323a;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.room-card:hover { border-color: rgba(46, 50, 58, 0.4); }
.room-card.is-active { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 22%, transparent); }
.room-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.room-name { display: -webkit-box; overflow: hidden; font-size: 0.7rem; font-weight: 800; overflow-wrap: break-word; hyphens: auto; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.room-size { color: #5f6773; font-size: 0.62rem; font-weight: 700; }

/* キャンバスパネル */

.canvas-panel { gap: 8px; }

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.bar-group { display: inline-flex; align-items: center; gap: 6px; }
.bar-spacer { flex: 1 1 auto; }
.editor-bar .ghost-button { min-height: 2rem; padding: 0.3rem 0.72rem; gap: 5px; }
.editor-bar .primary-button, .editor-bar .accent-button { min-height: 34px; padding: 6px 14px; font-size: 0.86rem; }
.editor-bar .icon-button { width: 34px; height: 34px; font-size: 0.95rem; }
.editor-bar .segment-group { padding: 2px; }
.editor-bar .segment { padding: 5px 10px; font-size: 0.76rem; white-space: nowrap; }
/* 隠し手がかりの ON/OFF（キャンバスの右上に浮かべる） */
.clue-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 4px 8px 4px 10px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.clue-toggle:hover { border-color: var(--line-strong); }
.clue-state { padding: 1px 7px; border-radius: 999px; background: var(--line); font-size: 0.68rem; letter-spacing: 0.04em; }
.clue-toggle.is-on { border-color: color-mix(in srgb, var(--warn) 60%, transparent); color: var(--warn); }
.clue-toggle.is-on .clue-state { background: var(--warn); color: #ffffff; }
body.is-dark .clue-toggle.is-on .clue-state { color: #1b1206; }
.bar-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #ffffff;
}

.canvas-wrap.is-dropping { box-shadow: inset 0 0 0 3px var(--blue); }

#mapCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.tool-strip {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.tool-sep { height: 1px; margin: 2px 4px; background: var(--line); }

.tool-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}

.tool-button:hover { background: var(--blue-soft); color: var(--blue); }
.tool-button.is-active { background: var(--blue); color: #ffffff; box-shadow: 0 4px 10px color-mix(in srgb, var(--blue) 30%, transparent); }
.tool-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool-key { position: absolute; right: 3px; bottom: 1px; font-size: 0.5rem; font-weight: 900; opacity: 0.6; }

.canvas-hint {
  position: absolute;
  left: 58px;
  bottom: 10px;
  z-index: 2;
  max-width: calc(100% - 250px);
  margin: 0;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: var(--shadow-soft);
}

.canvas-hint:empty { display: none; }
.canvas-hint.is-warn { color: var(--warn); }

.zoom-box {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.zoom-box button {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.zoom-box button:hover { background: var(--blue-soft); color: var(--blue); }
.zoom-box svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.zoom-value { min-width: 46px !important; font-variant-numeric: tabular-nums; }

.mini-bar {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  transform: translate(-50%, -100%);
}

.mini-bar button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

.mini-bar button:hover { background: var(--blue-soft); color: var(--blue); }
.mini-bar button.is-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.mini-bar button:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; color: var(--ink); }
.mini-bar button.is-gm { color: var(--danger); }
.mini-bar button.is-on { background: var(--blue-soft); color: var(--blue); }
.mini-bar button.is-clue { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.mini-bar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.floor-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.floor-tabs { display: flex; align-items: center; gap: 4px; }

.floor-tab {
  min-width: 44px;
  padding: 5px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.floor-tab:hover { border-color: var(--line-strong); }
.floor-tab.is-active { border-color: var(--blue); background: var(--blue); color: #ffffff; }
.floor-rename { width: 90px; min-height: 30px; padding: 3px 8px; font-size: 0.8rem; }

.floor-actions { display: flex; align-items: center; gap: 2px; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--line); }

.floor-action {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.floor-action:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.floor-action.is-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.floor-action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.floor-add { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: 1.5px dashed var(--line-strong); border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.floor-add:hover { border-color: var(--blue); color: var(--blue); }

/* プロパティパネル */

.props-panel { overflow-y: auto; scrollbar-gutter: stable; }

.props-body { display: flex; flex-direction: column; gap: 11px; }
.props-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.props-title { margin: 2px 0 0; font-size: 1rem; font-weight: 900; line-height: 1.3; word-break: break-word; }
.props-sub { color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.props-head > div:first-child { min-width: 0; }
.props-tools { display: flex; flex: none; gap: 4px; align-self: flex-start; }
.props-tool { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); }
.props-tool:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.props-tool.is-on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.props-tool:disabled { opacity: 0.4; cursor: not-allowed; }
.props-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.props-panel .number-input:disabled { opacity: 0.55; cursor: not-allowed; }
.props-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.props-panel .text-input, .props-panel .select-input, .props-panel .number-input { min-height: 32px; padding: 5px 9px; font-size: 0.84rem; }
.props-panel textarea.text-input { min-height: 64px; }
.props-panel .field-note { font-size: 0.7rem; }
.props-sep { height: 1px; margin: 2px 0; background: var(--line); }

.num-wrap { position: relative; display: flex; align-items: center; }
.num-wrap .number-input { padding-right: 34px; }
.num-suffix { position: absolute; right: 9px; color: var(--muted); font-size: 0.68rem; font-weight: 800; pointer-events: none; }

.props-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.props-actions .mini-button { min-height: 30px; padding: 4px 10px; font-size: 0.74rem; }
.props-actions .is-danger:hover { border-color: var(--danger); color: var(--danger); }

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--blue-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.readout span { color: var(--muted); font-weight: 700; }

.color-line { display: flex; align-items: center; gap: 8px; }
.color-line .color-input { width: 40px; height: 30px; }
.color-line .color-field.is-empty .color-input { opacity: 0.25; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.color-swatches .swatch { width: 22px; height: 22px; }

.rot-group .segment { padding: 5px 4px; font-size: 0.74rem; }

.props-empty { display: flex; flex-direction: column; gap: 11px; }
.props-tip { margin: 0; padding: 9px 11px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 0.76rem; line-height: 1.55; }

/* ---------- モーダル ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 18, 32, 0.46);
  backdrop-filter: blur(3px);
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(1100px, 100%);
  max-height: calc(100vh - 36px);
  padding: 20px 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.modal h2 { margin: 0; font-size: 1.1rem; }
.modal-intro { margin: -4px 0 0; color: var(--muted); font-size: 0.82rem; }
.tpl-options { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.modal-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-right: 40px; }

.tpl-groups { display: flex; flex-wrap: wrap; gap: 5px; }
.tpl-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-filter .text-input { flex: 1 1 240px; min-width: 0; min-height: 34px; padding: 5px 10px; font-size: 0.84rem; }
.tpl-filter .tag-select { max-width: none; min-height: 34px; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 3px 6px; margin: 2px 2px 0; }
.tpl-tag { color: var(--muted); font-size: 0.66rem; font-weight: 700; }

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  align-content: start;
  gap: 12px;
  /* タブを切り替えても一覧の高さを変えない（画面の高さに合わせて調整し、はみ出す分はスクロール） */
  height: clamp(300px, calc(100vh - 330px), 620px);
  overflow-y: auto;
  padding: 2px 4px 4px;
}

.tpl-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--ink);
  text-align: left;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.tpl-card:hover { transform: translateY(-2px); border-color: var(--blue); box-shadow: var(--shadow-soft); }

.tpl-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(76, 100, 132, 0.14);
}

.tpl-thumb img { display: block; max-width: 100%; max-height: 100%; }
.tpl-thumb.is-blank { color: var(--muted); font-size: 2rem; font-weight: 300; }
.tpl-name { margin: 2px 2px 0; font-size: 0.9rem; font-weight: 900; line-height: 1.3; }
.tpl-meta { margin: 0 2px; color: var(--blue); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.04em; }
.tpl-desc { margin: 0 2px; color: var(--muted); font-size: 0.72rem; line-height: 1.5; font-feature-settings: "palt"; }
.tpl-foot { margin: 0; color: var(--muted); font-size: 0.74rem; }

.export-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; min-height: 0; }
.export-options { display: flex; flex-direction: column; gap: 11px; }
.export-options .segment-group { flex-wrap: wrap; }
.export-options .segment { flex: 1 1 auto; font-size: 0.76rem; }

.export-preview {
  display: grid;
  place-items: center;
  min-height: 300px;
  max-height: min(64vh, 640px);
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: #dfe4ec;
  background-image: linear-gradient(45deg, #f6f8fb 25%, transparent 25%), linear-gradient(-45deg, #f6f8fb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f6f8fb 75%), linear-gradient(-45deg, transparent 75%, #f6f8fb 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.export-preview img { display: block; max-width: 100%; max-height: calc(min(64vh, 640px) - 24px); box-shadow: var(--shadow-soft); }
.export-info { margin: 0; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

/* ---------- レスポンシブ ---------- */

@media (max-width: 1480px) {
  .editor { grid-template-columns: 228px minmax(0, 1fr) 256px; }
}

@media (max-width: 1240px) {
  .editor { grid-template-columns: 236px minmax(0, 1fr); height: auto; }
  .editor > .library-panel { height: clamp(520px, calc(100vh - 214px), 1100px); }
  .editor > .canvas-panel { height: clamp(520px, calc(100vh - 214px), 1100px); }
  .props-panel { grid-column: 1 / -1; overflow: visible; }
  .props-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-items: start; }
  .props-body > .props-head, .props-body > .props-actions, .props-body > .props-sep { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .app-shell { padding: 10px; gap: 10px; }
  .app-header { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "lead" "actions"; row-gap: 10px; padding: 16px 16px 28px; }
  .header-actions { justify-content: flex-start; }
  .lead { padding-right: 0; }
  .version-engrave { position: absolute; right: 16px; bottom: 6px; }
  .rules-grid { grid-template-columns: 1fr; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor > .canvas-panel { order: -1; height: 72vh; min-height: 440px; }
  .editor > .library-panel { height: 380px; }
  .canvas-hint { display: none; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .export-layout { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 16px; }
}

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