/* ---------- Theme Variables — Dynamic Dexter brand ---------- */
:root {
  --green-primary: #0f172a; /* Brand dark navy — buttons / dark surfaces */
  --green-dark: #0e0f12; /* Deepest dark surface */
  --green-light: #ff7828; /* Brand accent orange — hover / highlight */
  --accent-gold: #ff7828; /* Brand accent orange */
  --accent-gold-dark: #d8dde3; /* Border / divider colour */
  --bg-cream: #f2f3f4; /* Page background */
  --bg-card: #ffffff; /* Card backgrounds */
  --text-main: #111318; /* Primary text */
  --text-muted: #5a6472; /* Secondary / muted text */
}

/* ---------- Global Styles ---------- */
html {
  height: 100%;
}
body {
  font-family: Arial, sans-serif;
  background: var(--bg-cream);
  color: var(--text-main);
  margin: 0;
  min-height: 100%;

  /* Mobile safe areas (notches/status bars/home indicator) */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);

  /* Older iOS fallback */
  padding-top: constant(safe-area-inset-top);
  padding-right: constant(safe-area-inset-right);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-left: constant(safe-area-inset-left);
}

/* ---------- Read Corner Mark (library cover overlay) ---------- */
.book-cover-wrap {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.5em;
}

.book-cover-img {
  max-height: 180px;
  display: block;
  margin: 0;
}

.read-corner {
  position: absolute;
  display: block;
  width: 44px;
  height: 44px;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.read-corner--tr {
  top: 0;
  right: 0;
}
.read-corner--tl {
  top: 0;
  left: 0;
}

.read-corner--jack {
  --corner-color: #2563eb;
}
.read-corner--thom {
  --corner-color: #dc2626;
}

/* Triangle + subtle highlight to mimic a folded page */
.read-corner {
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.45) 0%,
      rgba(255, 255, 255, 0) 45%
    ),
    linear-gradient(135deg, var(--corner-color) 0%, var(--corner-color) 100%);
}

.read-corner--tr {
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  border-top-right-radius: 10px;
}

.read-corner--tl {
  clip-path: polygon(0 0, 0 100%, 100% 0);
  border-top-left-radius: 10px;
}

@supports not (clip-path: polygon(0 0, 0 100%, 100% 0)) {
  .read-corner {
    background: none;
    width: 0;
    height: 0;
    border-top: 44px solid var(--corner-color);
  }
  .read-corner--tr {
    border-left: 44px solid transparent;
  }
  .read-corner--tl {
    border-right: 44px solid transparent;
  }
}

/* ---------- Library Expand/Collapse + Key ---------- */
.collapse-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
  margin: 1em 0;
}

.collapse-controls__buttons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
}

.read-key {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.35em 0.6em;
  border: 1px solid var(--accent-gold-dark);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-main);
}

.read-key__title {
  font-weight: 700;
  font-size: 0.9em;
  opacity: 0.9;
}

.read-key__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  white-space: nowrap;
  font-size: 0.9em;
}

