@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument';
  src: url('/fonts/instrument-italic.woff2') format('woff2');
  font-style: italic;
  font-display: swap;
}

/* Two colours, nothing else. The themes swap which one is paper and which is ink. */
:root {
  --cream: #f4ecd8;
  --navy: #0e1b3d;
  --paper: var(--cream);
  --ink: var(--navy);
  --flip-paper: var(--navy);
  --flip-ink: var(--cream);
  --flip-scheme: dark;
  --sans: 'Bricolage', ui-sans-serif, system-ui, sans-serif;
  --serif: 'Instrument', ui-serif, Georgia, serif;
  --rule: 1.5px solid var(--ink);
  --gutter: clamp(16px, 4vw, 56px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: var(--navy);
    --ink: var(--cream);
    --flip-paper: var(--cream);
    --flip-ink: var(--navy);
    --flip-scheme: light;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: var(--navy);
  --ink: var(--cream);
  --flip-paper: var(--cream);
  --flip-ink: var(--navy);
  --flip-scheme: light;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.4 var(--sans);
  --muted: color-mix(in srgb, var(--ink) 72%, var(--paper));
}
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2.5px solid currentColor; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A block printed the other way round. --rule has to be restated because it
   was resolved against the page's ink at :root. */
.invert {
  --paper: var(--flip-paper);
  --ink: var(--flip-ink);
  --rule: 1.5px solid var(--ink);
  color-scheme: var(--flip-scheme);
  --muted: color-mix(in srgb, var(--ink) 72%, var(--paper));
  background: var(--paper);
  color: var(--ink);
}
.invert .flip {
  --paper: var(--flip-ink);
  --ink: var(--flip-paper);
  --muted: color-mix(in srgb, var(--ink) 72%, var(--paper));
  background: var(--paper);
  color: var(--ink);
}

.page { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---- Top bar ---------------------------------------------------------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--gutter);
  border-bottom: var(--rule);
}
.mark {
  font-weight: 800; font-size: 19px; letter-spacing: -.03em; text-decoration: none;
  display: inline-flex; align-items: center; gap: 9px;
}
.mark::before {
  content: ''; width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 72% 50%, transparent 58%, var(--ink) 60%);
}
.top nav { display: flex; gap: 20px; font-size: 15px; }
.textbtn {
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px;
  min-height: 28px;
}
.textbtn:hover { text-decoration-thickness: 3px; }

/* ---- Board: an off-balance split, the panel running past the fold ------ */
.board { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); flex: 1 0 auto; }
.day { padding: clamp(20px, 3vw, 40px) var(--gutter) 56px; min-width: 0; }

