/**
 * Page Editor Styles - ページエディター専用スタイル
 * 設計書: docs/220_ページエディター設計書.md
 */

/* ===============================================
   編集ボタン
   =============================================== */

/* モーダルヘッダーのレイアウト調整（編集ボタン配置用） */
.modal-overlay .header {
  gap: 8px;
}

/* タイトルを左寄せ */
.modal-overlay .title {
  order: 1;
}

/* 編集ボタンを右端の1つ前に配置 */
.edit-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 0;
  transition: all 0.2s;
  flex-shrink: 0;
  order: 998;
}

/* ×ボタンを最後に配置 */
.modal-overlay .header .close-button,
.modal-overlay .header #modalClose {
  order: 999;
}

.edit-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* 編集ボタン非活性状態 */
.edit-btn--disabled,
.edit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
}

.edit-btn--disabled:hover,
.edit-btn:disabled:hover {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
}

.edit-btn.editing {
  background: #4a9eff;
  border-color: #4a9eff;
  color: white;
}

.edit-icon {
  font-size: 16px;
}

/* ===============================================
   保存・キャンセルボタン
   =============================================== */

.edit-controls {
  display: inline-flex;
  gap: 8px;
  margin-left: auto;
  margin-right: 0;
  order: 998; /* 編集ボタンと同じ位置（×ボタンの左隣） */
  flex-shrink: 0;
}

.undo-btn,
.redo-btn,
.save-btn,
.cancel-btn,
.restore-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

/* アンドゥ/リドゥボタン */
.undo-btn,
.redo-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 18px;
  padding: 6px 12px;
}

.undo-btn:hover:not(:disabled),
.redo-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.undo-btn:disabled,
.redo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
}

.undo-btn:disabled:hover,
.redo-btn:disabled:hover {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
}

.cancel-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
}

.cancel-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.save-btn {
  background: #4caf50;
  border: none;
  color: white;
}

.save-btn:hover {
  background: #45a049;
}

.restore-btn {
  background: transparent;
  border: 2px solid #ff9800;
  color: #ff9800;
}

.restore-btn:hover {
  background: rgba(255, 152, 0, 0.1);
  border-color: #ffb74d;
  color: #ffb74d;
}

/* ===============================================
   コンポーネント追加ボタン
   =============================================== */

.add-component-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: #4a9eff;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s;
  z-index: 1000;
}

.add-component-btn:hover {
  background: #3a8eef;
  transform: scale(1.1);
}

.add-component-btn:active {
  transform: scale(0.95);
}

/* ===============================================
   グリッド線表示（編集モード時）
   =============================================== */

.page-content[data-edit-mode='true']::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    repeating-linear-gradient(
      to right,
      rgba(255, 255, 255, 0.1) 0px,
      rgba(255, 255, 255, 0.1) 1px,
      transparent 1px,
      transparent calc(100% / 72)
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.1) 0px,
      rgba(255, 255, 255, 0.1) 1px,
      transparent 1px,
      transparent calc(100% / 48)
    );
  pointer-events: none;
  z-index: 1;
}

/* ===============================================
   編集可能なコンポーネント
   =============================================== */

.page-content[data-edit-mode='true'] .component-mount.editable {
  border: 2px solid transparent;
  transition: border-color 0.2s;
  position: relative;
}

.page-content[data-edit-mode='true'] .component-mount.editable:hover {
  border-color: #4a9eff;
}

.page-content[data-edit-mode='true'] .component-mount.editable.selected {
  border-color: #4a9eff;
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
  z-index: 1000; /* 選択中は最前面に表示 */
}

/* ===============================================
   リサイズハンドル
   =============================================== */

