:root {
  --bg: #4b2019;
  /* page background */
  --page: #2c0f0a;
  /* outer strips */
  --panel: #5a2b20;
  /* inner content panel */
  --panel-dark: #4a241b;
  --ink: #ffe9c8;
  /* parchment text */
  --muted: #e2caa5;
  --line: #3a170f;
  /* panel borders */
  --gold: #caa352;
  /* accent */
  --gold-deep: #9b7432;
  --gold-hover: #dcb15f;
  --chip: #2a100c;
  /* little chips/badges */
  --danger: #8e2b1e;
}

@media (max-width: 1400px) {
  :root {
    --bg: var(--page);
  }
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: "adobe-garamond-pro", Georgia, "Times New Roman", serif;
  background:
    linear-gradient(90deg, var(--page) 0, var(--page) 15%, var(--bg) 15%, var(--bg) 85%, var(--page) 85%, var(--page) 100%);
  color: var(--ink);
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 18px 48px;
}

.header {
  margin: 18px auto 10px;
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--gold-deep), inset 0 0 0 1px rgba(255, 255, 255, .04);
  overflow: hidden;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, #6b3527, #54271d 70%, #4b231a);
}

.brand {
  font-size: 28px;
  letter-spacing: .6px;
  color: var(--ink);
  text-decoration: none;
  text-shadow: 0 1px 0 #2a140f;
}

.brand .wordmark {
  color: var(--gold);
  text-shadow: 0 1px 0 #5b3f1a, 0 0 6px rgba(202, 163, 82, .25);
}

.nav {
  display: flex;
  gap: 8px
}

.nav a,
.btn {
  display: inline-block;
  padding: 8px 12px;
  background: linear-gradient(180deg, #8a5a2f, #664521);
  border: 1px solid #7a5329;
  border-bottom-color: #4a3117;
  border-radius: 4px;
  color: #fff4de;
  text-decoration: none;
  font-size: 14px;
  box-shadow: 0 1px 0 #caa352 inset, 0 1px 0 rgba(0, 0, 0, .3);
}

.nav a:hover,
.btn:hover {
  filter: brightness(1.06)
}

.profile-menu-wrapper {
  position: relative;
}

.profile-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #fff4de;
}

.profile-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: linear-gradient(180deg, #8a5a2f, #664521);
  border: 1px solid #7a5329;
  border-radius: 4px;
  flex-direction: column;
}

.profile-menu.open {
  display: flex;
}

.profile-menu a {
  padding: 8px 12px;
  color: #fff4de;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--ink);
  cursor: pointer;
  margin-left: auto;
}

.back-button {
  display: inline-block;
  padding: 6px 10px;
  background: linear-gradient(180deg, #60331f, #452114);
  border: 1px solid #7a5329;
  border-radius: 16px;
  color: var(--muted);
  text-decoration: none;
}

.notice,
.alert {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--gold-deep);
  background: #5a2b20;
  border-radius: 6px;
}

.notice {
  color: #e9ffdf;
  background: #2b3d26;
  border-color: #49643e
}

.alert {
  color: #ffe1e1;
  background: #522324;
  border-color: #7b3b3e
}

.search-wrap {
  margin: 14px 0
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  max-width: 420px;
  background: #31150f;
  color: var(--ink);
  border: 1px solid #7a5329;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 16px;
  box-sizing: border-box;
}

input::placeholder {
  color: #d2b992
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.book-row {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
    scrollbar-color: var(--gold) var(--panel-dark);
}

.book-row::-webkit-scrollbar {
  height: 12px;
}

.book-row::-webkit-scrollbar-track {
  background: var(--panel-dark);
}

.book-row::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 4px;
}

.book-row::-webkit-scrollbar-thumb:hover {
  background: var(--gold-hover);
}

.book-row > * {
  flex: 0 0 auto;
}

.favorite-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.favorite-category-header h3 {
  margin: 0;
}

.see-more-btn {
  margin-left: 10px;
}

@media (max-width: 600px) {
  .see-more-btn {
    display: none;
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
  width: 100%;
  max-width: 300px;
  overflow: hidden;
}

.book-actions {
  margin-top: auto;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.book-card h3 {
  margin: 0 0 6px
}

.book-card h3 a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
  padding-bottom: 2px;
}

.book-card h3 a:hover {
  color: var(--gold)
}

.book-card .byline {
  color: var(--muted);
  margin: 0 0 8px
}

.book-card .rating {
  color: var(--gold)
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  overflow: hidden;
}

thead th {
  text-align: left;
  background: var(--panel-dark);
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--gold-deep);
}

tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--gold-deep);
}

tbody tr:hover {
  background: #5f3125
}

.status-button {
  padding: 6px 10px;
  border-radius: 14px;
  cursor: pointer;
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--gold-deep);
}

.status-button.read {
  background: #2f472e;
  border-color: #4f6f3e
}

.status-button.not_read_yet {
  background: #3c2c26;
}

.category-button {
  padding: 6px 10px;
  border-radius: 14px;
  cursor: pointer;
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--gold-deep);
  background: #3c2c26;
  margin-bottom: 10px;
}

.category-button.selected {
  background: #2f472e;
  border-color: #4f6f3e;
}

.muted {
  color: var(--muted)
}

.top-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0
}

label {
  color: var(--muted)
}

.auth-page h1 {
  text-align: center;
  margin: 16px 0 12px;
}

.form-panel {
  max-width: 520px;
  margin: 0 auto 20px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

.form-panel,
.form-panel * {
  box-sizing: border-box;
}

.form-panel .field {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 14px;
}

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

.form-panel label {
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}

.form-panel input[type="text"],
.form-panel input[type="email"],
.form-panel input[type="password"],
.form-panel input[type="search"],
.form-panel input[type="number"],
.form-panel select,
.form-panel textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid #7a5329;
  border-radius: 4px;
  background: #31150f;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.form-panel textarea {
  min-height: 120px;
  resize: vertical;
}

.form-panel input::placeholder,
.form-panel textarea::placeholder {
  color: #d2b992;
}

/* Focus ring */
.form-panel input:focus,
.form-panel select:focus,
.form-panel textarea:focus {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(202, 163, 82, .18);
  background: #351810;
}

/* Actions row */
.form-panel .actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
  /* center the Sign in / Create account button */
}

/* Themed submit buttons (forms only) */
.form-panel input[type="submit"],
.form-panel button[type="submit"] {
  padding: 8px 14px;
  background: linear-gradient(180deg, #8a5a2f, #664521);
  border: 1px solid #7a5329;
  border-bottom-color: #4a3117;
  border-radius: 4px;
  color: #fff4de;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 0 #caa352 inset, 0 1px 0 rgba(0, 0, 0, .3);
}

.form-panel input[type="submit"]:hover,
.form-panel button[type="submit"]:hover {
  filter: brightness(1.06);
}

/* Autofill tint (Chrome) */
.form-panel input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #31150f inset !important;
  -webkit-text-fill-color: var(--ink) !important;
}

/* ===== Book show polish ===== */
.book-show h1 {
  margin: 0 0 10px;
  line-height: 1.15
}

.rule {
  border: 0;
  height: 1px;
  background: var(--gold-deep);
  margin: 14px 0;
}

.review-body {
  margin: 0 0 8px
}

.btn--sm {
  padding: 6px 10px;
  font-size: 13px
}

/* .btn--danger {
  background: linear-gradient(180deg, #b34232, var(--danger));
  border: 1px solid #b34232;
  border-bottom-color: #5e1e15;
  box-shadow: 0 1px 0 #d45845 inset, 0 1px 0 rgba(0, 0, 0, .3);
} */

/* form tweaks reused from earlier forms pack */
.form-panel,
.form-panel * {
  box-sizing: border-box
}

.form-panel .field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 14px;
}

.form-panel .field--full {
  grid-template-columns: 1fr
}

.form-panel label {
  color: var(--muted);
  font-weight: 700;
  margin: 0
}

.form-panel textarea {
  min-height: 140px;
  resize: vertical
}

/* make number input reasonable width */
.input-narrow {
  max-width: 110px
}

