* {
    box-sizing: border-box;
}

html {
    background: var(--color-bg);
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--color-text);
    min-height: 100vh;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--color-bg-header);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
}

.site-header-end {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-nav {
    display: flex;
    gap: 16px;
}

/* The user's initial in a circle, at the top right: their profile and
   settings. */
.avatar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--color-button-text);
    background: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}

.avatar[aria-current="page"] {
    box-shadow: 0 0 0 2px var(--color-bg-header), 0 0 0 4px var(--color-accent);
}

.avatar:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.site-nav a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.site-nav a[aria-current="page"] {
    color: var(--color-text);
    font-weight: 600;
}

/* The logo, four links and the avatar need about 375px; narrower phones (360px
   is common) get them a little tighter rather than a page zoomed out. */
@media (max-width: 380px) {
    .site-header {
        gap: 8px;
        padding: 12px;
    }

    .site-header-end,
    .site-nav {
        gap: 8px;
    }

    .site-nav a {
        font-size: 0.875rem;
    }
}

@media (hover: hover) {
    .site-nav a:hover {
        color: var(--color-text);
    }
}

.brand {
    display: inline-block;
    vertical-align: top;
}

.brand img {
    display: block;
}

/* The large app icon at the top of the login and error pages. */
.page-icon {
    display: block;
    margin: 0 auto 24px;
}

.error {
    max-width: 480px;
    margin: 15vh auto 0;
    padding: 0 16px;
    text-align: center;
}

.error-code {
    color: var(--color-accent);
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
}

.error-title {
    font-size: 1.5rem;
    margin: 16px 0 8px;
}

.error-message {
    color: var(--color-text-muted);
    margin: 0 0 24px;
}

.error-home {
    color: var(--color-link);
}

.login {
    max-width: 480px;
    margin: 15vh auto 0;
    padding: 0 16px;
    text-align: center;
}

.login-title {
    font-size: 1.5rem;
    margin: 0 0 8px;
}

.login-message {
    color: var(--color-text-muted);
    margin: 0 0 24px;
}

/* Google's own button artwork, which their branding guidelines say not to
   restyle. Hover and press get a Material-style state layer over it instead. */
.google-signin {
    position: relative;
    display: inline-block;
    border-radius: 4px;
}

.google-signin img {
    display: block;
}

.google-signin::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: #e3e3e3; /* the button's text colour */
    opacity: 0;
    transition: opacity 150ms;
}

/* Touch screens keep :hover after a tap, so only real pointers get it. */
@media (hover: hover) {
    .google-signin:hover::after {
        opacity: 0.08;
    }
}

.google-signin:active::after {
    opacity: 0.1;
}

.google-signin:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
}

.list-name,
.page-title {
    font-size: 1.5rem;
    margin: 0 0 16px;
}

.list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.list-header-link {
    color: var(--color-link);
    font-size: 0.875rem;
    text-decoration: none;
}

