:root {
    /* Light theme - 护眼色系 */
    --primary-bg: #f7f9fa;
    --card-bg: linear-gradient(145deg, #fefdf8 0%, #f9f7f1 100%);
    --text-color: #2d3748;
    --accent-color: #4c51bf;
    --border-color: #e2e8f0;
    --text-muted: #718096;
    --success-color: #38a169;
    --warning-color: #ed8936;
    
    /* Catppuccin Latte colors */
    --ctp-rosewater: 220, 138, 120;
    --ctp-flamingo: 221, 120, 120;
    --ctp-pink: 234, 118, 203;
    --ctp-mauve: 136, 57, 239;
    --ctp-red: 210, 15, 57;
    --ctp-maroon: 230, 69, 83;
    --ctp-peach: 254, 100, 11;
    --ctp-yellow: 223, 142, 29;
    --ctp-green: 64, 160, 43;
    --ctp-teal: 23, 146, 153;
    --ctp-sky: 4, 165, 229;
    --ctp-sapphire: 32, 159, 181;
    --ctp-blue: 30, 102, 245;
    --ctp-lavender: 114, 135, 253;
    --ctp-text: 76, 79, 105;
    --ctp-subtext1: 92, 95, 119;
    --ctp-subtext0: 108, 111, 133;
    --ctp-overlay2: 124, 127, 147;
    --ctp-overlay1: 140, 143, 161;
    --ctp-overlay0: 156, 160, 176;
    --ctp-surface2: 172, 176, 190;
    --ctp-surface1: 188, 192, 204;
    --ctp-surface0: 204, 208, 218;
    --ctp-base: 239, 241, 245;
    --ctp-mantle: 230, 233, 239;
    --ctp-crust: 220, 224, 232;
}

.theme-dark {
    /* Dark theme - Catppuccin Mocha colors */
    --primary-bg: #1e1e2e;
    --card-bg: #313244;
    --text-color: #cdd6f4;
    --accent-color: rgb(137, 180, 250);
    --border-color: #45475a;
    --text-muted: #a6adc8;
    --success-color: rgb(166, 227, 161);
    --warning-color: rgb(249, 226, 175);
    
    /* Catppuccin Mocha colors */
    --ctp-rosewater: 245, 224, 220;
    --ctp-flamingo: 242, 205, 205;
    --ctp-pink: 245, 194, 231;
    --ctp-mauve: 203, 166, 247;
    --ctp-red: 243, 139, 168;
    --ctp-maroon: 235, 160, 172;
    --ctp-peach: 250, 179, 135;
    --ctp-yellow: 249, 226, 175;
    --ctp-green: 166, 227, 161;
    --ctp-teal: 148, 226, 213;
    --ctp-sky: 137, 220, 235;
    --ctp-sapphire: 116, 199, 236;
    --ctp-blue: 137, 180, 250;
    --ctp-lavender: 180, 190, 254;
    --ctp-text: 205, 214, 244;
    --ctp-subtext1: 186, 194, 222;
    --ctp-subtext0: 166, 173, 200;
    --ctp-overlay2: 147, 153, 178;
    --ctp-overlay1: 127, 132, 156;
    --ctp-overlay0: 108, 112, 134;
    --ctp-surface2: 88, 91, 112;
    --ctp-surface1: 69, 71, 90;
    --ctp-surface0: 49, 50, 68;
    --ctp-base: 30, 30, 46;
    --ctp-mantle: 24, 24, 37;
    --ctp-crust: 17, 17, 27;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, rgb(var(--ctp-base)) 0%, rgb(var(--ctp-mantle)) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.app-container {
    width: 100%;
    max-width: 500px;
    background: rgba(135, 206, 235, 0.1); /* Light blue instead of gray */
    border-radius: 16px;
    border: 1px solid rgba(var(--ctp-overlay0), 0.3);
    padding: 32px;
    text-align: center;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(20px);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 16px;
}

h1 {
    margin: 0;
    background: linear-gradient(135deg, rgb(var(--ctp-blue)), rgb(var(--ctp-lavender)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
    text-align: left;
}

.header-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#importer-section {
    padding: 40px 20px;
}

#importer-section p {
    margin-bottom: 24px;
    font-size: 1rem;
    line-height: 1.6;
    color: rgb(var(--ctp-subtext1));
}

#json-file-input {
    display: none;
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(var(--ctp-blue), 0.2);
    color: rgb(var(--ctp-blue));
    border: 1px solid rgba(var(--ctp-blue), 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.file-upload-label:hover {
    transform: translateY(-1px);
    background-color: rgb(var(--ctp-blue));
    color: white;
    box-shadow: 0 4px 12px 0 rgba(var(--ctp-blue), 0.3);
}

#flashcard-main {
    display: none;
}

#unit-selection-section {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(135, 206, 235, 0.15); /* Light blue instead of blue */
    border-radius: 8px;
    border: 1px solid rgba(135, 206, 235, 0.3);
}

#unit-selection-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: rgb(var(--ctp-text));
    font-size: 0.85rem;
    text-align: left;
}

