:root {
    --bg: #faf8f4; --card: #ffffff; --text: #1f1d1a; --muted: #6b665e;
    --line: #e6e1d8; --accent: #1f6a5a; --badge-bg: #e3f1ec;
    --tag-bg: #e8eef7; --tag-text: #25467a;
    --year-bg: #f1ece2; --year-text: #5c4a2a;
    --assign-bg: #fdf1dc; --assign-text: #8a5a00; --assign-line: #e9c98a;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161514; --card: #1f1e1c; --text: #ece8e1; --muted: #a39d93;
        --line: #2e2c29; --accent: #7fcbb6; --badge-bg: #1c332d;
        --tag-bg: #1f2a3b; --tag-text: #9dbbea;
        --year-bg: #2e2922; --year-text: #d9c49c;
        --assign-bg: #3a2e17; --assign-text: #f0c46b; --assign-line: #6b5426;
    }
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.5 Georgia, "Iowan Old Style", "Times New Roman", serif;
}
main { max-width: 720px; margin: 0 auto; padding: 48px 16px 64px; }
header h1 { margin: 0; font-size: 2rem; letter-spacing: -0.01em; }
header p { margin: 4px 0 0; color: var(--muted); }
[hidden] { display: none !important; }

/* Week headings */
h2 {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
    font: 600 0.8rem/1 system-ui, sans-serif; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--muted);
    margin: 40px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
h2 .range { font-weight: 400; text-transform: none; letter-spacing: 0; }
.week.current h2 { color: var(--accent); border-bottom-color: var(--accent); }
.week { scroll-margin-top: 16px; }

