/* ============================================================
   DESIGN SYSTEM — 极简墨韵
   原则：留白呼吸 · 层次分明 · 克制用色 · 精准细节
   ============================================================ */

:root {
    --primary:        #1a56db;
    --primary-hover:  #1648c0;
    --primary-light:  #eff4ff;
    --primary-subtle: rgba(26, 86, 219, 0.08);
    --danger:         #e53e3e;
    --danger-hover:   #c53030;
    --danger-subtle:  rgba(229, 62, 62, 0.07);
    --success:        #16a34a;
    --warning:        #d97706;
    --purple:         #7c3aed;
    --background:     #f7f7f5;
    --surface:        #ffffff;
    --surface-raised: #ffffff;
    --surface-inset:  #f3f3f0;
    --text-primary:   #111827;
    --text-secondary: #4b5563;
    --text-muted:     #9ca3af;
    --text-disabled:  #d1d5db;
    --border:         #e8e8e4;
    --border-focus:   var(--primary);
    --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm:  0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:  0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg:  0 16px 48px rgba(0,0,0,0.10);
    --shadow-panel: 0 4px 20px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
    --radius-sm:  6px;
    --radius:     14px;
    --radius-lg:  18px;
    --radius-xl:  24px;
    --font-sans:  'Inter', system-ui, sans-serif;
    --font-serif: 'Playfair Display', serif;
    --ease:       cubic-bezier(0.4, 0, 0.2, 1);
    --duration:   0.18s;
    /* 兼容旧变量名 */
    --card-bg:        var(--surface);
    --text-main:      var(--text-primary);
}

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

html, body { overflow-x: hidden; }

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 2.5rem 1.25rem;
    padding-top: calc(56px + 2.5rem); /* topbar height + original top padding */
}

.app-container { max-width: 1200px; margin: 0 auto; position: relative; min-height: 90vh; }

header { margin-bottom: 2.5rem; text-align: center; }

h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

#app-subtitle { color: var(--text-muted); font-size: 1.1rem; font-weight: 400; }

h2 { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0; }

/* ── VIEW SWITCHER ── */
.view-switcher {
    display: flex;
    justify-content: center;
    gap: 3px;
    margin-bottom: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow-xs);
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 1.05rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    white-space: nowrap;
}

.view-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.view-btn:hover { background: var(--surface-inset); color: var(--text-primary); }

.view-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

#btn-view-day.active { color: #fee56f; }

/* ── CALENDAR HEADER ── */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 0.25rem;
    position: relative;
    z-index: 10;
}

