/* =========================
   0) Fonts
   ========================= */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Merriweather:wght@400;700&display=swap");

/* =========================
   1) Design tokens (CSS vars)
   ========================= */
:root {
  --bg: #f7f8fa;
  --paper: #ffffff;
  --primary: #365cff;
  --primary-ink: #1a2b6b;
  --ink: #1e1f24;
  --muted: #6b7280;
  --accent: #eef2ff;
  --success: #22c55e;
  --border: #e5e7eb;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --shadow: 0 8px 24px rgba(2, 6, 23, 0.08);
  --radius: 12px;

  --container-w: 980px;
  --header-h: clamp(96px, 12vw + 32px, 160px);
  --sticky-h: 64px;
}

@media (max-width: 380px) {
  :root {
    --header-h: clamp(120px, 15vw + 48px, 140px);
  }
}

/* =========================
   2) Base / reset / type
   ========================= */
* { box-sizing: border-box; }

html { scroll-padding-top: var(--header-h); scroll-behavior: smooth; font-size: 16px; }

body.page {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  letter-spacing: 0.01em;
  padding-top: var(--header-h);
}

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

a { color: var(--primary); text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
.link { text-decoration: none; }
.link:hover { text-decoration: underline; }

.separator { border: none; height: 1px; background: var(--border); margin: 24px 0; }

/* =========================
   3) Layout containers
   ========================= */
.main, .footer {
  width: min(100%, var(--container-w));
  margin-inline: auto;
  padding-inline: 20px;
}

/* =========================
   4) Header (fixed, full-width)
   ========================= */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85); 
  backdrop-filter: blur(12px); 
  box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 4px 20px rgba(0,0,0,0.03); 
  z-index: 100;
  transition: all 0.3s ease;

  display: flex;
  align-items: center;
}

