/* ===== CSS 变量定义 ===== */
:root {
    /* 背景色 */
    --bg-gradient-1: #d4dfe8;
    --bg-gradient-2: #b8cad8;
    --bg-gradient-3: #9ab5c4;
    
    /* 卡片 */
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-shadow: rgba(0, 0, 0, 0.06);
    
    /* 主色调 */
    --primary-gradient: linear-gradient(135deg, #6a9ec0 0%, #4a7ea6 100%);
    --primary-solid: #5a9bc4;
    --primary-dark: #4a7ea6;
    
    /* 文字色 */
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #9ca3af;
    --text-on-primary: white;
    
    /* 边框 */
    --border-color: #e5e7eb;
    --border-focus: #5a9bc4;
    
    /* 背景层 */
    --bg-light: #f9fafb;
    --bg-lighter: #f3f4f6;
    --bg-input: #f9fafb;
    
    /* 状态色 */
    --success-bg: #dbeafe;
    --success-text: #3b82f6;
    --danger-bg: #fee2e2;
    --danger-text: #ef4444;
    
    /* 历史记录 */
    --history-border: #f3f4f6;
    --history-bg: #f9fafb;
    --history-hover: #f3f4f6;
    
    /* 标签 */
    --tag-bg: #f3f4f6;

    /* 按钮语义色 */
    --semantic-primary-from: #6a9ec0;
    --semantic-primary-to: #4a7ea6;
    --semantic-primary-gradient: linear-gradient(135deg, var(--semantic-primary-from) 0%, var(--semantic-primary-to) 100%);
    --semantic-primary-shadow: 0 4px 10px rgba(90, 155, 196, 0.25);

    --semantic-danger-from: #f87171;
    --semantic-danger-to: #ef4444;
    --semantic-danger-gradient: linear-gradient(135deg, var(--semantic-danger-from) 0%, var(--semantic-danger-to) 100%);
    --semantic-danger-shadow: 0 4px 10px rgba(248, 113, 113, 0.25);

    --semantic-success-from: #4dbfad;
    --semantic-success-to: #229a8c;
    --semantic-success-gradient: linear-gradient(135deg, var(--semantic-success-from) 0%, var(--semantic-success-to) 100%);
    --semantic-success-shadow: 0 4px 10px rgba(51, 204, 179, 0.25);

    --semantic-neutral-bg: #f3f6f9;
    --semantic-neutral-bg-hover: #e8eef3;
    --semantic-neutral-text: #5a9bc4;
    --semantic-neutral-border: #c5d9e8;
}

[data-theme="dark"] {
    /* 背景 */
    --bg-gradient-1: #1a1a2e;
    --bg-gradient-2: #16213e;
    --bg-gradient-3: #0f3460;
    
    /* 卡片 */
    --card-bg: rgba(30, 30, 50, 0.9);
    --card-shadow: rgba(0, 0, 0, 0.3);
    
    /* 文字 */
    --text-primary: #e5e5e5;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    
    /* 边框 */
    --border-color: #3a3a4a;
    --border-focus: #5a9bc4;
    
    /* 背景层 */
    --bg-light: #2a2a3a;
    --bg-lighter: #252535;
    --bg-input: #2a2a3a;
    
    /* 状态色 */
    --success-bg: #1a3a5c;
    --success-text: #6ba3d6;
    --danger-bg: #4a2020;
    --danger-text: #e07070;
    
    /* 历史记录 */
    --history-border: #3a3a4a;
    --history-bg: #2a2a3a;
    --history-hover: #3a3a4a;
    
    /* 标签 */
    --tag-bg: #3a3a4a;

    --semantic-neutral-bg: #2a2a3a;
    --semantic-neutral-bg-hover: #353548;
    --semantic-neutral-text: #8eb8d4;
    --semantic-neutral-border: #4a5a6a;
}

/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
    min-height: 100vh;
    padding: 8px;
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

.app-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 8px 0;
}

.app-card {
    width: 100%;
    max-width: 672px;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 16px 20px;
    box-shadow: 0 8px 30px var(--card-shadow);
    transition: background 0.3s;
}