#unit-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(var(--ctp-overlay0), 0.5);
    font-size: 0.9rem;
    background: rgba(135, 206, 235, 0.1); /* Light blue instead of gray */
    color: rgb(var(--ctp-text));
    transition: all 0.2s ease;
}

#unit-select:focus {
    outline: none;
    border-color: rgb(var(--ctp-blue));
    box-shadow: 0 0 0 3px rgba(var(--ctp-blue), 0.2);
}

.flashcard {
    background: transparent;
    width: 100%;
    height: 260px;
    perspective: 1000px;
    margin: 24px 0;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.flashcard.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    padding: 32px 24px;
    font-size: 1.25rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.card-front {
    background: var(--card-bg); /* Use the yellow gradient */
    color: rgb(var(--ctp-text));
    border: 2px solid rgba(var(--ctp-overlay0), 0.3);
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-back {
    background: linear-gradient(135deg, rgb(var(--ctp-blue)), rgb(var(--ctp-lavender)));
    color: white;
    transform: rotateY(180deg);
    box-shadow: 
        0 10px 15px -3px rgba(var(--ctp-blue), 0.3),
        0 4px 6px -2px rgba(var(--ctp-blue), 0.2);
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 16px;
}

button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: rgba(135, 206, 235, 0.2); /* Light blue instead of gray */
    color: rgb(var(--ctp-text));
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(135, 206, 235, 0.4);
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-1px);
    background: rgba(135, 206, 235, 0.3); /* Light blue instead of gray */
    border-color: rgba(135, 206, 235, 0.5);
    box-shadow: 0 4px 12px 0 rgba(135, 206, 235, 0.2);
}

button:active {
    transform: translateY(0);
}

.header-controls button {
    padding: 8px 12px;
    font-size: 0.8rem;
    min-width: 50px;
}

/* 主要操作按钮 - 蓝色系 */
#theme-btn {
    background: rgba(var(--ctp-blue), 0.2);
    color: rgb(var(--ctp-blue));
    border: 1px solid rgba(var(--ctp-blue), 0.4);
    font-size: 1rem;
    padding: 8px 10px;
}

#theme-btn:hover {
    background: rgba(var(--ctp-blue), 0.3);
    color: white;
    background-color: rgb(var(--ctp-blue));
    box-shadow: 0 4px 12px 0 rgba(var(--ctp-blue), 0.3);
}

.navigation button {
    flex: 1;
    background: rgba(var(--ctp-blue), 0.2);
    color: rgb(var(--ctp-blue));
    border: 1px solid rgba(var(--ctp-blue), 0.4);
}

.navigation button:hover {
    background-color: rgb(var(--ctp-blue));
    color: white;
    box-shadow: 0 4px 12px 0 rgba(var(--ctp-blue), 0.3);
}

/* 警告操作按钮 - 黄色系 */
#shuffle-btn {
    background: rgba(var(--ctp-yellow), 0.2);
    color: rgb(var(--ctp-text));
    border: 1px solid rgba(var(--ctp-yellow), 0.4);
}

#shuffle-btn:hover {
    background-color: rgb(var(--ctp-yellow));
    color: rgb(var(--ctp-base));
    box-shadow: 0 4px 12px 0 rgba(var(--ctp-yellow), 0.3);
}

