:root {
  color-scheme: light;
  --ink: #101418;
  --ink-soft: #171d22;
  --paper: #f5ead6;
  --muted: #735f4a;
  --brass: #b98238;
  --brass-soft: #8f622c;
  --walnut: #84532f;
  --walnut-deep: #4f2e1a;
  --teal: #3e9a92;
  --wine: #7d3346;
  --line: rgba(81, 52, 30, 0.16);
  --shadow: rgba(76, 45, 21, 0.22);
  --cursor-rest: url("snoopy-cursor-muted.png") 20 38, auto;
  --cursor-active: url("snoopy-cursor-active.png") 20 38, pointer;
  --emboss-light: rgba(255, 255, 255, 0.9);
  --emboss-dark: rgba(82, 53, 25, 0.23);
  --radius: 8px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f7efdf;
  cursor: var(--cursor-rest);
}

body {
  position: relative;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(116deg, rgba(54, 152, 150, 0.07) 0 22%, transparent 46%),
    linear-gradient(248deg, rgba(201, 44, 48, 0.055) 0 18%, transparent 44%),
    linear-gradient(180deg, #fff9ed 0%, #f3e4ca 58%, #d9ba83 100%);
  background-size: auto, auto, auto;
  color: #2b2118;
  font-family: var(--font-sans);
  font-size: 16px;
  letter-spacing: 0;
  cursor: var(--cursor-rest);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body::before {
  background:
    url("paper-grain.png"),
    repeating-linear-gradient(2deg, rgba(97, 66, 36, 0.038) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(18deg, rgba(121, 85, 48, 0.035) 0 1px, transparent 1px 16px);
  background-size: 1000px 1000px, 360px 360px, 420px 420px, 560px 560px;
  background-blend-mode: soft-light, multiply, screen, multiply;
  opacity: 0.52;
  filter: contrast(0.82) brightness(1.08);
  mix-blend-mode: multiply;
}

body::after {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(135deg, transparent 0 23px, rgba(90, 58, 29, 0.06) 23px 24px, transparent 24px 46px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.36) 0 18%, transparent 45%, rgba(94, 59, 28, 0.085) 100%);
  background-position: 0 0, 2px 2px, 0 0;
  opacity: 0.74;
  mix-blend-mode: soft-light;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: var(--cursor-active);
}

a,
select,
.book-spine,
.shelf-tag,
.modal-scrim,
.modal-close {
  cursor: var(--cursor-active);
}

input {
  cursor: text;
}

.library-shell {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.library-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  min-height: 176px;
  margin-bottom: 18px;
  padding: 24px 26px;
  border: 1px solid rgba(109, 73, 39, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(110deg, rgba(255, 255, 252, 0.9), rgba(255, 239, 208, 0.72) 58%, rgba(213, 42, 45, 0.08)),
    linear-gradient(180deg, rgba(74, 167, 163, 0.13), transparent 72%);
  background-size: auto, auto;
  box-shadow:
    0 30px 74px rgba(112, 76, 39, 0.16),
    -7px -7px 18px rgba(255, 255, 255, 0.5),
    9px 12px 24px rgba(96, 61, 28, 0.17),
    -1px -1px 0 var(--emboss-light),
    1px 1px 0 rgba(82, 53, 25, 0.14),
    inset 2px 2px 4px rgba(255, 255, 255, 0.74),
    inset -3px -4px 10px rgba(96, 62, 30, 0.16),
    inset 0 -18px 42px rgba(124, 80, 38, 0.055);
  overflow: hidden;
}

.library-header::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: calc(var(--radius) - 2px);
  box-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.48),
    1px 1px 0 rgba(85, 56, 29, 0.12),
    inset 1px 1px 3px rgba(255, 255, 255, 0.6),
    inset -1px -1px 4px rgba(88, 58, 29, 0.14);
  pointer-events: none;
}

.title-block {
  position: relative;
  min-height: 166px;
  padding-right: 310px;
}

.eyebrow,
.modal-kicker {
  margin: 0 0 8px;
  color: #7a4d21;
  font-family: var(--font-serif);
  font-size: 0.86rem;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0;
}

.snoopy-stage {
  position: absolute;
  right: -4px;
  top: -12px;
  bottom: auto;
  width: 310px;
  height: 210px;
  pointer-events: none;
}

.snoopy-stage::before {
  content: "";
  position: absolute;
  left: 52px;
  right: 16px;
  bottom: 26px;
  height: 20px;
  border-radius: 999px;
  background: rgba(117, 74, 38, 0.14);
  filter: blur(3px);
}

.snoopy-reader {
  position: absolute;
  display: block;
  user-select: none;
}

.snoopy-reader {
  right: 0;
  top: 0;
  bottom: auto;
  width: 246px;
  filter: drop-shadow(0 17px 18px rgba(89, 55, 24, 0.18));
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.7fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(96, 65, 34, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.86), rgba(244, 230, 205, 0.74));
  background-size: auto;
  box-shadow:
    0 18px 42px rgba(111, 72, 34, 0.15),
    -5px -5px 14px rgba(255, 255, 255, 0.42),
    7px 9px 18px rgba(93, 59, 30, 0.13),
    -1px -1px 0 var(--emboss-light),
    1px 1px 0 rgba(82, 53, 25, 0.13),
    inset 2px 2px 4px rgba(255, 255, 255, 0.64),
    inset -3px -4px 8px rgba(91, 60, 31, 0.13);
}

