/* cuento's look: paper and ink, a bookbinder's red, Fraunces for the
 * books and Instrument Sans for the rest. A phone first: one column, big
 * targets. From 960px wide, a side column (adding, the shelves, the
 * count) stays in view beside a grid of books that grows with the
 * screen. Light and dark follow the system. */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-full-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-ext-full-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --paper: #f7f2e8;
  --paper-2: #efe7d8; /* the side column, a shade deeper */
  --card: #fffdf8;
  --ink: #2a241d;
  --muted: #7b7063;
  --line: #e4dac8;
  --accent: #b5532c; /* a bookbinder's red */
  --accent-ink: #fff8f0; /* text on the accent */
  --accent-soft: #f6e2d6;
  --bad: #a3301f;
  --star: #d9a21b;
  --shadow: 0 1px 2px #3a2a1a14, 0 8px 24px #3a2a1a12;
  --radius: 16px;
  --spring: cubic-bezier(0.3, 1.4, 0.5, 1); /* overshoots a little, then settles */
  --glide: cubic-bezier(0.2, 0.8, 0.2, 1);
  --serif: 'Fraunces', ui-serif, Georgia, serif;
  --sans: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171410;
    --paper-2: #1e1a15;
    --card: #241f19;
    --ink: #f1e9dc;
    --muted: #a99c8a;
    --line: #3a3229;
    --accent: #e68a5f;
    --accent-ink: #20140d;
    --accent-soft: #3d281d;
    --bad: #f39282;
    --star: #f2c14e;
    --shadow: 0 1px 2px #0006, 0 8px 24px #0004;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
textarea,
.button {
  font: inherit;
  color: inherit;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-weight: 550;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}
button:active,
.button:active {
  transform: scale(0.97);
}
input,
textarea {
  min-height: 48px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px; /* 16px or more: iPhone Safari does not zoom in on focus */
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- the layout: stacked on a phone, side column and grid when wide ---- */

.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 2400px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.side {
  display: contents; /* on a phone its parts join the column */
}
.main {
  order: 1;
}
@media (min-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
    gap: 32px;
    padding-top: 28px;
  }
  .side {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 24px;
    border-radius: 24px;
    background: var(--paper-2);
  }
  .filters {
    flex-wrap: wrap;
  }
  .side .add form {
    flex-direction: column; /* the column is narrow: field above button, both full width */
  }
  .side .add input {
    flex: none;
  }
}
@media (min-width: 1600px) {
  .layout {
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 40px;
  }
}

/* ---- settings: a gear in the top bar opens a sheet ---- */

.gear {
  margin-left: auto;
  width: 44px;
  padding: 0;
  border-color: transparent;
  background: none;
  color: var(--muted);
}
.gear svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.6s var(--spring);
}
.gear:hover svg {
  transform: rotate(60deg);
}
/* The sheet rises from the bottom on a phone, and is a centred card when
   there is room; the page behind dims. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  align-items: end;
  justify-items: center;
  background: #0006;
  animation: dim 0.3s ease both;
}
@keyframes dim {
  from {
    background: #0000;
  }
}
.settings {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 8px 20px max(24px, env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  box-shadow: 0 -8px 40px #0004;
  animation: sheet-up 0.45s var(--glide) both;
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@media (min-width: 640px) {
  .sheet {
    align-items: center;
  }
  .settings {
    border-radius: 24px;
    padding-bottom: 24px;
    animation: rise 0.4s var(--spring) both;
  }
}
.settings header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  padding: 12px 0;
  background: var(--paper);
}
.settings h2 {
  margin: 0;
  font: 650 26px/1 var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1;
}
.done {
  margin-left: auto;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.settings section {
  display: grid;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.settings h3 {
  margin: 0;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings section > button {
  justify-self: start;
}
.settings a {
  color: var(--accent);
}
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* The bar saying a new version is ready: it slides up from the bottom. */
.toast {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 10px 30px #0004;
  transform: translateX(-50%);
  animation: toast-up 0.5s var(--spring) both;
}
@keyframes toast-up {
  from {
    opacity: 0;
    transform: translate(-50%, 120%);
  }
}
.toast button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---- the hero: Tilde, the name, the count ---- */

