:root {
    --bg: #f6f4ef;
    --surface: #fffdf8;
    --text: #252520;
    --muted: #706d64;
    --line: #d8d2c4;
    --accent: #355f4d;
    --accent-text: #ffffff;
    --danger: #8a3730;
    --input: #ffffff;
}

.theme-dark {
    --bg: #181916;
    --surface: #20221e;
    --text: #ece8dc;
    --muted: #aaa393;
    --line: #3e4038;
    --accent: #adc7b6;
    --accent-text: #151714;
    --danger: #d79a8f;
    --input: #181916;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

body.has-page-image,
body.has-bg-image {
    background-image: var(--page-image);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

body.has-page-image::before,
body.has-bg-image::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: color-mix(in srgb, var(--bg) 24%, transparent);
}

body.has-bg-image .dashboard,
body.has-page-image .dashboard {
    background: transparent;
}

body.is-celebrating .dashboard {
    animation: page-shake 420ms ease;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
.text-action,
.primary-action {
    min-height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    padding: 0.55rem 0.8rem;
    text-decoration: none;
}

button:hover,
.text-action:hover,
.primary-action:hover {
    border-color: var(--accent);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.primary-action,
.compact-form button[type='submit'] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--input);
    color: var(--text);
    padding: 0.65rem 0.7rem;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
}

h1,
h2,
p {
    margin-top: 0;
}

.quiet {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-shell {
    width: min(100%, 31rem);
}

.auth-panel {
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 2rem;
}

.auth-panel h1 {
    margin-bottom: 1.5rem;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 400;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-bottom: 1.2rem;
}

.tab-button {
    border-radius: 0;
}

.tab-button.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.is-hidden {
    display: none;
}

.notice {
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.75rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.25rem clamp(1rem, 3vw, 2rem);
}

.wordmark {
    display: none;
    color: var(--muted);
    text-decoration: none;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-form {
    margin: 0;
}

.top-actions .text-action,
.top-actions button {
    min-height: auto;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.35rem 0.45rem;
    transition: color 180ms ease, opacity 180ms ease;
}

.top-actions .text-action:hover,
.top-actions button:hover {
    color: var(--text);
}

.dashboard {
    display: grid;
    grid-template-columns: clamp(10.5rem, 15vw, 14rem) minmax(22rem, 44rem) clamp(14rem, 20vw, 20rem);
    justify-content: space-between;
    align-items: center;
    gap: clamp(1.5rem, 4vw, 4rem);
    min-height: 100vh;
    padding: clamp(2rem, 8vh, 5rem) clamp(1rem, 2vw, 2rem);
    max-width: none;
    margin: 0 auto;
}

.dashboard input,
.dashboard select {
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
    background: transparent;
    color: var(--text);
    padding: 0.45rem 0;
}

.dashboard input::placeholder {
    color: color-mix(in srgb, var(--muted) 65%, transparent);
}

.dashboard button {
    min-height: auto;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.25rem 0;
    text-align: left;
    transition: color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.dashboard button:hover {
    color: var(--text);
    transform: translateY(-0.05rem);
}

.dashboard button:disabled {
    opacity: 0.28;
}

/* Force todo checkbox to stay visible, even when not hovered */
.dashboard .todo-check,
.todo-check {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.9) !important;
    color: #B0A598 !important;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
}

/* Keep it visible on normal light background too */
body:not(.has-page-image):not(.has-bg-image) .dashboard .todo-check,
body:not(.has-page-image):not(.has-bg-image) .todo-check {
    border-color: rgba(37, 37, 32, 0.85) !important;
    background: rgba(255, 255, 255, 0.5) !important;
    color: var(--text) !important;
    box-shadow: none;
}

.dashboard .todo-check:hover,
.todo-check:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    border-color: #ffffff !important;
    color: #B0A500 !important;
}

.todo-item.completed .todo-check::after {
    content: "✓";
    display: block;
    font-size: 14px;
    line-height: 1;
    color: inherit;
}

.dashboard .compact-form button[type='submit'] {
    background: transparent;
    border: 0;
    color: var(--accent);
    justify-self: start;
}

.panel,
.center-panel {
    min-width: 0;
}

.panel {
    border: 0;
    background: transparent;
    padding: 0;
}

.panel-heading h2 {
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: uppercase;
}

.compact-form,
.stacked-controls {
    display: grid;
    gap: 0.75rem;
}

.compact-form {
    margin-bottom: 1rem;
}

.item-list {
    display: grid;
    gap: 0.9rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.display-item {
    color: var(--text);
    font-size: clamp(1rem, 1.4vw, 1.35rem);
    line-height: 1.25;
    opacity: 0.86;
    transition: opacity 180ms ease, transform 180ms ease;
}

.display-item:hover {
    opacity: 1;
    transform: translateX(0.12rem);
}

.display-item a {
    text-decoration: none;
}

.editable-item {
    display: grid;
    gap: 0.5rem;
    padding: 0.45rem 0;
    transition: color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.editable-item:hover {
    opacity: 0.78;
    transform: translateX(0.15rem);
}

.item-main {
    display: grid;
    gap: 0.1rem;
}

.item-main a {
    font-weight: 400;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25rem;
    overflow-wrap: anywhere;
}

.item-main span,
summary {
    color: var(--muted);
    font-size: 0.9rem;
}

summary {
    cursor: pointer;
}

.row-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.row-actions form,
.editable-item > form {
    margin: 0;
}

.welcome-block {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 2rem);
    text-align: center;
    animation: welcome-fade 4s ease forwards;
    pointer-events: none;
}

.welcome-block h1 { max-width: 22ch; margin: 0; font-size: clamp(1.8rem, 4vw, 3.2rem); font-weight: 400; line-height: 1.1; }
.center-panel {
    position: relative;
    display: grid;
    min-height: 46vh;
    place-items: center;
}

.center-focus {
    display: grid;
    gap: 1rem;
    justify-items: center;
    opacity: 0;
    transform: translateY(0.45rem);
    animation: center-rise 1.25s ease 3.4s forwards;
}

body[data-celebrate='1'] .welcome-block {
    display: none;
}

body[data-celebrate='1'] .center-focus {
    opacity: 1;
    transform: none;
    animation: none;
}

.primary-task,
.quote {
    border-top: 0;
    padding-top: 1.25rem;
    text-align: center;
}

.primary-task h2 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 3.15rem);
    font-weight: 400;
    line-height: 1.05;
}

.main-task-toggle {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    justify-items: center;
    margin: 0;
}

.main-task-toggle.is-complete h2 {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-thickness: 0.06em;
}

/* Better quote alignment */
.quote {
    position: relative;
    max-width: 38rem;
    margin: 1rem auto 0;
    color: var(--muted);
    padding: 0.4rem 2.2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.quote p {
    margin: 0;
    font-size: clamp(1.05rem, 1.8vw, 1.45rem);
}

.quote::before,
.quote::after {
    position: static;
    color: var(--accent);
    font-family: Georgia, serif;
    font-size: 2.6rem;
    line-height: 1;
    opacity: 0.45;
    transform: translateY(0.12rem);
}

.quote::before {
    content: open-quote;
}

.quote::after {
    content: close-quote;
}

.quote cite {
    font-style: normal;
}

.task-toggle-form {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    margin: 0;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* More visible todo checkbox */
.todo-check {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.todo-check:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Light theme without image */
body:not(.has-page-image):not(.has-bg-image) .todo-check {
    border-color: rgba(37, 37, 32, 0.8);
    background: rgba(255, 255, 255, 0.45);
    color: var(--text);
    box-shadow: none;
}

/* Completed todo */
.todo-item.completed .todo-text {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-thickness: 0.06em;
    opacity: 0.6;
}

.todo-item.completed .todo-check {
    border-style: solid;
    opacity: 1;
}

.todo-item.completed .todo-check::after {
    content: "✓";
    display: block;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    color: inherit;
}
.focus-view {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    place-items: center;
    background: var(--bg);
}

.focus-view.is-active {
    display: grid;
}

.focus-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--text);
}

.page-actions {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.icon-action {
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.35rem;
}

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

.icon-action svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.settings-panel {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 45;
    width: min(100vw, 26rem);
    max-height: 100vh;
    overflow: auto;
    background: var(--bg);
    border-right: 1px solid var(--line);
    color: var(--text);
    padding: 1.2rem;
    transform: translateX(-100%);
    transition: transform 220ms ease;
}

.settings-panel.is-open {
    transform: translateX(0);
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.settings-head h2,
.settings-section h3 {
    margin: 0;
    font-weight: 400;
}

.settings-section {
    display: grid;
    gap: 0.8rem;
    border-top: 1px solid var(--line);
    padding: 1rem 0;
}

.settings-panel input,
.settings-panel select {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    padding: 0.45rem 0;
}

.settings-panel button,
.settings-logout {
    min-height: auto;
    border: 0;
    background: transparent;
    color: var(--accent);
    padding: 0.25rem 0;
    text-align: left;
    text-decoration: none;
}

.settings-list {
    display: grid;
    gap: 0.85rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.settings-list li {
    display: grid;
    gap: 0.45rem;
}

.settings-list summary {
    color: var(--text);
}

.settings-item-title {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.fireworks {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    overflow: hidden;
}

.firework {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    animation: firework-pop 900ms ease-out forwards;
}

.firework:nth-child(3n) {
    color: var(--text);
    background: currentColor;
}

.firework:nth-child(3n + 1) {
    color: var(--muted);
    background: currentColor;
}

@keyframes welcome-fade {
    0% {
        opacity: 0;
        transform: translateY(0.35rem);
    }

    18%,
    62% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-0.35rem);
        visibility: hidden;
    }
}

@keyframes center-rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes page-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-0.35rem);
    }

    40% {
        transform: translateX(0.35rem);
    }

    60% {
        transform: translateX(-0.2rem);
    }

    80% {
        transform: translateX(0.2rem);
    }
}

@keyframes firework-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }

    18% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.9);
    }
}

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
        max-width: 36rem;
        align-items: start;
        padding-bottom: 5rem;
    }

    .center-panel {
        order: -1;
        min-height: 52vh;
    }

    .welcome-block h1 {
        max-width: 14ch;
    }
}

@media (max-width: 560px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-actions {
        justify-content: flex-start;
    }

    .auth-panel {
        padding: 1rem;
    }

    .welcome-block h1 {
        font-size: 2rem;
    }
}


body.skip-welcome .welcome-block {
    display: none;
}

body.skip-welcome .center-focus {
    opacity: 1;
    transform: none;
    animation: none;
}
