/* nonane web GUI. One stylesheet, no framework; light and dark follow the
   system. Phones get a tab bar at the bottom and one board column per
   screen (FR-94). */

:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --accent: #2f6fdf;
  --accent-text: #ffffff;
  --warn: #b4321f;
  --warn-bg: #fdecea;
  --ok-bg: #e8f3ea;
  --card: #ffffff;
  --col: #efeee9;
  --code: #f0efea;
  --due: #b4321f;
  --soon: #a15c00;
  --tag: #3b5bab;
  --done: #2f8f4e;
  --done-text: #ffffff;
  --radius: 8px;
  --tabbar: 0px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --panel: #1f1f1e;
    --text: #e8e7e3;
    --muted: #9c9b95;
    --line: #34332f;
    --accent: #6d9bff;
    --accent-text: #0d1424;
    --warn: #ff8a75;
    --warn-bg: #3a1f1a;
    --ok-bg: #1b2e20;
    --card: #262624;
    --col: #1b1b1a;
    --code: #2a2a27;
    --due: #ff8a75;
    --soon: #f0b35a;
    --tag: #9db4ff;
    --done: #5bd08d;
    --done-text: #10261a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
code, pre, textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; }
main { padding: 1rem; max-width: 1400px; margin: 0 auto; padding-bottom: calc(1rem + var(--tabbar)); }
.narrow { max-width: 42rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .875rem; }
[hidden] { display: none !important; }

