:root {
    --text: #303030;
    --page: #f5f5f5;
    --accent: #35634f;
    --border: #dedede;
    --muted: #646464;
    --notice: #faf3db;
    --notice-border: #ac8730;
    --focus: #617e6e;
    --control-border: #929292;
    --disabled-text: #6b6b6b;
    --disabled-bg: #efefef;
    --surface: #ffffff;
    --on-accent: #ffffff;
    --danger: #a13535;
    color-scheme: light;
    font-family: system-ui, sans-serif;
    color: var(--text);
    background: var(--page);
    line-height: 1.6;
}

/* System colors also work when scripts are disabled or unavailable. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --text: #cccccc;
        --page: #181818;
        --accent: #a1c4b0;
        --border: #444444;
        --muted: #b2b2b2;
        --notice: #363021;
        --notice-border: #dfb85c;
        --focus: #8fa99a;
        --control-border: #808080;
        --disabled-text: #a3a3a3;
        --disabled-bg: #303030;
        --surface: #252525;
        --on-accent: #202020;
        --danger: #f0a09b;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --text: #cccccc;
    --page: #181818;
    --accent: #a1c4b0;
    --border: #444444;
    --muted: #b2b2b2;
    --notice: #363021;
    --notice-border: #dfb85c;
    --focus: #8fa99a;
    --control-border: #808080;
    --disabled-text: #a3a3a3;
    --disabled-bg: #303030;
    --surface: #252525;
    --on-accent: #202020;
    --danger: #f0a09b;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

header, main, footer {
    width: min(100% - 2rem, 54rem);
    margin-inline: auto;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-block: 1.5rem;
}

.brand {
    font-size: 1.5rem;
    font-weight: 750;
    text-decoration: none;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

a {
    color: var(--text);
    text-underline-offset: 0.25em;
}

a[aria-current="page"] {
    font-weight: 700;
}

main {
    padding: clamp(1rem, 4vw, 2.5rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
}

h1 {
    overflow-wrap: anywhere;
    margin-top: 0;
}

.eyebrow, .hint, footer {
    color: var(--muted);
    font-size: 0.9rem;
}

.notice {
    padding: 1rem;
    background: var(--notice);
    border-left: 3px solid var(--notice-border);
}

fieldset {
    margin: 1.5rem 0 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    min-width: 0;
}

label {
    display: block;
    margin-top: 1rem;
}

input, textarea, select, button {
    color: var(--text);
    background: var(--surface);
    padding: 0.75rem;
    font: inherit;
    border: 1px solid var(--control-border);
    border-radius: 0.4rem;
}

input, textarea, select {
    width: 100%;
}

:disabled {
    color: var(--disabled-text);
    background: var(--disabled-bg);
    opacity: 1;
    cursor: not-allowed;
}

button, .action {
    cursor: pointer;
    max-width: 100%;
}

.action {
    display: inline-block;
    padding: 0.65rem 1rem;
    margin-block: 1rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    text-align: center;
    text-decoration: none;
}

button:disabled, fieldset:disabled button {
    color: var(--disabled-text);
    background: var(--disabled-bg);
    cursor: not-allowed;
}

header nav {
    align-items: center;
    gap: 0.35rem 0.75rem;
}

header nav a, header nav button {
    padding: 0.5rem 0.25rem;
    margin: 0;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-decoration: none;
}

header nav a[aria-current="page"] {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
}

header nav button:disabled {
    color: var(--disabled-text);
}

header nav a:hover, header nav button:enabled:hover {
    color: var(--accent);
    text-decoration: underline;
}

#stage-note {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-heading h1, .page-heading .action {
    margin: 0;
}

.page-heading h1 {
    min-width: 0;
}

dt {
    font-weight: 600;
}

dd {
    margin: 0 0 1rem;
    color: var(--muted);
}

footer {
    padding-block: 1.5rem;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 4px;
}

.skip-link {
    position: absolute;
    top: -5rem;
    padding: 0.5rem;
    background: var(--surface);
}

.skip-link:focus {
    top: 0;
}

#todo-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

#todo-list li {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--surface);
    overflow-wrap: anywhere;
}

.todo-title {
    font-size: 1.1rem;
    font-weight: 650;
    text-decoration: none;
}

.todo-title:hover {
    color: var(--accent);
    text-decoration: underline;
}

.todo-summary {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.todo-metadata {
    color: var(--muted);
    font-size: 0.9rem;
}

#todo-list p {
    margin: 0.35rem 0;
}

#todo-detail dd {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.todo-actions {
    min-width: 0;
    margin: 0.5rem 0 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.todo-action-row, .todo-more-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.todo-actions button, .todo-actions a, .todo-actions summary {
    padding: 0.4rem 0.65rem;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.todo-actions a {
    text-decoration: none;
}

.todo-actions button:enabled:hover, .todo-actions a:hover, .todo-actions summary:hover {
    border-color: var(--border);
    background: var(--page);
}

.todo-actions button:disabled {
    color: var(--disabled-text);
    cursor: not-allowed;
}

.todo-more, .todo-more-items > * {
    min-width: 0;
    max-width: 100%;
}

.todo-more[open] {
    flex-basis: 100%;
}

.todo-more summary {
    width: fit-content;
    max-width: 100%;
}

.todo-more-items {
    padding-top: 0.25rem;
}

.todo-actions .danger {
    color: var(--danger);
}

.todo-feedback {
    font-size: 0.9rem;
}

.todo-feedback:empty, main > [role="status"]:empty {
    display: none;
}

.todo-filters {
    display: grid;
    gap: 0.65rem;
}

.filter-toolbar, .quick-status, .filter-search, .filter-summary, .page-size-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.filter-toolbar {
    justify-content: space-between;
}

.filter-search {
    flex: 1 1 15rem;
}

.filter-search input {
    flex: 1 1 8rem;
    width: auto;
    min-width: 0;
}

.todo-filters button, .filter-search input, .page-size-control input {
    padding: 0.45rem 0.65rem;
    margin: 0;
}

.quick-status button, #filter-reset {
    background: transparent;
    border-color: transparent;
    color: var(--text);
}

.quick-status button[aria-pressed="true"] {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--page);
    font-weight: 650;
}

.advanced-filters {
    min-width: 0;
}

.advanced-filters > summary {
    width: fit-content;
    padding-block: 0.4rem;
    color: var(--text);
    cursor: pointer;
}

.filter-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
    padding-block: 0.5rem 1rem;
}

.filter-fields > div {
    flex: 1 1 12rem;
    min-width: 0;
}

.filter-fields fieldset, .filter-fields label {
    margin-top: 0;
}

.filter-fields > p {
    flex-basis: 100%;
    margin: 0;
}

.filter-summary {
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-summary p {
    flex: 1 1 15rem;
    margin: 0;
    overflow-wrap: anywhere;
}

#filter-message:empty {
    display: none;
}

.page-size-control {
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.page-size-control label {
    margin: 0;
}

.page-size-control input {
    width: 5rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

#todo-pagination {
    margin-block: 1rem;
    align-items: center;
}

#todo-pagination span {
    flex-basis: 100%;
}

[hidden] {
    display: none !important;
}

.status-options {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.status-options label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

.status-options input {
    width: auto;
}

.todo-filters > p {
    flex-basis: 100%;
    margin: 0;
}

#custom-dates button {
    margin-top: 0.5rem;
}

#hierarchy-filters {
    flex-basis: 100%;
}

#apply-hierarchy {
    margin-block: 0.75rem;
}

.theme-control {
    position: relative;
}

.theme-options {
    position: absolute;
    z-index: 10;
    top: calc(100% + 0.35rem);
    right: 0;
    width: 9rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
}

.theme-options button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.65rem;
    text-align: left;
}

.theme-options button:hover, .theme-options button:focus-visible {
    background: var(--page);
}

.theme-options button[aria-pressed="true"] {
    color: var(--accent);
    font-weight: 650;
}

.theme-options button::after {
    content: "";
    width: 1em;
    height: 1em;
}

.theme-options button[aria-pressed="true"]::after {
    width: 0.4em;
    height: 0.7em;
    margin-right: 0.2em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

input::placeholder, textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

.detail-back {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

.detail-parent {
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.detail-content {
    margin-block: 2rem;
    overflow-wrap: anywhere;
}

#detail-content {
    white-space: pre-wrap;
    line-height: 1.8;
}

.detail-section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.detail-section-heading h2 {
    margin: 0;
    font-size: 1rem;
}

.detail-section-heading a, #detail-add-content {
    font-size: 0.9rem;
}

.detail-children {
    padding-block: 1.25rem;
    border-top: 1px solid var(--border);
}

#detail-children {
    list-style: none;
    padding: 0;
    margin-bottom: 0;
}

#detail-children a {
    display: block;
    padding-block: 0.6rem;
    overflow-wrap: anywhere;
}

#todo-detail .todo-actions {
    margin-block: 1rem 1.5rem;
}

#todo-detail .todo-action-row > button:enabled {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 650;
}

.detail-records {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}

.detail-records summary {
    width: fit-content;
    cursor: pointer;
    padding-block: 0.4rem;
}

#detail-records {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.5rem 1rem;
}

#detail-records dd {
    margin: 0;
}
