:root {
    --ink: #18231c;
    --paper: #f4f0e6;
    --panel: #fffdf8;
    --panel-raised: rgba(255, 253, 248, .88);
    --input: #fffefa;
    --line: #cbc4b2;
    --green: #216147;
    --green-dark: #153f30;
    --green-hover: #174d38;
    --orange: #df6430;
    --orange-hover: #bd4c20;
    --muted: #647069;
    --notice: #e5eee1;
    --alert: #f8ddd2;
    --entry: #1b3025;
    --on-accent: #fff;
    --auth-ink: #fffdf8;
    --focus: #b64b22;
    --error-text: #ffd4c1;
    --texture: rgba(44, 57, 46, .06);
    --row-hover: rgba(255, 253, 248, .72);
    --auth-shadow: rgba(21, 35, 28, .22);
    --shadow: 0 18px 60px rgba(34, 42, 34, .10);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --ink: #f1eee4;
        --paper: #111b16;
        --panel: #1b2922;
        --panel-raised: rgba(30, 45, 37, .9);
        --input: #21342a;
        --line: #3d5346;
        --green: #9ac9a6;
        --green-dark: #0b251b;
        --green-hover: #b5dabd;
        --orange: #ee8552;
        --orange-hover: #ff9c6d;
        --muted: #b0beb4;
        --notice: #263f31;
        --alert: #4b2d26;
        --entry: #0d1812;
        --on-accent: #14241b;
        --auth-ink: #fff5e9;
        --focus: #f3a36f;
        --error-text: #ffd2bd;
        --texture: rgba(224, 234, 220, .055);
        --row-hover: rgba(234, 244, 230, .055);
        --auth-shadow: rgba(0, 0, 0, .46);
        --shadow: 0 20px 64px rgba(0, 0, 0, .30);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ink: #f1eee4;
    --paper: #111b16;
    --panel: #1b2922;
    --panel-raised: rgba(30, 45, 37, .9);
    --input: #21342a;
    --line: #3d5346;
    --green: #9ac9a6;
    --green-dark: #0b251b;
    --green-hover: #b5dabd;
    --orange: #ee8552;
    --orange-hover: #ff9c6d;
    --muted: #b0beb4;
    --notice: #263f31;
    --alert: #4b2d26;
    --entry: #0d1812;
    --on-accent: #14241b;
    --auth-ink: #fff5e9;
    --focus: #f3a36f;
    --error-text: #ffd2bd;
    --texture: rgba(224, 234, 220, .055);
    --row-hover: rgba(234, 244, 230, .055);
    --auth-shadow: rgba(0, 0, 0, .46);
    --shadow: 0 20px 64px rgba(0, 0, 0, .30);
    color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Georgia, 'Times New Roman', serif; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .28; background-image: repeating-linear-gradient(0deg, transparent 0 31px, var(--texture) 31px 32px); }
