/* =========================================================
   EDITORIAL-PAPER THEME — Work List
   Tweak color/spacing tokens in :root below.
   ========================================================= */
:root {
  /* Anthropic "paper/clay" palette (ivory · white cards · clay · olive) */
  --paper:       #FAF9F5;   /* ivory canvas */
  --paper-2:     #ffffff;   /* white raised surfaces */
  --ink:         #141413;   /* slate */
  --ink-soft:    #3D3D3A;   /* gray-800 */
  --ink-faint:   #87867F;   /* gray-500 */
  --rule:        #D1CFC5;   /* gray-200 */
  --rule-soft:   #E6E3DA;   /* between gray-50 and gray-200 */
  --accent:      #D97757;   /* clay */
  --accent-soft: #E2997D;   /* lighter clay */
  --chip-bg:     #F0EEE6;   /* gray-50 */
  --urgent:      #b4361f;   /* urgent flag colour */
  --overdue:     #a8341f;
  --today:       #D97757;   /* clay */
  --tomorrow:    #9c7d1a;
  --week:        #788C5D;   /* olive */
  --focus:       #2f6b9a;
  /* per-tab accents (referenced from tasks.js TABS) */
  --t-research:      #D97757;   /* clay */
  --t-passion:       #788C5D;   /* olive */
  --t-admin:         #3D3D3A;   /* gray-800 */
  --t-relationships: #9a5b7d;
  --t-pregnancy:     #7d8b4a;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
/* Always reserve the vertical-scrollbar gutter. Without this, switching to a
   short tab (e.g. Pregnancy) removes the scrollbar, widens the page ~15px, and
   re-centers the (margin:0 auto) layout — that is the slight horizontal shift
   of the header when changing sub-fields. Measured: header was moving 7.5px. */
html { -webkit-text-size-adjust: 100%; overflow-y: scroll; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 18% 6%, rgba(217,119,87,.045), transparent 38%),
    radial-gradient(circle at 86% 90%, rgba(120,140,93,.045), transparent 42%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 34px 24px 96px;
}

/* ---------- Masthead (compact) ---------- */
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.masthead .lead { min-width: 0; }
.kicker {
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 4px;
}
h1.title {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.02; letter-spacing: -.012em;
  margin: 0;
}
h1.title em { font-style: italic; color: var(--accent); }
.dateline {
  font-family: var(--serif); font-style: italic;
  font-size: 14px; color: var(--ink-soft);
  margin: 3px 0 0;
}
.progress { text-align: right; min-width: 150px; }
.progress .nums {
  font-family: var(--serif); font-size: 15px; color: var(--ink-soft);
  margin-bottom: 6px; white-space: nowrap;
}
.progress .nums b { color: var(--ink); font-weight: 600; }
.bar {
  height: 4px; border-radius: 6px; width: 150px;
  background: var(--rule-soft); overflow: hidden; margin-left: auto;
}
.bar > span {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}

/* ---------- Mode toggle ---------- */
.modebar { margin: 18px 0 10px; }
.segmented {
  display: inline-flex; gap: 2px;
  background: var(--chip-bg); border-radius: 999px; padding: 3px;
}
.segmented.full { display: flex; }
.segmented button {
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--ink-soft); background: transparent;
  border: none; cursor: pointer;
  padding: 6px 16px; border-radius: 999px;
  transition: background .18s, color .18s, box-shadow .18s;
  flex: 1; white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--paper-2); color: var(--ink);
  box-shadow: 0 1px 2px rgba(40,33,22,.12);
}

/* ---------- Controls row ---------- */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: 11px 0; margin-bottom: 4px;
}
.search { position: relative; flex: 1; min-width: 180px; }
.search input {
  width: 100%; font-family: var(--serif); font-size: 15px; color: var(--ink);
  background: transparent; border: none; border-bottom: 1.5px solid var(--rule);
  padding: 4px 4px 4px 24px; transition: border-color .2s;
}
.search input::placeholder { color: var(--ink-faint); font-style: italic; }
.search input:focus { outline: none; border-bottom-color: var(--accent); }
.search .icon {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); pointer-events: none; display: flex;
}
.sortseg { display: inline-flex; gap: 2px; background: var(--chip-bg); border-radius: 999px; padding: 3px; }
.sortseg button {
  font-size: 11.5px; font-weight: 500; color: var(--ink-soft);
  background: transparent; border: none; cursor: pointer;
  padding: 5px 11px; border-radius: 999px; transition: all .18s;
}
.sortseg button:hover { color: var(--ink); }
.sortseg button[aria-pressed="true"] { background: var(--paper-2); color: var(--ink); box-shadow: 0 1px 2px rgba(40,33,22,.12); }

