:root {
  color-scheme: dark;
  --bg: #15151d;
  --bg-deep: #111119;
  --panel: #1b1b27;
  --panel-soft: rgba(28, 28, 40, 0.84);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f4f2f8;
  --muted: #8c8b98;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
  --shelf-photo: url("https://images.unsplash.com/photo-1600181982553-ce7d36051c01?auto=format&fit=crop&w=2400&q=78");
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 28%, rgba(44, 43, 58, 0.45), transparent 31rem),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  position: relative;
}

.home-view {
  position: relative;
  display: block;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 0 clamp(18px, 5vw, 72px);
}

.home-view.hidden,
.shelf-view.hidden {
  display: none;
}

.search-form {
  position: absolute;
  top: 40px;
  left: 50%;
  z-index: 10;
  width: min(100%, 842px);
  transform: translateX(-50%);
  transition:
    transform 190ms ease,
    filter 190ms ease;
}

.search-form:hover,
.search-form:focus-within {
  transform: translateX(-50%) scale(1.025);
  filter: brightness(1.06);
}

.search-form::after {
  content: "";
  display: none;
}

.search-submit {
  position: absolute;
  right: 17px;
  top: 50%;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 242, 248, 0.42);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  transform: translateY(-50%);
  transition:
    color 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.search-submit:hover,
.search-submit:focus-visible {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(244, 242, 248, 0.72);
  outline: none;
  transform: translateY(-50%) scale(1.06);
}

.search-input {
  width: 100%;
  height: 78px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  background: rgba(29, 29, 41, 0.92);
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  color: var(--text);
  padding: 0 74px 0 32px;
  font-size: clamp(18px, 2vw, 27px);
  font-weight: 650;
  letter-spacing: 0;
  transition:
    border-color 190ms ease,
    background 190ms ease,
    box-shadow 190ms ease;
}

.search-input::placeholder {
  color: rgba(142, 141, 154, 0.72);
}

.search-input:focus {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(32, 32, 46, 0.98);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.42),
    0 0 0 5px rgba(255, 255, 255, 0.035);
}

.category-grid {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: min(118vw, 1680px);
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: clamp(84px, 11vw, 210px);
  margin: 0;
  transform: translate(-50%, -50%) scale(0.75);
  transform-origin: center center;
}

.category-card {
  appearance: none;
  position: relative;
  display: grid;
  grid-template-rows: clamp(360px, 52vh, 560px) auto;
  width: min(100%, 420px);
  min-height: 0;
  justify-self: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  padding: 0;
  transition:
    transform 190ms ease,
    filter 190ms ease;
}

.category-card:hover,
.category-card:focus-visible {
  transform: translateY(-8px) scale(1.035);
  filter: brightness(1.06);
}

.cover-fan {
  position: relative;
  display: block;
  min-height: 0;
  overflow: visible;
}

.category-title {
  display: grid;
  position: relative;
  z-index: 2;
  place-items: center;
  min-width: 0;
  padding: 18px 12px 0;
  color: #f5f2fb;
  font-size: clamp(36px, 3.2vw, 58px);
  font-weight: 560;
  line-height: 1.1;
  text-align: center;
  letter-spacing: 0;
  text-shadow: 0 9px 28px rgba(0, 0, 0, 0.45);
}

.mini-cover {
  --x: 0px;
  --y: 0px;
  --rotation: 0deg;
  --scale: 1;
  position: absolute;
  left: 50%;
  top: 54%;
  width: clamp(230px, 19vw, 340px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%) translate(var(--x), var(--y)) rotate(var(--rotation)) scale(var(--scale));
  transform-origin: center bottom;
  transition:
    transform 240ms ease,
    opacity 220ms ease,
    filter 220ms ease;
  z-index: var(--z, 1);
}

.category-card[data-category="cd"] .mini-cover {
  width: clamp(300px, 25vw, 455px);
  aspect-ratio: 1;
}

.cover-count-1 .mini-cover:nth-child(1) {
  --z: 3;
}

.cover-count-2 .mini-cover:nth-child(1) {
  --x: 52px;
  --rotation: 5deg;
  --z: 3;
}

.cover-count-2 .mini-cover:nth-child(2) {
  --x: -52px;
  --rotation: -6deg;
  --scale: 0.94;
  --z: 2;
  filter: brightness(0.88);
}

.cover-count-3 .mini-cover:nth-child(1) {
  --z: 3;
}

.cover-count-3 .mini-cover:nth-child(2) {
  --x: -82px;
  --rotation: -8deg;
  --scale: 0.9;
  --z: 2;
  filter: brightness(0.88);
}

.cover-count-3 .mini-cover:nth-child(3) {
  --x: 82px;
  --rotation: 8deg;
  --scale: 0.9;
  --z: 1;
  filter: brightness(0.8);
}

.category-card:hover .cover-count-2 .mini-cover:nth-child(1),
.category-card:focus-visible .cover-count-2 .mini-cover:nth-child(1) {
  --x: 72px;
  --rotation: 7deg;
}

.category-card:hover .cover-count-2 .mini-cover:nth-child(2),
.category-card:focus-visible .cover-count-2 .mini-cover:nth-child(2) {
  --x: -72px;
  --rotation: -8deg;
}

.category-card:hover .cover-count-3 .mini-cover:nth-child(2),
.category-card:focus-visible .cover-count-3 .mini-cover:nth-child(2) {
  --x: -116px;
  --rotation: -11deg;
}