/* 切换按钮 - 紫色系 */
.mode-btn {
    background: rgba(var(--ctp-mauve), 0.2);
    color: rgb(var(--ctp-mauve));
    border: 1px solid rgba(var(--ctp-mauve), 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
}

.mode-btn:hover {
    background-color: rgb(var(--ctp-mauve));
    color: white;
    box-shadow: 0 4px 12px 0 rgba(var(--ctp-mauve), 0.3);
}

#progress {
    font-size: 1rem;
    font-weight: 500;
    color: rgb(var(--ctp-text));
    flex: 0 0 auto;
    min-width: 80px;
    padding: 10px 16px;
    background: rgba(135, 206, 235, 0.15); /* Light blue instead of gray */
    border-radius: 8px;
    margin: 0;
    border: 1px solid rgba(135, 206, 235, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

#progress:hover {
    background: rgba(135, 206, 235, 0.25); /* Light blue instead of gray */
    transform: translateY(-1px);
}

.progress-input {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(135, 206, 235, 0.95); /* Light blue instead of gray */
    border: 2px solid rgba(var(--ctp-blue), 0.4);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1000;
    min-width: 280px;
}

.progress-input.show {
    display: block;
}

.progress-input h3 {
    margin: 0 0 16px 0;
    color: rgb(var(--ctp-text));
    font-size: 1.1rem;
    text-align: center;
}

.progress-input input {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(var(--ctp-overlay0), 0.3);
    border-radius: 6px;
    background: rgba(135, 206, 235, 0.2); /* Light blue instead of gray */
    color: rgb(var(--ctp-text));
    font-size: 1rem;
    margin-bottom: 16px;
    text-align: center;
}

.progress-input .button-group {
    display: flex;
    gap: 12px;
}

.progress-input button {
    flex: 1;
    padding: 12px;
    font-size: 0.9rem;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.overlay.show {
    display: block;
}

/* Touch feedback */
button:active,
.file-upload-label:active,
#progress:active {
    transform: scale(0.98);
}

/* 移动端优化 */
@media (max-width: 480px) {
    .app-container {
        padding: 20px;
        margin: 12px;
        border-radius: 12px;
    }
    
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    h1 {
        text-align: center;
        font-size: 1.3rem;
    }
    
    .header-controls {
        justify-content: center;
        gap: 12px;
    }
    
    .header-controls button {
        min-width: 60px;
        padding: 12px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    #theme-btn {
        font-size: 1.1rem;
    }
    
    .flashcard {
        height: 220px;
        margin: 20px 0;
        border-radius: 12px;
        /* 防止选择文本 */
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        /* 禁用默认触摸行为 */
        touch-action: pan-y;
    }
    
    .card-face {
        font-size: 1.1rem;
        padding: 20px 16px;
        border-radius: 12px;
    }
    
    .navigation {
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 20px;
    }
    
    .navigation button {
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 10px;
        min-height: 48px;
    }
    
    #progress {
        order: -1;
        width: 100%;
        text-align: center;
        padding: 14px 16px;
        font-size: 1.1rem;
        border-radius: 10px;
        min-height: 48px;
    }
    
    #unit-selection-section {
        margin-bottom: 20px;
        padding: 16px;
        border-radius: 10px;
    }
    
    #unit-select {
        padding: 12px;
        font-size: 1rem;
        border-radius: 8px;
        min-height: 44px;
    }
    
    .progress-input {
        min-width: 320px;
        margin: 0 16px;
        max-width: calc(100vw - 32px);
    }
    
    .progress-input input {
        padding: 16px;
        font-size: 1.1rem;
        min-height: 48px;
    }
    
    .progress-input button {
        padding: 16px;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    .app-container {
        padding: 16px;
        margin: 8px;
    }
    
    .flashcard {
        height: 200px;
    }
    
    .card-face {
        font-size: 1rem;
        padding: 16px 12px;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .header-controls button {
        width: 100%;
        min-width: auto;
    }
}

/* 添加滑动提示 */
.swipe-hint {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(var(--ctp-subtext1), 0.7);
    font-size: 0.8rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flashcard:hover .swipe-hint {
    opacity: 1;
}

@media (max-width: 480px) {
    .swipe-hint {
        bottom: -35px;
        font-size: 0.75rem;
    }
}