.sync-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #68503a;
  font-size: 0.84rem;
}

.sync-copy strong {
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  white-space: nowrap;
}

.sync-copy span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-copy span:last-child.is-error {
  color: #9c3341;
}

.sync-mark {
  flex: 0 0 auto;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(74, 167, 163, 0.22);
  border-radius: 999px;
  color: #286c69;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(212, 239, 235, 0.5));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(77, 51, 26, 0.06);
  font-size: 0.74rem;
  font-weight: 700;
}

.api-key-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.api-key-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(96, 65, 34, 0.13);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(240, 226, 202, 0.28));
  box-shadow:
    inset 2px 2px 4px rgba(76, 50, 25, 0.13),
    inset -1px -1px 3px rgba(255, 255, 255, 0.62),
    0 1px 0 rgba(255, 255, 255, 0.7);
}

.api-key-field span {
  color: #7a4d21;
  font-size: 0.78rem;
  white-space: nowrap;
}

.api-key-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #2b2118;
}

.api-key-field input::placeholder {
  color: rgba(43, 33, 24, 0.34);
}

.sync-button,
.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 700;
}

.sync-button {
  border: 1px solid rgba(135, 83, 34, 0.2);
  color: #21170f;
  background:
    linear-gradient(180deg, #f7df91, #d59c47);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    0 5px 14px rgba(142, 92, 36, 0.16);
}

.ghost-button {
  border: 1px solid rgba(96, 65, 34, 0.14);
  color: #6b5139;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(238, 222, 195, 0.28));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.52),
    0 1px 2px rgba(77, 51, 26, 0.06);
}

.sync-button:hover,
.sync-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible {
  outline: none;
  filter: saturate(1.05) brightness(1.03);
  transform: translateY(-1px);
}

.sync-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  filter: grayscale(0.35);
  opacity: 0.62;
  transform: none;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 1px;
  min-width: 460px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow:
    0 18px 46px rgba(118, 78, 36, 0.14),
    -4px -4px 12px rgba(255, 255, 255, 0.36),
    5px 7px 14px rgba(93, 59, 30, 0.11),
    -1px -1px 0 rgba(255, 255, 255, 0.72),
    1px 1px 0 rgba(82, 53, 25, 0.12),
    inset 2px 2px 4px rgba(255, 255, 255, 0.54),
    inset -2px -2px 4px rgba(82, 53, 25, 0.13);
}

