@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #ecf3f3;
  --panel: #ffffff;
  --line: #d7e3e3;
  --text: #0f172a;
  --muted: #52607a;
  --teal: #0f8f8a;
  --teal-deep: #0a7f7a;
  --mint: #34a6a2;
  --yellow: #facc15;
  --green: #047857;
  --red: #b91c1c;
  --shadow: 0 20px 44px rgba(9, 30, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #f8fdfd 0%, var(--bg) 45%, #e6efef 100%);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

.bg-blur {
  position: fixed;
  border-radius: 999px;
  filter: blur(64px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.bg-blur-a {
  width: 260px;
  height: 260px;
  background: #87d3d0;
  top: 40px;
  left: -60px;
}

.bg-blur-b {
  width: 320px;
  height: 320px;
  background: #7cc9c6;
  right: -80px;
  bottom: 40px;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.news-bell {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #cde1e1;
  background: #ffffff;
  color: #0f7f7a;
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.news-bell:hover {
  background: #f3fbfb;
}

.news-bell svg {
  width: 21px;
  height: 21px;
}

.news-bell-icon {
  font-size: 18px;
  line-height: 1;
}

.news-bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--mint) 0%, var(--teal) 52%, var(--teal-deep) 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(15, 143, 138, 0.24);
}

.brand-inner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  background: #eff3f2;
  border: 1px solid rgba(13, 85, 83, 0.16);
}

.half {
  display: block;
  width: 100%;
  height: 50%;
}

.half.top {
  background: #dce3e0;
}

.half.bottom {
  background: var(--yellow);
}

.brand-copy {
  line-height: 1.15;
}

.brand-name {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  background: linear-gradient(125deg, #0e4745 0%, #0f8f8a 52%, #0f7d79 100%);
  border-radius: 20px;
  color: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.hero-copy h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.hero-copy p {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.85);
  max-width: 560px;
}

.eyebrow {
  margin: 0;
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-stats {
  display: grid;
  gap: 10px;
}

.stat {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 10px 12px;
}

.stat p {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.stat h3 {
  margin: 6px 0 0;
  font-size: 26px;
}

.toolbar {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  background: var(--panel);
  border: 1px solid #cfe1e1;
  border-radius: 16px;
  padding: 10px;
  box-shadow: var(--shadow);
}

.search-mode-bar {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #cfe3e3;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.mode-btn {
  border: 0;
  background: transparent;
  color: #5c6f8b;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.mode-btn:hover {
  background: #eef7f7;
  color: #0f6f6b;
}

.mode-btn.active {
  background: linear-gradient(145deg, #0f8f8a 0%, #0f7d79 100%);
  color: #fff;
  box-shadow: 0 10px 18px rgba(15, 143, 138, 0.2);
}

.news-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, 92vw);
  max-height: min(78vh, 780px);
  overflow: auto;
  background: linear-gradient(160deg, #ffffff 0%, #f3fbff 100%);
  border: 1px solid #d9ecf7;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
  z-index: 60;
}

.news-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 50;
}

.news-close {
  border: 1px solid #c7dfdf;
  background: #fff;
  color: #0f7f7a;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
}

.news-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.news-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0f4f8a;
}

.news-action {
  border: 1px solid #c7dfdf;
  background: #e9f6f5;
  color: #0f7f7a;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.news-list {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.news-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 2px;
}

.news-item {
  border: 1px solid #d7eaf5;
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(11, 85, 126, 0.06);
}

.news-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.news-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #44c2bf, #0f8f8a);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.news-heading h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.news-date {
  margin: 0;
  font-size: 11px;
  color: #6c7c96;
}

.news-body {
  margin: 10px 0 0;
  color: #30445d;
  font-size: 14px;
  line-height: 1.5;
}

.news-item img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 10px;
}

.news-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #5c6f8b;
}

.news-reactions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.reaction-btn {
  border: 1px solid #d8e8f4;
  background: #f5fbff;
  color: #214a69;
  border-radius: 999px;
  min-height: 36px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.reaction-btn:hover {
  background: #ebf7ff;
}

.reaction-btn.active {
  background: #d8f0ff;
  border-color: #7dc7ee;
  color: #0f5481;
}

.reaction-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: #8da1c4;
}

.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid #d8e7e7;
  background: #f8fbfb;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search-wrap input {
  padding-left: 36px;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: #8fc8c5;
  box-shadow: 0 0 0 3px rgba(15, 143, 138, 0.14);
}

.clear-btn {
  border: 1px solid #c7dfdf;
  background: #e9f6f5;
  color: #0f7f7a;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.clear-btn:hover {
  background: #dff0ef;
}