.calendar-header h2 { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { background: var(--border); color: var(--text-primary); }

/* ── CALENDAR GRID ── */
.calendar-grid {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.weekday {
    padding: 0.85rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.calendar-days { display: block; }

.week-row { display: flex; position: relative; }

.week-row .day-cell { flex: 1; min-width: 0; overflow: visible; }

.day-cell {
    min-height: 120px;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
    display: flex;
    flex-direction: column;
    position: relative;
}

.week-row .day-cell:last-child { border-right: none; }

.day-cell:hover { background: #fafaf8; }

.day-cell.other-month { background: #fafaf8; }
.day-cell.other-month .day-number { color: var(--text-disabled); }

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.3rem 0.4rem 0.15rem;
}

.day-number {
    font-weight: 500;
    font-size: 0.82rem;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background var(--duration);
    flex-shrink: 0;
}

.day-cell.today .day-number {
    background: var(--primary);
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(26, 86, 219, 0.35);
}

.chinese-date {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-muted);
    line-height: 24px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chinese-date.chinese-holiday  { color: #15803d; font-weight: 600; }
.chinese-date.chinese-solar-term { color: #b91c1c; font-weight: 600; }

/* ── CALENDAR EVENTS ── */
.calendar-event-slot { height: 22px; position: relative; width: 100%; }

.calendar-check-btn {
    width: 13px;
    height: 13px;
    margin-right: 4px;
    border: 1.5px solid rgba(0,0,0,0.18);
    border-radius: 3px;
    background: white;
    color: white;
    font-size: 9px;
    line-height: 11px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--duration), border-color var(--duration);
}

.calendar-event.completed .calendar-check-btn { background: var(--primary); border-color: var(--primary); }

.calendar-event {
    display: flex;
    align-items: center;
    background: #eff4ff;
    color: #1e40af;
    border-left: 2.5px solid #1e40af;
    font-size: 0.72rem;
    padding: 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 20px;
    line-height: 18px;
    position: absolute;
    left: 0; right: 0; top: 0;
    z-index: 10;
    pointer-events: auto;
    border-radius: 4px;
    font-weight: 500;
    letter-spacing: 0.03em;
    transition: opacity var(--duration);
}

.calendar-event:hover { opacity: 0.82; cursor: pointer; }

.calendar-event-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* 月视图 "+N 更多" 按钮 */
.month-more-btn {
    font-size: 0.72rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 20px;
    height: 20px;
    z-index: 5;
    transition: background 0.15s, color 0.15s;
}
.month-more-btn:hover {
    background: var(--primary-subtle);
    color: var(--primary);
}

/* 多日日程由 JS 直接控制圆角和边框 */

.category-catA { background: #eff4ff; color: #1e40af; border-left-color: #1e40af; }
.calendar-event.category-catA.all-day { background: #1a56db; color: white; border-left: none; }
.category-catA.completed { background: #f1f5f9; color: #94a3b8; border-left-color: #cbd5e1; }

.category-catB { background: #f0fdf4; color: #166534; border-left-color: #16a34a; }
.calendar-event.category-catB.all-day { background: #16a34a; color: white; border-left: none; }
.category-catB.completed { background: #f1f5f9; color: #94a3b8; border-left-color: #cbd5e1; }

.calendar-event.completed { background: #f1f5f9; color: #94a3b8; border-left-color: #cbd5e1; text-decoration: line-through; }
.calendar-event.all-day { border-left: none; }
.calendar-event.category-catA.all-day.completed,
.calendar-event.category-catB.all-day.completed { background: #e2e8f0; color: #64748b; border-left: none; }

/* ── WEEK VIEW ── */
.week-view { position: relative; z-index: 10; }
.week-view .day-cell { min-height: 420px; }

/* ── DAY VIEW ── */
.day-view-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    min-height: 400px;
    position: relative;
    z-index: 10;
}

.subtask-view { margin-top: 0.6rem; padding-left: 1.4rem; }

/* ── MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.32);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(5px);
}

.modal-overlay.open { display: flex; animation: fadeIn 0.18s ease-out; }

.modal {
    width: 100%;
    max-width: 500px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 0;
    animation: slideUp 0.25s var(--ease);
    position: relative;
    max-height: 90vh;
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0; }

/* All modal forms with modal-form-body use flex column layout for sticky header/footer */
.modal form:has(.modal-form-body),
#schedule-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-form-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem 0.5rem;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.modal-form-body::-webkit-scrollbar {
    display: none; /* Chrome/Safari - hidden by default */
}

/* Show scrollbar only when actually needed (overflow happening) */
.modal-form-body.scrollable::-webkit-scrollbar {
    display: block;
    width: 4px;
}

.modal-form-body.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.modal-form-body.scrollable::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.modal-form-footer {
    flex-shrink: 0;
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.modal-form-footer .btn-primary {
    margin-top: 0;
}

/* All modals use flex column layout for sticky header/footer */
/* Non-schedule modals use modal-form-body + modal-form-footer structure */

/* Reduce input heights in modal */
.modal-form-body input[type="text"],
.modal-form-body input[type="date"],
.modal-form-body input[type="time"],
.modal-form-body input[type="number"],
.modal-form-body select {
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
}

.modal-form-body .checkbox-group {
    padding: 0.5rem 0.9rem;
}

.modal-form-body .form-group {
    margin-bottom: 0.9rem;
}

/* Subtask inline delete button */
.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    opacity: 0.85;
    padding: 1px 0;
    margin-bottom: 0.38rem;
}

.subtask-item.done .subtask-title { text-decoration: line-through; opacity: 0.5; }

.subtask-item input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.subtask-title {
    cursor: pointer;
    line-height: 1.4;
    user-select: none;
    color: #4b5563;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.btn-subtask-delete-inline {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 1px 2px;
    display: inline-flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 3px;
    margin-left: 2px;
}

.subtask-item:hover .btn-subtask-delete-inline {
    opacity: 0.6;
}

.btn-subtask-delete-inline:hover {
    opacity: 1 !important;
    color: var(--danger);
    background: var(--danger-subtle);
}

.btn-icon-sm {
    background: var(--surface-inset);
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration), color var(--duration);
}

.btn-icon-sm:hover { background: var(--border); color: var(--text-primary); }

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
}

.checkbox-group input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--primary); }
.checkbox-group label { margin: 0; cursor: pointer; font-weight: 400; color: var(--text-secondary); font-size: 0.9rem; }

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--surface-inset);
    transition: border-color var(--duration), box-shadow var(--duration), background var(--duration);
    line-height: 1.5;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

input:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; border-color: var(--border); }
textarea { resize: vertical; min-height: 80px; }

select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--surface-inset);
    cursor: pointer;
    transition: border-color var(--duration), box-shadow var(--duration);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}

select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1); }

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--duration), transform 0.1s, box-shadow var(--duration);
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.22);
    margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(26, 86, 219, 0.32); }
.btn-primary:active { transform: scale(0.98); }

/* ── LIST VIEW ── */
.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; position: relative; z-index: 10; }

.badge {
    background: var(--text-primary);
    color: white;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.schedule-list { display: flex; flex-direction: column; gap: 0.85rem; position: relative; z-index: 10; }

.schedule-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    box-shadow: var(--shadow-xs);
}