.read-key__swatch {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* Reuse the same corner, just smaller inside the key */
.read-key__swatch .read-corner {
  width: 18px;
  height: 18px;
  filter: none;
}

.read-key__label {
  opacity: 0.95;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header buttons: keep emoji+text aligned and shrinkable */
header nav .btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  max-width: 100%;
}

/* ---------- Left Menu (Home Hub pattern, Library sizing) ---------- */

body.side-menu-open {
  overflow: hidden;
}

.menu-btn {
  position: fixed;
  top: calc(0.75em + env(safe-area-inset-top));
  left: calc(0.75em + env(safe-area-inset-left));
  z-index: 1200;

  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #d8dde3;
  background: #0f172a;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.menu-btn:hover {
  background: #ff7828;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1250;
}

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  width: min(280px, calc(100vw - 3.25rem));
  background: #f2f3f4;
  border-right: 2px solid var(--accent-gold-dark);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  z-index: 1300;
  padding: calc(14px + env(safe-area-inset-top)) 14px
    calc(14px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  transform: translateX(-105%);
  transition: transform 0.18s ease;

  display: flex;
  flex-direction: column;
}
.menu-panel.open {
  transform: translateX(0);
}

.menu-title {
  margin: 2px 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-title-img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 100%;
}

.menu-items {
  display: flex;
  flex-direction: column;
  gap: 0.45em;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Keep existing .btn-small sizing; only force full-width + alignment */
.menu-items .menu-item {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
}

.menu-items .menu-item .nav-text {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-spacer {
  flex: 1 1 auto;
}

.menu-divider {
  height: 1px;
  width: 100%;
  background: var(--accent-gold-dark);
  opacity: 0.45;
  border-radius: 999px;
  margin: 0.2em 0;
}

.menu-logout {
  margin-top: 0.6em;
}

header {
  background: #f2f3f4; /* Solid colour */
  padding: 1em;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);

  position: relative;

  display: flex;
  flex-direction: column; /* Stack items vertically */
  align-items: center; /* Center them horizontally */
  justify-content: center;
  gap: 0.6em; /* Space between logo and buttons */
}

/* Desktop: keep header buttons on ONE line with no horizontal scrolling */
header nav {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.35em;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 0;
  box-sizing: border-box;
}

header nav .btn-small {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0.35em 0.55em;
  font-size: clamp(0.78em, 1.05vw, 0.95em);
  white-space: nowrap;
  overflow: hidden;
}

/* Make the label shrink nicely instead of forcing sideways scroll */
header nav .btn-small .nav-text {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Drop the trailing emoji on desktop to save space */
header nav .btn-small .nav-emoji-right {
  display: none;
}

/* Header logout button (top-right) */
.header-logout {
  position: absolute;
  top: 0.9em;
  right: 1em;
  z-index: 2;
  display: inline-block;
  width: auto;
}

@media (max-width: 600px) {
  .header-logout {
    top: 0.6em;
    right: 0.75em;
    padding: 0.35em 0.65em;
    font-size: 0.9em;
  }
}

/* Home Library login scene (matches Movies/TV/RPI auth styling) */
.hl-login-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.hl-login-page footer {
  padding: 16px;
  margin-top: auto;
}

.hl-login-page .wrap {
  width: min(1240px, 92%);
  margin: 0 auto;
}

.hl-login-page .site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-cream);
  border-bottom: 1px solid var(--accent-gold-dark);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.hl-login-page .header-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 10px 0;
}

.hl-login-page .header-left {
  justify-self: start;
}

.hl-login-page .header-right {
  justify-self: end;
}

.hl-login-page .brand {
  display: block;
  justify-self: center;
  width: min(640px, 78vw);
  height: 96px;
}

.hl-login-page .brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.hl-login-page main.wrap {
  position: relative;
  isolation: isolate;
  padding: 28px 0 44px;
  display: grid;
  place-items: center;
}

.hl-login-page.is-login-scene main.wrap::before {
  content: "";
  position: fixed;
  inset: 70px -16vw -8vh -16vw;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(
      40% 30% at 18% 22%,
      rgba(255, 120, 40, 0.2),
      transparent 70%
    ),
    radial-gradient(
      36% 26% at 78% 28%,
      rgba(15, 23, 42, 0.12),
      transparent 70%
    ),
    radial-gradient(
      45% 36% at 52% 74%,
      rgba(255, 120, 40, 0.13),
      transparent 72%
    );
  filter: blur(26px);
}

.hl-login-page .card {
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dark);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.09);
}

.hl-login-page .narrow {
  max-width: 640px;
}

.hl-login-page .stack {
  display: grid;
  gap: 14px;
}

.hl-login-page .auth-card {
  margin: 0 auto;
}

.hl-login-page .auth-form {
  margin-top: 12px;
}

.hl-login-page .auth-form label {
  font-weight: 600;
  color: var(--text-main);
}

.hl-login-page .eyebrow {
  margin: 0 0 8px;
  color: var(--green-light);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.hl-login-page .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2px;
}

.hl-login-page .btn {
  border: none;
  border-radius: 10px;
  padding: 0.72rem 1rem;
  min-height: 44px;
  min-width: 122px;
  background: var(--green-primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    background 0.2s ease;
}

.hl-login-page .btn:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

.hl-login-page .alert {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(178, 50, 43, 0.28);
  background: rgba(178, 50, 43, 0.12);
  color: #7a241f;
}

.hl-login-page .login-title {
  display: inline-block;
  margin: 0;
  text-align: left;
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.hl-login-page .login-card {
  position: relative;
  overflow: hidden;
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.hl-login-page .login-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background: repeating-linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.26) 0px,
    rgba(15, 23, 42, 0.26) 1px,
    transparent 1px,
    transparent 3px
  );
}

.hl-login-page .login-form input {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent-gold-dark);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 16px;
}

.hl-login-page .login-form .password-wrap {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
}

.hl-login-page .login-form .password-wrap input {
  padding-right: 3.4em;
}

@media (max-width: 640px) {
  .hl-login-page .brand {
    height: 72px;
  }

  .hl-login-page .login-card {
    padding: 22px;
  }
}

/* ---------- Left Slide-out Menu (XDA-inspired) ---------- */

body.side-menu-open {
  overflow: hidden;
}

.side-menu-toggle {
  position: fixed;
  top: calc(0.75em + env(safe-area-inset-top));
  left: calc(0.75em + env(safe-area-inset-left));
  z-index: 1000;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;

  padding: 0.45em 0.75em;
  line-height: 1;
}

