/* Appearance is controlled by data attributes on <html>, set from the user's settings:
   data-theme (system|light|dark), data-density (comfortable|compact), data-width (narrow|wide). */

:root {
  --bg: #fafafa; --surface: #ffffff; --fg: #1a1a1a; --muted: #5f5f66; --border: #c9c9cf;
  --link: #1a5fb4; --error: #b3261e; --streak: #b45309; --today: #1b6e36; --focus: #1a73e8; --pin: #fdf1e3;
  --h0: #e4e4e8; --h1: #b7e4c0; --h2: #6cc88a; --h3: #2fa152; --h4: #1b6e36;
  --gap: 1rem; --row-pad: .55rem; --font: 1rem; --tap: 2.75rem; --max: 40rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e; --surface: #2a2a2d; --fg: #ececee; --muted: #a3a3ab; --border: #48484e;
    --link: #8ab4f8; --error: #ff8a80; --streak: #ffb74d; --today: #7ee0a0; --focus: #8ab4f8; --pin: #3a2f22;
    --h0: #36363b; --h1: #1f4d2c; --h2: #2a7a43; --h3: #3fae63; --h4: #7ee0a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1e; --surface: #2a2a2d; --fg: #ececee; --muted: #a3a3ab; --border: #48484e;
  --link: #8ab4f8; --error: #ff8a80; --streak: #ffb74d; --today: #7ee0a0; --focus: #8ab4f8; --pin: #3a2f22;
  --h0: #36363b; --h1: #1f4d2c; --h2: #2a7a43; --h3: #3fae63; --h4: #7ee0a0;
  color-scheme: dark;
}
:root[data-density="compact"] { --gap: .6rem; --row-pad: .2rem; --font: .92rem; --tap: 2.25rem; }
:root[data-width="wide"] { --max: 64rem; }

html { font-family: system-ui, -apple-system, sans-serif; line-height: 1.45; }
body {
  margin: 0 auto; max-width: var(--max); box-sizing: border-box; background: var(--bg); color: var(--fg);
  font-size: var(--font);
  padding: 0 max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left));
}
a { color: var(--link); }
/* Links that are obviously interactive from context (titles, project labels, the nav) are quiet: no
   underline until hovered. Links inside running text (notes, comments, Back/Cancel) keep theirs. */
.title, nav a, .projects a, .projectlist a { text-decoration: none; }
.title:hover, nav a:hover, .projects a:hover, .projectlist a:hover { text-decoration: underline; }
.projectlist a { color: var(--fg); font-weight: 500; }
nav a { color: var(--fg); }
.title { color: var(--fg); }
.projects a { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* iOS zooms into inputs below 16px, so controls keep 16px in every density. */
input, button, select, textarea { font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: .4rem; padding: .3rem .6rem; box-sizing: border-box; max-width: 100%; }
button { min-height: var(--tap); cursor: pointer; }
input[type=text], input:not([type]), input[type=number], input[type=date], input[type=time], input[type=password], select { min-height: var(--tap); }
input[type=radio], input[type=checkbox] { min-height: 0; }
textarea { width: 100%; }
label { display: block; font-size: .9rem; margin-bottom: .15rem; }
label input[type=radio], label input[type=checkbox] { display: inline; margin-right: .4rem; }
fieldset { border: 1px solid var(--border); border-radius: .5rem; margin: 0 0 var(--gap); padding: .4rem .8rem .6rem; }
legend { padding: 0 .3rem; font-weight: 600; }
.radios label { display: inline-block; margin-right: 1rem; font-size: 1rem; }

header { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center;
  padding: .75rem 0; border-bottom: 1px solid var(--border); }
header form { margin: 0; }
.brand { font-weight: bold; text-decoration: none; }
nav { display: flex; flex-wrap: wrap; gap: .75rem; }
nav a[aria-current="page"] { font-weight: bold; text-decoration: none; border-bottom: 2px solid currentColor; }

h1 { font-size: 1.4rem; margin: var(--gap) 0 .5rem; }
h2 { font-size: 1rem; margin: 1.25rem 0 .25rem; color: var(--muted); }
.error { color: var(--error); }
.empty, .count, .legend { color: var(--muted); }
.count, .legend { font-size: .85rem; }
.empty { padding: .5rem 0; }

.quickadd { display: grid; grid-template-columns: 1fr auto; gap: .25rem .5rem; margin: .5rem 0 var(--gap); }
.quickadd label { grid-column: 1 / -1; }

.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: .75rem; align-items: flex-start; padding: var(--row-pad) 0; border-bottom: 1px solid var(--border); }
.task .done { margin: 0; flex: none; align-self: center; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 500; }
/* One quiet line: date and time, rule, streak, projects, separated by middots (drawn by CSS, and
   marked as decoration with an empty alternative text so screen readers skip them). */