.dayhead { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; column-gap: clamp(14px, 2vw, 28px); }
.numeral {
  font-weight: 800;
  font-size: clamp(120px, 21vw, 300px);
  line-height: .78;
  letter-spacing: -.07em;
  margin-left: -.04em;
  font-variant-numeric: tabular-nums;
}
.dayhead h1 {
  font: italic 400 clamp(28px, 4vw, 56px)/1 var(--serif);
  letter-spacing: -.01em;
  padding-bottom: .1em;
}
.dayhead .eyebrow { font-weight: 700; font-size: 15px; margin-bottom: 8px; display: block; }
.daynav { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.square {
  width: 44px; height: 44px; border: var(--rule);
  display: inline-grid; place-items: center; font-size: 20px; line-height: 1;
}
.square:hover { background: var(--ink); color: var(--paper); }
.daynav .textbtn { margin-left: 8px; }
.tally { margin-left: auto; font-size: 15px; font-variant-numeric: tabular-nums; }

/* Forms */
.add { display: flex; gap: 8px; margin-top: 28px; flex-wrap: wrap; align-items: stretch; }
.field, .add select {
  min-height: 48px; padding: 0 12px;
  background: transparent; border: var(--rule); border-radius: 0; min-width: 0;
}
.add .grow { flex: 1 1 240px; }
.add select { flex: 0 1 200px; }
.field::placeholder { color: var(--muted); opacity: 1; }
.go {
  min-height: 48px; padding: 0 20px; font-weight: 700;
  background: var(--ink); color: var(--paper); border: var(--rule);
}
.go:hover { background: transparent; color: var(--ink); }

/* Rows */
.rows { margin-top: 24px; border-top: var(--rule); }
.row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center;
  gap: 8px; padding: 6px 0; min-height: 60px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, var(--paper));
}
.tick { position: relative; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.tick input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.tick span { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%; display: block; transition: background-color .12s; }
.tick input:checked + span { background: var(--ink); box-shadow: inset 0 0 0 4px var(--paper); }
.tick:hover span { background: color-mix(in srgb, var(--ink) 18%, var(--paper)); }
.tick input:checked:hover + span { background: var(--ink); }
.tick input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 3px; }
.rowbody { min-width: 0; overflow-wrap: anywhere; }
.rowtitle { font-size: 19px; font-weight: 500; line-height: 1.25; }
.isdone .rowtitle { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }
.meta { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; }
.meta a { text-underline-offset: 2px; }
.flagged {
  font-size: 12.5px; font-weight: 700; padding: 0 6px; background: var(--ink); color: var(--paper);
}
.actions { display: flex; gap: 14px; font-size: 14px; }

.empty { padding: 28px 0; font: italic 400 24px/1.2 var(--serif); border-bottom: var(--rule); }

/* ---- Deadlines panel --------------------------------------------------- */
.deadlines { padding: clamp(20px, 3vw, 40px) var(--gutter) 40px clamp(20px, 3vw, 40px); min-width: 0; }
.panelhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h2.big {
  font-weight: 800; font-size: clamp(38px, 5vw, 68px); line-height: .95; letter-spacing: -.045em;
}
.deadlines .add { margin-top: 20px; }
.deadlines .add .grow { flex-basis: 100%; }
.deadlines .add .when { flex: 1 1 130px; }
.deadlines .add .go { flex: 1 1 80px; }