.side-menu-plus {
  font-size: 1.25em;
  font-weight: 800;
  display: inline-block;
  transform-origin: 50% 50%;
  transition: transform 160ms ease;
}

/* When open, rotate + to look like an X */
.side-menu-toggle[aria-expanded="true"] .side-menu-plus {
  transform: rotate(45deg);
}

.side-menu-label {
  display: block;
  height: 1.05em;
  width: auto;
}

.side-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 160ms ease;
}

.side-menu-backdrop.is-open {
  opacity: 1;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1001;

  width: min(340px, calc(100vw - 3.25rem));
  padding: calc(0.8em + env(safe-area-inset-top)) 0.85em
    calc(0.8em + env(safe-area-inset-bottom));
  box-sizing: border-box;

  background: #f2f3f4;
  border-right: 2px solid var(--accent-gold-dark);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);

  transform: translateX(-105%);
  transition: transform 160ms ease;
}

.side-menu.is-open {
  transform: translateX(0);
}

.side-menu-nav {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}

.side-menu-link {
  width: 100%;
  margin: 0;
  box-sizing: border-box;

  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5em;

  padding: 0.6em 0.8em;
  font-size: 0.98em;
  white-space: normal;
}

.side-menu-link .nav-text {
  flex: 1 1 auto;
}

.side-menu-spacer {
  flex: 1 1 auto;
}

.side-menu-logout {
  margin-top: 0.35em;
}
footer {
  text-align: center;
  background: #0f172a;
  color: #ffffff;
  padding: 0.5em;
}

/* ---------- Universal Add Form (shared by Add Book, Add Location, etc.) ---------- */
.add-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.8em;
  background: var(--bg-card);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 1em 1.5em;
  margin: 1.5em auto;
  max-width: 600px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.add-form input[type="text"],
.add-form select {
  flex: 1 1 200px;
  min-width: 200px;
  max-width: 260px;
  padding: 0.6em 1em;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  font-size: 1em;
  background: #fff;
  box-sizing: border-box;
}
.add-form input[type="text"]:focus,
.add-form select:focus {
  outline: none;
  border-color: #ff7828;
  box-shadow: 0 0 0 2px rgba(255, 120, 40);
}
.add-form button {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.7em 1.4em;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition:
    background 0.3s,
    transform 0.1s;
}
.add-form button:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

/* ---------- Centered Form Heading ---------- */
.add-heading {
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 1.6em;
  color: var(--green-dark);
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  letter-spacing: 0.5px;
}

.app-logo {
  height: 70px; /* Main control for logo size */
  width: auto; /* Keeps proportions correct */
  max-width: 100%; /* Prevents overflow on small screens */
  display: block;
}

/* ---------- Book & Location Cards ---------- */ /* This grid is ONLY for the book cards inside a shelf */
.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1em;
  padding: 1em;
  align-items: start;
}
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dark);
  padding: 1em;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.book-card img {
  display: block;
  margin: 0 auto 0.5em;
  max-height: 180px;
  max-width: 100%;
  height: auto;
}
.book-card p {
  margin: 0.3em 0;
}
.book-card form {
  margin-top: 0.3em;
}
.book-card select {
  width: 100%;
  padding: 0.5em 0.8em;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  background: #fff;
  box-sizing: border-box;
  margin-bottom: 0.4em;
} /* ---------- Rooms & Shelves ---------- */ /* Room wrapper */

.book-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.09);
  border-color: #cfd6de;
}