.meta { display: flex; flex-wrap: wrap; gap: 0 .5rem; align-items: center; font-size: .75rem; color: var(--muted); }
.meta > span + span::before { content: "\00b7"; content: "\00b7" / ""; margin-right: .5rem; }
.due { font-weight: 500; }
.due.today { color: var(--today); }
.due.overdue { color: var(--error); }
.due.tomorrow { color: var(--fg); }
.streak { color: var(--streak); font-weight: 600; white-space: nowrap; }
.streak svg { width: .95em; height: .95em; vertical-align: -.1em; margin-right: .15em; fill: currentColor; }
.projects a + a { margin-left: .4rem; }
/* priority is only a word on the meta line: p1 red, p2 orange, p3 gray (p4, none, shows nothing) */
.prio-tag { font-weight: 600; }
.prio-tag.prio-1 { color: var(--error); }
.prio-tag.prio-2 { color: var(--streak); }
.prio-tag.prio-3 { color: var(--muted); }
/* Notes under a task: a small "notes" toggle, and the text smaller and indented behind a thin rule,
   so it reads as secondary to the title. */
.task details > summary { font-size: .8rem; color: var(--muted); cursor: pointer; padding: .1rem 0; }
.notes { white-space: pre-wrap; margin: .1rem 0 .3rem .35rem; padding-left: .7rem; border-left: 2px solid var(--border);
  font-size: .85rem; line-height: 1.4; }
.dense .notes, .card .notes { font-size: .8rem; }

.counter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .25rem 0; }
.counter progress { width: 8rem; }
.custom { display: flex; gap: .25rem; margin: 0; }
.custom input[type=number] { width: 6rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.card { border: 1px solid var(--border); background: var(--surface); border-radius: .5rem; padding: .25rem .75rem; margin: .75rem 0; }
.card summary { cursor: pointer; padding: .4rem 0; }
.card .task:last-child { border-bottom: 0; }

.danger { margin-top: 2rem; }

.stats { margin: .5rem 0 var(--gap); }
.heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: .25rem; }
.heat .col { display: flex; flex-direction: column; gap: 3px; }
.heat .cell { width: 11px; height: 11px; border-radius: 2px; background: var(--h0); display: block; }
.heat .cell.l1 { background: var(--h1); }
.heat .cell.l2 { background: var(--h2); }
.heat .cell.l3 { background: var(--h3); }
.heat .cell.l4 { background: var(--h4); }
.heat .cell.future { opacity: .3; }

.entries { list-style: none; padding: 0; }
.entries li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid var(--border); }
.entries form { margin: 0; }

.comment { border-left: 3px solid var(--border); padding: .25rem .75rem; margin: .5rem 0; }
.comment.pinned { border-left-color: #e67e22; background: var(--pin); }
.comment .when { font-size: .85rem; color: var(--muted); margin: 0; }
.comment .text, .preview { white-space: pre-wrap; margin: .25rem 0; }
.comment .actions { display: flex; gap: .5rem; }
.comment .actions form { margin: 0; }
details.comments > summary { cursor: pointer; padding: .25rem 0; }
.add-comment { margin-top: var(--gap); }
.preview { border-left: 3px solid var(--border); padding: .25rem .75rem; }

.note { color: var(--muted); margin: .25rem 0 var(--gap); }
.projectlist { list-style: none; padding: 0; }
.projectlist li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.rename { display: grid; grid-template-columns: 1fr auto; gap: .25rem .5rem; align-items: end; }
.rename label { grid-column: 1 / -1; }

/* Dense rows: the tasks inside a project card on Today and on a project page. */
.dense .task, .card .task { gap: .5rem; padding: .2rem 0; }
.dense .task .done button, .card .task .done button { min-height: 2rem; padding: .1rem .65rem; font-size: 14px; }
.dense .task .title, .card .task .title { font-size: .95rem; }
.dense .meta, .card .meta { font-size: .75rem; }
.dense .counter, .card .counter { gap: .35rem; margin: .1rem 0; }
.dense .counter progress, .card .counter progress { width: 5rem; height: .5rem; }
.dense .custom input[type=number], .card .custom input[type=number] { width: 6rem; min-height: 2rem; padding: .1rem .4rem; }
.dense .custom button, .card .custom button { min-height: 2rem; padding: .1rem .6rem; font-size: 14px; }
.card summary { padding: .25rem 0; }
.card { padding-top: .1rem; padding-bottom: .1rem; margin: .5rem 0; }

/* Profile menu: a <details> at the right end of the header (completed, settings, log out). */
.profile { position: relative; }
.profile summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--fg); }
.profile summary::-webkit-details-marker { display: none; }
.profile summary svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.profile[open] summary, .profile.current summary { border-color: var(--fg); }
.profile .menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 10; min-width: 11rem; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .3rem; }
.profile .who { margin: 0; padding: .3rem .7rem; font-size: .85rem; color: var(--muted); }
.profile .menu form { margin: 0; }
.profile .menu a, .profile .menu button { display: block; width: 100%; box-sizing: border-box; text-align: left; min-height: 0;
  padding: .5rem .7rem; border: 0; border-radius: .35rem; background: none; color: var(--fg); text-decoration: none; font-size: 1rem; }
.profile .menu a:hover, .profile .menu button:hover { background: var(--bg); }
.profile .menu a[aria-current="page"] { font-weight: bold; }

.projects-field .check { display: inline-block; margin: 0 1rem .35rem 0; font-size: 1rem; }
.projects-field .check input { margin-right: .4rem; }