.countdown {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 40%, var(--paper));
}
.countdown:first-child { border-top: var(--rule); }
.countdown.flip { padding-left: 12px; padding-right: 12px; margin: 0 -12px; border-bottom-color: transparent; }
.left { display: flex; flex-direction: column; line-height: 1; }
.left b { font-weight: 800; font-size: 46px; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.left small { font-size: 12.5px; margin-top: 4px; }
.countdown .ctrl { display: flex; align-items: center; gap: 8px; }
.countdown .tick { width: 36px; height: 36px; }
.deadlines .empty { border-color: var(--ink); }
details.past { margin-top: 20px; font-size: 15px; }
details.past summary { cursor: pointer; min-height: 32px; }
details.past li { padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; }
details.past li span { text-decoration: line-through; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }

/* ---- Horizons: long-term goals as an index ----------------------------- */
.horizons { border-top: var(--rule); padding: clamp(28px, 4vw, 56px) var(--gutter) 72px; }
.horizons .panelhead { margin-bottom: 28px; flex-wrap: wrap; }
.horizon {
  display: grid; grid-template-columns: 56px minmax(0, 5fr) minmax(0, 7fr); gap: 8px clamp(16px, 3vw, 40px);
  padding: 22px 0; border-top: var(--rule);
}
.horizon:last-child { border-bottom: var(--rule); }
.index { font: italic 400 30px/1 var(--serif); }
.longtitle { font-weight: 700; font-size: clamp(25px, 3.2vw, 42px); line-height: 1.04; letter-spacing: -.03em; overflow-wrap: anywhere; }
.isachieved .longtitle, .mid.isachieved .midname { text-decoration: line-through; text-decoration-thickness: 2px; }
.horizon .actions { margin-top: 10px; }
.mid {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px auto; align-items: center; gap: 14px;
  padding: 11px 0; text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, var(--paper));
}
.mid:first-child { padding-top: 2px; }
.midname { font-size: 19px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.mid:hover .midname { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.count { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }
.nomids { font: italic 400 21px/1.2 var(--serif); color: var(--muted); padding-bottom: 8px; }

/* Solid = done, hatched = not done, empty = still planned. */
.bar { display: flex; height: 10px; border: 1.5px solid var(--ink); }
.bar i { display: block; height: 100%; }
.bar .d { background: var(--ink); }
.bar .m { background: repeating-linear-gradient(135deg, var(--ink) 0 1.5px, transparent 1.5px 4px); }

/* ---- Goal page --------------------------------------------------------- */
.goalpage { padding: clamp(24px, 4vw, 48px) var(--gutter) 72px; flex: 1 0 auto; }
.goalhead { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 24px clamp(24px, 4vw, 64px); align-items: end; }
.crumb { font: italic 400 24px/1.2 var(--serif); margin-bottom: 10px; display: block; overflow-wrap: anywhere; }
.goalhead h1 { font-weight: 800; font-size: clamp(42px, 8vw, 110px); line-height: .92; letter-spacing: -.05em; overflow-wrap: anywhere; }
.goalpage .bar { height: 16px; margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats b { display: block; font-weight: 800; font-size: clamp(38px, 5vw, 60px); line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stats span { font-size: 14px; }
.goaltools { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.filters { display: flex; flex-wrap: wrap; margin-top: 32px; }
.filters button { min-height: 44px; padding: 0 14px; border: var(--rule); margin-right: -1.5px; font-size: 15px; }
.filters button[aria-pressed='true'] { background: var(--ink); color: var(--paper); font-weight: 700; }
.dategroup { margin-top: 28px; }
.dategroup h3 { font: italic 400 25px/1.1 var(--serif); margin-bottom: 8px; }
.dategroup .rows { margin-top: 0; }

/* ---- Sign in ----------------------------------------------------------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.login .word {
  display: flex; align-items: flex-end; padding: var(--gutter); overflow: hidden;
  font-weight: 800; font-size: clamp(72px, 13.5vw, 230px); line-height: .8; letter-spacing: -.07em;
}
.login form { display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; padding: var(--gutter); }
.login p { font: italic 400 30px/1.1 var(--serif); margin-bottom: 12px; }
.login .error { font-size: 15px; min-height: 22px; font-weight: 600; }

/* ---- Dialog ------------------------------------------------------------ */
dialog {
  width: min(480px, calc(100vw - 32px)); padding: 24px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
}
dialog::backdrop { background: color-mix(in srgb, var(--flip-paper) 50%, transparent); }
dialog h2 { font-weight: 800; font-size: 32px; line-height: 1; letter-spacing: -.04em; margin-bottom: 18px; }
dialog label.stack { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
dialog .field { width: 100%; display: block; margin-top: 4px; font-weight: 400; font-size: 17px; }
dialog label.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 32px; }
dialog label.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--ink); }
.dialogactions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.dialogactions .spacer { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px; font-weight: 600;
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--paper);
  visibility: hidden; z-index: 10;
}
#toast.show { visibility: visible; }

/* ---- Small screens ----------------------------------------------------- */
@media (max-width: 900px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .deadlines { padding-left: var(--gutter); }
  .horizon { grid-template-columns: 40px minmax(0, 1fr); }
  .horizon .mids { grid-column: 2; margin-top: 8px; }
  .goalhead { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); align-content: end; }
  .login .word { padding-bottom: 0; }
}
@media (max-width: 480px) {
  .numeral { font-size: 118px; }
  .add select { flex: 1 1 100%; }
  .add .go { flex: 1 1 100%; }
  .mid { grid-template-columns: minmax(0, 1fr) 52px auto; gap: 10px; }
  .countdown { grid-template-columns: 66px minmax(0, 1fr) auto; }
  .deadlines .add input[type='date'] { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