.schedule-item.category-catA { border-left: 3px solid #1a56db; }
.schedule-item.category-catB { border-left: 3px solid #16a34a; }
.schedule-item.completed { opacity: 0.6; }
.schedule-item.completed .item-title { text-decoration: line-through; color: var(--text-muted); }
.schedule-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.item-content { flex: 1; }

.item-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.3rem; }

.item-title {
    max-width: 900px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    transition: color var(--duration);
}

.item-time { font-size: 0.875rem; color: var(--primary); font-weight: 500; letter-spacing: 0.02em; }

/* 日程卡片上的OKR关联图标 */
.item-okr-icon {
    flex-shrink: 0;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.85;
}

.btn-delay-one-day { opacity: 0.5; transition: opacity var(--duration); margin-left: 4px; vertical-align: middle; }
.btn-delay-one-day:hover { opacity: 1; color: var(--primary); }

.item-date { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.3rem; letter-spacing: 0.03em; }

.item-notes {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    line-height: 1.6;
}

.item-actions { display: flex; align-items: center; gap: 0.25rem; margin-left: 1rem; flex-shrink: 0; }

.btn-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: color var(--duration), background var(--duration);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover { color: var(--primary); background: var(--primary-subtle); }
.btn-delete:hover  { color: var(--danger);  background: var(--danger-subtle); }

.btn-check {
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    border-radius: 5px;
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--duration), border-color var(--duration);
}

.schedule-item.completed .btn-check { background: var(--primary); border-color: var(--primary); color: white; }

.item-main { display: flex; align-items: flex-start; flex: 1; }

.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--text-muted);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
}

.empty-icon { width: 48px; height: 48px; margin-bottom: 1.2rem; opacity: 0.35; }

/* ── CONTEXT MENU ── */
.context-menu {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
    padding: 4px;
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.9rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background var(--duration), color var(--duration);
}

.ctx-item:hover { background: var(--surface-inset); }
.ctx-item.text-danger { color: var(--danger); }
.ctx-item.text-danger:hover { background: var(--danger-subtle); }

/* ── FAB ── */
.fab-group {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    z-index: 900;
}

.fab {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--duration), box-shadow var(--duration), background var(--duration);
    box-shadow: var(--shadow-md);
}

.fab:hover { transform: translateY(-2px) scale(1.07); box-shadow: var(--shadow-lg); }
.fab:active { transform: scale(0.93); }

.fab-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.fab-secondary:hover { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 6px 20px rgba(26,86,219,0.3); }

.fab-danger { color: var(--danger); border-color: rgba(229,62,62,0.25); }
.fab-danger:hover { background: var(--danger); color: white; border-color: var(--danger); box-shadow: 0 6px 20px rgba(229,62,62,0.3); }

/* ── ALERT PANEL ── */
@media (max-width: 1300px) { .alert-panel { display: none; } }

.alert-panel {
    position: fixed;
    left: 24px;
    top: 80px;
    width: 300px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--border);
    font-size: 13px;
    z-index: 1;
    transition: width 0.25s var(--ease);
}

.alert-panel.collapsed { width: 160px !important; }

.alert-title {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 10px;
    height: 26px;
    width: 100%;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 10px;
    background: var(--primary);
    color: #fee56f;
    user-select: none;
    cursor: pointer;
    transition: opacity 0.15s;
    letter-spacing: 0.02em;
}

.alert-title:hover { opacity: 0.88; }

#alert-chevron { transition: transform 0.25s var(--ease); flex-shrink: 0; }
.alert-title.collapsed #alert-chevron { transform: rotate(-90deg); }

#alert-body {
    overflow: hidden;
    transition: max-height 0.25s var(--ease), opacity 0.25s var(--ease);
    max-height: 600px;
    opacity: 1;
}

#alert-body.collapsed { max-height: 0; opacity: 0; }

.alert-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }

.alert-row input {
    flex: 1;
    padding: 5px 8px;
    font-size: 13.6px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--surface-inset);
    color: #578cff;
    transition: border-color var(--duration);
}

.alert-row input:focus { outline: none; border-color: var(--primary); background: var(--surface); }

input[type="text2"] {
    width: 100%;
    padding: 5px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.6px;
    background: var(--surface-inset);
    color: #578cff;
    transition: border-color var(--duration), box-shadow var(--duration);
}

input[type="text2"]:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

.btn-delete-alert {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration), background var(--duration), border-color var(--duration);
    padding: 0;
}

.btn-delete-alert:hover { color: var(--danger); background: var(--danger-subtle); border-color: var(--danger); }

.alert-add-btn {
    margin-top: 8px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    background: none;
    color: var(--primary);
    border: 1.5px dashed rgba(26, 86, 219, 0.4);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration), border-color var(--duration);
}

.alert-add-btn:hover { background: var(--primary-subtle); border-color: var(--primary); }

/* ── POMODORO PANEL ── */
@media (max-width: 1300px) { .pomodoro-panel { display: none; } }

.pomodoro-panel {
    position: fixed;
    right: 24px;
    top: 80px;
    width: 200px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--border);
    font-size: 13px;
    z-index: 1;
    transition: width 0.25s var(--ease);
}

