/* --fg is for the information you came for (title, temps, the habit, the pick, today, notes); --text is everything else.
   Purple accents: --accent (strong) colors the checkboxes, --rule (soft) the outlines; the two swap shades in dark mode. */
:root { color-scheme: light dark; --sunset: #c00; --fg: #000; --text: #555; --muted: #767676; --accent: #5e4b8b; --rule: #d3cae6; --check: 1.75rem; --bg: #fff; }
body {
  font-family: "Times New Roman", Times, serif;
  font-size: 1.125rem;
  line-height: 1.6;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem max(1rem, env(safe-area-inset-left)) 1.5rem max(1rem, env(safe-area-inset-right));
  background: var(--bg);
  color: var(--text);
}
a { color: #0000ee; }
a:visited { color: #551a8b; }
h1 { font-size: 1.75rem; line-height: 1.3; margin: 0 0 1.5rem; color: var(--fg); }
fieldset { margin: 0 0 1.75rem; padding: 0.75rem 1rem 1.25rem; min-width: 0; border: 1px solid var(--rule); }
legend { font-weight: bold; }
ul { list-style: none; margin: 0; padding: 0; }
button { font: inherit; min-height: 44px; padding: 0 0.75em; }
input[type="text"], input[type="search"] { font: inherit; min-height: 44px; box-sizing: border-box; max-width: 100%; }
textarea { display: block; font: inherit; width: 100%; box-sizing: border-box; margin-bottom: 0.5rem; }
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); margin: 0 0.5rem 0 0; flex: none; }
label { display: inline-flex; align-items: center; min-height: 44px; padding-right: 0.5rem; }
#banner { border: 2px solid #c00; padding: 0 0.75rem; margin-bottom: 1rem; }
#banner p { margin: 0.5rem 0; }
#weather-body { min-height: 8.5rem; }
#weather-body p { margin: 0; }
#weather-body table { width: 100%; border-collapse: collapse; }
#weather-body th, #weather-body td { text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; }
#weather-body tr + tr { border-top: 1px solid var(--rule); }
#weather-body th { font-weight: normal; }
#weather-body td:nth-child(2) { font-weight: bold; color: var(--fg); }
#weather-body th.sunset { color: var(--sunset); }
/* A module's title is a button that opens its edit sheet; it reads as the plain legend, with a dotted underline on
   hover like the other things you can tap to edit. */
.title-btn { min-height: 0; padding: 0; border: 0; border-bottom: 1px dotted transparent; background: none; font-weight: bold; color: inherit; cursor: pointer; }
.title-btn:hover, .title-btn:focus-visible { border-bottom-color: var(--rule); outline: none; }
#habit-legend.named { color: var(--fg); }
/* The habit's and the pick's day rows. 7 columns = RECENT_DAYS; a shorter chain fills from the left. */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-size: 0.85rem; }
.days label { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 0; }
.days input { width: var(--check); height: var(--check); margin: 0.25rem 0 0.5rem; }
.days .today { font-weight: bold; color: var(--fg); }
/* Read-only day rows (MonkeyDo's streak, filled in by ticking tasks): round dots, not boxes, so they don't read
   as something to tap. */
.days input[aria-readonly] { appearance: none; width: 1rem; height: 1rem; margin: 0.625rem 0 0.875rem; border: 2px solid var(--rule); border-radius: 50%; background: none; cursor: default; }
.days input[aria-readonly]:checked { border-color: var(--accent); background: var(--accent); }
.days input[aria-readonly]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Today's pick and MonkeyDo's task names read as plain text but are editable in place: a dotted underline on
   hover, a solid accent one while typing. */
