:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #647067;
  --paper: #f8f5ed;
  --surface: #fffdf8;
  --line: #ded8ca;
  --accent: #7f3f2d;
  --accent-strong: #633022;
  --teal: #315f5b;
  --gold: #9b7a3f;
  --green: #426a3c;
  --shadow: 0 24px 60px rgba(52, 42, 24, 0.16);
  --radius: 8px;
}

body.dark {
  color-scheme: dark;
  --ink: #f4efe3;
  --muted: #b8b0a3;
  --paper: #151815;
  --surface: #20241f;
  --line: #353a32;
  --accent: #e6774e;
  --accent-strong: #ffa071;
  --teal: #61b7af;
  --gold: #e0ad55;
  --green: #83b779;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(49, 95, 91, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(127, 63, 45, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 64px 64px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
  gap: 16px;
}

.brand,
.topbar-actions,
.dashboard,
.controls,
.section-heading,
.drawer-actions,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 28px;
  height: 34px;
  border-radius: 4px 2px 2px 4px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  box-shadow: inset 5px 0 0 rgba(255, 255, 255, 0.28);
}

.topbar-actions {
  gap: 10px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.surprise-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 22px;
}

.theme-glyph {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.primary-button,
.secondary-button,
.danger-button,
.surprise-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  color: #fffdf8;
  border-color: var(--accent);
  background: var(--accent);
}

.secondary-button {
  background: transparent;
}

.danger-button {
  color: #fffdf8;
  border-color: #9b2f26;
  background: #9b2f26;
}

.library-board {
  display: block;
  min-height: 0;
  padding: 16px 0 22px;
}

.board-copy h1 {
  max-width: 760px;
  margin: 6px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 5vw, 4.15rem);
  line-height: 1;
  letter-spacing: 0;
  text-wrap: balance;
}

.board-copy p:last-child {
  max-width: 560px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.text-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.text-link:hover {
  color: var(--ink);
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.feature-stack {
  display: none;
}

.feature-book {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border-radius: 6px;
  color: #fffdf8;
  box-shadow: 0 18px 45px rgba(52, 42, 24, 0.14);
  padding: 24px;
  isolation: isolate;
}

.feature-book::before {
  content: "";
  position: absolute;
  inset: 0 0 0 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.feature-book::after {
  content: "";
  position: absolute;
  inset: auto 18px 18px auto;
  width: 92px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.32);
  transform: rotate(45deg);
  z-index: -1;
}

.feature-book span,
.feature-book small {
  font-weight: 800;
  opacity: 0.82;
}

.feature-book strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1.05;
}

.feature-book-large {
  inset: 0 auto auto 8%;
  width: 60%;
  height: 390px;
  background: linear-gradient(145deg, #683523, #924c35 56%, #b27f3c);
  transform: rotate(-2deg);
}

.feature-book-medium {
  right: 0;
  bottom: 16px;
  width: 46%;
  height: 310px;
  background: linear-gradient(145deg, #284d4a, #315f5b 56%, #6f9b8e);
  transform: rotate(4deg);
}

.feature-book-small {
  left: 0;
  bottom: 36px;
  width: 40%;
  height: 250px;
  background: linear-gradient(145deg, #263d24, #426a3c 58%, #9fbd72);
  transform: rotate(2deg);
}

.dashboard {
  display: none;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 12px;
  margin: 0 0 18px;
}

.stat,
.surprise-button,
.controls,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  box-shadow: 0 12px 30px rgba(52, 42, 24, 0.08);
  backdrop-filter: blur(14px);
}

.stat {
  min-height: 92px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 42px;
  height: 6px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.stat span {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1;
}

.stat strong {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
}

.surprise-button {
  min-height: 92px;
  padding: 0 22px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px 180px;
  gap: 12px;
  padding: 12px;
  margin-bottom: 24px;
}

.mode-switch {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
    var(--surface);
}

.mode-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  letter-spacing: 0.02em;
  transition:
    color 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.mode-button::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 10px;
  margin-right: 9px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.75;
}

.mode-button.active {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 34%, transparent);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search,
select,
dialog input,
dialog textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

select {
  width: 100%;
}

.shelves {
  padding-bottom: 80px;
}

.section-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2,
dialog h2,
.drawer h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
}

.section-heading > span {
  color: var(--muted);
  font-weight: 800;
}

.shelf-groups {
  display: grid;
  gap: 32px;
}

.shelf-group {
  display: grid;
  gap: 10px;
}

.shelf-label {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-inline: 4px;
}

.shelf-label span {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
}

.shelf-label small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.shelf-wall {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 22px 11px;
  min-height: 260px;
  padding: 42px 20px 66px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--shelf-accent, var(--accent)) 8%, transparent), transparent 34%),
    linear-gradient(180deg, transparent calc(100% - 44px), rgba(95, 61, 34, 0.12) calc(100% - 44px)),
    color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 18px 48px rgba(52, 42, 24, 0.09);
}