.pomodoro-panel.collapsed { width: 160px !important; }

.pomodoro-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 26px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 10px;
    background: #dc2626;
    color: white;
    user-select: none;
    cursor: pointer;
    transition: opacity 0.15s;
    letter-spacing: 0.02em;
}

.pomodoro-title:hover { opacity: 0.88; }

#pomodoro-chevron { transition: transform 0.25s var(--ease); flex-shrink: 0; }
.pomodoro-title.collapsed #pomodoro-chevron { transform: rotate(-90deg); }

#pomodoro-body {
    overflow: hidden;
    transition: max-height 0.25s var(--ease), opacity 0.25s var(--ease);
    max-height: 320px;
    opacity: 1;
}

#pomodoro-body.collapsed { max-height: 0; opacity: 0; }

.pomodoro-ring-wrap { position: relative; width: 108px; height: 108px; margin: 10px auto 12px; }
.pomodoro-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: #fee2e2; stroke-width: 7; }
.ring-fill { fill: none; stroke: #dc2626; stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring-fill.running { stroke: #dc2626; }
.ring-fill.paused  { stroke: #f87171; }

.pomodoro-time-display {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.pomodoro-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }

.pomo-btn {
    padding: 5px 14px;
    border-radius: 999px;
    border: none;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    letter-spacing: 0.02em;
}

.pomo-btn:hover  { opacity: 0.85; transform: scale(1.04); }
.pomo-btn:active { transform: scale(0.96); }
.pomo-btn-start  { background: #dc2626; color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.pomo-btn-reset  { background: var(--surface-inset); color: var(--text-secondary); border: 1px solid var(--border); }
.pomo-btn-test   { background: var(--surface-inset); color: var(--text-secondary); border: 1px solid var(--border); flex-basis: auto; }

.pomodoro-today-info {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
    line-height: 1.7;
}

.pomodoro-today-info strong { color: #dc2626; font-weight: 700; }

/* ── DASHBOARD ── */
.dashboard-container { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }

/* 仪表盘视图整体层级与月/周/今天/列表视图保持一致，避免被 alert/pomodoro 侧边栏遮挡 */
#view-dashboard {
    position: relative;
    z-index: 10;
}
@media (max-width: 700px) { .dashboard-container { grid-template-columns: 1fr; } }

.dashboard-col { display: flex; flex-direction: column; gap: 1rem; }

.dashboard-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-col-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.dashboard-col-title svg { color: var(--primary); }

.dashboard-add-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(26, 86, 219, 0.2);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration), transform 0.1s, box-shadow var(--duration), color var(--duration), border-color var(--duration);
}

.dashboard-add-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(26, 86, 219, 0.25);
    transform: translateY(-1px);
}

.dashboard-cards { display: flex; flex-direction: column; gap: 0.85rem; }

.goal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    position: relative;
    transition: box-shadow var(--duration), transform var(--duration);
    border-left: 3px solid var(--primary);
    box-shadow: var(--shadow-xs);
}

.goal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.goal-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.goal-card-title { font-weight: 600; font-size: 0.92rem; color: var(--text-primary); flex: 1; line-height: 1.45; }
.goal-card-actions { display: flex; gap: 0.15rem; flex-shrink: 0; }
.goal-card-actions .btn-action { padding: 0.2rem; border-radius: 5px; }

.progress-section { margin-bottom: 0.6rem; }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.progress-bar-track { height: 6px; background: var(--surface-inset); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.5s var(--ease); }
.progress-bar-fill.completion { background: var(--success); }

.goal-completion-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-muted); margin-top: 0.4rem; flex-wrap: wrap; }
.goal-completion-row strong { color: var(--text-primary); font-weight: 600; }

.btn-plus-one { opacity: 0.55; transition: opacity var(--duration); margin-left: 4px; vertical-align: middle; cursor: pointer; background: none; border: none; color: inherit; padding: 0; }
.btn-plus-one:hover { opacity: 1; color: var(--primary); }

.timer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    border-left: 3px solid var(--purple);
    transition: box-shadow var(--duration), transform var(--duration);
    box-shadow: var(--shadow-xs);
}

.timer-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.timer-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.timer-card-title { font-weight: 600; font-size: 0.92rem; color: var(--text-primary); }
.timer-card-type { font-size: 0.7rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 600; letter-spacing: 0.02em; }
.timer-type-countdown { background: #ede9fe; color: var(--purple); }
.timer-type-countup   { background: #fef3c7; color: var(--warning); }
.timer-days { font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1.1; margin: 0.25rem 0; letter-spacing: -0.02em; }
.timer-days span { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); margin-left: 0.25rem; letter-spacing: 0; }
.timer-card-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.timer-card-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }

.dashboard-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-muted);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.7;
}

/* ── DEEP WORK SUMMARY ── */
.deep-work-summary { margin-top: 1rem; }
.deep-work-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.deep-work-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    border-left: 3px solid #dc2626;
    text-align: center;
    box-shadow: var(--shadow-xs);
}