.stat-item {
  min-height: 74px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 252, 243, 0.84), rgba(245, 232, 210, 0.78));
  background-size: auto;
}

.stat-item strong {
  display: block;
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.1;
}

.stat-item span {
  display: block;
  margin-top: 8px;
  color: #7a614b;
  font-size: 0.8rem;
}

.control-deck {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(160px, 200px) minmax(148px, 170px);
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 254, 248, 0.92), rgba(247, 236, 217, 0.9));
  background-size: auto;
  box-shadow:
    0 18px 46px rgba(118, 78, 36, 0.15),
    -5px -5px 14px rgba(255, 255, 255, 0.42),
    7px 9px 18px rgba(93, 59, 30, 0.13),
    -1px -1px 0 var(--emboss-light),
    1px 1px 0 rgba(82, 53, 25, 0.13),
    inset 2px 2px 4px rgba(255, 255, 255, 0.66),
    inset -3px -4px 8px rgba(103, 69, 36, 0.13);
  backdrop-filter: blur(18px);
}

.search-field,
.select-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(96, 65, 34, 0.13);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(240, 226, 202, 0.25));
  box-shadow:
    inset 2px 2px 4px rgba(80, 52, 24, 0.12),
    inset -1px -1px 3px rgba(255, 255, 255, 0.6),
    0 1px 0 rgba(255, 255, 255, 0.66);
}

.search-field span,
.select-field span {
  color: #7a4d21;
  font-size: 0.78rem;
  white-space: nowrap;
}

.search-field input,
.select-field select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #2b2118;
}

.search-field input::placeholder {
  color: rgba(43, 33, 24, 0.42);
}

.select-field select {
  appearance: none;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(5, minmax(68px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(96, 65, 34, 0.12);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(241, 225, 197, 0.24));
  box-shadow:
    inset 2px 2px 4px rgba(80, 52, 24, 0.1),
    inset -1px -1px 3px rgba(255, 255, 255, 0.62),
    0 1px 0 rgba(255, 255, 255, 0.64);
}

.segment {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #654d38;
  font-size: 0.84rem;
}

.segment:hover,
.segment:focus-visible {
  outline: none;
  color: #2b2118;
  background: rgba(189, 132, 61, 0.14);
}

.segment.is-active {
  color: #21170f;
  background: linear-gradient(180deg, #f5d986, #d39b48);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 3px 10px rgba(139, 91, 36, 0.12);
}

.shelves {
  display: grid;
  gap: 28px;
}

.category-section {
  border: 1px solid rgba(106, 69, 38, 0.16);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(248, 232, 204, 0.42)),
    rgba(255, 248, 235, 0.74);
  background-size: auto, auto;
  box-shadow:
    0 24px 62px rgba(118, 78, 36, 0.16),
    -6px -6px 16px rgba(255, 255, 255, 0.4),
    9px 12px 24px rgba(94, 59, 29, 0.14),
    -1px -1px 0 var(--emboss-light),
    1px 1px 0 rgba(82, 53, 25, 0.13),
    inset 2px 2px 5px rgba(255, 255, 255, 0.64),
    inset -3px -4px 9px rgba(82, 53, 25, 0.13);
}

.wall-section {
  box-shadow:
    0 32px 82px rgba(103, 65, 31, 0.2),
    -7px -7px 18px rgba(255, 255, 255, 0.43),
    10px 13px 26px rgba(88, 54, 27, 0.16),
    -1px -1px 0 var(--emboss-light),
    1px 1px 0 rgba(82, 53, 25, 0.14),
    inset 2px 2px 5px rgba(255, 255, 255, 0.66),
    inset -3px -4px 10px rgba(82, 53, 25, 0.14);
}

.category-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  min-height: 54px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(106, 69, 38, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 252, 243, 0.68), rgba(244, 229, 202, 0.5));
  background-size: auto;
}

.category-heading h2 {
  margin: 0;
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 0;
}

