/* 字体引入 */
@font-face {
    font-family: 'TimeTraveler';
    src: url('TimeTravelerPal-Normal-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Chillax';
    src: url('Chillax-Variable.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 根变量定义 */
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --btn-bg: #f5f5f5;
    --btn-hover: #e8e8e8;
    --btn-active: #dcdcdc;
    --btn-primary: #4a90e2;
    --btn-primary-hover: #3a80d2;
    --toggle-bg: #e0e0e0;
    --toggle-dot: #ffffff;
    --toggle-icon-color: #ffc107;
    /* 太阳图标色 */
    --toggle-icon-dark-color: #ffe066;
    /* 深色模式月亮图标色 */
    --input-bg: #ffffff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.12);
    --notice-bg: #f9f9f9;
    --notice-border: #eaeaea;
    --edit-btn-bg: rgba(74, 144, 226, 0.1);
    --edit-btn-hover: rgba(74, 144, 226, 0.2);
}

.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --border-color: #333333;
    --btn-bg: #2d2d2d;
    --btn-hover: #383838;
    --btn-active: #444444;
    --btn-primary: #5a9ff2;
    --btn-primary-hover: #4a8fe2;
    --toggle-bg: #444444;
    --toggle-dot: #ffffff;
    --toggle-icon-color: #ffe066;
    /* 深色模式太阳图标色 */
    --toggle-icon-dark-color: #ffc107;
    /* 深色模式月亮图标色 */
    --input-bg: #2d2d2d;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.4);
    --notice-bg: #242424;
    --notice-border: #3a3a3a;
    --edit-btn-bg: rgba(90, 159, 242, 0.15);
    --edit-btn-hover: rgba(90, 159, 242, 0.25);
}

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
    gap: 30px;
    position: relative;
    /* 定位基准 */
}

/* 左侧主内容区域 */
.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 时间显示 */
#time-display {
    color: var(--text-color);
    font-family: 'TimeTraveler', '思源黑体', '鸿蒙黑体', sans-serif;
    text-align: center;
    letter-spacing: 0.10em;
    padding: 0 10px;
    margin-bottom: 35px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.time-character {
    display: inline-block;
    width: 0.7em;
    text-align: center;
    letter-spacing: 0;
}

.time-separator {
    width: 0.3em;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.05);
    color: #334155;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    z-index: 10;
}

.theme-toggle:hover {
    background: rgba(15, 23, 42, 0.08);
}

.theme-toggle:active {
    transform: translateY(1px);
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.theme-toggle-sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    color: inherit;
}

.theme-toggle-moon {
    opacity: 0;
    transform: scale(0.8) rotate(-18deg);
    color: inherit;
}

.dark-mode .theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}

.dark-mode .theme-toggle-sun {
    opacity: 0;
    transform: scale(0.8) rotate(18deg);
}

.dark-mode .theme-toggle-moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    color: inherit;
}

.theme-toggle svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle .theme-toggle-moon path {
    fill: currentColor;
    stroke: none;
}

/* 2. 音频选择区域（音频名完整显示） */
.audio-selection {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Chillax', sans-serif;
    font-size: 14px;
    background-color: var(--bg-color);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    /* 允许换行，避免溢出 */
    max-width: calc(100% - 120px);
    /* 限制最大宽度，避免遮挡主题按钮 */
}

.custom-audio-btn {
    padding: 6px 12px;
    border-radius: 8px;
    background-color: var(--btn-bg);
    color: var(--text-color);
    border: none;
    font-family: 'Chillax', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.custom-audio-btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-1px);
}

#audio-filename {
    /* 移除截断样式，完整显示 */
    white-space: normal;
    /* 允许换行 */
    color: var(--text-color);
    opacity: 0.9;
    line-height: 1.4;
    /* 换行后行高适配 */
}

#custom-audio {
    display: none;
}

/* 模式按钮 */
.mode-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
}