.deep-work-card-label { font-size: 0.68rem; color: var(--text-muted); margin-bottom: 0.4rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.deep-work-card-value { font-size: 1.7rem; font-weight: 800; color: #dc2626; line-height: 1.1; letter-spacing: -0.02em; }
.deep-work-card-unit  { font-size: 0.78rem; color: var(--text-muted); font-weight: 400; margin-left: 2px; }

.pomo-refresh-hint {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.75;
    letter-spacing: 0.01em;
}

/* ── POMO GOAL CARDS ── */
.pomo-goal-cards-container { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 0.85rem; }

.pomo-goal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    border-left: 3px solid #dc2626;
    transition: box-shadow var(--duration), transform var(--duration);
    box-shadow: var(--shadow-xs);
}

.pomo-goal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.pomo-goal-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.pomo-goal-card-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.45;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pomo-goal-card-actions { display: flex; gap: 0.15rem; flex-shrink: 0; }
.pomo-goal-card-actions .btn-action { padding: 0.2rem; border-radius: 5px; }

.pomo-goal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.pomo-goal-work-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    margin-bottom: 0.1rem;
}

.pomo-goal-work-row strong { color: var(--text-primary); font-weight: 600; }
.pomo-goal-sep { color: var(--border); }

/* 番茄钟目标进度条颜色（红色系，与深度工作统计保持一致） */
.progress-bar-fill.pomo-goal-time       { background: #fca5a5; }
.progress-bar-fill.pomo-goal-completion { background: #dc2626; }

/* ── POMO GOAL 表单内元素 ── */
.pomo-goal-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.78rem;
    color: #dc2626;
    line-height: 1.5;
    margin-bottom: 0.85rem;
}

.pomo-goal-tip svg { flex-shrink: 0; margin-top: 2px; color: #dc2626; }

.pomo-goal-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
}

.pomo-goal-stats strong { color: #dc2626; font-weight: 700; }

/* ── SUBTASK (modal) ── */
#subtask-container { margin-top: 0.25rem; }

#subtask-container .form-label,
#subtask-container > label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#subtask-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }

.subtask-row { display: flex; align-items: center; gap: 0.5rem; }

.subtask-input {
    flex: 1;
    padding: 0.5rem 0.75rem !important;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface-inset);
    transition: border-color var(--duration), box-shadow var(--duration);
    color: var(--text-primary);
}

.subtask-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.08); background: var(--surface); }

.btn-delete-subtask {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration), background var(--duration), border-color var(--duration);
    padding: 0;
}

.btn-delete-subtask:hover { color: var(--danger); background: var(--danger-subtle); border-color: var(--danger); }

#btn-add-subtask {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    background: none;
    color: var(--primary);
    border: 1.5px dashed rgba(26, 86, 219, 0.4);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration), border-color var(--duration);
    width: 100%;
    justify-content: center;
}

#btn-add-subtask:hover { background: var(--primary-subtle); border-color: var(--primary); }

/* ── ANIMATIONS ── */
@keyframes fadeIn  { from { opacity: 0; }                        to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
    body { padding: 1.25rem 0.75rem; }
    .view-switcher { gap: 2px; padding: 4px; }
    .view-btn { padding: 0.38rem 0.7rem; font-size: 0.78rem; }
    .calendar-weekdays .weekday { font-size: 0.65rem; padding: 0.55rem 0.2rem; }
    .day-cell { min-height: 72px; }
    .calendar-event { font-size: 0.62rem; }
    .form-row { grid-template-columns: 1fr; }
    .modal { padding: 1.5rem; border-radius: var(--radius); }
}