/* theme the submit button inside the form panel */
.form-panel input[type="submit"],
.form-panel button[type="submit"] {
  padding: 8px 14px;
  background: linear-gradient(180deg, #8a5a2f, #664521);
  border: 1px solid #7a5329;
  border-bottom-color: #4a3117;
  border-radius: 4px;
  color: #fff4de;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 0 #caa352 inset, 0 1px 0 rgba(0, 0, 0, .3);
}

.form-panel input[type="submit"]:hover,
.form-panel button[type="submit"]:hover {
  filter: brightness(1.06)
}

.read-more-link {
  display: inline-block;
  margin-left: 6px;
  color: var(--gold);
  font-size: 0.9em;
}

.read-more-link:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

html {
  scroll-behavior: smooth;
}

/* briefly highlight the anchored review */
.review-card:target {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  background: rgba(202, 163, 82, .08);
  border-radius: 6px;
}

.book-actions {
  display: flex;
  gap: 10px;
  /* space between buttons */
}

.book-actions .btn {
  background-color: #7b4b25;
  color: #f2e0c9;
  padding: 8px 14px;
  border: 1px solid #caa45d;
  border-radius: 4px;
  text-decoration: none;
}

.book-actions .btn:hover {
  background-color: #a1632e;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.review-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

.review-card h3 {
  margin: 0 0 6px;
  margin-top: 8px;
}

.review-card h3 a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
  padding-bottom: 2px;
}

.review-card h3 a:hover {
  color: var(--gold)
}

.review-card .rating {
  color: var(--gold);
  margin: 0 0 8px
}

.review-card .date {
  color: var(--muted);
  margin-top: 8px;
}

.review-card .like-section {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
}

.review-card .like-section form {
  margin: 0
}

.review-card .like-count {
  color: var(--muted)
}

.see-more-link {
  margin-left: 4px;
  color: var(--gold);
  text-decoration: underline;
  font-size: 0.95em;
  cursor: pointer;
}

.see-more-link:hover {
  color: var(--gold-deep);
}

/* Library cards for mobile view */
.library-cards {
  display: none;
  margin-top: 10px;
}

.library-card {
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
  margin-bottom: 10px;
}

.library-card h3 {
  margin: 0 0 6px
}

.library-card .byline {
  color: var(--muted);
  margin: 0 0 8px
}

.library-card .actions {
  display: flex;
  gap: 8px
}



.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.modal.open {
  display: flex;
  opacity: 1;
}

.modal-content, 
.review-modal-content {
  background: var(--panel);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 20px;
  max-width: 500px;
  min-width: 400px;
  max-height: 80%;
  overflow: auto;
  box-sizing: border-box;
  margin: 0 auto;
  pointer-events: auto;
  position: relative;
}

.review-modal-content {
  width: 600px;
  padding-top: 40px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
  position: absolute;
  top: 10px;
  right: 10px;
}

.star-rating {
  display: flex;
  gap: 6px;
  font-size: 24px;
  cursor: pointer;
}

.star {
  color: var(--muted);
  transition: color 0.2s;
}

.star.active {
  color: var(--gold);
}

.star.hover {
  color: var(--gold-hover);
}

.cover-image-and-description {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  padding-top: 0;
}

.description-and-button {
  padding-right: 30px;
}

.description-and-button p {
  padding-top: 0;
  margin-top: 0;
  vertical-align: top;
}

.book-details {
  display: flex;
  flex-direction: row;
  gap: 30px;
}

.book-cover,
.book-card-image {
  max-width: 200px;
  min-width: 200px;
  height: auto;
  object-fit: contain;
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  margin-bottom: 8px;
}

.book-card-image {
  min-width: 100px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 600px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .nav {
    display: none;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
  }

  .nav.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

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

  /* search form stacks vertically */
  .search-wrap form {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .search-wrap input[type="text"],
  .search-wrap input[type="search"],
  .search-wrap .btn {
    width: 100%;
    max-width: 100%;
  }

  .library-table {
    display: none;
  }

  .library-cards {
    display: block;
  }

  h1 {
    font-size: 1.4rem;
  }

  .book-show h1 {
    font-size: 1.3rem;
  }

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

  .form-panel label {
    margin-bottom: 4px;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    pointer-events: auto;
  }

  .review-modal-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    pointer-events: auto;
  }
}

@media (max-width: 600px) {
  .cover-image-and-description {
    flex-direction: column;
  }

  .description-and-button {
    margin: 0;
    padding-right: 0;
  }

  .book-details {
    flex-direction: column;
    gap: 0px;
    margin-bottom: 20px;
  }

  .book-details p {
    margin: 2px;
  }

  .book-cover {
    margin: 0 auto;
    margin-bottom: 20px;
  }
}

.truncate-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(1.2em * 3);
  line-height: 1.2em;
  text-decoration: underline;
  text-decoration-color: inherit;
}