.header__inner {
  width: min(100%, var(--container-w));
  margin-inline: auto;
  padding-inline: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.header__title {
  margin: 20px 0 0;
  font-size: clamp(1.8rem, 1.2rem + 2.2vw, 2.75rem);
  line-height: 1.1;
  background: linear-gradient(135deg, var(--ink) 0%, #4b5563 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header__bar { display: flex; align-items: center; gap: 16px; }

.nav__list {
  display: flex; gap: 8px;
  padding: 0; margin: 0; list-style: none;
  flex-wrap: wrap;
}

.nav__link, .btn-ghost {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 99px; 
  background: transparent;
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  white-space: nowrap;
}

.nav__link:hover, .btn-ghost:hover {
  background: var(--gray-100);
  color: var(--primary);
  transform: translateY(0);
  box-shadow: none;
  text-decoration: none;
}

.nav__link.is-active {
  background: var(--ink);
  color: white;
}
.nav__link:hover, .btn-ghost:hover { box-shadow: var(--shadow); transform: translateY(-1px); background: #fff; }

.header__auth {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
  color: var(--muted);
}
.header__auth .divider { color: var(--border); }

/* =========================
   5) Sections / components
   ========================= */
.section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.section--accent { background: var(--accent); }
.section__title { margin: 0 0 12px; font-size: 1.5rem; }

.section__title.separator-bottom,
.section__header .section__title {
  display: block;
  width: 100%;
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.section__subtitle { margin: 16px 0 8px; font-size: 1.125rem; color: var(--primary-ink); }

.lead { font-size: 1.0625rem; color: #111827; }

.genres__title { margin: 12px 0 8px; font-weight: 700; }
.tags {
  list-style: none; display: flex; gap: 8px;
  padding: 0; margin: 0 0 12px; flex-wrap: wrap;
}
.tags__link {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: .9375rem;
  text-transform: capitalize;
}

.tags__link:hover { background: #fff; box-shadow: var(--shadow); }

.card .stretched-link {
    border-radius: var(--radius);
    position: absolute;
    inset: 0;
    z-index: 1;
}

.card:not(form):not(.no-hover):hover { 
  transform: translateY(-4px); 
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}

.card__title {
  margin: 0 0 6px;
  font-size: 1.25rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-right: 42px;
  height: 3.25rem; 
  display: flex;
  display: -webkit-box; 
}

.card__meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__text {
  margin: 8px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: default;
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  flex: 1;
  position: relative;
}

a.stat-item { cursor: pointer; }

.stat-item:hover { transform: translateY(-2px); text-decoration: none; }

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.stat-label {
  color: #9ca3af;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.stat-item.subscribers .stat-value { color: #4b9c7b; }
.stat-item.favorites .stat-value { color: #5c7cfa; }
.stat-item.read .stat-value { color: #d97706; }
.stat-item.reviews .stat-value { color: #a78bfa; }

a.stat-item:hover .stat-value,
a.stat-item:hover .stat-label {
    text-decoration: none;
    color: inherit; /* Prevent blue color on hover */
}
/* Ensure colors persist on hover for links */
a.stat-item.subscribers:hover .stat-value { color: #4b9c7b; }
a.stat-item.favorites:hover .stat-value { color: #5c7cfa; }
a.stat-item.read:hover .stat-value { color: #d97706; }

.stat-item.logout {
  transition: all 0.2s ease;
}

.stat-item.logout .stat-icon img {
  filter: grayscale(1);
  opacity: 0.6;
  transition: all 0.2s ease;
}

.stat-item.logout:hover {
  opacity: 1;
  transform: translateY(-2px) scale(1.05);
}

.stat-item.logout:hover .stat-icon img {
  filter: grayscale(0) drop-shadow(0 4px 6px rgba(239, 68, 68, 0.2));
}

.btn-edit-avatar {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  background: #ffffff;
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-edit-avatar:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.btn-edit-avatar img {
  width: 16px; 
  height: 16px; 
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-edit-avatar:hover img { opacity: 1; }

.card {
  background: #fff;
  border-radius: 16px; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.03); 
  border: 1px solid rgba(0,0,0,0.04); 
  overflow: hidden;
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
}

.card:not(form):not(.no-hover):hover { 
  transform: translateY(-4px); 
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.1); 
  border-color: var(--primary);
}

.card__friend{
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #eaf0ff;
  color: var(--primary-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none; 
  position: relative;
  z-index: 2;
  transition: all 0.2s ease;
}

.card__friend:hover {
  background: #dbe3ff;
  color: #111c5d;
}

.figure { 
  margin: 0 0 8px; 
  position: relative;
  overflow: hidden; 
  border-radius: 10px;
}

.figure__img {
  width: 100%;
  aspect-ratio: 2 / 3;
  height: auto;
  object-fit: cover;
  object-position: center top; 
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card:hover .figure__img {
  transform: scale(1.03); 
}

.figure__caption {
  margin-top: 6px; font-size: .875rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}

.tip {
  background: #fff8e7; border: 1px solid #f5d48a; color: #7a5a00;
  border-radius: var(--radius); padding: 14px; margin-top: 12px;
}
.tip__title { margin: 0 0 4px; font-weight: 700; }
.tip__steps { margin: 8px 0 0 18px; }

.list { margin: 0; padding-left: 18px; }

.quote {
  margin: 8px 0 12px; padding: 12px 16px;
  background: #f0f3ff; border-left: 4px solid var(--primary);
  border-radius: 8px; color: #141a33;
}
.quote cite { display: block; margin-top: 6px; color: var(--muted); font-style: normal; }

.code {
  background: #0b1220; color: #e2e8f0;
  border-radius: 10px; padding: 14px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .9375rem;
}

strong{ font-weight: 700; }
em{ font-style: italic; background: #fff9c4; }
del{ color: #991b1b; text-decoration-thickness: 3px; }
ins{ color: #065f46; text-decoration: underline wavy 2px; }

.footer { margin: 28px auto 40px; color: #111827; }
.footer__title{ margin-bottom: 8px; font-size: 1.125rem; }
.footer__address{ font-style: normal; color: var(--muted); }
.footer__copy{ color: var(--muted); margin-top: 8px; }

.section__sticky{
  position: sticky;
  top: calc(var(--header-h) + 4px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 10px;
  border-radius: 10px;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.section__sticky .sticky-label{ flex:0 0 auto; }

.section__sticky .sticky-scroller{
  display:flex;
  gap:10px;
  flex:1 1 auto;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-x:contain;
  white-space:nowrap;
  scroll-snap-type:x proximity;
  padding-bottom:2px;
}

.section__sticky .sticky-scroller > *{
  flex:0 0 auto;
  scroll-snap-align:start;
}

.section__sticky .tags__link{ display:inline-block; padding:6px 10px; }

.section__sticky--genres{ background: var(--paper); }


.h-scroll {
  display: flex; gap: 16px; overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 6px 4px 12px;
  align-items: stretch; 
}

.h-scroll > .card {
  flex: 0 0 200px;
  scroll-snap-align: start;
  scroll-margin-inline: 16px;
  scroll-margin-top: var(--sticky-h);
  display: flex;
  flex-direction: column;
  height: auto;
}
@media (min-width: 560px){ .h-scroll > .card{ flex-basis: 280px; } }
@media (min-width: 880px){ .h-scroll > .card{ flex-basis: 320px; } }

.card:target {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  background: #f5f7ff;
  box-shadow: 0 0 0 4px rgba(54, 92, 255, 0.15);
  animation: highlightFade 3s ease forwards;
}
@keyframes highlightFade {
  0%   { outline-color: var(--primary); box-shadow: 0 0 0 4px rgba(54, 92, 255, 0.15); background-color: #f5f7ff; }
  80%  { outline-color: rgba(54, 92, 255, 0.2); box-shadow: 0 0 0 2px rgba(54, 92, 255, 0.05); }
  100% { outline-color: transparent; box-shadow: none; background-color: var(--paper); }
}

.h-scroll::-webkit-scrollbar{ height: 10px; }
.h-scroll::-webkit-scrollbar-track{ background: #eef2ff; border-radius: 6px; }
.h-scroll::-webkit-scrollbar-thumb{ background: #c7d2fe; border-radius: 6px; border: 2px solid #eef2ff; }

.promo{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #d2e4fc, #2a37602a);
  margin: 34px 0;
}

@media (max-width: 640px){
  .promo{ display: none; }
}

/* =========================
    6) CSS Grid table
   ========================= */
.table-wrap{ overflow: hidden; border-radius: var(--radius); border:1px solid var(--border); background: var(--paper); }
.table-grid{ width: 100%; border-collapse: collapse; background: var(--paper); }
.table-grid caption{
  text-align: center; font-weight: 700; padding: 12px;
  background: #f3f4f6; border-bottom: 1px solid var(--border);
}
.table-grid thead th, .table-grid tbody td, .table-grid tbody th{
  padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left;
}
.table-grid thead th{
  position: sticky; top: calc(var(--header-h) + 6px);
  background: #eaf0ff; z-index: 2; text-align: left;
  border-bottom: 1px solid #dbe3ff;
}
.table-grid tbody tr:nth-child(even){ background: #fafafa; }

.table-grid thead tr,
.table-grid tbody tr{
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr 1fr;
  column-gap: 0;
}

@media (max-width: 850px){
  .table-grid thead tr,
  .table-grid tbody tr{ grid-template-columns: 2.2fr 1fr 1fr 1fr; }
  .table-grid .col-hide-md{ display: none; }
}

@media (max-width: 720px){
  .table-grid thead tr,
  .table-grid tbody tr{ grid-template-columns: 2.2fr 1fr 1fr; }
  .table-grid .col-hide-sm{ display: none; }
}

/* =========================
   7) Mobile tweaks
   ========================= */
@media (max-width: 900px) {
  .header__inner { padding-inline: 16px; gap: 8px; }
  .header__title { font-size: clamp(1.4rem, 5vw, 2rem); margin: 0; padding-top: 10px; }

  .header__bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
  }

  .nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav__list { flex-wrap: nowrap; gap: 8px; width: max-content; }
  .nav__link, .btn-ghost { padding: 8px 12px; border-radius: 10px; }

  .header__auth { margin-left: 0; gap: 10px; white-space: nowrap; }
  .header__auth .divider { display: none; }
}

form.card {
  max-width: 400px;
  margin: 40px auto;
  display: grid;
  gap: 16px;
  padding: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.9rem;
  color: #666;
}

.field input, .field textarea, .field select {
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent, #5b7cfa);
  box-shadow: 0 0 0 3px rgba(91,124,250,0.2);
  outline: none;
}

.field input[type="file"] {
  padding: 6px;
  background: #f9fafb;
}

.field input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.field input[type="file"]::file-selector-button:hover {
  background: var(--primary-ink);
}

/* =========================
   Buttons
   ========================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 6px rgba(54, 92, 255, 0.15);
}
.btn-primary:hover {
  background: var(--primary-ink);
  color: #ffffff !important;
  border-color: var(--primary-ink);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(54, 92, 255, 0.25);
  text-decoration: none;
}

.btn-secondary {
  background: #ffffff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--gray-900);
  text-decoration: none;
}

.btn-danger {
  background: #ffffff;
  color: #dc2626;
  border-color: #fee2e2;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
  color: #b91c1c;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--primary);
  padding: 10px 24px;
  border: 1px solid var(--primary);
  border-radius: 99px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-decoration: none;
}

.btn-ghost:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(54, 92, 255, 0.2);
}

.btn-ghost:active {
  transform: translateY(0);
  opacity: 0.95;
}

.header__auth .btn-ghost {
  padding: 8px 16px;
  border: 1px solid transparent; 
  background: transparent;
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: none;
}

.header__auth .btn-ghost:hover {
  background: var(--gray-50);
  color: var(--primary);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.header__auth .divider {
  color: var(--border);
  margin: 0 4px;
}

.auth .link {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

.auth .link:hover {
  color: #3b5cdc;
  text-decoration: underline;
}

.auth {
  padding: 40px 20px;
  text-align: center;
}

.auth .section__title {
  margin-bottom: 12px;
  font-size: 1.8rem;
  font-weight: 600;
}

.auth .lead {
  max-width: 500px;
  margin: 0 auto 24px;
  color: #555;
  font-size: 1rem;
  line-height: 1.5;
}

@media (max-width: 480px) {
  form.card {retch; 
    padding: 16px;
  }
  .btn-ghost {
    width: 100%;
  }
}

.grid--cards {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
  padding: 10px 0;
}

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

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}

.btn-small {
  display: inline-block;
  padding: 6px 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-500);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: absolute;
  top: 0px;
  right: 0px;
}

.btn-small:hover {
  box-shadow: 0 2px 6px rgba(91,124,250,0.25);
  transform: translateY(-1px);
  text-decoration: none; 
}

.btn-small:active {
  transform: translateY(0);
  opacity: 0.95;
}

.nav__link--active {
  background: var(--accent);
  cursor: default;
  transform: none;
}

.nav__link--active:hover {
  background: var(--accent);
  box-shadow: none;
  transform: none;
  text-decoration: none; 
}

#book-notes .bn-error { color: #b42318; }

#book-notes .bn-actions {
  display: flex; gap: 10px; margin-top: 4px;
}

#book-notes .bn-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

#book-notes .bn-card__header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
#book-notes .bn-meta { display: flex; gap: 8px; color: var(--muted); font-size: .9375rem; }

#book-notes .btn-outline {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .12s ease, background .15s ease;
}
#book-notes .btn-outline:hover {
  background: #fff; box-shadow: var(--shadow); transform: translateY(-1px);
}

#book-notes .btn-sm { padding: 6px 10px; font-size: .9rem; }

#book-notes .bn-hidden { display: none !important; }
#book-notes .bn-card--editing { outline: 2px dashed var(--border); }

#book-notes .field select,
#book-notes .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
  background: var(--paper);
}
#book-notes .field select:focus,
#book-notes .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,124,250,0.2);
  outline: none;
}

.bn-error {
  color: red;
  font-weight: bold;
  text-align: center;
  margin: 20px 0;
}

.preloader {
  width: 48px;
  height: 48px;
  border: 5px solid #ccc;
  border-top-color: #4e8ef7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 30px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.section--picks{ padding: 20px 0 10px; }

.picks-swiper{
  width: 100%;
  padding: 18px 20px 36px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.book-card{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
  height: auto;
}

.book-card__figure{ margin:0; }
.book-card__img{
  display:block;
  width:100%;
  height: 220px;
  object-fit: cover;
  border-radius: 10px;
}
.book-card__caption{
  font: 600 0.95rem/1.2 ui-sans-serif,system-ui;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: .2px;
}

.book-card{ position: relative; margin-bottom: 35px;}

.fav-btn{
  position: absolute;
  top: 10px; right: 10px;
  width: 38px; height: 38px; 
  display: grid; place-items: center;
  border: none;
  background: rgba(255, 255, 255, 0.75); 
  backdrop-filter: blur(4px);
  border-radius: 50%;
  color: #9ca3af; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 3;
}

.fav-btn:hover{ 
  transform: translateY(-1px) scale(1.05); 
  background: white;
  color: #fbbf24;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.fav-btn:active{ transform: translateY(0) scale(0.95); }

.fav-btn.is-active{
  border-color: transparent;
  background: #fff;
  color: #f59e0b; 
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2); 
}

.fav-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
  pointer-events: none; 
}

.fav-btn svg, .fav-btn i {
  font-size: 1.1rem; 
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fav-btn.is-active svg, .fav-btn.is-active i {
  transform: scale(1.05);
}

.picks-swiper .swiper-slide{ overflow: visible; }

.picks-swiper .swiper-button-prev,
.picks-swiper .swiper-button-next{
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.picks-swiper .swiper-button-prev::after,
.picks-swiper .swiper-button-next::after{
  font-size: 16px; color: var(--text);
}

.picks-swiper .swiper-pagination-bullet{
  background: #c9c9d3; opacity: 1;
}
.picks-swiper .swiper-pagination-bullet-active{
  background: var(--accent);
}

.toastify{
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  color: var(--accent-ink) !important;
  background: var(--accent) !important;
  font-weight: 600;
}

@media (min-width: 480px){
  .book-card__img{ height: 260px; }
}
@media (min-width: 768px){
  .book-card__img{ height: 300px; }
}

.picks-swiper{ height:auto; overflow:hidden; }
.picks-swiper .swiper-wrapper{ align-items:stretch; }
.picks-swiper .swiper-slide{ height:auto; display:flex; }
.picks-swiper .book-card{ width:100%; }

.book-card__img{
  width:100%;
  height:auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
}

@media (min-width: 1024px){
  .picks-swiper{ padding: 14px 16px 28px; }
}

.section--picks {
  padding: 20px;
}

.section__sticky--picks {
  background: var(--paper);
  box-shadow: none;
}

.book-card__link{
  display: block;
  color: var(--text); 
  text-decoration: none;
  font-weight: 600;
  margin-top: 6px;
  transition: color .1s ease;
}

.book-card__link:hover{
  color: var(--gray-500);
  text-decoration: underline;
}

.book-card__caption{
  font-size: .95rem;
  margin-top: 8px;
  line-height: 1.3;
}
.card__image-wrapper {
  width: 100%;
  aspect-ratio: 2/3;
  background: #f3f4f6;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.figure__caption {
  margin-bottom: 8px; 
}

.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: 100%;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  background: var(--paper);
  border-radius: 12px;
  padding: 1rem;
}
.user-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}
.user-card__avatar-box {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 0.75rem;
}
.user-card__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  transition: transform 0.3s ease;
}
.user-card:hover .user-card__avatar {
    transform: scale(1.03);
}
.user-card__badge {
   position: absolute;
   bottom: -6px;
   left: 50%;
   transform: translateX(-50%);
   background: #e0e7ff; 
   color: #3730a3;       
   padding: 3px 12px;
   border-radius: 99px;
   font-size: 0.65rem;
   font-weight: 700;     
   text-transform: uppercase;
   letter-spacing: 0.05em;
   box-shadow: 0 0 0 4px #fff; 
   border: 1px solid rgba(55, 48, 163, 0.1);
   white-space: nowrap;
   z-index: 2;
}
.user-card__title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gray-800);
  letter-spacing: -0.01em;
}
.user-card__actions {
  margin-top: auto;
  width: 100%;
  padding-top: 0;
  position: relative;
  z-index: 2;
}
.stretched-link {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.profile-section {
  border: none;
  box-shadow: none;
  background: transparent;
  margin-top: 20px;
  padding: 0;
}
.profile-header-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto 3rem;
}
.profile-avatar-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}
.profile-figure {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  margin: 0;
  border: 3px solid white;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
}
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}
.profile-username {
  margin: 0;
  font-size: 1.75rem;
}
.profile-email {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}
.profile-stats {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 16px; 
  border: 1px solid rgba(0,0,0,0.04); 
  padding: 12px 16px;
  margin-top: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03); 
  gap: 0;
  transition: box-shadow 0.3s ease; 
}

@media (max-width: 768px) {
  .profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    margin-top: 1rem;
    padding: 0.5rem 0;
    gap: 0;
    overflow: hidden;
    scroll-padding-bottom: 0px;
    position: relative;
    border: 1px solid rgba(0,0,0,0.04);
  }
  
  .profile-stats .stat-divider {
    display: none;
  }
  
  .profile-stats .stat-item {
    min-width: 0;
    padding: 10px 4px;
    width: 100%;
    position: relative;
    border: none;
  }
  
  .profile-stats .stat-item::after { display: none; }
  .profile-stats .stat-item::before { display: none; }

  .profile-stats::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 5%;
      width: 90%;
      height: 1px;
      background-color: #e5e7eb;
      z-index: 1;
      pointer-events: none;
      transform: translateY(-50%);
  }

  .profile-stats::after {
      content: '';
      position: absolute;
      top: 15%;
      bottom: 15%;
      left: 0;
      width: 100%;
      background-image: 
        linear-gradient(
            to right, 
            transparent 33.3%, 
            #e5e7eb 33.3%, 
            #e5e7eb calc(33.3% + 1px), 
            transparent calc(33.3% + 1px),
            
            transparent 66.6%, 
            #e5e7eb 66.6%, 
            #e5e7eb calc(66.6% + 1px), 
            transparent calc(66.6% + 1px)
        ),
        linear-gradient(
            to right, 
            transparent 33.3%, 
            #e5e7eb 33.3%, 
            #e5e7eb calc(33.3% + 1px), 
            transparent calc(33.3% + 1px),
            
            transparent 66.6%, 
            #e5e7eb 66.6%, 
            #e5e7eb calc(66.6% + 1px), 
            transparent calc(66.6% + 1px)
        );
      background-position: top, bottom;
      background-size: 100% 40%;
      background-repeat: no-repeat;
      z-index: 1;
      pointer-events: none;
  }
}

.stat-item.friends .stat-value {
    color: var(--gray-500);
}

.profile-stats:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  cursor: default;
  transition: all 0.2s ease;
  color: inherit;
  text-decoration: none;
  min-width: 80px; 
  gap: 6px; 
}
.stat-item:hover {
  transform: translateY(-2px);
}
.stat-item.logout {
    cursor: pointer;
}
.stat-divider {
  display: block;
  width: 1px;
  min-width: 1px;
  height: 24px;
  background: #e5e7eb; 
  margin: 0; 
  flex-shrink: 0;
}
.stat-value {
  font-size: 1.25rem; 
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  margin: 0;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
.stat-icon {
    margin: 0;
    line-height: 1;
    display: flex; 
    align-items: center;
    height: 1.25rem; 
    opacity: 0.5;
    transition: opacity 0.2s;
}
.stat-item:hover .stat-icon {
  opacity: 1;
}

.profile-favorites-container {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.04);
    padding: 2rem;
    margin-bottom: 2rem;
}

.book-detail-container {
  width: 100%;
  display: flex;
  gap: 3rem; 
  flex-wrap: wrap;
  background: var(--paper);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.03);
  margin-bottom: 40px;
  margin-top: 32px;
}
.book-detail-cover {
  flex: 0 0 340px; 
  width: 340px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.book-detail-info {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
  min-height: 520px;
}
.book-actions {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 2rem;
}

.book-detail-cover .profile-stats {
    width: 100%;
    margin-top: 0;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    min-width: 0;
    background: transparent;
    border: none !important;
}
.book-detail-cover .profile-stats::before,
.book-detail-cover .profile-stats::after {
    display: none !important;
}
.book-detail-cover .profile-stats .stat-item {
    min-width: 0;
    padding: 8px 4px;
    width: auto;
}
.book-detail-cover .profile-stats .stat-value svg {
    width: 20px; height: 20px;
}
.book-detail-cover .profile-stats .stat-label {
    font-size: 0.65rem;
}
.book-detail-figure {
  margin: 0;
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  background: #f3f4f6; 
  transition: transform 0.3s ease;
}
.book-detail-figure:hover {
    transform: scale(1.02);
}
.book-detail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.book-detail-info {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.book-detail-title {
  text-align: left;
  margin-bottom: 0.25rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: -0.25rem;
  padding-right: 120px;
}
.book-detail-author {
  font-size: 1.1rem;
  color: #4b5563;
  margin-bottom: 1rem;
}
.book-detail-genre {
  display: inline-block;
  background: #f3f4f6;
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  border: 1px solid transparent; 
  text-decoration: none;
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
}
.book-description {
  line-height: 1.7;
  color: #374151;
  font-size: 1rem;
  margin-top: 1.5rem; 
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb; 
}
.book-description-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #111827;
}
.book-description-text {
  white-space: pre-wrap;
}
.book-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: auto;
}
.book-action-read {
  width: 100%;
  box-sizing: border-box; 
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 12px;
  letter-spacing: 0.01em;
  text-align: center;
  margin-bottom: 0; 
  transition: all 0.2s ease;
}
.book-action-read:hover {
  transform: translateY(-2px);
}
.book-action-row {
  display: flex;
  gap: 12px;
  width: 100%;
}
.book-action-row > * {
  flex: 1; 
}
.book-action-edit, .book-action-delete-btn {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink); 
  border: 1px solid var(--border);
  background: transparent;
  transition: all 0.2s ease;
}
.book-action-edit {
   color: var(--ink);
}
.book-action-edit:hover {
    background: var(--bg-surface-2);
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}
.book-action-delete-btn {
    color: #ef4444; 
    border-color: #fecaca;
}
.book-action-delete-btn:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}
.book-action-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.book-action-edit {
  flex: 1;
}
.book-action-delete {
  margin: 0;
  flex: 1;
}
.book-action-delete-btn {
  width: 100%;
}

.status-widget {
  max-width: 100%;
  margin-top: auto;
  margin-bottom: 0;
  display: flex !important;
  justify-content: space-between; 
  gap: 8px; 
  padding: 0 !important;
  cursor: default;
  background: transparent;
  border: none;
  box-shadow: none !important; 
}

@media (max-width: 850px) {
  .book-detail-container {
      justify-content: center;
  }
  .book-detail-cover {
      margin: 0 auto;
  }
  .book-detail-cover .profile-stats {
      justify-content: center;
  }
}

.header__user {
    transition: opacity 0.2s;
}
.header__user:hover {
    opacity: 0.8;
}

.status-widget .stat-item {
  cursor: pointer;
  opacity: 1; 
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  flex: 1; 
  display: flex;
  flex-direction: column; 
  align-items: center;
  justify-content: center;
  gap: 6px; 
  padding: 10px 4px; 
  background: transparent;
  border: 1px solid transparent; 
  border-radius: 12px;
  color: #9ca3af; 
  text-align: center;
  position: relative;
}

.status-widget .stat-item .stat-value,
.status-widget .stat-item .stat-label {
    color: inherit;
    transition: color 0.2s;
}

.status-widget .stat-item:hover {
  transform: translateY(-2px);
  background: transparent;
  text-decoration: none;
  box-shadow: none !important; 
}

.status-option[data-status="planned"].is-active, 
.status-option[data-status="planned"]:hover {
  color: #2563eb !important;
}
.status-option[data-status="planned"].is-active .stat-value svg,
.status-option[data-status="planned"]:hover .stat-value svg {
    stroke: #2563eb;
}

.status-option[data-status="reading"].is-active,
.status-option[data-status="reading"]:hover {
  color: #d97706 !important;
}
.status-option[data-status="reading"].is-active .stat-value svg,
.status-option[data-status="reading"]:hover .stat-value svg {
    stroke: #d97706;
}

.status-option[data-status="read"].is-active,
.status-option[data-status="read"]:hover {
  color: #16a34a !important;
}
.status-option[data-status="read"].is-active .stat-value svg,
.status-option[data-status="read"]:hover .stat-value svg {
    stroke: #16a34a;
}

.status-option[data-status="none"].is-active,
.status-option[data-status="none"]:hover {
  color: #4b5563 !important;
}

.status-option.is-active {
    background: #fff;
    border-color: #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); 
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}

.collapsible-header:hover {
  opacity: 0.8;
}

.collapsible-chevron {
  transition: transform 0.3s ease;
  width: 24px; 
  height: 24px;
  display: flex;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-500);
}

.section.is-collapsed .collapsible-chevron {
  transform: rotate(-90deg);
}

.collapsible-content {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
}

.section.is-collapsed .collapsible-content {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
}

.hero-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: white;
  border-radius: 20px;
  padding: 32px;
  margin-top: 24px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px -10px rgba(49, 46, 129, 0.3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 220px;
}

.hero-card__bg {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background-image: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 40%),
                    radial-gradient(circle at 10% 80%, rgba(99, 102, 241, 0.4) 0%, transparent 50%);
  pointer-events: none;
}

.hero-card__content {
  position: relative;
  z-index: 2;
  max-width: 600px;
}

.hero-title {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 20px;
  line-height: 1.5;
}

.hero-btn {
  background: white;
  color: #312e81;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 99px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-block;
  font-size: 0.95rem;
}

.hero-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
  color: #312e81;
  text-decoration: none;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.feature-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 8px 16px rgba(54, 92, 255, 0.15);
  text-decoration: none;
}

.feature-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--primary);
  display: grid; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

.feature-info { display: flex; flex-direction: column; }
.feature-title { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.feature-desc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.section__title { margin: 0 0 12px; font-size: 1.5rem; display: flex; align-items: center; gap: 8px;}