.pick-row { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.75rem; }
#pick-label, .task-name { min-width: 0; margin: 0; padding: 0; border: 0; border-bottom: 1px dotted transparent; background: none; resize: none; field-sizing: content; overflow: hidden; }
#pick-label { flex: 1; }
#pick-label:hover, .task-name:hover { border-bottom-color: var(--rule); }
#pick-label:focus, .task-name:focus { outline: none; border-bottom: 1px solid var(--accent); }
/* A task name is as wide as its text (so a star can follow it), wrapping when it runs out of room. */
.task-name { flex: 0 1 auto; width: auto; min-width: 2ch; color: inherit; font-weight: inherit; line-height: inherit; }
/* Today's pick is the point of its box: bigger and bolder than everything around it. */
#pick-label { font-size: 1.5rem; line-height: 1.3; font-weight: bold; color: var(--fg); }
/* Quiet icon buttons (re-pick, add, ⋯); the button itself is the 44px tap target. */
.icon-btn { flex: none; display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--accent); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.again { margin: -0.25rem -0.5rem 0 0; }
/* MonkeyDo. Task rows wrap under their text, not under the box; subtasks step in by one box width. */
.task { display: flex; align-items: flex-start; flex: 1; min-width: 0; padding: 0.55rem 0.5rem 0.55rem 0; min-height: 0; overflow-wrap: anywhere; }
/* Only the box ticks. Its label is padded out (and pulled back by the same amount) for a bigger tap target. */
.task .box { display: block; min-height: 0; padding: 0.55rem 0.25rem 0.55rem 0.55rem; margin: -0.55rem 0.25rem -0.55rem -0.55rem; cursor: pointer; }
.task .box input { display: block; margin: 0.2rem 0 0; }
.task.project { font-weight: bold; color: var(--fg); }
.task.current { color: var(--accent); }
/* MonkeyDo's pick is the body size like everything else, picked out in bold and color among its project. */
#monkey-body .current { font-weight: bold; color: var(--accent); }
/* The pick's project: its name opens and closes the list of its subtasks. */
.pick-project { display: flex; align-items: center; gap: 0.3em; width: 100%; padding: 0; border: 0; background: none; text-align: left; font-weight: bold; color: var(--fg); cursor: pointer; }
.pick-project::before { content: "▾"; display: inline-block; width: 1em; flex: none; font-weight: normal; color: var(--muted); }
.pick-project[aria-expanded="false"]::before { content: "▸"; }
.pick-project .count { font-weight: normal; color: var(--muted); }
#monkey-body > .tree { margin-bottom: 0.25rem; }
#monkey-body p { margin: 0 0 0.75rem; }
/* Drag handle on subtask rows; touch-action keeps a drag on it from scrolling the page. */
.grip { flex: none; display: grid; place-items: center; width: 1.75rem; min-height: 44px; margin-left: -0.5rem; color: var(--muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.grip svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.dragging { background: color-mix(in srgb, var(--rule) 40%, transparent); }
.dragging .grip { cursor: grabbing; color: var(--accent); }
.tree .tree { padding-left: 1.25rem; }
.task-row { display: flex; align-items: flex-start; }
/* Narrower than the 44px icon buttons elsewhere (each is still 44px tall), so "+" and "⋯" sit close together. */
.actions { flex: none; display: flex; margin-right: -0.375rem; }
.actions .icon-btn { width: 2rem; }
.icon-btn[aria-expanded="true"] { color: var(--accent); }
.menu-wrap > .icon-btn svg { stroke-width: 3; }
/* The ⋯ menu: a popover placed by JS (top and right) under its button. */
.menu { position: fixed; inset: auto; margin: 0; padding: 0.25rem 0; min-width: 9rem; border: 1px solid var(--rule); background: var(--bg); color: var(--text); box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 0.15); }
.menu button { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0 1rem 0 0.75rem; border: 0; background: none; text-align: left; color: inherit; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: color-mix(in srgb, var(--rule) 40%, transparent); outline: none; color: var(--fg); }
.menu svg { width: 1.1rem; height: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
/* A starred task's name carries a small filled star. */
.star-mark { flex: none; margin-left: 0.35em; }
.star-mark svg { display: inline-block; width: 0.8em; height: 0.8em; vertical-align: -0.05em; fill: var(--accent); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.tree .add-row { padding-left: 1.75rem; }
#monkey-body > .add-row { padding-left: 1.25rem; }
.add-row { display: flex; gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
/* "+ subtask": a small quiet word row, not a button-shaped button; ::after keeps a 44px tap target. */
.add-sub { position: relative; min-height: 0; padding: 0; border: 0; background: none; font-size: 0.85rem; line-height: 1.5rem; color: var(--muted); cursor: pointer; }
.add-sub::after { content: ""; position: absolute; inset: -0.6rem -0.75rem; }
.add-sub:hover, .add-sub:focus-visible { color: var(--accent); outline: none; }
.tree .add-row:has(> .add-sub) { margin: -0.35rem 0 0.25rem; }
.add-row input { flex: 1; min-width: 0; }
#monkey-days { margin-bottom: 0.25rem; }
#monkey details, .sheet-open { margin-top: 0.25rem; }
/* "All (n)" opens the full-screen list; it looks like the Done summary under it. */
.sheet-open { display: flex; align-items: center; gap: 0.3em; width: 100%; padding: 0; border: 0; background: none; text-align: left; color: var(--muted); cursor: pointer; }
.sheet-open::before { content: "▸"; display: inline-block; width: 1em; }
/* The All list as a full-screen sheet, its column as wide as the page's. */
.sheet { box-sizing: border-box; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0 max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); border: 0; background: var(--bg); color: var(--text); overscroll-behavior: contain; }
.sheet::backdrop { background: var(--bg); }
body:has(.sheet[open]) { overflow: hidden; }
.sheet-inner { max-width: 40rem; margin: 0 auto; }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding-top: max(0.5rem, env(safe-area-inset-top)); margin-bottom: 0.25rem; border-bottom: 1px solid var(--rule); background: var(--bg); }
.sheet-head h2 { margin: 0; font-size: inherit; line-height: 44px; color: var(--fg); }
.sheet-head h2 span { font-weight: normal; color: var(--muted); }
#monkey-all-close, .sheet-cancel, .sheet-save { padding: 0 0.35em; border: 0; background: none; font-size: 1rem; color: var(--muted); text-decoration: underline; cursor: pointer; }
#monkey-all-close, .sheet-save { margin-right: -0.35em; }
.sheet-cancel { margin-left: -0.35em; }
.sheet-save { font-weight: bold; color: var(--accent); }
.sheet-save:disabled { opacity: 0.5; }
/* Edit sheets: the fields sit under the header; a list box fills the rest of the screen. */
.sheet-inner > label, .sheet-inner > form { margin-top: 0.5rem; }
.sheet-text { min-height: calc(100dvh - 12rem); tab-size: 2; }
#monkey summary { min-height: 44px; display: flex; align-items: center; gap: 0.3em; cursor: pointer; color: var(--muted); list-style: none; }
#monkey summary::before { content: "▸"; display: inline-block; width: 1em; }
#monkey details[open] > summary::before { content: "▾"; }
#monkey summary::-webkit-details-marker { display: none; }
#monkey-done-list .task { color: var(--muted); }
.path { color: var(--muted); }
#notes-text { margin: 0; padding: 0; border: 0; background: none; color: var(--fg); resize: vertical; min-height: 4lh; field-sizing: content; }
#notes-text::placeholder { color: var(--muted); }
/* Word buttons (notes' copy and clear, MonkeyDo's repick) sit on the top border opposite the legend, cutting the
   line the same way. Absolute top is measured from the legend's bottom, so go up one legend line (1.8rem = body
   size x line-height) and match its height. The gap keeps the two tap targets apart so a thumb can't hit the
   wrong one. */
#notes, #monkey { position: relative; }
.corner { position: absolute; top: -1.8rem; right: 0.75rem; display: flex; gap: 1.25rem; background: var(--bg); }
.corner button { position: relative; line-height: 1.8rem; min-height: 0; padding: 0 0.35em; border: 0; background: none; font-size: 1rem; color: var(--muted); text-decoration: underline; cursor: pointer; }
.corner button::after { content: ""; position: absolute; inset: -0.75rem -0.5rem; } /* a 44px tap target without the bulk */
.corner button[hidden] { display: none; }
#place-results button { display: block; margin-bottom: 0.25rem; text-align: left; max-width: 100%; overflow-wrap: anywhere; }
footer { margin-top: 2.5rem; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root { --sunset: #f66; --fg: #fff; --text: #a8a8a8; --muted: #8a8a8a; --accent: #c3b4e6; --rule: #3d3452; --bg: #000; }
  a, a:visited { color: #8ab4ff; }
  #banner { border-color: #f66; }
}