.list-header-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.list-cadence {
    margin: -12px 0 16px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.add-item {
    margin: 0 0 16px;
}

.add-item-row,
.new-list-row {
    display: flex;
    gap: 8px;
}

.add-item-title,
.add-item-note textarea,
.item-edit-note,
.new-list-name {
    width: 100%;
    padding: 10px 12px;
    font: inherit; /* 16px, below which iOS zooms in on focus */
    color: var(--color-text);
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.add-item-title,
.new-list-name {
    flex: 1;
    min-width: 0;
}

.add-item-title::placeholder,
.new-list-name::placeholder {
    color: var(--color-placeholder);
}

.add-item-title:focus-visible,
.add-item-note textarea:focus-visible,
.item-edit-note:focus-visible,
.add-item-submit:focus-visible,
.new-list-name:focus-visible,
.new-list-submit:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.add-item-submit,
.new-list-submit {
    padding: 0 16px;
    font: inherit;
    font-weight: 600;
    color: var(--color-button-text);
    background: var(--color-button-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

@media (hover: hover) {
    .add-item-submit:hover,
    .new-list-submit:hover {
        filter: brightness(1.08);
    }
}

/* The list picker and "Add a note" share a row, and an open note takes all
   of it. */
.add-item-more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-top: 8px;
}

.add-item-note[open] {
    flex-basis: 100%;
}

/* Only a mixed list's items choose how they repeat. */
.add-item-repeat {
    display: none;
}

.add-item[data-cadence="mixed"] .add-item-repeat,
.item-edit[data-cadence="mixed"] .add-item-repeat,
.add-item:has(select[name="list"] option[data-cadence="mixed"]:checked) .add-item-repeat {
    display: revert;
}

/* A daily item's days: on a daily list, or a mixed list's item picked to
   repeat daily. */
.add-item[data-cadence="daily"] .add-item-weekdays,
.item-edit[data-cadence="daily"] .add-item-weekdays,
.add-item[data-cadence="mixed"]:has(select[name="repeat"] option[value="daily"]:checked) .add-item-weekdays,
.item-edit[data-cadence="mixed"]:has(select[name="repeat"] option[value="daily"]:checked) .add-item-weekdays,
.add-item:has(select[name="list"] option[data-cadence="daily"]:checked) .add-item-weekdays,
.add-item:has(select[name="list"] option[data-cadence="mixed"]:checked):has(select[name="repeat"] option[value="daily"]:checked) .add-item-weekdays {
    display: flex;
}

/* When a repeating item is due, and when to remind of it: a time, and the day
   its period has. */
.add-item-due,
.add-item-remind {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    flex-basis: 100%;
    margin: 0;
    padding: 0;
    border: none;
}

:is(.add-item-due, .add-item-remind) legend {
    float: left; /* keeps the legend on the row, beside the fields */
    color: var(--color-text-muted);
}

.add-item-due-weekday,
.add-item-due-month-day,
.add-item-remind-weekday,
.add-item-remind-month-day {
    display: none;
}

:is(.add-item, .item-edit)[data-cadence="daily"] :is(.add-item-due, .add-item-remind),
:is(.add-item, .item-edit)[data-cadence="weekly"] :is(.add-item-due, .add-item-remind),
:is(.add-item, .item-edit)[data-cadence="monthly"] :is(.add-item-due, .add-item-remind),
:is(.add-item, .item-edit)[data-cadence="mixed"]:has(select[name="repeat"] option:not([value="never"]):checked) :is(.add-item-due, .add-item-remind),
.add-item:has(select[name="list"] option[data-cadence="daily"]:checked) :is(.add-item-due, .add-item-remind),
.add-item:has(select[name="list"] option[data-cadence="weekly"]:checked) :is(.add-item-due, .add-item-remind),
.add-item:has(select[name="list"] option[data-cadence="monthly"]:checked) :is(.add-item-due, .add-item-remind),
.add-item:has(select[name="list"] option[data-cadence="mixed"]:checked):has(select[name="repeat"] option:not([value="never"]):checked) :is(.add-item-due, .add-item-remind) {
    display: flex;
}

:is(.add-item, .item-edit)[data-cadence="weekly"] :is(.add-item-due-weekday, .add-item-remind-weekday),
:is(.add-item, .item-edit)[data-cadence="mixed"]:has(select[name="repeat"] option[value="weekly"]:checked) :is(.add-item-due-weekday, .add-item-remind-weekday),
.add-item:has(select[name="list"] option[data-cadence="weekly"]:checked) :is(.add-item-due-weekday, .add-item-remind-weekday),
.add-item:has(select[name="list"] option[data-cadence="mixed"]:checked):has(select[name="repeat"] option[value="weekly"]:checked) :is(.add-item-due-weekday, .add-item-remind-weekday),
:is(.add-item, .item-edit)[data-cadence="monthly"] :is(.add-item-due-month-day, .add-item-remind-month-day),
:is(.add-item, .item-edit)[data-cadence="mixed"]:has(select[name="repeat"] option[value="monthly"]:checked) :is(.add-item-due-month-day, .add-item-remind-month-day),
.add-item:has(select[name="list"] option[data-cadence="monthly"]:checked) :is(.add-item-due-month-day, .add-item-remind-month-day),
.add-item:has(select[name="list"] option[data-cadence="mixed"]:checked):has(select[name="repeat"] option[value="monthly"]:checked) :is(.add-item-due-month-day, .add-item-remind-month-day) {
    display: revert;
}

/* Which Remind applies: a select can't hide some of its options everywhere, so
   an item with a due time has one, with "before" to choose, and one without has
   another. Picking a time of its own shows when. */
.add-item-remind-timed,
.add-item-remind-own {
    display: none;
}

:is(.add-item, .item-edit):has(select[name="due_hour"] option:not([value=""]):checked) .add-item-remind-timed {
    display: revert;
}

:is(.add-item, .item-edit):has(select[name="due_hour"] option:not([value=""]):checked) .add-item-remind-untimed {
    display: none;
}

/* A one-off with a due time has it from "Remind me", where it can't be changed,
   and is reminded before it. */
.item-edit:has(input[name="one_off_due"]):has(select[name="repeat"] option[value="never"]:checked) .add-item-remind {
    display: flex;
}

.item-edit:has(input[name="one_off_due"]):has(select[name="repeat"] option[value="never"]:checked) .add-item-remind-timed {
    display: revert;
}

.item-edit:has(input[name="one_off_due"]):has(select[name="repeat"] option[value="never"]:checked) .add-item-remind-untimed {
    display: none;
}

:is(.add-item, .item-edit):has(select[name="due_hour"] option:not([value=""]):checked):has(select[name="remind"] option[value="at"]:checked) .add-item-remind-own,
:is(.add-item, .item-edit):has(select[name="due_hour"] option[value=""]:checked):has(select[name="remind_untimed"] option[value="at"]:checked) .add-item-remind-own {
    display: contents;
}

/* Why a form was refused, under the row it was sent from. */
.form-refusal {
    margin: 8px 0 0;
    color: var(--color-error);
}

.add-item-list,
.new-list-cadence {
    padding: 4px 8px;
    font: inherit; /* 16px, below which iOS zooms in on focus */
    color: var(--color-text);
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.add-item-list:focus-visible,
.new-list-cadence:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.add-item-note summary,
.list-delete summary {
    width: fit-content;
    color: var(--color-link);
    font-size: 0.875rem;
    cursor: pointer;
}

.list-delete {
    margin: 24px 0 0;
}

.list-delete-warning {
    margin: 8px 0;
    color: var(--color-text-muted);
}

.add-item-note textarea,
.item-edit-note {
    display: block;
    margin-top: 8px;
    resize: vertical;
}

.new-list-templates {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin: 0 0 8px;
    font-size: 0.875rem;
}

.new-list-templates-label {
    color: var(--color-text-muted);
}

.new-list-templates a {
    color: var(--color-link);
    text-decoration: none;
}

.new-list-templates a[aria-current] {
    color: var(--color-text);
    font-weight: 600;
}

@media (hover: hover) {
    .new-list-templates a:hover {
        text-decoration: underline;
    }
}

.new-list-templates a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.new-list {
    margin: 0 0 16px;
}

.new-list-cadence {
    margin: 8px 0 0;
}

/* Only a list that doesn't repeat can be ephemeral. */
.new-list-ephemeral {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
}

.new-list:has(.new-list-cadence option[value="never"]:checked) .new-list-ephemeral {
    display: flex;
}

.new-list-mode {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0 0;
    padding: 0;
    border: none;
    font-size: 0.875rem;
}

.lists {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lists-entry {
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere; /* a long name mustn't widen the page */
}

/* The whole row opens the list. */
.lists-entry a {
    display: block;
    padding: 12px 0;
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    .lists-entry a:hover {
        color: var(--color-link);
    }
}

.lists-entry a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* A view's row opens it, but for its Edit link at the end. */
.views-entry {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.views-entry a:first-child {
    flex: 1;
}

.views-entry .views-entry-edit,
.view-edit-link {
    color: var(--color-link);
    font-size: 0.875rem;
    text-decoration: none;
}

.view-edit-link {
    display: inline-block;
    margin: 0 0 8px;
}

.view-edit-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 24px;
}

.view-entries {
    margin: 0 0 24px;
}

.view-entries-heading {
    font-size: 1rem;
    margin: 0 0 8px;
}

.view-entries-empty {
    color: var(--color-text-muted);
}

.view-entries-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}

.view-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.view-entry-name {
    flex: 1;
    overflow-wrap: anywhere; /* a long name mustn't widen the page */
}

.view-entry-move {
    display: flex;
    gap: 4px;
}

.view-entry-move button {
    min-width: 32px;
    padding: 4px 8px;
    font: inherit;
    color: var(--color-text);
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
}

.view-entry-move button:disabled {
    opacity: 0.4;
    cursor: default;
}

.view-entry-move button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.view-entry-add {
    display: flex;
    gap: 12px;
}

.view-entry-add select {
    flex: 1;
    min-width: 0;
}

.items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.item-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere; /* a long URL mustn't widen the page */
}

.item-when {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

/* A list with one cadence says it once, in its header, so only a mixed list's
   items show theirs. Each item has its repeat, so an answer to ticking one
   needn't know its list's cadence. */
.list:not([data-cadence="mixed"]) .item-repeat {
    display: none;
}

.item-repeat:has(+ .item-due)::after {
    content: " · ";
}

.item-overdue {
    color: var(--color-error);
}

.item-tick {
    margin: 0;
}

/* A round box that shows its tick on hover and focus, to say what it does. */
.tick {
    position: relative;
    display: block;
    width: 22px;
    height: 22px;
    margin-top: 1px; /* level with the title's first line */
    padding: 0;
    border: 2px solid var(--color-tick-border);
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.tick::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--color-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 150ms;
}

@media (hover: hover) {
    .tick:hover {
        border-color: var(--color-accent);
    }

    .tick:hover::after {
        opacity: 1;
    }
}

.tick:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.tick:focus-visible::after {
    opacity: 1;
}

/* On a keep list a ticked item stays, with its tick showing. */
.item-ticked .tick {
    border-color: var(--color-accent);
}

.item-ticked .tick::after {
    opacity: 1;
}

.item-ticked .item-title {
    color: var(--color-text-muted);
    text-decoration: line-through;
}

.item-note {
    margin: 4px 0 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    white-space: pre-line; /* keep the note's line breaks */
}

.flush {
    margin: 12px 0 0;
}

.list:not(:has(.item-ticked)) .flush {
    display: none;
}

.flush-button {
    padding: 0;
    border: none;
    background: none;
    color: var(--color-link);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

@media (hover: hover) {
    .flush-button:hover {
        text-decoration: underline;
    }
}

.flush-button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

a.item-title {
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    a.item-title:hover {
        text-decoration: underline;
    }
}

a.item-title:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.item-back {
    margin-left: 8px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.list-empty,
.home-empty {
    color: var(--color-text-muted);
    margin: 0;
}

.home-list .list-name {
    margin: 24px 0 4px;
    font-size: 1.125rem;
}

.home-list .list-name a {
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    .home-list .list-name a:hover {
        color: var(--color-link);
    }
}

.home-list .list-name a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* A list with nothing on it, or whose last item was just ticked off. */
.home-list:not(:has(.item)) {
    display: none;
}

/* A built-in view's name over its lists, on a view with several entries. */
.view-section-name {
    margin: 32px 0 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.view-section:not(:has(.item)) {
    display: none;
}

/* Where a view has several entries, a line tells each one from the one
   before, a list's own entry from a built-in view's lists especially. Only
   after one that still shows, so emptying the first leaves no line on top. */
.view-section:has(.item) ~ .view-section {
    margin-top: 32px;
    border-top: 1px solid var(--color-border);
}

.page:has(.item) .home-empty {
    display: none;
}

.list:has(.item) .list-empty {
    display: none;
}

.history-day {
    margin-bottom: 24px;
}

/* A day whose last entry was undone. */
.history-day:not(:has(.history-entry)) {
    display: none;
}

.history-day-label {
    margin: 0 0 4px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.history-entries {
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-entry {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.history-time {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.history-undo {
    margin: 0;
}

.undo,
.delete {
    padding: 0;
    border: none;
    background: none;
    color: var(--color-link);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

@media (hover: hover) {
    .undo:hover,
    .delete:hover {
        text-decoration: underline;
    }
}

.undo:focus-visible,
.delete:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

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

.page:has(.history-entry) .history-empty {
    display: none;
}

/* The date and time pickers lay out as if they were the form's own fields. */
.when-picker {
    display: contents;
}

.date-picker {
    position: relative;
}

.date-picker-open {
    display: none;
    min-width: 8em;
    text-align: left;
    cursor: pointer;
}

.date-picker-empty {
    color: var(--color-placeholder);
}

.date-picker-open[aria-invalid="true"] {
    border-color: var(--color-error);
}

/* The calendar under the date button. */
.date-picker-popover {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2;
    margin-top: 4px;
    padding: 12px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.date-picker-quick {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.date-picker-quick button,
.date-picker-month button,
.date-picker-grid button,
.date-picker-months button {
    padding: 0;
    font: inherit;
    color: var(--color-text);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.date-picker-quick button {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
}

.date-picker-month {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
}

.date-picker-month button {
    width: 2rem;
    height: 2rem;
    font-size: 1.25rem;
}

.date-picker-month .date-picker-title {
    width: auto;
    padding: 0 8px;
    font-size: 1rem;
    font-weight: 600;
}

/* The year's months, the same width as the days. */
.date-picker-months {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: 17.5rem;
}

.date-picker-months[hidden] {
    display: none;
}

.date-picker-months button {
    height: 2.75rem;
}

.date-picker-grid {
    border-collapse: collapse;
}

.date-picker-grid th {
    width: 2.5rem;
    padding-bottom: 4px;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.date-picker-grid td {
    padding: 1px;
    text-align: center;
}

.date-picker-grid button {
    width: 2.25rem;
    height: 2.25rem;
    font-variant-numeric: tabular-nums;
}

.date-picker-grid button[aria-current="date"],
.date-picker-months button[aria-current="date"] {
    box-shadow: inset 0 0 0 1px var(--color-accent);
}

.date-picker-grid button[aria-pressed="true"],
.date-picker-months button[aria-pressed="true"] {
    color: var(--color-button-text);
    background: var(--color-button-bg);
    font-weight: 600;
}

.date-picker-quick button:disabled,
.date-picker-month button:disabled,
.date-picker-grid button:disabled,
.date-picker-months button:disabled {
    color: var(--color-placeholder);
    cursor: default;
}

@media (hover: hover) {
    .date-picker-quick button:enabled:hover,
    .date-picker-month button:enabled:hover,
    .date-picker-grid button:enabled:not([aria-pressed="true"]):hover,
    .date-picker-months button:enabled:not([aria-pressed="true"]):hover {
        background: var(--color-border);
    }
}

.date-picker-quick button:focus-visible,
.date-picker-month button:focus-visible,
.date-picker-grid button:focus-visible,
.date-picker-months button:focus-visible,
.date-picker-open:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* With scripting, the button takes the date field's place, which stays in the
   form and is what's sent. when-picker.js checks the same query. */
@media (scripting: enabled) {
    .date-picker > input[type="date"] {
        display: none;
    }

    .date-picker-open {
        display: block;
    }
}

.time-picker {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-picker-field,
.time-picker-open {
    display: none;
    font-variant-numeric: tabular-nums;
}

.time-picker-field {
    width: 5.5em;
}

.time-picker-field:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.time-picker-open {
    cursor: pointer;
}

/* Times to pick under the field, of which the highlighted one is
   aria-selected. */
.time-picker-options {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1;
    min-width: 100%;
    max-height: 15rem;
    margin: 4px 0 0;
    padding: 4px 0;
    overflow-y: auto;
    list-style: none;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.time-picker-options [role="option"] {
    padding: 6px 12px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.time-picker-options [aria-selected="true"] {
    background: var(--color-border);
}

/* Which picker shows is decided here rather than in the script, so the
   dropdowns don't show until the script has run. when-picker.js checks the
   same queries. With scripting, the field takes the dropdowns' place. They
   stay in the form, and are what's sent. */
@media (scripting: enabled) {
    .time-picker > select,
    .time-picker > .time-picker-colon {
        display: none;
    }

    .time-picker-field {
        display: block;
    }
}

/* On touch screens, a button showing the time takes their place instead, and
   opens a sheet of wheels. */
@media (pointer: coarse) and (scripting: enabled) {
    .time-picker-field {
        display: none;
    }

    .time-picker-open {
        display: block;
    }

    /* Out of sight, but still in the form and read by screen readers. */
    .time-picker > select {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* A sheet along the bottom of the screen, with the calendar above the time's
   wheels. Its padding is on the content, so a tap on the dialog itself is a
   tap on the backdrop. */
.when-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    margin: auto 0 0;
    padding: 0;
    border: none;
    border-radius: 16px 16px 0 0;
    color: var(--color-text);
    background: var(--color-bg-header);
}

.when-sheet::backdrop {
    background: rgb(0 0 0 / 0.6);
}

.when-sheet-content {
    padding: 16px 16px 8px;
}

/* In the sheet, the calendar takes the width, for bigger days to tap. */
.when-sheet .date-picker-grid,
.when-sheet .date-picker-months {
    width: 100%;
}

.when-sheet .date-picker-grid th {
    width: auto;
}

.when-sheet .date-picker-grid button {
    width: 100%;
    height: 2.5rem;
}

.when-sheet .time-picker-wheels {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.time-picker-wheels {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.time-picker-wheels .time-picker-colon {
    font-size: 3rem;
    font-weight: 600;
}

.when-sheet-actions {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 16px;
}

.when-sheet-action {
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--color-link);
    font: inherit;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
}

.when-sheet-action:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Three rows show, the middle one the pick. The padding lets the first and
   last rows reach the middle, and the fade dims the rows around it. The script
   does the scrolling, so the browser's own is off. */
.wheel {
    --wheel-row: 4.25rem;
    width: 5.45rem;
    height: calc(3 * var(--wheel-row));
    padding: var(--wheel-row) 0;
    overflow-y: hidden;
    touch-action: none;
    user-select: none;
    font-size: 3rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
    -webkit-mask-image: linear-gradient(transparent, black 35%, black 65%, transparent);
    mask-image: linear-gradient(transparent, black 35%, black 65%, transparent);
}

.wheel-item {
    height: var(--wheel-row);
    line-height: var(--wheel-row);
}

.remind-weekdays,
.add-item-weekdays {
    display: none;
    flex-wrap: wrap;
    gap: 4px 12px;
    flex-basis: 100%;
    margin: 0;
    padding: 0;
    border: none;
}

.remind-form:has(select[name="repeat"] option[value="weekly"]:checked) .remind-weekdays {
    display: flex;
}

.remind-weekdays legend,
.add-item-weekdays legend {
    float: left; /* keeps the legend on the row, beside the days */
    color: var(--color-text-muted);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 8px;
}

.tabs a {
    color: var(--color-text-muted);
    text-decoration: none;
    white-space: nowrap;
}

.tabs a[aria-current="page"] {
    color: var(--color-text);
    font-weight: 600;
}

@media (hover: hover) {
    .tabs a:hover {
        color: var(--color-text);
    }
}

.reminders {
    list-style: none;
    margin: 0;
    padding: 0;
}

.reminder {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.reminder-when {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.reminder-delete,
.item-delete {
    margin: 0;
}

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

.page:has(.reminder) .reminders-empty {
    display: none;
}

/* Tabs down the side, the tab's panel beside them, and the account under
   the tabs. On a phone, the tabs run across the top and the account comes
   last. */
.settings {
    display: grid;
    grid-template-areas: "tabs" "panel" "account";
    gap: 16px;
}

.settings-tabs {
    grid-area: tabs;
    display: flex;
    gap: 16px;
}

.settings-tabs a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.settings-tabs a[aria-current="page"] {
    color: var(--color-text);
    font-weight: 600;
}

@media (hover: hover) {
    .settings-tabs a:hover {
        color: var(--color-text);
    }
}

.settings-panel {
    grid-area: panel;
}

.settings-heading {
    margin: 0 0 8px;
    font-size: 1.125rem;
}

.push-status {
    margin: 0 0 12px;
    color: var(--color-text-muted);
}

.settings-subheading {
    margin: 24px 0 4px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.devices {
    list-style: none;
    margin: 0;
    padding: 0;
}

.device {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.device-body {
    flex: 1;
    min-width: 0;
}

.device-this {
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--color-button-text);
    background: var(--color-accent);
    font-size: 0.75rem;
    font-weight: 600;
}

.device-since {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.device-off {
    margin: 0;
}

.devices-empty {
    margin: 8px 0 0;
    color: var(--color-text-muted);
}

.push-settings:has(.device) .devices-empty {
    display: none;
}

.push-on {
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    color: var(--color-button-text);
    background: var(--color-button-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.push-on:disabled {
    opacity: 0.6;
    cursor: default;
}

.push-hint {
    margin: 12px 0 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* The buttons' row is as tall as a button, whichever shows, or neither. */
.push-actions {
    display: flex;
    gap: 12px;
    min-height: 2.75rem;
}

.push-test {
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    color: var(--color-text);
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
}

.push-test:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (hover: hover) {
    .push-test:enabled:hover {
        background: var(--color-input-bg);
    }
}

.push-test:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Working: a spinner, in full colour, while the browser subscribes or the
   test push goes. */
.push-actions button[aria-busy="true"] {
    opacity: 1;
    cursor: progress;
}

.push-actions button[aria-busy="true"]::before {
    content: "";
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 8px;
    vertical-align: -0.1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: push-spin 0.8s linear infinite;
}

@keyframes push-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .push-actions button[aria-busy="true"]::before {
        animation: none;
    }
}

/* Without scripting, only the note that it's needed shows. */
@media (scripting: none) {
    .push-checking,
    .push-actions {
        display: none;
    }
}

@media (hover: hover) {
    .push-on:enabled:hover {
        filter: brightness(1.08);
    }
}

.push-on:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.settings .account {
    grid-area: account;
}

@media (min-width: 640px) {
    .settings {
        grid-template-areas: "tabs panel" "account panel";
        grid-template-columns: 10rem 1fr;
        grid-template-rows: auto 1fr;
        column-gap: 32px;
    }

    .settings-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .settings .account {
        align-self: end;
    }
}

.account {
    margin-top: 32px;
}

.signed-in-as {
    color: var(--color-text-muted);
    margin: 0;
}

.sign-out {
    margin-top: 12px;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-link);
    font: inherit;
    cursor: pointer;
}

.sign-out:hover {
    text-decoration: underline;
}
