/* Folio — 3D PDF library */

@font-face {
  font-family: 'Instrument Serif';
  src: url(../fonts/instrument-serif-latin-400-normal.woff2) format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: block;
  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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url(../fonts/instrument-serif-latin-ext-400-normal.woff2) format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: block;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, 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 Serif';
  src: url(../fonts/instrument-serif-latin-400-italic.woff2) format('woff2');
  font-style: italic;
  font-weight: 400;
  font-display: block;
  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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url(../fonts/instrument-serif-latin-ext-400-italic.woff2) format('woff2');
  font-style: italic;
  font-weight: 400;
  font-display: block;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, 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: 'IBM Plex Mono';
  src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url(../fonts/ibm-plex-mono-latin-300-normal.woff2) format('woff2');
  font-weight: 300;
  font-display: block;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2');
  font-weight: 500;
  font-display: block;
}
@font-face {
  font-family: 'Inter';
  src: url(../fonts/inter-latin-400-normal.woff2) format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url(../fonts/inter-latin-500-normal.woff2) format('woff2');
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #e8e7e0;
  --fg: #191715;
  --muted: rgba(25, 23, 21, 0.45);
  --rule: rgba(25, 23, 21, 0.9);
  --soft: rgba(25, 23, 21, 0.08);
  --bar-bg: transparent;
  --pill-bg: rgba(30, 28, 25, 0.74);
  --pill-fg: #f4f1ea;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --gutter: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --title-size: clamp(28px, 3.6vw, 58px);
  color-scheme: light;
}
body[data-theme='dark'] {
  --bg: #000000;
  --fg: #f7f7ef;
  --muted: rgba(247, 247, 239, 0.45);
  --rule: rgba(247, 247, 239, 0.85);
  --soft: rgba(247, 247, 239, 0.1);
  --pill-bg: rgba(247, 247, 239, 0.16);
  --pill-fg: #f7f7ef;
  color-scheme: dark;
}
body[data-theme='color'] {
  --muted: color-mix(in srgb, var(--fg) 50%, transparent);
  --rule: color-mix(in srgb, var(--fg) 85%, transparent);
  --soft: color-mix(in srgb, var(--fg) 12%, transparent);
  --bar-bg: color-mix(in srgb, var(--bg) 70%, black 30%);
  --pill-bg: color-mix(in srgb, var(--bg) 55%, black 45%);
  --pill-fg: var(--fg);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  transition: background-color 0.6s ease, color 0.6s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  letter-spacing: inherit;
}
button:focus-visible,
input:focus-visible {
  outline: 1px dashed var(--fg);
  outline-offset: 3px;
}
.mono {
  font-family: var(--mono);
  text-transform: uppercase;
}
.dim {
  color: var(--muted);
}
.mono-btn {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 11px;
  line-height: 1;
  padding: 8px 0;
  white-space: nowrap;
}
.mono-btn:hover {
  opacity: 0.6;
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  margin-right: -7px;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  z-index: 1; /* above the title row: books pass in front of the titles, as in the reference */
}

/* ---------------------------------------------------------------- header */
.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-t) + 8px) calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l));
  z-index: 10;
  pointer-events: none;
}
.top > * {
  pointer-events: auto;
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  height: 36px;
}
.brand {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.06em;
  font-weight: 400;
}
.top-right {
  display: flex;
  gap: 18px;
  align-items: center;
}
.sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  position: relative;
}
/* arranging the shelf means nothing while a book is open */
#sort-btn {
  transition: opacity 0.3s ease;
}
body[data-mode='reading'] #sort-btn {
  opacity: 0;
  pointer-events: none;
}

/* one add button: PDF files or a folder */
.add-wrap {
  position: relative;
}
#add-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 250px;
  padding: 10px 16px 8px;
  background: var(--bg);
  border: 1px solid var(--rule);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#add-menu[hidden] {
  display: none;
}
#add-menu .mono-btn {
  padding: 8px 0;
}
#add-menu .note {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--muted);
  margin: 6px 0 2px;
}

