/* --- 基础全局设置 --- */
body {
    margin: 0;
    padding: 0;
    background-color: #000000;
    color: #dddddd;
    font-family: 'Helvetica Neue', 'San Francisco', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* 优化点8：消除手机端点击高亮 */
}

/* 动态背景层 */
#bg-layer {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    z-index: -1;
    transition: background-image 0.5s ease;
}

/* --- 右上角设置按钮 --- */
.settings-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.settings-btn svg {
    transition: stroke 0.3s, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.settings-btn:hover svg {
    stroke: #aaaaaa;
    transform: rotate(45deg);
}

/* --- 中央时钟区域布局 --- */
.clock-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    /* 缩小间距，让视觉更紧凑 */
    width: 100%;
}

.status-top {
    font-size: 1rem;
    color: #555555;
    letter-spacing: 2px;
    transition: opacity 0.3s;
}

/* 优化点2 & 8：纯数字时钟极简美学，并增加响应式伸缩 */
.time-main {
    display: flex;
    align-items: center;
    justify-content: center;
    /* 使用 clamp 函数：最小值 5rem，推荐值 18vw，最大值 15rem。在电脑上更大，在手机上自动缩小 */
    font-size: clamp(5rem, 18vw, 15rem);
    font-weight: 300;
    color: #eeeeee;
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
    line-height: 1;
    /* 去除多余的行高 */
}

.colon {
    transform: translateY(-0.08em);
    margin: 0 2vw;
    /* 冒号间距也使用相对单位 */
    animation: blink 1s step-start infinite;
}

/* 优化点1：当 JS 给冒号添加 .solid 类时，停止闪烁 */
.colon.solid {
    animation: none;
    opacity: 1;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* 优化点4：同一行显示，并且信息类元素大幅度弱化 */
.status-bottom {
    display: flex;
    flex-direction: row;
    /* 强制横向一行 */
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s;
    margin-top: 5px;
    min-width: 260px;
    /* 强制给一个足以装下英文的宽度 */
    justify-content: center;
}

.info-text-muted {
    font-size: 0.9rem;
    color: #444444;
    /* 极其淡化，不抢视觉中心 */
    letter-spacing: 1px;
    font-weight: 400;
}

.separator {
    color: #333333;
    font-size: 1.2rem;
}

/* --- 右下角番茄钟遥控器 --- */
.pomodoro-wrapper {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 20;
}

/* 优化点5：独立的环形容器与退出SVG */
.ring-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 原本的计时进度圆环 */
    background: conic-gradient(var(--bg-color, #151515) calc(100% - var(--progress, 100%)), var(--fill-color, #151515) 0);
    mask: radial-gradient(transparent 60%, black 65%), repeating-conic-gradient(black 0deg, black 4deg, transparent 4.5deg, transparent 6deg);
    -webkit-mask: radial-gradient(transparent 60%, black 65%), repeating-conic-gradient(black 0deg, black 4deg, transparent 4.5deg, transparent 6deg);
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
    transition: transform 0.2s ease, filter 0.2s;
}

/* 独立的退出动画层，完美贴合在按钮上 */
.exit-ring-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    /* 让圆环从12点钟方向开始 */
    pointer-events: none;
    /* 防止遮挡点击 */
}

#exit-progress-circle {
    fill: none;
    stroke: #b33939;
    /* 独立的退出专属颜色：暗沉的警示红 */
    stroke-width: 6;
    /* 圆的周长 = 2 * pi * r (47) ≈ 295.31 */
    stroke-dasharray: 295.31;
    stroke-dashoffset: 295.31;
    /* 默认隐藏 */
    stroke-linecap: round;
    /* 使用 JS requestAnimationFrame 不用过渡，或者用 CSS 0.1s 极速线性过渡保证顺滑 */
    transition: stroke-dashoffset 0.1s linear;
}

.ring-icon {
    font-size: 16px;
    color: #ffffff;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    /* 确保图标在退出圆环的上方 */
}

.ring-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.ring-btn:hover .ring-icon {
    opacity: 1;
    transform: scale(1.1);
}

.records-container {
    display: flex;
    flex-wrap: wrap;
    width: 120px;
    justify-content: flex-end;
    gap: 6px;
}

