/* ==========================================================================
   Just Read A Lot — Design System
   Style: clean & minimal. White base, one calm accent color (sky blue),
   coral used sparingly for favorites/hashtags. Flat surfaces, thin
   borders instead of heavy shadows, no gradients.
   ========================================================================== */

:root {
  /* Primary accent — sky blue, tinted from "Oyster Bay" #E5F6FE */
  --blue-50:  #eff8fc;
  --blue-100: #dbeef6;
  --blue-300: #a9d7e8;
  --blue-500: #4b9dbf;
  --blue-600: #35809f;
  --blue-700: #276781;

  /* Secondary accent — coral, tinted from "Cosmos" #FADCDC + "Peach Cream" #FCE0DE */
  --orange-50:  #fbeeec;
  --orange-100: #f6ded9;
  --orange-300: #e8ab9d;
  --orange-500: #d97e68;
  --orange-600: #c1614b;
  --orange-700: #9c4c3a;

  --ink-900: #26241f;
  --ink-700: #4a463e;
  --ink-500: #7a756a;
  --ink-300: #c3beb4;
  --ink-100: #e9e7e2;

  --white: #ffffff;
  --bg: #ffffff;
  --bg-soft: #f7f6f3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --border: 1px solid var(--ink-100);
  --shadow-sm: 0 1px 3px rgba(38, 36, 31, 0.06);
  --shadow-md: 0 4px 16px rgba(38, 36, 31, 0.08);

  --font-display: 'Baloo 2', 'Noto Sans Thai', sans-serif;
  --font-body: 'Noto Sans Thai', 'Baloo 2', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink-900);
  margin: 0 0 0.5em;
  font-weight: 700;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------- Header ---------------- */

.site-header {
  background: var(--white);
  border-bottom: var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 104px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink-900);
  white-space: nowrap;
}
.brand-logo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  gap: 2px;
  flex: 1;
}
.main-nav a {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-700);
  transition: background 0.15s, color 0.15s;
}
.main-nav a:hover { background: var(--bg-soft); color: var(--ink-900); }
.main-nav a.nav-admin {
  color: var(--orange-700);
}
.main-nav a.nav-admin:hover { background: var(--orange-50); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.hi-user {
  color: var(--ink-500);
  font-size: 0.88rem;
  margin-right: 4px;
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--border);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.92rem;
  background: var(--white);
  color: var(--ink-900);
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:active { opacity: 0.85; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

.btn-primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: var(--white);
}
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }

.btn-orange {
  background: var(--orange-600);
  border-color: var(--orange-600);
  color: var(--white);
}
.btn-orange:hover { background: var(--orange-700); border-color: var(--orange-700); }

.btn-ghost {
  background: var(--bg-soft);
  border-color: var(--bg-soft);
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--ink-100); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--blue-600);
  color: var(--blue-600);
}
.btn-outline:hover { background: var(--blue-50); }

.btn-danger {
  background: var(--white);
  border-color: #e3b3ac;
  color: #a3392a;
}
.btn-danger:hover { background: #fbf1f0; }

.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Icon buttons (heart / plus) ---------------- */

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: var(--border);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  color: var(--ink-500);
}
.icon-btn:hover { border-color: var(--ink-300); }
.icon-btn.is-active {
  color: var(--white);
  border-color: transparent;
}
.icon-btn.icon-heart.is-active { background: var(--orange-600); }
.icon-btn.icon-plus.is-active { background: var(--blue-600); }

/* ---------------- Hero / Page heading ---------------- */

/* ---------------- Quick nav (onepage pills) ---------------- */

html {
  scroll-behavior: smooth;
}

#hero,
#search-section,
#readlist,
#fav-category,
#hashtag-section {
  scroll-margin-top: 120px;
}

.quick-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--white);
  border-bottom: var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 104px;
  z-index: 40;
}
.quick-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--ink-700);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.quick-nav-pill:hover {
  background: var(--blue-100);
  color: var(--blue-700);
}
.quick-nav-pill.is-active {
  background: var(--blue-600);
  color: var(--white);
}

/* ---------------- Hero carousel ---------------- */

