@import url('https://fonts.googleapis.com/css2?family=M+PLUS+1p:wght@400;500;700&family=Noto+Serif+JP:wght@400;500;700&display=swap');

:root {
  --font-sans:
    'M PLUS 1p', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', 'YuGothic', Meiryo, sans-serif;

  --font-serif:
    'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'MS PMincho', serif;
}

html,
body {
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

* {
  margin: 0;
  padding: 0;
  color: #333;
}

html.no-scroll,
body.no-scroll {
  overflow: hidden;
  height: 100%;
}

body.no-scroll {
  position: fixed;
  width: 100%;
}

.editor-backdrop {
  pointer-events: none;
}
.editor-backdrop.is-open {
  pointer-events: auto;
}

body {
  height: 100vh;
  position: relative;
}

.logoWrap {
  text-align: left;
}

.logo {
  margin: 40px;
  width: 55px;
}

#contents {
  background: url(../img/step_bg.png) left top/cover no-repeat;
}

#contents:not(.d_page) p.alert,
#contents:not(.d_page) form {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
#contents:not(.d_page) form {
  display: flex;
  flex-direction: column;
  max-width: 300px;
}
#contents form button:not(.link-toggle) {
  margin-top: 20px;
}
#contents:not(.d_page) p.alert {
  color: #ff0004;
  font-size: 1em;
  font-weight: bold;
}

.file-input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#contents form button:not(.link-toggle),
.file-label {
  background-color: #222222;
  color: #fff;
  width: 300px;
  height: 70px;
  line-height: 70px;
  cursor: pointer;
  text-align: center;
  display: inline-block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #222;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.12);
}

#contents form button#startSimBtn:not(.link-toggle) {
  padding-left: 40px;
}

#contents#contents form button:not(.link-toggle):hover,
.file-label:hover {
  background-color: #fff;
  color: #222;
  border: 1px solid #ddd;
}

#contents#contents form button:not(.link-toggle):before,
.file-label:before {
  content: '';
  display: inline-block;
  width: 50px;
  height: 48px;
  position: absolute;
  left: 20px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
  background-position: left center;
  background-size: contain;
  background-repeat: no-repeat;
}

.file-label:before {
  background-image: url(../img/icon_camera_wht.png);
}

#contents form button#input-size:not(.link-toggle):before {
  background-image: url(../img/icon_meajur_wht.png);
}

#contents form button#startSimBtn:not(.link-toggle):before {
  background-image: url(../img/icon_simulation_wht.png);
  width: 46px;
  height: 36px;
}

.file-label:hover:before {
  background-image: url(../img/icon_camera_blk.png);
}

#contents#contents:not(.d_page) form button#input-size:hover:before {
  background-image: url(../img/icon_meajur_blk.png);
}

#contents form button#startSimBtn:not(.link-toggle):hover:before {
  background-image: url(../img/icon_simulation_blk.png);
}

.icon-wrapper {
  text-align: center;
  margin-bottom: 20px;
}

h1.mail-ttl {
  font-family: var(--font-serif);
  color: #fff;
  margin-bottom: 30px;
  font-weight: 500;
  margin-left: -20px;
  margin-right: -20px;
  text-align: center;
  letter-spacing: 5px;
}

p.copy {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 12px;
  font-family: var(--font-serif);
  text-align: center;
  letter-spacing: 1px;
}

#contents p.txt {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
}

.file-name {
  margin-top: 10px;
  color: #333;
  font-size: 14px;
}

.image-preview {
  width: 298px;
  height: 298px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  text-align: center;
  background: #f5f5f5;
  border: 1px solid #dddddd;
}
.image-preview img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

#imageInput {
  display: none;
}

.back-to-index-btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  text-align: center;
  position: absolute;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
}
.back-to-index-btn:hover {
  background-color: #0056b3;
}

.size-form {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 320px;
  width: 90%;
  display: grid;
  gap: 2px;
}
.size-inputs {
  display: grid;
  gap: 8px;
}
.size-inputs label {
  display: grid;
  gap: 0px;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}
.size-inputs input[type='number'] {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
}
.size-alert {
  color: #c00;
  font-size: 14px;
  font-weight: 700;
}

.size-form .image-preview {
  margin-bottom: 5px;
}

.size-form button {
  margin-top: 6px !important;
}

.size-form p.txt {
  margin-top: 3px;
}

/* ===== 右上クイックメニュー ===== */
.quick-menu {
  position: fixed;
  top: 20px;
  right: 0;
  z-index: 10050; /* 各種UIより前面 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  pointer-events: auto;
}

/* 共通アイテム枠 */
.qm-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 69px; /* 指定 */
  height: 67px; /* 指定（ハンバーガーの縦） */
  padding: 6px 4px;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.qm-item.soudan {
  margin-top: -8px;
}

.qm-item.soudan .qm-label {
  margin-top: 6px;
}

/* ラベル（画像の下） */
.qm-label {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #333;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}

/* アイコン画像ボックス */
.qm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  opacity: 0.7;
}
.qm-icon img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* モバイルでの干渉回避（右下ズームUIと重ならないように） */
@media (max-width: 768px) {
  .quick-menu {
    gap: 13px;
  }
  .qm-item.scene {
    margin-top: -5px;
  }
  .qm-item {
    width: 55px;
    height: 54px;
    margin-right: 3px;
  }
  .qm-label {
    font-size: 10px;
    margin-top: 6px;
  }
}

/* ===== モーダル共通 ===== */
.qm-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* hidden のときだけ消す（最優先） */
.qm-modal[hidden] {
  display: none !important;
}

.qm-modal-inner {
  position: relative;
  inset: 0;
  padding: 48px 20px;
  color: #fff;
  max-width: min(500px, 96vw);
  width: 100%;
}

.qm-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  background: #303435;
  border: none;
  cursor: pointer;
  width: 64px;
  height: 64px;
  z-index: 99999;
}

.qm-modal-close::before,
.qm-modal-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 1px;
  background: #fff;
  transform-origin: center;
}

.qm-modal-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.qm-modal-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.qm-modal .btnWrap {
  text-align: center;
}

.qm-modal .p-button {
  width: 200px;
  height: 50px;
  background: #303435;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.qm-modal .p-button:hover {
  color: #303435;
  background: #fff;
  border: 1px solid #ddd;
  outline: none;
}

