@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Literata:opsz,wght@7..72,400;7..72,500;7..72,600&display=swap');

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8faff;
  --line: #e5e9f2;
  --text: #182033;
  --muted: #6b7285;
  --primary: #5b5ce2;
  --primary-dark: #4647c5;
  --primary-soft: #eeefff;
  --accent: #22b8a7;
  --accent-soft: #e6faf7;
  --warning: #f59e0b;
  --danger: #e25555;
  --success: #2e9b68;
  --shadow-sm: 0 2px 10px rgba(24, 32, 51, .05);
  --shadow-md: 0 12px 32px rgba(24, 32, 51, .09);
  --shadow-lg: 0 20px 55px rgba(24, 32, 51, .13);
  --radius: 16px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(91,92,226,.09), transparent 28rem),
    radial-gradient(circle at 92% 8%, rgba(34,184,167,.07), transparent 25rem),
    var(--bg);
}

body::selection {
  background: rgba(91,92,226,.18);
}

h1, h2, h3, .brand, .btn, .book-cta, .page-tile,
.account-nav, .gdz-badge, .gdz-seq {
  font-family: 'Manrope', system-ui, sans-serif;
}

h1, h2, h3 {
  color: var(--text);
  line-height: 1.18;
  letter-spacing: -.025em;
  margin: 0 0 .55em;
}

h1 { font-size: clamp(2rem, 4vw, 3.15rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 750; }

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

button, input, textarea { font: inherit; }

.wrap {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 15px 0;
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(229,233,242,.9);
  box-shadow: 0 4px 24px rgba(24,32,51,.045);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -.04em;
}

.brand-link {
  color: var(--text);
  text-decoration: none;
}

.brand-dot { color: var(--primary); }

.site-header .tagline {
  color: var(--muted);
  font-size: .72rem;
  margin: 1px 0 0;
  letter-spacing: .01em;
}

.account-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.account-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 9px;
  transition: .18s ease;
}

.account-nav a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

/* Hero */
.hero {
  padding: 70px 0 34px;
}

.hero h1 {
  max-width: 760px;
  margin-bottom: 15px;
}

.hero p {
  max-width: 650px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.75;
  margin: 0;
}

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
  padding: 16px 0 70px;
}

.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.book-card:hover {
  transform: translateY(-5px);
  border-color: #d7daf4;
  box-shadow: var(--shadow-lg);
}

.book-card-top {
  display: flex;
  gap: 17px;
  padding: 18px;
  flex: 1;
}

.book-cover-wrap {
  position: relative;
  flex-shrink: 0;
  width: 88px;
  min-height: 124px;
  border-radius: 11px;
  overflow: hidden;
  background: linear-gradient(145deg, #5b5ce2, #3536a7);
  box-shadow: 0 8px 20px rgba(70,71,197,.2);
}

.book-cover-wrap .spine { display: none; }

.book-cover {
  width: 100%;
  height: 100%;
  min-height: 124px;
  object-fit: cover;
  display: block;
  padding: 0;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary), #3839a8);
}

.book-cover.placeholder {
  min-height: 124px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: .72rem;
  line-height: 1.25;
  text-align: center;
  padding: 12px;
  background: linear-gradient(145deg, var(--primary), #3839a8);
}

.book-details {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.book-details h3 {
  font-size: 1rem;
  margin: 2px 0 10px;
  line-height: 1.35;
}

.book-attrs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.book-attrs .attr {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: .76rem;
  line-height: 1.4;
}

.book-attrs dt {
  color: var(--muted);
  font-weight: 700;
}

.book-attrs dd {
  margin: 0;
  color: var(--text);
}

.book-attrs .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #dddfff;
  font-size: .7rem;
  font-weight: 800;
}

.book-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 17px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  transition: background .2s ease;
}

.book-card:hover .book-cta { background: var(--primary-soft); }

.book-cta .cta-text {
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 800;
}

