:root {
    --background: #f5f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #778096;
    --primary: #be123c;
    --border: #e7eaf1;
    --danger: #ef4444;
    --shadow: 0 10px 30px rgba(20, 30, 60, 0.07);
    --input-bg: #ffffff;
    --empty-icon-bg: #eef0ff;
    --delete-hover-bg: #fff0f0;
    --done-hover-bg: #eef7ee;
    --done-border: #d1d5e0;
    --done-btn-color: #a3aabd;
    --error-bg: #fff1f2;
    --error-color: #be123c;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f1117;
        --card: #1a1d27;
        --text: #e4e6ed;
        --muted: #8b8fa3;
        --primary: #be123c;
        --border: #2a2d3a;
        --danger: #f87171;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
        --input-bg: #1a1d27;
        --empty-icon-bg: #252840;
        --delete-hover-bg: #2d1f1f;
        --done-hover-bg: #1a2e1a;
        --done-border: #3a3d4a;
        --done-btn-color: #6b7085;
        --error-bg: #2d1f1f;
        --error-color: #fca5a5;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* -------------------------------------------------------
   Header
------------------------------------------------------- */

.topbar {
    height: 68px;
    background: var(--card);
    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 32px;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;

    font-size: 20px;
    font-weight: 700;
}

.logo-small {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: var(--primary);
    color: white;
    font-weight: 800;
}

.logo-small-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    color: white;
    padding: 7px 12px;
    border-radius: 20px;

    font-size: 13px;
    font-weight: 700;
}

.logout {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

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


/* -------------------------------------------------------
   Main
------------------------------------------------------- */

.container {
    width: min(800px, calc(100% - 32px));
    margin: 50px auto;
}

.welcome h1 {
    margin: 0 0 6px;

    font-size: 34px;
    letter-spacing: -1px;
}

.welcome p {
    margin: 0;
    color: var(--muted);
}


/* -------------------------------------------------------
   Input
------------------------------------------------------- */

.new-todo {
    margin-top: 28px;
}

.new-todo form {
    display: flex;
    gap: 10px;
}

input[type="text"],
input[type="password"] {
    width: 100%;

    border: 1px solid var(--border);
    background: var(--input-bg);

    border-radius: 12px;

    padding: 15px 17px;

    font-size: 16px;
    color: var(--text);

    outline: none;

    box-shadow: var(--shadow);
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.12),
        var(--shadow);
}

button {
    border: 0;
    border-radius: 12px;

    padding: 0 22px;

    background: var(--primary);
    color: white;

    font-size: 15px;
    font-weight: 700;

    cursor: pointer;
    transition: 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(0.96);
}


/* -------------------------------------------------------
   Todo list
------------------------------------------------------- */

.todo-list {
    margin-top: 24px;

    display: flex;
    flex-direction: column;
    gap: 10px;
}

.todo-item {
    background: var(--card);

    border: 1px solid var(--border);
    border-radius: 14px;

    padding: 16px;

    display: flex;
    align-items: center;
    gap: 14px;

    box-shadow: 0 4px 15px rgba(20, 30, 60, 0.035);

    transition: 0.15s ease;
}

.todo-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.avatar {
    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: white;
    font-weight: 800;
}

.todo-content {
    flex: 1;
    min-width: 0;
}

.todo-text {
    font-size: 16px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.todo-user {
    margin-top: 5px;

    font-size: 12px;
    font-weight: 700;
}

.delete-button {
    width: 34px;
    height: 34px;

    padding: 0;

    background: transparent;
    color: var(--done-btn-color);

    font-size: 24px;
    font-weight: 400;
}

.delete-button:hover {
    background: var(--delete-hover-bg);
    color: var(--danger);
    transform: none;
}

.done-button {
    width: 34px;
    height: 34px;

    padding: 0;

    background: transparent;
    color: var(--done-btn-color);
    border: 2px solid var(--done-border);

    border-radius: 50%;

    font-size: 16px;
    font-weight: 700;
    line-height: 1;

    display: flex;
    align-items: center;
    justify-content: center;
}

.done-button:hover {
    background: var(--done-hover-bg);
    color: #16a34a;
    border-color: #16a34a;
    transform: none;
}

.undone-button {
    width: 34px;
    height: 34px;

    padding: 0;

    background: transparent;
    color: var(--done-btn-color);

    font-size: 18px;
    font-weight: 400;

    border-radius: 12px;
}

.undone-button:hover {
    background: var(--done-hover-bg);
    color: #16a34a;
    transform: none;
}

.done-section {
    margin-top: 40px;
}

.done-heading {
    font-size: 18px;
    color: var(--muted);
    margin: 0 0 12px;
}

.todo-done {
    opacity: 0.55;
}

.todo-done .todo-text {
    text-decoration: line-through;
}


/* -------------------------------------------------------
   Empty state
------------------------------------------------------- */

.empty {
    background: var(--card);

    border: 1px dashed var(--border);
    border-radius: 16px;

    padding: 50px 20px;

    text-align: center;
}

.empty-icon {
    margin: auto;

    width: 52px;
    height: 52px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--empty-icon-bg);
    color: var(--primary);

    font-size: 22px;
    font-weight: 800;
}

.empty h2 {
    margin: 15px 0 5px;
    font-size: 18px;
}

.empty p {
    margin: 0;
    color: var(--muted);
}


/* -------------------------------------------------------
   Login
------------------------------------------------------- */

.login-page {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
}

.login-card {
    width: min(400px, 100%);

    background: var(--card);

    border: 1px solid var(--border);
    border-radius: 20px;

    padding: 40px;

    box-shadow: var(--shadow);

    text-align: center;
}

.logo {
    width: 60px;
    height: 60px;

    margin: 0 auto 20px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 17px;

    background: var(--primary);
    color: white;

    font-size: 28px;
    font-weight: 800;
}

.login-card h1 {
    margin: 0;
    font-size: 28px;
}

.subtitle {
    color: var(--muted);
    margin: 8px 0 28px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card button {
    height: 50px;
}

.error {
    margin-bottom: 16px;

    padding: 12px;

    border-radius: 10px;

    background: var(--error-bg);
    color: var(--error-color);

    font-size: 14px;
}


/* -------------------------------------------------------
   Mobile
------------------------------------------------------- */

@media (max-width: 600px) {

    .topbar {
        padding: 0 16px;
    }

    .logout {
        display: none;
    }

    .container {
        margin: 30px auto;
        padding-bottom: 90px;
    }

    .welcome h1 {
        font-size: 28px;
    }

    .new-todo {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        margin: 0;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        background: var(--card);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    }

    .new-todo form {
        flex-direction: row;
    }

    .new-todo button {
        height: 48px;
    }

    .login-card {
        padding: 30px 22px;
    }
}