/* 顶部标题区 */
.header-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-right: 88px;
}

.header-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-icon-btn,
.theme-toggle {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.header-icon-btn:hover,
.theme-toggle:hover {
    background: var(--bg-lighter);
    transform: scale(1.05);
}

/* 账户与同步状态栏 */
.account-bar,
.sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.account-label {
    color: var(--text-muted);
    flex-shrink: 0;
}

.account-email {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.sync-bar {
    margin-bottom: 10px;
}

.sync-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.sync-status {
    flex: 1;
    color: var(--text-secondary);
}

.sync-status[data-status="synced"] {
    color: var(--primary-solid);
}

.sync-status[data-status="error"] {
    color: var(--danger-text);
}

.sync-status[data-status="offline"] {
    color: var(--text-muted);
}

.sync-now-btn {
    flex-shrink: 0;
}

/* 通用弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid var(--border-color);
    background: var(--semantic-primary-gradient);
    color: var(--text-on-primary);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* 认证弹窗 */
.auth-form .form-group {
    margin-bottom: 14px;
}

.auth-submit-btn {
    width: 100%;
    margin-top: 4px;
}

.auth-error {
    color: var(--danger-text);
    font-size: 13px;
    margin: 8px 0;
}

.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 16px;
}

.auth-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.auth-code-row .form-input {
    flex: 1;
    min-width: 0;
}

.auth-code-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary-solid);
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}

/* 迁移弹窗 */
.migration-desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 16px;
}

.migration-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.migration-progress {
    margin-bottom: 16px;
}

.migration-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.migration-progress-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.migration-progress-track {
    background: var(--bg-lighter);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.migration-progress-bar {
    background: linear-gradient(90deg, var(--primary-solid), var(--primary-light, #60a5fa));
    border-radius: 999px;
    height: 100%;
    transition: width 0.25s ease;
}

[data-theme="dark"] .header-icon-btn,
[data-theme="dark"] .theme-toggle {
    background: var(--bg-lighter);
    border-color: var(--border-color);
}

[data-theme="dark"] .header-icon-btn:hover,
[data-theme="dark"] .theme-toggle:hover {
    background: var(--history-hover);
}

.header-icon {
    font-size: 24px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 核心计时卡片 */
.timer-card {
    background: var(--primary-gradient);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin-bottom: 12px;
    color: var(--text-on-primary);
    box-shadow: 0 6px 16px rgba(90, 159, 194, 0.3);
    transition: background 0.3s;
}

.timer-card-top {
    position: relative;
    min-height: 24px;
    margin-bottom: 10px;
}

.timer-status {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    z-index: 1;
}

.timer-status .status-text {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.timer-display {
    font-size: 48px;
    font-weight: 700;
    margin: 8px 0;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timer-wall-clock {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    opacity: 0.88;
    margin-bottom: 8px;
}

.timer-sub-label {
    font-size: 12px;
    opacity: 0.9;
}

.timer-wall-clock-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-on-primary);
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-dot.active {
    background: #3dbf6b;
}

.status-dot.stopped {
    background: #f87171;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: 1.2em;
    font-weight: 500;
}

.current-time {
    font-size: 3em;
    font-weight: 700;
    margin: 20px 0;
    font-variant-numeric: tabular-nums;
}

.current-work-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 72px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0.95;
    text-align: center;
    line-height: 1.35;
    word-break: break-word;
}

.current-work-name span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.history-tag-chip {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--success-bg);
    color: var(--success-text);
}

/* 闹钟进度条 */
.alarm-progress {
    margin-top: 16px;
    padding: 0 4px;
    animation: alarmProgressFadeIn 0.3s ease;
}

@keyframes alarmProgressFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alarm-progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
    opacity: 0.95;
}

.alarm-progress-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.5px;
}

.alarm-progress-label::before {
    content: '⏳';
    font-size: 14px;
}

.alarm-progress-remaining {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.alarm-progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.alarm-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ffffff 0%, #e6f4ff 100%);
    border-radius: 999px;
    transition: width 0.5s linear, background 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}

.alarm-progress.warning .alarm-progress-bar {
    background: linear-gradient(90deg, #ffe9a8 0%, #ffd166 100%);
    box-shadow: 0 0 8px rgba(255, 209, 102, 0.6);
}

.alarm-progress.warning .alarm-progress-remaining {
    color: #fff3c2;
}

.alarm-progress.danger .alarm-progress-bar {
    background: linear-gradient(90deg, #ffb4a2 0%, #ff6b6b 100%);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.7);
    animation: alarmProgressPulse 1.2s ease-in-out infinite;
}

.alarm-progress.danger .alarm-progress-remaining {
    color: #ffd6d1;
}

@keyframes alarmProgressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 工作内容输入区 */
.work-name-section {
    margin-bottom: 12px;
}

.layout-left.is-recording .work-name-section {
    display: none;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.work-name-section .input-label {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.work-name-section .work-name-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--bg-light);
}

.work-name-section .work-name-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: white;
    box-shadow: 0 0 0 3px rgba(90, 155, 196, 0.1);
}

.work-name-section .work-name-input:disabled {
    background: var(--bg-lighter);
    cursor: not-allowed;
    opacity: 0.7;
}

/* 标签选择区 */
.tag-section {
    margin-bottom: 12px;
}

.quick-tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.quick-tags-row .manage-tags-btn {
    flex-shrink: 0;
    margin-left: auto;
}

.work-name-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
    margin-bottom: 10px;
}

.work-name-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(90, 155, 196, 0.1);
}

