:root {
    --background-color: #f0f2f5;
    --container-bg: #ffffff;
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --text-color: #1a1a2e;
    --subtle-text-color: #8e8ea0;
    --border-color: #e4e7ed;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --completed-color: #a0a0b0;
    --card-radius: 12px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #e8ecf1 0%, #f0f2f5 100%);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-color);
}

body.logged-in {
    background: linear-gradient(135deg, #f0f2f5 0%, #e8ecf1 100%);
}

.container {
    background-color: var(--container-bg);
    border-radius: var(--card-radius);
    box-shadow: 0 2px 16px var(--shadow-color);
    width: 100%;
    max-width: 780px;
    padding: 36px 40px;
    box-sizing: border-box;
    transition: all var(--transition);
}

/* ===== 登录界面 ===== */
#login-screen {
    text-align: center;
    padding: 40px 20px;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
}

.login-logo svg {
    width: 100%;
    height: 100%;
}

#login-screen h1 {
    font-size: 1.6em;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text-color);
}

.login-desc {
    color: var(--subtle-text-color);
    font-size: 0.95em;
    margin: 0 0 32px;
}

.login-form {
    max-width: 360px;
    margin: 0 auto;
}

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--subtle-text-color);
    pointer-events: none;
    transition: color 0.3s;
}

#secret-key-input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    box-sizing: border-box;
    background: #f8f9fb;
    color: var(--text-color);
    font-family: inherit;
    transition: all 0.3s;
    outline: none;
}

#secret-key-input::placeholder {
    color: #b0b0b0;
}

#secret-key-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}

#secret-key-input:focus ~ .input-icon {
    color: var(--primary-color);
}

#login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color), #357abd);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

#login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.35);
}

#login-btn:active {
    transform: translateY(0);
}

#login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-error {
    color: #e74c3c;
    font-size: 0.85em;
    margin: 12px 0 0;
    min-height: 1.2em;
    display: none;
}

.login-error.visible {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}


/* Todo 应用界面 */
.hidden {
    display: none;
}

header {
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: var(--subtle-text-color);
    font-size: 0.85em;
}

#logout-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--subtle-text-color);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    font-size: 0.85em;
}

#logout-btn:hover {
    background-color: #f5f5f5;
    color: var(--text-color);
    border-color: #ccc;
}

header h1 {
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-color);
}

#new-todo-form {
    display: flex;
    margin-top: 16px;
    gap: 0;
}

#new-todo-input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px 0 0 10px;
    font-size: 0.95em;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fafbfc;
    font-family: inherit;
}

#new-todo-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: inset 0 0 0 1px rgba(74, 144, 226, 0.1);
}

#new-todo-type {
    padding: 12px 10px;
    border: 1.5px solid var(--border-color);
    border-left: none;
    border-right: none;
    font-size: 0.85em;
    background: #fafbfc;
    color: var(--text-color);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: border-color var(--transition);
}

#new-todo-type:focus {
    border-color: var(--primary-color);
}

#new-todo-form button[type="submit"] {
    padding: 12px 20px;
    font-size: 1.3em;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}

#new-todo-form button[type="submit"]:hover {
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

#todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition);
    border-radius: 4px;
}

.todo-item:last-child {
    border-bottom: none;
}

.todo-item:hover {
    background-color: #f8f9fb;
}

.todo-item .checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #d0d5dd;
    cursor: pointer;
    margin-right: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    background: white;
}

.todo-item .checkbox:hover {
    border-color: var(--primary-color);
    background: #f0f6ff;
}

.todo-item.completed .checkbox {
    background: linear-gradient(135deg, var(--primary-color), #6db3f2);
    border-color: var(--primary-color);
}

.todo-item.completed .checkbox::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -1px;
}

.todo-item .content {
    flex-grow: 1;
    transition: color var(--transition);
    font-size: 0.95em;
    line-height: 1.4;
}

.todo-item.completed .content {
    text-decoration: line-through;
    color: var(--completed-color);
}

.todo-item .delete-btn {
    background: none;
    border: none;
    color: #c0c4cc;
    font-size: 1.3em;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.todo-item:hover .delete-btn {
    opacity: 1;
}

.todo-item .delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}



/* ===== Tab Navigation ===== */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 16px;
    background: #f4f5f7;
    border-radius: 10px;
    padding: 3px;
}

.nav-tab {
    background: none;
    border: none;
    padding: 8px 14px;
    font-size: 0.9em;
    cursor: pointer;
    color: var(--subtle-text-color);
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
    border-radius: 8px;
    font-weight: 500;
}

.nav-tab:hover {
    color: var(--text-color);
}

.nav-tab.active {
    color: var(--primary-color);
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* ===== View Panel ===== */
.view-container {
    max-height: 55vh;
    overflow-y: auto;
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

/* ===== View Controls ===== */
.view-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.ctrl-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
    font-family: inherit;
}

.ctrl-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.today-btn {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 500;
}

.today-btn:hover {
    background-color: #357abd;
}

.view-controls span {
    font-size: 1.05em;
    font-weight: 500;
    min-width: 120px;
    text-align: center;
}

.year-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05em;
    font-weight: 500;
}