.hero {
  display: grid;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img {
  width: 44px;
  height: 44px;
}
h1 {
  margin: 0;
  font: 650 30px/1 var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1;
  letter-spacing: -0.02em;
}
.count {
  margin: 14px 0 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.count .big {
  font: 600 64px/0.9 var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 144;
  color: var(--accent);
  font-variant-numeric: lining-nums;
  display: inline-block;
  animation: tick 0.6s var(--spring) both; /* each new count ticks in */
}
@keyframes tick {
  from {
    opacity: 0;
    transform: translateY(40%) scale(0.7);
  }
}
.count .what {
  font: 500 19px/1.2 var(--serif);
  font-variation-settings: 'SOFT' 50;
}
/* The goal: a thin bar that fills as books are finished. */
.goal {
  height: 8px;
  margin: 10px 0 2px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}
.goal span {
  display: block;
  height: 100%;
  width: calc(var(--done) * 100%);
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--accent),
    color-mix(in srgb, var(--accent) 70%, var(--star))
  );
  transition: width 0.8s var(--spring);
  animation: fill 1.2s var(--glide) both;
}
@keyframes fill {
  from {
    width: 0;
  }
}
/* The way into a year's review: a gold-edged pill. */
.review-button {
  justify-self: start;
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--star) 60%, transparent);
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    var(--card),
    color-mix(in srgb, var(--star) 14%, var(--card))
  );
  font-family: var(--serif);
  font-weight: 600;
}
.review-button span {
  transition: transform 0.25s var(--spring);
}
.review-button:hover span {
  transform: translateX(3px);
}
.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---- adding a book ---- */

.add form,
.by-hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.add input {
  flex: 1 1 120px;
  letter-spacing: 0.02em;
}
.add form > button,
.by-hand > button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.add form > button:hover,
.by-hand > button:hover {
  filter: brightness(1.05);
}
/* Scan sits between the field and Add, in the card's colours; on a
   phone it is just its icon. */