/* Header and navigation */
.top { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); letter-spacing: .02em; }
.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .35rem .65rem; border-radius: var(--radius); color: var(--muted); display: flex; gap: .35rem; align-items: center; }
.tabs a[aria-current] { background: var(--col); color: var(--text); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .ico { font-size: 1.05rem; }
.search { margin-left: auto; flex: 0 1 14rem; min-width: 6rem; }
.search input { width: 100%; }
/* Between a phone and a wide screen the sections show their icons only,
   the current one with its name, so that the bar fits on one line. */
@media (min-width: 761px) and (max-width: 1180px) {
  .tabs a:not([aria-current]) span:last-child { display: none; }
  .tabs a { padding: .35rem .5rem; }
}
.signout { margin: 0; }

.clockbar { display: flex; align-items: center; gap: .6rem; padding: .4rem 1rem; background: var(--ok-bg); border-bottom: 1px solid var(--line); font-size: .95rem; }
.clockbar a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clockbar form { margin: 0 0 0 auto; }
.clockbar form + form { margin-left: 0; }
.clockbar button { white-space: nowrap; }
.clock-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #2fa84f; flex: none; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.elapsed { font-variant-numeric: tabular-nums; color: var(--muted); }

.flash { margin: .75rem 1rem 0; padding: .6rem .8rem; border-radius: var(--radius); background: var(--ok-bg); max-width: 1400px; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
main .flash { margin: 0 0 1rem; }

/* Forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=time], input:not([type]), select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .55rem; min-height: 2.4rem; max-width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .8rem; min-height: 2.4rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; color: var(--text); }
button:hover, .button:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: .2rem .3rem; min-height: auto; }
button.small, .button.small { min-height: 1.9rem; padding: .15rem .5rem; font-size: .875rem; }
button.danger { color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.stack label > input, .stack label > select, .stack label > textarea { color: var(--text); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 0; }
.toolbar .filter { flex: 1; min-width: 12rem; }
.toolbar .filter input { flex: 1; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

/* Sign-in */
.login { max-width: 22rem; margin: 12vh auto 0; }
.login h1 { font-size: 2rem; text-align: center; margin-bottom: 1.5rem; }

/* Badges */
.badges { display: inline-flex; flex-wrap: wrap; gap: .3rem; font-size: .8rem; color: var(--muted); }
.badge { padding: 0 .35rem; border-radius: 4px; background: var(--col); white-space: nowrap; }
.badge.due { color: var(--due); }
.badge.soon { color: var(--soon); }
.badge.tag { color: var(--tag); background: none; padding: 0; }
.badge.prio { font-weight: 600; }
.badge.running { background: var(--ok-bg); }

/* Task list */
.tasklist { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tasklist li { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .75rem; border-top: 1px solid var(--line); }
.tasklist li:first-child { border-top: none; }
.tasklist .group { background: var(--col); font-weight: 600; font-size: .85rem; color: var(--muted); padding: .3rem .75rem; }
.tasklist .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.tasklist .title { color: var(--text); word-break: break-word; }
.tasklist .closed .title { text-decoration: line-through; color: var(--muted); }
.tasklist form { margin: 0; }
.check { width: 1.6rem; height: 1.6rem; min-height: 0; padding: 0; border-radius: 50%; flex: none; font-size: .9rem; }
.check.doing { border-color: var(--accent); color: var(--accent); }
.check.done { background: var(--col); }
.actions { display: flex; gap: .25rem; flex: none; }
.quickadd { display: flex; gap: .5rem; margin-bottom: 1rem; }
.quickadd input { flex: 1; min-width: 0; }

/* Task form */
.taskform { max-width: 46rem; }
.taskform textarea { min-height: 7rem; }
.blocks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.blocks li { display: flex; gap: .5rem; align-items: center; }

/* Board */
.board { display: flex; gap: .75rem; align-items: flex-start; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.column { flex: 0 0 18rem; background: var(--col); border-radius: var(--radius); padding: .5rem; scroll-snap-align: start; display: flex; flex-direction: column; max-height: calc(100vh - 11rem); }
.column header { display: flex; justify-content: space-between; align-items: baseline; padding: .15rem .3rem .5rem; font-weight: 600; text-transform: capitalize; }
.column header .count { color: var(--muted); font-weight: 400; font-size: .85rem; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; min-height: 3rem; overflow-y: auto; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; display: flex; flex-direction: column; gap: .3rem; touch-action: manipulation; }
.card .title { color: var(--text); word-break: break-word; }
.card .foot { display: flex; justify-content: space-between; align-items: center; gap: .3rem; }
.card .move { display: flex; gap: .15rem; margin: 0; }
.card .move button { min-height: 1.9rem; min-width: 2.2rem; padding: 0 .4rem; }
.card .badge.status { display: none; }
.card.dragging { opacity: .5; }
.card.ghost { opacity: .3; }
.card.chosen { box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.card.busy { opacity: .6; }
.column .add { margin: .5rem 0 0; display: flex; gap: .3rem; }
.column .add input { flex: 1; min-width: 0; min-height: 2.1rem; }
.column .add button { min-height: 2.1rem; }

/* Notes */
.notes-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.5rem; align-items: start; }
.notes-layout aside { position: sticky; top: 4rem; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; word-break: break-word; }
.crumbs a { color: var(--muted); }
.filelist { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.filelist li { border-top: 1px solid var(--line); }
.filelist li:first-child { border-top: none; }
.filelist a { display: flex; gap: .5rem; padding: .55rem .75rem; color: var(--text); word-break: break-word; }
.filelist .folder a { font-weight: 600; }
.filelist .meta { margin-left: auto; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.prose { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose img { max-width: 100%; height: auto; }
.prose pre { background: var(--code); padding: .75rem; border-radius: 6px; overflow-x: auto; }
.prose code { background: var(--code); padding: .05rem .25rem; border-radius: 4px; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .3rem .6rem; }
.prose ul.contains-task-list { padding-left: 1.2rem; }
.prose li.task-list-item { list-style: none; }
.prose li.task-list-item input { margin: 0 .4rem 0 -1.2rem; }
.prose a.wikilink.unresolved { color: var(--muted); border-bottom: 1px dashed var(--muted); }
.prose a.tag { color: var(--tag); }
.prose li:has(> input[type=checkbox]), .prose li:has(> .tsym), .prose li:has(> p > input[type=checkbox]), .prose li:has(> p > .tsym) { list-style: none; }
.prose li > input[type=checkbox], .prose li > p > input[type=checkbox] { margin: 0 .35rem 0 -1.25rem; }
.prose .tsym { font-family: ui-monospace, monospace; font-size: .85em; color: var(--muted); margin-left: -1.6rem; }
.prose .embed { display: block; border-left: 3px solid var(--accent); padding: .25rem 0 .25rem 1rem; margin: .75rem 0; }
.prose .embed-title { display: block; font-size: .85rem; color: var(--muted); }
.prose mark { background: #fff2a8; color: #1d1d1b; }
.props { font-size: .875rem; color: var(--muted); margin: 0 0 .75rem; display: grid; grid-template-columns: max-content 1fr; gap: .1rem .75rem; }
.props dt { font-weight: 600; }
.props dd { margin: 0; }
.backlinks ul { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.backlinks li { padding: .3rem 0; border-top: 1px solid var(--line); }
.backlinks .ctx { display: block; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hits { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.hits li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.hits .path { font-size: .8rem; color: var(--muted); }
.hits .line { font-size: .875rem; margin: .2rem 0 0; color: var(--muted); overflow-wrap: anywhere; }
.hits .line b { color: var(--text); }

/* Editor */
.editor { display: flex; flex-direction: column; gap: .6rem; }
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.editor-panes.no-preview { grid-template-columns: 1fr; }
.editor-panes.preview-only .source { display: none; }
.editor-panes.preview-only { grid-template-columns: 1fr; }
.editor textarea.source { width: 100%; min-height: 60vh; resize: vertical; line-height: 1.5; }
.editor .cm-editor { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-height: 60vh; font-size: .95rem; }
.editor .cm-editor.cm-focused { outline: 2px solid var(--accent); }
.editor .cm-scroller { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; line-height: 1.5; }
.editor .preview { min-height: 60vh; }
.editor .bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; position: sticky; top: 3.4rem; background: var(--bg); padding: .3rem 0; z-index: 5; }
.conflict { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.conflict pre { background: var(--code); padding: .75rem; border-radius: 6px; max-height: 40vh; overflow: auto; white-space: pre-wrap; }

/* Agenda */
.days { display: flex; flex-direction: column; gap: 1rem; }
.agenda-day h2 { margin: 0 0 .4rem; font-size: 1rem; }
.agenda-day.today h2 { color: var(--accent); }
.items { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.items li { display: flex; gap: .75rem; padding: .45rem .75rem; border-top: 1px solid var(--line); align-items: baseline; }
.items li:first-child { border-top: none; }
.items .when { flex: 0 0 6.5rem; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.items .kind-overdue .when, .items .kind-deadline .when { color: var(--due); }
.items .empty { color: var(--muted); }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month .head { background: var(--col); text-align: center; font-size: .8rem; padding: .25rem; color: var(--muted); }
.month .cell { background: var(--panel); min-height: 6.5rem; padding: .25rem; font-size: .78rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.month .cell.other { background: var(--bg); color: var(--muted); }
.month .cell.today .num { background: var(--accent); color: var(--accent-text); border-radius: 50%; }
.month .num { align-self: flex-start; min-width: 1.5rem; text-align: center; font-weight: 600; color: inherit; }
.month .it { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 .2rem; border-radius: 3px; background: var(--col); color: var(--text); }
.month .it.kind-appointment { background: #dcf3e2; color: #10391c; }
.month .it.kind-block { background: #ece0fb; color: #3b1966; }
.month .it.kind-deadline, .month .it.kind-overdue { color: var(--due); }
.month .more { color: var(--muted); }

/* Reports */
.chart { width: 100%; max-width: 760px; height: auto; display: block; }
.chart text { fill: var(--text); font-size: 13px; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart g:hover .bar { opacity: .8; }
.chart .muted { fill: var(--muted); }
table.report { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.report th, table.report td { text-align: left; padding: .4rem .75rem; border-top: 1px solid var(--line); }
table.report td.num, table.report th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.report tr.sub td:first-child { padding-left: 1.75rem; color: var(--muted); }
table.report tfoot td { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .85rem; }

/* Phones (FR-94): bottom tab bar, one board column per screen width, a
   single editor pane with a preview toggle. */
@media (max-width: 760px) {
  :root { --tabbar: 3.6rem; }
  main { padding: .75rem; padding-bottom: calc(1rem + var(--tabbar) + env(safe-area-inset-bottom)); }
  .top { gap: .5rem; padding: .4rem .75rem; }
  .search { flex: 1; margin-left: 0; }
  .search input { width: 100%; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); justify-content: space-around; padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); z-index: 20; }
  .tabs a { flex: 1 1 0; flex-direction: column; gap: 0; font-size: .7rem; padding: .2rem .1rem; min-width: 0; }
  .tabs .ico { font-size: 1.25rem; }
  .column { flex: 0 0 86vw; max-height: none; }
  .board { margin: 0 -.75rem; padding: 0 .75rem .5rem; scroll-padding: 0 .75rem; }
  .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .notes-layout aside { position: static; }
  .editor-panes { grid-template-columns: 1fr; }
  .editor-panes:not(.show-preview) .preview { display: none; }
  .editor-panes.show-preview .source, .editor-panes.show-preview .cm-editor { display: none; }
  .editor .bar { top: 3rem; }
  .editor .bar strong { flex-basis: 100%; }
  .editor .bar .status { flex: 1; }
  .page-edit .tabs { display: none; }
  .page-edit main { padding-bottom: 1rem; }
  .month .cell { min-height: 4.5rem; }
  .month .it { font-size: .68rem; }
  .items .when { flex-basis: 5.4rem; font-size: .8rem; white-space: nowrap; }
  .toolbar h1.grow { flex-basis: 100%; margin-bottom: 0; }
  .chart text { font-size: 22px; }
  .prose { padding: .75rem .85rem; }
}
@media (min-width: 761px) {
  .only-phone { display: none !important; }
}

/* Week calendar (FR-100): a grid of days and slots; positions come from
   the generated calendar-grid.css. */
.cal-scroll { overflow: auto; max-height: calc(100vh - 13rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.cal { display: grid; grid-template-columns: 3.4rem repeat(7, minmax(6.5rem, 1fr)); min-width: 100%; }
.cal.slot15 { --slot: 1.05rem; }
.cal.slot30 { --slot: 1.45rem; }
.cal.slot60 { --slot: 2.6rem; }
.cal-corner, .cal-head { position: sticky; top: 0; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line); }
.cal-corner { left: 0; z-index: 5; }
.cal-head { padding: .3rem .35rem; border-left: 1px solid var(--line); font-size: .8rem; min-width: 0; }
.cal-head.today .cal-date { color: var(--accent); }
.cal-date { font-weight: 600; color: var(--text); display: block; }
.cal-strip { list-style: none; margin: .15rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .1rem; }
.cal-strip li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.cal-strip .kind-appointment { background: #dcf3e2; color: #10391c; border-radius: 3px; padding: 0 .2rem; }
.cal-strip .kind-deadline, .cal-strip .kind-overdue { color: var(--due); }
.cal-strip a { color: inherit; }
.cal-times { position: sticky; left: 0; z-index: 3; display: grid; background: var(--panel); font-size: .72rem; color: var(--muted); border-right: 1px solid var(--line); }
.cal-times span { padding: 0 .3rem; transform: translateY(-.45em); text-align: right; }
.cal-day { display: grid; position: relative; border-left: 1px solid var(--line); min-width: 0; }
.cal-day.today { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-day .slot { grid-column: 1 / -1; border-top: 1px dotted color-mix(in srgb, var(--line) 70%, transparent); z-index: 0; }
.cal-day .slot.hour { border-top: 1px solid var(--line); }
.cal-day .slot:hover, .cal-day .slot:focus-visible, .cal-day .slot.picked { background: color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }
.cal-day .ev { z-index: 1; margin: 1px 2px; padding: .1rem .3rem; border-radius: 5px; overflow: hidden; font-size: .75rem; line-height: 1.25; color: var(--text); min-width: 0; background: var(--col); border-left: 3px solid var(--muted); }
.cal-day .ev:hover { text-decoration: none; filter: brightness(.97); }
.cal-day .ev .when { display: block; color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
.cal-day .ev.kind-block { background: #ece0fb; border-left-color: #8b46e8; color: #2a1150; }
.cal-day .ev.kind-appointment { background: #dcf3e2; border-left-color: #2fa84f; color: #10391c; }
.cal-day .ev.running { box-shadow: inset 0 0 0 2px #2fa84f; }
.cal-day .ev.cont-before { border-top-left-radius: 0; border-top-right-radius: 0; }
.cal-day .ev.cont-after { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cal-day .now { grid-column: 1 / -1; z-index: 2; border-top: 2px solid #e5484d; pointer-events: none; height: 0; align-self: start; }
@media (prefers-color-scheme: dark) {
  .cal-day .ev.kind-block { background: #33224d; color: #eadcff; }
  .cal-day .ev.kind-appointment { background: #183524; color: #d3f5dd; }
  .cal-strip .kind-appointment { background: #183524; color: #d3f5dd; }
}
@media (max-width: 760px) {
  .cal-scroll { max-height: calc(100vh - 15rem - var(--tabbar)); margin: 0 -.75rem; border-radius: 0; border-left: 0; border-right: 0; }
  .cal { grid-template-columns: 2.8rem repeat(7, minmax(5.6rem, 1fr)); }
}

/* Completion (FR-19): complete.js puts the list under the field. */
.complete { position: fixed; z-index: 60; margin: 0; padding: .25rem 0; list-style: none; max-height: 16rem; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.15); font-size: .9rem; }
.complete li { display: flex; gap: .6rem; align-items: baseline; padding: .35rem .7rem; cursor: pointer; }
.complete li .text { overflow-wrap: anywhere; }
.complete li .detail { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.complete li:hover { background: var(--col); }
.complete li[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.complete li[aria-selected="true"] .detail { color: inherit; opacity: .8; }
@media (max-width: 760px) {
  .complete li { padding: .55rem .8rem; }
}

/* Planning an open task (FR-48): beside the grid on wide screens, a list
   to drag from or to pick from (calendar.js shows it); on the page of a
   slot, a list of buttons. */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.cal-tasks, .cal-tasks[hidden] { display: none; }
@media (min-width: 1100px) {
  .cal-wrap.with-tasks { grid-template-columns: minmax(0, 1fr) 15rem; }
  .cal-tasks:not([hidden]) { display: flex; flex-direction: column; gap: .4rem; min-height: 0; max-height: calc(100vh - 13rem); }
}
.cal-tasks h2 { font-size: 1rem; margin: 0; }
.cal-tasks .hint { margin: 0; color: var(--muted); }
.cal-tasks ul, .plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.cal-tasks ul { overflow: auto; min-height: 0; }
.cal-task, .plan-task { display: flex; flex-direction: column; align-items: stretch; gap: .1rem; width: 100%; text-align: left; padding: .35rem .5rem; border: 1px solid var(--line); border-left: 3px solid var(--project, var(--line)); border-radius: 6px; background: var(--card); color: var(--text); font: inherit; font-size: .85rem; }
.cal-task { cursor: grab; user-select: none; }
.cal-task .title, .plan-task .title { overflow-wrap: anywhere; }
.cal-task .meta, .plan-task .meta { font-size: .72rem; color: var(--muted); }
.cal-task:hover, .cal-task:focus-visible, .plan-task:hover { border-color: var(--accent); border-left-color: var(--project, var(--accent)); outline: none; }
.cal-task[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, var(--card)); box-shadow: 0 0 0 2px var(--accent); }
.cal-task.dragging { opacity: .5; }
.cal-day .slot.drop { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.planning .cal-day .slot { cursor: copy; }
.plan { margin-top: 1rem; }
.plan h2 { font-size: 1.05rem; margin: 0; }
.plan .plan-task { min-height: 2.6rem; justify-content: center; }

/* Project colours (FR-54): app.js sets --project from data-color. Without
   it the elements keep their usual colours. */
.pdot { display: inline-block; width: .62em; height: .62em; border-radius: 2px; margin-right: .35em; background: var(--project, transparent); }
.card[data-color] { border-left: 4px solid var(--project, var(--line)); }
.tasklist .task[data-color] { box-shadow: inset 3px 0 0 var(--project, transparent); }
.cal-day .ev.kind-block[data-color] { border-left-color: var(--project, #8b46e8); background: color-mix(in srgb, var(--project, #8b46e8) 24%, var(--card)); color: var(--text); }
.month .it.kind-block[data-color] { background: color-mix(in srgb, var(--project, #8b46e8) 24%, var(--card)); color: var(--text); }
@media (prefers-color-scheme: dark) {
  .cal-day .ev.kind-block[data-color], .month .it.kind-block[data-color] { background: color-mix(in srgb, var(--project, #8b46e8) 32%, var(--card)); }
}

/* Habits (file-format §5.10): a card per habit with a grid of its last
   weeks; each day is a button that ticks or unticks it. */
.habits { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; }
.habit { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .75rem; min-width: 0; }
.habit[data-color] { border-left: 4px solid var(--project, var(--line)); }
.habit header { gap: .5rem; align-items: baseline; }
.habit .title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.habit p { margin: .15rem 0 .5rem; font-size: .9rem; }
.badge.streak { color: var(--done); font-weight: 600; }
.habit-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; margin: 0; }
.habit-grid .wd { text-align: center; font-size: .75rem; color: var(--muted); }
.habit-grid .day { min-width: 0; height: 2.1rem; padding: 0; font-size: .8rem; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-variant-numeric: tabular-nums; }
.habit-grid .day.done { background: var(--done); border-color: var(--done); color: var(--done-text); font-weight: 600; }
.habit-grid .day.missed { border-color: var(--due); color: var(--due); }
.habit-grid .day.due { border: 2px solid var(--accent); color: var(--text); }
.habit-grid .day.today { font-weight: 700; }
.habit-grid .day.later { opacity: .35; border-style: dashed; }
.habit-grid .day:not(:disabled):hover { border-color: var(--accent); }

/* Spaces (M8): the switcher, read-only notices. */
.switcher { position: relative; }
.switcher summary { cursor: pointer; list-style: none; padding: .3rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); font-size: .9rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher summary::after { content: " ▾"; color: var(--muted); }
.switcher summary::-webkit-details-marker { display: none; }
.switcher ul { position: absolute; z-index: 30; top: 2.4rem; left: 0; min-width: 14rem; list-style: none; margin: 0; padding: .3rem 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.switcher li a { display: block; padding: .45rem .8rem; color: var(--text); }
.switcher li a[aria-current] { font-weight: 600; }
.role { font-size: .75rem; color: var(--muted); background: var(--col); border-radius: 4px; padding: 0 .3rem; }
.flash.readonly { background: var(--col); color: var(--muted); }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.check.readonly { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); }
@media (max-width: 760px) {
  .switcher summary { max-width: 7rem; }
  .switcher ul { position: fixed; left: .75rem; right: .75rem; top: 3rem; }
}

/* Members and accounts (FR-140). */
.member { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .55rem .75rem; }
.member form { margin: 0; }
.member .grow { min-width: 10rem; }
code.secret { user-select: all; font-size: 1rem; }

/* Contacts */
.cardnote { white-space: pre-wrap; }
.people { margin: .25rem 0 .75rem; color: var(--muted); }
.edit-card { margin-top: 1rem; }
.edit-card summary { cursor: pointer; color: var(--accent); }
.handle.contact, .wikilink.contact { text-decoration-style: dotted; }
.kinds { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.devices .device { padding: .6rem .75rem; gap: .5rem; }
.devices .device .meta { margin-left: auto; color: var(--muted); font-size: .85rem; }
.devices .device form { margin: 0; }
.devices .device label.row { flex-direction: row; align-items: center; gap: .3rem; font-size: .9rem; color: var(--text); }
.this-device { font-size: .85rem; }

/* History (FR-160, ADR-0028): a file's versions, the line diff between two
   of them, which scrolls in its own box, one version's text, and the
   history of a task's line. Long paths wrap; nothing makes the page wider
   than a phone. */
.path, .versions .what, .versions .file, .meta-line { overflow-wrap: anywhere; }
.versions { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.versions li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; padding: .5rem .75rem; border-top: 1px solid var(--line); }
.versions li:first-child { border-top: none; }
.versions .pick { display: flex; gap: .6rem; font-size: .8rem; color: var(--muted); flex: none; }
.versions .pick label { display: inline-flex; gap: .2rem; align-items: center; }
.versions .what { flex: 1 1 14rem; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.versions .meta-line { font-size: .85rem; color: var(--muted); }
.versions .meta-line strong { color: var(--text); font-weight: 600; }
.versions .file { font-weight: 600; }
.versions .size { color: var(--muted); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.versions .acts { display: flex; gap: .3rem; margin-left: auto; flex: none; }
.versions .acts form, .version .row form { margin: 0; }
.versions code.line { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; }
.versions .gone code.line { text-decoration: line-through; color: var(--muted); }
.badge.now { background: var(--ok-bg); color: var(--text); }
.compare-form { margin-bottom: .5rem; }
.version, .compare { margin-bottom: 1.25rem; }
.version h2, .compare h2 { margin-top: 0; }
.meta-line { margin: 0 0 .5rem; }
pre.version-text { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: .5rem 0 0; max-height: 70vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-box { overflow: auto; max-height: 75vh; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.diff { border-collapse: collapse; min-width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.45; }
table.diff td { padding: 0 .45rem; white-space: pre; vertical-align: top; }
table.diff td.n { width: 1%; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; user-select: none; }
table.diff td.s { width: 1%; padding: 0 .2rem; user-select: none; }
table.diff tr.add { background: var(--ok-bg); }
table.diff tr.add td.s { color: var(--done); font-weight: 700; }
table.diff tr.del { background: var(--warn-bg); }
table.diff tr.del td.s { color: var(--warn); font-weight: 700; }
table.diff tr.skip td { background: var(--col); color: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .8rem; padding: .1rem .5rem; }
table.diff .eol { margin-left: .5rem; padding: 0 .3rem; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: .72rem; }
.conflict-copy p { margin: 0 0 .4rem; }
.conflict-copy form { margin: 0; }
.items .hist { flex: none; font-size: .85rem; }
@media (max-width: 760px) {
  .diff-box { margin: 0 -.75rem; border-radius: 0; border-left: 0; border-right: 0; }
  .versions li { padding: .5rem .6rem; }
}