.shelf-wall::before,
.shelf-wall::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 1px;
  background: color-mix(in srgb, var(--line) 64%, var(--shelf-accent, var(--accent)));
}

.shelf-wall::before {
  top: 22px;
}

.shelf-wall::after {
  bottom: 44px;
  height: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  background: color-mix(in srgb, var(--gold) 16%, var(--surface));
}

.book-card:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent);
  outline-offset: 2px;
}

.book-spine {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: var(--spine-w);
  height: var(--spine-h);
  min-width: 62px;
  max-width: 98px;
  min-height: 212px;
  margin-top: calc(314px - var(--spine-h));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px 5px 2px 2px;
  color: #fffdf8;
  background: var(--cover, linear-gradient(135deg, var(--accent), var(--gold)));
  box-shadow:
    inset 10px 0 13px rgba(255, 255, 255, 0.13),
    inset -13px 0 18px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 14px 24px rgba(52, 42, 24, 0.18);
  text-align: left;
  transform: rotate(var(--tilt));
  transform-origin: bottom center;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    translate 180ms ease;
  isolation: isolate;
}

.book-spine:hover,
.book-spine:focus-visible {
  box-shadow:
    inset 10px 0 13px rgba(255, 255, 255, 0.16),
    inset -13px 0 18px rgba(0, 0, 0, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 22px 36px rgba(52, 42, 24, 0.24);
  translate: 0 -10px;
  transform: rotate(0deg);
  z-index: 3;
}

.book-spine::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), transparent 14%, transparent 82%, rgba(0, 0, 0, 0.16)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.13), transparent 24%);
  pointer-events: none;
}

.book-spine::after {
  content: none;
}

.spine-band {
  width: 100%;
  min-height: 32px;
  padding: 0;
  border-bottom: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
}

.spine-title {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--spine-h) - 78px);
  max-width: 236px;
  min-width: 118px;
  height: 28px;
  overflow: hidden;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.16);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: normal;
  writing-mode: horizontal-tb;
  color: #fffaf1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  z-index: 1;
}

.spine-title-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-lines-2 .spine-title,
.title-lines-3 .spine-title {
  padding: 0 14px;
  white-space: normal;
  text-overflow: clip;
}