/* ===== Progress Bar ===== */
.progress-bar-container {
    position: relative;
    width: 100%;
    height: 22px;
    background-color: #eef1f5;
    border-radius: 11px;
    margin: 12px 0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #6db3f2);
    border-radius: 11px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7em;
    font-weight: 600;
    color: #555;
    letter-spacing: 0.3px;
}

/* ===== List Views (Weekly, Monthly) ===== */
#weekly-todo-list,
#monthly-todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ===== Kanban Board ===== */
.kanban-board {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    min-height: 200px;
}

.kanban-column {
    background-color: #f8f9fb;
    border-radius: 10px;
    padding: 14px 12px;
    min-height: 180px;
    border: 2px solid transparent;
    transition: all var(--transition);
}

.kanban-column.drag-over {
    border-color: var(--primary-color);
    background-color: #f0f5ff;
}

.kanban-column-header {
    font-size: 0.9em;
    font-weight: 600;
    margin: 0 0 10px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.todo-header {
    color: #e67e22;
}

.progress-header {
    color: #3498db;
}

.done-header {
    color: #27ae60;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 40px;
}

.kanban-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: grab;
    transition: all var(--transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.kanban-card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.kanban-card.dragging {
    opacity: 0.4;
    transform: rotate(2deg);
}

.kanban-card .card-content {
    font-size: 0.9em;
    margin-bottom: 6px;
    word-break: break-word;
    line-height: 1.4;
}

.kanban-card .card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75em;
}

/* ===== Task Type Badge ===== */
.task-type-badge {
    display: inline-block;
    font-size: 0.7em;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.task-type-badge.daily {
    background-color: #e8f4fd;
    color: #3498db;
}

.task-type-badge.weekly {
    background-color: #fef3e2;
    color: #e67e22;
}

.task-type-badge.monthly {
    background-color: #e8f8e8;
    color: #27ae60;
}

.todo-item .task-type-badge {
    margin-left: 8px;
    flex-shrink: 0;
}

/* ===== Empty Hint ===== */
.empty-hint {
    text-align: center;
    color: var(--subtle-text-color);
    padding: 30px 0;
    font-size: 0.9em;
    display: none;
}

.empty-hint.visible {
    display: block;
}

/* ===== Analytics ===== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.stats-card {
    background: linear-gradient(135deg, #f8f9fb, #ffffff);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px 12px;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.stats-card .stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.stats-card .stat-label {
    font-size: 0.8em;
    color: var(--subtle-text-color);
    margin-top: 4px;
}

.stats-card .stat-value.green {
    color: #27ae60;
}

.stats-card .stat-value.orange {
    color: #e67e22;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.chart-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    background: white;
    transition: box-shadow var(--transition);
}

.chart-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chart-card h3 {
    font-size: 0.9em;
    margin: 0 0 12px 0;
    color: var(--text-color);
    font-weight: 600;
}

.chart-card canvas {
    max-height: 200px;
    max-width: 100%;
}

.streak-display {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    margin: 16px 0;
    text-align: center;
    background: linear-gradient(135deg, #fff5f5, #ffffff);
}

.streak-display .streak-title {
    font-size: 0.9em;
    color: var(--subtle-text-color);
    margin-bottom: 10px;
}

.streak-display .streak-numbers {
    display: flex;
    justify-content: center;
    gap: 48px;
}

.streak-display .streak-item {
    text-align: center;
}

.streak-display .streak-item .number {
    font-size: 2.4em;
    font-weight: 700;
    color: #e74c3c;
    line-height: 1.2;
}

.streak-display .streak-item .label {
    font-size: 0.75em;
    color: var(--subtle-text-color);
    margin-top: 2px;
}

.weekly-ranking {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
}

.weekly-ranking h3 {
    font-size: 0.9em;
    margin: 0 0 12px 0;
    font-weight: 600;
}

.weekly-ranking table {
    width: 100%;
    border-collapse: collapse;
}

.weekly-ranking th,
.weekly-ranking td {
    padding: 8px 6px;
    text-align: left;
    font-size: 0.85em;
    border-bottom: 1px solid var(--border-color);
}

.weekly-ranking th {
    color: var(--subtle-text-color);
    font-weight: 500;
}

.weekly-ranking .rank-bar {
    height: 6px;
    background-color: #eef1f5;
    border-radius: 3px;
    overflow: hidden;
}

.weekly-ranking .rank-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #6db3f2);
    border-radius: 3px;
}

footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75em;
    color: var(--subtle-text-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
    .container {
        max-width: 100%;
        padding: 20px;
        border-radius: 0;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }

    .nav-tab {
        padding: 8px 10px;
        font-size: 0.85em;
    }

    .nav-tabs {
        gap: 2px;
    }

    .view-container {
        max-height: 60vh;
    }
}

/* ===== Scrollbar ===== */
.view-container::-webkit-scrollbar {
    width: 6px;
}

.view-container::-webkit-scrollbar-track {
    background: transparent;
}

.view-container::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

main {
    max-height: 55vh;
    overflow-y: auto;
    scrollbar-width: thin;
}
