/* ===== リセット & 基本レイアウト ===== */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body { 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== パネルレイアウト ===== */
.panel {
  display: flex;
  flex-direction: column;
  width: 50%;
  height: 100vh;
}

.panel-header {
  background: #2c3e50;
  color: white;
  padding: 15px 20px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}
.code-header {
  flex:1;
}

/* ===== コピーボタン ===== */
.copy-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #2980b9;
}

.copy-btn:active {
  background: #1c5a85;
}

.copy-btn.copied {
  background: #27ae60;
}

/* ===== コードエディタ ===== */
#code-input {
  flex: 1;
  border: none;
  padding: 20px;
  font-family: monospace;
  font-size: 15px;
  resize: none;
  background: #080808;
  color: #f0f0f0;
  line-height: 1.6;
  transition: background 0.2s, opacity 0.2s;
}

#code-input:focus {
  outline: 2px solid #3498db;
  outline-offset: -2px;
}

/* ===== プレビューコンテナ ===== */
#preview-container {
  flex: 1;
  background: #f5f5f5;
  overflow: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#svg-preview {
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#svg-preview svg {
  display: block;
  width: 640px;
  height: 360px;
  max-width: 100%;
  height: auto;
}

/* ===== プレビュー用視覚的フィードバック ===== */
#svg-preview .hover-highlight {
  outline: 1px dashed #0095d9;
}

#svg-preview .selected-element {
  outline: 2px solid #e74c3c;
}

/* ===== エラーメッセージ ===== */
#error-message {
  color: #e74c3c;
  padding: 10px;
  background: #fadbd8;
  margin: 10px;
  border-radius: 4px;
  display: none;
}

/* ===== テキストエディタ（ポップアップ） ===== */
#text-editor {
  position: fixed;
  background: white;
  border: 2px solid #0095d9;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  display: none;
}

#text-editor input {
  border: 1px solid #ddd;
  padding: 8px;
  font-size: 14px;
  width: 300px;
  font-family: 'Meiryo', sans-serif;
}

#text-editor button {
  margin-left: 8px;
  padding: 8px 16px;
  background: #0095d9;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

#text-editor button:hover {
  background: #007ab8;
}

/* ===== プロパティパネル ===== */
.property-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  background: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 250px;
  max-width: 300px;
  display: none;
  z-index: 100;
}

.property-panel h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: #2c3e50;
}

.property-item {
  margin-bottom: 10px;
}

.property-item label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.property-item input[type="color"],
.property-item input[type="number"],
.property-item select {
  width: 100%;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* ===== カラーパレット ===== */
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 2px solid #ddd;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.color-swatch:hover {
  transform: scale(1.1);
  border-color: #0095d9;
}

.color-swatch.selected {
  border-color: #0095d9;
  border-width: 3px;
}

.color-swatch::after {
  content: attr(data-class);
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #666;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.color-swatch:hover::after {
  opacity: 1;
}

.custom-color-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}

/* ===== defs表示欄 ===== */
#defs-display {
  background: #000;
  color: #ecf0f1;
  padding: 8px 10px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  max-height: 33%;
  overflow-y: auto;
  border-top: 1px solid #34495e;
}

#defs-display h4 {
  color: #3498db;
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 600;
}

#defs-content {
  white-space: pre-wrap;
  line-height: 1.5;
  color: #bdc3c7;
}

#defs-content .style-class {
  color: #e67e22;
}

#defs-content .style-property {
  color: #9b59b6;
}

#defs-content .style-value {
  color: #2ecc71;
}