@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2-variations"), url("/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

/* Colours sampled from the reference notepad. */
:root {
  --paper: #f1e4ba;
  --band: #f0d8ac;
  --red: #e33b0c;
  --ink: #2b2118;
  --ink-soft: rgb(43 33 24 / 0.42);
  --shadow: 120 55 15;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: "Archivo", system-ui, sans-serif;
  font-stretch: 100%;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Paper grain over everything. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .38 0 0 0 0 .2 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
[contenteditable]:focus-visible { outline: none; }

.wide, .heading, .fb-title, .fb-avatar, .count, .stamp, .field-label, .menu button, .sheet h2, .toast button, .by {
  font-stretch: 125%;
  font-weight: 900;
  text-transform: uppercase;
}

/* ---- The pad ---------------------------------------------------------- */

/* All pad measurements are in cqi (1% of pad width) so the layout keeps the
   reference proportions (450px wide pad) at every screen size. */
.pad {
  container-type: inline-size;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
  --row: clamp(46px, 11.6cqi, 60px);
  --box: clamp(13px, 3.2cqi, 17px);
  --rule: max(1px, 0.24cqi);
  --left: 12.4cqi;
  --right: 12.2cqi;
}

.heading {
  margin: 0;
  padding: calc(6.6cqi + env(safe-area-inset-top)) 6.2cqi 0;
  color: var(--red);
  font-size: 19.5cqi; /* refined by fitHeading() in app.js */
  line-height: 0.9;
  white-space: nowrap;
  outline: none;
  caret-color: var(--red);
}
.heading.wrap { white-space: normal; overflow-wrap: anywhere; }
.heading[contenteditable] { cursor: text; }
.heading[contenteditable]:focus { background: rgb(240 216 172 / 0.55); border-radius: 4px; }
.heading-probe {
  position: absolute;
  left: -9999px;
  top: 0;
  visibility: hidden;
  white-space: pre;
  font-size: 100px;
  font-stretch: 125%;
  font-weight: 900;
}

.lines {
  list-style: none;
  margin: 4cqi 0 0;
  padding: 0 var(--right) 0 var(--left);
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 3.6cqi;
  min-height: var(--row);
}

.box {
  position: relative;
  flex: none;
  width: var(--box);
  height: var(--box);
  margin: 0 0 1px;
  padding: 0;
  border: var(--rule) solid var(--red);
  background: transparent;
}
button.box::before { content: ""; position: absolute; inset: -14px; } /* bigger tap target */
.box.ticked::after, .box[aria-checked="true"]::after {
  content: "";
  position: absolute;
  left: -15%;
  top: -55%;
  width: 150%;
  height: 150%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 13.5c2.2 1.4 3.9 3.4 5.2 6.2C11 12.6 15.6 6.4 22 2.2' fill='none' stroke='%23e33b0c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.line {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: stretch;
  padding: 0;
  border: 0;
  border-bottom: var(--rule) solid var(--red);
  background: none;
  text-align: left;
}

.text {
  flex: 1;
  min-width: 0;
  padding-top: 10px;
  font-size: clamp(17px, 3.4cqi, 19px);
  line-height: 1.3;
  font-weight: 450;
  overflow-wrap: anywhere;
  outline: none;
  caret-color: var(--red);
}
.text:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-soft);
  pointer-events: none;
}
.row.done .text {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 1.5px;
}
.row.blank { cursor: text; }

.by {
  flex: none;
  font-size: 11px;
  color: var(--red);
  opacity: 0.75;
  padding-bottom: 2px;
}

.acts { display: none; flex: none; gap: 2px; margin: 0 -6px 0 0; }
.row:focus-within .acts { display: flex; }
@media (hover: hover) { .row:hover .acts { display: flex; } }
.act {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--red);
  display: grid;
  place-items: center;
}
.act:hover { background: rgb(227 59 12 / 0.1); }
.act svg { width: 18px; height: 18px; }

/* Tasks list rows */
.task .line { cursor: pointer; color: var(--ink); }
.task .line:hover .text { color: var(--red); }
.count { flex: none; font-size: 12px; color: var(--red); letter-spacing: 0.04em; padding-bottom: 2px; }
.chev { flex: none; width: 16px; height: 16px; color: var(--red); margin-bottom: 2px; }

.mark { display: flex; justify-content: center; padding-top: 9cqi; color: var(--red); }
.mark svg { width: clamp(30px, 8.5cqi, 44px); height: auto; }

/* ---- Screens & sliding track ------------------------------------------- */