/* ══════════════════════════════════════════
   MOBILE FULL ADAPTATION  (≤ 768px)
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Base layout ── */
    body {
        padding: 0;
        padding-bottom: 80px; /* space for bottom nav */
        background: var(--background);
        overflow-x: hidden; /* prevent horizontal scroll on all views */
        width: 100%;
    }

    .app-container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        overflow-x: hidden;
    }

    main {
        width: 100%;
        overflow-x: hidden;
    }

    /* ── Header ── */
    header {
        padding: 1.25rem 1rem 0.5rem;
        margin-bottom: 0;
        text-align: left;
    }

    h1 {
        font-size: 1.6rem;
        margin-bottom: 0.2rem;
    }

    #app-subtitle {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    /* ── Top navigation → hidden, replaced by bottom tab bar ── */
    .view-switcher {
        display: none;
    }

    /* ── Bottom Tab Bar ── */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;          /* 强制视口宽度，不随内容溢出偏移 */
        height: 64px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
        z-index: 950;
        padding-bottom: env(safe-area-inset-bottom);
        align-items: center;
        overflow: hidden;      /* 防止子元素撑宽 */
    }

    .mobile-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 500;
        cursor: pointer;
        transition: color var(--duration);
        padding: 8px 4px;
        letter-spacing: 0.03em;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab-item svg {
        width: 22px;
        height: 22px;
    }

    .mobile-tab-item.active {
        color: var(--primary);
    }

    .mobile-tab-item.active svg {
        stroke-width: 2.5;
    }

    /* Add button in center of tab bar */
    .mobile-tab-item.tab-add {
        flex: 0 0 64px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-tab-add-btn {
        width: 46px;
        height: 46px;
        min-width: 46px;
        min-height: 46px;
        flex-shrink: 0;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 14px rgba(26,86,219,0.38);
        cursor: pointer;
        transition: transform 0.15s, box-shadow 0.15s;
        -webkit-tap-highlight-color: transparent;
        /* Prevent any flex/grid stretching */
        align-self: center;
        padding: 0;
        overflow: hidden;
    }

    .mobile-tab-add-btn:active {
        transform: scale(0.92);
    }

    /* ── Hide desktop-only elements ── */
    .alert-panel,
    .pomodoro-panel,
    .fab-group {
        display: none !important;
    }

    /* ── Main content area ── */
    main {
        padding: 0 0.75rem;
    }

    /* ── Calendar header ── */
    .calendar-header {
        padding: 0.75rem 0 0.75rem;
        margin-bottom: 0.75rem;
    }

    .calendar-header h2 {
        font-size: 1rem;
    }

    /* ── Month grid ── */
    .calendar-grid {
        border-radius: var(--radius);
        border-left: none;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
        margin: 0 -0.75rem;
        border-left: none;
        border-right: none;
    }

    .calendar-weekdays .weekday {
        font-size: 0.6rem;
        padding: 0.5rem 0.1rem;
        letter-spacing: 0;
    }

    .day-cell {
        min-height: 58px;
        padding: 0;
    }

    .day-header {
        padding: 0.2rem 0.25rem 0.1rem;
    }

    .day-number {
        font-size: 0.75rem;
        width: 20px;
        height: 20px;
    }

    .chinese-date {
        font-size: 0.58rem;
        line-height: 20px;
    }

    .calendar-event {
        font-size: 0.6rem;
        height: 17px;
        line-height: 15px;
        padding: 0 3px;
    }

    /* ── Week grid ── */
    .week-view .day-cell {
        min-height: 220px;
    }

    /* ── Day view ── */
    .day-view-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        /* 不使用负 margin，避免横向溢出；用 -0.75rem 补偿 main 的 padding */
        margin: 0 -0.75rem;
        width: calc(100% + 1.5rem);
        padding: 1rem 0.75rem;
        box-sizing: border-box;
    }

    /* ── List view ── */
    .list-header {
        padding: 0.75rem 0 0.5rem;
        margin-bottom: 0.75rem;
    }

    .schedule-item {
        padding: 0.9rem 1rem;
        border-radius: var(--radius-sm);
    }

    .item-title {
        font-size: 0.92rem;
        max-width: 100%;
    }

    .item-actions {
        gap: 0.1rem;
        margin-left: 0.5rem;
    }

    .btn-action {
        padding: 0.3rem;
    }

    /* ── Dashboard ── */
    .dashboard-container {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding-top: 0.5rem;
    }

    .goal-card,
    .timer-card {
        padding: 0.9rem 1rem;
    }

    /* ── Modal ── */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        max-width: 100% !important;
        width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        max-height: 92vh;
        animation: slideUpMobile 0.28s var(--ease);
    }

    .confirm-modal {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        max-width: 100% !important;
    }

    /* ── Form ── */
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-header {
        padding: 1.1rem 1.25rem 1rem;
    }

    .modal-form-body {
        padding: 0.75rem 1.25rem 0.5rem;
    }

    .modal-form-footer {
        padding: 0.75rem 1.25rem 1.25rem;
    }

    /* ── Context menu — larger tap targets on mobile ── */
    .ctx-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* ── Section titles ── */
    .list-header h2 {
        font-size: 1.05rem;
    }

    /* ── Prevent item-title from overflowing on narrow screens ── */
    .item-title {
        max-width: calc(100vw - 120px);
    }

    /* ── OKR view full-width on mobile ── */
    #view-okr {
        max-width: 100%;
        padding: 0;
    }

    .okr-header {
        padding-left: 0;
        padding-right: 0;
    }

    /* ── view-list full-width on mobile ── */
    #view-list {
        width: 100%;
    }

    /* ── view-dashboard full-width on mobile ── */
    #view-dashboard {
        width: 100%;
    }

    /* ── view-calendar-container full-width on mobile ── */
    #view-calendar-container {
        width: 100%;
        overflow-x: hidden;
    }
}

@keyframes slideUpMobile {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Desktop: hide mobile tab bar */
@media (min-width: 769px) {
    .mobile-tab-bar { display: none; }
}

/* ── CUSTOM CONFIRM DIALOG ── */
.confirm-modal {
    max-width: 380px !important;
    padding: 2rem 2rem 1.75rem !important;
    text-align: center;
    display: block !important;
    overflow: visible !important;
}

.confirm-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fff7ed;
    border: 1.5px solid #fed7aa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.1rem;
    color: #ea580c;
}