/* ---------------------------------------------------------------- title marquee */
#marquee {
  --lift: 42px; /* the box reaches up into the line under the header, where an open book's title goes */
  --head: 19px; /* from the titles' line up to the middle of that line */
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--safe-t) + 78px - var(--lift));
  height: calc(var(--title-size) * 1.25 + var(--lift));
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
}
#marquee .track {
  position: absolute;
  left: 0;
  top: var(--lift);
  height: calc(var(--title-size) * 1.25);
  white-space: nowrap;
  will-change: transform;
}
#marquee .t {
  position: absolute;
  top: 0;
  font-family: var(--serif);
  font-size: var(--title-size);
  line-height: 1.12;
  letter-spacing: -0.012em;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap;
  transition: color 0.35s ease;
}
#marquee .t.on {
  color: var(--fg);
  font-style: normal;
}
/* While a book opens, the row steps back: the neighbours part and fade as the book rises between them, and the
   open book's title shrinks up into the line above it, quiet, like a running head. Closing plays it back, the
   neighbours returning a moment after the title has started to grow. */
#marquee .ti {
  display: inline-block;
  transform-origin: 50% 0;
  transition: opacity 0.5s ease 0.28s, transform 0.9s cubic-bezier(0.22, 0.8, 0.2, 1) 0.2s;
}
#marquee .t.on .ti {
  transition: opacity 0.6s ease, transform 0.9s cubic-bezier(0.22, 0.8, 0.2, 1);
}
body[data-mode='reading'] #marquee .t.l .ti,
body[data-mode='reading'] #marquee .t.r .ti {
  opacity: 0;
  transition: opacity 0.42s ease, transform 0.75s cubic-bezier(0.4, 0, 0.6, 1);
}
body[data-mode='reading'] #marquee .t.l .ti {
  transform: translateX(-9vw);
}
body[data-mode='reading'] #marquee .t.r .ti {
  transform: translateX(9vw);
}
body[data-mode='reading'] #marquee .t.on .ti {
  opacity: 0.72;
  transform: translateY(calc(-1 * var(--head) - var(--title-size) * 0.2576)) scale(0.46);
  transition: opacity 0.8s ease 0.15s, transform 1s cubic-bezier(0.5, 0, 0.2, 1) 0.1s;
}
#marquee .t sup {
  font-family: var(--serif);
  font-style: normal;
  font-size: 0.16em;
  letter-spacing: 0;
  vertical-align: top;
  position: relative;
  top: 0.9em;
  margin-left: 0.35em;
  opacity: 0.9;
}

/* ---------------------------------------------------------------- footer */
.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 calc(var(--gutter) + var(--safe-r)) calc(var(--safe-b) + 4px) calc(var(--gutter) + var(--safe-l));
  height: calc(var(--safe-b) + 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  font-size: 12px;
}
.bottom .mono-btn {
  font-size: 12px;
}
.now {
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.sep {
  width: 0;
  height: 16px;
  border-left: 1px dotted var(--muted);
}

/* ---------------------------------------------------------------- empty shelf */
#empty {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  text-align: center;
  max-width: 520px;
  padding: 28px 32px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#empty h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 54px;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
#empty p {
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0;
  margin: 0 0 18px;
  line-height: 1.45;
}
#empty .big {
  font-size: 14px;
  padding: 12px 6px;
}
#empty .empty-acts {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
}
#empty .hint-drop {
  font-family: var(--mono);
  font-size: 10px;
  margin: 6px 0 0;
}

/* ---------------------------------------------------------------- reader bar */
#readerbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 40px);
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.6vw, 22px);
  padding: 4px 16px;
  background: var(--bar-bg);
  font-size: 10.5px;
  white-space: nowrap;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#readerbar[hidden] {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
}
.rb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  min-width: 30px;
  justify-content: center;
}
.rb svg {
  width: 12px;
  height: 12px;
}
.rb.icon svg {
  width: 17px;
  height: 17px;
}
.rb:disabled {
  opacity: 0.3;
  cursor: default;
}
.rb[aria-pressed='true'] {
  position: relative;
}
.rb.icon[aria-pressed='true']::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}
#rb-bookmark[aria-pressed='true'] svg path:not(.pole) {
  fill: currentColor;
}
/* back to where you were reading (shown after a jump) */
.rb.back[hidden] {
  display: none;
}
/* the two halves of a book's details */
.panel-body .tabs {
  display: flex;
  gap: 22px;
  border-top: 1px solid var(--soft);
  border-bottom: 1px solid var(--soft);
  margin: 0 0 2px;
}
.panel-body .tabs .mono-btn {
  font-size: 11px;
  padding: 12px 0 10px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1.5px solid transparent;
}
.panel-body .tabs [aria-selected='true'] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}
.panel-body .tab-pane[hidden] {
  display: none;
}
.panel-body .tab-pane > section:first-child {
  border-top: 0;
}
.rb.back {
  letter-spacing: 0.03em;
}
.rb.back svg {
  width: 11px;
  height: 11px;
}

