:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #14161a;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #5b5bd6;
  --on-accent: #ffffff;
  --p1: #e5484d;
  --p2: #d98a00;
  --p3: #8b93a1;
  --danger: #d93036;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04);
  --shadow-md: 0 1px 2px rgb(16 24 40 / 0.05), 0 10px 28px -8px rgb(16 24 40 / 0.14);
  --display: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e11;
    --surface: #16181d;
    --ink: #eceef2;
    --muted: #8b92a0;
    --line: #262a31;
    --accent: #7b7bf5;
    --p1: #ff6369;
    --p2: #ffb224;
    --p3: #7d8594;
    --danger: #ff6369;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 32px -10px rgb(0 0 0 / 0.65);
  }
}

/* Each note gets a hue (--h) from its id; the tint is derived from it. */
.note,
.note-window {
  --h: 90;
  --note: oklch(0.97 0.035 var(--h));
  --note-ink: oklch(0.27 0.03 var(--h));
  --note-line: oklch(0.89 0.055 var(--h));
  --note-dot: oklch(0.72 0.15 var(--h));
}

@media (prefers-color-scheme: dark) {
  .note,
  .note-window {
    --note: oklch(0.235 0.022 var(--h));
    --note-ink: oklch(0.94 0.02 var(--h));
    --note-line: oklch(0.34 0.04 var(--h));
    --note-dot: oklch(0.75 0.13 var(--h));
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  min-width: 0;
}

textarea {
  display: block;
  width: 100%;
  resize: none;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type='checkbox'] {
  appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  cursor: pointer;
}

input[type='checkbox']:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

button {
  cursor: pointer;
}

kbd {
  font: 500 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 5px;
  border: 1px solid currentColor;
  border-radius: 5px;
  opacity: 0.65;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
  font-weight: 500;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.link {
  padding: 4px 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.link:hover:not(:disabled),
.link.strong {
  color: var(--ink);
}

.link.danger:hover {
  color: var(--danger);
}

.link:disabled {
  cursor: progress;
}

select.link {
  max-width: 9.5em;
  cursor: pointer;
}

.icon {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.icon:hover {
  background: var(--line);
  color: var(--ink);
}

.count {
  margin-left: 8px;
  color: var(--muted);
  font: 500 11px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.empty {
  margin: 6px 0;
  color: var(--muted);
  font-size: 14px;
}

.empty.big {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
}

/* ---------- shell ---------- */

#nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: 148px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--line);
}

#nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 9px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

#nav a.sub {
  padding: 2px 9px 2px 20px;
  font-size: 12px;
}

#nav a:hover {
  color: var(--ink);
}

#nav a.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

#view {
  max-width: 800px;
  margin-left: 148px;
  padding: 16px 22px 64px;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.head h1 {
  margin: 0;
  font: 600 17px/1.2 var(--display);
  letter-spacing: -0.01em;
}

.head p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 7px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-weight: 500;
  animation: rise 0.2s ease-out;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast .link,
.toast .link:hover {
  flex: none;
  color: inherit;
  text-decoration: underline;
}

/* ---------- forms ---------- */

.add input {
  width: 100%;
  padding: 6px 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.title {
  flex: 1;
  padding: 4px 6px;
  border-color: transparent;
  text-overflow: ellipsis;
}

.title:hover {
  border-color: var(--line);
}

.is-done .title {
  color: var(--muted);
  text-decoration: line-through;
}

.chip {
  flex: none;
  max-width: 11em;
  overflow: hidden;
  padding: 3px 9px;
  border: 1px solid var(--c, var(--line));
  border-radius: 999px;
  color: var(--c, var(--muted));
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.due {
  background: var(--p1);
  border-color: var(--p1);
  color: #fff;
}

.editor {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 6px 0 12px 32px;
}

.editor label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.editor label > * {
  color: var(--ink);
  font-size: 12px;
  font-weight: 400;
}

.editor textarea {
  flex-basis: 100%;
  min-height: 60px;
}

.seg {
  display: flex;
  flex-basis: 100%;
  gap: 6px;
}

.seg button {
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.seg button.on {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

/* ---------- front page ---------- */

#view.week {
  max-width: none;
  padding: 16px 22px 64px;
}

.week .head {
  margin-bottom: 12px;
}

.week .head h1 {
  font-size: 17px;
}

.week .btn {
  padding: 5px 12px;
}

.progress {
  height: 4px;
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--line);
  border-radius: 2px;
}

.progress div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.week .add input {
  padding: 6px 10px;
}

.week .row {
  align-items: flex-start;
  gap: 4px;
  padding: 1px 0 1px 4px;
}

.week .row input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-top: 5px;
  border-color: var(--pc);
}

.week .row input[type='checkbox']:checked {
  background: var(--muted);
  border-color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.week textarea.title {
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.week .chip {
  margin-top: 4px;
  padding: 1px 6px;
  font-size: 10px;
}

.week .icon {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 6px;
  font-size: 12px;
}

.week .editor {
  gap: 8px 10px;
  padding: 4px 0 6px;
}

.week .editor label > *,
.week .seg button {
  padding: 4px 8px;
  font-size: 12px;
}

/* ---------- calendar ---------- */

.days-out {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.days-out input {
  width: 58px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* A group of labels, boxed and tinted so the groups read apart at a glance. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: color-mix(in srgb, var(--c, var(--muted)) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 35%, transparent);
  border-radius: 9px;
}

.cluster.ghost {
  background: none;
  border-style: dashed;
}

.cluster.block {
  padding: 3px;
}

.cluster .pname {
  margin: 0 3px 0 1px;
  color: color-mix(in srgb, var(--c) 65%, var(--ink));
}

.cluster form {
  display: flex;
}

.cluster input {
  padding: 0 6px;
  border-color: transparent;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.5;
}

.cluster input:hover,
.cluster input:focus,
.palette.editing input.pname {
  border-color: var(--line);
}

.palette.editing .ev {
  padding: 0 2px 0 0;
}

.palette.editing .ev input {
  border: 0;
}

.palette.editing input.pname {
  color: var(--ink);
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
}

.choose {
  width: min(400px, 100%);
  padding: 16px 18px 12px;
}

.choose p {
  margin: 0 0 10px;
  color: var(--muted);
}

.choice {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.choice:hover,
.choice:focus-visible {
  border-color: var(--accent);
}

.choice strong {
  display: block;
  font-weight: 600;
}

.choice span {
  color: var(--muted);
  font-size: 12px;
}

.pname {
  margin-right: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
}

/* A label: in the palette, on a day, or on a sprint commitment. */
.ev {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 1px 8px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

button.ev,
.ev.placed {
  cursor: grab;
}

.ev.armed,
.ev.done {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

.ev.block {
  --c: #6b7280;
  background: repeating-linear-gradient(135deg, #30333b 0 5px, #1c1e23 5px 10px);
  border-color: #454952;
  color: #f1f2f4;
}

.ev.block.armed {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ev.placed {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev .t {
  margin-right: 5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.ev .x {
  padding: 0 5px;
  background: none;
  border: 0;
  color: var(--muted);
}

.ev .x:hover {
  color: var(--danger);
}

.dow-row,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.dow-row {
  padding: 0 5px 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.days {
  margin-bottom: 20px;
}

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 54px;
  padding: 2px 4px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.day.past > :not(.pop) {
  opacity: 0.45;
}

.day.today {
  border-color: var(--accent);
}

/* An all-day block shades the whole day. */
.day.blocked {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ink) 13%, var(--surface)) 0 6px, var(--surface) 6px 12px);
}

.day.target {
  cursor: copy;
}

.day.over,
.day.target:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.date {
  align-self: flex-start;
  padding: 0 1px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 11px;
}

.date:hover {
  color: var(--ink);
  text-decoration: underline;
}

.today .date {
  color: var(--accent);
  font-weight: 500;
}

.dow {
  display: none;
  margin-right: 4px;
}

.pop {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 262px;
  margin-top: 3px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  cursor: default;
}

.pop.right {
  right: 0;
  left: auto;
}

.pop-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pop-row input[type='time'] {
  flex: 1;
  padding: 2px 4px;
}

.pop-row label,
.sheet-tools label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pop-row .hint {
  flex: 1;
}

/* ---------- agenda ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 14px;
  overflow: auto;
  background: rgb(0 0 0 / 0.55);
}

.agenda {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.sheet-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.sheet-tools .seg {
  flex-basis: auto;
}

.sheet-tools .seg button.on {
  --c: var(--accent);
}

.sheet-tools a.btn {
  color: inherit;
  text-decoration: none;
}

.spacer {
  flex: 1;
}

.agenda-body {
  padding: 16px 20px 18px;
}

.agenda h2 {
  margin: 0 0 10px;
  font: 600 16px/1.2 var(--display);
}

.agenda h3 {
  margin: 12px 0 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 600 10.5px/1.4 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.agenda h4 {
  margin: 6px 0 0;
  font: 600 12px/1.4 var(--display);
}

.agenda ul {
  margin: 0;
  padding-left: 18px;
}

.agenda .item {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 10px;
  padding: 1px 0;
}

.agenda .when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.agenda .item.block .what {
  font-weight: 500;
}

.agenda small {
  margin-left: 6px;
  color: var(--muted);
}

.agenda .none {
  margin: 1px 0;
  color: var(--muted);
}

@media print {
  body.has-sheet {
    --surface: #fff;
    --ink: #111;
    --muted: #555;
    --line: #ccc;
    background: #fff;
  }

  body.has-sheet #nav,
  body.has-sheet #view,
  body.has-sheet #toasts,
  .sheet-tools {
    display: none !important;
  }

  .sheet-backdrop {
    position: static;
    display: block;
    padding: 0;
    background: none;
  }

  .agenda {
    width: auto;
    border: 0;
    box-shadow: none;
  }
}

/* ---------- sprints ---------- */

.sprint-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.sprint-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.sprint-pill strong {
  color: var(--ink);
  font-weight: 500;
}

.score {
  flex: none;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.score.good,
.tally.good {
  --g: #2f9e7f;
}

.score.warn,
.tally.warn {
  --g: var(--p2);
}

.score.bad,
.tally.bad {
  --g: var(--p1);
}

.score {
  background: color-mix(in srgb, var(--g) 18%, transparent);
  color: var(--g);
}

.sprint-add,
.commit-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sprint-add {
  margin-bottom: 12px;
}

.sprint-add input[name='name'],
.commit-add input[name='text'] {
  flex: 1;
  min-width: 160px;
}

.sprint-add label,
.commit-add label,
.sprint-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.commit-add input[type='number'] {
  width: 46px;
}

.sprint-head {
  display: flex;
  align-items: center;
}

.sprint-head .title {
  margin-left: -5px;
  font-size: 14px;
  font-weight: 500;
}

.sprint-meta {
  flex-wrap: wrap;
  margin: 2px 0 6px;
}

.sprint-meta input {
  padding: 0 4px;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
}

.sprint-meta input:hover {
  border-color: var(--line);
}

.sprint-meta > :first-child {
  margin-right: auto;
  color: var(--ink);
}

.sprint.finished .progress div {
  background: var(--muted);
}

.commit {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--line);
}

.commit .what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commit.is-done .what {
  color: var(--muted);
  text-decoration: line-through;
}

.meter {
  position: relative;
  flex: none;
  width: 120px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--c);
  border-radius: 3px;
}

/* Where you should be by today. */
.meter i {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  background: var(--ink);
}

.tally {
  flex: none;
  color: var(--g, var(--muted));
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.commit .icon {
  width: 22px;
  height: 22px;
  font-size: 12px;
}

.commit-add {
  margin: 6px 0 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.finished summary {
  margin-bottom: 8px;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- notes ---------- */

/* On the front page the notes sit under the calendar. */
#notes {
  margin-top: 32px;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  align-items: start;
  gap: 10px;
}

.note {
  position: relative;
  padding: 10px 12px 6px;
  background: var(--note);
  color: var(--note-ink);
  border: 1px solid var(--note-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.note:hover {
  transform: translateY(-2px);
}

.note.floating {
  border-style: dashed;
  border-color: var(--note-dot);
}

.note.snapped {
  animation: snap 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.note textarea,
.note-window textarea {
  min-height: 80px;
  padding: 0;
  border: 0;
  outline: 0;
  color: inherit;
  line-height: 1.4;
}

/* Formatted (Markdown) note text */

.md {
  min-height: 80px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  cursor: text;
}

#rendered {
  flex: 1;
  overflow: auto;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p,
.md ul,
.md ol,
.md pre,
.md blockquote {
  margin: 0 0 0.6em;
}

.md h3,
.md h4,
.md h5 {
  margin: 0.8em 0 0.3em;
  font: 600 1.2em/1.25 var(--display);
  letter-spacing: -0.01em;
}

.md h4 {
  font-size: 1.08em;
}

.md h5 {
  font-size: 1em;
}

.md ul,
.md ol {
  padding-left: 1.25em;
}

.md li > ul,
.md li > ol {
  margin: 0.15em 0 0;
}

.md li {
  margin: 0.15em 0;
}

.md li::marker {
  color: var(--note-dot);
}

.md li.check {
  display: flex;
  gap: 7px;
  margin-left: -1.25em;
  list-style: none;
}

.md li.check input {
  width: 15px;
  height: 15px;
  margin-top: 0.2em;
  border-color: var(--note-dot);
  border-radius: 4px;
}

.md li.check input:checked {
  background: var(--note-dot);
  border-color: var(--note-dot);
  box-shadow: inset 0 0 0 2px var(--note);
}

.md li.checked span {
  opacity: 0.55;
  text-decoration: line-through;
}

.md a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--note-dot);
  text-underline-offset: 2px;
}

.md code,
.md pre {
  background: var(--note-line);
  border-radius: 5px;
  font: 0.88em ui-monospace, SFMono-Regular, Menlo, monospace;
}

.md code {
  padding: 1px 5px;
}

.md pre {
  padding: 8px 10px;
  overflow-x: auto;
}

.md pre code {
  padding: 0;
  background: none;
  font-size: 1em;
}

.md blockquote {
  padding-left: 10px;
  border-left: 3px solid var(--note-dot);
  opacity: 0.85;
}

.md hr {
  margin: 0.8em 0;
  border: 0;
  border-top: 1px solid var(--note-line);
}

.note footer,
.note-window footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--note-line);
}

.note .link,
.note-window .link {
  border: 0;
  padding: 4px 0;
  color: inherit;
  font-size: 12px;
  opacity: 0.65;
}

.note .link:hover:not(:disabled),
.note-window .link:hover:not(:disabled),
.note-window .link.strong {
  color: inherit;
  opacity: 1;
}

.badge {
  position: absolute;
  top: -9px;
  right: 10px;
  padding: 2px 8px;
  background: var(--note-dot);
  color: oklch(0.2 0.03 var(--h));
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.note-window {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 14px 14px 8px;
  background: var(--note);
  color: var(--note-ink);
}

.note-window textarea {
  flex: 1;
  overflow: auto;
}

.note-window footer {
  flex-wrap: nowrap;
}

.note-window #status {
  flex: 1;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.closed {
  margin: auto;
  text-align: center;
}

/* ---------- settings ---------- */

.panel {
  margin-bottom: 10px;
  padding: 12px 14px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0 0 8px;
  font: 600 13px/1.2 var(--display);
}

.panel p {
  margin: 0 0 10px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-weight: 500;
}

.field small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.field textarea {
  min-height: 72px;
}

code {
  padding: 3px 7px;
  background: var(--bg);
  border-radius: 6px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.keys {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}

.keys dd {
  margin: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes snap {
  from {
    opacity: 0;
    transform: translateY(-40px) rotate(-4deg) scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}

/* ---------- phone ---------- */

@media (max-width: 760px) {
  #nav {
    inset: auto 0 0 0;
    z-index: 5;
    width: auto;
    flex-direction: row;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  #nav a {
    flex: 1;
    justify-content: center;
    padding: 8px 4px;
    font-size: 12px;
  }

  #nav a.sub {
    display: none;
  }

  #nav .count {
    margin-left: 5px;
  }

  #view {
    margin-left: 0;
    padding: calc(20px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
  }

  .head h1 {
    font-size: 17px;
  }

  #toasts {
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .editor {
    padding-left: 0;
  }

  .dow-row {
    display: none;
  }

  .days {
    grid-template-columns: 1fr;
  }

  .day {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    min-height: 26px;
    padding: 2px 6px;
  }

  .day .ev.placed {
    display: inline-block;
  }

  .date {
    width: 62px;
    text-align: left;
  }

  .dow {
    display: inline;
  }

  .palette .hint {
    flex-basis: 100%;
  }

  .meter {
    display: none;
  }

  .commit {
    flex-wrap: wrap;
  }

  #view.week {
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom));
  }

  .panel {
    padding: 16px 14px 10px;
  }
}

/* ---------- sign-in ---------- */

body.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 16px;
}

.login form {
  display: grid;
  gap: 10px;
  width: min(280px, 100%);
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.login h1 {
  margin: 0 0 4px;
  font: 600 16px var(--display);
}

.login input {
  padding: 8px 10px;
  font: inherit;
  font-size: 16px; /* below 16px, iOS zooms the page on focus */
}

.login .btn {
  justify-content: center;
  padding: 8px 10px;
}

.login .error {
  margin: 0;
  color: var(--danger);
}
