:root {
  color-scheme: light dark;
  --page: #f5f5f3; --surface: #fcfcfb; --line: #e1e0dc; --ink: #1c1c1a; --muted: #62615c;
  --series: #2a78d6; --series-soft: #cfe1f7; --accent: #fbf236; --accent-ink: #1c1c1a; --warn: #8a5a00; --late: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #111110; --surface: #1a1a19; --line: #353430; --ink: #f2f1ec; --muted: #a5a39b;
    --series: #3987e5; --series-soft: #1f3a5c; --warn: #e5b454; --late: #f97066;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.small { padding: 1px 7px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.nav { display: flex; gap: 2px; }
.nav a { padding: 4px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a:hover { color: var(--ink); background: var(--page); }
.nav a[aria-current] { background: var(--accent); color: var(--accent-ink); }
#crumbs { color: var(--muted); }
.grow { flex: 1; }
#status, .muted { color: var(--muted); }
main { max-width: 1240px; margin: 0 auto; padding: 20px; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 30px 0 10px; }
h3 { font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }

.tiles, .grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 45%), 1fr)); }
.grid { grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); align-items: start; }
.tile, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.tile b { display: block; font-size: 24px; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 13px; }
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: start; gap: 8px; margin-bottom: 2px; }
.card-head h3 { flex: 1; }
.card-sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font-size: 12px; color: var(--muted); align-items: center; }
.card-tools select { padding: 1px 4px; max-width: 190px; }

.summary { text-decoration: none; display: block; }
.summary:hover { border-color: var(--muted); }
.summary dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 10px 0 0; }
.summary dt { color: var(--muted); font-size: 12px; }
.summary dd { margin: 0; font-weight: 600; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 8px; font-size: 11px; font-weight: 700; }

.columns { display: flex; align-items: stretch; gap: 2px; height: 150px; border-bottom: 1px solid var(--line); }
.column { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: end; align-items: center; background: none; border: 0; border-radius: 0; padding: 0; cursor: default; }
.column i { display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--series); min-height: 1px; }
.column:hover i, .column:focus-visible i { filter: brightness(1.15); }
.column em { font-style: normal; font-size: 11px; color: var(--muted); }
.axis { position: relative; display: flex; gap: 2px; font-size: 11px; color: var(--muted); padding-top: 3px; height: 20px; }
.axis > span { flex: 1; min-width: 0; display: flex; justify-content: center; white-space: nowrap; }
.axis-title { text-align: center; font-size: 11px; color: var(--muted); }

.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 8px; align-items: center; }
.bar .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track i { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--series); min-width: 2px; }
.bar .value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }

.scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.pick { cursor: pointer; }
tr.pick:hover td { background: var(--page); }
tr.on td { background: var(--series-soft); }
tr.hidden-player td { color: var(--muted); }