/* a raised flag's label: where it leads; tap again (or here) to go */
#flag-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 10px 6px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.18s ease;
}
#flag-tip.on {
  opacity: 1;
}
#flag-tip[hidden] {
  display: none;
}
#flag-tip .ft-p {
  font-size: 12px;
  letter-spacing: 0.04em;
}
#flag-tip .ft-h {
  font-size: 9px;
  letter-spacing: 0.06em;
  opacity: 0.66;
}
#flag-tip::before {
  content: '';
  position: absolute;
  top: 10px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
}
#flag-tip.right::before {
  left: -10px;
  border-right-color: var(--fg);
}
#flag-tip.left::before {
  right: -10px;
  border-left-color: var(--fg);
}
.readout {
  gap: 7px;
  letter-spacing: 0.03em;
  padding: 0 4px;
}
.readout .sep {
  opacity: 0.45;
}
.swatches {
  display: inline-flex;
}
.sw {
  min-width: 0;
  padding: 0;
}
.sw i {
  display: block;
  width: 14px;
  height: 14px;
  background: var(--ink);
  border: 1.2px solid currentColor;
}
#rb-pink i {
  border-right-width: 0.6px;
}
#rb-yellow i {
  border-left-width: 0.6px;
}
.sw#rb-pink {
  padding-left: 8px;
}
.sw#rb-yellow {
  padding-right: 8px;
}
.sw[aria-pressed='true'] i {
  background: linear-gradient(to top right, var(--ink) calc(50% - 0.8px), #e5322d calc(50% - 0.8px), #e5322d calc(50% + 0.8px), var(--ink) calc(50% + 0.8px));
}

/* ---------------------------------------------------------------- reading lights */
/* behind the 3D canvas: the room dims to the light's mood, its light pools on the wall, a window's
   pattern falls on the wall, lightning flashes */
#room-dim,
#room-glow,
#room-flash,
#room-wall {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
}
#room-wall {
  width: 100%;
  height: 100%;
  mix-blend-mode: soft-light;
}
#room-dim {
  --d1: rgba(26, 18, 10, 0.34);
  --d2: rgba(14, 9, 4, 0.5);
  --dx: 50%;
  background: radial-gradient(ellipse at var(--dx) 55%, var(--d1), var(--d2));
}
#room-glow {
  --gx: 50%;
  --gy: 50%;
  --g1: rgba(255, 176, 96, 0.95);
  --g2: rgba(255, 150, 70, 0.42);
  --gr: 30vmin;
  background: radial-gradient(circle at var(--gx) var(--gy), var(--g1) 0, var(--g2) calc(var(--gr) * 0.3), rgba(255, 130, 50, 0.12) var(--gr), rgba(255, 120, 40, 0) calc(var(--gr) * 1.95));
  mix-blend-mode: soft-light;
}
#room-flash {
  z-index: 2;
  background: rgba(225, 232, 255, 0.55);
  mix-blend-mode: screen;
}
#light-pop {
  position: fixed;
  top: calc(var(--safe-t) + 80px);
  right: calc(var(--gutter) + var(--safe-r));
  z-index: 11;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 12px 16px 10px;
  width: min(420px, 94vw);
  max-height: calc(100vh - var(--safe-t) - var(--safe-b) - 100px);
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#light-pop[hidden],
#light-pop [hidden] {
  display: none;
}
.lp-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 10px 0 2px;
}
.lp-choices button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  opacity: 0.55;
}
.lp-choices button svg {
  width: 22px;
  height: 22px;
}
.lp-choices button[aria-checked='true'] {
  opacity: 1;
  border-color: var(--rule);
}
#light-pop .note {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--muted);
  margin: 8px 0 4px;
  min-height: 2.8em;
}
.lp-act {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--soft);
}
.lp-candle-off > .mono {
  font-size: 10.5px;
}
/* a light that is on: a dot under its tile */
.lp-choices button {
  position: relative;
}
.lp-choices button[data-on='true']::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}
.lp-choices button[data-on='true'] {
  opacity: 0.9;
}
#lp-toggle {
  font-size: 12px;
}

