:root {
    --ios-bg: #fdf7ff;
    --ios-card: #ffffff;
    --una-primary: #af7AC5;
    --danger-red: #ff3b30;
    --success-green: #34c759;
    --warning-bg: #ffe5e5;
}

body {
    font-family: -apple-system, system-ui, sans-serif;
    background-color: var(--ios-bg);
    margin: 0; padding: 15px;
    padding-top: env(safe-area-inset-top);
    -webkit-tap-highlight-color: transparent;
    
    /* --- 置中 Container 效果 --- */
    max-width: 1000px;  /* 限制最大寬度，避免電腦螢幕太寬 */
    margin: 0 auto;     /* 左右自動留白置中 */
}

/* 頂部標題區 */
.header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 15px; 
    padding: 0 5px;
}

.header h1 { 
    font-size: 22px; 
    color: var(--una-primary); 
    margin: 0; 
    font-weight: 800; 
}

.all-stop-btn {
    background-color: #8e8e93;
    color: white; border: none; padding: 6px 12px;
    border-radius: 8px; font-weight: bold; cursor: pointer; font-size: 11px;
    flex-shrink: 0;
}

/* 列表排版 */
#timerList {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* --- 手機打橫瘦身計畫 + 左右留白 --- */
@media (min-width: 500px) and (max-height: 500px) {
    body {
        /* 在手機打橫時，縮小 Container 寬度讓左右留白更多 */
        max-width: 85%; 
    }

    #timerList { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 10px !important;
        padding-bottom: 70px !important; 
    }

    .header {
        padding: 5px 10px !important;
        margin-bottom: 8px !important;
    }

    .header h1 { font-size: 18px !important; }

    .timer-card {
        min-height: auto !important;
        padding: 10px !important;
        /* 讓卡片本身不要太寬，靠 Grid 自動分配空間 */
    }

    .time-display {
        font-size: 28px !important;
        margin: 4px 0 !important;
    }

    .card-icon { font-size: 20px !important; }
    .card-title { font-size: 14px !important; }
    
    .btn { padding: 8px 5px !important; font-size: 12px !important; }
    .btn-reset { width: 35px !important; }

    .add-fab {
        width: 45px !important;
        height: 45px !important;
        bottom: 20px !important;
        right: 7% !important; /* 讓按鈕也往中間靠一點，才不會離卡片太遠 */
        opacity: 0.6;
    }
}

/* 平板與電腦排版 */
@media (min-width: 1024px) {
    #timerList { grid-template-columns: repeat(4, 1fr); }
}

/* 卡片基礎樣式 */
.timer-card {
    background: var(--ios-card);
    border-radius: 20px; padding: 16px;
    box-shadow: 0 4px 12px rgba(175, 122, 197, 0.12);
    border: 2px solid transparent;
    display: flex; flex-direction: column; justify-content: space-between;
    min-height: 160px;
}

.timer-card.warning-alert {
    background-color: var(--warning-bg);
    border: 2px solid var(--danger-red);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-header-left { flex: 1; cursor: pointer; }
.card-header-top { display: flex; align-items: center; gap: 6px; }
.card-icon { font-size: 24px; }
.card-title { font-weight: bold; font-size: 16px; color: #333; }
.card-note { 
    font-size: 11px; color: var(--una-primary); background: #f4ebf7; 
    padding: 2px 6px; border-radius: 4px; display: inline-block; margin-top: 4px; 
}

.delete-btn { color: #d1d1d6; font-size: 22px; padding: 0 0 10px 10px; cursor: pointer; }

.time-display {
    font-size: 42px; font-weight: 800; font-family: 'SF Mono', monospace;
    text-align: center; margin: 10px 0; color: #1c1c1e;
    font-variant-numeric: tabular-nums;
}

/* 按鈕樣式 */
.card-footer { display: flex; gap: 8px; }
.btn { 
    flex: 1; padding: 12px 5px; border: none; border-radius: 12px; 
    font-weight: bold; cursor: pointer; font-size: 14px; 
    display: flex; align-items: center; justify-content: center; 
}
.btn-start { background: var(--success-green); color: white; }
.btn-pause { background: #ff9500; color: white; }
.btn-restart { background: var(--una-primary); color: white; }
.btn-reset { background: #e5e5ea; color: #333; font-size: 18px; width: 45px; flex: 0.35; }

/* Modal 彈窗 */
.modal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.5); align-items: center; justify-content: center; 
    z-index: 100; backdrop-filter: blur(4px); 
}
.modal-content { 
    background: white; width: 85%; max-width: 380px; border-radius: 24px; 
    padding: 20px; display: flex; flex-direction: column; gap: 12px; 
}

.modal-header { font-size: 18px; font-weight: 800; color: var(--una-primary); text-align: center; }
.input-row { display: flex; gap: 8px; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.input-group label { font-size: 10px; color: #8e8e93; text-align: center; }
input, select { 
    padding: 12px; border: 1px solid #efefef; border-radius: 10px; 
    font-size: 15px; background: #f5f5f7; width: 100%; box-sizing: border-box; 
}
.modal-footer { display: flex; gap: 10px; margin-top: 5px; }
.btn-confirm { background: var(--una-primary); color: white; flex: 2; }
.btn-cancel { background: #e5e5ea; color: #333; flex: 1; }

/* 右下角新增按鈕 (FAB) */
.add-fab { 
    position: fixed; bottom: 30px; right: 30px; width: 60px; height: 60px; 
    background: var(--una-primary); color: white; border-radius: 30px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 30px; box-shadow: 0 6px 15px rgba(175, 122, 197, 0.4); 
    z-index: 10; transition: all 0.2s;
}
.add-fab:active { transform: scale(0.9); opacity: 1; }

/* 空狀態 */
.empty-state { 
    display: flex; flex-direction: column; align-items: center; 
    justify-content: center; margin-top: 80px; color: #aeaeb2; text-align: center; 
}