.search-btn {
  border: 1px solid #0f8a85;
  background: linear-gradient(145deg, #0f8f8a 0%, #0f7d79 100%);
  color: #fff;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(15, 143, 138, 0.18);
}

.search-btn:hover {
  filter: brightness(1.02);
}

.results-head {
  margin: 14px 2px 0;
}

.results-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.external-books-panel {
  margin-top: 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.external-books-head {
  display: none;
}

.external-books-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f7d79;
}

.external-books-head h2 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.external-books-copy {
  margin: 8px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.google-open-all {
  border: 1px solid #bcdedc;
  background: linear-gradient(145deg, #0f8f8a 0%, #0f7d79 100%);
  color: #fff;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 14px 24px rgba(15, 143, 138, 0.18);
}

.google-open-all:hover {
  transform: translateY(-1px);
}

.external-books-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.ebook-card {
  border: 1px solid #d6e8e8;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.ebook-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.1);
  border-color: #add7d5;
}

.ebook-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.ebook-cover {
  position: relative;
  height: 270px;
  background: linear-gradient(155deg, #103a56 0%, #0f8f8a 56%, #8fd6d3 100%);
  overflow: hidden;
}

.ebook-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ebook-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ebook-pill {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ebook-content {
  padding: 14px;
}

.ebook-meta {
  margin: 8px 0 0;
  color: #61708a;
  font-size: 12px;
  line-height: 1.5;
}

.ebook-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ebook-source {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f7d79;
}

.ebook-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: #eff8f7;
  color: #0f6f6b;
  font-size: 12px;
  font-weight: 800;
}

.ebook-library-card {
  overflow: hidden;
}

.ebook-library-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.ebook-library-card .ebook-cover {
  height: 260px;
  background: linear-gradient(150deg, #d6efef 0%, #eaf6f6 60%, #dfefef 100%);
}

.ebook-library-card .ebook-placeholder {
  color: #5a8381;
}

.ebook-library-card .ebook-content {
  padding: 13px;
}

.ebook-library-card .meta {
  margin-top: 9px;
  font-size: 12px;
  color: #667593;
  overflow-wrap: anywhere;
}

.ebook-library-card .badge {
  margin-top: 10px;
}

.grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.books-pagination {
  margin-top: 14px;
  border: 1px solid #b8e1df;
  border-radius: 14px;
  background: linear-gradient(125deg, #e7f7f6 0%, #f2fbfb 55%, #e8f6f5 100%);
  padding: 14px;
  order: 99;
}

.books-pagination-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rows-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cde8e6;
  border-radius: 12px;
  padding: 4px;
}

.rows-label {
  font-size: 13px;
  font-weight: 700;
  color: #0f6b67;
  padding: 0 8px;
}

.rows-btn {
  border: 0;
  background: transparent;
  color: #0f6b67;
  border-radius: 9px;
  min-width: 36px;
  height: 34px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.rows-btn:hover {
  background: #dff2f1;
}

.rows-btn.active {
  background: linear-gradient(145deg, #0f8f8a 0%, #0f7d79 100%);
  color: #fff;
}

.books-total-text {
  margin: 0;
  font-size: 14px;
  color: #0f6b67;
  font-weight: 600;
}

.pages-nav {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.page-btn {
  border: 1px solid #c7e4e2;
  background: #ffffff;
  color: #0f7d79;
  border-radius: 10px;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.page-btn:hover {
  background: #eaf7f6;
}

.page-btn.active {
  background: linear-gradient(145deg, #0f8f8a 0%, #0f7d79 100%);
  color: #fff;
  border-color: #0f8a85;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-dots {
  color: #7aa8a5;
  font-size: 18px;
  padding: 0 4px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(9, 30, 42, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.1);
}

.cover {
  height: 260px;
  background: linear-gradient(150deg, #d6efef 0%, #eaf6f6 60%, #dfefef 100%);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #5a8381;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.content {
  padding: 13px;
}

.title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.author {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 9px;
  font-size: 12px;
  color: #667593;
  overflow-wrap: anywhere;
}

.badge {
  margin-top: 10px;
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.available {
  background: #d1fae5;
  color: var(--green);
}

.badge.out {
  background: #fee2e2;
  color: var(--red);
}

.loading,
.empty {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .topbar {
    margin-bottom: 10px;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

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

  .search-mode-bar {
    width: 100%;
    justify-content: stretch;
  }

  .mode-btn {
    flex: 1;
  }

  .external-books-head {
    flex-direction: column;
  }

  .clear-btn {
    height: 44px;
    min-width: 120px;
  }

  .search-btn {
    height: 44px;
    min-width: 120px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 18px 12px 30px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .brand-inner {
    width: 24px;
    height: 24px;
  }

  .hero-panel {
    border-radius: 16px;
    padding: 18px;
  }

  .news-list {
    grid-template-columns: 1fr;
  }

  .news-panel {
    width: min(94vw, 94vw);
    max-height: 82vh;
    padding: 12px;
  }

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

  .books-pagination-top {
    flex-direction: column;
    align-items: stretch;
  }

  .rows-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .rows-label {
    padding: 0 4px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 9px 10px;
  }

  .stat h3 {
    font-size: 20px;
  }

  .hero-copy p {
    font-size: 14px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    border-radius: 14px;
  }

  .search-mode-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .external-books-panel {
    margin-top: 12px;
  }

  .external-books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .ebook-cover {
    height: auto;
    aspect-ratio: 3 / 4;
  }

  .toolbar input,
  .toolbar select,
  .search-btn,
  .clear-btn {
    font-size: 16px;
    min-height: 46px;
  }

  .search-btn,
  .clear-btn {
    width: 100%;
  }

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

  .cover {
    height: auto;
    aspect-ratio: 3 / 4;
  }

  .card {
    border-radius: 14px;
  }

  .content {
    padding: 11px;
  }

  .title {
    font-size: 14px;
  }

  .author,
  .meta {
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .hero-panel {
    padding: 14px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

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

  .external-books-grid {
    grid-template-columns: 1fr;
  }
}