.confirm-icon-wrap.danger {
    background: #fff1f2;
    border-color: #fecdd3;
    color: var(--danger);
}

.confirm-title {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    margin-bottom: 0.5rem !important;
    letter-spacing: -0.01em;
}

.confirm-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-btn-cancel {
    flex: 1;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration), border-color var(--duration), color var(--duration);
}

.confirm-btn-cancel:hover {
    background: var(--surface-inset);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.confirm-btn-ok {
    flex: 1;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--danger);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration), box-shadow var(--duration);
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.25);
}

.confirm-btn-ok:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 14px rgba(229, 62, 62, 0.35);
}

.confirm-btn-ok.safe {
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.25);
}

.confirm-btn-ok.safe:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 14px rgba(26, 86, 219, 0.35);
}

/* ── TOP BAR ── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    z-index: 800;
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    text-decoration: none;
}

.topbar-brand svg { color: var(--primary); flex-shrink: 0; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-btn {
    padding: 0.42rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration), color var(--duration), box-shadow var(--duration);
    text-decoration: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.topbar-btn-ghost:hover { background: var(--surface-inset); color: var(--text-primary); }

.topbar-btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(26,86,219,0.22);
}

.topbar-btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(26,86,219,0.32); }

/* ── User dropdown menu ── */
.topbar-user-menu { position: relative; }

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--duration), border-color var(--duration);
}

.topbar-user-btn:hover { background: var(--surface-inset); border-color: var(--text-muted); }

.topbar-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 1100;
    padding: 4px;
    animation: fadeIn 0.12s ease-out;
}

.topbar-dropdown.open { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background var(--duration);
    white-space: nowrap;
}

.dropdown-item:hover { background: var(--surface-inset); }

.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-subtle); }

.dropdown-user-info {
    font-weight: 600;
    color: var(--text-primary);
    cursor: default;
    pointer-events: none;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ── Form error text ── */
.form-error {
    color: var(--danger);
    font-size: 0.82rem;
    margin: 0.4rem 0 0.75rem;
    min-height: 1rem;
}

/* ── Mobile topbar adjustments ── */
@media (max-width: 768px) {
    .topbar-inner { padding: 0 1rem; }
    .topbar-brand span { display: none; }
    body { padding-top: calc(56px + 1.25rem); padding-bottom: 80px; overflow-x: hidden; }
}

/* ── POMODORO RESULT MODAL ── */
.pomo-result-modal {
    max-width: 340px !important;
    padding: 0 !important;
    text-align: center;
    display: block !important;
    overflow: hidden !important;
    border-radius: var(--radius-xl) !important;
}

.pomo-result-emoji {
    font-size: 3rem;
    padding: 2rem 2rem 0.75rem;
    line-height: 1;
}

.pomo-result-title {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    margin: 0 0 0.4rem !important;
    letter-spacing: -0.01em;
}

.pomo-result-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
    padding: 0 1.5rem;
    line-height: 1.5;
}

.pomo-result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border);
}

.pomo-result-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 1rem 0.75rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration), color var(--duration);
    letter-spacing: 0.01em;
}

.pomo-result-yes {
    color: var(--success);
    border-right: 1px solid var(--border);
}

.pomo-result-yes:hover {
    background: #f0fdf4;
}

.pomo-result-no {
    color: var(--text-muted);
}

.pomo-result-no:hover {
    background: var(--surface-inset);
    color: var(--text-secondary);
}

/* ── PANEL PIN BUTTON ── */
.panel-pin-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: rgba(255,255,255,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
    transition: color 0.15s, background 0.15s;
    margin-left: 4px;
}

.panel-pin-btn:hover {
    color: #fee56f;
    background: rgba(255,255,255,0.12);
}

.panel-pin-btn.pinned {
    color: #fee56f;
}

.panel-pin-btn.pinned svg {
    fill: #fee56f;
    stroke: #fee56f;
}

/* Pomodoro pin button color scheme */
.pomodoro-title .panel-pin-btn {
    color: rgba(255,255,255,0.55);
}

.pomodoro-title .panel-pin-btn:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

.pomodoro-title .panel-pin-btn.pinned {
    color: white;
}

.pomodoro-title .panel-pin-btn.pinned svg {
    fill: white;
    stroke: white;
}

/* Title flex layout for pin button */
.alert-title,
.pomodoro-title {
    display: flex;
    align-items: center;
}

/* ══════════════════════════════════════════════════════
   OKR VIEW STYLES
   ══════════════════════════════════════════════════════ */

/* OKR 视图容器 */
#view-okr {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 10;
}

.okr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.okr-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.okr-add-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(26, 86, 219, 0.2);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration), transform 0.1s, box-shadow var(--duration), color var(--duration), border-color var(--duration);
}

.okr-add-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(26, 86, 219, 0.25);
    transform: translateY(-1px);
}

.okr-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

/* OKR 目标卡片 */
.okr-objective-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-xs);
    border-left: 4px solid var(--primary);
    transition: box-shadow var(--duration), transform var(--duration);
}