.title-lines-2 .spine-title-text {
  display: -webkit-box;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.title-lines-2 .spine-title {
  height: 40px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.08;
}

.spine-author {
  display: none;
  width: 100%;
  overflow: hidden;
  padding: 9px 6px 30px;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  opacity: 0.86;
}

.book-spine:hover .spine-title,
.book-spine:focus-visible .spine-title {
  background: rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.book-pile {
  position: relative;
  display: block;
  width: 326px;
  height: 250px;
  margin: 0 18px;
  align-self: flex-end;
  filter: drop-shadow(0 16px 24px rgba(52, 42, 24, 0.14));
}

.horizontal-book {
  position: absolute;
  left: var(--pile-x);
  bottom: var(--pile-offset);
  display: flex;
  align-items: center;
  width: var(--pile-w);
  height: 56px;
  justify-content: center;
  padding: 0 26px;
  border: 1px solid rgba(50, 35, 20, 0.18);
  border-radius: 4px;
  color: #fffaf1;
  background: var(--cover);
  box-shadow:
    inset 0 8px 12px rgba(255, 255, 255, 0.13),
    inset 0 -10px 14px rgba(0, 0, 0, 0.2),
    inset 1px 0 0 rgba(255, 255, 255, 0.16),
    0 11px 18px rgba(52, 42, 24, 0.18);
  text-align: left;
  transform: rotate(var(--pile-tilt));
  transition:
    translate 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.horizontal-book::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 34%, rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.032) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.horizontal-book::after {
  content: "";
  position: absolute;
  inset: 11px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.horizontal-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  width: calc(var(--pile-w) - 42px);
  max-width: 256px;
  height: 28px;
  overflow: hidden;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
}

.horizontal-title-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horizontal-lines-2 .horizontal-title {
  height: 38px;
  border-radius: 18px;
  font-size: 0.98rem;
  line-height: 1.05;
}

.horizontal-lines-2 .horizontal-title-text {
  display: -webkit-box;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.horizontal-book:hover,
.horizontal-book:focus-visible {
  translate: 12px -4px;
  transform: rotate(0deg);
  box-shadow:
    inset 0 8px 12px rgba(255, 255, 255, 0.16),
    inset 0 -10px 14px rgba(0, 0, 0, 0.17),
    inset 1px 0 0 rgba(255, 255, 255, 0.2),
    0 18px 30px rgba(52, 42, 24, 0.24);
  z-index: 4;
}

.spine-card {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  display: grid;
  width: 270px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(6px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
  z-index: 5;
}

.book-spine:hover .spine-card,
.book-spine:focus-visible .spine-card {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.spine-card::after {
  content: "";
  position: absolute;
  left: calc(50% - 7px);
  bottom: -8px;
  width: 14px;
  height: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transform: rotate(45deg);
}

.spine-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.1;
}

.spine-card small,
.spine-card em {
  margin-top: 6px;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.spine-card span:last-child {
  margin-top: 12px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.45;
}

/*
.book-cover::before {
  content: "";
  position: absolute;
  inset: 0 0 0 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.book-cover span {
  position: relative;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.book-initials {
  position: relative;
  align-self: flex-end;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.8rem;
  line-height: 0.8;
  opacity: 0.28;
}

.book-info {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.book-info h3 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.34rem;
  line-height: 1.12;
}

.book-info p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.book-info .notes {
  margin-top: 14px;
  color: var(--ink);
}

.rec-label {
  display: block;
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.genre-pill {
  display: inline-flex;
  max-width: 100%;
  margin-top: 14px;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  font-size: 0.76rem;
  font-weight: 900;
}
*/

.empty-state {
  padding: 36px;
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 10;
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  width: min(440px, 100%);
  height: 100%;
  overflow: auto;
  padding: 56px 28px 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(24px);
  transition: transform 180ms ease;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.close-button {
  position: absolute;
  top: 22px;
  right: 24px;
}

.drawer-author {
  color: var(--muted);
  font-weight: 800;
}

.drawer-subhead {
  margin: 26px 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.drawer p:not(.eyebrow):not(.drawer-author) {
  line-height: 1.7;
}

.drawer-actions {
  gap: 10px;
  margin-top: 24px;
}

dialog {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-dialog {
  width: min(1180px, calc(100% - 24px));
  max-height: min(860px, calc(100vh - 24px));
}

.admin-panel {
  display: grid;
  gap: 24px;
}

.admin-login {
  max-width: 460px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--paper));
}

.admin-content {
  display: grid;
  gap: 24px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 9%, var(--surface));
}

.admin-toolbar span,
.admin-message {
  color: var(--muted);
  font-weight: 900;
}

.admin-message {
  min-height: 1.2em;
  margin: 0;
}

.admin-section {
  display: grid;
  gap: 10px;
}

.admin-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-section h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
}

.admin-section-heading span {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.admin-table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.admin-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: var(--surface);
}

.admin-table th,
.admin-table td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-size: 0.86rem;
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--accent-strong);
  background: var(--surface);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-table input,
.admin-table textarea {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 82%, var(--paper));
  padding: 7px;
}

.admin-table textarea {
  min-height: 58px;
  resize: vertical;
}

.admin-actions {
  display: flex;
  gap: 8px;
  min-width: 170px;
}

.admin-empty {
  color: var(--muted);
  font-weight: 800;
}

.category-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.category-fields legend {
  padding: 0 6px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.category-fields label {
  align-content: start;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

form {
  display: grid;
  gap: 14px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

dialog input,
dialog textarea {
  width: 100%;
  padding: 10px 12px;
}

dialog textarea {
  resize: vertical;
}

.dialog-actions {
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

@media (max-width: 850px) {
  .library-board,
  .controls,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .library-board {
    min-height: auto;
    padding-bottom: 28px;
  }

  .feature-stack {
    min-height: 390px;
  }

  .dashboard {
    margin-top: 0;
  }

  .surprise-button {
    min-height: 58px;
  }

  .category-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    align-items: flex-start;
  }

  .brand span:last-child {
    max-width: 120px;
  }

  .primary-button {
    padding: 0 12px;
  }

  .board-copy h1 {
    font-size: clamp(2rem, 12vw, 2.75rem);
  }

  .controls {
    gap: 10px;
    padding: 10px;
  }

  .mode-switch {
    gap: 5px;
    padding: 5px;
  }

  .mode-button {
    min-height: 42px;
    font-size: 0.92rem;
  }

  .mode-button::before {
    width: 14px;
    margin-right: 6px;
  }

  .section-heading,
  .shelf-label {
    align-items: flex-start;
  }

  .section-heading > span,
  .shelf-label small {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .shelf-label span {
    min-width: 0;
    font-size: clamp(1.35rem, 8vw, 1.8rem);
  }

  .feature-book-large {
    width: 68%;
    height: 330px;
  }

  .feature-book-medium {
    width: 54%;
    height: 260px;
  }

  .feature-book-small {
    width: 46%;
    height: 220px;
  }

  .shelf-wall {
    gap: 16px 8px;
    justify-content: center;
    padding-inline: 10px;
    overflow: hidden;
  }

  .book-pile {
    width: min(100%, 300px);
    height: 235px;
    margin-inline: 0;
  }

  .horizontal-book {
    width: min(var(--pile-w), calc(100vw - 76px));
    height: 52px;
  }

  .horizontal-title {
    width: calc(min(var(--pile-w), calc(100vw - 76px)) - 42px);
    font-size: 1rem;
  }

  .spine-card {
    display: none;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}
