:root {
  --grad-start: #36d1dc;
  --grad-end: #5b86e5;
  --brand-gradient: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
  --brand-gradient-hover: linear-gradient(135deg, #2bc0cb 0%, #4875da 100%);

  /* Section 1: Hero Band (#36d1dc -> #5b86e5) */
  --hero-band-bg: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
  --hero-text: #ffffff;
  --hero-line: rgba(255, 255, 255, 0.55);

  /* Section 2: Search & Sort Controls Band (Aqua-Ice Color Division) */
  --controls-band-bg: linear-gradient(90deg, #daf6f9 0%, #e2ecfc 100%);
  --controls-band-border: #b5e6ef;

  /* Section 3: Books Catalog Band (Soft Sky-Azure Color Division) */
  --catalog-band-bg: linear-gradient(180deg, #f2fbff 0%, #e8f2ff 55%, #ddeaff 100%);
  --catalog-band-border: #c5dcf8;

  /* Section 4: Footer Band (Deep Royal Indigo-Blue Color Division) */
  --footer-band-bg: linear-gradient(135deg, #163368 0%, #254b96 50%, #3764c7 100%);
  --footer-text: #f0f9ff;

  --bg: #eef7ff;
  --bg-elevated: #ffffff;
  --bg-subtle: #e8f6fa;
  --surface-glass: rgba(255, 255, 255, 0.92);
  --ink: #0f172a;
  --muted: #475569;
  --line: #cfe2f7;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: rgba(54, 209, 220, 0.14);
  --heading: #1e3a8a;
  --accent-line: #bfdbfe;
  --card-shadow: 0 8px 24px rgba(30, 58, 138, 0.08);
  --card-shadow-hover: 0 18px 36px rgba(54, 209, 220, 0.24);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --hero-band-bg: linear-gradient(135deg, #136f78 0%, #24438a 100%);
  --hero-text: #f8fafc;
  --hero-line: rgba(54, 209, 220, 0.5);

  --controls-band-bg: linear-gradient(90deg, #0d2137 0%, #132747 100%);
  --controls-band-border: #1e3a5f;

  --catalog-band-bg: linear-gradient(180deg, #091324 0%, #0d1b33 55%, #112240 100%);
  --catalog-band-border: #1e293b;

  --footer-band-bg: linear-gradient(135deg, #060d1a 0%, #0c182e 50%, #132548 100%);
  --footer-text: #cbd5e1;

  --bg: #0b1120;
  --bg-elevated: #13223d;
  --bg-subtle: #182b4d;
  --surface-glass: rgba(19, 34, 61, 0.92);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: #23385c;
  --primary: #36d1dc;
  --primary-hover: #5b86e5;
  --primary-soft: rgba(54, 209, 220, 0.16);
  --heading: #93c5fd;
  --accent-line: #1e3a8a;
  --card-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  --card-shadow-hover: 0 18px 40px rgba(54, 209, 220, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--brand-gradient);
  background-attachment: fixed;
  line-height: 1.55;
  transition: background 0.25s ease, color 0.25s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button, select, input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

.container {
  width: min(1160px, 92%);
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Full-width Section Color Divisions */
.section-band {
  width: 100%;
  position: relative;
}

/* SECTION 1: Hero Band (#36d1dc -> #5b86e5 Gradient) */
.hero-band {
  background: var(--hero-band-bg);
  border-bottom: 3px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 -10px 24px rgba(15, 23, 42, 0.06);
}

/* SECTION 2: Controls Band (Distinct Aqua-Ice Color Band) */
.controls-band {
  background: var(--controls-band-bg);
  border-top: 1px solid var(--controls-band-border);
  border-bottom: 2px solid var(--controls-band-border);
  padding: 18px 0;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.07);
}

/* SECTION 3: Books Catalog Band (Distinct Soft Sky-Blue Color Band) */
.catalog-band {
  background: var(--catalog-band-bg);
  border-top: 1px solid var(--catalog-band-border);
  flex: 1;
  padding-top: 36px;
}

/* SECTION 4: Footer Band (Distinct Deep Royal Blue Color Band) */
.footer-band {
  background: var(--footer-band-bg);
  border-top: 3px solid #36d1dc;
  color: var(--footer-text);
}

/* Clean Top Accent Line */
.top-accent-line {
  height: 4px;
  background: linear-gradient(90deg, #36d1dc, #ffffff, #5b86e5, #36d1dc);
}

/* Fixed Theme Toggle on User Version */
.theme-toggle-fixed {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, border-color 0.2s ease;
}

.theme-toggle-fixed:hover,
.theme-toggle-inline:hover {
  transform: translateY(-1px);
  border-color: #36d1dc;
}

/* Owner Version Top Bar */
.owner-header-bar {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--controls-band-border);
  padding: 12px 0;
}

.owner-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.owner-brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.owner-pill {
  background: var(--brand-gradient);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(54, 209, 220, 0.35);
}

.owner-sub {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.owner-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 600;
}

[data-theme="light"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  color: #36d1dc;
}

/* Hero Centerpiece: Author Image Strictly at the Exact Centre of the Design */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 46px 0 40px;
}

.hero-centerpiece {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 28px;
  margin: 0 auto 22px;
}

.side-line {
  flex: 1;
  max-width: 220px;
  height: 1.5px;
}

.side-line.left {
  background: linear-gradient(90deg, transparent, var(--hero-line));
}

.side-line.right {
  background: linear-gradient(90deg, var(--hero-line), transparent);
}

.photo-center-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

/* Clean Rectangular Portrait with Soft Curved Corners — Dead Center */
.author-photo {
  position: relative;
  z-index: 1;
  width: 220px;
  height: 276px;
  margin: 0 auto;
  object-fit: cover;
  object-position: center center;
  border: none;
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
}

.hero-name {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: clamp(2.2rem, 4.5vw, 3.2rem);
  font-weight: 700;
  color: var(--hero-text);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 auto;
  text-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
}

.hero-underline {
  width: 72px;
  height: 4px;
  border-radius: 999px;
  background: #ffffff;
  margin: 14px auto 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

/* Aligned Search & Sort Bar inside Controls Band */
.catalog-section {
  padding-bottom: 72px;
}

.toolbar-surface {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--surface-glass);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(54, 209, 220, 0.12);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--muted);
  flex: 1;
  max-width: 420px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field:focus-within {
  border-color: #36d1dc;
  box-shadow: 0 0 0 3px rgba(54, 209, 220, 0.2);
}

.search-field input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem;
  width: 100%;
}

.sort-select {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.sort-select:focus {
  border-color: #36d1dc;
}

/* Uniform 4-Column Aligned Books Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 26px 22px;
  align-items: stretch;
}

.book {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-top: 3px solid #36d1dc;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  box-shadow: var(--card-shadow);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease, border-color 0.24s ease;
  opacity: 0;
  transform: translateY(14px);
  animation: cardFadeIn 0.4s ease forwards;
}

@keyframes cardFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* All Book Images Centered and Fit Cleanly Inside Uniform Frame */
.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background: linear-gradient(145deg, rgba(54, 209, 220, 0.12) 0%, rgba(91, 134, 229, 0.14) 100%);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.book-cover img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center center;
  margin: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.14);
  transition: transform 0.28s ease;
}

.book:hover .book-cover img {
  transform: scale(1.04);
}

.placeholder-cover {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  background: var(--brand-gradient);
  color: #ffffff;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 6px;
}

.book-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  padding-top: 14px;
  text-align: center;
}

.book-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.36;
  min-height: 3.7rem;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.18s;
}

.book-title:hover {
  color: #5b86e5;
}

.book-format {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}

.buy-link {
  margin-top: auto;
  padding-top: 14px;
  display: block;
}

.buy-btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--brand-gradient);
  color: #ffffff;
  font-size: 0.83rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(91, 134, 229, 0.28);
  transition: filter 0.18s, transform 0.15s, box-shadow 0.18s;
}

.buy-link:hover .buy-btn-inner {
  background: var(--brand-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(54, 209, 220, 0.38);
}

.owner-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.owner-actions button {
  flex: 1;
  padding: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--ink);
  border-radius: 6px;
}

.owner-actions .del {
  color: #dc2626;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 48px 20px;
  font-size: 0.95rem;
}

/* Footer */
.site-footer {
  margin-top: 0;
}

.footer-inner {
  padding: 24px 0;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--footer-text);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-gradient-hover);
}

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

