:root {
  --theme-color-1: #FF7EB3;
  --theme-color-2: #8B44FF;
  --theme-bg: linear-gradient(135deg, #FF7EB3, #8B44FF); 
  --theme-color-rgb: 255, 126, 179; 
  --font-family: 'Noto Sans JP', sans-serif;
  --bg-color: #f4f6fa;
  --text-main: #2c3e50;
  --border-color: #e2e8f0;
}

body {
  font-family: var(--font-family); background-color: var(--bg-color);
  background-image: radial-gradient(#d1d8e0 1.5px, transparent 1.5px); background-size: 24px 24px;
  color: var(--text-main); margin: 0; padding: 0; transition: font-family 0.3s;
}

header { position: relative; text-align: center; padding: 40px 20px; background: var(--theme-bg); color: white; box-shadow: 0 4px 20px rgba(0,0,0,0.1); overflow: hidden; }
header h1 { margin: 0; font-size: 2.2em; position: relative; z-index: 2; text-shadow: 0 2px 5px rgba(0,0,0,0.2); }
header p { margin: 10px 0 0; font-size: 1em; opacity: 0.95; position: relative; z-index: 2; }
.bg-shape { position: absolute; background: rgba(255,255,255,0.15); border-radius: 50%; z-index: 1; pointer-events: none;}
.shape-1 { width: 150px; height: 150px; top: -50px; left: -20px; }
.shape-2 { width: 80px; height: 80px; bottom: -20px; right: 10%; }

.main-container { display: flex; flex-wrap: wrap; gap: 30px; padding: 30px; max-width: 1600px; margin: 0 auto; }
.mobile-only { display: none; }

/* スマホ用レスポンシブ */
@media (max-width: 1100px) {
  .main-container { flex-direction: column; padding: 15px; gap: 20px;}
  .editor-panel { flex: 1 1 100%; width: 100%; box-sizing: border-box; max-height: none !important;}
  .preview-panel { width: 100%; padding-bottom: 20px; overflow-x: hidden; }
  .preview-scale-box { width: 100%; overflow: hidden; }
  .cards-wrapper { transform-origin: top left; }
  .mobile-only { display: inline; color: #ff7675; font-weight: bold;}
}

.preview-scale-box { width: 100%; position: relative; display: block; transition: height 0.3s;}
.cards-wrapper { width: 900px; display: flex; flex-direction: column; align-items: center; gap: 40px; margin: 0 auto;}

.guide-box { background: #fff; border: 1px solid var(--theme-color-1); border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
.guide-box summary { background: rgba(var(--theme-color-rgb), 0.1); color: var(--theme-color-1); padding: 15px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.guide-content { padding: 15px; font-size: 0.9em; color: #555; line-height: 1.5; }

.editor-panel { flex: 1 1 450px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); padding: 30px; border-radius: 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.06); max-height: 85vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.5); }
.preview-panel { flex: 2 1 800px; display: flex; flex-direction: column; align-items: center; }

.file-drop-area { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed var(--theme-color-1); border-radius: 16px; padding: 25px; background: rgba(var(--theme-color-rgb), 0.05); color: var(--theme-color-1); cursor: pointer; transition: 0.2s; font-weight: bold; width: 100%; box-sizing: border-box; }
.file-drop-area:hover { transform: translateY(-2px); background: rgba(var(--theme-color-rgb), 0.1); }
#imageLoader { display: none; }

.toolbar-buttons, .preview-actions { display: flex; gap: 10px; margin-bottom: 20px; width: 100%; justify-content: center; flex-wrap: wrap;}
.toolbar-buttons { margin-top: 25px; } 

.color-picker-wrapper { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }
.preset-color { width: 36px; height: 36px; border-radius: 50%; border: 2px solid white; box-shadow: 0 2px 8px rgba(0,0,0,0.15); cursor: pointer; transition: 0.2s; }
.preset-color:hover { transform: scale(1.15); }

.custom-color-inputs { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
.color-circle { -webkit-appearance: none; -moz-appearance: none; appearance: none; width: 40px; height: 40px; border: 3px solid #fff; border-radius: 50%; padding: 0; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.15); background: transparent; }
.color-circle::-webkit-color-swatch-wrapper { padding: 0; }
.color-circle::-webkit-color-swatch { border: none; border-radius: 50%; }
.color-circle::-moz-color-swatch { border: none; border-radius: 50%; }
.custom-color-inputs span { font-weight: bold; color: #aaa; font-size: 1.2em; }

.select-wrapper { position: relative; width: 100%; }
.select-wrapper::after { content: '\f0d7'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--theme-color-1); pointer-events: none; }
.custom-select { appearance: none; width: 100%; padding: 12px 15px; border: 1px solid var(--border-color); border-radius: 12px; background: #f9fbff; font-family: inherit; font-size: 0.95em; color: var(--text-main); cursor: pointer; transition: 0.2s; }
.custom-select:focus { border-color: var(--theme-color-1); outline: none; box-shadow: 0 0 0 3px rgba(var(--theme-color-rgb), 0.2); }

.section { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px dashed var(--border-color); }
.section h2 { font-size: 1.1em; color: var(--text-main); margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.section h2 i { color: var(--theme-color-1); }
.input-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.85em; font-weight: bold; color: #666; }
input[type="text"], input[type="number"], textarea { width: 100%; padding: 12px 15px; border: 1px solid var(--border-color); border-radius: 12px; background: #f9fbff; box-sizing: border-box; transition: 0.2s; font-family: inherit; font-size: 0.95em; }

.icon-upload-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(45deg, #ff9a9e, #fecfef); color: #d63031; font-weight: bold; padding: 12px 20px; border-radius: 12px; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 10px rgba(255, 154, 158, 0.3); border: 1px solid #fff; margin-top: 5px;}
.icon-upload-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }

.list-item-row { display: flex; align-items: center; gap: 8px; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 8px; flex-wrap: wrap;}
.drag-handle { cursor: grab; color: #bbb; padding: 0 5px; font-size: 1.2em; }
.drag-handle:active { cursor: grabbing; }
.list-item-row .custom-select { padding: 8px; font-size: 0.85em; width: 120px; flex: unset;}
.list-item-row input[type="text"] { padding: 8px; flex: 1; min-width: 100px;}

.size-controls { display: flex; gap: 10px; background: #fdfdfd; padding: 10px; border-radius: 12px; border: 1px solid #eee; margin-bottom: 15px; font-size: 0.8em; font-weight: bold; align-items: center; flex-wrap: wrap;}
.size-controls input[type="range"] { flex: 1; accent-color: var(--theme-color-1); min-width: 60px;}
.val-disp { display: inline-block; width: 45px; text-align: right; font-weight: normal; color: #888; font-family: monospace; font-size: 1.1em;}

.grid-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }

.btn { padding: 12px 20px; border-radius: 12px; font-weight: bold; cursor: pointer; border: none; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; font-family: inherit;}
.btn:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
.btn-primary { background: var(--theme-bg); color: white; }
.btn-primary-outline { border: 2px solid var(--theme-color-1); background: transparent; color: var(--theme-color-1); }
/* 🗑️ 追加した削除ボタンのスタイル */
.btn-secondary-outline { border: 2px solid #a4b0be; background: transparent; color: #747d8c; }
.btn-secondary-outline:hover { background: rgba(0,0,0,0.05); color: #ff7675; border-color: #ff7675; }

.btn-danger { background: #ff7675; color: white; }
.btn-info { background: #55efc4; color: #2d3436; }
.btn-outline { border: 1px dashed var(--theme-color-1); color: var(--theme-color-1); background: transparent; width: 100%;}

.card { width: 900px; min-height: 480px; background-color: var(--card-bg, #ffffff); border-radius: 24px; box-shadow: 0 12px 40px rgba(0,0,0,0.1); overflow: hidden; display: flex; flex-direction: column; position: relative; }

.effect-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 5; }
.particle { position: absolute; font-size: 24px; animation: fall linear forwards; opacity: 0.8; }
@keyframes fall { 0% { transform: translateY(-50px) rotate(0deg) scale(0.8); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateY(600px) rotate(360deg) scale(1.2); opacity: 0; } }

.card.theme-simple { --card-bg: #ffffff; }
.card.theme-watercolor { --card-bg: #fff; background-image: radial-gradient(circle at 10% 20%, rgba(216, 241, 230, 0.5) 0%, rgba(233, 226, 255, 0.5) 90%); }
.card.theme-geometric { --card-bg: #fafafa; background-image: linear-gradient(30deg, #f0f0f0 12%, transparent 12.5%, transparent 87%, #f0f0f0 87.5%, #f0f0f0), linear-gradient(150deg, #f0f0f0 12%, transparent 12.5%, transparent 87%, #f0f0f0 87.5%, #f0f0f0); background-size: 20px 35px; }
.card.theme-cyber { --card-bg: #0f172a; color: #e2e8f0; background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px); background-size: 20px 20px; }
.card.theme-nature { --card-bg: #f8faf5; background-image: radial-gradient(#d4e2d4 2px, transparent 2px); background-size: 30px 30px; }
.card.theme-night { --card-bg: #191970; color: #fff; background-image: radial-gradient(circle, #ffffff 1px, transparent 1px); background-size: 50px 50px; }

.card-header { padding: 25px 35px; display: flex; align-items: center; position: relative; border-bottom: 3px solid rgba(255,255,255,0.2); z-index: 10; color: white;}
.card-header.header-solid { background: var(--theme-bg); }
.card-header.header-stripe { background: repeating-linear-gradient(45deg, var(--theme-color-1), var(--theme-color-1) 5px, var(--theme-color-2) 5px, var(--theme-color-2) 10px); }
.card-header.header-dot { background: var(--theme-color-1); background-image: radial-gradient(var(--theme-color-2) 20%, transparent 20%); background-size: 12px 12px; }
.card-header.header-grid { background: var(--theme-color-1); background-image: linear-gradient(var(--theme-color-2) 1px, transparent 1px), linear-gradient(90deg, var(--theme-color-2) 1px, transparent 1px); background-size: 20px 20px; }
.card-header.header-glass { background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); color: inherit; border-bottom: 1px solid rgba(255,255,255,0.5); box-shadow: 0 4px 10px rgba(0,0,0,0.05), inset 0 0 20px rgba(255,255,255,0.4); }

.card-header.align-left { justify-content: flex-start; }
.card-header.align-center { justify-content: center; }
.card-header.align-right { justify-content: flex-end; flex-direction: row-reverse;}
.profile-area { display: flex; align-items: center; gap: 20px; }
.icon-circle { width: 90px; height: 90px; border-radius: 50%; background: white; background-size: cover; background-position: center; border: 4px solid rgba(255,255,255,0.8); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.profile-area h2 { margin: 0; font-size: 2.2em; text-shadow: 0 2px 4px rgba(0,0,0,0.3); font-weight: 800; }
.header-glass .profile-area h2 { text-shadow: 0 2px 6px rgba(255,255,255,0.8); }

.card-body { padding: 30px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; align-content: flex-start; flex: 1; z-index: 10; min-height: 200px;}

.card-module { box-sizing: border-box; padding: 20px; width: var(--mod-width, 100%); }
.card-module.sortable-ghost { opacity: 0.4; }
.drag-handle-mod { cursor: grab; margin-right: 8px; opacity: 0.7; }
.drag-handle-mod:active { cursor: grabbing; }

.card.frame-glass .card-module { background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.05), inset 0 0 15px rgba(255,255,255,0.3); }
.card.frame-glass .module-title { color: var(--theme-color-1); border-bottom: 2px solid rgba(var(--theme-color-rgb), 0.2); }
.card.frame-simple .card-module { background: #fff; border: 1px solid #ddd; border-radius: 12px; }
.card.frame-simple .module-title { color: #333; border-bottom: 1px solid #eee; }
.card.frame-neon .card-module { background: rgba(10,10,10,0.8); border: 1px solid var(--theme-color-1); border-radius: 12px; box-shadow: 0 0 10px var(--theme-color-1), inset 0 0 10px rgba(var(--theme-color-rgb), 0.3); color: #fff; }
.card.frame-neon .module-title { color: #fff; text-shadow: 0 0 8px var(--theme-color-1); border-bottom: 1px dashed var(--theme-color-1); }
.card.frame-neon .typology-item { background: transparent; border-left: 2px solid var(--theme-color-1); color: #fff; }
.card.frame-gold .card-module { background: #fffdf5; border: 2px solid #d4af37; border-radius: 8px; box-shadow: 0 4px 15px rgba(212, 175, 55, 0.15); }
.card.frame-gold .module-title { color: #b8860b; border-bottom: 2px double #d4af37; text-align: center; }
.card.frame-ryousan .card-module { background: #fff0f5; border: 3px dashed #ffb6c1; border-radius: 24px; box-shadow: 0 4px 10px rgba(255, 182, 193, 0.2); }
.card.frame-ryousan .module-title { color: #ff69b4; border-bottom: 2px dotted #ff69b4; }
.card.frame-ryousan .typology-item { background: #fff; border-radius: 16px; border-left: none; border: 1px solid #ffe4e1;}
.card.frame-wa .card-module { background: #fdfaf4; border-top: 4px solid #8b4513; border-bottom: 4px solid #8b4513; border-left: none; border-right: none; border-radius: 0; }
.card.frame-wa .module-title { color: #5c4033; border-bottom: none; font-family: 'Shippori Mincho', serif; text-align: center;}
.card.frame-wa .typology-item { background: transparent; border-left: 3px solid #8b4513; border-radius: 0;}
.card.frame-pop .card-module { background: #fff; border: 3px solid #111; border-radius: 12px; box-shadow: 6px 6px 0 #111; }
.card.frame-pop .module-title { color: #111; border-bottom: 3px solid #111; font-weight: 900; }
.card.frame-pop .typology-item { border: 2px solid #111; background: #f0f0f0; box-shadow: 2px 2px 0 #111;}

.module-title { font-size: 0.95em; margin: 0 0 15px 0; text-transform: uppercase; letter-spacing: 1.5px; padding-bottom: 8px; display:flex; align-items:center; }
.module-content { 
  transform: scale(var(--mod-scale, 1)); 
  transform-origin: top center; /* 💡 上の中央を基準にすることで右へのズレを完全防止！ */
  width: calc(100% / var(--mod-scale, 1)); 
}

.typology-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.typology-item { background: rgba(255,255,255,0.8); padding: 12px 16px; border-radius: 12px; border-left: 5px solid var(--theme-color-1); flex: 1 1 150px; box-shadow: 0 2px 8px rgba(0,0,0,0.02);}
.typology-item .label { font-size: 0.75em; opacity: 0.8; text-transform: uppercase; }
.typology-item .value { font-size: 1.15em; font-weight: bold; margin-top: 4px; }
.official-badge { display: inline-block; background: #fff3cd; color: #856404; font-size: 0.65em; padding: 3px 8px; border-radius: 12px; margin-left: 8px; vertical-align: middle; text-shadow:none;}

.graph-box { position: relative; width: 100%; height: var(--mod-height, 220px); display: flex; justify-content: center; align-items: center;}
.dicho-wrap { display: flex; flex-direction: column; justify-content: space-evenly; height: 100%; width: 100%;}
.dicho-bar-wrap { margin-bottom: 0; width: 100%;}
.dicho-labels { display: flex; justify-content: space-between; font-weight: bold; font-size: 0.9em; margin-bottom: 5px; color: inherit;}
.dicho-labels .val-txt { font-weight: normal; font-size: 0.85em; opacity: 0.6; margin: 0 4px;}
.dicho-track { width: 100%; height: 12px; background: rgba(0,0,0,0.08); border-radius: 6px; position: relative; }
.dicho-fill { height: 100%; background: var(--theme-bg); position: absolute; border-radius:6px; transition: 0.3s; }
.dicho-thumb { position: absolute; top: 50%; width: 18px; height: 18px; background: #fff; border: 3px solid var(--theme-color-1); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: 0.3s; }

.function-order-box { background: rgba(var(--theme-color-rgb), 0.1); padding: 10px; border-radius: 12px; text-align: center; margin-bottom: 10px; font-weight: bold; }
.free-space-box { white-space: pre-wrap; font-size: 1em; line-height: 1.6; }

footer { text-align: center; padding: 30px; background: #fff; margin-top: 40px; border-top: 1px solid var(--border-color); }
.footer-links a { display: inline-block; text-decoration: none; color: var(--theme-color-1); font-weight: bold; margin-bottom: 20px; padding: 10px 20px; border: 2px solid var(--theme-color-1); border-radius: 30px; transition: 0.2s; }
.footer-links a:hover { background: var(--theme-color-1); color: #fff; }

.modal-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); backdrop-filter:blur(5px); display:flex; justify-content:center; align-items:center; z-index: 2000; opacity: 0; visibility: hidden; transition: 0.3s; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background: #fff; padding: 30px; border-radius: 20px; max-width: 400px; text-align: center; box-shadow: 0 15px 40px rgba(0,0,0,0.2); transform: translateY(20px); transition: 0.3s;}
.modal-overlay.show .modal-content { transform: translateY(0); }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: rgba(30,30,30,0.9); backdrop-filter: blur(5px); color: white; padding: 15px 30px; border-radius: 30px; font-weight: bold; box-shadow: 0 10px 30px rgba(0,0,0,0.2); transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); z-index: 1000; opacity: 0; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* スマホ用レスポンシブ (自動スケールで完全に見切れ防止！) */
@media (max-width: 1100px) {
  .main-container { flex-direction: column; padding: 15px; gap: 20px;}
  .editor-panel { flex: 1 1 100%; width: 100%; box-sizing: border-box; max-height: none !important;}
  .preview-panel { width: 100%; padding-bottom: 20px; overflow: visible; }
  .preview-scale-box { width: 100%; overflow: hidden; position: relative; }
  .cards-wrapper { width: 900px; transform-origin: top left; margin: 0; }
  .mobile-only { display: inline; color: #ff7675; font-weight: bold;}
}
/* 🌟 グラフのキャンバスが勝手に小さくなるのを防ぐ絶対指定！ */
.graph-box canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}
/* ↩️ 改行パーツのデザイン */
.drag-item-break {
  background: #f8f9fa;
  border: 1px dashed #b2bec3;
  color: #636e72;
}
.drag-item-break span { font-size: 0.85em; font-weight: bold; }

/* 🖱️ ドラッグ中の要素（ゴースト）が変な形・位置になるのを防ぎ、綺麗に浮かせる！ */
.sortable-fallback {
  opacity: 1 !important;
  box-shadow: 0 15px 30px rgba(0,0,0,0.2) !important;
  z-index: 9999 !important;
  background: #fff !important;
  cursor: grabbing !important;
  border-radius: 8px !important;
}