.qm-modal .n-button {
  color: #888;
  font-size: 16px;
  font-weight: 600;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.qm-modal .n-button:hover {
  opacity: 0.75;
}

/* ===== ペイン ===== */

.qm-pane {
  width: 100%;
  margin: 0;
}

.qm-save-pane--list {
  max-height: calc(100vh - 200px);
  overflow: auto;
}

.qm-pane-ttl {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 2px;
  margin: 0 0 25px;
  color: #303435;
  border-bottom: 1px solid #ccc;
  padding-bottom: 3px;
  position: relative;
}

.qm-pane-ttl small {
  display: inline-block;
  position: absolute;
  right: 0;
  top: 3px;
  font-weight: normal;
  font-size: 0.7;
}

.qm-pane-sub-ttl {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 5px;
}

.qm-menu-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.qm-menu-list li {
  margin: 0 0 12px;
}

.qm-pane textarea::placeholder,
.qm-pane input::placeholder {
  color: #888;
}

.qm-pane .ast {
  line-height: 1.1;
}

/* ===== 金額計算UI ===== */

.qm-kingaku ul {
  margin-bottom: 20px;
}

.qm-kingaku ul li {
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 6px 0;
  border-bottom: 1px solid #ccc;
}

.qm-kingaku ul li span {
  font-size: 18px;
  color: #888;
}

.qm-kingaku-total {
  margin-bottom: 10px;
}

.qm-kingaku-total small {
  font-weight: 400;
}

.qm-kingaku-note--shipping {
  margin-top: -5px;
}

.qm-kingaku-total #kingakuTotal {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

.qm-kingaku-note {
  margin-top: 10px;
  color: #a33;
}

/* ===== 保存UI ===== */
.qm-save-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.qm-save-tab {
  background: #555;
  color: #fff;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
}
.qm-save-tab.is-active {
  background: #777;
}

.qm-save-label {
  display: block;
  margin-bottom: 12px;
}
.qm-save-label input {
  width: min(520px, 100%);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #666;
  background: #222;
  color: #fff;
}

.qm-save-actions {
  margin-bottom: 8px;
}
.qm-save-actions .qm-save-do {
  background: #08c;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.qm-save-note {
  opacity: 0.75;
  margin-bottom: 16px;
}

.qm-save-table {
  width: 100%;
  border-collapse: collapse;
  background: #222;
}
.qm-save-table th,
.qm-save-table td {
  border: 1px solid #555;
  padding: 8px;
}
.qm-save-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.qm-copy-input {
  width: min(420px, 100%);
  background: #111;
  color: #fff;
  border: 1px solid #555;
  padding: 6px;
}
.qm-save-empty {
  margin: 8px 0 0;
}

#qmPaneSoudan textarea,
#qmPaneSoudan input[type='email'],
#qmPaneSoudan input[type='text'],
#qmPaneSave input[type='text'] {
  width: 100%;
  font-size: 18px;
  padding: 12px;
  color: #303435;
  background: #f5f5f5;
  border: 1px solid #cccccc;
  border-radius: 0;
  margin-bottom: 20px;
  box-sizing: border-box;
}

#qmPaneSoudan textarea {
  min-height: 200px;
}

#qmSoudanSavedTableWrap,
.qm-save-pane--list {
  max-height: 250px;
  overflow-y: auto;
  scrollbar-color: #90b3ad #f5f5f5;
  scrollbar-width: thin;
  background: #f5f5f5;
  padding-left: 8px;
  padding-right: 8px;
}

#qmSoudanSavedTableWrap #qmSoudanSavedTable,
.qm-save-pane--list .qm-saved-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

#qmSoudanSavedTableWrap #qmSoudanSavedTable thead,
.qm-save-pane--list .qm-saved-table thead {
  display: none;
}

.qm-save-pane--list .u-button {
  display: none;
}
.qm-save-pane--list .d-button {
  background: none;
  border: none;
  outline: none;
  vertical-align: middle;
}

#qmSoudanSavedTableWrap #qmSoudanSavedTable td,
.qm-save-pane--list .qm-saved-table td {
  text-align: center;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}

#qmSoudanSavedTableWrap #qmSoudanSavedTable td.qm-saved-td-name,
.qm-save-pane--list .qm-saved-table td.qm-saved-td-name {
  text-align: left;
  width: 80%;
  line-height: 1.4;
}

#qmSoudanSavedTableWrap #qmSoudanSavedTable td.qm-saved-td-name a,
.qm-save-pane--list .qm-saved-table td.qm-saved-td-name a {
  color: #90b3ad;
  text-decoration: none;
}

#qmSoudanSavedTableWrap,
.qm-pane--saved {
  margin-top: 10px;
  margin-bottom: 20px;
}

.qm-saved-td-date {
  font-size: 90%;
  color: #888;
}

td.qm-soudan-td-check {
  padding: 6px 0 !important;
}

/* 相談一覧のチェックボックスをオリジナル化 */
.qm-soudan-td-check input[type='checkbox'] {
  -webkit-appearance: none;
  appearance: none;
  width: 35px;
  height: 35px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 2px;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  margin: 0;
  position: relative;
}

/* チェック時のマーク（#90b3ad、少し太め） */
.qm-soudan-td-check input[type='checkbox']::after {
  content: '';
  width: 10px;
  height: 18px;
  border-right: 4px solid #90b3ad;
  border-bottom: 4px solid #90b3ad;
  transform: rotate(45deg);
  opacity: 0;
  /* ちょい中央寄せ微調整 */
  margin-top: -2px;
}

/* checked で表示 */
.qm-soudan-td-check input[type='checkbox']:checked::after {
  opacity: 1;
}

.qm-pane--notice .qm-notice-center {
  text-align: center;
}

.qm-notice-text {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 5px solid #cc0000;
  padding: 20px;
  background: #fff;
}

/* --- ディスプレイコンテンツ--- */

:root {
  --honsi-border-color: #8c8d8e;
}

.jiku-wrapper {
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 90vh;
  background: #f3f4f5;
  display: inline-block;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.3);
}

.chumawasi {
  position: relative;
  top: 52%;
  transform: translateY(-48%);
  background: #e1e2e3;
  display: inline-block;
  z-index: 7;
  /*box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.3);*/
}

.honsi {
  --honsi-padding-y: 20px;
  height: auto;
  max-height: 60vh;
  width: auto;
  max-width: 60vw;
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent; /* 台紙色は .honsi-wrap 側に任せる */
}

.honsi-wrap {
  position: relative;
  vertical-align: top;
  width: auto !important;
  height: auto !important;
  overflow: visible;
  display: flow-root;
  padding: 0 !important;
  background-color: #8c8d8e;
  background-clip: padding-box;
  box-sizing: content-box;
}

.honsi-wrap.is-sunken {
  padding: 2px !important;
}

