.book-exchange-page {
  --book-bg: #e9e9e9;
  --book-ink: #171717;
  --book-muted: #505050;
  --book-line: #c7c7c7;
  --book-mono: 'Courier New', monospace;
  background: var(--book-bg);
  color: var(--book-ink);
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.book-exchange-page .masthead { border-bottom: 1px solid var(--book-line); }
.book-exchange-main { flex: 1; display: flex; flex-direction: column; }
.book-board-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(20px, 4vw, 50px) clamp(16px, 4vw, 56px) 18px;
}
.book-kicker { margin: 0 0 10px; color: var(--book-muted); font: 12px/1.45 var(--book-mono); letter-spacing: .12em; text-transform: uppercase; }
.book-board-header h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 84px);
  line-height: .99;
  letter-spacing: -.065em;
  font-weight: 400;
}
.book-board-tools { display: flex; gap: 6px; flex: none; }
.book-icon-button, .book-camera-controls button {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #a0a0a0;
  color: #333;
  background: #f9f9f9;
}
.book-icon-button:hover, .book-camera-controls button:hover:not(:disabled), .book-secondary:hover { background: #e3e3e3; }
.book-icon-button.is-active { background: #282828; color: #fff; border-color: #282828; }
.book-board-meta {
  min-height: 42px;
  padding: 6px clamp(16px, 4vw, 56px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  border-block: 1px solid var(--book-line);
  font: 13px/1.35 var(--book-mono);
}
.book-board-meta p { margin: 0; }
#book-active-controls { display: flex; align-items: center; gap: 8px; color: var(--book-muted); min-width: 0; }
#book-active-description { overflow-wrap: anywhere; }
#book-owner-link { margin-inline-start: auto; text-underline-offset: 3px; }
.book-board-wrap { position: relative; isolation: isolate; flex: 1; min-height: 360px; height: max(360px, calc(100dvh - 242px)); }
.book-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-image: radial-gradient(circle, #0002 1px, transparent 1.3px);
  background-size: 24px 24px;
}
.book-canvas:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.book-canvas.is-panning { cursor: grabbing; }
.book-stage { position: absolute; inset: 0 auto auto 0; transform-origin: 0 0; will-change: transform; }
.book-tile {
  position: absolute;
  display: block;
  padding: 0;
  background: #f7f7f7;
  border: 1px solid #0004;
  color: #171717;
  cursor: inherit;
  transform-origin: center;
  box-shadow: 3px 6px 14px #0003;
}
.book-tile:focus-visible, .book-tile:hover { z-index: 1; }
.book-tile-cover, .book-cover-placeholder { width: 100%; height: 100%; display: block; }
.book-tile-cover img, .book-detail-cover img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; }
.book-tile-cover, .book-detail-cover { background: #d5d5d5; pointer-events: none; }
.book-cover-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 10px 9px 10px 13px;
  border-left: 4px solid #838383;
  text-align: left;
  overflow: hidden;
  background: #f6f6f6;
  color: #242424;
  font: 12px/1.2 var(--book-mono);
  overflow-wrap: anywhere;
}
.book-cover-placeholder strong { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.book-cover-placeholder small { color: #555; }
.book-tile-caption {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  padding: 5px 7px;
  background: #fff;
  color: #171717;
  font: 13px/1.25 var(--book-mono);
  opacity: 0;
  pointer-events: none;
}
.book-tile:focus-visible .book-tile-caption { opacity: 1; }
@media (hover: hover) { .book-tile:hover .book-tile-caption { opacity: 1; } }
.book-empty {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(410px, calc(100% - 38px));
  background: #f6f6f6;
  border: 1px solid #bdbdbd;
  padding: 23px 22px;
  text-align: center;
}
.book-empty h2 { margin: 0 0 8px; font-weight: 400; font-size: 25px; letter-spacing: -.03em; }
.book-empty p { margin: 0; color: var(--book-muted); font: 14px/1.5 var(--book-mono); }
.book-empty button { margin-top: 16px; }
.book-camera-controls {
  position: absolute;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #a0a0a0;
}
.book-camera-controls button { border: 0; font: 15px/1 var(--book-mono); }
.book-camera-controls button:disabled { color: #777; cursor: default; }
.book-camera-controls output { min-width: 47px; text-align: center; font: 12px/1 var(--book-mono); }
.book-camera-controls button:last-child { border-left: 1px solid #d3d3d3; }
.book-menu-toggle { position: absolute; right: 18px; bottom: 18px; min-width: 48px; min-height: 46px; }

.book-modal, .book-panel {
  color: var(--book-ink);
  background: #fff;
  border: 1px solid #a0a0a0;
  overflow: auto;
  padding: 27px;
}
.book-modal { width: min(462px, calc(100% - 28px)); max-height: calc(100dvh - 28px); }
.book-modal::backdrop, .book-panel::backdrop { background: #0005; }
.book-menu { padding-top: 34px; }
.book-menu-mark { display: grid; place-items: center; width: 48px; height: 48px; background: #ebebeb; border: 1px solid #cecece; color: #555; margin-bottom: 20px; }
.book-menu h2, .book-modal h2, .book-panel h2 { font-size: clamp(27px, 5vw, 38px); font-weight: 400; line-height: 1.05; letter-spacing: -.04em; margin: 0 0 11px; overflow-wrap: anywhere; }
.book-modal h2, .book-panel > section > h2 { padding-right: 28px; }
.book-menu p:not(.book-kicker), .book-panel p:not(.book-kicker), .book-admin-main .book-intro { color: var(--book-muted); font: 14px/1.55 var(--book-mono); margin: 0 0 16px; }
.book-menu-actions { display: grid; gap: 8px; margin-top: 23px; }
.book-primary, .book-secondary {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #9d9d9d;
  background: #fff;
  color: #242424;
  font: 14px/1.35 var(--book-mono);
  text-align: start;
  text-decoration: none;
}
.book-primary { background: #282828; color: #fff; border-color: #282828; }
.book-primary:hover { background: #424242; }
.book-primary:focus-visible { outline-color: #171717; }
.book-primary:disabled, .book-secondary:disabled { opacity: .62; cursor: default; }
.book-wide, .book-menu-actions button { width: 100%; justify-content: space-between; }
.book-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  color: #222;
  background: #fff;
  font: 27px/1 Arial, sans-serif;
}
.book-close:hover { background: #f0f0f0; }
.book-panel { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(460px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh; padding: 58px 26px 30px; border: 0; border-left: 1px solid #bbb; }
.book-detail-heading { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 17px; align-items: center; padding: 5px 0 12px; }
.book-detail-heading h2 { font-size: clamp(26px, 5vw, 36px); margin: 0 0 5px; }
/* Dialog headings receive programmatic focus for screen readers, not editing. */
.book-panel h2[tabindex="-1"]:focus { outline: none; }
.book-detail-cover { width: 96px; height: 136px; }
.book-detail-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; border-block: 1px solid #dadada; margin: 12px 0; padding: 16px 0; font: 14px/1.4 var(--book-mono); }
.book-detail-facts dt { font-weight: 700; }
.book-detail-facts dd { margin: 3px 0 0; color: var(--book-muted); }
.book-rating { background: #ededed; padding: 11px 13px; margin: 0 0 20px; font: 14px/1.5 var(--book-mono); overflow-wrap: anywhere; }
.book-rating small { display: block; color: #4c4c4c; }
.book-rating a, .book-source { text-underline-offset: 3px; }
.book-panel h3, .book-admin-main h3 { font-size: 17px; line-height: 1.2; font-weight: 700; margin: 0 0 8px; }
.book-summary { white-space: pre-line; overflow-wrap: anywhere; }
#request-swap { margin-top: 9px; }

.book-form { display: grid; gap: 8px; margin-top: 18px; font: 14px/1.45 var(--book-mono); }
.book-form label, .book-form legend { font-weight: 700; }
.book-form label small, .book-form small { color: #525252; font: 12px/1.45 var(--book-mono); }
.book-form input, .book-form select, .book-form textarea, .book-admin-filters select {
  width: 100%; min-width: 0; border: 1px solid #a3a3a3; padding: 9px 10px;
  min-height: 44px; border-radius: 0; color: #171717; background: #fff; font: 16px/1.3 var(--book-mono);
}
.book-form textarea { resize: vertical; }
.book-form :is(input, select, textarea):focus-visible, .book-admin-filters select:focus-visible { outline: 2px solid #333; outline-offset: 2px; }
.book-form input::placeholder { color: #606060; }
.book-form fieldset { min-width: 0; }
.book-year-filter { padding: 0; border: 0; margin: 3px 0; }
.book-year-filter legend { padding: 0 0 5px; }
.book-form-columns { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.book-form-columns label { display: grid; gap: 5px; min-width: 0; }
.book-form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.book-text-button { border: 0; background: none; color: inherit; padding: 5px; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.book-back { margin: 0 0 14px -5px; font: 13px/1.35 var(--book-mono); }
.book-form-trap { position: absolute; left: -9999px; overflow: hidden; width: 1px; height: 1px; }
.book-form .book-form-error, .book-panel .book-form-error { color: #252525; font-weight: 700; margin: 0; }
.book-form-error:empty { display: none; }
.book-form-items, #book-form-items { display: grid; gap: 12px; }
.book-fields { display: grid; gap: 7px; padding: 12px; border: 1px solid #ccc; margin: 0; background: #f7f7f7; }
.book-fields legend { padding: 0 5px; }
.book-fields .book-text-button { justify-self: start; }
.book-contact { display: grid; gap: 8px; border-top: 1px solid #ccc; padding-top: 15px; margin-top: 6px; }
.book-location { margin: 9px 0 0; padding: 12px; border: 1px solid #ccc; }
.book-location legend { padding: 0 5px; }
#book-add-swap-row small { display: block; margin: 5px 0; }
#book-success .book-primary { margin-top: 12px; }

.book-admin-main { width: min(1020px, 100%); margin-inline: auto; padding: 26px 22px 56px; }
.book-admin-main h1 { font-size: clamp(37px, 7vw, 65px); letter-spacing: -.05em; font-weight: 400; line-height: 1; margin: 0 0 14px; }
.book-admin-main h2 { font-size: 26px; letter-spacing: -.03em; font-weight: 400; margin: 22px 0 13px; }
.book-admin-main nav { display: flex; flex-wrap: wrap; gap: 16px; font: 14px/1.4 var(--book-mono); }
.book-admin-main nav a { text-underline-offset: 3px; }
.book-admin-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font: 14px/1.4 var(--book-mono); }
.book-admin-filters select { width: auto; }
.book-admin-list { display: grid; gap: 10px; }
.book-admin-card { border: 1px solid #bbb; background: #fff; padding: 15px; overflow-wrap: anywhere; }
.book-admin-card p, .book-admin-card li, #book-admin-status { margin: 5px 0; font: 14px/1.5 var(--book-mono); }
.book-admin-card ol { padding-inline-start: 20px; }
.book-admin-card details summary { cursor: pointer; font: 14px/1.5 var(--book-mono); padding: 5px 0; }
.book-blind-queue > summary { cursor: pointer; font: 14px/1.5 var(--book-mono); padding: 8px 0; }
.book-admin-card .book-secondary { margin: 7px 6px 0 0; }
.book-admin-editor .book-intro { margin-bottom: 8px; }
.book-admin-editor .book-form { padding-bottom: 6px; }
.book-admin-editor .book-credits-fields { display: grid; gap: 8px; border: 1px solid #ccc; margin: 7px 0 0; padding: 11px; }

@media (max-width: 560px) {
  .book-board-header { gap: 8px; }
  .book-board-header h1 { font-size: clamp(31px, 8.3vw, 48px); }
  .book-board-tools { gap: 4px; }
  .book-board-wrap { min-height: 340px; height: max(340px, calc(100dvh - 195px)); }
  .book-menu-toggle { right: 12px; bottom: 12px; }
  .book-camera-controls { bottom: 12px; left: 12px; }
  .book-panel { padding-inline: 19px; }
  .book-modal { padding-inline: 20px; }
  .book-admin-main { padding-inline: 15px; }
}
