/* The Working Ledger — warm paper, ink, and a single editorial accent. */
:root {
  color-scheme: light;
  --paper: #f5f3ee;
  --surface: #fffefa;
  --ink: #292923;
  --muted: #6c6b61;
  --line: #dcdad1;
  --line-soft: #eeece5;
  --accent: #b9402c;
  --overdue: #ac3526;
  --soon: #805b13;
  --sched: #386247;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
a { color: inherit; text-underline-offset: 4px; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
::selection { background: #f1d9cd; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; transform: translateY(-150%); z-index: 10; background: var(--ink); color: white; padding: 12px 20px; }
.skip-link:focus { transform: translateY(0); }
.topbar {
  min-height: 94px; max-width: 1440px; margin: auto; padding: 20px 48px;
  display: flex; align-items: center; gap: 64px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; font-size: 14px; font-weight: 650; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 43px; background: var(--ink); color: var(--surface); font: italic 34px/.9 var(--serif); padding-bottom: 5px; }
.brand-caption { display: block; color: var(--muted); font-size: 10px; font-weight: 400; letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { min-height: 44px; padding: 11px 20px; text-decoration: none; color: var(--muted); border-radius: 3px; }
.topbar nav a:hover { background: #eae8e0; color: var(--ink); }
.topbar nav a[aria-current] { background: var(--ink); color: var(--surface); }
.masthead-note { margin-left: auto; font: italic 16px var(--serif); color: var(--muted); }
/* WE4: sign-out sits at the far right; it's a quiet outline button, not a primary action. */
.logout-form { margin: 0 0 0 auto; }
.masthead-note + .logout-form { margin-left: -40px; }
.logout-button { background: transparent; color: var(--muted); border-color: var(--line); }
.logout-button:hover { background: #eae8e0; color: var(--ink); }
main { max-width: 1280px; padding: 52px 48px 64px; margin: auto; min-height: calc(100vh - 180px); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.eyebrow { margin: 0; font-size: 10px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
h1 { font: 400 clamp(48px, 6vw, 76px)/1.07 var(--serif); letter-spacing: -.055em; margin: 9px 0 0; }
.heading-dot { color: var(--accent); }
.edition-date { text-align: right; margin: 0 0 5px; font-size: 12px; color: var(--muted); line-height: 1.9; font-variant-numeric: tabular-nums; }
.edition-date span, .edition-date time { display: block; }
.edition-date > :first-child { color: var(--ink); }
.quick-add { background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--ink); padding: 23px 26px 16px; }
.quick-add form { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.capture-plus { font: 30px/1 var(--serif); color: var(--accent); }
.quick-add input { flex: 1; min-width: 0; width: 100%; padding: 12px 0; border: 0; background: transparent; color: var(--ink); font-size: 19px; }
input::placeholder { color: #77766c; opacity: 1; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 44px; padding: 10px 17px; border: 1px solid var(--ink); border-radius: 3px; background: var(--ink); color: var(--surface); text-decoration: none; cursor: pointer; font-size: 12px; font-weight: 550; transition: background-color 130ms, border-color 130ms, color 130ms; }
button:hover, .btn:hover { background: #48483e; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, input:disabled { cursor: wait; opacity: .6; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.quick-add .hint { padding-left: 32px; }
.quick-add .hint span { color: var(--ink); }
.filters { border-bottom: 1px solid var(--line); padding: 18px 0; }
.filters form { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.filter-title { margin-right: 12px; }
.filters label { font-size: 11px; color: var(--muted); margin-left: 10px; }
select { color: var(--ink); border: 1px solid var(--line); border-radius: 3px; background: var(--surface); min-height: 44px; padding: 8px 28px 8px 10px; max-width: 100%; }
.filters select { font-size: 12px; background-color: transparent; border-color: transparent; padding-left: 4px; }
.filters select:hover { border-color: var(--line); }
.reset-filters { margin-left: auto; font-size: 12px; color: var(--muted); padding: 11px 6px; }
.list-meta { display: flex; align-items: center; justify-content: space-between; padding: 24px 0 16px; gap: 16px; }
.list-instruction { font-size: 11px; color: var(--muted); }
.group { margin-bottom: 22px; border: 1px solid var(--line); background: var(--surface); }
.group summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; min-height: 62px; padding: 12px 18px; background: #eeece5; }
.group summary::-webkit-details-marker { display: none; }
.group-name { font: 400 23px/1.25 var(--serif); letter-spacing: -.025em; overflow-wrap: anywhere; }
.count { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-variant-numeric: tabular-nums; }
.group .count { margin-left: auto; }
.disclosure { font-size: 18px; width: 24px; text-align: center; transform: rotate(-90deg); }
details[open] > summary .disclosure { transform: rotate(0); }
ul.items { list-style: none; margin: 0; padding: 0 18px; min-height: 12px; }
.item { display: grid; grid-template-columns: 18px 22px minmax(0, 1fr) minmax(80px, 130px) 164px; align-items: center; gap: 12px; min-height: 78px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.item:last-child { border-bottom: 0; }
.item:hover { background: #faf9f4; }
.item-copy { min-width: 0; }
.item-text { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.note, .mirror-hint { display: block; margin-top: 3px; font-size: 12px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.mirror-hint { font-style: italic; }
.item-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 5px 8px; }
.due-tag { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.flag { display: inline-block; font-size: 9px; font-weight: 600; letter-spacing: .04em; line-height: 1.5; padding: 3px 6px; border: 1px solid transparent; border-radius: 2px; text-transform: uppercase; }
.flag-overdue { color: var(--overdue); background: #f8e9e3; border-color: #ecd4ca; }
.flag-soon { color: var(--soon); background: #f6efd9; border-color: #e9dfba; }
.flag-sched { color: var(--sched); background: #eaf0e9; border-color: #d4e0d2; }
.flag-blocked { color: #625742; background: #eee9de; border-color: #ded5c4; }
.item.overdue .due-tag { color: var(--overdue); }
.item-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.group-select { width: 95px; min-width: 0; font-size: 10px; padding: 7px 2px; background: transparent; border-color: transparent; color: var(--muted); }
.group-select:hover { border-color: var(--line); }
.edit-btn { min-width: 58px; padding: 8px 4px; gap: 6px; font-size: 11px; background: transparent; color: var(--muted); border-color: transparent; }
.edit-btn:hover { background: #eeece5; color: var(--ink); }
.drag-handle { cursor: grab; color: #8a897e; user-select: none; font-size: 18px; text-align: center; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.done-box { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; border: 1px solid #aaa99e; border-radius: 50%; background: transparent; cursor: pointer; display: grid; place-items: center; position: relative; }
.done-box::before { content: ""; position: absolute; inset: -12px -5px; }
.done-box:hover { border-color: var(--sched); background: #eaf0e9; }
.done-box:checked { border-color: var(--sched); background: var(--sched); }
.done-box:checked::after { content: "✓"; color: white; font-size: 12px; }
.item:has(.done-box:checked) .item-text { text-decoration: line-through; color: var(--muted); }
.mirror-marker { grid-column: 1 / 3; text-align: center; color: var(--muted); font: 24px var(--serif); }
.sortable-ghost { opacity: .35; background: #e2e6d9; }
.sortable-chosen { box-shadow: 0 4px 14px #29292312; }
.group-empty { color: var(--muted); font-size: 12px; margin: 3px 24px 20px; }
.empty-state { text-align: center; border-bottom: 1px solid var(--line); padding: 34px 20px 45px; margin-bottom: 24px; }
.empty-mark { color: var(--accent); font: 40px var(--serif); }
.empty-state h2 { font: 30px var(--serif); letter-spacing: -.025em; margin: 6px 0 12px; }
.empty-state p { font-size: 13px; color: var(--muted); }
.parse-echo, .ui-error { margin: 0 0 20px; padding: 14px 18px; border-left: 3px solid var(--sched); background: #eaf0e9; font-size: 13px; color: #2f533c; }
.ui-error { border-color: var(--overdue); background: #f8e9e3; color: #8b2c20; }
.htmx-request { cursor: progress; }
form.htmx-request button[type=submit] { opacity: .5; pointer-events: none; }
.list.htmx-swapping { opacity: .65; }
.item.editing { display: block; padding: 22px 6px; background: #faf9f4; }
.edit-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.edit-form > div { min-width: 0; }
.edit-form label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600; }
.edit-form input, .edit-form select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--ink); padding: 10px; font-size: 13px; }
.edit-note { grid-column: 1 / -1; }
.optional { font-weight: 400; color: var(--muted); margin-left: 5px; }
.edit-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.cancel-btn, .btn-secondary, .btn-icon { background: transparent; color: var(--ink); border-color: var(--line); }
.cancel-btn:hover, .btn-secondary:hover, .btn-icon:hover { background: #eae8e0; }
.cal-toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 24px; border-top: 1px solid var(--line); padding-top: 22px; }
.week-label { font: 23px/1.3 var(--serif); letter-spacing: -.02em; margin: 0; }
.week-navigation { display: flex; gap: 8px; }
.btn-icon { width: 44px; padding: 8px; font-size: 18px; }
.cal-wrap { display: flex; align-items: flex-start; gap: 24px; }
.unscheduled-tray { width: 210px; flex-shrink: 0; border-top: 2px solid var(--ink); padding-top: 16px; }
.tray-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tray-heading h3 { font: 22px var(--serif); margin: 0; letter-spacing: -.02em; }
.tray { list-style: none; padding: 0; margin: 22px 0; }
.tray-item { display: flex; align-items: baseline; gap: 10px; padding: 14px 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 8px; cursor: grab; font-size: 12px; overflow-wrap: anywhere; }
.tray-item > span:last-child { min-width: 0; }
.tray-item:hover { border-color: #969587; }
.tray-grip { color: var(--muted); }
.tray-empty { font: italic 15px/1.6 var(--serif); color: var(--muted); padding: 12px 0; }
.tray-list-link { font-size: 12px; display: inline-flex; gap: 16px; min-height: 44px; align-items: center; }
.calendar-scroll { flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--line); background: var(--surface); }
.cal-grid { display: grid; min-width: 700px; grid-template-columns: 48px repeat(7, minmax(0, 1fr)); grid-auto-rows: min-content; }
.cal-corner { display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cal-dayhead { text-align: center; border-left: 1px solid var(--line-soft); border-bottom: 1px solid var(--line); padding: 13px 0; }
.cal-dayhead > span { display: block; text-transform: uppercase; font-size: 9px; letter-spacing: .1em; color: var(--muted); }
.cal-dayhead time { display: inline-grid; place-items: center; width: 34px; height: 34px; font: 25px var(--serif); margin-top: 4px; }
.cal-dayhead.is-today time { background: var(--accent); color: var(--surface); border-radius: 50%; }
.cal-hours { grid-column: 1; }
.cal-hour { font-size: 9px; color: var(--muted); text-align: right; padding: 5px 6px 0 0; border-top: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-left: 1px solid var(--line-soft); }
.cal-slot { border-top: 1px solid var(--line-soft); }
.cal-slot.drop-hover { background: #eaf0e9; outline: 1px dashed var(--sched); outline-offset: -2px; }
.cal-block { position: absolute; left: 3px; right: 3px; background: #eaf0e9; border: 1px solid #d4e0d2; border-left: 2px solid var(--sched); border-radius: 2px; padding: 5px 6px; overflow: hidden; cursor: grab; }
.cal-block-time { display: block; padding-right: 19px; font-size: 9px; font-weight: 600; color: var(--sched); font-variant-numeric: tabular-nums; }
.cal-block-text { display: block; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; margin-top: 3px; }
.cal-unsched { position: absolute; top: 0; right: 0; width: 25px; min-height: 26px; padding: 0; background: transparent; border-color: transparent; color: var(--sched); font-size: 17px; }
.cal-unsched:hover { background: #d4e0d2; }
.page-footer { max-width: 1184px; margin: auto; padding: 20px 0 26px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 10px; }
.page-footer > :first-child { font: italic 15px var(--serif); }
@media (min-width: 1400px) {
  main { padding-top: 64px; }
}
@media (max-width: 1000px) {
  .topbar { gap: 28px; padding: 18px 28px; }
  .masthead-note { display: none; }
  .masthead-note + .logout-form { margin-left: auto; }
  main { padding: 36px 28px 48px; }
  .page-footer { margin: 0 28px; }
  .item { grid-template-columns: 18px 22px minmax(0, 1fr) 100px; }
  .item-actions { grid-column: 3 / -1; justify-content: flex-start; margin-top: -10px; }
  .item-actions:empty { display: none; }
  .group-select { width: auto; max-width: 160px; }
  .cal-wrap { gap: 18px; }
  .unscheduled-tray { width: 180px; }
}
@media (max-width: 700px) {
  .topbar { padding: 16px 20px; min-height: 80px; justify-content: space-between; gap: 12px; }
  .brand { font-size: 12px; gap: 9px; }
  .brand-mark { width: 31px; height: 36px; font-size: 29px; }
  .brand-caption { font-size: 8px; letter-spacing: .08em; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 11px 12px; font-size: 12px; }
  main { padding: 30px 20px 40px; }
  .page-heading { margin-bottom: 26px; gap: 12px; }
  .eyebrow { font-size: 9px; letter-spacing: .1em; }
  .edition-date { font-size: 10px; }
  .quick-add { padding: 18px 16px 14px; }
  .quick-add form { gap: 10px; }
  .quick-add input { font-size: 16px; }
  .quick-add button { padding: 10px 12px; gap: 6px; }
  .capture-plus { display: none; }
  .quick-add .hint { padding: 0; font-size: 11px; }
  .quick-add .hint span { display: block; }
  .filters form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; }
  .filter-title { display: none; }
  .filters label { margin-left: 0; }
  .filters select { width: 100%; font-size: 16px; }
  .reset-filters { grid-column: 2; margin-left: 0; justify-self: start; }
  .list-instruction { display: none; }
  .list-meta { padding: 20px 0 13px; }
  .group summary { padding: 12px; min-height: 58px; gap: 9px; }
  .group-name { font-size: 22px; }
  ul.items { padding: 0 12px; }
  .item { grid-template-columns: 16px 22px minmax(0, 1fr); gap: 8px 10px; padding: 16px 0 10px; }
  .item-meta { grid-column: 3; justify-content: flex-start; }
  .item-meta:empty { display: none; }
  .item-actions { grid-column: 3; margin-top: -3px; }
  .item-copy { align-self: center; }
  .item-text { font-size: 14px; }
  .group-select { font-size: 16px; max-width: 155px; }
  .edit-btn { font-size: 12px; }
  .edit-form { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
  .edit-title { grid-column: 1 / -1; }
  .edit-form input, .edit-form select { font-size: 16px; }
  .cal-toolbar { flex-direction: column; align-items: flex-start; gap: 14px; }
  .week-label { font-size: 21px; }
  .cal-wrap { flex-direction: column; }
  .unscheduled-tray, .calendar-scroll { width: 100%; }
  .tray { display: flex; gap: 8px; overflow-x: auto; margin: 16px 0 8px; padding-bottom: 5px; }
  .tray-item { flex: 0 0 180px; margin-bottom: 0; }
  .unscheduled-tray .hint br { display: none; }
  .cal-unsched { min-height: 30px; width: 30px; }
  .cal-block-time { padding-right: 25px; }
  .page-footer { margin: 0 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .done-box { appearance: auto; }
  .done-box::after { content: none; }
  .flag, .brand-mark { border: 1px solid CanvasText; }
}