.ichimonji {
  position: relative;
  display: block;
  margin: 0 !important;
  width: 100%;
  height: auto;
  background-color: #8c8d8e; /* ★ デフォルト色 */
  background-repeat: repeat !important;
  background-position: center top !important;
  background-size: min(1000px, 100%) auto !important;
  /* 一文字の上下余白（= これまでの honsi 上下マージンの役割） */
  --ichimonji-padding-y: 20px; /* 初期値はお好みで */
  padding-block: var(--ichimonji-padding-y);
  /* マージン折り畳み対策（BFC） */
  display: flow-root;
  box-sizing: border-box;
}

:root {
  --fuutai-w: 5.2%;
  --fuutai-max: 22px;
}

.fuutai {
  display: inline-block;
  width: var(--fuutai-w);
  max-width: var(--fuutai-max);
  height: 50%;
  background: #babbbc;
  /*box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.3);*/
}

.fuutai.left {
  position: absolute;
  top: 0;
  left: 30%;
}

.fuutai.right {
  position: absolute;
  top: 0;
  right: 30%;
}

/* ===== Fuutai: Sunken mode (割合配置) ===== */
.fuutai.is-sunken {
  position: absolute; /* 親はそのまま寸法だけ使う */
  background: none !important; /* 背景は子へ（CSS変数） */
}

/* 子の細帯（親幅の1/4を左右外側へ） */
.fuutai .sink {
  position: absolute;
  top: 0;
  height: 100%;
  width: 25%; /* 細帯幅 = 親幅の1/4（ズームで自然追従） */
  pointer-events: none;
  background-image: var(--fu-bg, none);
  background-color: var(--fu-bgcolor, #babbbc);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

/* 左右の外側位置（親の外側に並べる） */
.fuutai .sink.before {
  left: -25%;
} /* 親の左外 */
.fuutai .sink.after {
  left: 100%;
} /* 親の右外 */

.jikusen {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #e1e2e3;
  width: calc(var(--fuutai-w) / 3);
  max-width: 10px;
  z-index: 6;
  background-repeat: repeat;
  background-position: center top;
  background-size: min(300px, 200px) auto !important;
}

.jikusen.left {
  left: calc(var(--fuutai-w) - (var(--fuutai-w) / 3));
}

.jikusen.right {
  right: calc(var(--fuutai-w) - (var(--fuutai-w) / 3));
}

.jikubottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 5;
  height: 0;
}

.jikubottom::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(
      to top,
      rgba(34, 34, 34, 0.18) 0%,
      rgba(34, 34, 34, 0.06) 60%,
      rgba(34, 34, 34, 0) 80%,
      rgba(34, 34, 34, 0.08) 100%
    ),
    linear-gradient(
      90deg,
      rgba(34, 34, 34, 0.05) 0%,
      rgba(34, 34, 34, 0) 22%,
      rgba(34, 34, 34, 0) 78%,
      rgba(34, 34, 34, 0.05) 100%
    );
}

.jikusaki {
  position: absolute;
  background: #777879;
  height: 0;
  width: 0;
  z-index: 6;
  pointer-events: none;
}

.jikusaki.left {
  transform: rotate(-90deg) scaleX(-1) !important;
  transform-origin: center center;
}

.edit-icon {
  position: fixed;
  top: 50%;
  left: 0; /* ← 左端ぴったり */
  transform: translateY(-50%);
  z-index: 10005;

  width: 48px;
  height: 170px;
  background: #222;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  box-sizing: border-box;

  /* 中の span を絶対配置で扱うので相対基準に */
  position: fixed;
}

/* 文字（縦書き）を “箱の中心” に厳密配置 */
.edit-icon > span {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #fff;

  /* iOS の視覚センター補正：少しだけ左に寄せる */
  --glyph-nudge: 0px;
  transform: translate(calc(-50% - var(--glyph-nudge)), -50%);

  /* 縦書き設定 */
  writing-mode: vertical-rl;
  text-orientation: upright;

  /* 余計なズレ対策 */
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  font-kerning: none;
  font-variant-east-asian: proportional-width;
  font-feature-settings: 'palt' 1;
  pointer-events: none; /* タップ判定は親に任せる */
}

.edit-icon:hover {
  background: #eee;
}

.edit-icon:hover span {
  color: #222 !important;
}

.edit-icon.is-hidden {
  opacity: 0;
  transform: translateY(-50%);
  pointer-events: none;
}

.size-info-wrap {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 9999;
}

.size-info {
  font-size: 12px;
  color: #333;
  background: rgba(255, 255, 255, 0.85);
  padding: 6px 8px;
  border-radius: 4px;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  display: inline-block;
}

.color-ast {
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.4;
}

/* ラベル全体のクリックでON/OFF */
.daisi-check {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  user-select: none;
  margin-top: 15px;
  margin-bottom: 15px;
}

/* テキスト */
.daisi-check .daisi-text {
  line-height: 1.4;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

/* ネイティブUIは視覚的に隠す（アクセシビリティは維持） */
.daisi-check input[type='checkbox'] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* チェックボックスの見た目（正方形） */
.daisi-check .daisi-box {
  display: inline-block;
  box-sizing: border-box;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  position: relative;
  /* 2行分の正方形（lh対応ブラウザ優先） */
  inline-size: 1.6em;
  block-size: 1.6em; /* フォールバック */
}
@supports (block-size: 2lh) {
  .daisi-check .daisi-box {
    inline-size: 1.6lh;
    block-size: 1.6lh;
  }
}

/* キーボードフォーカス可視化 */
.daisi-check input[type='checkbox']:focus-visible + .daisi-box {
  outline: 3px solid rgba(0, 0, 0, 0.25);
  outline-offset: 3px;
}

/* チェックマーク（緑 #90b3ad） */
.daisi-check .daisi-box::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  /* V字を border で作る */
  width: 40%;
  height: 65%;
  border-right: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(45deg) translateY(-5%);
  opacity: 0;
  transition: opacity 0.12s ease-out;
  top: -4px;
}

.daisi-check input[type='checkbox']:checked + .daisi-box::after {
  border-color: #90b3ad;
  opacity: 1;
}

/* disabled想定（必要なら） */
.daisi-check input[type='checkbox']:disabled + .daisi-box {
  border-color: #ccc;
  background: #f5f5f5;
}
.daisi-check input[type='checkbox']:disabled ~ .daisi-text {
  color: #999;
}

body.flat-mode .editor-heading:has(+ .e_honsi),
body.flat-mode .e_honsi {
  display: none !important;
}

body.flat-mode .honsi-wrap.is-sunken {
  padding: 0 !important;
}

#daisi.honsi {
  box-sizing: content-box;
  position: relative;
  background: #fff;
  padding: 0; /* ← 初期20pxを無効化 */
  max-width: 60vw;
  max-height: 60vh;
}