.category-heading span {
  color: #7a614b;
  font-size: 0.84rem;
  white-space: nowrap;
}

.shelf-frame {
  padding: 12px 14px 0;
  border-left: 12px solid rgba(126, 77, 40, 0.86);
  border-right: 12px solid rgba(126, 77, 40, 0.86);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24), transparent 15%, transparent 85%, rgba(92, 52, 27, 0.06)),
    repeating-linear-gradient(90deg, rgba(108, 74, 44, 0.075) 0 14px, rgba(255, 249, 237, 0.7) 14px 31px);
  background-size: auto, auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    inset 12px 0 22px rgba(89, 52, 26, 0.16),
    inset -12px 0 22px rgba(89, 52, 26, 0.16),
    inset 0 8px 16px rgba(255, 255, 255, 0.18);
}

.wall-frame {
  padding-top: 18px;
}

.shelf-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  min-height: 218px;
  padding: 18px 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: rgba(202, 165, 106, 0.34) transparent;
  scrollbar-width: thin;
}

.wall-row {
  min-height: 226px;
}

.shelf-row::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 100%;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 34%),
    linear-gradient(90deg, rgba(101, 62, 34, 0.12), transparent 12%, transparent 88%, rgba(101, 62, 34, 0.16));
}

.shelf-plank {
  height: 24px;
  margin: 0 -14px;
  border-top: 1px solid rgba(255, 232, 185, 0.23);
  background:
    linear-gradient(180deg, #c8965e, #855632 52%, #57321e),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 20px);
  box-shadow:
    0 14px 24px rgba(78, 45, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -4px 8px rgba(57, 31, 16, 0.22);
}

.book-spine {
  --book-hue: 32;
  --book-sat: 50%;
  --book-light: 42%;
  --book-width: 28px;
  --book-height: 168px;
  --book-progress: 0%;
  --spine-top: hsl(var(--book-hue) var(--book-sat) calc(var(--book-light) + 8%));
  --spine-bottom: hsl(var(--book-hue) var(--book-sat) var(--book-light));
  --spine-accent: rgba(255, 248, 232, 0.32);
  --spine-text: rgba(255, 248, 232, 0.93);
  --spine-title-shadow: rgba(0, 0, 0, 0.82);
  --spine-title-backdrop: rgba(0, 0, 0, 0.14);
  --spine-texture: none;
  --spine-band-top: 15%;
  --spine-band-bottom: 78%;
  --spine-line-opacity: 0.18;
  position: relative;
  z-index: 1;
  flex: 0 0 var(--book-width);
  width: var(--book-width);
  height: var(--book-height);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-bottom: 0;
  border-radius: 2px 5px 0 0;
  appearance: none;
  overflow: hidden;
  color: var(--spine-text);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.24), rgba(255, 255, 255, 0.22) 13%, rgba(255, 255, 255, 0.04) 34%, rgba(0, 0, 0, 0.28) 100%),
    linear-gradient(180deg, transparent 0 var(--spine-band-top), color-mix(in srgb, var(--spine-accent), transparent 18%) var(--spine-band-top) calc(var(--spine-band-top) + 3px), transparent calc(var(--spine-band-top) + 3px) var(--spine-band-bottom), color-mix(in srgb, var(--spine-accent), transparent 25%) var(--spine-band-bottom) calc(var(--spine-band-bottom) + 2px), transparent calc(var(--spine-band-bottom) + 2px)),
    linear-gradient(180deg, var(--spine-top), var(--spine-bottom));
  box-shadow:
    3px 0 8px rgba(80, 45, 18, 0.34),
    inset 3px 0 5px rgba(255, 255, 255, 0.08),
    inset -4px 0 8px rgba(0, 0, 0, 0.32);
  transform-origin: bottom center;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.book-spine.has-cover-visual,
.book-spine.is-album.has-cover-visual,
.book-spine.is-collection.has-cover-visual {
  border-color: rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.34), rgba(255, 255, 255, 0.24) 11%, rgba(255, 255, 255, 0.05) 33%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.2)),
    repeating-linear-gradient(180deg, color-mix(in srgb, var(--spine-accent), transparent 78%) 0 2px, transparent 2px 18px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, transparent 0 var(--spine-band-top), color-mix(in srgb, var(--spine-accent), transparent 12%) var(--spine-band-top) calc(var(--spine-band-top) + 2px), transparent calc(var(--spine-band-top) + 2px) var(--spine-band-bottom), color-mix(in srgb, var(--spine-accent), transparent 22%) var(--spine-band-bottom) calc(var(--spine-band-bottom) + 2px), transparent calc(var(--spine-band-bottom) + 2px)),
    var(--spine-texture),
    linear-gradient(180deg, var(--spine-top), var(--spine-bottom));
  background-repeat: no-repeat;
  background-size: auto, auto, auto, auto, auto, 100% 100%, auto;
  background-position: center;
  background-blend-mode: normal, normal, soft-light, soft-light, soft-light, multiply, normal;
}