.work-name-input:disabled {
    background: var(--bg-lighter);
    cursor: not-allowed;
}

/* 快速标签 */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.quick-tag {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-weight: 500;
}

.quick-tag:not(.selected) {
    background: var(--semantic-neutral-bg);
    color: var(--semantic-neutral-text);
    border: 1px solid var(--semantic-neutral-border);
}

.quick-tag.selected {
    background: var(--semantic-primary-gradient);
    color: var(--text-on-primary);
    box-shadow: var(--semantic-primary-shadow);
}

.quick-tag:hover:not(.selected) {
    box-shadow: 0 2px 8px rgba(90, 155, 196, 0.2);
}

/* 标签管理弹窗 */
.tag-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tag-modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tag-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #f3f4f6;
    background: linear-gradient(135deg, #5a9bc4 0%, #4a7ea6 100%);
    color: var(--text-on-primary);
}

.tag-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-on-primary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.tag-modal-body {
    padding: 25px;
    overflow-y: auto;
}

.tag-add-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tag-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
}

.tag-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(90, 155, 196, 0.1);
}

.tag-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: move;
    user-select: none;
}

.tag-item:hover {
    background: var(--bg-lighter);
    transform: translateX(5px);
}

.tag-item.dragging {
    opacity: 0.5;
    background: #e5e7eb;
}

.tag-item.drag-over {
    border-top: 3px solid #5a9bc4;
}

.tag-drag-handle {
    color: var(--text-muted);
    font-size: 1.2em;
    margin-right: 10px;
    cursor: grab;
    user-select: none;
}

.tag-drag-handle:active {
    cursor: grabbing;
}

.tag-item-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1em;
}

.btn-delete-tag {
    background: #fee2e2;
    color: var(--danger-text);
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-delete-tag:hover {
    background: #fecaca;
    transform: scale(1.05);
}

.empty-tags {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 1em;
}

/* 编辑记录弹窗 */
.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.edit-modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #f3f4f6;
    background: linear-gradient(135deg, #5a9bc4 0%, #4a7ea6 100%);
    color: var(--text-on-primary);
}

.edit-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.edit-modal-body {
    padding: 25px;
    overflow-y: auto;
}

/* 编辑表单 */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95em;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(90, 155, 196, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.form-actions .btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
}

/* 更多设置（闹钟 / 通知） */
.more-settings {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-light);
    overflow: hidden;
}