/* Modals (Owner Only) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal-card {
  background: var(--bg-elevated);
  color: var(--ink);
  width: min(720px, 100%);
  border-radius: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-top: 4px solid #36d1dc;
  box-shadow: var(--card-shadow-hover);
}

.modal-card.small {
  width: min(380px, 100%);
}

.modal-card h3 {
  font-family: var(--serif);
  font-size: 1.65rem;
  color: var(--heading);
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 12px 0 5px;
  color: var(--muted);
}

.modal-card input[type="text"],
.modal-card input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

.modal-card input:focus {
  outline: none;
  border-color: #36d1dc;
}

.input-row {
  display: flex;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 24px;
}

.preview-col .cover-preview {
  width: 160px;
  aspect-ratio: 3 / 4;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.cover-preview img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: auto;
}

.status {
  margin-top: 8px;
  font-size: 0.84rem;
  padding: 7px 10px;
  border-radius: 6px;
}

.status.success {
  background: rgba(29, 107, 56, 0.12);
  color: #16a34a;
}

.status.error {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.status.loading {
  background: var(--primary-soft);
  color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--card-shadow-hover);
}

.toast.error {
  background: #dc2626;
  color: #ffffff;
}

/* Tablet & Mobile Responsive Grid */
@media (max-width: 980px) {
  .books-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px 18px;
  }
}

@media (max-width: 700px) {
  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 14px;
  }

  .author-photo {
    width: 185px;
    height: 232px;
  }

  .side-line {
    max-width: 60px;
  }

  .theme-toggle-fixed {
    top: 14px;
    right: 14px;
    padding: 6px 12px;
    font-size: 0.76rem;
  }
}

@media (max-width: 520px) {
  .container {
    width: 94%;
  }

  .side-line {
    display: none;
  }

  .controls-band {
    padding: 12px 0;
  }

  .toolbar-surface {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    gap: 10px;
  }

  .search-field {
    max-width: none;
  }

  .sort-select {
    width: 100%;
  }

  .book {
    padding: 10px;
    border-radius: 11px;
  }

  .book-cover {
    padding: 10px;
  }

  .book-title {
    font-size: 0.8rem;
    min-height: 3.3rem;
  }

  .book-format {
    font-size: 0.72rem;
  }

  .buy-btn-inner {
    padding: 7px 10px;
    font-size: 0.76rem;
  }

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

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }
}