.okr-objective-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* 目标标题行 */
.okr-objective-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.okr-objective-info {
    flex: 1;
}

/* 目标标题行：「目标」标签 + 目标名称 */
.okr-objective-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
    flex-wrap: wrap;
}

.okr-objective-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-subtle);
    border: 1px solid rgba(26, 86, 219, 0.25);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.okr-objective-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.okr-objective-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.okr-objective-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
    align-items: flex-start;
}

.okr-objective-actions .btn-action { padding: 0.2rem; border-radius: 5px; }

/* 总完成率行 */
.okr-total-progress {
    margin-bottom: 0.85rem;
}

.okr-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.77rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.okr-progress-label strong {
    color: var(--text-primary);
    font-size: 0.88rem;
}

/* KR 关键结果列表 */
.okr-kr-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--border);
}

.okr-kr-item {
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border);
}

.okr-kr-left {
    flex: 1;
    min-width: 0;
}

/* KR 标题行：KR编号 + KR描述 */
.okr-kr-header-row {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
    min-width: 0;
}

.okr-kr-num {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    flex-shrink: 0;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.okr-kr-title-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Legacy .okr-kr-title kept for backward compatibility */
.okr-kr-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.okr-kr-progress-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.okr-kr-bar-track {
    flex: 1;
    height: 5px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.okr-kr-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    transition: width 0.5s var(--ease);
}

.okr-kr-pct {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    width: 2.8rem;
    text-align: right;
    flex-shrink: 0;
}

/* KR 评估标签 */
.okr-kr-eval {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
    white-space: nowrap;
}

.okr-kr-eval.eval-ok {
    color: var(--success);
    background: rgba(22, 163, 74, 0.1);
}

.okr-kr-eval.eval-behind {
    color: var(--warning);
    background: rgba(217, 119, 6, 0.1);
}

.okr-kr-eval.eval-risk {
    color: var(--danger);
    background: rgba(229, 62, 62, 0.1);
}

.okr-kr-weight {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.okr-kr-actions {
    display: flex;
    gap: 0.1rem;
    flex-shrink: 0;
}

.okr-kr-actions .btn-action { padding: 0.15rem; border-radius: 4px; }

/* OKR Modal 样式 */
.okr-kr-form-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.okr-kr-form-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
}

.okr-kr-form-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.5rem;
    height: 2rem;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--duration);
}

.okr-kr-form-row input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.okr-kr-weight-input {
    width: 72px !important;      /* 加宽，确保3位数完整显示 */
    flex: none !important;
    text-align: center;
    padding: 0.3rem 0.5rem;
    height: 2rem;                /* 与描述输入框等高 */
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--duration);
}
.okr-kr-weight-input:focus {
    outline: none;
    border-color: var(--primary);
}

.okr-kr-weight-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.okr-add-kr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    background: none;
    color: var(--primary);
    border: 1.5px dashed rgba(26, 86, 219, 0.4);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration), border-color var(--duration);
    width: 100%;
    margin-top: 0.25rem;
}

.okr-add-kr-btn:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
}

.okr-weight-total-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    margin-top: 0.25rem;
    position: relative;
}

.okr-weight-total {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.okr-weight-total.over-100  { color: var(--danger);  font-weight: 600; }
.okr-weight-total.under-100 { color: var(--warning); font-weight: 600; }
.okr-weight-total.exact-100 { color: var(--success); font-weight: 600; }

/* 权重合计不等于100%时显示的提示标签 */
.okr-weight-tip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    background: var(--danger);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    white-space: nowrap;
    animation: okr-tip-fadein 0.18s ease;
}

/* 跳动警告效果：每次权重改变或点击保存时触发 */
.okr-weight-tip-shake {
    animation: okr-tip-shake 0.45s ease;
}

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

@keyframes okr-tip-shake {
    0%   { transform: translateX(0); }
    15%  { transform: translateX(-5px); }
    30%  { transform: translateX(5px); }
    45%  { transform: translateX(-4px); }
    60%  { transform: translateX(4px); }
    75%  { transform: translateX(-2px); }
    90%  { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

/* 日程 modal 中关联OKR的选择器样式 */
.form-group-okr-link {
    margin-top: 0.75rem;
}

.form-group-okr-link select {
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--surface-inset);
    color: var(--text-primary);
    transition: border-color var(--duration);
    cursor: pointer;
}

.form-group-okr-link select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

/* OKR 模态框 */
#okr-modal-overlay .modal {
    max-width: 560px;
}

/* 响应式 */
@media (max-width: 600px) {
    .okr-objective-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    .okr-objective-actions {
        align-self: flex-end;
    }
    .okr-kr-item {
        flex-wrap: wrap;
    }
}

/* ── 进度表单：完成度模式切换 ── */
.goal-mode-tabs {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}
.goal-mode-tab {
    padding: 0.3rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 0.82rem;
    background: var(--surface-inset);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.goal-mode-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.goal-mode-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