/* ★ display.php では作品サイズは“画像に任せる”（ゼロ固定にしない） */
#daisi .art-box {
  position: relative;
  display: inline-block; /* 画像サイズに追従 */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

/* 画像は自然寸法。必要なら親幅に収まるよう max-width だけ掛ける */
#daisi .art-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 枠線はオーバーレイ（内容サイズを変えず、上下の食い込み回避） */
#daisi .daisi-border {
  position: absolute;
  inset: 0;
  border: 1px solid #dddddd;
  pointer-events: none;
  transform: translateZ(0);
}

/* ===== エディタ共通 ===== */
.editor-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  display: none;
  z-index: 10010;
}
.editor-backdrop.is-open {
  display: block;
}

:root {
  --editor-btn-h: 42px;
}

.style-editor {
  position: fixed;
  top: 0;
  left: 0;
  width: 210px;
  height: 100svh; /* 可視ビューポート */
  height: 100dvh; /* 対応ブラウザでは dvh が優先 */
  min-height: -webkit-fill-available; /* iOS保険 */
  background: rgba(238, 238, 238, 0.75);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 10030;
  padding-bottom: calc(
    var(--editor-btn-h, 44px) + 12px + max(8px, env(safe-area-inset-bottom)) + var(--vv-bottom)
  );
}
.style-editor.is-open {
  transform: translateX(0);
}

.style-editor .editor-heading {
  margin: 0;
  padding: 12px 36px 12px 16px;
  background-color: #323334;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-align: left;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.style-editor .editor-heading:focus,
.style-editor .editor-heading:focus-visible {
  outline: none;
}

.style-editor .editor-heading:active {
  background: #323334;
}

.style-editor .editor-heading::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  transform: translateY(-80%) rotate(45deg);
  transition: transform 0.3s ease;
}

.style-editor .editor-heading.is-open::after {
  transform: translateY(-30%) rotate(-135deg);
}

.style-editor .editor-body + .editor-heading {
  margin-top: 2px;
}

/* ===============================
   style-editor ボタンの新デザイン
   =============================== */
.style-editor .editor-btn {
  position: relative;
  width: 100%;
  height: 42px;
  background: #fff !important;
  color: #222 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 42px 0 10px;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  border: 1px solid #fff;
}

.style-editor .editor-btn::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px;
  height: 19px;
  background: #90b3ad;
  border-radius: 50%;
  pointer-events: none;
}

.style-editor .editor-btn::before {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #fff;
  pointer-events: none;
  z-index: 1;
}

.style-editor .editor-btn:hover,
.style-editor .editor-btn:focus {
  border-color: #90b3ad !important;
  outline: none;
}

.style-editor .editor-btn.editor-btn-nashi_2,
.style-editor .editor-btn.editor-btn-nashi {
  background: #aaa;
}

.style-editor .editor-btn.editor-btn-nashi_2:hover,
.style-editor .editor-btn.editor-btn-nashi:hover {
  background: #999;
}

.style-editor .editor-backlink {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 70px;
  z-index: 10060;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  background: transparent;
  color: #333;
  text-decoration: none;
  box-sizing: border-box;
}

.style-editor .editor-backlink:hover {
  opacity: 0.75;
}
.style-editor .editor-backlink .icon {
  width: 0.8em;
  height: 0.8em;
  pointer-events: none;
}
.style-editor .editor-backlink span {
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.style-editor .editor-backlink_d {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid #aaa;
  color: #333;
  text-decoration: none;
  box-sizing: border-box;
  pointer-events: auto;
  touch-action: manipulation;
}

.style-editor .editor-backlink_d:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: #90b3ad;
}
.style-editor .editor-backlink_d .icon {
  width: 0.8em;
  height: 0.8em;
  pointer-events: none;
}
.style-editor .editor-backlink_d span {
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

/* ===============================
   layout-editor
   =============================== */

.layout-editor {
  position: fixed;
  top: 0;
  left: 0;
  width: 420px;
  height: 100vh;
  background: rgba(144, 179, 173, 0.75);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 10020;
  visibility: hidden;
  padding: 67px 64px 20px 20px;
  box-sizing: border-box;
}

/* 追加：リンク（連動）トグルの見た目 */
.layout-editor .link-toggle {
  position: absolute;
  right: -42px;
  width: 36px;
  height: 54px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: contain;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease;
  z-index: 2;
  background-color: transparent;
  border: none;
  top: 62px;
}

/* パネルごとの個別配置は JS で top を算出して当てる */

.layout-editor .editor-body h3 {
  font-size: 20px;
  font-weight: normal;
  margin-bottom: 20px;
}

.layout-editor.is-open {
  transform: translateX(210px);
  visibility: visible;
}

.editor-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 70px;
  height: 70px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.editor-close::before,
.editor-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 1px;
  background: #fff;
  transform-origin: center;
}
.editor-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.editor-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.style-editor,
.layout-editor {
  will-change: transform;
}

/* ====== レンジUI ====== */
.margin-editor {
  width: 100%;
}

.me-title {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
  color: #000;
}

.margin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  margin-bottom: 16px;
}

.margin-row label {
  width: 1em;
  font-size: 20px;
  color: #fff;
  text-align: center;
}

.me-range {
  flex: 1 1 auto;
  height: 26px;
  -webkit-appearance: none;
  appearance: none;
  background: #fff;
  border: 1px solid #c9c9c9;
  outline: none;
}

.me-range::-webkit-slider-runnable-track {
  height: 26px;
  background: #fff;
  border: none;
}
.me-range::-moz-range-track {
  height: 26px;
  background: #fff;
  border: none;
  border-radius: 4px;
}

:root {
  --thumb-line-inset-y: 8px; /* 上下余白（大きいほど線が短く） */
  --thumb-line-inset-x: 7px; /* 左右の位置 */
  --thumb-line-thickness: 1px; /* 線の太さ */
}

.me-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 26px;
  background: #323334;
  border: none;
  position: relative;
  cursor: pointer;
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size:
    var(--thumb-line-thickness) calc(100% - (var(--thumb-line-inset-y) * 2)),
    var(--thumb-line-thickness) calc(100% - (var(--thumb-line-inset-y) * 2));
  background-position:
    var(--thumb-line-inset-x) var(--thumb-line-inset-y),
    calc(100% - var(--thumb-line-inset-x)) var(--thumb-line-inset-y);
  background-repeat: no-repeat;
}

