:root {
  color-scheme: light;
  --bg: #3a3a3a;
  --ink: #f7ead1;
  --muted: #d8c9ab;
  --line: #d8d1c4;
  --panel: #fffdf8;
  --accent: #1f6f78;
  --accent-strong: #164c53;
  --gold: #9f7419;
  --danger: #884049;
  --shadow: 0 18px 45px rgba(49, 43, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(900px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 8px 0 16px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: rgba(245, 220, 164, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #f7e7bd;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.1;
  text-shadow:
    0 0 8px rgba(255, 245, 204, 0.38),
    0 3px 10px rgba(0, 0, 0, 0.72);
}

.lead {
  display: none;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, 104px);
  gap: 10px;
}

.summary div {
  min-height: 92px;
  border: 1px solid rgba(219, 181, 95, 0.45);
  border-radius: 8px;
  background: rgba(35, 18, 22, 0.72);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  display: grid;
  place-items: center;
  align-content: center;
}

.summary span {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.summary small {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.toolbar {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.filter-button {
  min-height: 40px;
  border: 1px solid rgba(221, 186, 112, 0.5);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(40, 24, 28, 0.82);
  color: #f7e9c7;
  cursor: pointer;
  font-weight: 800;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

.filter-button:hover,
.filter-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.filter-button.is-active {
  border-color: rgba(255, 226, 152, 0.95);
  background: rgba(93, 59, 24, 0.9);
  color: #fff;
  box-shadow:
    inset 0 0 10px rgba(255, 230, 158, 0.2),
    0 0 10px rgba(255, 225, 135, 0.22);
}

.rarity-tabs {
  gap: 12px;
}

.rarity-tabs .filter-button {
  min-width: 128px;
  min-height: 54px;
  border-width: 2px;
  border-radius: 18px;
  font-size: 1.45rem;
}

.rarity-tabs [data-filter-value="all"] {
  display: none;
}

.rarity-tabs [data-filter-value="unique"] {
  border-color: rgba(223, 171, 82, 0.82);
  background: rgba(79, 45, 18, 0.86);
}

.rarity-tabs [data-filter-value="rare"] {
  border-color: rgba(190, 194, 213, 0.78);
  background: rgba(70, 66, 83, 0.86);
}

.rarity-tabs [data-filter-value="normal"] {
  border-color: rgba(207, 132, 87, 0.78);
  background: rgba(95, 54, 39, 0.86);
}

.rarity-tabs [data-filter-value="cursed"] {
  border-color: rgba(176, 67, 75, 0.84);
  background: rgba(85, 31, 37, 0.9);
}

.status-tabs .filter-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.status-tabs [data-filter-value="owned"] {
  border-color: rgba(54, 104, 70, 0.68);
  background: rgba(24, 48, 34, 0.88);
  color: #c9e7cc;
}

.status-tabs [data-filter-value="owned"].is-active {
  border-color: rgba(82, 143, 94, 0.9);
  background: rgba(33, 83, 49, 0.95);
}

.status-tabs [data-filter-value="missing"] {
  border-color: rgba(108, 104, 112, 0.72);
  background: rgba(30, 29, 34, 0.88);
  color: #d8d5dc;
}

.status-tabs [data-filter-value="missing"].is-active {
  border-color: rgba(164, 158, 172, 0.95);
  background: rgba(55, 52, 62, 0.95);
}

.status-tabs [data-filter-value="favorite"].is-active {
  border-color: rgba(255, 105, 113, 0.9);
  background: rgba(93, 31, 38, 0.95);
}

.status-tabs [data-filter-value="favorite"] {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
}

.status-tabs [data-filter-value="favorite"]::before {
  width: 10px;
  height: 14px;
  background: #d73b46;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  content: "";
}

.search-box {
  width: min(100%, 450px);
  justify-self: center;
}

.search-box input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(221, 186, 112, 0.5);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(28, 18, 14, 0.72);
  color: #fff6dc;
  outline: none;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.18);
}

.search-box input::placeholder {
  color: rgba(247, 233, 199, 0.58);
}

.search-box input:focus {
  border-color: rgba(255, 226, 152, 0.95);
  box-shadow:
    inset 0 0 12px rgba(0, 0, 0, 0.18),
    0 0 10px rgba(255, 225, 135, 0.2);
}

.list-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  border-top: 1px solid rgba(223, 185, 111, 0.28);
  padding-top: 14px;
  margin-bottom: 14px;
}

.list-header h2 {
  margin-bottom: 0;
  font-size: 1.3rem;
}

.list-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.book-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-right: 72px;
}

.book-card {
  position: relative;
  width: min(100%, 450px);
  aspect-ratio: 600 / 152;
  min-height: 122px;
  border: 1px solid rgba(205, 160, 70, 0.72);
  border-radius: 8px;
  background: #241315;
  color: #f8efd4;
  padding: 14px 12px 12px 96px;
  box-shadow: 0 14px 30px rgba(33, 22, 17, 0.2);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 6px;
  overflow: visible;
}

.book-card::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background-image: var(--rarity-bg);
  background-position: center;
  background-size: 100% 100%;
  content: "";
  overflow: hidden;
}

.book-card::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(30, 12, 16, 0.08), rgba(30, 12, 16, 0.34) 56%, rgba(30, 12, 16, 0.7)),
    linear-gradient(180deg, rgba(255, 246, 205, 0.12), rgba(0, 0, 0, 0.12));
  content: "";
  pointer-events: none;
}

