:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --muted: #64748b;
  --ink: #0f172a;
}

body {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.app-navbar {
  background: var(--accent);
}
.app-navbar .navbar-brand,
.app-navbar .nav-link {
  color: #fff;
}
.app-navbar .nav-link:hover { color: #e0f2fe; }

/* ---------- Login ---------- */
.login-wrap {
  max-width: 380px;
  margin: 8vh auto 0;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

/* ---------- Board (vertical stack of stages) ---------- */
.board, .history-wrap { max-width: 820px; margin: 0 auto; }
.board { display: flex; flex-direction: column; gap: 1rem; }
.stage {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.95rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.stage-title { font-weight: 600; color: var(--ink); }
.stage-count {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 0.05rem 0.55rem;
  margin-left: 0.4rem;
}
.stage-empty { color: var(--muted); font-size: 0.85rem; margin: 0.7rem 0.95rem; }

/* Collapsible stage (Future Reads) */
.stage-toggle { width: 100%; border: 0; cursor: pointer; }
.stage-toggle .stage-chevron { color: var(--muted); transition: transform 0.2s; }
.stage-toggle:not(.collapsed) { border-bottom: 1px solid var(--border); }
.stage-toggle:not(.collapsed) .stage-chevron { transform: rotate(180deg); }

/* Digital shelf (active stages) - clean and modern, no skeuomorphic wood */
.shelf-scroll { overflow-x: auto; }
.shelf {
  display: flex;
  gap: 1.15rem;
  align-items: flex-end;
  padding: 1rem 1.1rem 1.2rem;
  min-height: 200px;
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.shelf::after {
  content: '';
  position: absolute;
  left: 0.7rem; right: 0.7rem; bottom: 0.8rem;
  height: 7px;
  border-radius: 6px;
  background: linear-gradient(180deg, #e6ebf1, #cbd5e1);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.14);
}
.shelf-book {
  flex: 0 0 104px; width: 104px;
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1;
}
.shelf-cover {
  width: 96px; height: 144px;
  object-fit: cover;
  border-radius: 3px;
  background: #eef2f7;
  box-shadow: 0 7px 12px rgba(15, 23, 42, 0.20), 0 1px 0 rgba(15, 23, 42, 0.10);
}
.shelf-title {
  font-size: 0.72rem; line-height: 1.15; text-align: center;
  margin-top: 0.45rem; max-height: 2.3em; overflow: hidden; color: var(--ink);
}
.shelf-actions { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }

/* List rows (Future Reads collapsed list, Reading History) */
.list-body {
  max-height: 60vh; overflow-y: auto;
  padding: 0.5rem 0.6rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
#history-list.list-body { max-height: none; overflow: visible; padding: 0; }
.list-row {
  display: flex; gap: 0.7rem; align-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.6rem; background: var(--card);
}
.list-cover { width: 38px; height: 57px; flex: 0 0 38px; object-fit: cover; border-radius: 3px; background: #eef2f7; }
.list-main { flex: 1 1 auto; min-width: 0; }
.list-title { font-weight: 600; font-size: 0.9rem; color: var(--ink); text-decoration: none; display: block; }
.list-title:hover { color: var(--accent); }
.list-author { color: var(--muted); font-size: 0.8rem; }
.list-meta { color: var(--muted); font-size: 0.72rem; }
.list-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: flex-end; }

/* Action buttons */
.btn-act {
  font-size: 0.72rem; line-height: 1; padding: 0.34rem 0.55rem;
  border-radius: 6px; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.btn-act:disabled { opacity: 0.5; cursor: default; }
.btn-act-primary { background: var(--accent); color: #fff; }
.btn-act-primary:hover { background: var(--accent-dark); }
.btn-act-soft { background: #eef2f7; color: var(--ink); border-color: var(--border); }
.btn-act-soft:hover { background: #e2e8f0; }
.btn-act-del { background: transparent; color: var(--muted); }
.btn-act-del:hover { background: #fee2e2; color: #b91c1c; }

/* Inline rating stars */
.stars { color: #f59e0b; letter-spacing: 1px; }
.rating-inline { white-space: nowrap; }
.rate-star { font-size: 1.2rem; color: #cbd5e1; cursor: pointer; line-height: 1; padding: 0 1px; }
.rate-star.on { color: #f59e0b; }

/* Shared card classes used by the Add and Recommendations pages */
.book-cover { width: 44px; height: 66px; flex: 0 0 44px; object-fit: cover; border-radius: 4px; background: #eef2f7; }
.book-cover.placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.7rem; text-align: center; }
.book-title { font-weight: 600; font-size: 0.9rem; line-height: 1.15; }
.book-author { color: var(--muted); font-size: 0.8rem; }
.book-meta { color: var(--muted); font-size: 0.72rem; margin-top: 0.15rem; }

/* ---------- Add / search ---------- */
.result-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  padding: 0.6rem;
}
.result-row img.book-cover { width: 40px; height: 60px; flex: 0 0 40px; }

#reader { width: 100%; max-width: 420px; }

/* ---------- Detail ---------- */
.detail-cover {
  width: 100%;
  max-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ---------- Toasts ---------- */
.toast-area {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1080;
  max-width: min(90vw, 360px);
}
.app-toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  font-size: 0.9rem;
}
.app-toast.error { border-left-color: #dc2626; }
.app-toast.success { border-left-color: #16a34a; }

.rating-star {
  font-size: 1.9rem;
  color: #cbd5e1;
  cursor: pointer;
  line-height: 1;
}
.rating-star.on { color: #f59e0b; }