/* clip (not hidden) so focusing something off-screen can never scroll the track sideways */
#app { position: fixed; inset: 0; overflow: clip; }
.track {
  display: flex;
  width: 200%;
  height: 100%;
  transition: transform 0.38s var(--ease);
}
.track.to-todo { transform: translateX(-50%); }
.track.instant { transition: none; }
.panel { position: relative; width: 50%; height: 100%; overflow: clip; }
.scroller {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(227 59 12 / 0.35) transparent;
}
@media (prefers-reduced-motion: reduce) { .track { transition: none; } }

#login { min-height: 100%; }

/* ---- Floating bar ------------------------------------------------------ */

.floatbar {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 5;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: min(calc(100% - 28px), 520px);
  padding: 5px;
  border-radius: 999px;
  background: var(--band);
  box-shadow: 0 12px 30px -12px rgb(var(--shadow) / 0.5), 0 2px 6px -2px rgb(var(--shadow) / 0.25);
}
.fb-btn, .fb-avatar {
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  color: var(--red);
  display: grid;
  place-items: center;
}
.fb-btn svg { width: 22px; height: 22px; }
.fb-avatar { font-size: 17px; }
.fb-title {
  min-width: 0;
  padding: 0 12px;
  color: var(--red);
  font-size: 15px;
  letter-spacing: 0.01em;
  line-height: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  caret-color: var(--red);
}
.fb-title[contenteditable] { cursor: text; }
.fb-title:focus { text-overflow: clip; }

.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 6px;
  border-radius: 16px;
  background: var(--paper);
  border: 1.5px solid var(--red);
  box-shadow: 0 16px 34px -14px rgb(var(--shadow) / 0.55);
}
.menu button {
  display: block;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--red);
  font-size: 13px;
  letter-spacing: 0.03em;
  text-align: left;
  white-space: nowrap;
}
.menu button:hover, .menu button:focus-visible { background: var(--band); outline: none; }
.menu button.danger { color: var(--ink); }

/* ---- Forms (sign in, dialogs) ----------------------------------------- */

.form { padding: 7cqi var(--right) 0 var(--left); display: grid; gap: 22px; }
.field { display: grid; gap: 2px; }
.field-label { font-size: 11px; letter-spacing: 0.06em; color: var(--red); }
.field input {
  width: 100%;
  padding: 10px 0 6px;
  border: 0;
  border-bottom: var(--rule, 1px) solid var(--red);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  outline: none;
  caret-color: var(--red);
}
.field input:focus { border-bottom-width: 2px; padding-bottom: 5px; }
.form-error { margin: -6px 0 0; min-height: 1.3em; color: var(--red); font-size: 14px; font-weight: 600; }
.stamp {
  justify-self: start;
  padding: 13px 26px 12px;
  border: 2px solid var(--red);
  border-radius: 2px;
  background: transparent;
  color: var(--red);
  font-size: 15px;
  letter-spacing: 0.06em;
  transition: background 0.15s, color 0.15s;
}
.stamp:hover, .stamp:active { background: var(--red); color: var(--paper); }
.stamp:disabled { opacity: 0.5; pointer-events: none; }
.stamp.danger { border-color: var(--ink); color: var(--ink); }
.stamp.danger:hover { background: var(--ink); color: var(--paper); }

.sheet {
  width: min(calc(100vw - 32px), 440px);
  max-height: calc(100dvh - 48px);
  padding: 26px 24px 24px;
  border: 0;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 60px -20px rgb(var(--shadow) / 0.6);
}
.sheet::backdrop { background: rgb(43 33 24 / 0.32); }
.sheet h2 { margin: 0 0 6px; color: var(--red); font-size: 30px; line-height: 0.95; }
.sheet p { margin: 0; line-height: 1.45; }
.sheet .form { padding: 18px 0 0; gap: 18px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.sheet .ghost { border-color: transparent; }
.user-card { padding: 16px 0 0; display: grid; gap: 10px; }
.user-card .form-error { margin: 0; }
.user-card strong { font-stretch: 125%; font-weight: 900; text-transform: uppercase; color: var(--red); }
.user-card .meta { font-size: 14px; color: var(--ink-soft); }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 1; }
.inline-form .stamp { padding: 10px 16px 9px; font-size: 13px; }

/* ---- Toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 28px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  box-shadow: 0 12px 30px -12px rgb(0 0 0 / 0.5);
  transform: translate(-50%, calc(-100% - 40px));
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0s 0.3s;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform 0.3s var(--ease); }
.toast button { border: 0; background: none; color: #ff8a5c; font-size: 13px; letter-spacing: 0.04em; padding: 4px; }