/* ---------- Tab bar ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px 2px;
  margin: 12px 0 2px;
  border-bottom: 1px solid var(--rule-soft);
}
.tabs[hidden] { display: none; }   /* hide tab bar in Today's Agenda */
.tabs button {
  position: relative;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--ink-faint); background: none; border: none; cursor: pointer;
  padding: 8px 12px 10px; transition: color .18s;
}
.tabs button .ct {
  font-family: var(--mono);
  font-size: 10px; font-weight: 600; color: var(--ink-faint);
  margin-left: 5px; opacity: .8;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--tab-accent, var(--accent));
}
.tabs button[aria-selected="true"] .ct { color: var(--tab-accent, var(--accent)); opacity: 1; }

/* ---------- Project group header ---------- */
.group { margin-top: 6px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 14px 2px 7px; color: var(--ink-soft);
  font-family: var(--sans);
}
.group-head .tw {
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.group-head .gc { font-size: 10.5px; font-weight: 600; color: var(--ink-faint); }
.group-head .grule { flex: 1; height: 1px; background: var(--rule-soft); }
.group-head:hover .grule { background: var(--rule); }
.group-head .caret {
  color: var(--ink-faint); transition: transform .2s; display: flex;
}
.group.collapsed .caret { transform: rotate(-90deg); }
.group.collapsed ul.list { display: none; }
.group-head::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px;
  background: var(--tab-accent, var(--accent)); flex: none;
}

/* ---------- Task list ---------- */
ul.list { list-style: none; margin: 0; padding: 0; }
li.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 9px 4px 9px 14px;
  margin-left: calc(var(--depth, 0) * 26px);
  border-bottom: 1px solid var(--rule-soft);
  position: relative;
  transition: opacity .25s, background .15s, margin-left .2s var(--ease);
}
/* nested (indented) rows read as sublist items: subtler left rail */
li.task.nested::before { opacity: .5; }
li.task:hover { background: rgba(255,255,255,.4); }
/* left rail: faint by default, accent when urgent */
li.task::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 3px; background: var(--rule);
}
li.task.urgent::before { background: var(--urgent); }
li.task.done::before { opacity: .3; }

/* checkbox — aligns to the first title line */
.check { flex: none; margin-top: 1px; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 50%;
  border: 1.6px solid var(--ink-faint); cursor: pointer; color: transparent;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .26s var(--ease);
}
.check label:hover { border-color: var(--week); transform: scale(1.08); }
.check input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.check input:checked + label { background: var(--week); border-color: var(--week); color: #fff; }
.check label svg { width: 11px; height: 11px; }

/* main column: title row + meta */
.main { flex: 1 1 auto; min-width: 0; }
.titlerow {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
}
.ttitle {
  font-family: var(--serif); font-optical-sizing: auto;
  font-size: 16px; line-height: 1.3; letter-spacing: -.004em;
  font-weight: 450; color: var(--ink); min-width: 0;
  cursor: text;
}
.ttitle.bold { font-weight: 700; }
.ttitle.editing {
  outline: none; cursor: text;
  background: var(--paper-2);
  box-shadow: inset 0 -1.5px 0 var(--accent);
  border-radius: 3px; padding: 0 2px; margin: 0 -2px;
}

/* ---------- Add-task row (+) ---------- */
li.addrow {
  list-style: none; border-bottom: 1px solid var(--rule-soft);
  padding: 0;
}
.addbtn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--ink-faint);
  padding: 9px 4px 9px 14px;
  transition: color .15s;
}
.addbtn:hover { color: var(--accent); }
.addbtn .addicon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.4px solid var(--rule); color: var(--ink-faint);
  transition: border-color .15s, color .15s;
}
.addbtn .addicon svg { width: 11px; height: 11px; }
.addbtn:hover .addicon { border-color: var(--accent); color: var(--accent); }

/* when badge — clickable to reschedule */
.whenwrap { position: relative; flex: none; }
.when {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--chip-bg); border: 1.5px solid var(--rule); cursor: pointer;
  padding: 2px 7px; border-radius: 8px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.when:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-faint); }
.when .wcaret { width: 10px; height: 10px; opacity: .5; }
.when.today    { color: var(--today); }
.when.tomorrow { color: var(--tomorrow); }
.when.week     { color: var(--week); }
.when.later    { color: var(--ink-faint); opacity: .8; }
.when.overdue  { color: var(--overdue); }

/* reschedule dropdown */
.whenmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  display: none; flex-direction: column; min-width: 152px;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 11px; padding: 5px;
  box-shadow: 0 6px 22px -8px rgba(40,33,22,.38);
}
.whenmenu.open { display: flex; }
.wopt {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--ink-soft);
  padding: 7px 9px; border-radius: 7px; transition: background .12s, color .12s;
}
.wopt:hover { background: var(--chip-bg); color: var(--ink); }
.wopt.sel { color: var(--ink); font-weight: 600; }
.wopt .wdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wopt .wdot.today    { background: var(--today); }
.wopt .wdot.tomorrow { background: var(--tomorrow); }
.wopt .wdot.week     { background: var(--week); }
.wopt .wdot.later    { background: var(--ink-faint); }
.wopt .wcheck { margin-left: auto; color: var(--accent); display: inline-flex; }

