@font-face {
    font-family: 'StarfruitCelesSerif-Bold';
    src: url('../fonts/StarfruitCelesSerif-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

/* 確保預覽畫面的字體能套用 */
svg text {
    text-rendering: optimizeLegibility;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f0f2f5; margin: 0; color: #333; height: 100vh; overflow: hidden; }
.main-container { display: flex; gap: 20px; padding: 20px; box-sizing: border-box; height: 100%; }

/* 控制面板與標題整合 */
.control-panel { width: 360px; flex-shrink: 0; background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); display: flex; flex-direction: column; box-sizing: border-box; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #eaeaea; }
.panel-header h2 { margin: 0; font-size: 18px; color: #1a202c; font-weight: 700; }
.panel-header select { padding: 4px 8px; border-radius: 6px; border: 1px solid #cbd5e1; background: #f8fafc; outline: none; cursor: pointer; font-size: 12px; color: #475569; }

#pdfForm { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.form-scroll-area { flex: 1; overflow-y: auto; padding-right: 5px; margin-bottom: 10px; }
.action-area { flex-shrink: 0; padding-top: 10px; border-top: 1px solid #eee; }

.preview-panel { flex: 1; background: #e0e4e8; border-radius: 12px; display: flex; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; overflow: hidden; }
canvas { background: white; box-shadow: 0 10px 40px rgba(0,0,0,0.15); max-width: 100%; max-height: 100%; object-fit: contain; }

.form-group { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.col { flex: 1; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #555; }
select, input[type="number"], input[type="color"] { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-size: 14px; outline: none; }
select:focus, input[type="number"]:focus { border-color: #2b6cb0; }
button { width: 100%; background: #2b6cb0; color: white; border: none; padding: 14px; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: 0.2s; }
button:hover { background: #2c5282; }

.stats { background: #edf2f7; padding: 12px; border-radius: 8px; font-size: 13px; color: #4a5568; line-height: 1.6; border: 1px solid #e2e8f0; margin-bottom: 15px;}
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid #eee; margin: 15px 0; }

.color-picker-ui { display: flex; align-items: center; justify-content: space-between; background: #f9f9fb; padding: 8px; border-radius: 8px; border: 1px solid #e2e8f0; }
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.color-custom { display: flex; align-items: center; gap: 6px; border-left: 1px solid #ddd; padding-left: 10px; }
.color-custom input[type="color"] { width: 30px; height: 24px; padding: 0; border: none; background: none; cursor: pointer; border-radius: 4px; }

/* === 手機版 RWD === */
@media (max-width: 768px) {
    body { height: auto; overflow: auto; }
    .main-container { flex-direction: column; padding: 10px; height: auto; }
    .control-panel { width: 100%; height: auto; }
    .form-scroll-area { overflow-y: visible; }
    .preview-panel { width: 100%; min-height: 400px; order: -1; }
}