:root {
    --bg: #0a0b0d;
    --surface: #16181d;
    --accent: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --border: #26292f;
    --calendar-inv: invert(1);
    --modal-bg: rgba(10, 11, 13, 0.85);
}

[data-theme="light"] {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --accent: #2563eb;
    --success: #059669;
    --danger: #dc2626;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --calendar-inv: invert(0);
    --modal-bg: rgba(243, 246, 249, 0.85);
}

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

html, body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- Navigation --- */
.top-nav {
    background: var(--surface);
    padding: 12px 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    gap: 15px;
    flex-wrap: wrap;
}

.logo {
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1;
    min-width: fit-content;
    flex: 0 0 auto;
}

.logo span {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Auth UI */
#auth-ui {
    flex: 1 1 240px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

#login-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 100px;
    font-weight: 800;
    font-size: 0.75rem;
    cursor: pointer;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#user-info {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 50px;
    border: 1px solid var(--border);
    max-width: 100%;
    min-width: 0;
}

#user-pic {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    flex: 0 0 auto;
}

#user-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#logout-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    font-weight: 800;
    font-size: 0.65rem;
    cursor: pointer;
    padding-left: 8px;
    border-left: 1px solid var(--border);
    white-space: nowrap;
}

/* Time */
.time-box {
    text-align: right;
    min-width: fit-content;
    flex: 0 0 auto;
}

#liveTime {
    font-weight: 800;
    color: var(--accent);
    font-size: 1rem;
}

#liveDate {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 600;
}

/* Layout */
.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
    min-height: 80vh;
}

/* Suggestions */
.suggestion-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-dim);
    margin-bottom: 10px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-label span {
    color: var(--accent);
    animation: pulse 2s infinite;
}

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

.suggestion-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.chip {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}

.chip:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

/* Cards */
.card {
    background: var(--surface);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--surface);
    padding: 5px;
    border-radius: 14px;
    border: 1px solid var(--border);
    width: fit-content;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 20px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.tab.active {
    background: var(--accent);
    color: white;
}

/* Entry Form */
.entry-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(120px, 1fr);
    gap: 12px;
    align-items: stretch;
}

.input-wrapper {
    position: relative;
    width: 100%;
    min-width: 0;
}

input {
    width: 100%;
    background: var(--bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 12px 42px 12px 12px;
    border-radius: 12px;
    outline: none;
    font-weight: 600;
    min-width: 0;
}

input:focus {
    border-color: var(--accent);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--danger);
    cursor: pointer;
    font-weight: 800;
    display: none;
    z-index: 2;
}

input:not(:placeholder-shown) + .clear-btn {
    display: block;
}

.btn-add {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    min-height: 46px;
    padding: 12px 16px;
    white-space: nowrap;
}

/* Task List */
.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.item {
    background: var(--surface);
    padding: 15px;
    border-radius: 18px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Switch */
.switch {
    position: relative;
    width: 44px;
    height: 22px;
    flex: 0 0 auto;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #2d3139;
    border-radius: 34px;
}

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

input:checked + .slider {
    background: var(--success);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Footer */
#footer {
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 50px;
}

.f-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    margin: 10px 15px;
    font-size: 0.85rem;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-bg);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    position: relative;
    z-index: 2001;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.summary-box {
    background: var(--surface);
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Mobile */
@media (max-width: 768px) {
    .top-nav {
        justify-content: center;
        text-align: center;
        padding: 15px;
    }

    .logo {
        order: 1;
        width: 100%;
        text-align: center;
    }

    .time-box {
        order: 2;
        width: 100%;
        text-align: center;
    }

    #auth-ui {
        order: 3;
        width: 100%;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
        justify-content: center;
    }

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

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

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

    #user-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .tabs {
        width: 100%;
    }

    .tab {
        flex: 1 1 auto;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .card {
        padding: 16px;
    }

    .logo, .time-box {
        width: 100%;
        text-align: center;
    }

    .logo {
        margin-bottom: 5px;
    }

    .btn-add {
        width: 100%;
    }

    .item {
        flex-direction: column;
        align-items: stretch;
    }
}

.month-summary-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.month-summary-card:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.month-summary-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.month-summary-name {
    font-weight: 800;
    font-size: 1rem;
}

.month-summary-sub {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 4px;
}

.month-summary-score {
    font-weight: 800;
    color: var(--accent);
    font-size: 1rem;
}

.month-detail-card {
    max-width: 560px;
    width: 100%;
}

.month-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.month-detail-kicker {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    font-weight: 800;
    margin-bottom: 4px;
}

.month-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: var(--bg);
    color: var(--danger);
    font-size: 1.25rem;
    font-weight: 900;
    cursor: pointer;
}

.month-detail-list {
    display: grid;
    gap: 12px;
    max-height: min(60vh, 520px);
    overflow: auto;
    padding-right: 4px;
}

.month-activity-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
}

.month-activity-name {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 6px;
    word-break: break-word;
}

.month-activity-meta {
    color: var(--text-dim);
    font-size: 0.9rem;
}