.book-card .book-cover-wrap {
  width: 100%;
  min-height: 190px;
  margin: 0 auto 0.65rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.book-card .book-cover-img {
  margin: 0;
  max-height: 180px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.location-group {
  margin: 1em auto;
  max-width: 1600px;
  padding: 0 1.25em;
  box-sizing: border-box;
} /* Room title bar */
.location-group h2 {
  background: linear-gradient(135deg, #0f172a 0%, #131c2f 100%);
  color: #fff;
  padding: 0.48em 0.75em;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  text-align: center;
  margin-bottom: 1em; /* separation from first shelf */
}
.location-group h2 a {
  color: #fff;
  text-decoration: none;
} /* Shelf list inside each room (holds shelf accordions in a column) */
.shelf-list {
  display: block;
  margin-top: 0.5em;
  padding: 0; /* shelf cards handle spacing */
} /* Each shelf = its own card */
.shelf-group {
  display: block;
  width: 100%;
  margin: 0 0 0.9em; /* space between shelf cards */
  padding: 0.42em 0.5em;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
} /* ---------- Buttons ---------- */
.btn-small,
button.btn-small {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  text-decoration: none;
  margin: 0.2em;
  display: inline-block;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  transition:
    background-color 0.2s,
    transform 0.1s,
    box-shadow 0.1s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.btn-small:hover,
button.btn-small:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}
.btn-small:active,
button.btn-small:active {
  background: var(--green-dark);
  transform: translateY(0);
}
.danger {
  background: #a62828;
}
.danger:hover {
  background: #7b1d1d;
}
.btn-large {
  background: var(--green-primary);
  color: #fff;
  padding: 1em 1.4em;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
}
.btn-large:hover {
  background: var(--green-light);
} /* Move dialog layout */
#moveDialog {
  border: none;
  border-radius: 0.75rem;
  padding: 0;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
} /* body of the dialog already has padding via inline style on the form */
.move-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.move-field label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.move-field select,
.move-field input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1px solid #c9c3b4;
}
.move-field select:focus,
.move-field input:focus {
  outline: none;
  border-color: #ff7828;
  box-shadow: 0 0 0 2px rgba(255, 120, 40);
}
.move-actions {
  display: flex;
  justify-content: flex-end;
} /* ---------- Dashboard Layout ---------- */
.dashboard {
  text-align: center;
  margin: 2em auto;
  max-width: 800px;
}
.dash-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1em;
  margin-top: 1.5em;
  margin-bottom: 2.5em;
} /* ---------- Barcode & Book Detail ---------- */
.barcode-box {
  text-align: center;
  margin: 1.5em 0;
}
.barcode-box img {
  display: inline-block;
  max-width: 100%;
  height: auto;
}
.book-detail {
  text-align: center;
  padding: 1em;
}
.book-detail img {
  margin: 1em 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.barcode-location {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 0.5em;
  letter-spacing: 1px;
} /* ---------- Collapsible Sections ---------- */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #131c2f 100%);
  color: #fff;
  padding: 0.62em 0.9em;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  cursor: pointer;
  margin-top: 0; /* sits flush inside shelf card */
  transition: background 0.16s ease, transform 0.12s ease;
}
.collapsible-header a {
  color: #fff;
  text-decoration: none;
}
.collapsible-header:hover {
  background: linear-gradient(135deg, #1a2742 0%, #233252 100%);
  transform: translateY(-1px);
}

.collapsible-header .title {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.toggle-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9em;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.15s ease;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
} /* Apply collapsible behaviour to BOTH shelf-list and book-list containers */
.collapsible-content {
  margin-top: 0.65em;
  overflow: hidden;
  max-height: none;
  opacity: 1;
  transition: opacity 0.25s ease-in-out;
}
.collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  pointer-events: none;
}
.collapse-controls {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-bottom: 1.5em;
}
.collapse-controls .btn-small {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.3s ease,
    transform 0.1s;
}
.collapse-controls .btn-small:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}
.collapse-controls .btn-small.danger {
  background: #a33;
}
.collapse-controls .btn-small.danger:hover {
  background: #c44;
} /* ---------- Charts ---------- */

/* Dashboard welcome title image */
.dashboard-welcome-title {
  text-align: center;
  margin: 0.2em auto 0.8em;
}
.dashboard-welcome-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
  height: auto;
}

.dashboard-user-image-wrap {
  margin: 0.2em auto 1em;
  text-align: center;
}

.dashboard-user-image {
  display: inline-block;
  width: min(220px, 70vw);
  height: auto;
}

.dashboard-divider-double {
  width: 60%;
  margin: 0.35em auto 1em;
  display: grid;
  gap: 0.35em;
}

.dashboard-divider-double hr {
  margin: 0;
}

/* Dashboard chart title image */
.dashboard-chart-title {
  text-align: center;
  margin: 1.2em auto 0.5em;
}

.dashboard-chart-title-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
  height: auto;
}

/* Library scan title image */
.library-addscan-title {
  margin-top: 1.2em;
  margin-bottom: 0.6em;
}
.library-addscan-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 380px;
  height: auto;
}

/* Scan page title image */
.scan-addscan-title {
  margin-top: 0.2em;
  margin-bottom: 0.9em;
}
.scan-addscan-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 420px;
  height: auto;
}

/* Add manual page title image */
.addman-title {
  margin-top: 0.2em;
  margin-bottom: 0.9em;
}
.addman-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 420px;
  height: auto;
}

/* Locations page title image */
.locations-title {
  margin-top: 0.2em;
  margin-bottom: 0.9em;
}
.locations-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 340px;
  height: auto;
}

/* Edit page title image */
.edit-title {
  margin-top: 0.2em;
  margin-bottom: 0.9em;
}
.edit-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 340px;
  height: auto;
}

/* Locations page 'Location Name' label image */
.locname-title {
  margin: 0.1em auto 0.2em;
  text-align: center;
}
.locname-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 260px;
  height: auto;
}