.more-settings-summary {
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.more-settings-summary::-webkit-details-marker {
    display: none;
}

.more-settings-summary::after {
    content: '▼';
    float: right;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.more-settings[open] .more-settings-summary::after {
    transform: rotate(180deg);
}

.more-settings-body {
    padding: 0 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.more-settings .reminder-section {
    margin-bottom: 0;
}

/* 闹钟提醒设置区 */
.reminder-section {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid #d8e9f5;
}

.reminder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.reminder-icon {
    font-size: 16px;
}

.reminder-label {
    font-size: 14px;
    font-weight: 600;
    color: #4a7ea6;
}

.alarm-header-badge {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    margin: 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-on-primary);
    background: var(--semantic-primary-gradient);
    border-radius: 20px;
    box-shadow: var(--semantic-primary-shadow);
    white-space: nowrap;
}

.alarm-header-badge[hidden] {
    display: none;
}

.alarm-header-badge.updated {
    animation: alarmBadgePop 0.4s ease;
}

@keyframes alarmBadgePop {
    0%   { transform: scale(0.85); opacity: 0.6; }
    50%  { transform: scale(1.08); }
    100% { transform: scale(1);   opacity: 1; }
}

.reminder-options {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.reminder-options.active {
    display: flex;
}

/* 开关样式 */
.alarm-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-on-primary);
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.alarm-toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, #5a9bc4 0%, #4a7ea6 100%);
}

.alarm-toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* 桌面系统通知 */
.notify-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 4px;
}

.notify-status {
    font-size: 0.8em;
    color: #4a6b80;
    flex: 1;
    min-width: 140px;
}

/* 预设按钮 */
.preset-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    background: var(--semantic-neutral-bg);
    border: 1.5px solid var(--semantic-neutral-border);
    color: var(--semantic-neutral-text);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
    white-space: nowrap;
}

.preset-btn:hover {
    background: var(--semantic-neutral-bg-hover);
    transform: translateY(-1px);
}

.preset-btn.selected {
    background: var(--semantic-primary-gradient);
    border-color: var(--semantic-primary-to);
    color: var(--text-on-primary);
    box-shadow: var(--semantic-primary-shadow);
}

.preset-btn.selected:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(90, 155, 196, 0.4);
}

/* 自定义时长输入 */
.custom-alarm {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.custom-alarm-input {
    width: 70px;
    padding: 8px 12px;
    border: 1.5px solid #d0e6ff;
    border-radius: 20px;
    font-size: 0.9em;
    transition: all 0.25s ease;
    background: linear-gradient(135deg, #f8fcff 0%, #f0f7ff 100%);
    font-family: inherit;
}

.custom-alarm-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: white;
    box-shadow: 0 0 0 3px rgba(90, 155, 196, 0.1);
}

.custom-alarm-input::placeholder {
    color: #a0c4e8;
}

.custom-alarm-unit {
    color: #5a9bc4;
    font-size: 0.85em;
    font-weight: 500;
}



/* 自定义闹钟时长管理 */
.alarm-presets-toggle {
    white-space: nowrap;
}

.alarm-presets-toggle.active {
    background: var(--primary-color);
    color: #fff;
}

.custom-alarm-presets {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(90, 155, 196, 0.08);
    border-radius: 12px;
}

.custom-alarm-presets[hidden] {
    display: none;
}

.custom-alarm-presets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

.custom-alarm-presets-add {
    display: flex;
    align-items: center;
    gap: 4px;
}

.custom-alarm-presets-add .custom-alarm-input {
    width: 60px;
    padding: 4px 8px;
    font-size: 0.85em;
}

.custom-alarm-presets-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.alarm-preset-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4a8fc4 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

.alarm-preset-remove {
    cursor: pointer;
    opacity: 0.7;
    font-size: 1.1em;
    line-height: 1;
    margin-left: 2px;
}

.alarm-preset-remove:hover {
    opacity: 1;
    color: #ff6b6b;
}

.more-settings .btn-sm {
    border-radius: 20px;
}

/* 闹钟状态（已移至标题行徽章，保留 DOM 供兼容） */
.alarm-status {
    display: none;
}

/* 闹钟提醒弹窗 */
.alarm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.alarm-modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.alarm-modal-icon {
    font-size: 4em;
    margin-bottom: 16px;
    animation: bellShake 0.5s ease infinite;
}

@keyframes bellShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    75% { transform: rotate(-10deg); }
}