.hero-carousel {
  position: relative;
  overflow: hidden;
  background: var(--bg-soft) center / cover no-repeat;
  border-bottom: var(--border);
}
.hero-track {
  position: relative;
  height: 500px;
}
.hero-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 100px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(24px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}
.hero-slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}
.hero-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 980px;
  padding: 44px 52px;
}
.hero-card-content {
  text-align: left;
}
.hero-card-image {
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-card-image img {
  max-height: 100%;
  max-width: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transform: rotate(-3deg);
}
.hero-card-image .placeholder {
  width: 170px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-100);
  color: var(--ink-500);
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.hero-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange-600);
  margin-bottom: 10px;
}
.hero-card-content h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--ink-900);
  margin-bottom: 6px;
}
.hero-author {
  color: var(--ink-500);
  font-weight: 600;
  margin-bottom: 14px;
}
.hero-desc {
  color: var(--ink-700);
  line-height: 1.7;
  margin-bottom: 22px;
}
.hero-cta { display: inline-flex; }
.hero-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: var(--border);
  background: var(--white);
  color: var(--ink-900);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 3;
}
.hero-arrow:hover { background: var(--bg-soft); }
.hero-arrow-prev { left: 24px; }
.hero-arrow-next { right: 24px; }
.hero-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 3;
}
.hero-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  opacity: 0.6;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow-sm);
}
.hero-dot.is-active {
  background: var(--blue-600);
  opacity: 1;
  width: 22px;
  border-radius: var(--radius-pill);
}

@media (max-width: 900px) {
  .hero-slide { padding: 28px 24px; }
  .hero-card { grid-template-columns: 1fr; padding: 32px 28px; text-align: center; }
  .hero-card-content { text-align: center; }
  .hero-card-image { order: -1; height: 200px; }
}

@media (max-width: 720px) {
  .quick-nav { top: 0; }
  .hero-track { height: auto; min-height: 560px; }
  .hero-slide {
    position: relative;
    padding: 24px 16px 56px;
  }
  .hero-slide:not(.is-active) { display: none; }
  .hero-arrow { display: none; }
}

.page-hero {
  text-align: center;
  padding: 44px 0 24px;
}
.page-hero h1 {
  font-size: 2.1rem;
  color: var(--ink-900);
}
.page-hero p {
  color: var(--ink-500);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

/* ---------------- Search bar ---------------- */

.search-bar {
  display: flex;
  gap: 10px;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 20px;
  align-items: center;
  max-width: 760px;
  margin: 0 auto 32px;
}
.search-bar input[type="text"] {
  border: none;
  outline: none;
  flex: 1;
  font-size: 0.98rem;
  font-family: var(--font-body);
  background: transparent;
}
.search-bar select {
  border: none;
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
}
.search-bar button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--blue-600);
  color: var(--white);
  cursor: pointer;
  font-size: 1rem;
}
.search-bar button:hover { background: var(--blue-700); }

/* ---------------- Section header w/ line ---------------- */