.book-spine.has-cover-fallback {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.24), rgba(255, 255, 255, 0.2) 12%, transparent 34%, rgba(0, 0, 0, 0.28) 100%),
    linear-gradient(180deg, hsl(var(--book-hue) var(--book-sat) calc(var(--book-light) + 10%)), hsl(var(--book-hue) var(--book-sat) calc(var(--book-light) - 3%)));
}

.book-spine:hover,
.book-spine:focus-visible {
  z-index: 6;
  outline: 0;
  transform: translateY(-16px) scale(1.04);
  filter: saturate(1.1) brightness(1.12);
  box-shadow:
    8px 12px 22px rgba(0, 0, 0, 0.45),
    inset 3px 0 5px rgba(255, 255, 255, 0.1),
    inset -4px 0 8px rgba(0, 0, 0, 0.28);
}

.book-spine::before {
  content: "";
  position: absolute;
  inset: 9px 5px auto;
  height: 2px;
  background: color-mix(in srgb, var(--spine-accent), white 16%);
  opacity: var(--spine-line-opacity);
  box-shadow:
    0 10px 0 color-mix(in srgb, var(--spine-accent), transparent 22%),
    0 18px 0 color-mix(in srgb, var(--spine-accent), transparent 48%);
}

.book-spine::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--book-progress);
  max-height: 100%;
  background: linear-gradient(180deg, rgba(226, 197, 143, 0.12), rgba(226, 197, 143, 0.44));
  border-top: 1px solid rgba(255, 247, 231, 0.22);
}

.book-spine.is-done::after {
  background: linear-gradient(180deg, rgba(82, 168, 132, 0.12), rgba(82, 168, 132, 0.5));
}

.book-spine.is-unread::after {
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.book-spine.is-album {
  --book-width: 42px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.28)),
    linear-gradient(180deg, #42a6a2, #1e5d68);
}

.book-spine.is-collection {
  --book-width: 46px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.24)),
    linear-gradient(180deg, #e0ac52, #8c572a);
}

.book-title {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: calc(100% - 18px);
  padding: 26px 4px 10px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  overflow: hidden;
  color: var(--spine-text);
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.16;
  text-shadow:
    0 1px 2px var(--spine-title-shadow),
    0 0 10px rgba(0, 0, 0, 0.18);
  word-break: break-all;
}

.book-spine.has-cover-visual .book-title {
  padding-inline: 5px;
  background:
    linear-gradient(90deg, transparent, var(--spine-title-backdrop) 18%, var(--spine-title-backdrop) 82%, transparent);
  backdrop-filter: saturate(1.1);
}