.mode-buttons button {
    padding: 10px 22px;
    border: none;
    background-color: var(--btn-bg);
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Chillax', '思源黑体', sans-serif;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.mode-buttons button.active {
    background-color: var(--btn-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.mode-buttons button:hover:not(.active) {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* 倒计时设置 */
.countdown-setting {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 25px;
}

.countdown-setting input {
    width: 80px;
    padding: 12px 10px;
    font-size: 18px;
    text-align: center;
    border: 1px solid var(--border-color);
    font-family: 'Chillax', '思源黑体', sans-serif;
    border-radius: 10px;
    background-color: var(--input-bg);
    color: var(--text-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.countdown-setting input:hover,
.countdown-setting input:focus {
    border-color: var(--btn-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.countdown-setting span {
    font-size: 22px;
    color: var(--text-color);
    font-family: 'Chillax', sans-serif;
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 15px;
}

.controls button {
    padding: 12px 24px;
    border: none;
    background-color: var(--btn-bg);
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Chillax', '思源黑体', sans-serif;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls button#start {
    background-color: var(--btn-primary);
    color: white;
}

.controls button#start:hover:not(:disabled) {
    background-color: var(--btn-primary-hover);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.controls button:hover:not(:disabled):not(#start) {
    background-color: var(--btn-hover);
}

.controls button:active:not(:disabled) {
    transform: scale(0.98);
    box-shadow: var(--shadow);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: var(--shadow) !important;
}

/* 倒计时结束闪烁动画 */
@keyframes flash {

    0%,
    100% {
        background-color: var(--bg-color);
    }

    50% {
        background-color: #ff6b6b;
    }
}

.alert-active {
    animation: flash 0.5s infinite;
}

/* 倒计时结束弹窗 */
.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.alert-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.alert-dialog {
    background-color: var(--bg-color);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.alert-overlay.active .alert-dialog {
    transform: translateY(0);
}

.alert-dialog h3 {
    font-family: 'Chillax', sans-serif;
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-color);
}

.alert-dialog button {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    background-color: var(--btn-primary);
    color: white;
    font-family: 'Chillax', sans-serif;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.alert-dialog button:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.alert-dialog button:active {
    transform: translateY(0);
}

/* 3. 通知栏（移除标题，编辑按钮美化+调整位置） */
.notice-section {
    width: 300px;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 600px;
    background-color: var(--notice-bg);
    border: 1px solid var(--notice-border);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
} 

/* 通知内容区 */
.notice-display {
    padding: 15px;
    font-family: 'Chillax', sans-serif;
    font-size: 15px;
    min-height: 280px;
    overflow-y: auto;
    line-height: 1.6;
    flex-grow: 1;
    margin-top: 10px;
    /* 给编辑按钮留空间 */
}

/* Markdown样式适配 */
.notice-display h1 {
    font-size: 1.8em;
    margin: 0.67em 0;
}

.notice-display h2 {
    font-size: 1.5em;
    margin: 0.75em 0;
}

.notice-display h3 {
    font-size: 1.2em;
    margin: 0.83em 0;
}

.notice-display strong {
    font-weight: bold;
}

.notice-display em {
    font-style: italic;
}

.notice-display ul,
.notice-display ol {
    margin: 1em 0;
    padding-left: 2em;
}

.notice-display li {
    margin: 0.5em 0;
}

.notice-display a {
    color: var(--btn-primary);
    text-decoration: underline;
}

.notice-display code {
    background-color: var(--input-bg);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

.notice-display blockquote {
    border-left: 3px solid var(--btn-primary);
    padding-left: 1em;
    margin: 1em 0;
}

/* 4. 通知栏编辑按钮（美化+右上角位置） */
.notice-edit-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    /* 右上角 */
    padding: 4px 10px;
    border-radius: 20px;
    /* 圆角按钮 */
    background-color: var(--edit-btn-bg);
    color: var(--btn-primary);
    border: 1px solid transparent;
    font-family: 'Chillax', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow);
}

.notice-edit-btn:hover {
    background-color: var(--edit-btn-hover);
    border-color: rgba(74, 144, 226, 0.3);
    transform: translateY(-1px);
}

/* 通知编辑弹窗 */
.notice-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.notice-edit-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.notice-edit-dialog {
    background-color: var(--bg-color);
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-hover);
}

.notice-edit-dialog h4 {
    font-family: 'Chillax', sans-serif;
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.markdown-hint {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 15px;
    font-family: 'Chillax', sans-serif;
}

#notice-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-family: 'Chillax', sans-serif;
    font-size: 15px;
    min-height: 150px;
    resize: vertical;
    margin-bottom: 15px;
    line-height: 1.6;
}

.notice-edit-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.notice-edit-buttons button {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-family: 'Chillax', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.notice-cancel {
    background-color: var(--btn-bg);
    color: var(--text-color);
}

.notice-cancel:hover {
    background-color: var(--btn-hover);
}

.notice-save {
    background-color: var(--btn-primary);
    color: white;
}

.notice-save:hover {
    background-color: var(--btn-primary-hover);
}

/* 响应式调整 */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
        padding: 60px 20px 30px;
        /* 顶部留空 */
    }

    /* 音频选择区域：顶部居中 */
    .audio-selection {
        position: fixed;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100% - 40px);
        justify-content: center;
        padding: 6px 12px;
    }

    .main-content {
        width: 100%;
        margin-bottom: 30px;
    }

    .notice-section {
        width: 100%;
        max-width: 500px;
        height: auto;
    }

    .notice-display {
        min-height: 150px;
    }

    /* 主题按钮：避免重叠 */
    .theme-toggle {
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 11;
    }
}

@media (max-width: 480px) {
    .countdown-setting {
        gap: 10px;
    }

    .countdown-setting input {
        width: 70px;
        padding: 10px 8px;
        font-size: 16px;
    }

    .controls button,
    .mode-buttons button {
        padding: 10px 16px;
        font-size: 14px;
    }

    .mode-buttons,
    .controls {
        gap: 10px;
    }

    #time-display {
        margin-bottom: 25px;
    }

    /* 编辑按钮：简化显示 */
    .notice-edit-btn {
        padding: 3px 8px;
        font-size: 12px;
    }
}