:root {
  --bg: #f3f2ef;
  --ink: #11101a;
  --panel: #fffefb;
  --line: #d9d3c7;
  --accent: #c0392b;
  --accent-soft: #f8d7d3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #fff8e1, transparent 40%),
    radial-gradient(circle at 80% 90%, #e6f4ff, transparent 30%), var(--bg);
  min-height: 100vh;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}

.top-nav {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-nav-left {
  display: flex;
  gap: 8px;
}

.top-nav .btn {
  margin-top: 0;
}

.nav-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.nav-link.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  padding: 18px;
}

.auth-status {
  min-height: 20px;
  color: var(--accent);
  font-weight: 600;
  margin: 6px 0 8px;
}

.auth-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.auth-form h2 {
  margin: 0;
  font-size: 20px;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.search-panel {
  padding: 18px;
  position: sticky;
  top: 16px;
  height: fit-content;
}

h1 {
  margin: 0;
  letter-spacing: 0.02em;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-head .btn {
  margin-top: 0;
}

.subtitle {
  margin: 4px 0 14px;
  opacity: 0.75;
}

input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
}

.results {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 70vh;
  overflow: auto;
}

.results li {
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.results li:hover,
.results li.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.result-title {
  flex: 1;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fav-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.fav-btn.active {
  color: #b51616;
  border-color: #b51616;
  background: #ffe5e5;
}

.favorite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.favorite-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.favorite-cover {
  width: 42px;
  height: 62px;
  border-radius: 6px;
  object-fit: cover;
  background: #ececec;
}

.detail-panel {
  padding: 18px;
}

.placeholder {
  opacity: 0.7;
}

.hidden {
  display: none !important;
}

.hero {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.hero img {
  width: 120px;
  height: 170px;
  object-fit: cover;
  border-radius: 8px;
  background: #ececec;
}

h2 {
  margin: 0;
}

#meta {
  margin-top: 6px;
  opacity: 0.75;
}

.json-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.json-header .btn {
  margin-top: 0;
}

.btn {
  margin-top: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

pre {
  margin: 0;
  background: #17181c;
  color: #eceef3;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
  max-height: 65vh;
  font-size: 12px;
  line-height: 1.45;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 50;
}

.modal-card {
  width: min(960px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

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

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-actions .btn {
  margin-top: 0;
}

.volumes-list {
  display: grid;
  gap: 8px;
}

.volume-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
}

.volume-main {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: start;
  gap: 10px;
}

.volume-info {
  min-width: 0;
}

.volume-cover {
  width: 72px;
  height: 102px;
  border-radius: 8px;
  object-fit: cover;
  background: #ececec;
  margin: 0;
}

.volume-card h4 {
  margin: 0 0 2px;
  font-size: 22px;
  line-height: 1.15;
}

.volume-card .subtitle {
  margin: 0 0 6px;
}

.volume-card pre {
  max-height: 220px;
  margin-top: 6px;
}

.volume-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.volume-actions .btn {
  margin-top: 0;
  padding: 6px 10px;
}

.volume-track-actions {
  margin: 8px 0 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn.secondary.is-on {
  border-color: #2b8f3a;
  color: #1f6f2c;
  background: #e6f8e9;
}

#volumeDetailsModal {
  z-index: 60;
}

#volumeDetailsJson {
  max-height: 70vh;
}

.volume-details-cover {
  width: 140px;
  height: 200px;
  border-radius: 10px;
  object-fit: cover;
  background: #ececec;
  margin-bottom: 10px;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.fact-row {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}

.description-box {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.link-btn {
  margin-top: 0;
  text-decoration: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .search-panel {
    position: static;
  }
}