.shelf-tag {
  --tag-hue: 38;
  position: relative;
  z-index: 2;
  flex: 0 0 32px;
  width: 32px;
  height: 166px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 8px;
  margin: 0 8px 0 5px;
  padding: 12px 4px 8px;
  border: 1px solid rgba(72, 45, 26, 0.18);
  border-bottom: 0;
  border-radius: 999px 999px 2px 2px;
  color: #2b2118;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), transparent 40%, rgba(0, 0, 0, 0.08)),
    linear-gradient(180deg, hsl(var(--tag-hue) 68% 78%), hsl(var(--tag-hue) 54% 62%));
  box-shadow:
    6px 8px 16px rgba(71, 42, 19, 0.16),
    -2px -2px 6px rgba(255, 255, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    inset -2px -3px 6px rgba(81, 49, 25, 0.12);
}

.shelf-tag::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.54);
  transform: translateX(-50%);
  box-shadow: inset 0 0 0 1px rgba(72, 45, 26, 0.14);
}

.shelf-tag strong {
  max-height: 106px;
  max-width: 1.2em;
  overflow: hidden;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.8rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.shelf-tag span {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(43, 33, 24, 0.72);
  background: rgba(255, 255, 255, 0.48);
  font-size: 0.68rem;
  font-weight: 700;
}

.book-status-pin {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 248, 232, 0.28);
  transform: translateX(-50%);
}

.book-spine.is-done .book-status-pin {
  background: #76d0a6;
  box-shadow: 0 0 12px rgba(118, 208, 166, 0.58);
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.46);
}

.book-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.book-modal.is-open {
  display: flex;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(42, 30, 18, 0.52);
  backdrop-filter: blur(18px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 28px;
  width: min(940px, 100%);
  min-height: 340px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(89, 58, 32, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(246, 220, 184, 0.38)),
    #fff7e8;
  background-size: auto, auto;
  box-shadow:
    0 30px 90px rgba(63, 38, 18, 0.36),
    -6px -6px 16px rgba(255, 255, 255, 0.38),
    8px 11px 24px rgba(62, 38, 18, 0.22),
    -1px -1px 0 rgba(255, 255, 255, 0.78),
    1px 1px 0 rgba(82, 53, 25, 0.14),
    inset 2px 2px 5px rgba(255, 255, 255, 0.64),
    inset -3px -4px 10px rgba(105, 70, 36, 0.14);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(89, 58, 32, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.52);
  color: #2b2118;
  font-size: 1.3rem;
  line-height: 1;
}

.modal-close:hover,
.modal-close:focus-visible {
  outline: none;
  background: rgba(221, 183, 117, 0.22);
}

.cover-stage {
  align-self: start;
  width: 210px;
  min-height: 302px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(180deg, #f1d9aa, #b9874d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.cover-stage img {
  width: 172px;
  max-width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 3px 7px 7px 3px;
  box-shadow:
    14px 18px 30px rgba(0, 0, 0, 0.44),
    -4px 0 10px rgba(0, 0, 0, 0.32);
}

.cover-placeholder {
  width: 172px;
  aspect-ratio: 2 / 3;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 3px 7px 7px 3px;
  background: linear-gradient(180deg, #c99354, #6e4226);
  color: #fff4df;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.35;
  text-align: center;
  box-shadow: 14px 18px 30px rgba(0, 0, 0, 0.44);
}

.modal-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal-copy h2 {
  margin: 0;
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 1.55rem;
  line-height: 1.28;
  letter-spacing: 0;
}

.modal-author {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.meta-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(89, 58, 32, 0.14);
  border-radius: 999px;
  color: #5e4633;
  background: rgba(255, 255, 255, 0.58);
  font-size: 0.82rem;
}

.progress-block {
  margin-top: 18px;
}

.progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-line strong {
  color: #2b2118;
  font-size: 1.12rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(89, 58, 32, 0.13);
  border-radius: 999px;
  background: rgba(115, 81, 48, 0.12);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--brass-soft));
}

.progress-note {
  margin: 10px 0 0;
  color: rgba(43, 33, 24, 0.62);
  font-size: 0.84rem;
  line-height: 1.5;
}

.notes-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(89, 58, 32, 0.13);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(244, 229, 202, 0.28));
  box-shadow:
    inset 1px 1px 3px rgba(255, 255, 255, 0.54),
    inset -1px -2px 5px rgba(96, 62, 30, 0.08);
}