.me-range::-moz-range-thumb {
  width: 18px;
  height: 26px;
  background: #000;
  border: none;
  cursor: pointer;
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size:
    var(--thumb-line-thickness) calc(100% - (var(--thumb-line-inset-y) * 2)),
    var(--thumb-line-thickness) calc(100% - (var(--thumb-line-inset-y) * 2));
  background-position:
    var(--thumb-line-inset-x) var(--thumb-line-inset-y),
    calc(100% - var(--thumb-line-inset-x)) var(--thumb-line-inset-y);
  background-repeat: no-repeat;
}

.me-input {
  width: 54px;
  height: 26px;
  font-size: 16px;
  text-align: center;
  border: 1px solid #c9c9c9;
  background: #fff;
  outline: none;
}
.margin-row span {
  color: #fff;
  font-size: 20px;
}

.me-alert {
  margin-top: 8px;
  color: #c00;
  font-weight: 700;
  font-size: 14px;
}

:root {
  --vv-bottom: 0px;
}

#zoomist.zoomist-container {
  position: relative;
  width: 100%;
  height: 100svh;
  height: 100dvh;
  min-height: -webkit-fill-available;
}

#zoomist .zoomist-wrapper,
#zoomist .zoomist-image {
  width: 100%;
  height: 100%;
  background: #fff;
}

#zoomist .zoomist-image {
  position: relative;
}

#zoomist .zoomist-zoomer {
  position: fixed;
  top: initial;
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(
    max(8px, env(safe-area-inset-bottom)) + var(--vv-bottom) + var(--sliderBoxH, 220px) + 12px
  );
  z-index: 121;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.zoomist-zoomer,
.zoomist-zoomer-button {
  touch-action: manipulation;
}

.zoomist-zoomer-button {
  background: #eee !important;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#zoomSliderBox,
#zoomSliderMount,
#zoomSliderMount .zoomist-slider,
#zoomSliderMount .zoomist-slider__track,
#zoomSliderMount .zoomist-slider__thumb {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@supports (bottom: constant(safe-area-inset-bottom)) {
  #zoomSliderBox {
    right: max(8px, constant(safe-area-inset-right));
    bottom: calc(max(8px, constant(safe-area-inset-bottom)) + var(--vv-bottom));
  }
  #zoomist .zoomist-zoomer {
    right: max(8px, constant(safe-area-inset-right));
    bottom: calc(
      max(8px, constant(safe-area-inset-bottom)) + var(--vv-bottom) + var(--sliderBoxH) + 12px
    );
  }
}

#zoomSliderBox {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--vv-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.35);
  padding: 8px 14px 8px;
  width: 44px;
  box-sizing: border-box;
}

#zoomPercent {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12px;
  color: #333;
  min-width: 4ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  margin-bottom: 10px;
}

#zoomSliderMount .zoomist-slider {
  height: 200px;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#zoomSliderMount .zoomist-slider-bar {
  width: 1px;
  height: 100%;
  margin: 0 auto;
  border-radius: 8px;
  background-color: #ddd;
}

.zoomist-slider-vertical .zoomist-slider-wrapper {
  background: none;
}

#zoomSliderMount .zoomist-slider-button {
  width: 26px;
  height: 26px;
}

#zoomSliderMount .zoomist-slider-button::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.25);
  left: -11px;
}

#zoomSliderMount {
  --zoomist-slider-padding-y: 0 !important;
  --zoomist-slider-padding-x: 0 !important;
  --zoomist-slider-bar-size: 200px !important;
  --zoomist-slider-bar-side: 4px !important;
  --zoomist-slider-bar-border-radius: 8px !important;
  --zoomist-slider-button-size: 26px !important;
}

#zoomSliderMount .zoomist-slider {
  padding: 0 !important;
  height: var(--zoomist-slider-bar-size) !important;
}

#zoomSliderMount .zoomist-slider__track {
  height: 100% !important;
  width: var(--zoomist-slider-bar-side) !important;
  margin: 0 auto !important;
  border-radius: var(--zoomist-slider-bar-border-radius) !important;
}

#zoomPercent {
  min-width: 4ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

#zoomSliderBox {
  width: 48px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ---- Common palette layout (vertical single column) ---- */
.editor-palette {
  display: grid;
  grid-template-columns: 1fr; /* vertical list */
  gap: 5px;
  align-items: stretch;
}

.editor-palette .palette-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
}

/* ---- Common palette item ---- */
.palette-item {
  display: block;
  width: 100%;
  height: 66px; /* height can be synced by JS */
  box-sizing: border-box;
  border: 1px solid #bbb;
  background-color: #f7f7f7;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.palette-item::after {
  content: '';
  font-size: 14px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background: rgba(34, 34, 34, 0.5);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  letter-spacing: 0.5px;
}
.palette-item:hover::after,
.palette-item.is-selected::after {
  opacity: 1;
}
.palette-item.is-selected::after {
  content: '選択中';
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  padding-bottom: 8px;
  z-index: 1;
}

.sub-body:not(.e_jikusaki)
  .palette-item.is-selected:not(.upload_item)[data-kiji-name]:not([data-kiji-name=''])::before {
  content: attr(data-kiji-name);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13px;
  text-align: center;
  font-size: 11px;
  color: #ffffff;
  line-height: 1.2;
  z-index: 2;
}

.palette-item.upload_item.is-selected::before {
  content: '';
}
.e_jikusaki .palette-item.is-selected::after,
.palette-item.upload_item.is-selected::after {
  padding-bottom: 0;
}
.editor-palette .coming-soon {
  font-size: 90%;
  padding-left: 12px;
  color: #666;
}

.style-editor .editor-heading {
  cursor: pointer;
  user-select: none;
}

/* ---- style-editor アコーディオン：高さアニメ専用に上書き（最下部に置く） ---- */
.style-editor .editor-heading + .editor-body {
  display: block !important; /* ← display切り替えは使わない */
}

.style-editor .editor-body {
  height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  padding-right: 5px;
  padding-left: 5px;
  opacity: 0;
  transition:
    height 0.32s cubic-bezier(0.35, 0.1, 0.15, 1),
    padding 0.32s cubic-bezier(0.35, 0.1, 0.15, 1),
    opacity 0.24s ease-out;
  will-change: height;
}

.style-editor {
  --acc-open-pad-y: 5px;
}

.style-editor .editor-body.is-open {
  padding-top: var(--acc-open-pad-y);
  padding-bottom: var(--acc-open-pad-y);
  opacity: 1;
}

/* セグメント：ベース */
.seg-radio {
  width: 100%;
}

/* アイテムコンテナはグリッド */
.seg-radio .seg-items {
  display: grid;
  grid-auto-rows: 42px; /* ボタン高さを揃える */
  width: 100%;
  margin-bottom: 5px;
}