.add form > .scan {
  order: 1;
  padding: 0 14px;
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
.add form > button:not(.scan) {
  order: 2;
}
@media (max-width: 480px) {
  .scan .label {
    display: none;
  }
}
.scan svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The camera sheet: the camera fills the screen; a frame to aim the
   barcode into, with a sweeping line; what to do, and Cancel. */
.scanner {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #000;
  color: #fff;
  animation: sheet 0.35s var(--glide) both;
}
@keyframes sheet {
  from {
    opacity: 0;
    transform: scale(1.04);
  }
}
.scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.aim {
  position: relative;
  width: min(80vw, 420px);
  aspect-ratio: 2 / 1;
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax #0008; /* darkens all but the frame */
  outline: 3px solid #fff;
  overflow: hidden;
}
.laser {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px 2px var(--accent);
  animation: sweep 1.8s ease-in-out infinite alternate;
}
@keyframes sweep {
  from {
    top: 12%;
  }
  to {
    top: 88%;
  }
}
.tell {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  margin: 0;
  text-align: center;
  font: 600 18px/1.3 var(--sans);
  text-shadow: 0 1px 6px #000;
}
.scanner .close {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  min-width: 140px;
  border: 0;
  border-radius: 999px;
  background: #fffe;
  color: #1a1410;
}

/* The books a search found: a card of rows, each one tap to add. */
.hits {
  list-style: none;
  margin: 10px 0 0;
  padding: 6px;
  display: grid;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  max-height: min(60vh, 520px);
  overflow-y: auto;
  animation: unfold 0.35s var(--glide) both;
}
.hits li {
  animation: rise 0.4s var(--glide) both;
}
.hits li:nth-child(2) {
  animation-delay: 30ms;
}
.hits li:nth-child(3) {
  animation-delay: 60ms;
}
.hits li:nth-child(4) {
  animation-delay: 90ms;
}
.hits li:nth-child(5) {
  animation-delay: 120ms;
}
.hits li:nth-child(n + 6) {
  animation-delay: 150ms;
}
.hit {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  justify-content: stretch;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  font-weight: inherit;
}
.hit:hover:not(:disabled) {
  background: var(--paper-2);
}
.hit:disabled {
  cursor: default;
  opacity: 0.55;
}
.hit img,
.hit .nocover {
  width: 40px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 2px 4px 4px 2px;
  background: var(--cloth, var(--line));
  box-shadow: 0 1px 3px #0003;
}
.hit .what {
  display: grid;
  min-width: 0;
}
.hit strong {
  font: 600 16px/1.25 var(--serif);
  font-variation-settings: 'SOFT' 50;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit .what span {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit .plus {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
}

.by-hand {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px dashed var(--line);
}
.by-hand .note {
  flex-basis: 100%;
  margin: 0;
}
.by-hand input {
  flex: 1 1 150px;
}
.note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 15px;
}
.note.looking::after {
  content: '…';
  display: inline-block;
  animation: breathe 1s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    opacity: 0.2;
  }
}
.note.bad {
  color: var(--bad);
}
.note button {
  min-height: 36px;
  margin-left: 6px;
  padding: 0 12px;
}

/* ---- the shelves and the search ---- */

.tools {
  display: grid;
  gap: 12px;
}
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 2px 16px;
}
@media (min-width: 960px) {
  .filters {
    margin: 0;
    padding: 2px 0;
  }
}
.chip {
  flex: none;
  min-height: 40px;
  border-radius: 999px;
  padding: 0 14px;
  white-space: nowrap;
}
.chip,
.chip .n {
  transition:
    transform 0.12s ease,
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}
.chip .n {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.chip.on .n {
  background: color-mix(in srgb, var(--paper) 20%, transparent);
  color: var(--paper);
}
/* History: the years books were finished in, quieter than the shelves. */
.years {
  align-items: center;
}
.years .label {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.years .chip {
  min-height: 34px;
  font-variant-numeric: lining-nums;
}

/* A year's shelf opens with its year, large. */
.year-card {
  display: grid;
  gap: 2px;
  margin-bottom: 14px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  animation: rise 0.45s var(--glide) both;
}
.year-card .year {
  margin: 0;
  font: 650 56px/1 var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1,
    'opsz' 144;
  color: var(--accent);
}
.year-card .what {
  margin: 0;
  color: var(--muted);
}
.goal-field {
  display: grid;
  gap: 6px;
}
.goal-field input {
  max-width: 160px;
}

.tools input[type='search'] {
  width: 100%;
}

/* ---- the books ---- */

.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
@media (min-width: 960px) {
  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    align-items: start; /* a book keeps its own height when its neighbour opens */
    gap: 18px;
  }
}
.book {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition:
    transform 0.25s var(--glide),
    box-shadow 0.25s var(--glide);
}
/* As the page opens the first books rise in one after another; later,
   books that come and go glide (a view transition) instead. */
:root:not(.settled) .book {
  animation: rise 0.5s var(--glide) both;
  animation-delay: calc(min(var(--n, 0), 10) * 45ms);
}
.book:nth-child(2) {
  --n: 1;
}
.book:nth-child(3) {
  --n: 2;
}
.book:nth-child(4) {
  --n: 3;
}
.book:nth-child(5) {
  --n: 4;
}
.book:nth-child(6) {
  --n: 5;
}
.book:nth-child(7) {
  --n: 6;
}
.book:nth-child(8) {
  --n: 7;
}
.book:nth-child(n + 9) {
  --n: 8;
}
@media (hover: hover) {
  .book:hover {
    transform: translateY(-2px);
    box-shadow:
      var(--shadow),
      0 14px 32px #3a2a1a14;
  }
}
.book.open {
  outline: 2px solid var(--accent-soft);
}
@media (min-width: 960px) {
  .book {
    grid-template-columns: 92px minmax(0, 1fr);
    padding: 16px;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}
.cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px 8px 8px 4px;
  background: var(--line);
  box-shadow:
    inset 3px 0 0 #0000001f,
    0 2px 6px #00000026;
}
.spine {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 5px;
  overflow: hidden;
  container-type: inline-size; /* the title's size follows the spine's width */
  text-align: center;
  color: #fff8ee;
  background:
    linear-gradient(90deg, #00000033 0 6%, transparent 6% 94%, #0000001a 94%),
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--cloth) 82%, #fff),
      color-mix(in srgb, var(--cloth) 80%, #000)
    );
}
.spine::before,
.spine::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: #e7c46a;
  opacity: 0.85;
}
.spine::before {
  top: 12%;
}
.spine::after {
  bottom: 12%;
}
.spine span {
  /* Small enough that a long word ("Punishment") fits whole on a phone's
     spine; breaking inside a word is the last resort. */
  font: 600 clamp(9px, 16cqi, 12px) / 1.15 var(--serif);
  hyphens: auto;
  overflow-wrap: break-word;
  font-variation-settings: 'SOFT' 100;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.body {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}
.title {
  display: grid;
  justify-items: start;
  justify-content: start; /* the base button centres; a title reads from the left */
  gap: 2px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: inherit;
}
.title:active {
  transform: none;
}
.title strong {
  font: 600 19px/1.2 var(--serif);
  font-variation-settings:
    'SOFT' 50,
    'opsz' 36;
  overflow-wrap: anywhere;
}
.authors {
  color: var(--muted);
  font-size: 15px;
}
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* The status switch: three segments, the current one filled. */
/* The status switch: three equal segments, and a thumb that slides to
   the current one (red for Read). */
.seg {
  --at: 0;
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 12px;
  background: var(--paper-2);
}
.seg[data-at='reading'] {
  --at: 1;
}
.seg[data-at='read'] {
  --at: 2;
}
.seg::before {
  content: '';
  position: absolute;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / 3);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 1px 3px #0000001f;
  transform: translateX(calc(var(--at) * 100%));
  transition:
    transform 0.35s var(--spring),
    background 0.25s ease;
}
.seg[data-at='read']::before {
  background: var(--accent);
}
.seg button {
  position: relative; /* above the thumb */
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  transition: color 0.25s ease;
}
.seg button[aria-checked='true'] {
  color: var(--ink);
}
.seg button[data-status='read'][aria-checked='true'] {
  color: var(--accent-ink);
}