.book-card[data-rarity="unique"] {
  --rarity-bg: url("images/gold.png");
}

.book-card[data-rarity="rare"] {
  --rarity-bg: url("images/silver.png");
}

.book-card[data-rarity="normal"] {
  --rarity-bg: url("images/bronze.png");
}

.book-card[data-rarity="cursed"] {
  --rarity-bg: url("images/demerit.png");
}

.book-card.is-owned {
  border-color: rgba(90, 218, 204, 0.82);
}

.book-card.is-favorite {
  box-shadow:
    0 0 0 2px rgba(255, 226, 134, 0.5),
    0 16px 34px rgba(116, 78, 19, 0.28);
}

.book-card__top {
  position: relative;
  z-index: 2;
  display: none;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.rarity-mark {
  position: absolute;
  left: -112px;
  top: 0;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 238, 185, 0.2);
  display: none;
  place-items: center;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.42));
}

.rarity-image {
  width: 100%;
  height: 100%;
  object-fit: none;
  object-position: 11% 50%;
  transform: scale(1.7);
}

.rarity-label {
  display: none;
}

h3 {
  display: none;
}

.effect {
  color: #fff6dc;
  display: block;
  align-self: center;
  font-size: clamp(0.64rem, 1.18vw, 0.78rem);
  font-weight: 500;
  line-height: 1.18;
  margin: 0;
  position: relative;
  z-index: 2;
  text-shadow:
    0 0 8px rgba(255, 246, 218, 0.34),
    0 2px 6px rgba(0, 0, 0, 0.82);
}

.actions {
  z-index: 2;
  position: absolute;
  top: 0;
  bottom: 0;
  right: -76px;
  display: block;
  width: 58px;
}

.owned-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  min-height: 24px;
  border: 1px solid rgba(255, 236, 176, 0.72);
  border-radius: 6px;
  padding: 0 8px;
  background: rgba(28, 18, 14, 0.68);
  color: #fff1c9;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.owned-button.is-owned {
  background: rgba(31, 111, 120, 0.88);
  color: #fff;
}

.favorite-toggle {
  position: absolute;
  top: -1px;
  left: -50px;
  z-index: 4;
  width: 24px;
  min-height: 28px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.favorite-toggle input {
  position: absolute;
  inset: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.bookmark-icon {
  width: 14px;
  height: 20px;
  background: #8b8b8b;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.favorite-toggle input:checked + .bookmark-icon {
  background: #d73b46;
}

.favorite-toggle:has(input:checked) {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 10px, 1120px);
    padding-top: 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

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

  .filter-button {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.88rem;
  }

  .rarity-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .rarity-tabs .filter-button {
    min-width: 0;
    min-height: 42px;
    padding: 0 6px;
    font-size: clamp(0.9rem, 4.4vw, 1.18rem);
  }

  .actions {
    right: -64px;
    width: 52px;
  }

  .favorite-toggle {
    top: -1px;
    left: -43px;
    padding: 0;
  }

  .owned-button {
    width: 52px;
  }

  .book-card {
    width: min(100%, 450px);
    min-height: 118px;
    padding: 14px 10px 10px 86px;
    grid-template-columns: 1fr;
    gap: 6px;
    background-position: center;
  }

  .rarity-mark {
    left: -78px;
    top: 2px;
    width: 58px;
    height: 58px;
  }

  .rarity-image {
    object-position: 10% 50%;
    transform: scale(1.55);
  }

  .rarity-label {
    margin-bottom: 2px;
    font-size: 0.7rem;
  }

  h3 {
    display: none;
  }

  .effect {
    font-size: clamp(0.62rem, 2.58vw, 0.76rem);
    line-height: 1.16;
  }

  .owned-button,
  .favorite-toggle {
    min-height: 30px;
    font-size: 0.72rem;
  }
}

@media (max-width: 390px) {
  .app-shell {
    width: min(100% - 6px, 1120px);
  }

  .book-list {
    padding-right: 58px;
  }

  .book-card {
    padding-left: 76px;
  }

  .actions {
    right: -60px;
  }

  .rarity-mark {
    left: -70px;
    width: 52px;
    height: 52px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