.notes-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notes-heading strong {
  display: block;
  color: #2e2117;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.notes-heading span {
  display: block;
  margin-top: 3px;
  color: rgba(43, 33, 24, 0.58);
  font-size: 0.78rem;
}

.notes-load {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(135, 83, 34, 0.18);
  border-radius: 999px;
  color: #20160e;
  background: linear-gradient(180deg, #f4dd96, #cf9a4d);
  font-size: 0.82rem;
  font-weight: 700;
}

.notes-load:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.notes-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid rgba(96, 65, 34, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.36);
}

.notes-tabs button {
  min-height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #6b5139;
  font-size: 0.78rem;
}

.notes-tabs button.is-active {
  color: #1d140d;
  background: linear-gradient(180deg, rgba(246, 220, 143, 0.92), rgba(208, 154, 77, 0.9));
  font-weight: 700;
}

.notes-list {
  display: grid;
  gap: 10px;
  max-height: 310px;
  margin-top: 12px;
  padding-right: 4px;
  overflow: auto;
  scrollbar-color: rgba(202, 165, 106, 0.42) transparent;
  scrollbar-width: thin;
}

.notes-empty,
.notes-loading {
  margin: 12px 0 0;
  color: rgba(43, 33, 24, 0.62);
  font-size: 0.84rem;
  line-height: 1.55;
}

.notes-empty.is-error {
  color: #9c3341;
}

.trace-card {
  padding: 10px 11px;
  border: 1px solid rgba(89, 58, 32, 0.11);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.72), rgba(246, 232, 208, 0.42));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.56),
    0 1px 2px rgba(85, 55, 27, 0.06);
}

.trace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  color: rgba(43, 33, 24, 0.55);
  font-size: 0.72rem;
}

.trace-meta span:first-child {
  color: #7a4d21;
  font-weight: 700;
}

.trace-card blockquote {
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid rgba(185, 130, 56, 0.42);
  color: #2d241c;
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.58;
}

.trace-thought {
  margin: 8px 0 0;
  color: #453628;
  font-size: 0.88rem;
  line-height: 1.6;
}

.trace-link {
  display: inline-flex;
  margin-top: 8px;
  color: #2e756f;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
}

.weread-link {
  align-self: flex-start;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  padding: 0 16px;
  border: 1px solid rgba(226, 197, 143, 0.48);
  border-radius: 999px;
  color: #17120a;
  background: linear-gradient(180deg, #f5d986, #d39b48);
  text-decoration: none;
  font-weight: 700;
}

.weread-link.is-hidden {
  display: none;
}

@media (max-width: 980px) {
  .library-header,
  .sync-panel,
  .control-deck {
    grid-template-columns: 1fr;
  }

  .stat-strip {
    min-width: 0;
  }

  .control-deck {
    position: static;
  }

  .api-key-form {
    grid-template-columns: 1fr auto auto;
  }
}

@media (max-width: 680px) {
  .library-shell {
    width: min(100% - 22px, 1500px);
    padding-top: 18px;
  }

  .library-header {
    min-height: 0;
    padding: 20px 18px;
  }

  .title-block {
    min-height: 0;
    padding-right: 0;
  }

  h1 {
    font-size: 1.54rem;
  }

  .snoopy-stage {
    position: relative;
    right: auto;
    bottom: auto;
    width: 268px;
    height: 168px;
    margin: 14px auto -4px;
    transform: scale(0.94);
    transform-origin: center bottom;
  }

  .snoopy-reader {
    width: 238px;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sync-copy {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .api-key-form {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shelf-frame {
    border-left-width: 8px;
    border-right-width: 8px;
    padding-inline: 8px;
  }

  .modal-panel {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 48px);
    overflow: auto;
  }

  .cover-stage {
    width: 100%;
    min-height: 240px;
  }
}