.stars {
  display: inline-flex;
}
.star {
  min-height: 40px;
  min-width: 34px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--line);
}
.star.on {
  color: var(--star);
  animation: pop 0.4s var(--spring) both;
}
.star:nth-child(2) {
  animation-delay: 40ms;
}
.star:nth-child(3) {
  animation-delay: 80ms;
}
.star:nth-child(4) {
  animation-delay: 120ms;
}
.star:nth-child(5) {
  animation-delay: 160ms;
}
@media (hover: hover) {
  .stars:hover .star {
    transform: scale(1.12);
  }
  .stars .star:hover ~ .star {
    transform: none;
  }
}
@keyframes pop {
  0% {
    transform: scale(0.6) rotate(-20deg);
  }
  60% {
    transform: scale(1.3) rotate(8deg);
  }
}

.details {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  animation: unfold 0.35s var(--glide) both;
}
@keyframes unfold {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.dates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.dates label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.dates input {
  width: 100%;
  min-height: 44px;
}
.details textarea {
  width: 100%;
  resize: vertical;
}
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.remove {
  justify-self: start;
  border-color: transparent;
  background: none;
  color: var(--bad);
  padding: 0 4px;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}
.tilde {
  margin-bottom: 8px;
  overflow: visible;
}
/* Her head sways slowly on her neck, the book stays put; now and then
   she blinks. */
.tilde .head {
  transform-box: view-box;
  transform-origin: 104px 124px; /* her neck */
  animation: sway 6s ease-in-out infinite;
}
.tilde .eyes circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5s infinite;
}
.empty strong {
  font: 600 22px/1.2 var(--serif);
  font-variation-settings: 'SOFT' 100;
  color: var(--ink);
}
.empty p {
  margin: 0;
  max-width: 34ch;
}
@keyframes sway {
  0%,
  100% {
    transform: rotate(0);
  }
  30% {
    transform: rotate(-6deg);
  }
  65% {
    transform: rotate(4deg);
  }
}
@keyframes blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}

/* ---- export and import ---- */

.backup {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---- a book just read: sparks fly (app.ts throws them) ---- */

.spark {
  position: fixed;
  z-index: 10;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 2px;
  background: var(--star);
  pointer-events: none;
}
.spark:nth-child(3n) {
  background: var(--accent);
  border-radius: 50%;
}

/* ---- books gliding to their new places (view transitions) ---- */

:root {
  view-transition-name: none; /* only the books move; the rest changes at once */
}
::view-transition {
  pointer-events: none; /* taps go through to the page while books glide */
}
::view-transition-group(*) {
  animation-duration: 0.4s;
  animation-timing-function: var(--glide);
  overflow: clip;
  border-radius: var(--radius);
}
::view-transition-old(*),
::view-transition-new(*) {
  height: 100%; /* a book that opens grows; its picture is not stretched */
  object-fit: none;
  object-position: top left;
}
::view-transition-new(*):only-child {
  animation: appear 0.4s var(--spring) both; /* a book arriving */
}
::view-transition-old(*):only-child {
  animation: vanish 0.25s ease both; /* a book leaving */
}
@keyframes appear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}
@keyframes vanish {
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

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