.category-card:hover .cover-count-3 .mini-cover:nth-child(3),
.category-card:focus-visible .cover-count-3 .mini-cover:nth-child(3) {
  --x: 116px;
  --rotation: 11deg;
}

.cover-shell {
  position: relative;
  overflow: hidden;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(106, 108, 132, 0.36), rgba(23, 23, 34, 0.72)),
    #171720;
  box-shadow:
    0 34px 82px rgba(0, 0, 0, 0.46),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.cover-shell.mini-cover {
  position: absolute;
}

.cover-shell.cd {
  border-radius: 7px;
}

.cover-shell img,
.result-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  color: rgba(245, 242, 251, 0.58);
  font-size: 13px;
  font-weight: 760;
  text-align: center;
}

.category-card .cover-placeholder {
  color: transparent;
}

.shelf-view {
  min-height: 100vh;
  padding: 24px clamp(18px, 2vw, 34px) 64px;
  background:
    radial-gradient(circle at 50% 28%, rgba(44, 43, 58, 0.45), transparent 31rem),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

.shelf-head {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 14px;
  margin: 0 0 26px;
}

.round-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(29, 29, 41, 0.78);
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.round-button:hover {
  transform: scale(1.06);
  border-color: var(--line-strong);
  background: rgba(42, 42, 58, 0.88);
}

.shelf-head h1 {
  margin: 0;
  font-size: clamp(25px, 2.2vw, 34px);
  font-weight: 680;
  letter-spacing: 0;
}

.shelf-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.shelf-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(243px, 243px));
  gap: 34px 24px;
  align-items: start;
  justify-content: start;
  margin: 0;
  padding: 0 0 30px;
}

.item-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
}

.item-cover {
  width: 243px;
  aspect-ratio: 3 / 4;
  transition:
    transform 210ms ease,
    box-shadow 210ms ease;
}

.shelf-grid.cd .item-cover {
  aspect-ratio: 1;
}

.item-card:hover .item-cover,
.item-card:focus-within .item-cover {
  transform: translateY(-4px) scale(1.035);
}

.item-title {
  width: 243px;
  min-height: 0;
  margin: 0;
  color: #d9d7df;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.38;
  text-align: center;
  overflow-wrap: anywhere;
}

.item-meta {
  width: 243px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

.delete-button {
  position: absolute;
  top: -8px;
  right: calc(50% - min(50%, 81px) - 8px);
  z-index: 2;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(29, 29, 41, 0.92);
  color: #f3c5c5;
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.item-card:hover .delete-button,
.item-card:focus-within .delete-button {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 180px;
  place-items: start;
  color: var(--muted);
  background: transparent;
}

.search-panel {
  position: fixed;
  top: 126px;
  left: 50%;
  z-index: 40;
  display: grid;
  width: min(calc(100% - 28px), 920px);
  max-height: calc(100vh - 148px);
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(22, 22, 31, 0.97);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px) scale(0.985);
  transition:
    opacity 190ms ease,
    transform 190ms ease;
}

.search-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-kicker {
  margin: 0 0 4px;
  color: #b9b7c7;
  font-size: 12px;
  font-weight: 760;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.warning-line {
  display: none;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  color: #f0c4c4;
  font-size: 13px;
}

.warning-line.visible {
  display: block;
}

.result-list {
  overflow: auto;
  min-height: 110px;
}

.result-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.result-thumb {
  position: relative;
  width: 72px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.result-row[data-category="cd"] .result-thumb {
  aspect-ratio: 1;
}

.result-title {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 720;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.result-meta,
.result-description {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.result-description {
  color: #777684;
}

.result-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 126px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #d4d2df;
  font-size: 12px;
  white-space: normal;
  text-align: center;
}

.import-button {
  height: 34px;
  border: 1px solid rgba(168, 184, 218, 0.38);
  border-radius: 999px;
  background: rgba(168, 184, 218, 0.12);
  color: #dfe6fb;
  cursor: pointer;
  padding: 0 14px;
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.import-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(168, 184, 218, 0.2);
}

.import-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.loading-state,
.no-results {
  display: grid;
  min-height: 150px;
  place-items: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(440px, calc(100% - 30px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(24, 24, 34, 0.94);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .home-view {
    padding: 0 18px;
  }

  .search-input {
    height: 66px;
  }

  .category-grid {
    gap: clamp(18px, 5vw, 42px);
  }

  .category-card {
    width: min(100%, 260px);
  }
}

@media (max-width: 760px) {
  .home-view {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 22px 18px 44px;
  }

  .search-form {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin: 0 auto;
  }

  .search-form:hover,
  .search-form:focus-within {
    transform: scale(1.015);
  }

  .category-grid {
    position: relative;
    left: auto;
    top: auto;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 44px;
    transform: none;
  }

  .category-card {
    width: min(100%, 290px);
    grid-template-rows: 320px auto;
  }

  .shelf-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 170px));
    gap: 28px 18px;
  }

  .item-cover,
  .item-title,
  .item-meta {
    width: 170px;
  }

  .search-panel {
    top: 100px;
    max-height: calc(100vh - 118px);
  }

  .result-row {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .result-thumb {
    width: 62px;
  }

  .result-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-items: start;
  }

  .badge {
    max-width: none;
  }
}