a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-hover); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.site-header { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; max-width: 1320px; margin: auto; padding: 24px 32px; border-bottom: 1px solid var(--line); }
.wordmark { color: var(--ink); text-decoration: none; font: 700 23px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -1px; }
.wordmark span { color: var(--orange); }
nav { display: flex; align-items: center; gap: 22px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
nav form { margin: 0; }
.link-button { border: 0; background: none; color: var(--green); padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.theme-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.theme-control select { border: 1px solid var(--line); border-radius: 0; padding: 4px 6px; color: var(--ink); background: var(--panel); font-size: 11px; }
.theme-control select:hover { border-color: var(--green); }
.page-shell { position: relative; max-width: 1320px; margin: auto; padding: 48px 32px 80px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 32px; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 760px; margin-bottom: 0; font-size: clamp(42px, 7vw, 82px); line-height: .95; letter-spacing: -4px; font-weight: 500; }
h2 { font-size: 20px; }
.eyebrow { margin-bottom: 12px; color: var(--orange); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; text-transform: uppercase; }
.syntax { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: nowrap; }
.syntax b { color: var(--green); }
.task-entry { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 28px; padding: 10px; background: var(--entry); box-shadow: var(--shadow); }
.task-autocomplete { position: relative; min-width: 0; }
.task-entry input { width: 100%; min-width: 0; border: 0; padding: 15px 17px; background: var(--input); color: var(--ink); font: 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.task-suggestions { position: absolute; z-index: 3; top: 100%; right: 0; left: 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-top: 0; background: var(--panel); box-shadow: var(--shadow); font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.task-suggestions [role="option"] { padding: 9px 17px; cursor: pointer; }
.task-suggestions [role="option"][aria-selected="true"], .task-suggestions [role="option"]:hover { color: var(--on-accent); background: var(--green); }
.task-entry.editing { width: 100%; margin: 0; grid-template-columns: 1fr auto; box-shadow: none; }
.task-entry.editing .task-autocomplete { grid-column: 1/-1; }
.task-entry.editing .primary { justify-self: end; }
.task-entry .form-error { grid-column: 1/-1; margin: 2px 8px 5px; color: var(--error-text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.primary, .secondary { border: 1px solid transparent; padding: 11px 18px; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }
.primary { color: var(--on-accent); background: var(--orange); }
.primary:hover { background: var(--orange-hover); }
.secondary { color: var(--ink); background: var(--paper); border-color: var(--line); }
.secondary:hover { border-color: var(--green); background: var(--panel); }
.workbench { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 34px; align-items: start; }
.filter-panel { position: sticky; top: 18px; border-top: 5px solid var(--green); padding: 19px; background: var(--panel-raised); box-shadow: var(--shadow); }
.filter-heading { display: flex; justify-content: space-between; align-items: baseline; }
.filter-heading a { font-size: 12px; }
.filters { display: grid; gap: 17px; }
.filters label, .stack-form label { display: grid; gap: 7px; color: var(--muted); font: 700 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .6px; text-transform: uppercase; }
.filters select, .stack-form input { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 9px; background: var(--panel); color: var(--ink); text-transform: none; }
.filters select[multiple] { padding: 4px; }
.filters option { padding: 5px; }
.filter-heading h2 { margin-bottom: 0; }
.no-htmx { display: none; }
.list-panel { min-width: 0; }
.list-header { display: flex; justify-content: space-between; padding: 0 4px 12px; border-bottom: 1px solid var(--line); }
.list-header h2 { margin: 0; font-weight: 500; }
.task-rows { display: grid; }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 63px; border-bottom: 1px solid var(--line); padding: 10px 5px; }
.task-row:hover { background: var(--row-hover); }
.task-row code { overflow-wrap: anywhere; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.task-row.completed code { color: var(--muted); text-decoration: line-through; }
.complete-button { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--green); border-radius: 50%; color: var(--on-accent); background: transparent; font: 20px/1 sans-serif; }
.completed .complete-button { background: var(--green); }
.task-actions { display: flex; gap: 9px; opacity: 0; }
.task-row:hover .task-actions, .task-actions:focus-within { opacity: 1; }
.task-actions form { margin: 0; }
.task-actions button, .task-actions a { border: 0; padding: 4px; color: var(--muted); background: none; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-decoration: underline; }
.empty-state { display: grid; place-items: center; min-height: 260px; color: var(--muted); }
.empty-state strong { align-self: end; color: var(--ink); font-size: 28px; font-weight: 500; }
.empty-state span { align-self: start; margin-top: 7px; }
.htmx-indicator { opacity: 0; color: var(--orange); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.notice, .alert { padding: 14px 17px; border-left: 4px solid var(--green); background: var(--notice); }
.alert { border-color: var(--orange); background: var(--alert); }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: var(--green-dark); }
.auth-body::before { opacity: .08; background-image: repeating-linear-gradient(0deg, transparent 0 31px, var(--auth-ink) 31px 32px); }
.auth-shell { position: relative; width: min(100%, 520px); }
.auth-shell > .wordmark { display: inline-block; margin-bottom: 22px; color: var(--auth-ink); }
.auth-card { padding: clamp(28px, 6vw, 54px); background: var(--panel); box-shadow: 16px 16px 0 var(--auth-shadow); }
.auth-card h1 { margin-bottom: 30px; font-size: clamp(38px, 8vw, 58px); letter-spacing: -3px; }
.stack-form { display: grid; gap: 19px; }
.stack-form input { padding: 12px; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; }
.stack-form .check { display: flex; grid-template-columns: auto 1fr; align-items: center; text-transform: none; }
.stack-form .check input { width: auto; }
.stack-form small { font-weight: 400; }
.narrow-page { max-width: 720px; padding-top: 20px; }
.narrow-page h1 { margin-bottom: 28px; }
.narrow-page > p { font-size: 18px; line-height: 1.6; }
.import-form { margin: 28px 0; padding: 25px; border: 1px solid var(--line); background: var(--panel); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

@media (max-width: 760px) {
    .site-header { padding: 18px; }
    nav { flex-wrap: wrap; justify-content: end; gap: 12px; }
    .page-shell { padding: 34px 18px 60px; }
    .hero { display: block; }
    .syntax { margin-top: 20px; white-space: normal; }
    .task-entry { grid-template-columns: 1fr; }
    .workbench { grid-template-columns: 1fr; }
    .filter-panel { position: static; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-heading { grid-column: 1/-1; }
    .task-row { grid-template-columns: auto minmax(0, 1fr); }
    .task-actions { grid-column: 2; opacity: 1; }
}

@media (scripting: none) { .no-htmx { display: block; } }