.resize-handle {
  position: absolute;
  background: #4a9eff;
  border: 2px solid white;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 50; /* コンポーネント内部要素（max 49）より前面 */
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.resize-handle.top {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.resize-handle.bottom {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.resize-handle.left {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.resize-handle.right {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.resize-handle.top-left {
  top: -6px;
  left: -6px;
  cursor: nwse-resize;
}

.resize-handle.top-right {
  top: -6px;
  right: -6px;
  cursor: nesw-resize;
}

.resize-handle.bottom-left {
  bottom: -6px;
  left: -6px;
  cursor: nesw-resize;
}

.resize-handle.bottom-right {
  bottom: -6px;
  right: -6px;
  cursor: nwse-resize;
}

/* ===============================================
   ズームコントロール
   =============================================== */

.zoom-control {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px;
  border-radius: 6px;
  z-index: 52; /* サイズ情報（51）より前面 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  /* ホバー時のみ表示 */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
}

/* コンポーネントにホバー時にズームコントロールを表示 */
.page-content[data-edit-mode='true'] .component-mount.editable:hover .zoom-control {
  opacity: 1;
  visibility: visible;
}

/* 設定ポップオーバー表示中は常にズームコントロールを表示 */
.page-content[data-edit-mode='true'] .component-mount.editable.settings-open .zoom-control {
  opacity: 1;
  visibility: visible;
}

.zoom-btn {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.zoom-value {
  color: white;
  font-size: 12px;
  min-width: 40px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.zoom-value:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===============================================
   サイズ情報表示
   =============================================== */

.size-info-control {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px 10px;
  border-radius: 6px;
  z-index: 51; /* ズームコントロール（52）より背面 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  /* ホバー時のみ表示 */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
}

/* コンポーネントにホバー時にサイズ情報を表示 */
.page-content[data-edit-mode='true'] .component-mount.editable:hover .size-info-control {
  opacity: 1;
  visibility: visible;
}

/* 設定ポップオーバー表示中は常にサイズ情報を表示 */
.page-content[data-edit-mode='true'] .component-mount.editable.settings-open .size-info-control {
  opacity: 1;
  visibility: visible;
}

/* ===============================================
   コンポーネントライブラリウィンドウ
   =============================================== */

.component-library-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.component-library-window {
  background: #2a2a2a;
  border-radius: 12px;
  width: 90%;
  max-width: 1000px;
  height: 80%;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.component-library-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.component-library-header h2 {
  color: white;
  margin: 0;
  font-size: 20px;
}

.component-library-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background 0.2s;
}

.component-library-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.component-library-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.component-library-list {
  width: 30%;
  min-width: 200px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  padding: 20px;
}

/* ===============================================
   コンポーネントライブラリ - サムネイル表示
   =============================================== */

.component-library-thumbnails {
  width: 70%;
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.component-library-empty-message {
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  text-align: center;
  margin: auto;
}

.component-thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  flex: 1;
  align-content: start;
}

.component-thumbnail {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  overflow: hidden;
}

.component-thumbnail:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.component-thumbnail.selected {
  background: rgba(74, 158, 255, 0.2);
  border-color: #4a9eff;
}

.component-thumbnail-preview {
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.component-thumbnail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.component-thumbnail-icon {
  font-size: 36px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.component-thumbnail-info {
  padding: 4px 8px;
  height: calc(17px * 1.3 * 2 + 8px);
}

.component-thumbnail-name {
  color: white;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.component-library-action {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.component-library-add-btn {
  margin-top: 20px;
  padding: 12px 32px;
  background: #4a9eff;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.component-library-add-btn:hover {
  background: #3a8eef;
}

.component-library-add-btn:disabled {
  background: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
}

/* ===============================================
   スクロールバースタイル
   =============================================== */

.component-library-list::-webkit-scrollbar,
.component-library-preview::-webkit-scrollbar {
  width: 8px;
}

.component-library-list::-webkit-scrollbar-track,
.component-library-preview::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.component-library-list::-webkit-scrollbar-thumb,
.component-library-preview::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.component-library-list::-webkit-scrollbar-thumb:hover,
.component-library-preview::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===============================================
   コンポーネントライブラリ - グループリスト
   =============================================== */

.component-library-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.component-library-group-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.component-library-group-item.selected {
  background: rgba(74, 158, 255, 0.2);
  border-color: #4a9eff;
}

.component-library-group-item .group-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.component-library-group-item .group-count {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

/* 空状態 */
.component-library-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.6);
}

.component-library-empty p {
  margin: 0 0 8px;
  font-size: 16px;
}

.component-library-empty small {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

/* プレビュー内の定義リスト */
.component-library-preview-content h3 {
  color: white;
  margin: 0 0 12px;
  font-size: 18px;
}

.component-library-preview-content > p {
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
}

.component-library-preview-content dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
}

.component-library-preview-content dt {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.component-library-preview-content dd {
  color: white;
  font-size: 13px;
  margin: 0;
}

/* ===============================================
   コンポーネント設定ポップオーバー
   =============================================== */

.component-settings-popover {
  position: fixed;
  background: #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  min-width: 240px;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-popover-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-popover-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ヘルプアイコン */
.settings-help-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-help-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ヘルプポップアップ */
.settings-help-popup {
  position: fixed;
  z-index: 10002;
  background: #1f2937;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 12px 16px;
  color: white;
  font-size: 13px;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  animation: helpPopupFadeIn 0.15s ease-out;
}

.settings-help-popup strong {
  color: #fbbf24;
  font-weight: 600;
}

@keyframes helpPopupFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-popover-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}

.settings-popover-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.settings-popover-form {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-form-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.settings-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: white;
  font-size: 13px;
  transition: border-color 0.2s;
}

.settings-input:focus {
  outline: none;
  border-color: #4a9eff;
}

/* セレクトボックスのスタイル */
select.settings-input {
  background-color: #2a2a2a;
}

select.settings-input option {
  background-color: #2a2a2a;
  color: white;
}

.settings-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4a9eff;
}

/* ===============================================
   共通トグルスイッチ（横スライド式）
   =============================================== */

.settings-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.settings-toggle .toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  transition: background-color 0.2s;
}

.settings-toggle .toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.settings-toggle input:checked + .toggle-slider {
  background-color: #4a9eff;
}

.settings-toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* トグル付きの行レイアウト（横並び） */
.settings-row-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-number-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.settings-number {
  padding: 8px 10px;
  padding-right: 28px;
  width: 100%;
  box-sizing: border-box;
  -moz-appearance: textfield;
}

.settings-number::-webkit-inner-spin-button,
.settings-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.settings-number::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* カスタム上下ボタン */
.settings-number-btns {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  display: flex;
  flex-direction: column;
  width: 22px;
}

.settings-number-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  font-size: 8px;
  line-height: 1;
}

.settings-number-btn:first-child {
  border-radius: 4px 4px 0 0;
}

.settings-number-btn:last-child {
  border-radius: 0 0 4px 4px;
}

.settings-number-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.settings-number-btn:active {
  background: #4a9eff;
  color: white;
}

.settings-number-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-text {
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
}

/* テキストエリア */
.settings-textarea {
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  line-height: 1.4;
}

.settings-textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* カラーピッカー */
.settings-color-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-color {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.settings-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.settings-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.settings-color-hex {
  flex: 1;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 13px;
  text-transform: lowercase;
}

.settings-color-hex::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* マルチセレクト */
.settings-multiselect {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  cursor: pointer;
}

.settings-multiselect-option input[type='checkbox'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #4a9eff;
}

/* 設定ボタン（⚙アイコン） */
.zoom-btn.zoom-settings {
  font-size: 14px;
}

/* ラジオボタン形式のボタングループ */
.settings-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.settings-radio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.settings-radio-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.settings-radio-btn.selected {
  background: #4a9eff;
  border-color: #4a9eff;
  color: white;
}

.settings-radio-btn input[type='radio'] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* 無効化された設定行 */
.settings-row-disabled {
  opacity: 0.5;
}

.settings-row-disabled .settings-label {
  color: rgba(255, 255, 255, 0.4);
}

.settings-radio-btn.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.settings-radio-btn.disabled:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ===============================================
   設定グループ（2カラムレイアウト）
   =============================================== */

.settings-group-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.settings-group-columns .settings-row {
  min-width: 0;
}

/* ===============================================
   ページエディターボタンコンテナ
   =============================================== */

.page-editor-btn-container {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 12px;
  z-index: 1000;
}

/* ===============================================
   ページ設定ボタン
   =============================================== */

.page-settings-btn {
  width: 48px;
  height: 48px;
  background: #6c757d;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s;
}

.page-settings-btn:hover {
  background: #5a6268;
  transform: scale(1.1);
}

.page-settings-btn:active {
  transform: scale(0.95);
}

/* ボタンコンテナ内の追加ボタン位置調整 */
.page-editor-btn-container .add-component-btn {
  position: static;
  bottom: auto;
  right: auto;
}

/* ===============================================
   ページ設定ポップオーバー
   =============================================== */

.page-settings-popover {
  position: fixed;
  background: #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  min-width: 280px;
  max-width: 360px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===============================================
   背景色プリセットグリッド
   =============================================== */

.page-settings-color-preset-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.page-settings-color-preset {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  background: none;
}

.page-settings-color-preset:hover {
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

.page-settings-color-preset.selected {
  border-color: #4a9eff;
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

/* 透明パターン */
.page-settings-color-preset.transparent-pattern {
  background-image:
    linear-gradient(45deg, #666 25%, transparent 25%),
    linear-gradient(-45deg, #666 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #666 75%),
    linear-gradient(-45deg, transparent 75%, #666 75%);
  background-size: 12px 12px;
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0px;
  background-color: #444;
}

/* ===============================================
   カスタムカラー入力行
   =============================================== */

.page-settings-custom-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.page-settings-custom-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  flex-shrink: 0;
}

.page-settings-custom-input {
  flex: 1;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 13px;
}

.page-settings-color-picker {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.page-settings-color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.page-settings-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* ===============================================
   背景画像設定
   =============================================== */

.page-settings-image-row {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.page-settings-image-preview {
  position: relative;
  width: 100%;
  height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  margin-top: 8px;
}

.page-settings-image-preview:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background-color: rgba(255, 255, 255, 0.08);
}

.page-settings-image-preview.has-image {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.3);
}

.page-settings-image-preview.uploading {
  opacity: 0.6;
  pointer-events: none;
}

.page-settings-image-preview.uploading::after {
  content: '処理中...';
  position: absolute;
  color: white;
  font-size: 12px;
}

.page-settings-image-placeholder {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.page-settings-image-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.page-settings-image-btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.page-settings-image-btn.upload {
  background: #4a9eff;
  color: white;
}

.page-settings-image-btn.upload:hover {
  background: #3a8eef;
}

.page-settings-image-btn.upload:disabled {
  background: rgba(74, 158, 255, 0.5);
  cursor: not-allowed;
}

.page-settings-image-btn.delete {
  background: rgba(255, 255, 255, 0.1);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.page-settings-image-btn.delete:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.5);
}

.page-settings-image-btn.delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-settings-fit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.page-settings-fit-select {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
}

.page-settings-image-note {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  margin-top: 8px;
  text-align: right;
}

/* ===============================================
   コンポーネント共通スタイル設定
   =============================================== */

.page-settings-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
}

.page-settings-component-style {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-settings-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.page-settings-section-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 600;
}

.page-settings-reset-btn-group {
  display: flex;
  gap: 6px;
}

.page-settings-reset-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
  white-space: nowrap;
}

.page-settings-reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.8);
}

/* リセットボタン - 有効状態（変更がある場合） */
.page-settings-reset-btn.active {
  border-color: rgba(40, 120, 255, 1);
  color: rgba(80, 150, 255, 1);
  background: rgba(40, 120, 255, 0.35);
}

.page-settings-reset-btn.active:hover {
  border-color: rgba(60, 140, 255, 1);
  color: rgba(120, 180, 255, 1);
  background: rgba(60, 140, 255, 0.45);
}

.page-settings-reset-all-btn {
  border-color: rgba(255, 100, 100, 0.4);
  color: rgba(255, 130, 130, 0.8);
}

.page-settings-reset-all-btn:hover {
  background: rgba(255, 100, 100, 0.1);
  border-color: rgba(255, 100, 100, 0.6);
  color: rgba(255, 150, 150, 1);
}

/* 全リセットボタン - 有効状態（変更がある場合） */
.page-settings-reset-all-btn.active {
  border-color: rgba(255, 60, 60, 1);
  color: rgba(255, 100, 100, 1);
  background: rgba(255, 60, 60, 0.4);
}

.page-settings-reset-all-btn.active:hover {
  border-color: rgba(255, 80, 80, 1);
  color: rgba(255, 130, 130, 1);
  background: rgba(255, 80, 80, 0.5);
}

.page-settings-style-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-settings-checkbox-row {
  justify-content: space-between;
}

/* 横並びレイアウト（枠線と角丸） */
.page-settings-inline-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-settings-inline-row .page-settings-style-row {
  gap: 6px;
}

.page-settings-inline-row .page-settings-style-row:first-child .page-settings-style-label {
  min-width: 41px; /* 他の行と同じラベル幅 */
}

.page-settings-inline-row .page-settings-style-row:last-child .page-settings-style-label {
  min-width: auto;
}

.page-settings-style-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  min-width: 35px;
  flex-shrink: 0;
}

/* 数値入力グループ */
.page-settings-number-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.page-settings-number-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.page-settings-number-input {
  width: 60px;
  padding: 8px 10px;
  padding-right: 28px;
  font-size: 13px;
  text-align: center;
  border-radius: 6px;
  -moz-appearance: textfield;
}

.page-settings-number-input::-webkit-inner-spin-button,
.page-settings-number-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* カスタム上下ボタン */
.page-settings-number-btns {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  display: flex;
  flex-direction: column;
  width: 22px;
}

.page-settings-number-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  font-size: 10px;
  line-height: 1;
}

.page-settings-number-btn:first-child {
  border-radius: 4px 4px 0 0;
}

.page-settings-number-btn:last-child {
  border-radius: 0 0 4px 4px;
}

.page-settings-number-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.page-settings-number-btn:active {
  background: #4a9eff;
  color: white;
}

.page-settings-unit-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  min-width: 20px;
}

/* ボーダースタイル選択 */
.page-settings-border-style-select {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

/* ボーダー色設定 */
.page-settings-border-color-group {
  display: flex;
  gap: 8px;
  flex: 1;
}

.page-settings-border-color-input {
  flex: 1;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 12px;
}

.page-settings-border-color-picker {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.page-settings-border-color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.page-settings-border-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* ===============================================
   コンポーネント個別スタイル設定（コンポーネント設定ポップオーバー内）
   =============================================== */

.component-settings-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
}

.component-style-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.component-style-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.component-style-section-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 600;
}

.component-style-reset-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
  white-space: nowrap;
}

.component-style-reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.8);
}

/* コンポーネント個別スタイル リセットボタン - 有効状態（変更がある場合） */
.component-style-reset-btn.active {
  border-color: rgba(40, 120, 255, 1);
  color: rgba(80, 150, 255, 1);
  background: rgba(40, 120, 255, 0.35);
}

.component-style-reset-btn.active:hover {
  border-color: rgba(60, 140, 255, 1);
  color: rgba(120, 180, 255, 1);
  background: rgba(60, 140, 255, 0.45);
}

.component-style-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.component-style-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  min-width: 33px;
  flex-shrink: 0;
}

/* 数値入力グループ */
.component-style-number-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.component-style-number-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.component-style-number-input {
  width: 55px;
  padding: 6px 8px;
  padding-right: 24px;
  font-size: 12px;
  text-align: center;
  border-radius: 4px;
  -moz-appearance: textfield;
}

.component-style-number-input::-webkit-inner-spin-button,
.component-style-number-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.component-style-number-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-size: 10px;
}

/* カスタム上下ボタン */
.component-style-number-btns {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  display: flex;
  flex-direction: column;
  width: 18px;
}

.component-style-number-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  font-size: 8px;
  line-height: 1;
}

.component-style-number-btn:first-child {
  border-radius: 3px 3px 0 0;
}

.component-style-number-btn:last-child {
  border-radius: 0 0 3px 3px;
}

.component-style-number-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.component-style-number-btn:active {
  background: #4a9eff;
  color: white;
}

.component-style-unit {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  min-width: 18px;
}

/* セレクト */
.component-style-select {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

/* カラー入力グループ */
.component-style-color-group {
  display: flex;
  gap: 6px;
  flex: 1;
}

.component-style-color-input {
  flex: 1;
  padding: 5px 6px;
  font-family: monospace;
  font-size: 11px;
}

.component-style-color-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-size: 10px;
}

.component-style-color-picker {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.component-style-color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.component-style-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* トグルスイッチ行 */
.component-style-checkbox-row {
  justify-content: space-between;
}

.component-style-checkbox-row .component-style-label {
  min-width: auto;
}

/* 横並びレイアウト（枠線と角丸） */
.component-style-inline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.component-style-inline-row .component-style-row {
  gap: 4px;
}

.component-style-inline-row .component-style-row:first-child .component-style-label {
  min-width: 39px; /* 他の行と同じラベル幅 */
}

.component-style-inline-row .component-style-row:last-child .component-style-label {
  min-width: auto;
}