/* 2カラム：50%／gap 10px */
.seg-radio .seg-items.cols-2 {
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

/* 3カラム：33.333%／gap 8px */
.seg-radio .seg-items.cols-3 {
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

/* ボタン本体（非選択=濃、選択=明） */
.seg-radio .seg-item {
  /* 幅はグリッドに委ねる */
  width: 100%;
  height: 100%;
  padding: 0 14px;
  background: #acacac;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  border: none !important;
}

.seg-radio .seg-item.is-active {
  background: #fff; /* 選択（明） */
  color: #333;
  border: solid 1px #90b3ad !important;
}

/* セクション OFF（is-off or data-on="0"）のとき、seg-radio 以外は常に隠す */
.style-editor .editor-body.is-off > *:not(.seg-radio),
.style-editor .editor-body[data-on='0'] > *:not(.seg-radio) {
  display: none !important;
  visibility: hidden !important;
}

/* お好みでホバー（任意） */
.seg-radio .seg-item:not(.is-active):hover {
  filter: brightness(1.05);
}

.style-editor .e_jikusen .editor-palette {
  gap: 0;
}

/* 既存のON/OFF系ボタンは見た目から隠す（裏でclickだけ使う） */
.style-editor .editor-btn-nashi,
.style-editor .editor-btn-nashi_2,
.style-editor .editor-btn-nashi-variant,
.style-editor .editor-btn-on,
.style-editor .editor-btn-off {
  display: none !important;
}

/* 軸線：線調整ボタンのベース見た目（背景なし、常に下線） */
.style-editor
  .editor-body.e_jikusen
  :is(
    .editor-btn-hosomincho2mm,
    .editor-btn-hosomincho5mm,
    .editor-btn-hosomincho5mm_2,
    .editor-btn-futomincho10mm,
    .editor-btn-futomincho10mm_2
  ) {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid #acacac !important;
  color: #333;
  box-shadow: none;
}

/* 「選択中」だけ背景 #FFF */
.style-editor
  .editor-body.e_jikusen
  :is(
    .editor-btn-hosomincho2mm,
    .editor-btn-hosomincho5mm,
    .editor-btn-hosomincho5mm_2,
    .editor-btn-futomincho10mm,
    .editor-btn-futomincho10mm_2
  ).is-selected {
  background: #fff !important;
  border-bottom: solid 1px #90b3ad !important;
}

/* 指定：futomincho10mm だけボーダーボトム無し（_2 は除外） */
.style-editor .editor-body.e_jikusen .editor-btn-futomincho10mm_2 {
  border-bottom: none !important;
  margin-bottom: 5px;
}

/* 軸線ボタンの疑似要素を完全に無効化 */
.style-editor
  .editor-body.e_jikusen
  :is(
    .editor-btn-hosomincho2mm,
    .editor-btn-hosomincho5mm,
    .editor-btn-hosomincho5mm_2,
    .editor-btn-futomincho10mm,
    .editor-btn-futomincho10mm_2
  )::before,
.style-editor
  .editor-body.e_jikusen
  :is(
    .editor-btn-hosomincho2mm,
    .editor-btn-hosomincho5mm,
    .editor-btn-hosomincho5mm_2,
    .editor-btn-futomincho10mm,
    .editor-btn-futomincho10mm_2
  )::after {
  content: none !important; /* 疑似要素自体を生成しない */
  /* 念のための保険（古い実装向け） */
  display: none !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* ===== Sub-Editor（style-editor の裏側を通る） ===== */
.sub-editor {
  position: fixed;
  top: 0;
  left: 0; /* 画面原点に固定 */
  width: 210px; /* 実幅はJSで上書き */
  height: 100vh;
  background: rgba(255, 255, 255, 0.75);
  /* ★閉時は style-editor と同位置で“真下”に隠す（裏側を通る） */
  transform: translateX(0);

  /* 初期は操作不可＆非表示（style-editor が閉じている場合の露出防止） */
  visibility: hidden;
  pointer-events: none;

  /* 表示/非表示のタイミングは transform 完了に合わせる */
  transition:
    transform 0.3s ease,
    visibility 0s linear 0.3s;

  /* ★ style-editor(=10030) より下にして「裏側」へ */
  z-index: 10025;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.15);
}

.sub-editor.is-open {
  /* ★開時だけ style-editor 幅分右へスライド（＝右側に現れる） */
  transform: translateX(var(--se-offset, 210px));
  /* すぐ可視＆操作可へ */
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.3s ease; /* 閉時の visibility 遅延は不要 */
}

.sub-editor .sub-body {
  flex: 1 1 auto; /* 残り高さを占有 */
  min-height: 0; /* ★ flex 子のオーバーフローを許可する重要プロパティ */
  overflow-y: auto; /* ここでスクロール */
  -webkit-overflow-scrolling: touch; /* iOS 慣性スクロール */
  padding: 5px;
  color: #fff;
  padding-bottom: 70px;
  scrollbar-color: #90b3ad #f5f5f5;
  scrollbar-width: thin;
}

/* hidden のときに確実に消す（既存の [hidden] を尊重） */
.sub-editor .sub-body[hidden] {
  display: none !important;
}

@media (max-width: 768px) {
  .sub-editor {
    height: calc(100vh - var(--vv-bottom)); /* 既存の style-editor と同等の高さ確保 */
  }
}

/* 色パレット用：中身は純色。画像は使わない */
.color-palette .palette-item {
  background-image: none !important;
}

/* --- 軸先サブエディタ（2カラム） --- */
.sub-editor .e_jikusaki .editor-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sub-editor .e_jikusaki .palette-item {
  --pad: 2px; /* 基本の内側余白 */
  --topExtra: 2px; /* 上だけ追加で空けたい分 */

  width: 100%;
  aspect-ratio: 1 / 1; /* ★正方形を保証（iOS安定） */
  height: auto;

  position: relative;
  overflow: hidden;
  box-sizing: border-box;

  /* ★グレー背景は“正方形にピッタリ” */
  background-color: #f3f4f5;

  /* 親は画像を保持するが表示しない（::beforeが使う） */
  background-size: 0 0 !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  position: relative;
}

/* サムネは内側だけに描画（上だけ余白+5px） */
.sub-editor .e_jikusaki .palette-item::before {
  content: '';
  position: absolute;

  top: calc(var(--pad) + var(--topExtra));
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);

  background-image: inherit; /* ← .jc3-3 の url(...) を引き継ぐ */
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;

  pointer-events: none;
  border-radius: inherit;
}

/* （念のため）古い環境向けフォールバック */
@supports not (aspect-ratio: 1 / 1) {
  .sub-editor .e_jikusaki .palette-item {
    height: 0;
    padding-top: 100%;
  }
}

/* --- アップロード専用ボタンの見た目 --- */
.sub-editor .editor-palette .palette-item.item_upload {
  position: relative;
  display: block;
  border: 1px solid #bbbbbb;
  cursor: pointer;
  color: #222;
  font-size: 14px;
  /* 高さは JS で .style-editor .editor-btn に揃えるため固定しない */
  background: #fff;
}
.sub-editor .editor-palette .palette-item.item_upload::after {
  background: transparent;
}

/* hover で border-color を #90b3ad */
.sub-editor .editor-palette .palette-item.item_upload:hover {
  border-color: #90b3ad;
  background: #fff;
}

/* アイコンはラベルと別で absolute、左基準 */
.sub-editor .editor-palette .palette-item.item_upload .pu-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  background: no-repeat center / contain url('../img/icon_upload_grn.png');
  pointer-events: none;
}