.book-cta .cta-price {
  color: var(--text);
  font-size: .8rem;
  font-weight: 800;
}

/* Page list */
.page-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 10px;
  padding: 22px 0 55px;
}

.page-tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transition: .18s ease;
}

.page-tile:hover {
  color: var(--primary);
  border-color: #cfd1f6;
  background: var(--primary-soft);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(91,92,226,.1);
}

.page-tile.locked {
  color: #8b91a3;
  background: #f9fafc;
}

.page-tile.locked:hover {
  color: #696f82;
  background: #f1f3f8;
}

.lock-icon {
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 10px;
  height: 10px;
  color: #a1a7b6;
}

.unlock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin: 22px 0 0;
  padding: 18px 20px;
  background: linear-gradient(135deg, #f1f1ff, #fff);
  border: 1px solid #dddfff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.unlock-banner p { margin: 0; color: var(--muted); }
.unlock-banner strong { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 17px;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 7px 16px rgba(91,92,226,.22);
}

.btn-primary:hover {
  color: #fff;
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(91,92,226,.28);
}

.btn-outline {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  color: var(--primary);
  border-color: #cfd1f6;
  background: var(--primary-soft);
}

/* Checkout / forms */
.checkout-box,
.login-box {
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 30px;
  margin: 28px 0 70px;
}

.login-box { margin: 58px auto 70px; }

.checkout-box .price-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 15px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.checkout-box .price-line .sum {
  color: var(--primary);
  font-size: 1.65rem;
  font-weight: 800;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: .76rem;
  font-weight: 800;
}

.field input,
.admin-panel textarea {
  width: 100%;
  padding: 11px 13px;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: .18s ease;
}

.field input:focus,
.admin-panel textarea:focus {
  border-color: #aeb0f0;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(91,92,226,.1);
}

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 100px; }

.test-mode-note,
.gdz-note {
  background: #fff9eb;
  border: 1px solid #f5dfae;
  color: #7c5a1b;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .84rem;
  margin-bottom: 18px;
}

.test-mode-note code {
  background: #fff;
  border: 1px solid #f0d8a8;
  padding: 1px 5px;
  border-radius: 5px;
}

.error-box {
  background: #fff0f0;
  border: 1px solid #f1bcbc;
  color: #a53f3f;
  padding: 11px 14px;
  border-radius: 11px;
  margin-bottom: 16px;
  font-size: .86rem;
}

.notice {
  background: var(--accent-soft);
  border: 1px solid #bcece5;
  color: #207c70;
  padding: 11px 14px;
  border-radius: 11px;
  margin-bottom: 18px;
  font-size: .84rem;
}

.notice-warn {
  background: #fff9eb;
  border-color: #f5dfae;
  color: #7c5a1b;
}

/* Reading page */
.meta {
  font-size: .84rem;
  margin-top: -5px;
}

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0 55px;
}

.page-content {
  margin: 26px 0 18px;
  padding: 34px 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-family: 'Literata', Georgia, serif;
  font-size: 1.03rem;
  line-height: 1.8;
}

.page-content h2,
.page-content h3 {
  font-family: 'Manrope', system-ui, sans-serif;
}

.page-content h2 { margin-top: 1.45em; font-size: 1.35rem; }
.page-content h3 { margin-top: 1.25em; font-size: 1.08rem; }
.page-content p { margin: 0 0 1em; }
.page-content ul, .page-content ol { margin: 0 0 1em; padding-left: 1.35em; }
.page-content li { margin-bottom: .35em; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover { color: var(--primary); }

.icon-chevron {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-radius: 1px;
  transform: rotate(225deg);
  flex-shrink: 0;
}

.icon-chevron.next { transform: rotate(45deg); }

.nav-btn { display: inline-flex; align-items: center; gap: 8px; }

/* Footer */
footer {
  margin-top: 20px;
  padding: 25px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
}

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 25px 0 65px;
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.admin-panel h2 { font-size: 1.05rem; }
.admin-panel textarea { min-height: 160px; resize: vertical; font-family: 'Literata', serif; }

.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
}