/* Cards */
.card {
    display: flex; gap: 18px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 16px; margin-bottom: 12px;
}
.week.done .card { opacity: 0.75; }
.date {
    flex: 0 0 56px; text-align: center; font-family: system-ui, sans-serif;
    display: flex; flex-direction: column; line-height: 1.1;
}
.date .dow, .date .mon { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.date .day { font-size: 1.9rem; font-weight: 700; color: var(--accent); margin: 2px 0; }
.body { min-width: 0; flex: 1; }
.body h3 { margin: 0 0 4px; font-size: 1.1rem; line-height: 1.35; }
.meta { margin: 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: 0.88rem; }
.meta .author { color: var(--text); font-weight: 600; }
.source { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.note { margin: 6px 0 0; font: 0.85rem system-ui, sans-serif; color: var(--accent); }
.desc { margin: 8px 0 0; }
.title-link { color: inherit; text-decoration: none; }
.title-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Assignment cards stand out from readings */
.card.assignment { background: var(--assign-bg); border-color: var(--assign-line); }
.card.assignment .date .day { color: var(--assign-text); }
.badge.assignment-badge { background: var(--card); color: var(--assign-text); }

/* Labels: year badge + keyword tags */
.labels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.badge {
    display: inline-block; font: 600 0.7rem/1 system-ui, sans-serif;
    text-transform: uppercase; letter-spacing: 0.06em;
    background: var(--badge-bg); color: var(--accent);
    padding: 4px 7px; border-radius: 4px;
}
.badge.year { background: var(--year-bg); color: var(--year-text); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.tag {
    display: inline-block; font: 500 0.75rem/1 system-ui, sans-serif;
    color: var(--tag-text); background: var(--tag-bg);
    padding: 5px 10px; border-radius: 999px; text-decoration: none;
    border: 1px solid transparent;
}
.tag:hover { border-color: var(--tag-text); }
.tag.small { font-size: 0.7rem; padding: 3px 8px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.filters .label { font: 0.8rem system-ui, sans-serif; color: var(--muted); margin-right: 2px; }
.filters .tag { font-size: 0.85rem; padding: 6px 12px; background: transparent; border-color: var(--line); color: var(--text); }
.filters .tag.active { background: var(--tag-text); border-color: var(--tag-text); color: var(--card); }

/* PDF / notes links */
.attachments { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments a {
    font: 0.85rem system-ui, sans-serif; color: var(--text); text-decoration: none;
    border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.attachments a:hover { border-color: var(--accent); color: var(--accent); }
.attachments a.notes { border-color: var(--accent); color: var(--accent); }

/* Questions, folded away until clicked */
.questions { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.questions summary {
    cursor: pointer; font: 600 0.85rem system-ui, sans-serif; color: var(--accent);
    list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.questions summary::-webkit-details-marker { display: none; }
.questions summary::before { content: "▸"; transition: transform .15s; }
.questions[open] summary::before { transform: rotate(90deg); }
.questions ol { margin: 10px 0 0; padding-left: 1.4em; }
.questions li { margin-bottom: 8px; }
.questions li::marker { color: var(--muted); font-family: system-ui, sans-serif; font-size: 0.85rem; }

/* Further reading */
.further-block { margin: 18px 0 8px; }
.further-block h4 {
    margin: 0 0 8px; font: 600 0.75rem/1 system-ui, sans-serif;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.further-list { list-style: none; padding: 0; margin: 0; }
.card.further { display: block; padding: 10px 14px; margin-bottom: 8px; background: transparent; }
.further-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.further-main .author { font-weight: 600; }
.card.further .desc { margin: 4px 0 0; font-size: 0.92rem; color: var(--muted); }

/* Buttons, back link, notices */
.button {
    display: inline-block; margin-top: 10px;
    font: 500 0.85rem/1 system-ui, sans-serif; text-decoration: none;
    color: var(--accent); border: 1px solid var(--accent);
    padding: 7px 14px; border-radius: 999px;
}
.button:hover { background: var(--badge-bg); }
button.button { background: transparent; cursor: pointer; }
.buttons, .share { display: flex; flex-wrap: wrap; gap: 8px; }
.back { font: 0.9rem system-ui, sans-serif; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.notice {
    margin-top: 32px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px;
}
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin: 0; }
.notice a { color: var(--accent); }
.empty { color: var(--muted); font-style: italic; }
details.problems { margin-top: 40px; color: #b3261e; font: 0.85rem system-ui, sans-serif; }
details.problems summary { cursor: pointer; }
footer { margin-top: 56px; color: var(--muted); font: 0.85rem system-ui, sans-serif; }
footer a { color: inherit; }

/* Single reading page */
.card.single { margin-top: 24px; padding: 20px; }
.card.single h1 { margin: 0 0 6px; font-size: 1.6rem; line-height: 1.25; letter-spacing: -0.01em; }
.card.single .questions { border-top-style: solid; }
.prev-next { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; }
.prev-next a {
    flex: 0 1 48%; display: flex; flex-direction: column; gap: 2px;
    text-decoration: none; color: var(--text); font-size: 0.95rem; line-height: 1.3;
    border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--card);
}
.prev-next a span { font: 0.75rem system-ui, sans-serif; color: var(--muted); }
.prev-next a.next { text-align: right; margin-left: auto; }
.prev-next a:hover { border-color: var(--accent); }

/* Search (same as the HPS calendar) */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search {
    display: flex; align-items: center; flex-shrink: 0;
    height: 40px; border: 1px solid transparent; border-radius: 999px;
    transition: border-color .2s, background-color .2s;
}
.search.open { border-color: var(--line); background: var(--card); }
.search-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; border: 0; border-radius: 999px;
    background: transparent; color: var(--muted); cursor: pointer;
}
.search-toggle:hover, .search.open .search-toggle { color: var(--text); }
.search input {
    width: 0; padding: 0; border: 0; outline: 0; background: transparent;
    font: 1rem system-ui, sans-serif; color: var(--text);
    transition: width .25s ease, padding .25s ease;
}
.search.open input { width: 200px; padding-right: 14px; }
.search.open:focus-within { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }

@media (max-width: 480px) {
    .card { gap: 12px; padding: 14px; }
    .date { flex-basis: 44px; }
    .date .day { font-size: 1.5rem; }
    .title-row { flex-wrap: wrap; }
    .search.open { width: 100%; order: 2; }
    .search.open input { width: auto; flex: 1; min-width: 0; }
    .prev-next { flex-direction: column; }
    .prev-next a, .prev-next a.next { flex-basis: auto; text-align: left; margin-left: 0; }
}