.section {
  margin: 44px 0;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.section-title h2 {
  font-size: 1.15rem;
  white-space: nowrap;
  color: var(--ink-900);
}
.section-title .line {
  flex: 1;
  height: 1px;
  background: var(--ink-100);
}

/* ---------------- Chips / Pills ---------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--ink-700);
  font-weight: 600;
  font-size: 0.86rem;
  border: var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--ink-300); }
.chip.is-active {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: var(--white);
}
.chip.chip-orange { color: var(--orange-700); }
.chip.chip-orange:hover { border-color: var(--orange-300); }
.chip.chip-orange.is-active { background: var(--orange-600); border-color: var(--orange-600); color: var(--white); }
.chip .count { opacity: 0.55; font-size: 0.85em; }

/* ---------------- Book grid & cards ---------------- */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: var(--border);
  transition: border-color 0.15s ease;
  position: relative;
}
.book-card:hover {
  border-color: var(--ink-300);
}
.book-cover {
  aspect-ratio: 3 / 4;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-300);
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card-body { padding: 12px 14px 16px; }
.book-card-body h3 {
  font-size: 0.94rem;
  margin: 0 0 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-card-body .author {
  font-size: 0.8rem;
  color: var(--ink-500);
  margin: 0;
}
.book-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.empty-state {
  text-align: center;
  color: var(--ink-500);
  padding: 60px 20px;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
}

/* ---------------- Book detail page ---------------- */

.book-detail {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 36px;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.book-detail-cover img,
.book-detail-cover .placeholder {
  width: 100%;
  border-radius: var(--radius-md);
  border: var(--border);
}
.book-detail-cover .placeholder {
  aspect-ratio: 3/4;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-300);
  font-weight: 700;
}
.book-number-tag {
  display: inline-block;
  color: var(--ink-500);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.book-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.book-detail-title h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.book-actions { display: flex; gap: 10px; flex-shrink: 0; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 28px;
  margin: 20px 0;
  padding: 18px 0;
  border-top: var(--border);
  border-bottom: var(--border);
}
.meta-item { display: flex; gap: 8px; font-size: 0.9rem; }
.meta-item .label { color: var(--ink-500); font-weight: 600; min-width: 90px; }
.meta-item .value { color: var(--ink-900); font-weight: 600; }


.favorite-quote .quote-mark {
  display: none;
}
.favorite-quote p {
  margin: 0;
  font-style: italic;
  font-weight: 600;
  color: var(--ink-700);
}

.book-description, .book-review {
  margin-top: 20px;
}
.book-review {
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 18px 22px;
}
.book-review h3 { color: var(--ink-900); font-size: 1rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.gallery-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.gallery-grid img:hover { opacity: 0.85; }

.affiliate-box {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.affiliate-box p { margin: 0; color: var(--ink-700); font-weight: 600; font-size: 0.9rem; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(20,20,20,0.9);
  display: none; align-items: center; justify-content: center; z-index: 200;
  padding: 24px;
}
.lightbox.is-open { display: flex; }
.lightbox img { max-height: 88vh; max-width: 90vw; border-radius: var(--radius-md); }
.lightbox-close {
  position: absolute; top: 24px; right: 32px; color: white; font-size: 2rem;
  cursor: pointer; background: none; border: none;
}

/* ---------------- Forms / Auth ---------------- */

.auth-wrap {
  max-width: 420px;
  margin: 60px auto;
  background: var(--white);
  border: var(--border);
  padding: 36px;
  border-radius: var(--radius-lg);
}
.auth-wrap h1 { text-align: center; font-size: 1.4rem; }
.auth-sub { text-align: center; color: var(--ink-500); margin-bottom: 24px; font-size: 0.88rem; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--ink-700);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-100);
  font-family: var(--font-body);
  font-size: 0.94rem;
  background: var(--white);
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--blue-500);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-hint { font-size: 0.78rem; color: var(--ink-500); margin-top: 4px; }

.auth-footer-link { text-align: center; margin-top: 18px; font-size: 0.88rem; color: var(--ink-500); }
.auth-footer-link a { color: var(--blue-600); font-weight: 700; }

.checkbox-tags {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.checkbox-tags label {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--white); padding: 7px 14px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.84rem; cursor: pointer; border: var(--border);
}
.checkbox-tags input:checked + span,
.checkbox-tags label:has(input:checked) {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: var(--white);
}

/* ---------------- Flash messages ---------------- */

.flash {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  margin: 16px 0;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.flash-success { background: #f2f8f4; color: #2f6b45; border-color: #d7ead9; }
.flash-error { background: #fbf1f0; color: #a3392a; border-color: #f0d4cf; }
.flash-info { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }

/* ---------------- Cards / Panels (dashboard, admin) ---------------- */

.panel {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 24px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.panel-head h2 { margin: 0; font-size: 1.15rem; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}
.stat-card .num { font-size: 1.8rem; font-weight: 800; color: var(--ink-900); font-family: var(--font-display); }
.stat-card .lbl { color: var(--ink-500); font-size: 0.82rem; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: var(--border);
  font-size: 0.88rem;
}
.data-table th { color: var(--ink-500); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
.data-table tr:hover td { background: var(--bg-soft); }
.data-table .thumb { width: 44px; height: 58px; object-fit: cover; border-radius: 6px; background: var(--bg-soft); }
.table-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: var(--border); flex-wrap: wrap; }
.admin-tabs { margin-top: 28px; }
.tabs a {
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--ink-900); border-color: var(--ink-900); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-admin { background: var(--orange-50); color: var(--orange-700); }
.badge-member { background: var(--blue-50); color: var(--blue-700); }

/* ---------------- Footer ---------------- */

.site-footer {
  border-top: var(--border);
  padding: 26px 0;
  margin-top: 56px;
  color: var(--ink-500);
  font-size: 0.84rem;
  text-align: center;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  .main-nav { display: none; }
  .book-detail { grid-template-columns: 1fr; }
  .book-detail-cover { max-width: 200px; }
  .meta-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .header-inner { height: auto; padding: 12px 0; flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar { flex-wrap: wrap; border-radius: var(--radius-md); padding: 14px; }
  .search-bar select { width: 100%; }
}