/* Locations page 'Code' label image (match Location Name sizing) */
.loccode-title {
  margin: 0.1em auto 0.2em;
  text-align: center;
}
.loccode-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 260px;
  height: auto;
}

/* Dashboard chart container (blend into page) */
.dashboard-chart-block {
  margin-bottom: 2.5em;
}
.dashboard-chart-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  max-width: 720px;
  margin: 1em auto 0;
}
#booksChart {
  display: block;
  width: 100%;
  height: 380px;
  border: none;
}

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

.dashboard-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1em;
  margin-top: 1.5em;
  margin-bottom: 2.5em;
}
.dashboard-buttons .btn,
.btn-large {
  display: inline-block;
  padding: 1em 1.4em;
  background: var(--green-primary);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition:
    background 0.3s ease,
    transform 0.2s ease;
}
.dashboard-buttons .btn:hover,
.btn-large:hover {
  background: var(--green-light);
  transform: translateY(-2px);
}

/* Universal form card + stack (use on Add Manual + Edit) */

.form-card {
  max-width: 520px;
  margin: 2em auto;
  padding: 1.2em 1.4em;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dark);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9em;
}
.form-stack label {
  font-weight: 600;
  color: var(--green-dark);
}
.form-stack input[type="text"],
.form-stack input[type="number"],
.form-stack select {
  width: 100%;
  padding: 0.6em;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  box-sizing: border-box;
  background: #fff;
}
.form-stack input[type="text"]:focus,
.form-stack input[type="number"]:focus,
.form-stack select:focus {
  outline: none;
  border-color: #ff7828;
  box-shadow: 0 0 0 2px rgba(255, 120, 40);
}
.form-stack button {
  display: block;
  width: 100%;
  padding: 0.8em;
  background: var(--green-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s;
}
.form-stack button:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

/* Base style for smaller action buttons (kept for compatibility) */

.btn-small {
  display: inline-block;
  padding: 0.5em 1em;
  background-color: var(--green-primary);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color 0.2s,
    transform 0.1s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.btn-small:hover {
  background-color: var(--green-light);
  transform: translateY(-1px);
}
.btn-small:active {
  background-color: var(--green-dark);
  transform: translateY(0);
}

/* Optional: add icon space if using "+" or emojis */

.btn-small::before {
  content: "";
  margin-right: 0.2em;
}
.btn-small.center {
  display: block;
  margin: 1em auto;
  text-align: center;
  width: fit-content;
}

/* Hide duplicate location line in Library book cards (kept in markup) */
.library-location-meta {
  display: none;
}

/* Center ISBN input and location dropdown on scan page */
.form-stack {
  align-items: center;
}

.form-stack input[type="text"],
.form-stack input[type="number"],
.form-stack select {
  display: block;
  margin: 0.6em auto;
  width: 100%;
  max-width: 300px;
}

/* Login page spacing */
.login-form input {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0.75em auto;
  padding: 0.6em 0.8em;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  box-sizing: border-box;
}

/* Password reveal toggle inside the password field */
.login-form .password-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0.75em auto;
}

.login-form .password-wrap input {
  margin: 0;
  max-width: none;
  padding-right: 3.4em; /* space for the toggle button */
}

.login-form .password-toggle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 1px;

  background: transparent;
  border: none;
  padding: 0 0.55em;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  color: var(--green-primary);
  cursor: pointer;
  z-index: 1;
}

.login-form .password-toggle .password-icon {
  display: block;
  width: 24px;
  height: 24px;
}

.login-form .password-toggle .password-icon--hide {
  display: none;
}

.login-form .password-toggle.is-revealed .password-icon--show {
  display: none;
}

.login-form .password-toggle.is-revealed .password-icon--hide {
  display: block;
}

.login-form .password-toggle:hover {
  color: var(--green-light);
}

.login-form .password-toggle:focus-visible {
  outline: 2px solid rgba(255, 120, 40);
  outline-offset: 2px;
  border-radius: 4px;
}

.login-form input:hover {
  border-color: var(--green-light);
}

.login-form input:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 2px rgba(255, 120, 40);
}

.login-form button[type="submit"] {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 1em auto 0;
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.75em 1em;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}

.login-form button[type="submit"]:hover {
  background: var(--green-light);
  transform: translateY(-1px);
}

.login-form button[type="submit"]:active {
  background: var(--green-dark);
  transform: translateY(0);
}

/* Login page title image */
.login-title {
  text-align: center;
  margin: 0.25em auto 0.9em;
}

.login-title-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 260px;
  height: auto;
}

/* Login page card sizing */
.login-card {
  max-width: 400px;
  margin: 4em auto;
  text-align: center;
}

