* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #f8f9fa;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部标题 */
.page-header {
  text-align: center;
  padding: 24px 20px 16px;
  background: white;
}

.page-header h1 {
  font-size: 2.2rem;
  color: #3498db;
  margin-bottom: 8px;
}

.page-header p {
  font-size: 1rem;
  color: #95a5a6;
}

.container {
  display: flex;
  flex: 1;
  max-width: 3600px;
  margin: 0 auto;
  width: 100%;
  gap: 24px;
  padding: 0 20px 20px;
}

/* 左右两栏 */
.left-panel, .right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  background: #3498db;
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
}

.panel-body {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 左侧控制区 */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.controls label {
  font-weight: 600;
}

.controls select, .controls input[type="color"], .controls input[type="text"] {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  font-size: 14px;
  outline: none;
}

.controls input[type="color"] {
  width: 40px;
  height: 30px;
  padding: 0;
  cursor: pointer;
}

textarea {
  flex: 1;
  min-height: 300px;
  padding: 12px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid #ddd;
  border-radius: 8px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 右侧导出区 */
.export-controls {
  display: flex;
  justify-content: flex-end; /* ← 右对齐 */
  gap: 12px;
  margin-bottom: 16px;
}

select, button {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

button {
  cursor: pointer;
  background: #3498db;
  color: white;
  border: none;
  font-weight: 500;
  transition: background 0.2s;
}

button:hover:not(:disabled) {
  background: #2980b9;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 预览容器 — 关键：宽度自适应 + 居中 */
.preview-wrapper {
  display: flex;
  justify-content: center;
}

.preview-container {
  display: inline-block;
  min-width: 300px; /* 防止过窄 */
  max-width: 100%;
  padding: 26px;
  /* background-color 由 JS 控制，初始为透明渐变 */
  background-size: cover;
  background-position: center;
}

.code-preview {
  padding: 15px;
  padding-bottom: 26px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: white;
}

.window-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #2d2d2d;
  border-radius: 4px;
  color: #ccc;
  font-size: 12px;
}

.window-buttons {
  display: flex;
  gap: 6px;
}

.window-btn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.close { background: #ff5f57; }
.minimize { background: #ffbd2e; }
.expand { background: #28c940; }

.window-title {
  flex: 1;
  text-align: center;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 500;
  font-size: 15px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 10px;
}

/* 代码输出 */
.code-output {
  flex: 1;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.45;
  color: #d4d4d4;
}

.code-output pre {
  margin: 0;
  padding: 0 8px;
  padding-right: 14px;
  background: none !important;
  white-space: pre-wrap;
  word-break: break-all;
  overflow: hidden;
}

.bg-light .code-preview {
  background: #f8f8f8;
  color: #333;
}
.bg-light .code-output,
.bg-light .code-output pre {
  color: #333;
}

/* 新增：统一美化 label（用于 controls 和 export-controls） */
.controls label,
.export-controls label {
  padding: 6px 10px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  margin-right: 4px;
}

footer {
text-align: center;
margin-bottom: 10px;
color: #666;
font-size: 0.9rem;
}
  
footer a,
footer a:visited,
footer a:hover,
footer a:active {
color: #666;
text-decoration: none;
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  .controls, .export-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .preview-wrapper {
    padding: 10px;
  }
}