/* arranging the shelf: under the order button, top left */
#arrange-pop {
  position: fixed;
  top: calc(var(--safe-t) + 80px);
  left: calc(var(--gutter) + var(--safe-l));
  z-index: 11;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 12px 16px 10px;
  width: min(460px, 94vw);
  max-height: calc(100vh - var(--safe-t) - var(--safe-b) - 100px);
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#arrange-pop[hidden],
#arrange-pop [hidden] {
  display: none;
}
.ap-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: baseline;
  margin-top: 10px;
}
.ap-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
}
.ap-opts .mono-btn {
  font-size: 10.5px;
  padding: 7px 0;
}
.ap-opts [aria-checked='false'] {
  opacity: 0.42;
}
.ap-shelves {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--soft);
}
.ap-shelves .list li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ap-shelves .list li button.open {
  flex: 1;
}
.ap-shelves .list li .mv {
  font-family: var(--mono);
  font-size: 12px;
  width: 26px;
  padding: 8px 0;
  border-bottom: 1px solid var(--soft);
  color: var(--muted);
}
.new-shelf-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.new-shelf-row[hidden],
.f-labelled[hidden] {
  display: none;
}
.f-labelled {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.f-labelled > .mono.dim {
  min-width: 66px;
  font-size: 10.5px;
  text-transform: uppercase;
}
.ap-field {
  flex: 1;
  font: 14px var(--sans);
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--soft);
  padding: 6px 0;
  user-select: text;
  -webkit-user-select: text;
  border-radius: 0;
}
.ap-field:focus {
  outline: none;
  border-bottom-color: var(--fg);
}
#arrange-pop .note {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--muted);
  margin: 10px 0 2px;
}
.check-list li label {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--soft);
  font: 15px var(--sans);
  letter-spacing: 0;
  cursor: pointer;
}
.check-list li label .dim {
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}
.check-list input {
  accent-color: var(--fg);
}

/* header: the reading light, next to the theme */
.sub-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.light-btn {
  width: auto;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 0;
}
.light-btn .ct {
  font-family: var(--mono);
  font-size: 10px;
}
.light-btn .ct:empty {
  display: none;
}
.light-btn[aria-pressed='true'] svg {
  filter: drop-shadow(0 0 3px rgba(255, 170, 80, 0.55));
}
#lp-clock[aria-checked='false'] {
  opacity: 0.45;
}
.cp-times {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.cp-on .cp-times {
  margin-top: 6px;
}

/* ---------------------------------------------------------------- pen & highlighter settings */
#ink-pop {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 88px);
  transform: translateX(-50%);
  z-index: 9;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 12px 16px 8px;
  width: min(400px, 94vw);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#ink-pop[hidden],
#ink-pop [hidden] {
  display: none;
}
.ip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#ip-preview {
  display: block;
  width: 100%;
  height: 74px;
  margin: 8px 0 6px;
  border-top: 1px solid var(--soft);
  border-bottom: 1px solid var(--soft);
}
.ip-row {
  display: grid;
  grid-template-columns: 92px 1fr 44px;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}
.ip-l {
  font-size: 10.5px;
  color: var(--muted);
}
.ip-v {
  font-size: 10.5px;
  text-align: right;
}
.ip-row input[type='range'] {
  width: 100%;
  margin: 0;
  accent-color: var(--fg);
  height: 28px;
}
.ip-colors,
.ip-seg {
  grid-column: 2 / 4;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ip-seg {
  gap: 16px;
}
.ip-seg [aria-checked='false'] {
  opacity: 0.4;
}
.ip-colors button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}
.ip-colors button i {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.ip-colors button[aria-checked='true'] i {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.2px var(--fg);
}
.ip-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.ip-foot .note {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--muted);
  margin: 6px 0 4px;
}
.ip-foot .mono-btn {
  font-size: 10.5px;
  flex: none;
}

/* ---------------------------------------------------------------- go-to popover */
#goto {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 88px);
  transform: translateX(-50%);
  z-index: 9;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 14px 16px 12px;
  width: min(360px, 92vw);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#goto input[type='range'] {
  width: 100%;
  margin: 10px 0 12px;
  accent-color: var(--fg);
}
.goto-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
#goto input[type='number'] {
  width: 84px;
  font: 14px var(--mono);
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 4px 2px;
  user-select: text;
  -webkit-user-select: text;
}
#goto-go {
  margin-left: auto;
  font-size: 12px;
}

/* ---------------------------------------------------------------- side panel */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  z-index: 20;
  background: var(--bg);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.1, 1), background-color 0.6s ease;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}