/* Make everything calculate width sanely */
* {
  box-sizing: border-box;
}

@media (max-width: 600px) {
  header {
    padding: 0.75em;
    gap: 0.5em;
  }

  header nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    margin-top: 0 !important;
    padding: 0;
  }

  header nav .btn-small {
    width: 100%;
    text-align: center;
    margin: 0; /* override the current 0.2em margin */
    padding: 0.75em 1em;
  }
}

.scroll-top-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999;

  width: 44px;
  height: 44px;
  border: none;
  border-radius: 999px;
  cursor: pointer;

  background: var(--green-primary);
  color: #fff;
  font-size: 18px;
  line-height: 44px;
  text-align: center;

  /* Starts hidden */
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) translateZ(0); /* forces its own layer */
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease,
    background-color 0.2s ease;
  will-change: transform; /* hint to the renderer */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.scroll-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) translateZ(0);
}

.scroll-top-btn:hover {
  background: var(--green-light);
}

.scroll-top-btn:active {
  background: var(--green-dark);
  transform: translateY(1px) translateZ(0);
}

@supports (bottom: env(safe-area-inset-bottom)) {
  .scroll-top-btn {
    bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  header {
    box-shadow: none;
  }
  .book-card,
  .shelf-group,
  .btn-small {
    box-shadow: none;
  }
}

/* Collapsible cards (used on Locations page) */
details.collapsible {
  padding: 0; /* keep book-card spacing clean */
}

details.collapsible summary {
  list-style: none; /* removes default marker */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

details.collapsible summary::-webkit-details-marker {
  display: none; /* Chrome/Android */
}

.collapsible-summary {
  padding: 12px 12px; /* match your card padding vibe */
}

.collapsible-title {
  font-weight: 700;
}

.collapsible-meta {
  opacity: 0.75;
  font-size: 0.95em;
  white-space: nowrap;
}

.prefix-pattern {
  opacity: 0.7;
}

/* Right side of Library dropdown headers (count + arrow) */
.collapsible-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.collapsible-body {
  padding: 0 12px 12px 12px;
}

/* Optional: make room group header feel more “section-like” */
.room-group > summary {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Optional: slightly tighter shelf items */
.shelf-item .collapsible-summary {
  padding: 10px 12px;
}

/* Make Manage Locations behave like Library collapsible lists */
.location-list {
  display: block !important;
}

.location-list .book-card {
  margin-bottom: 10px;
}

/* Make room group headers look like site buttons */
.room-group > summary {
  background-color: #0f172a; /* same grey as your buttons */
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
}

/* Keep the text inside crisp and white */
.room-group > summary .collapsible-title,
.room-group > summary .collapsible-meta {
  color: white;
}

/* Hover effect to match buttons */
.room-group > summary:hover {
  background-color: #ff7828; /* your usual darker hover shade */
}

.room-group > summary::after {
  content: "▼";
  font-size: 0.8em;
  opacity: 0.8;
  margin-left: 8px;
}

.room-group[open] > summary::after {
  content: "▲";
}

.room-group {
  border: none; /* remove card border if it clashes */
  margin-bottom: 10px; /* tidy vertical rhythm */
}

header a.btn-small:hover,
header a.btn:hover {
  background-color: #ff7828;
  color: white;
}

.dash-number {
  color: #ff7828; /* your signature orange */
  font-weight: bold;
}

/* Dashboard totals */
.dashboard-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  margin: 0.65em auto 0.45em;
}

.dashboard-stats-row {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 1.25em;
  flex-wrap: wrap;
}

.dashboard-stats-row--bottom {
  margin-top: 0.2em;
}

.dashboard-stat--center {
  min-width: 220px;
}

.dashboard-stat-divider {
  width: min(180px, 42vw);
  display: block;
  height: 0;
  border: 0;
  border-top: 1px solid #bdbdbd;
  margin: 0 auto 1.05em;
}

.dashboard-stat-label--read {
  margin-bottom: 0.35em;
}

.dashboard-stats-separator {
  width: 60%;
  margin: 0.9em auto 0.95em;
}

.dashboard-stat {
  min-width: 220px;
  padding: 0.75em 1em;
}

.dashboard-stat-label {
  color: var(--text-muted);
  font-size: 0.95em;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.dashboard-stat-value {
  margin-top: 0.15em;
  font-size: 1.9em;
  line-height: 1.1;
}

@media (max-width: 600px) {
  .dashboard-stat {
    min-width: 0;
    width: 100%;
    max-width: 360px;
  }
  .dashboard-stats-row--bottom {
    margin-top: 0;
  }
  .dashboard-stat-value {
    font-size: 1.7em;
  }
}

/* Handheld optimizations (e.g., Zebra TC5x class devices) */
@media (max-width: 480px) {
  /* Stop any accidental horizontal scrolling on handhelds */
  html,
  body {
    overflow-x: hidden;
  }

  main {
    padding: 0 0.75em 1em;
  }

  /* Single-column cards on small screens */
  .location-group {
    padding: 0 0.5em;
  }

  .book-list {
    grid-template-columns: 1fr;
    padding: 0.5em;
    gap: 0.75em;
  }

  .app-logo {
    height: 56px;
  }

  header {
    padding: 0.6em;
    gap: 0.45em;
  }

  header nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5em;
    width: 100%;
    max-width: 720px;
    padding: 0;
  }

  header nav .btn-small {
    width: 100%;
    padding: 0.65em 0.6em;
    font-size: 0.9em;
    line-height: 1.15;
    white-space: normal;
    min-width: 0; /* allow grid items to shrink */
    overflow: visible; /* allow full label to show */
  }

  header nav .btn-small .nav-emoji-right {
    display: none;
  }
  header nav .btn-small .nav-emoji {
    display: inline-block;
    width: 1.15em;
    text-align: center;
  }
  header nav .btn-small .nav-text {
    display: inline-block;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    vertical-align: bottom;
  }

  .dashboard {
    margin: 1.2em auto;
    max-width: 800px;
  }
  #booksChart {
    height: 280px;
  }

  .location-group {
    margin: 0.8em auto;
  }
  /* book-list single-column already set above */
  .book-card {
    padding: 0.85em;
  }

  /* Login card should fit neatly within the viewport */
  .login-card {
    width: calc(100% - 1.25em);
    max-width: 360px;
    margin: 1.4em auto;
    padding: 1em 1em;
    border-radius: 10px;
  }

  .collapsible-header {
    padding: 0.5em 0.7em;
  }
  .collapsible-header .title {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
    font-size: 0.96em;
  }
  .collapsible-right {
    gap: 8px;
  }
  .collapsible-meta {
    font-size: 0.85em;
    opacity: 0.86;
  }

  .toggle-btn {
    width: 24px;
    height: 24px;
    font-size: 0.78em;
  }

  /* Manage Locations: keep group header on one tidy line */
  details.collapsible.room-group > summary {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
  }

  /* Hide the [LR-*] pattern on TC51 to save width */
  details.collapsible.room-group > summary .prefix-pattern {
    display: none;
  }

  details.collapsible.room-group > summary .collapsible-title {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
  }

  details.collapsible.room-group > summary .collapsible-meta {
    flex: 0 0 auto;
    font-size: 0.88em;
    white-space: nowrap;
  }

  /* Remove extra marker to avoid wrapping on small screens */
  .room-group > summary::after {
    display: none;
  }
}

@media (pointer: coarse) {
  .btn-small,
  button.btn-small {
    padding: 0.55em 0.95em;
  }
}

/* Library search area (avoid inline styles, keep it clean on handhelds) */
.search-wrap {
  max-width: 800px;
  margin: 1.5em auto;
  padding: 0 0.75em;
}

.search-wrap #searchBox {
  width: 100%;
  max-width: 520px;
  display: block;
  margin: 1em auto;
  padding: 0.6em;
  border: 2px solid var(--accent-gold);
  border-radius: 6px;
}