.alarm-modal-title {
    font-size: 1.8em;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 700;
}

.alarm-modal-message {
    font-size: 1.1em;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.alarm-modal-actions {
    display: flex;
    gap: 12px;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 按钮语义：主操作 / 危险 / 次要 / 成功 */
.btn-primary {
    background: var(--semantic-primary-gradient);
    color: var(--text-on-primary);
    box-shadow: var(--semantic-primary-shadow);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 14px rgba(90, 155, 196, 0.4);
}

.btn-danger {
    background: var(--semantic-danger-gradient);
    color: var(--text-on-primary);
    box-shadow: var(--semantic-danger-shadow);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 4px 14px rgba(248, 113, 113, 0.4);
}

.btn-success {
    background: var(--semantic-success-gradient);
    color: var(--text-on-primary);
    box-shadow: var(--semantic-success-shadow);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 4px 14px rgba(51, 204, 179, 0.35);
}

.btn-neutral {
    background: var(--semantic-neutral-bg);
    color: var(--semantic-neutral-text);
    border: 1.5px solid var(--semantic-neutral-border);
    box-shadow: none;
}

.btn-neutral:hover:not(:disabled) {
    background: var(--semantic-neutral-bg-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

.btn-modal {
    flex: 1;
    padding: 14px 20px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 12px;
}

.history-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* 历史记录区域 */
.history-section {
    margin-bottom: 12px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.date-filter {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    transition: all 0.3s;
    background: var(--bg-light);
}

.date-filter:focus {
    outline: none;
    border-color: var(--border-focus);
    background: white;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
    border-left: 3px solid #5a9bc4;
    padding-left: 10px;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.history-item {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: var(--bg-lighter);
    transform: translateX(5px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.history-date {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1em;
}

.history-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: all 0.3s ease;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.btn-edit-record,
.btn-delete-record {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-edit-record:hover {
    background: #dbeafe;
    color: var(--success-text);
    transform: scale(1.1);
}

.btn-delete-record:hover {
    background: #fee2e2;
    color: var(--danger-text);
    transform: scale(1.1);
}

.history-duration {
    background: linear-gradient(135deg, #5a9bc4 0%, #4a7ea6 100%);
    color: var(--text-on-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(90, 155, 196, 0.3);
}

.history-work-name {
    font-weight: 600;
    color: #3d8ab8;
    margin-bottom: 8px;
    font-size: 1em;
    padding: 4px 0;
}

.history-time {
    display: flex;
    gap: 20px;
    color: #6b7280;
    font-size: 0.95em;
}

.history-time span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 统计信息 */
.statistics-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    background: linear-gradient(135deg, #e4eef5 0%, #dae8f2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(90, 155, 196, 0.1);
}

.statistics-section .stat-item {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.statistics-section .stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    margin-bottom: 4px;
}

.statistics-section .stat-value {
    display: block;
    background: linear-gradient(135deg, #5a9bc4 0%, #3d8ab8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* 滚动条样式 */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #5a9bc4 0%, #4a7ea6 100%);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #5a9bc4;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .app-container {
        padding: 4px;
    }

    .app-card {
        padding: 12px 16px;
    }

    .header-title {
        font-size: 18px;
    }

    .timer-display {
        font-size: 36px;
    }

    .timer-card {
        padding: 16px;
    }

    .action-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .statistics-section {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .history-list {
        max-height: 150px;
    }
}


/* ===== 快捷键说明弹窗 ===== */
.shortcuts-modal-content {
    max-width: 360px;
}

.shortcuts-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcuts-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.shortcuts-item kbd {
    background: var(--bg-lighter);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    border: 1px solid var(--border-color);
    min-width: 2em;
    text-align: center;
}

.shortcuts-plus {
    color: var(--text-muted);
    font-size: 12px;
}

.shortcuts-item > span:last-child {
    flex: 1;
}

/* ===== 深色模式额外适配 ===== */
[data-theme="dark"] .modal-content {
    background: #2a2a3a;
    color: var(--text-primary);
}

[data-theme="dark"] .form-input {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .history-item {
    background: var(--history-bg);
    border-color: var(--history-border);
}

[data-theme="dark"] .history-item:hover {
    background: var(--history-hover);
}

[data-theme="dark"] .empty-state {
    color: var(--text-muted);
}

[data-theme="dark"] .preset-btn,
[data-theme="dark"] .custom-alarm-input {
    background: var(--bg-lighter);
    color: var(--text-primary);
}

/* ===== 桌面双栏布局（定稿版）=====
 * 桌面端（≥768px）Flexbox 双列：左侧控制区按内容高度自适应，
 * 右侧历史+统计固定在视口内，历史列表内部滚动，页面外层无滚动条。
 * 移动端 layout-cols/left/right 退化为块级，恢复单列。
 */
@media (min-width: 768px) {

    body {
        padding: 8px;
        overflow: hidden; /* 禁用页面外层滚动 */
    }

    .app-container {
        align-items: center;
        padding: 8px 0;
        height: calc(100vh - 16px);
    }

    /* app-card 固定为视口高度，内部 flex 纵向分配 */
    .app-card {
        max-width: 980px;
        height: 100%;
        display: flex;
        flex-direction: column;
        padding: 14px 20px 12px;
        overflow: hidden;
    }

    .header-section {
        flex-shrink: 0;
        margin-bottom: 10px;
    }

    /* layout-cols：横向两栏，占满剩余高度 */
    .layout-cols {
        flex: 1;
        min-height: 0;
        display: flex;
        gap: 20px;
        overflow: hidden;
    }

    /* 左栏：按内容高度自然堆叠，超出时内部滚动 */
    .layout-left {
        flex: 1;
        min-width: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 4px; /* 给滚动条留空间 */
    }

    .layout-left .timer-card {
        margin-bottom: 8px;
        padding: 16px;
    }

    .layout-left .timer-display {
        font-size: 40px;
    }

    .layout-left .timer-wall-clock {
        margin-bottom: 6px;
    }

    .layout-left .work-name-section  { margin-bottom: 8px; }
    .layout-left .tag-section        { margin-bottom: 8px; }
    .layout-left .action-buttons     { margin-bottom: 4px; }

    .layout-left .more-settings-summary {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* 更多设置 / 闹钟区域 */
    .layout-left .more-settings {
        margin-bottom: 8px;
    }

    .layout-left .reminder-section {
        margin-bottom: 0;
        padding: 8px 12px;
        border-radius: 12px;
    }

    .reminder-header    { margin-bottom: 6px; }
    .reminder-icon      { font-size: 14px; }
    .reminder-label     { font-size: 13px; }
    .reminder-options   { gap: 5px; }

    /* 5 个预设按钮强制一行等宽排列 */
    .preset-buttons {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .preset-btn {
        flex: 1;
        padding: 4px 0;
        font-size: 11px;
        white-space: nowrap;
        text-align: center;
        border-radius: 14px;
    }

    .custom-alarm        { gap: 5px; margin-top: 2px; }
    .custom-alarm-input  { width: 60px; padding: 5px 8px; font-size: 12px; }
    .custom-alarm-unit   { font-size: 12px; }
    .alarm-header-badge { font-size: 12px; padding: 3px 10px; margin: 0 6px; }

    .notify-row    { margin-top: 3px; gap: 6px; }
    .notify-status { font-size: 11px; }

    /* 右栏：固定高度，历史列表弹性填满，不撑高页面 */
    .layout-right {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .layout-right .history-section {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        margin-bottom: 8px;
    }

    .layout-right .history-list {
        flex: 1;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        margin-bottom: 0;
    }

    /* 统计区：垂直列表，固定在右栏底部 */
    .layout-right .statistics-section {
        flex-shrink: 0;
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .layout-right .statistics-section .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 10px;
    }

    .layout-right .statistics-section .stat-label {
        margin-bottom: 0;
        font-size: 12px;
    }

    .layout-right .statistics-section .stat-value {
        font-size: 15px;
    }
}
