:root {
    interpolate-size: allow-keywords;
    --primary-color: rgba(255, 255, 255, 0.9);
    --accent-color: #ff8a8a; /* 預設紅色 */
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-relax: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.theme-red { --accent-color: #ff8a8a; }
body.theme-blue { --accent-color: #8ab6ff; }
body.theme-green { --accent-color: #8affad; }
body.theme-yellow { --accent-color: #fffa8a; }
body.theme-purple { --accent-color: #d18aff; }
body.theme-orange { --accent-color: #ffb38a; }
body.theme-teal { --accent-color: #8afff2; }
body.theme-gray { --accent-color: #d1d1d1; }

/* 深色系擴充 */
body.theme-midnight { --accent-color: #1e3a5f; }
body.theme-espresso { --accent-color: #3e2723; }
body.theme-evergreen { --accent-color: #1b5e20; }
body.theme-bordeaux { --accent-color: #880e4f; }
body.theme-amethyst { --accent-color: #4a148c; }
body.theme-coal { --accent-color: #212121; }
body.theme-space { --accent-color: #0d1b2a; }
body.theme-graphite { --accent-color: #424242; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center; /* 改為居中，方便佈置雙面板 */
    padding: 20px;
    background-color: #1a1a1a;
}

/* 影片背景樣式 */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

#bg-video {
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    filter: brightness(0.7) blur(2px);
    transition: filter 1s ease;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.4) 100%);
}

/* 容器設計 */
.container {
    display: flex;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    justify-content: center;
    align-items: flex-start;
    animation: fadeIn 1.5s ease-out;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 40px;
    border: 1px solid var(--glass-border);
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s var(--transition-relax), width 0.5s var(--transition-relax), height 0.5s var(--transition-relax), background-color 0.5s var(--transition-relax);
    will-change: transform, width, height;
}

.glass-panel:hover {
    transform: translateY(-5px);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

header p {
    font-weight: 300;
    opacity: 0.8;
    margin-bottom: 20px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#status-text {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.fade-out {
    opacity: 0 !important;
    transform: translateY(5px);
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.lang-menu, .theme-menu {
    position: relative;
    display: inline-block;
}

.icon-toggle-btn, .theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.icon-toggle-btn:hover, .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.current-theme-dot {
    width: 10px;
    height: 10px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.icon-toggle-btn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 138, 138, 0.3);
    transform: scale(1.05);
}

.options-panel, .theme-options {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 50;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.5s var(--transition-bounce), opacity 0.4s var(--transition-relax);
    transform-origin: top center;
}

.options-panel.hidden, .theme-options.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-15px) scale(0.95);
    pointer-events: none;
}

.lang-option {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.lang-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lang-option.active {
    color: var(--accent-color);
    font-weight: 600;
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px;
}

.theme-options.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
}

.theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.theme-dot:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.theme-dot.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.theme-divider {
    grid-column: span 4;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 5px 0;
}

/* 進度環與時間顯示 */
.timer-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.8s ease-in-out;
    transform-origin: 50% 50%;
    filter: drop-shadow(0 0 8px var(--accent-color));
}

.timer-display {
    font-size: 5rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1;
}

/* 控制按鈕 */
.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
}

.btn {
    border: none;
    padding: 14px 28px;
    border-radius: 18px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.primary {
    background-color: white;
    color: #333;
}

.primary:hover {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 8px 25px rgba(255, 138, 138, 0.4);
    transform: translateY(-2px);
    letter-spacing: 0.5px;
}

.secondary {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.secondary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.3);
}

.secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 時間選擇器 */
.duration-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.duration-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: transform 0.4s var(--transition-relax), background-color 0.4s var(--transition-relax), box-shadow 0.4s var(--transition-relax);
    position: relative;
    overflow: hidden;
}

.duration-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.duration-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 138, 138, 0.4);
    color: white;
}

.tertiary {
    background-color: transparent;
    color: white;
    opacity: 0.6;
}

.tertiary:hover {
    opacity: 1;
    text-decoration: underline;
}

/* 模式切換 */
.modes {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 20px;
    gap: 5px;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: white;
    padding: 10px;
    border-radius: 15px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: transform 0.4s var(--transition-relax), opacity 0.4s var(--transition-relax), background-color 0.4s var(--transition-relax);
    opacity: 0.6;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    font-weight: 600;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

/* 動效 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.timer-display.running {
    animation: pulse 2s infinite ease-in-out;
    color: var(--accent-color);
}

/* 額外細節：捲軸隱藏 */
::-webkit-scrollbar {
    display: none;
}

/* 今日紀錄面板 */
.records-panel {
    flex: 1;
    max-width: 400px;
    height: 520px;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.records-panel h3 {
    margin-bottom: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 10px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.6;
    text-transform: uppercase;
}

.log-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.log-list::-webkit-scrollbar {
    width: 4px;
    display: block;
}

.log-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.log-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    border-left: 3px solid var(--accent-color);
}

.log-time {
    opacity: 0.5;
    font-size: 0.75rem;
    margin-bottom: 4px;
    display: block;
}

/* Modal 彈窗樣式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    max-width: 400px;
    width: 90%;
    transform: scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.8);
}

.modal-header h2 {
    margin-bottom: 10px;
    color: var(--accent-color);
}

.modal-body {
    margin: 30px 0;
}

.question {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.input-group input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 12px;
    width: 100px;
    color: white;
    font-size: 1.5rem;
    text-align: center;
    font-family: inherit;
    transition: all 0.3s ease;
    /* 隱藏原生 Spinner (Chrome, Safari, Edge, Opera) */
    appearance: textfield;
    -moz-appearance: textfield;
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 138, 138, 0.3);
}

/* 自訂增減按鈕 */
.num-ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.num-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.num-ctrl-btn:active {
    transform: scale(0.92);
}

.num-ctrl-btn svg {
    transition: all 0.3s ease;
}

.num-ctrl-btn:hover svg {
    filter: drop-shadow(0 0 5px var(--accent-color));
}

.input-group span {
    font-size: 1.2rem;
    opacity: 0.6;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.wisdom-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#wisdom-message {
    font-style: italic;
    margin-bottom: 20px;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* 響應式佈局最佳化 */
@media (max-width: 1100px) {
    .container {
        max-width: 900px;
        gap: 20px;
    }
}

@media (max-width: 900px) {
    body {
        overflow-y: auto;
        height: auto;
        padding: 40px 20px;
    }

    .container {
        flex-direction: column;
        align-items: center;
        max-width: 480px;
    }

    .records-panel {
        width: 100%;
        max-width: 450px;
        height: auto;
        min-height: 400px;
    }
}

@media (max-width: 500px) {
    .glass-panel { 
        padding: 30px 20px; 
    }
    
    .timer-display { 
        font-size: 3.5rem; 
    }
    
    .timer-container { 
        width: 240px; 
        height: 240px; 
        margin-bottom: 20px;
    }
    
    svg.progress-ring { 
        width: 240px; 
        height: 240px; 
    }
    
    .progress-ring circle { 
        r: 110; 
        cx: 120; 
        cy: 120; 
    }

    header h1 {
        font-size: 2rem;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .duration-selector {
        flex-wrap: wrap;
    }
}

@media (max-height: 700px) and (min-width: 901px) {
    .records-panel {
        height: 450px;
    }
}
/* 環境音面板特有樣式 */
.ambient-panel {
    flex: 0 1 310px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 280px;
    padding: 40px 25px;
}

.ambient-panel h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 主題切換區域 */
.theme-section {
    padding: 0 5px;
    margin-bottom: 15px;
}

.section-label {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.theme-switcher {
    display: flex;
    gap: 12px;
}

.theme-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.theme-btn.active {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.2);
}

.theme-preview {
    height: 30px;
    border-radius: 6px;
    width: 100%;
}

.zen-bg { background: linear-gradient(45deg, #1a1a2e, #16213e); }
.cafe-bg { background: linear-gradient(45deg, #2c1810, #4a3728); }

/* 影片切換動畫 */
#bg-video {
    transition: opacity 0.8s ease;
}

#bg-video.fading {
    opacity: 0;
}

.ambient-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 5px;
}

.panel-header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ambient-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 5px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.ambient-control:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ambient-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ambient-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.ambient-btn.active {
    background: var(--accent-color);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: 0 0 15px var(--accent-color);
}

/* 迷你水平 Slider */
.ambient-slider-mini {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 60px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.ambient-slider-mini::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    background: white;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid var(--accent-color);
}

.ambient-slider-mini::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: white;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid var(--accent-color);
}

.icon-btn-mini {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn-mini:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: rotate(45deg);
}

/* 響應式調整 */
@media (max-width: 900px) {
    .ambient-panel {
        flex: 1;
        max-width: none;
        width: 100%;
    }
    
    .ambient-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
}

@media (max-width: 480px) {
    .ambient-control {
        flex: 1 1 100%;
    }
}