.session { margin-bottom: 14px; }
.session summary { cursor: pointer; font-weight: 600; }
.event { display: grid; grid-template-columns: 62px minmax(90px, 160px) 1fr; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.event .props { color: var(--muted); overflow-wrap: anywhere; }
.event time { font-variant-numeric: tabular-nums; color: var(--muted); }

#tip { position: fixed; z-index: 5; pointer-events: none; background: var(--ink); color: var(--page); padding: 5px 9px; border-radius: 6px; font-size: 12px; max-width: 300px; white-space: pre-line; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.login { max-width: 320px; margin: 15vh auto 0; display: grid; gap: 12px; }
.logged-out .top button, .logged-out .nav { display: none; }

/* Todo (public/sections/todo.js). */
#status.bad { color: var(--late); }
.todo { max-width: 760px; margin: 0 auto; font-size: 15px; }
.todo .add { display: flex; gap: 8px; margin-bottom: 14px; }
.todo .add input[type="text"] { flex: 1; min-width: 0; padding: 6px 10px; }
.todo .add input[type="date"] { width: 150px; }
@media (max-width: 520px) {
  .todo .add { flex-wrap: wrap; }
  .todo .add input[type="text"] { flex-basis: 100%; }
  .todo .add input[type="date"] { flex: 1; width: auto; }
}
.todo .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.todo .tags:empty { display: none; }
.todo .chip { border-radius: 99px; padding: 2px 11px; font-size: 13px; }
.todo .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.todo .chip .n { margin-left: 6px; color: var(--muted); }
.todo .chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.todo .tasks { list-style: none; margin: 0; padding: 0; }
.todo .task { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.todo .task.dragging { border-color: var(--series); box-shadow: 0 4px 14px rgb(0 0 0 / 0.15); position: relative; z-index: 1; }
.todo .handle { flex: none; width: 22px; padding: 0; border: 0; background: none; color: var(--muted); cursor: grab; touch-action: none; user-select: none; text-align: center; }
.todo .task.dragging .handle { cursor: grabbing; }
.todo .task input[type="checkbox"] { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--muted); cursor: pointer; }
.todo .text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.todo .title { border: 0; background: none; padding: 2px 0; text-align: left; overflow-wrap: anywhere; cursor: text; }
.todo .edit { flex: 1; min-width: 0; padding: 2px 6px; }
.todo .tag { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); }
.todo .tag:hover { color: var(--ink); text-decoration: underline; }
.todo .finished .title { color: var(--muted); text-decoration: line-through; }
.todo .due { flex: none; border: 0; background: none; padding: 2px 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.todo .due.late { color: var(--late); font-weight: 600; }
.todo .due.today { color: var(--ink); font-weight: 600; }
.todo .due.soon { color: var(--warn); }
.todo .due.none { opacity: 0; }
.todo .task:hover .due.none, .todo .due.none:focus-visible { opacity: 1; }
@media (hover: none) { .todo .due.none { opacity: 1; } }
.todo .due-input { flex: none; padding: 1px 4px; font-size: 13px; }
.todo .delete { flex: none; border: 0; background: none; padding: 0 4px; font-size: 18px; line-height: 1; color: var(--muted); }
.todo .delete:hover { color: var(--late); }
.todo .done { margin-top: 18px; }
.todo .done summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.todo .done .small { margin-top: 6px; }
.summary dd.late { color: var(--late); }
.summary ol { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.summary li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Todo with the calendar beside it. */
.todo .beside-toggle { flex: none; }
.todo-page.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: start; }
.todo-page.split .todo { max-width: none; margin: 0; }
@media (max-width: 1000px) { .todo-page.split { grid-template-columns: minmax(0, 1fr); } }

/* Calendar (public/sections/calendar.js). Dates are yellow, tasks dashed. */
.calendar { max-width: 1100px; margin: 0 auto; }
.calendar .add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.calendar .add input[type="text"] { flex: 1 1 240px; min-width: 0; padding: 6px 10px; }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-bar h2 { margin: 0 0 0 6px; font-size: 18px; }
.views { display: flex; gap: 2px; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.month .wd { font-size: 12px; color: var(--muted); padding: 0 4px; }
.month .cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; min-height: 96px; padding: 3px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.month .cell.weekend { background: color-mix(in srgb, var(--surface) 60%, var(--page)); }
.month .cell.out { opacity: 0.45; }
.month .cell:hover { border-color: var(--muted); }
.month .cell.selected { border-color: var(--series); box-shadow: inset 0 0 0 1px var(--series); }
.month .num, .month .num[aria-pressed="true"] { align-self: flex-start; border: 0; background: none; color: inherit; padding: 0 6px; border-radius: 99px; font-size: 12px; font-variant-numeric: tabular-nums; }
.month .today .num { background: var(--series); color: #fff; }
.cal-item { display: block; padding: 1px 5px; border-radius: 4px; font-size: 12px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item.date { background: var(--accent); color: var(--accent-ink); }
.cal-item.date.cont { opacity: 0.55; }
.cal-item.task { border: 1px dashed var(--muted); color: var(--muted); }
.month .more { padding-left: 5px; font-size: 11px; color: var(--muted); }
.calendar.beside .month .cell { min-height: 72px; }
/* Too narrow for words: each date is a bar, and the picked day lists them below. */
@media (max-width: 640px) {
  .month .cell { min-height: 54px; padding: 2px; }
  .cal-item { height: 6px; padding: 0; font-size: 0; }
}

.year { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.mini-title { border: 0; background: none; padding: 0 0 4px; font-weight: 700; }
.mini-title:hover { text-decoration: underline; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-grid .wd { color: var(--muted); font-size: 10px; }
.mini-grid .d { border: 0; background: none; padding: 2px 0; border-radius: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.mini-grid .d.has { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mini-grid .d.has-task { box-shadow: inset 0 -2px 0 var(--muted); }
.mini-grid .d.today { outline: 2px solid var(--series); outline-offset: -2px; }
.mini-grid .d.selected { background: var(--series); color: #fff; }

.day-detail { margin-top: 14px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.day-detail h3 { margin-bottom: 6px; }
.coming h3 { margin: 18px 0 6px; }
.coming h3:first-child { margin-top: 0; }
.coming h3.late { color: var(--late); }
.calendar ul { list-style: none; margin: 0; padding: 0; }
.calendar .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.calendar .line:last-child { border-bottom: 0; }
.calendar .line .when { flex: none; width: 96px; color: var(--muted); font-variant-numeric: tabular-nums; }
.calendar .line .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.calendar .line .what::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 2px; }
.calendar .line.date .what::before { background: var(--accent); box-shadow: 0 0 0 1px var(--line); }
.calendar .line.task .what::before { border: 1px dashed var(--muted); }
.calendar .tag { color: var(--muted); font-size: 13px; }
.calendar .tools { display: flex; gap: 6px; align-items: center; }
.calendar .delete { border: 0; background: none; padding: 0 4px; font-size: 18px; line-height: 1; color: var(--muted); }
.calendar .delete:hover { color: var(--late); }
.calendar .task-link:hover { text-decoration-thickness: 2px; }
.edit-date { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; }
.edit-date input[type="text"] { flex: 1 1 200px; min-width: 0; }
