/* --- Global Variables & Reset --- */
:root {
    --bg-color: #000000;
    --surface-color: #1c1c1e;
    --surface-hover: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --border-color: #38383a;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition-speed: 0.2s;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #f5f5f7;
        --surface-color: #ffffff;
        --surface-hover: #f0f0f5;
        --text-primary: #1d1d1f;
        --text-secondary: #86868b;
        --border-color: #e5e5ea;
        --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
    }
}

body {
    /* Apple system font stack */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color var(--transition-speed) ease-in-out, color var(--transition-speed) ease-in-out;
}

/* Auth Container */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    min-height: 100vh;
}

.auth-box {
    background: var(--surface-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 340px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.auth-title {
    margin: 0;
    font-size: 2em;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-subtitle {
    margin: 8px 0 24px 0;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-input {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 1em;
    font-family: inherit;
    transition: all var(--transition-speed) ease;
    outline: none;
}

.auth-input:focus {
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 2px rgba(142, 142, 147, 0.2);
}

.auth-btn {
    background: var(--text-primary);
    color: var(--bg-color);
    border: none;
    padding: 14px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-family: inherit;
    margin-top: 8px;
}

.auth-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 24px;
    cursor: pointer;
    font-family: inherit;
    transition: color var(--transition-speed) ease;
    padding: 8px;
}

.auth-toggle-btn:hover {
    color: var(--text-primary);
}


/* Header & Footer */
header, footer {
    padding: 24px 0;
    text-align: center;
    color: var(--text-primary);
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 600;
    letter-spacing: -0.02em;
}

footer {
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Links */
a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-speed) ease-in-out;
}
a:hover {
    color: var(--text-primary);
}

/* Main Layout */
#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}
.main-layout-container {
    display: flex;
    flex-direction: row;
    gap: 60px;
    width: 100%;
    max-width: 900px;
    justify-content: center;
    align-items: flex-start;
}

/* To-Do List */
.todo-container {
    width: 320px;
    background: var(--surface-color);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: 600px;
    border: 1px solid var(--border-color);
}
.todo-header {
    text-align: center;
    margin-bottom: 20px;
}
.todo-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
}
.todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}
.todo-list::-webkit-scrollbar {
    width: 6px;
}
.todo-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.todo-list li {
    background: var(--bg-color);
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: var(--border-radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    font-size: 0.95em;
    transition: all var(--transition-speed) ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
}
.todo-list li:hover {
    background: var(--surface-hover);
    border-color: var(--border-color);
    transform: translateY(-1px);
}
.todo-list li.completed {
    text-decoration: line-through;
    opacity: 0.4;
    background: transparent;
    border-color: var(--border-color);
    transform: none;
}

/* Input & Add Button */
.todo-input-container {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
}
.todo-input {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    width: 100%;
    font-size: 0.95em;
    font-family: inherit;
    transition: all var(--transition-speed) ease-in-out;
    outline: none;
}
.todo-input:focus {
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 2px rgba(142, 142, 147, 0.2);
}
.todo-add-btn {
    background: var(--text-primary);
    color: var(--bg-color);
    border: none;
    padding: 0 20px;
    border-radius: var(--border-radius-sm);
    font-size: 1.5em;
    cursor: pointer;
    transition: opacity var(--transition-speed) ease-in-out, transform var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.todo-add-btn:hover {
    opacity: 0.8;
    transform: scale(1.05);
}
.todo-add-btn:active {
    transform: scale(0.95);
}

.delete-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-speed) ease-in-out, color var(--transition-speed) ease-in-out;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.todo-list li:hover .delete-btn {
    opacity: 1;
}
.delete-btn:hover {
    color: var(--text-primary);
}

/* Pomodoro Timer */
.main-content-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.centered-content {
    margin-bottom: 20px;
}
.centered-content p {
    margin: 5px 0;
    font-size: 0.95em;
    color: var(--text-secondary);
}

#pomodoro-timer {
    background: var(--surface-color);
    color: var(--text-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-width: 250px;
    border: 1px solid var(--border-color);
}
.timer-display {
    font-size: 4em;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
}

.timer-controls {
    display: flex;
    gap: 10px;
}
.timer-controls button {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 20px; /* pill shape for Apple style */
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease-in-out;
    font-family: inherit;
}
.timer-controls button:hover {
    background: var(--text-primary);
    color: var(--bg-color);
    border-color: var(--text-primary);
}
.timer-controls button:active {
    transform: scale(0.96);
}

/* Circular progress bar */
.progress-ring {
    transform: rotate(-90deg);
    margin-top: 10px;
}
.progress-ring-background {
    stroke: var(--border-color);
}
.progress-ring-circle {
    transition: stroke-dashoffset 0.5s ease-out;
    stroke: var(--text-primary);
    stroke-dasharray: calc(2 * 3.14159 * 40);
    stroke-dashoffset: calc(2 * 3.14159 * 40);
    stroke-linecap: round;
}

/* Extra Info */
#clock, #progress {
    color: var(--text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* --- Heatmap Stats --- */
.heatmap-container {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

.heatmap-container h4 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 500;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.heatmap-cell {
    width: 14px;
    height: 14px;
    background-color: var(--bg-color);
    border-radius: 4px;
    transition: background-color 0.3s;
}

/* Heatmap intensity levels - Apple style subtle greens/grays depending on monochrome requirement. Using pure grayscale as requested */
.heatmap-cell[data-level="1"] { background-color: rgba(142, 142, 147, 0.3); }
.heatmap-cell[data-level="2"] { background-color: rgba(142, 142, 147, 0.6); }
.heatmap-cell[data-level="3"] { background-color: rgba(142, 142, 147, 0.9); }
.heatmap-cell[data-level="4"] { background-color: var(--text-primary); }

/* --- Random Quotes Block --- */
.quotes-container {
    margin-top: 24px;
    background: var(--surface-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    text-align: center;
    border: 1px solid var(--border-color);
}
.random-quote {
    font-style: normal;
    font-weight: 400;
    font-size: 1.05em;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 10px;
}
.quote-author {
    margin-top: 10px;
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Mobile Optimization --- */
@media (max-width: 768px) {
    main {
        padding: 20px 16px;
    }

    .main-layout-container {
        flex-direction: column;
        gap: 24px;
        align-items: stretch;
        width: 100%;
        box-sizing: border-box;
    }

    .todo-container {
        width: 100%;
        box-sizing: border-box;
        padding: 20px 16px;
    }

    #pomodoro-timer {
        width: 100%;
        box-sizing: border-box;
        padding: 24px 16px;
    }

    .auth-box {
        padding: 24px 16px;
        margin: 0 16px;
    }

    /* Touch Targets & Minimum Font Size to prevent iOS zoom */
    input, button, .auth-btn, .todo-add-btn, .timer-controls button, .auth-input, .todo-input, .todo-list li {
        min-height: 44px;
        font-size: 16px;
    }

    .delete-btn, .todo-add-btn {
        min-width: 44px;
        min-height: 44px;
    }
}