#panel[hidden] {
  display: flex !important;
  transform: translateX(102%);
  pointer-events: none;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule);
}
.panel-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 40px;
  flex: 1;
  user-select: text;
  -webkit-user-select: text;
}
.panel-body h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 5vw, 54px);
  line-height: 0.98;
  letter-spacing: -0.012em;
  margin: 6px 0 10px;
  word-break: break-word;
}
.panel-body .byline {
  font-family: var(--sans);
  font-style: italic;
  font-size: 19px;
  letter-spacing: 0;
  margin: 0 0 6px;
}
.panel-body section {
  border-top: 1px solid var(--soft);
  padding: 14px 0 16px;
}
.panel-body section:first-child {
  border-top: 0;
}
.panel-body .k {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 11px;
  margin-bottom: 10px;
  display: block;
}
.panel-body .field {
  display: block;
  width: 100%;
  font: 17px var(--sans);
  letter-spacing: 0;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--soft);
  padding: 8px 0;
  margin-bottom: 6px;
  user-select: text;
  -webkit-user-select: text;
}
.panel-body .field:focus {
  outline: none;
  border-bottom-color: var(--fg);
}
.panel-body .facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}
.panel-body .facts span:nth-child(odd) {
  color: var(--muted);
}
.progress {
  height: 2px;
  background: var(--soft);
  margin: 8px 0 10px;
  position: relative;
}
.progress i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--fg);
}
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  padding: 8px 0;
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0;
  border-bottom: 1px solid var(--soft);
  line-height: 1.3;
}
.list li button:hover {
  opacity: 0.65;
}
.list li button .pg {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  flex: none;
  padding-top: 2px;
}
.list li.d1 button {
  padding-left: 14px;
}
.list li.d2 button {
  padding-left: 28px;
  font-size: 14px;
}
.list li.d3 button {
  padding-left: 42px;
  font-size: 13px;
}
.list .sel button {
  font-weight: 500;
}
.cloths {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cloths button {
  width: 28px;
  height: 40px;
  border: 1px solid var(--soft);
  background: var(--c);
}
.cloths button[aria-pressed='true'] {
  outline: 1.5px solid var(--fg);
  outline-offset: 2px;
}
.seg {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.seg > .mono.dim:first-child {
  min-width: 66px;
}
.seg button[aria-pressed='true'] {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.panel-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.panel-actions .danger {
  color: #c3263c;
}
body[data-theme='dark'] .panel-actions .danger,
body[data-theme='color'] .panel-actions .danger {
  color: #ff7d8e;
}
.note {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.45;
  color: var(--muted);
  margin: 8px 0 0;
}

/* ---------------------------------------------------------------- toast, drop */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 92px);
  transform: translate(-50%, 10px);
  z-index: 30;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}
#drop {
  position: fixed;
  inset: 12px;
  z-index: 40;
  border: 1.5px dashed var(--fg);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  font-family: var(--serif);
  font-size: 44px;
  pointer-events: none;
}
#drop[hidden],
#empty[hidden],
#goto[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- mode switches */
body[data-mode='reading'] #empty {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --gutter: 12px;
  }
  .top-right #count {
    display: none;
  }
  .top-right {
    gap: 12px;
  }
  #marquee {
    top: calc(var(--safe-t) + 72px - var(--lift));
    --head: 13px;
  }
  .bottom .actions .mono-btn {
    font-size: 11px;
  }
  .now {
    max-width: 40vw;
  }
}
@media (pointer: coarse) {
  .rb {
    min-height: 44px;
    min-width: 36px;
  }
  .mono-btn {
    padding: 12px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01s !important;
  }
}

/* paper controls (Settings and a book's details) */
.pe-types {
  margin: 2px 0 6px;
}
.pe-note {
  margin: 4px 0 8px;
}
.ip-row.pe-row {
  grid-template-columns: 74px 1fr 78px;
}
.pe-row .ip-v {
  text-align: right;
  text-transform: uppercase;
}
.pe-facts {
  font-size: 10.5px;
  text-transform: uppercase;
  margin: 6px 0 0;
}
#pe-lib-row[hidden] {
  display: none;
}
/* a paper slider: the track, and a small mark where the chosen type really is */
.pe-track {
  position: relative;
  display: block;
}
.pe-track input[type='range'] {
  display: block;
}
.pe-mark {
  position: absolute;
  bottom: 1px;
  width: 1px;
  height: 7px;
  margin-left: -0.5px;
  background: currentColor;
  opacity: 0.55;
  pointer-events: none;
}