.record-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: #555555;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- 极简暗黑设置模态框 --- */
.modal-overlay {
    opacity: 0;
    visibility: hidden;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content.with-sidebar {
    background: #0a0a0a;
    border-radius: 12px;
    display: flex;
    flex-direction: row;
    border: 1px solid #1a1a1a;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 680px;
    /* 稍微加宽一点以适应新加的按钮 */
    max-width: 90vw;
    height: 450px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
}

/* 左侧导航 */
.modal-sidebar {
    width: 180px;
    min-width: 180px;
    /* 锁死最小宽度 */
    flex-shrink: 0;
    /* 绝对不缩放 */
    box-sizing: border-box;
    /* 保证 padding 计算在内 */
    background: #050505;
    border-right: 1px solid #151515;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.modal-title {
    margin: 0 0 25px 0;
    font-size: 1.1rem;
    color: #777777;
    font-weight: 400;
    padding-left: 10px;
}

.settings-tabs {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tab-btn {
    padding: 12px 15px;
    color: #666666;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.tab-btn:hover {
    background: #111111;
    color: #aaaaaa;
}

.tab-btn.active {
    background: #1a1a1a;
    color: #eeeeee;
}

/* 右侧内容区 */
.modal-body {
    flex: 1;
    padding: 35px 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
    width: 0px;
}

.tab-pane {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: #888888;
}

/* 统一输入框样式 */
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body select {
    background: #000000;
    border: 1px solid #222222;
    color: #cccccc;
    padding: 10px 15px;
    border-radius: 6px;
    width: 200px;
    box-sizing: border-box;
    text-align: center;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body select:focus {
    border-color: #555555;
}

/* 优化点3：文件上传组合框样式 */
.file-input-wrapper {
    display: flex;
    gap: 8px;
    width: 200px;
}

.file-input-wrapper input[type="text"] {
    width: 100%;
    /* 填满剩余空间 */
    flex: 1;
}

.icon-btn {
    background: #111111;
    border: 1px solid #222222;
    color: #aaaaaa;
    border-radius: 6px;
    padding: 0 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: #222222;
    border-color: #555555;
}

/* 优化点6：极简暗黑 Switch 开关 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1a1a1a;
    border: 1px solid #333;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #666;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked+.slider {
    background-color: #333;
    border-color: #555;
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(20px);
    background-color: #eeeeee;
}

.divider {
    height: 1px;
    background: #151515;
    margin: auto 0 20px 0;
}

.control-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.modal-body button {
    border: 1px solid transparent;
    padding: 10px 25px;
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.primary-btn {
    background: #1a1a1a !important;
    color: #dddddd;
    border: 1px solid #333333 !important;
}

.primary-btn:hover {
    background: #252525 !important;
    border-color: #555555 !important;
}

.secondary-btn {
    color: #666666;
}

.secondary-btn:hover {
    color: #aaaaaa;
    background: #111111 !important;
}

/* 飘窗提示 (Toast) */
#toast-container {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(20, 20, 20, 0.95);
    color: #bbbbbb;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 0.95rem;
    border: 1px solid #333333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    animation: toastEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, toastLeave 0.3s ease-in 2.5s forwards;
}

@keyframes toastEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastLeave {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* =========================================
   优化点8：响应式布局 (适配手机屏幕)
========================================= */
@media screen and (max-width: 768px) {

    /* 调整右上角和右下角按钮的位置 */
    .settings-btn {
        top: 20px;
        right: 20px;
    }

    .pomodoro-wrapper {
        bottom: 30px;
        right: 30px;
    }

    /* 设置面板在手机上改为上下布局 */
    .modal-content.with-sidebar {
        flex-direction: column;
        width: 90vw;
        height: 80vh;
        /* 手机端高度自适应 */
    }

    .modal-sidebar {
        width: 100%;
        padding: 20px 20px 10px 20px;
        border-right: none;
        border-bottom: 1px solid #151515;
        box-sizing: border-box;
    }

    .modal-title {
        margin-bottom: 15px;
    }

    /* 侧边栏按钮在手机上横向滑动或平铺 */
    .settings-tabs {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .tab-btn {
        white-space: nowrap;
        /* 手机端文字不换行 */
    }

    /* 模态框主体内容适配 */
    .modal-body {
        padding: 20px;
    }

    .input-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .modal-body input[type="text"],
    .modal-body input[type="number"],
    .modal-body select,
    .file-input-wrapper {
        width: 100%;
        /* 手机端输入框填满宽度 */
    }
}