/* meta row (urgent flag, tab chip, due, notes) */
.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px;
  margin-top: 3px;
}
.uchip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  color: var(--urgent); background: none; padding: 0;
}
.uchip svg { width: 11px; height: 11px; opacity: .9; }
/* quiet category tag (Today's Agenda) — muted, pushed to the right */
.tabtag {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint);
}
.tabtag .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; opacity: .65; }
.due {
  font-family: var(--mono);
  font-size: 11px; font-weight: 500; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 4px;
}
.due svg { width: 11px; height: 11px; opacity: .7; }
.due.overdue { color: var(--overdue); font-weight: 600; }
.due.overdue svg { opacity: 1; }
.notes {
  font-family: var(--serif); font-style: italic; font-size: 13px;
  color: var(--ink-soft); line-height: 1.4;
}

li.task.done .ttitle { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--rule); font-weight: 450; }
li.task.done .notes { opacity: .6; }
li.task.done { opacity: .8; }

/* drag handle (reorder) — kept gently visible so it's discoverable */
.handle {
  flex: none; align-self: center;
  color: var(--rule); background: none; border: none; cursor: grab;
  opacity: .28; transition: opacity .18s, color .18s;
  font-size: 13px; line-height: .7; letter-spacing: 1px;
  padding: 2px 0; user-select: none;
}
li.task:hover .handle { opacity: 1; }
.handle:hover { color: var(--ink-faint); }
.handle:focus-visible { opacity: 1; outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* delete button (hover-reveal) */
.del {
  flex: none; align-self: center;
  color: var(--ink-faint); background: none; border: none; cursor: pointer;
  opacity: 0; transition: opacity .18s, color .18s, background .15s;
  padding: 4px; margin-left: 2px; border-radius: 6px; display: inline-flex;
}
.del svg { width: 14px; height: 14px; }
li.task:hover .del { opacity: .65; }
.del:hover { opacity: 1 !important; color: var(--urgent); background: rgba(180,54,31,.08); }
.del:focus-visible { opacity: 1; outline: 2px solid var(--focus); outline-offset: 1px; }

li.task.dragging { opacity: .4; }
li.task.drag-over { box-shadow: inset 0 2px 0 var(--accent); }

/* keyboard focus highlight */
li.task.kbfocus { background: rgba(47,107,154,.09); }
li.task.kbfocus::before { background: var(--focus); width: 3px; opacity: 1; }
li.task.kbfocus .handle { opacity: 1; color: var(--focus); }

/* empty state */
.empty { text-align: center; padding: 54px 20px; color: var(--ink-faint); }
.empty .mark { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--ink-soft); margin-bottom: 6px; }
.empty p { margin: 3px 0; font-size: 13.5px; }

/* footer */
.colophon {
  margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: 11.5px; color: var(--ink-faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 18px;
}
.colophon .legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.colophon .legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .lg-flag { color: var(--urgent); font-weight: 600; }
.legend .lg-flag svg { width: 10px; height: 10px; }
.legend .tdot { width: 7px; height: 7px; border-radius: 50%; }
.reset-btn {
  background: none; border: none; cursor: pointer; color: var(--ink-faint);
  font-size: 11.5px; font-weight: 500; padding: 0;
  border-bottom: 1px solid transparent; transition: color .18s, border-color .18s;
}
.reset-btn:hover { color: var(--accent); border-bottom-color: var(--accent); }
.reset-btn:disabled { color: var(--rule); cursor: default; border-bottom-color: transparent; }
.foot-actions { display: inline-flex; gap: 16px; align-items: center; }

/* shortcuts overlay */
.help-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(37,33,27,.42); backdrop-filter: blur(2px);
}
.help-overlay.open { display: flex; }
.help-card {
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 16px; padding: 22px 24px 24px;
  max-width: 640px; width: 100%;
  box-shadow: 0 18px 50px -12px rgba(40,33,22,.5);
}
.help-head h2 {
  font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0;
}
.help-head p { margin: 4px 0 16px; font-size: 12.5px; color: var(--ink-soft); }
.help-cols { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px 22px; }
.help-cols h3 {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 8px;
}
.help-cols dl { margin: 0; }
.help-cols dl > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 4px 0; border-bottom: 1px solid var(--rule-soft);
}
.help-cols dt { flex: none; }
.help-cols dd { margin: 0; font-size: 12.5px; color: var(--ink-soft); text-align: right; }
kbd {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink);
  background: var(--chip-bg); border: 1px solid var(--rule);
  border-radius: 5px; padding: 1px 5px; box-shadow: 0 1px 0 var(--rule);
}
@media (max-width: 540px) { .help-cols { grid-template-columns: 1fr; } }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

@media (max-width: 540px) {
  .wrap { padding: 26px 16px 80px; }
  .masthead { flex-direction: column; align-items: stretch; gap: 14px; }
  .progress { text-align: left; }
  .progress .nums { margin-left: 0; }
  .bar { width: 100%; margin-left: 0; }
  .tabs { gap: 2px; }
  .tabs button { padding: 8px 9px 10px; font-size: 12.5px; }
}