.admin-top h1 { margin: 0; }
.admin-top .btn { min-height: 38px; padding: 8px 13px; font-size: .78rem; }

.admin-book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-pages-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.admin-pages-table td {
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
}

.admin-pages-table td.actions {
  text-align: right;
  white-space: nowrap;
}

.admin-pages-table td.actions a,
.admin-pages-table td.actions button {
  margin-left: 12px;
  font: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.admin-pages-table td.actions a:hover,
.admin-pages-table td.actions button:hover { text-decoration: underline; }

.admin-pages-table td.actions button.danger { color: var(--danger); }

/* GDZ content */
.gdz-badge {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #dddfff;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.gdz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1em 0 1.4em;
  overflow: hidden;
  font-size: .93rem;
}

.gdz-table th,
.gdz-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}

.gdz-table th:first-child,
.gdz-table td:first-child { border-left: 1px solid var(--line); }

.gdz-table th {
  background: var(--surface-2);
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
}

.gdz-table tr:first-child th { border-top: 1px solid var(--line); }

.gdz-seq {
  display: inline-block;
  padding: 7px 12px;
  margin: .4em 0 1em;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid #dddfff;
  border-radius: 9px;
  font-size: .98rem;
  font-weight: 800;
}

.gdz-answer {
  background: var(--accent-soft);
  border: 1px solid #bcece5;
  border-radius: 12px;
  padding: 14px 17px;
  margin: 1em 0 1.4em;
  font-size: .96rem;
}

.gdz-answer strong:first-child {
  display: block;
  color: #207c70;
  font-family: 'Manrope', sans-serif;
  margin-bottom: 6px;
}

.gdz-illustration {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.25em auto;
  border-radius: 10px;
}

.gdz-illustration-caption {
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  margin-top: -.8em;
  margin-bottom: 1.4em;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1em 0 1.4em;
  border-radius: 10px;
}

.table-scroll .gdz-table { margin: 0; }

/* Payment requisites */
.requisites-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 4px 0 18px;
}

.requisites-box h3 { font-size: .95rem; margin: 0 0 10px; }

.req-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .85rem;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}

.req-row:last-of-type { border-bottom: none; }
.req-row span { color: var(--muted); }
.req-row strong { font-weight: 800; }
.req-comment { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }

.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff9eb;
  color: #7c5a1b;
  border: 1px solid #f5dfae;
  margin-left: 8px;
  font-size: .67rem;
  font-weight: 800;
  text-transform: uppercase;
}

/* Responsive */
@media (max-width: 760px) {
  .wrap { width: min(100% - 28px, 1120px); }

  .site-header { padding: 12px 0; }
  .site-header .wrap { align-items: center; }
  .site-header .tagline { display: none; }
  .account-nav { gap: 2px; }
  .account-nav a { padding: 7px 8px; font-size: .75rem; }

  .hero { padding: 46px 0 24px; }
  .hero h1 { font-size: 2rem; }

  .book-grid { grid-template-columns: 1fr; gap: 14px; padding-bottom: 45px; }
  .book-card-top { padding: 15px; }
  .book-cover-wrap, .book-cover, .book-cover.placeholder { min-height: 112px; }
  .book-cover-wrap { width: 78px; }

  .admin-grid { grid-template-columns: 1fr; }
  .page-content { padding: 23px 18px; font-size: .98rem; }

  .checkout-box,
  .login-box { padding: 22px 18px; }

  .page-list { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
}

@media (max-width: 480px) {
  .account-nav a:first-child:last-child { display: none; }
  h1 { font-size: 1.65rem; }
  .unlock-banner { align-items: stretch; }
  .unlock-banner .btn { width: 100%; }
  .page-nav .btn { padding-inline: 12px; }
  .admin-top { align-items: flex-start; flex-direction: column; }
  .req-row { flex-direction: column; gap: 2px; }
}