.search-wrap #searchBox:focus {
  outline: none;
  border-color: #ff7828;
  box-shadow: 0 0 0 2px rgba(255, 120, 40);
}

/* Book card spacing (Author / Type / Genre / divider) */
.book-card p.author {
  margin: 0.3em 0 0.45em;
  line-height: 1.25;
}

.book-card p.meta {
  margin: 0.1em 0;
  line-height: 1.25;
}

.book-card p.meta + p.meta {
  margin-top: 0;
  padding-top: 0.25em;
}

.book-card h3 {
  margin: 0.2em 0 0.35em;
  line-height: 1.2;
  min-height: 2.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card p.meta strong,
.book-card p.author strong {
  display: inline-block;
  min-width: 52px;
}

.book-card hr.book-actions-divider {
  border: 0;
  border-top: 1px solid var(--text-main);
  opacity: 0.25;
  margin: 0.75em 0 0.5em;
}

/* ---------- Book Card Action Bar ---------- */
.book-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.1rem;
}

.book-actions__group {
  display: flex;
  align-items: center;
  gap: 0;
}

.book-actions__group--right {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  min-width: 0;
}

/* Reorder arrow pair — connected pill */
.reorder-form {
  display: contents;
}

.btn-icon {
  background: var(--green-primary);
  color: #fff;
  border: none;
  padding: 0.3em 0.6em;
  font-size: 0.9em;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--green-light);
}

