/* ==========================================
   1. 註冊 8 款專屬字體 (已修正為專屬的 .woff 格式)
   ========================================== */
@font-face {
    font-family: 'df_font_01';
    src: url('assets/fonts/font_01-cute.woff') format('woff'); 
}
@font-face {
    font-family: 'df_font_02';
    /* 雅痞體保留呼叫蘋果內建字型的防呆機制 */
    src: local('Yuppie TC'), local('YuppieTC-Regular'), local('雅痞-繁'),
         url('assets/fonts/font_02_yuppie.woff') format('woff');
}
@font-face {
    font-family: 'df_font_03';
    src: url('assets/fonts/font_03_notoserif.woff') format('woff');
}
@font-face {
    font-family: 'df_font_04';
    src: url('assets/fonts/font_04_notosanstc.woff') format('woff');
}
@font-face {
    font-family: 'df_font_05';
    src: url('assets/fonts/font_05_notosanstc_bold.woff') format('woff');
}
@font-face {
    font-family: 'df_font_06';
    src: url('assets/fonts/font_06_aryenti.woff') format('woff');
}
@font-face {
    font-family: 'df_font_07';
    src: url('assets/fonts/font_07_weibei.woff') format('woff');
}
@font-face {
    font-family: 'df_font_08';
    src: url('assets/fonts/font_08_dfhanzipen.woff') format('woff');
}

/* ==========================================
   2. 基礎重置與手機版優化
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'df_font_04', 'Helvetica Neue', Arial, sans-serif; /* 預設使用思源黑體 Normal */
    -webkit-tap-highlight-color: transparent; 
}

body {
    background-color: #faf9f6; /* 溫潤的米白底色 */
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 430px; 
    min-height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0,0,0,0.02);
}

.canvas-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #f0ebe1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.control-panel {
    padding: 20px 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-title {
    font-size: 0.85rem;
    color: #8c7b70; /* 柔和的棕灰色 */
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* 橫向滑動選單 */
.scroll-tabs {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 8px;
    scrollbar-width: none; 
}
.scroll-tabs::-webkit-scrollbar { display: none; }

.color-btn, .font-btn {
    flex: 0 0 auto;
    padding: 10px 18px;
    border: 1px solid #e6e2d8;
    border-radius: 20px;
    background: #fff;
    color: #5c554d;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.color-btn.active, .font-btn.active {
    background: #cda788; /* 淺木頭暖色調 */
    color: #fff;
    border-color: #cda788;
}

/* 專屬於字體的展開式網格 (一排3個，自動換行) */
.font-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* [修正版] 微調字體按鈕，確保按鈕本身顯示該字體的預覽且消除擠壓感 */
.font-grid .font-btn {
    padding: 10px 6px; /* [核心修正1] 增加左右內距：消除長字串擠壓感 */
    font-size: 0.85rem;
    text-align: center;
    font-family: inherit; /* [核心修正2] 強制繼承：確保按鈕本身變成字體預覽 */
    transition: all 0.2s ease;
}

/* 輸入框設計 */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group.row-1 {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 65px;
    border: 1px dashed #cda788;
    border-radius: 8px;
    background: #faf9f6;
    color: #8c7b70;
    font-size: 0.8rem;
}

.input-wrapper {
    flex-grow: 1;
    position: relative;
    display: flex;
}

input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e6e2d8;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    color: #5c554d;
    background: #faf9f6;
}
input[type="text"]:focus {
    border-color: #cda788;
    background: #ffffff;
}

.word-count {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #b5aba3;
    pointer-events: none; 
}

.download-btn {
    margin-top: auto;
    width: 100%;
    padding: 16px;
    background-color: #cda788;
    color: white;
    font-size: 1.05rem;
    letter-spacing: 1px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(205, 167, 136, 0.25);
}

/* ==========================================
   [新增] 插圖抽屜專屬樣式 (Bottom Sheet)
   ========================================== */

/* 半透明黑底遮罩 */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.drawer-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* 抽屜本體 */
.icon-drawer {
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    z-index: 100;
    padding: 20px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-height: 60vh;
    display: flex;
    flex-direction: column;
}
.icon-drawer.show {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0; /* [修正] 防止被圖片網格擠壓消失 */
}
.drawer-header h3 {
    color: #5c554d;
    font-size: 1.1rem;
}
.close-btn {
    background: none; border: none; font-size: 1.2rem; color: #999;
}

.drawer-tabs {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    flex-shrink: 0; /* [修正] 防止被圖片網格擠壓消失 */
}
.tab-btn {
    padding: 6px 12px;
    border: none; background: none; color: #888; font-size: 0.9rem;
    border-radius: 15px;
}
.tab-btn.active {
    background: #e6e2d8; color: #5c554d; font-weight: bold;
}

/* 圖片網格：一排 4 個，確保在手機上好點擊 */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    overflow-y: auto; 
    flex-grow: 1;
    padding-bottom: 10px;
}
.icon-item {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #faf9f6;
    border: 1px solid #e6e2d8;
    border-radius: 10px;
    display: flex; justify-content: center; align-items: center;
    padding: 8px;
}
.icon-item img {
    max-width: 100%; max-height: 100%;
}
.icon-item.selected {
    border: 2px solid #cda788;
    background: #fff8f3;
}

.drawer-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}
.remove-icon-btn {
    width: 100%; padding: 12px;
    background: #f5f5f5; color: #888;
    border: none; border-radius: 10px; font-size: 0.95rem;
}

/* 免責聲明文字 */
.disclaimer-text {
    font-size: 0.75rem;
    color: #a8a09a;
    line-height: 1.5;
    text-align: justify;
    margin-bottom: 5px;
    padding: 0 5px;
}

/* ==========================================
   [新增] 雙日期輸入框排版
   ========================================== */
.row-date {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-input {
    flex: 1;
    width: 100%;
    padding: 12px 10px;
    border: 1px solid #e6e2d8;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    color: #5c554d;
    background: #faf9f6;
    font-family: inherit;
    /* 移除 iOS 預設的怪異陰影 */
    -webkit-appearance: none; 
}
.date-input:focus {
    border-color: #cda788;
    background: #ffffff;
}

.date-dash {
    color: #8c7b70;
    font-weight: bold;
}