:root {
    --color-bg: #f7f7fb;
    --color-surface: #ffffff;
    --color-text: #1c1c26;
    --color-muted: #62626e;
    --color-border: #d8d8e2;
    --color-accent: #3b5bfd;
    --color-accent-text: #ffffff;
    --color-accent-soft: #e8ecff;
    --color-error: #c0293c;
    --color-error-soft: #fbe3e6;
    --color-success: #1a7f4f;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #14141b;
        --color-surface: #1e1e28;
        --color-text: #ecebf3;
        --color-muted: #a3a2b3;
        --color-border: #33333f;
        --color-accent: #7b93ff;
        --color-accent-text: #14141b;
        --color-accent-soft: #262c4a;
        --color-error: #ff6b7d;
        --color-error-soft: #3d2129;
        --color-success: #4fd394;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --color-bg: #14141b;
    --color-surface: #1e1e28;
    --color-text: #ecebf3;
    --color-muted: #a3a2b3;
    --color-border: #33333f;
    --color-accent: #7b93ff;
    --color-accent-text: #14141b;
    --color-accent-soft: #262c4a;
    --color-error: #ff6b7d;
    --color-error-soft: #3d2129;
    --color-success: #4fd394;
    color-scheme: dark;
}

html {
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    /* 100vh on mobile Chrome/Safari uses the *largest* possible viewport
       (address bar hidden) -- while the address bar is actually showing,
       that makes the page taller than what's visible, pushing the sticky
       footer below the fold. 100dvh tracks the real, currently-visible
       viewport instead; the 100vh line above it is a fallback for browsers
       that don't support dvh. */
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    width: 100%;
    max-width: 28rem;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

h2, h3 {
    font-size: 1rem;
    margin: 0 0 0.75rem;
}

main section {
    margin-bottom: 2rem;
}

/* [hidden] - an author stylesheet rule always beats the browser's own
   `[hidden] { display: none }` UA rule, regardless of specificity. This
   bit twice already: `main ul` giving every <ul> `display: flex`
   unconditionally silently defeated `hidden` on the finished-today list
   (the one <ul> that toggles it directly), and then `#undo-toast`'s own
   `display: flex` did the same to itself -- an ID selector beats this
   rule's plain attribute selector regardless of source order, same trap,
   one specificity tier higher. `!important` here instead of chasing every
   future element's own `display:` with a `:not([hidden])` override --
   `hidden` should always just mean invisible. */
[hidden] {
    display: none !important;
}

main ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

main li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    padding: 0.6rem 0.8rem;
}

/* task-due-today - a task instance due today (not overdue, not later),
   on the household Tasks tab and My Tasks alike -- a lighter touch than
   the plain-text "OVERDUE" marker overdue tasks already get, since due
   today isn't a problem yet, just worth noticing at a glance. */
main li.task-due-today {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
}

/* task-overdue - the red counterpart to task-due-today, for a task whose
   due date has actually passed: same isTaskOverdue() check that already
   drives the plain-text "OVERDUE" marker, now also reddening the row
   itself so an overdue task stands out at a glance, not just on close
   reading of its label. */
main li.task-overdue {
    background: var(--color-error-soft);
    border-color: var(--color-error);
}

main li .li-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

main li button {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

main button.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    background: transparent;
    color: var(--color-muted);
    flex-shrink: 0;
}

main button.icon-button:hover {
    color: var(--color-accent);
    background: var(--color-bg);
}

.inline-edit-form {
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    gap: 0.6rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

#household-detail-section > button {
    margin-top: 1rem;
}

#home-improvement-project-detail {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.25rem;
}

button.tab-button,
button.top-tab-button,
button.hi-tab-button {
    background: none;
    color: var(--color-muted);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.6rem 0.9rem;
    border-radius: 0.4rem 0.4rem 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

button.tab-button:hover,
button.top-tab-button:hover,
button.hi-tab-button:hover {
    color: var(--color-text);
    background: var(--color-surface);
}

button.tab-button[aria-selected="true"],
button.top-tab-button[aria-selected="true"],
button.hi-tab-button[aria-selected="true"] {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.tab-panel,
.top-tab-panel,
.hi-tab-panel {
    margin-bottom: 2rem;
}

label {
    font-size: 0.85rem;
    color: var(--color-muted);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* contact-entry-row (a phone/email row in the household contacts form) --
   select is content-sized (its "Home"/"Mobile"/"Work" text is short), but
   the value input needs min-width: 0 to actually shrink inside the flex
   row instead of overflowing past the icon-button on a narrow screen; the
   media query below narrows it further still, leaving a little more room
   for the button on the smallest screens. */
.contact-entry-row select {
    flex: 0 0 auto;
}

.contact-entry-row input {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 480px) {
    .contact-entry-row input {
        max-width: 90%;
    }
}

.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

fieldset.checkbox-fieldset {
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

fieldset.checkbox-fieldset legend {
    font-size: 0.85rem;
    color: var(--color-muted);
    padding: 0 0.3rem;
}

fieldset.checkbox-fieldset .checkbox-label {
    color: var(--color-text);
}

button.button--compact {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.inline-number-unit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inline-number-unit input {
    width: 5rem;
}

input {
    font: inherit;
    padding: 0.55rem 0.7rem;
    border-radius: 0.4rem;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
}

button {
    font: inherit;
    font-weight: 600;
    padding: 0.6rem 1rem;
    border-radius: 0.4rem;
    border: none;
    background: var(--color-accent);
    color: var(--color-accent-text);
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: default;
}

a {
    color: var(--color-accent);
}

.form-links {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.message {
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

.message--error {
    color: var(--color-error);
}

.message--success {
    color: var(--color-success);
}

/* #undo-toast - the brief "Undo" affordance after completing a task (see
   main.js's showUndoToast()), fixed to the bottom of the viewport so it's
   visible regardless of scroll position. No box-shadow used anywhere else
   in the app, but this is the first floating-over-content element -- needs
   one for visual separation from whatever's underneath it. */
#undo-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: calc(100vw - 2rem);
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

#undo-toast-message {
    font-size: 0.9rem;
}

#undo-toast-button {
    flex-shrink: 0;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* #app-version is a link (to the GitHub repo) rather than plain text, but
   should still read as the same muted footer text until hovered -- `a`
   below otherwise wins over the inherited footer color regardless of
   selector order, since it targets the element directly. */
#app-version {
    color: inherit;
    text-decoration: none;
}

#app-version:hover {
    text-decoration: underline;
}

footer select {
    font: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 0.3rem;
}

/* Buy Me a Coffee's own static badge (buymeacoffee.com/jceddy) -- a plain
   image link rather than their animated widget script, since that widget
   is sized for a standalone placement (see MoodSwings-Web's own Resources
   dialog) and would dominate this slim inline footer bar otherwise. */
footer .coffee-link img {
    display: block;
    height: 1.75rem;
    width: auto;
}