.btn-icon:disabled,
.btn-icon[aria-disabled="true"] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon--first {
  border-radius: 6px 0 0 6px;
  border-right: 1px solid rgba(255,255,255,0.15);
}

.btn-icon--last {
  border-radius: 0 6px 6px 0;
}

/* Action buttons: Edit / Move / Delete */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--green-primary);
  border: 1px solid var(--accent-gold-dark);
  width: 100%;
  min-height: 32px;
  padding: 0.22em 0.55em;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-action:hover {
  background: var(--green-primary);
  color: #fff;
  border-color: var(--green-primary);
}

.btn-action--danger {
  color: #b0311e;
  border-color: rgba(176, 49, 30, 0.35);
}

.btn-action--danger:hover {
  background: #b0311e;
  color: #fff;
  border-color: #b0311e;
}

.delete-form {
  display: contents;
}

@media (max-width: 420px) {
  .book-actions {
    gap: 0.35rem;
  }

  .btn-icon {
    padding: 0.26em 0.52em;
    font-size: 0.82em;
  }

  .btn-action {
    min-height: 30px;
    font-size: 0.76em;
    padding: 0.2em 0.45em;
  }
}

/* Keep shared login scene styles authoritative over legacy login rules */
.hl-login-page .login-form input {
  max-width: none;
  margin: 0;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent-gold-dark);
}

.hl-login-page .login-form .password-wrap {
  max-width: none;
  margin: 0;
}

.hl-login-page .login-form button[type="submit"].btn {
  width: auto;
  max-width: none;
  margin: 0;
  border-radius: 10px;
  padding: 0.72rem 1rem;
}

.hl-login-page .login-title {
  text-align: left;
  margin: 0;
}

.hl-login-page .login-card {
  max-width: 640px;
  margin: 0 auto;
  text-align: left;
}

/* ---------- Reading Dates ---------- */
.reading-dates {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--bg-cream);
  border: 1px solid var(--accent-gold-dark);
  border-radius: 10px;
}

.reading-dates h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--green-primary);
  letter-spacing: 0.01em;
}

.reading-dates__display {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.reading-dates__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 110px;
}

.reading-dates__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.reading-dates__value {
  font-size: 0.95rem;
  color: var(--text-main);
  font-weight: 500;
}

.reading-dates__form {
  border-top: 1px solid var(--accent-gold-dark);
  padding-top: 0.8rem;
  margin-top: 0.2rem;
}

.reading-dates__fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.reading-dates__fields .btn-small {
  margin: 0;
  min-height: 32px;
}

.reading-dates__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.reading-dates__field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reading-dates__field input[type="date"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.45rem 0.6rem;
  border: 1px solid #c9c3b4;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  color: var(--text-main);
  font-family: inherit;
}

.reading-dates__field input[type="date"]:focus {
  outline: 2px solid var(--accent-gold);
  outline-offset: 1px;
  border-color: var(--accent-gold);
}

/* Inside a book card: no outer border/background, tighter spacing */
.reading-dates--card {
  margin-top: 0.45rem;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

.reading-dates--card h3 {
  display: none;
}

.reading-dates--card .reading-dates__display {
  margin-bottom: 0.5rem;
}

.reading-dates--card .reading-dates__form {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.reading-dates--card .reading-dates__fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.reading-dates--card .reading-dates__fields .btn-small {
  grid-column: 1 / -1;
  width: 100%;
}

.btn-small--tracking {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 32px;
  margin: 0.45rem 0 0;
  padding: 0.22em 0.55em;
  border-radius: 6px;
  border: 1px dashed rgba(15, 23, 42, 0.45);
  background: rgba(15, 23, 42, 0.03);
  color: var(--green-primary);
  font-size: 0.8em;
  font-weight: 600;
  line-height: 1.1;
  box-sizing: border-box;
  opacity: 1;
}

.btn-small--tracking:focus-visible,
.btn-action:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 1px;
}

.btn-small--tracking.active {
  border-style: solid;
  border-color: var(--green-primary);
  background: var(--green-primary);
  color: #fff;
}

.btn-small--tracking:hover {
  transform: none;
}

@media (max-width: 420px) {
  .reading-dates__fields {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .reading-dates__fields .btn-small {
    width: 100%;
    margin: 0;
  }

  .btn-small--tracking {
    min-height: 30px;
    font-size: 0.76em;
    margin-top: 0.4rem;
  }

  .book-card .book-cover-wrap {
    min-height: 168px;
    margin-bottom: 0.5rem;
  }

  .book-card .book-cover-img {
    max-height: 158px;
  }

  .book-card h3 {
    min-height: 2.2em;
    font-size: 1.05em;
  }
}

@media (max-width: 560px) {
  .reading-dates--card .reading-dates__fields {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .book-card:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-gold-dark);
  }
}
