body {
    font-family: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
    padding: 20px;
    box-sizing: border-box;
}
.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 900px;
    text-align: center;
    box-sizing: border-box;
}
h1 {
    color: #1E88E5;
    margin-bottom: 25px;
    font-size: 2.5em;
}
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    align-items: center;
}
label {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
}
input[type="text"] {
    width: calc(100% - 40px);
    padding: 12px 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1.1em;
    box-sizing: border-box;
    max-width: 600px;
}
button {
    background-color: #1E88E5;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(30, 136, 229, 0.3);
}
button:hover {
    background-color: #1565C0;
    transform: translateY(-2px);
}
.result-area {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 30px;
    text-align: left;
}
.loading {
    display: none;
    margin-top: 20px;
    color: #666;
    font-size: 1.1em;
}
.error-message {
    color: #D32F2F;
    margin-top: 20px;
    font-weight: bold;
}
img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    margin-top: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
a {
    display: inline-block;
    margin-top: 20px;
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}
a:hover {
    background-color: #218838;
}

/* 讓結果表單的內容靠左對齊 */
#regenerateForm {
    align-items: flex-start;
}

/* --- 編輯功能樣式 --- */
.editable-field {
    display: flex;
    align-items: center; /* 垂直置中對齊 */
    gap: 10px;          /* 項目之間的間距 */
    margin-bottom: 15px;/* 每個欄位之間的間距 */
    width: 100%;        /* 新增：確保此容器佔滿父元素的全部寬度 */
}

.editable-field label {
    font-weight: bold;
    margin-bottom: 0;   /* 覆蓋 label 的預設 margin */
    flex-shrink: 0;     /* 防止 label 在空間不足時被壓縮 */
}

.editable-field .text-display,
.editable-field .editable-input {
    flex-grow: 1;       /* 讓文字和輸入框填滿剩餘空間 */
    border: 1px solid transparent; /* 預設無邊框 */
    background-color: transparent; /* 預設透明背景 */
    padding: 2px;
    font-family: inherit; /* 繼承字體 */
    font-size: inherit;   /* 繼承字體大小 */
    color: inherit;       /* 繼承文字顏色 */
    resize: vertical;     /* 允許 textarea 垂直調整大小 */
}

/* 當輸入框不是 readonly (即編輯模式) 時，顯示邊框 */
.editable-field .editable-input:not([readonly]) {
    border: 1px solid #ccc;
    background-color: #fff;
}

.editable-field .edit-btn,
.editable-field .save-btn {
    padding: 2px 8px;       /* 縮小內邊距 */
    font-size: 0.9em;       /* 縮小字體 */
    box-shadow: none;       /* 移除陰影 */
    min-width: 50px;        /* 設定最小寬度，避免文字換行 */
    background-color: #546E7A; /* 改為較中性的顏色 */
}


/* RWD 調整 */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }
    input[type="text"] {
        width: calc(100% - 20px);
        padding: 10px;
    }
    button {
        padding: 10px 20px;
        font-size: 1em;
    }
    .container {
        padding: 20px;
    }
}