/* ラベルは中央配置（上下中央） */
.sub-editor .editor-palette .palette-item.item_upload .pu-label {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  line-height: 1;
  font-weight: 700;
  color: #222;
  pointer-events: none;
}

/* 生成されるアップロード画像アイテム（既存のpalette-itemと同じ扱い） */
.sub-editor .editor-palette .palette-item.upload_item {
  display: block;
  border: 1px solid #ddd;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}
.sub-editor .editor-palette .palette-item.upload_item:hover {
  border-color: #90b3ad;
}

.honsi,
.chumawasi,
.tenchi-hasira,
.jikubottom {
  background-repeat: repeat !important;
  background-position: center top !important;
  background-size: min(300px, 100%) auto !important;
}

.palette-ttl {
  font-size: 14px;
  padding: 0 8px;
  margin-top: 6px;
  margin-bottom: 3px;
  border-bottom: 1px solid #90b3ad;
}

.sub-editor .note {
  font-size: 12px;
  margin: 0 !important;
}

/* ==============================
   中廻し：線モード（新方式）
   - borderは使わない
   - 背景色 rgb(102,102,102)
   - padding 2px（box-sizing:border-box で外寸を増やさない）
   - 内側に透明ボックスを生成（.chuma-line-inner）
================================ */
.chumawasi.is-line2 {
  box-sizing: border-box;
  padding: 2px 0; /* top/bottom=2px, left/right=0 */
  border: none !important;

  background-color: rgb(102, 102, 102) !important;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;

  position: relative; /* 内側ボックス用 */
}

/* 柱裂幅(=左右が開いた)時だけ左右2pxを付ける */
.chumawasi.is-line2.has-side-gap {
  padding-left: 2px;
  padding-right: 2px;
}

.chumawasi.is-line2 > .chuma-line-inner {
  position: absolute;
  inset: 2px 0; /* padding幅と一致 */
  pointer-events: none;
  background: #f3f4f5;
}

.chumawasi.is-line2.has-side-gap > .chuma-line-inner {
  inset: 2px; /* top/right/bottom/left=2px */
}

@media (max-width: 768px) {
  .logo {
    width: 40px;
    margin: 25px;
  }
  .jiku-wrapper {
    top: 46%;
    height: 75vh;
  }
  .layout-editor {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 260px !important;
    transform: translateY(100%) !important;
    transition: transform 0.2s ease !important;
    background: rgba(144, 179, 173, 0.75) !important;
    visibility: hidden !important;
    z-index: 10040 !important;
    padding: 50px 56px 17px 17px;
  }
  .layout-editor.is-open {
    transform: translateY(0) !important;
    visibility: visible !important;
  }
  .style-editor {
    transform: translateX(-100%) !important;
    transition: transform 0.2s ease !important;
    z-index: 10080 !important;
    width: calc(100vw / 2.6);
  }
  .style-editor.is-open {
    transform: translateX(0) !important;
  }
  .style-editor.is-peek {
    transform: translateX(calc(-100% + 10px)) !important;
  }
  .style-editor .editor-heading {
    padding: 10px 36px 10px 12px;
    font-size: 14px;
  }
  .style-editor .editor-heading::after {
    width: 8px;
    height: 8px;
  }
  .layout-editor .margin-row {
    display: grid !important;
    grid-template-columns: 20px minmax(0, 1fr) 48px auto !important;
    align-items: center !important;
    column-gap: 6px !important;
    row-gap: 6px !important;
    margin-bottom: 10px !important;
    position: relative !important;
  }
  .style-editor .editor-btn {
    height: 42px;
    font-size: 14px;
    padding: 0 8px;
  }
  .editor-close {
    width: 60px;
    height: 60px;
  }
  .layout-editor .editor-body h3 {
    font-size: 18px;
    margin-bottom: 15px;
  }
  .layout-editor .margin-row > label {
    font-size: 14px !important;
    color: #fff !important;
    text-align: left !important;
    width: auto !important;
    margin-left: 2px;
  }
  .layout-editor .me-range {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 24px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background: #fff !important;
    border: 1px solid #c9c9c9 !important;
    outline: none !important;
    overflow: hidden !important;
    border-radius: 0;
  }
  .layout-editor .me-range::-webkit-slider-runnable-track {
    height: 24px !important;
    background: transparent !important;
    border: none !important;
  }
  .layout-editor .me-range::-moz-range-track {
    height: 24px !important;
    background: transparent !important;
    border: none !important;
  }
  :root {
    --thumb-line-inset-y: 8px; /* 上下余白（大きいほど線が短く） */
    --thumb-line-inset-x: 6px; /* 左右の位置 */
    --thumb-line-thickness: 1px; /* 線の太さ */
  }
  .layout-editor .me-range::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 16px !important;
    height: 24px !important;
    border: none !important;
    position: relative !important;
    cursor: pointer !important;
  }
  .layout-editor .me-range::-moz-range-thumb {
    width: 16px !important;
    height: 24px !important;
    border: none !important;
    cursor: pointer !important;
  }
  .layout-editor .me-input {
    width: 48px !important;
    height: 24px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: 0 !important;
    border: 1px solid #c9c9c9 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    border-radius: 0;
  }
  .layout-editor .margin-row > span {
    font-size: 14px !important;
    color: #fff !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }
  .layout-editor .editor-body {
    overflow-y: auto !important;
    position: relative;
  }
  .layout-editor .editor-close {
    pointer-events: auto;
    z-index: 101;
  }
  .editor-close::before,
  .editor-close::after {
    width: 45px;
  }
  .style-editor.is-open,
  .layout-editor.is-open {
    touch-action: none;
  }

  .style-editor .editor-body,
  .layout-editor .editor-body {
    touch-action: pan-y;
    overscroll-behavior: contain;
  }
  .editor-palette .coming-soon {
    padding-left: 7px;
  }
  /* --- FIX: レイアウトエディタ内のスライダーを横ドラッグ可能に --- */
  .layout-editor.is-open {
    touch-action: auto !important;
  }
  .layout-editor .editor-body {
    touch-action: auto !important;
  }
  .layout-editor .editor-body input[type='range'] {
    touch-action: pan-x !important; /* 横ドラッグを許可 */
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
  }
  .layout-editor .link-toggle {
    position: absolute;
    right: -38px;
    top: 45px;
    display: block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    z-index: 5; /* 見出しや×ボタンより手前に */
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
  }
  .layout-editor .le-panel.is-active > .editor-body {
    overflow: visible !important;
  }
  #zoomSliderMount {
    --zoomist-slider-bar-size: 185px !important;
  }
  #zoomist .zoomist-zoomer {
    bottom: calc(
      max(8px, env(safe-area-inset-bottom)) + var(--vv-bottom) + var(--sliderBoxH, 220px) + 8px
    );
  }
  #zoomPercent {
    margin-bottom: 5px;
  }
  .zoomist-zoomer-button {
    width: 44px !important;
    height: 44px !important;
  }
  #zoomSliderBox {
    width: 44px;
  }
  .edit-icon {
    width: 44px;
    height: 160px;
  }
  .edit-icon > span {
    font-size: 14px;
  }
  .style-editor .editor-btn::after {
    right: 6px;
    width: 17px;
    height: 17px;
  }
  .style-editor .editor-btn::before {
    right: 11px;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid #fff;
  }
  .seg-radio .seg-item {
    white-space: nowrap;
    padding: 0 7px;
    font-size: 13px;
  }
  .sub-editor {
    width: 138px !important;
  }
  .palette-item {
    height: 58px !important;
  }
  .palette-item::after {
    font-size: 13px;
  }
  .palette-item.item_upload .pu-label {
    font-size: 13px;
    padding-left: 25px;
  }
  .sub-editor .editor-palette .palette-item.item_upload {
    height: 42px !important;
    font-size: 13px;
  }
  .sub-editor .editor-palette .palette-item.item_upload .pu-icon {
    width: 18px;
    height: 18px;
    left: 10px;
  }
  .style-editor .editor-backlink {
    padding: 0 6px;
    gap: 7px;
    pointer-events: auto;
    touch-action: manipulation;
    height: 20px;
  }
  .style-editor .editor-backlink span {
    font-size: 10px;
  }
  .style-editor .editor-backlink .icon {
    width: 0.5em;
    height: 0.5em;
  }
  .style-editor .editor-backlink_d {
    padding: 0 8px;
    gap: 8px;
  }
  .style-editor .editor-backlink_d span {
    font-size: 11px;
  }
  .style-editor .editor-backlink_d .icon {
    width: 0.5em;
    height: 0.5em;
  }
  .qm-modal-close {
    width: 55px;
    height: 55px;
  }
  .qm-modal-close::before,
  .qm-modal-close::after {
    width: 35px;
  }
  .qm-modal-inner {
    padding: 0 15px;
  }
  .qm-pane-ttl {
    font-size: 18px;
    margin: 0 0 12px;
    letter-spacing: 1px;
  }
  .qm-kingaku ul li span {
    font-size: 15px;
  }
  .qm-kingaku ul {
    margin-bottom: 17px;
  }
  .qm-modal .p-button {
    width: 180px;
    height: 46px;
    font-size: 15px;
  }
  .qm-modal .n-button {
    font-size: 15px;
  }
  .qm-kingaku-total #kingakuTotal {
    font-size: 16px;
  }
  .qm-pane-sub-ttl {
    font-size: 15px;
    margin-bottom: 2px;
  }
  #qmPaneSoudan textarea,
  #qmPaneSoudan input[type='email'],
  #qmPaneSoudan input[type='text'],
  #qmPaneSave input[type='text'] {
    font-size: 16px;
    padding: 10px;
    margin-bottom: 12px;
  }
  #qmSoudanSavedTableWrap #qmSoudanSavedTable td,
  .qm-save-pane--list .qm-saved-table td {
    padding: 8px 4px;
  }
  #qmSoudanSavedTableWrap #qmSoudanSavedTable td.qm-saved-td-name,
  .qm-save-pane--list .qm-saved-table td.qm-saved-td-name {
    font-size: 12px;
  }
  .qm-saved-td-date {
    font-size: 11px;
  }
  .qm-soudan-td-check input[type='checkbox'] {
    width: 30px;
    height: 30px;
    margin-right: 5px;
  }
  .qm-soudan-td-check input[type='checkbox']::after {
    width: 8px;
    height: 15px;
    border-right: 3px solid #90b3ad;
    border-bottom: 3px solid #90b3ad;
  }
  .qm-pane .ast small {
    font-size: 12px;
  }
  #qmPaneSoudan textarea {
    min-height: 120px;
  }
  .qm-save-pane--list {
    max-height: 180px;
  }
  #qmSoudanSavedTableWrap {
    max-height: 110px;
    margin-top: 6px;
    margin-bottom: 10px;
  }
  .qm-pane--saved {
    margin-top: 6px;
    margin-bottom: 18px;
  }
  .btnWrap.cancel {
    display: none;
  }
  #qmPaneSoudan .p-button {
    margin-bottom: 0;
  }
  #qmPaneSoudan {
    padding-top: 20px;
  }
  .palette-ttl {
    font-size: 14px;
    margin-top: 3px;
    margin-bottom: 0;
  }
  .palette-item.is-selected::after {
    padding-bottom: 10px;
  }
  .palette-item.is-selected:not(.upload_item)[data-kiji-name]:not([data-kiji-name=''])::before {
    bottom: 10px;
  }
  .qm-notice-text {
    font-size: 15px;
    margin-bottom: 0;
    border: 3px solid #cc0000;
    padding: 10px;
  }

  .icon-wrapper {
    margin-bottom: 0;
  }

  .icon-wrapper img {
    width: 50px;
    margin: -20px 0 0;
  }

  h1.mail-ttl {
    font-size: 25px;
    margin-bottom: 8px;
    letter-spacing: 3px;
  }

  p.copy {
    bottom: 10px;
    font-size: 10px;
  }
  .color-ast {
    margin-top: 4px;
    font-size: 9px;
  }
  .sub-editor .note {
    font-size: 10px;
  }
  button#input-size {
    margin-top: 10px !important;
  }
  .qm-kingaku-note--shipping {
    font-size: 14px;
  }
}

/* iOS Safari 実機で右寄りに見える補正（必要に応じて 1〜2px に調整） */
@supports (-webkit-touch-callout: none) {
  .edit-icon > span {
    --glyph-nudge: 8px;
  }
}
