.bs {
  --paper: #dcdcda;
  --ink: #141414;
  --mid: #4b4b4b;
  --faint: #8c8c8c;
  --edge: 28px; /* left margin of the page */
  --gutter: 40px; /* right margin, where the scrollbar runs */
  position: relative;
  width: 540px;
  height: 540px;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
  color: var(--ink);
  font-family: "Literata Variable", serif;
  font-size: 19px;
  font-feature-settings: "lnum", "tnum";
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

.bs *,
.bs *::before,
.bs *::after {
  box-sizing: border-box;
}

/* the grain of the panel, over everything it shows */
.bs::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background: url("./grain.png") 0 0 / 256px 256px;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.sm-area {
  position: relative;
  width: 540px;
  height: 540px;
}

.sm-view {
  width: 100%;
  height: 100%;
  outline: 0;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scroll-padding-top: 38px;
}

/* focus: the page is framed in ink */
.sm-area:has(.sm-view:focus-visible)::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  border: 3px solid var(--ink);
  pointer-events: none;
}

/* the foot of the page leaves room for the last day to rest whole under its heading */
.sm-page {
  padding: 0 var(--gutter) 50px var(--edge);
}

.sm-page p,
.sm-page h1,
.sm-page h2,
.sm-page ol {
  margin: 0;
  padding: 0;
  font-weight: 400;
  list-style: none;
}

/* the title of the statement, which scrolls away like a title page */
.sm-title {
  padding: 30px 0 22px;
  scroll-snap-align: start;
  scroll-margin-top: 38px;
}

.sm-bank,
.sm-head {
  font-size: 13px;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.09em;
  line-height: 16px;
}

.sm-bank {
  font-size: 14px;
}

.sm-title > h1 {
  margin: 14px 0 12px -2px;
  font-size: 60px;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 60px;
}

.sm-account {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 19px;
  line-height: 26px;
}

.sm-account i {
  margin-right: 6px;
  font-size: 15px;
  color: var(--mid);
}

.sm-account > span:last-child {
  font-weight: 600;
}

/* each day's heading stays at the head of the page while its entries pass under it */
.sm-head {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 38px;
  padding-bottom: 7px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.sm-head > span:last-child {
  font-weight: 400;
  color: var(--mid);
}

.sm-line {
  display: grid;
  grid-template-columns: 1fr 104px 112px;
  align-items: baseline;
  height: 52px;
  padding-top: 7px;
  scroll-snap-align: start;
  border-bottom: 1px solid var(--faint);
  line-height: 22px;
  white-space: nowrap;
}

.sm-line:last-child {
  border-bottom: 0;
}

.sm-payee {
  font-weight: 500;
}

.sm-amount,
.sm-balance {
  justify-self: end;
}

.sm-amount {
  font-weight: 500;
}

[data-in] > .sm-amount {
  font-weight: 700;
}

.sm-balance {
  color: var(--mid);
}

.sm-kind {
  grid-column: 1 / -1;
  font-size: 14px;
  font-style: italic;
  line-height: 18px;
  color: var(--mid);
}

.sm-forward {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  height: 64px;
  padding-top: 14px;
  border-top: 2px solid var(--ink);
  font-style: italic;
  line-height: 22px;
}

.sm-forward > span:last-child {
  font-style: normal;
  color: var(--mid);
}

/* a full refresh, after a jump of a page or more: the page turns to its negative and clears,
   then the page before shows through for a moment and is gone */
.sm-refresh {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.sm-flash {
  position: absolute;
  inset: 0;
  animation: sm-flash 0.18s step-end forwards;
}

@keyframes sm-flash {
  0% {
    backdrop-filter: invert(1);
    background: #0000;
  }
  60% {
    backdrop-filter: none;
    background: #e6e6e4;
  }
  100% {
    background: #0000;
    visibility: hidden;
  }
}

.sm-ghost {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: sm-after 0.8s linear forwards;
}

@keyframes sm-after {
  0%,
  22% {
    opacity: 0;
  }
  22.5% {
    opacity: 0.12;
    animation-timing-function: cubic-bezier(0.25, 0, 0.6, 1);
  }
  100% {
    opacity: 0;
  }
}

.sm-ghost .sm-page {
  padding-bottom: 0;
}

.sm-ghost .sm-head {
  position: static;
  background: none;
}

.sm-ghost * {
  color: var(--ink) !important;
}

@media (prefers-reduced-motion: reduce) {
  .sm-refresh {
    display: none;
  }
}

/* the scrollbar: a rail of half-tone down the margin, and a bar of solid ink on it */
.sm-bar {
  z-index: 3;
  width: 20px;
  margin: 14px 10px 14px 0;
  padding: 0 6px;
  background: repeating-conic-gradient(var(--ink) 0 25%, #0000 0 50%) 0 0 / 2px 2px content-box;
}

.sm-thumb {
  width: 20px;
  margin-left: -6px;
  background: linear-gradient(var(--ink), var(--ink)) 50% 0 / 8px 100% no-repeat;
  cursor: grab;
}

.sm-thumb:hover,
.sm-thumb[data-dragging] {
  background-size: 14px 100%;
}

.sm-thumb[data-dragging] {
  cursor: grabbing;
}
