/* ==========================================================================
   RCCC Library v2 — Design language from school.rccc.org
   Rutgers Community Christian Church — 若歌教會
   Clean, welcoming, accessible; WCAG 2.1 Level AA; mobile-first
   ========================================================================== */

/* --- RCCC / school.rccc.org design tokens -------------------------------- */
:root {
  /* RCCC primary: #2c3e50 (HSL 210 29% 24%) */
  --rccc-primary: 210 29% 24%;
  --rccc-primary-light: 210 25% 32%;
  --rccc-cream: 40 20% 97%;
  --rccc-warm-white: 40 15% 99%;
  --rccc-gold: 42 75% 45%;
  --rccc-gold-foreground: 0 0% 100%;

  /* Core palette — RCCC #2c3e50 */
  --background: 40 15% 99%;
  --foreground: 210 29% 24%;
  --card: 0 0% 100%;
  --card-foreground: 210 29% 24%;
  --popover: 0 0% 100%;
  --popover-foreground: 210 29% 24%;
  --primary: 210 29% 24%;
  --primary-foreground: 0 0% 100%;
  --secondary: 40 20% 94%;
  --secondary-foreground: 210 29% 24%;
  --muted: 40 15% 94%;
  --muted-foreground: 210 15% 42%;
  --accent: 40 25% 92%;
  --accent-foreground: 210 29% 24%;
  --destructive: 0 72% 48%;
  --destructive-foreground: 0 0% 100%;
  --border: 40 12% 88%;
  --input: 40 12% 88%;
  --ring: 210 29% 24%;
  --radius: 0.375rem;

  /* Typography — clear, readable (school site style) */
  --font-sans: "Helvetica Neue", Helvetica, Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --text-base: 1rem;
  --text-sm: 0.875rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --color-success: 142.1 76.2% 36.3%;
  --color-success-bg: 138 76% 97%;
  --color-warning: 38 92% 50%;
  --color-warning-bg: 48 96% 89%;

  --content-max-width: 75rem;
  --touch-target: 44px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  /* Reserve scrollbar space to prevent horizontal shift when navigating between long/short pages */
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Skip link (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  text-decoration: none;
  z-index: 100;
  border-radius: var(--radius);
}
.skip-link:focus {
  top: var(--space-4);
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Layout --------------------------------------------------------------- */
.app-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-4);
  flex: 1;
  width: 100%;
}

main {
  min-height: 40vh;
}

/* --- Headings (school.rccc.org section style) ----------------------------- */
h1, h2, h3, h4 {
  margin-top: 0;
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
  font-weight: 600;
  color: hsl(var(--foreground));
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

/* --- RCCC banner (own role; separate from Library row) -------------------- */
.rccc-banner {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: var(--space-1) var(--space-4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  /* Reserve height so logo image load does not cause layout shift */
  min-height: calc(var(--space-1) * 2 + 36px);
}

.rccc-banner__inner {
  max-width: var(--content-max-width);
  margin: auto auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rccc-banner__brand {
  display: inline-block;
  text-decoration: none;
  line-height: 0;
}
.rccc-banner__brand:hover {
  opacity: 0.92;
}

.rccc-banner__logo {
  display: block;
  height: auto;
  max-height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* --- Library nav row (second row; app navigation) ------------------------ */
.library-nav {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  padding: var(--space-2) var(--space-4);
  margin-bottom: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.library-nav nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  max-width: var(--content-max-width);
  margin: 0 auto;
  position: relative;
}

.library-nav__brand {
  font-weight: 600;
  font-size: var(--text-lg);
  color: hsl(var(--foreground));
  text-decoration: none;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.library-nav__brand:hover {
  color: hsl(var(--primary));
}

.staff-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}
.staff-nav .nav-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}
.staff-nav .nav-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-group-label {
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: var(--space-2);
  padding-right: var(--space-2);
  border-right: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.nav-group:not(.nav-dropdown) .nav-group-label:last-of-type { border-right: none; margin-right: 0; padding-right: 0; }

.library-nav nav a {
  padding: var(--space-2) var(--space-3);
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--foreground));
  text-decoration: none;
  border-radius: var(--radius);
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.library-nav nav a:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* View toggle (Staff view / Member view) — hollow pill to distinguish from nav links */
.library-nav nav a.nav-view-toggle {
  background: transparent;
  color: hsl(var(--primary));
  border: 1.5px solid hsl(var(--primary));
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
}
.library-nav nav a.nav-view-toggle:hover {
  background: hsl(var(--rccc-gold) / 0.15);
  color: hsl(var(--foreground));
  border-color: hsl(var(--rccc-gold));
}

/* Current page tab */
.library-nav nav a.nav-link--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.library-nav nav a.nav-link--active:hover {
  background: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
.nav-dropdown-trigger.nav-link--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.nav-dropdown-trigger.nav-link--active:hover {
  background: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
.nav-dropdown .nav-dropdown-panel a.nav-link--active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-weight: 600;
}

/* Dropdown — in header (light panel on dark) */
.nav-dropdown {
  position: relative;
}
.nav-dropdown .nav-dropdown-trigger {
  list-style: none;
  padding: var(--space-2) var(--space-3);
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  color: hsl(var(--foreground));
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius);
  user-select: none;
  transition: background-color 0.15s, color 0.15s;
}
/* Active dropdown trigger: ensure light text on primary background (overrides .nav-dropdown .nav-dropdown-trigger color) */
.nav-dropdown .nav-dropdown-trigger.nav-link--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.nav-dropdown .nav-dropdown-trigger.nav-link--active:hover {
  background: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
.nav-dropdown .nav-dropdown-trigger::-webkit-details-marker { display: none; }
.nav-dropdown .nav-dropdown-trigger::after {
  content: "";
  border: 4px solid transparent;
  border-top-color: currentColor;
  margin-left: 2px;
  opacity: 0.7;
}
.nav-dropdown[open] .nav-dropdown-trigger::after {
  border-top-color: transparent;
  border-bottom-color: currentColor;
  margin-top: -4px;
}
.nav-dropdown .nav-dropdown-trigger:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
.nav-dropdown .nav-dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-1);
  min-width: 12rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: var(--space-2);
  z-index: 50;
}
.nav-dropdown .nav-dropdown-panel a {
  display: block;
  padding: var(--space-2) var(--space-3);
  min-height: auto;
  min-width: auto;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
}
.nav-dropdown .nav-dropdown-panel a:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

nav .btn-signout {
  margin-left: auto;
  flex-shrink: 0;
}
.staff-nav .btn-signout { margin-left: auto; }

/* User menu — avatar with dropdown (Sign out) */
.user-menu {
  margin-left: auto;
  flex-shrink: 0;
}
.user-menu .user-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  border-radius: var(--radius);
}
.user-menu .user-menu__trigger::after {
  margin-left: var(--space-1);
}
.user-menu__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
}
.user-menu .user-menu__trigger:hover .user-menu__avatar {
  background: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
.user-menu__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}
.user-menu .user-menu__trigger:hover .user-menu__label {
  color: inherit;
}
.user-menu__panel {
  left: auto;
  right: 0;
  min-width: 11rem;
  max-width: min(11rem, calc(100vw - 2 * var(--space-4)));
}
@media (max-width: 380px) {
  /* On very narrow screens, open panel to the right so it stays in view */
  .user-menu__panel {
    left: calc(100% + var(--space-1));
    right: auto;
    max-width: calc(100vw - 2 * var(--space-4));
  }
}
.user-menu__signout {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.user-menu__signout:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.library-nav .btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.library-nav .btn-primary:hover {
  background: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--rccc-primary-light));
}

.library-nav form.btn input[type="submit"],
.library-nav form.btn button {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--input));
}
.library-nav form.btn input[type="submit"]:hover,
.library-nav form.btn button:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--input));
}

/* Mobile hamburger menu: trigger (hamburger) and dropdown panel */
.nav-mobile-menu {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}
.nav-mobile-menu__trigger {
  display: none; /* shown only on mobile via media query */
  list-style: none;
  padding: var(--space-2) var(--space-3);
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  margin-left: auto;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0;
  position: relative;
}
.nav-mobile-menu__trigger::-webkit-details-marker { display: none; }
.nav-mobile-menu__trigger::before,
.nav-mobile-menu__trigger::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.25rem;
  height: 2px;
  margin-left: -0.625rem; /* half of width for exact center */
  margin-top: -1px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-mobile-menu__trigger::before {
  transform: translateY(-6px);
}
.nav-mobile-menu__trigger::after {
  transform: translateY(6px);
}
.nav-mobile-menu__trigger .nav-mobile-menu__hamburger-line {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1.25rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
/* Balanced X: both lines centered at same point, rotated ±45deg */
.nav-mobile-menu[open] .nav-mobile-menu__trigger::before {
  transform: rotate(45deg);
}
.nav-mobile-menu[open] .nav-mobile-menu__trigger .nav-mobile-menu__hamburger-line {
  opacity: 0;
}
.nav-mobile-menu[open] .nav-mobile-menu__trigger::after {
  transform: rotate(-45deg);
}
.nav-mobile-menu__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

@media (min-width: 1024px) {
  .nav-mobile-menu__trigger {
    display: none;
  }
  /* Details and panel take remaining width */
  .library-nav nav .nav-mobile-menu {
    display: flex !important;
    flex: 1 1 0%;
    min-width: 0;
  }
  .nav-mobile-menu .nav-mobile-menu__panel {
    display: flex !important;
    flex: 1 1 0%;
    min-width: 0;
    min-height: var(--touch-target); /* visible row height when panel is empty (e.g. not logged in) */
    padding-right: 14rem; /* leave space for absolutely positioned user menu */
  }
  /* Pin user menu to right edge of nav so it stays right-aligned */
  .nav-mobile-menu__panel .user-menu {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
  }
}

@media (max-width: 1023px) {
  .library-nav {
    position: relative;
  }
  .library-nav nav {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .library-nav .library-nav__brand {
    flex: 0 0 auto;
  }
  .nav-mobile-menu {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }
  .nav-mobile-menu__trigger {
    display: block;
    flex-shrink: 0;
    align-self: flex-end;
  }
  .nav-mobile-menu__panel {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid hsl(var(--border));
    /* Position full width below header (relative to .library-nav) */
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    width: 100%;
    margin: 0;
    background: hsl(var(--card));
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
    z-index: 40;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  .nav-mobile-menu[open] .nav-mobile-menu__panel {
    display: flex;
  }
  .nav-mobile-menu__panel > * {
    width: 100%;
    max-width: 100%;
  }
  .nav-mobile-menu__panel a,
  .nav-mobile-menu__panel .nav-dropdown-trigger {
    justify-content: flex-start;
    width: 100%;
    text-align: left;
  }
  .nav-mobile-menu__panel .nav-groups {
    align-items: stretch;
    width: 100%;
  }
  .nav-mobile-menu__panel .nav-group {
    align-items: stretch;
  }
  /* Center Admin and its sub-menu in the hamburger panel */
  .nav-mobile-menu__panel .nav-dropdown {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .nav-mobile-menu__panel .nav-dropdown .nav-dropdown-trigger {
    justify-content: center;
    width: 100%;
  }
  .nav-mobile-menu__panel .nav-dropdown .nav-dropdown-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .nav-mobile-menu__panel .nav-dropdown .nav-dropdown-panel a {
    justify-content: center;
  }
  .nav-mobile-menu__panel .user-menu {
    margin-left: 0;
  }
  .staff-nav .nav-groups {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  .staff-nav .nav-group {
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
    padding-right: 0;
    padding-bottom: var(--space-2);
    margin-right: 0;
    margin-bottom: 0;
  }
  .staff-nav .nav-group:last-of-type { border-bottom: none; padding-bottom: 0; }
  .nav-group-label {
    border-right: none;
    border-bottom: none;
    margin-right: 0;
    padding-right: 0;
    width: 100%;
    margin-bottom: var(--space-1);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid hsl(var(--border));
  }
  .nav-group .nav-group-label + a { margin-left: 0; }
  .nav-group {
    flex-direction: column;
    align-items: stretch;
  }
  .nav-dropdown {
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
    padding-bottom: var(--space-2);
  }
  .nav-dropdown .nav-dropdown-panel {
    position: static;
    margin-top: var(--space-2);
    box-shadow: none;
    border: none;
    background: hsl(var(--muted));
    border-radius: calc(var(--radius) - 2px);
  }
  nav .btn-signout,
  .staff-nav .btn-signout { margin-left: 0; }
}

/* --- Breadcrumbs ---------------------------------------------------------- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  margin-bottom: var(--space-2);
}

.breadcrumbs a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumbs a:hover {
  color: hsl(var(--foreground));
}

.breadcrumbs span {
  color: hsl(var(--muted-foreground) / 0.8);
  user-select: none;
}
.breadcrumbs span:last-of-type {
  color: hsl(var(--foreground));
  font-weight: 500;
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.btn-primary:hover {
  background: hsl(var(--rccc-primary-light));
  border-color: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--input));
}
.btn-secondary:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}
.btn-danger:hover {
  background: hsl(0 72% 42%);
  border-color: hsl(0 72% 42%);
  color: hsl(var(--destructive-foreground));
}

.btn-sm {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* --- Status badge (shared component) --------------------------------------- */
.status-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius);
  white-space: nowrap;
}
.status-badge--success {
  background: hsl(var(--color-success-bg));
  color: hsl(var(--color-success));
}
.status-badge--info {
  background: hsl(210 40% 96%);
  color: hsl(210 50% 35%);
}
.status-badge--warning {
  background: hsl(var(--color-warning-bg));
  color: hsl(var(--color-warning));
}
.status-badge--danger {
  background: hsl(0 72% 97%);
  color: hsl(var(--destructive));
}
.status-badge--muted {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.status-badge--neutral {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

form:not(.btn) input[type="submit"],
form:not(.btn) button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--primary));
  cursor: pointer;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  transition: background-color 0.15s, border-color 0.15s;
}
form:not(.btn) input[type="submit"]:hover,
form:not(.btn) button[type="submit"]:hover {
  background: hsl(var(--rccc-primary-light));
  border-color: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
form:not(.btn) input[type="submit"]:focus-visible,
form:not(.btn) button[type="submit"]:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

form.btn {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  outline: none;
}
form.btn input[type="submit"],
form.btn button {
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  cursor: pointer;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: none;
  outline: none;
  box-sizing: border-box;
}
form.btn input[type="submit"]:focus-visible,
form.btn button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
form.btn input[type="submit"]:hover,
form.btn button:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
form.btn.btn-primary input[type="submit"],
form.btn.btn-primary button {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
form.btn.btn-primary input[type="submit"]:hover,
form.btn.btn-primary button:hover {
  background: hsl(var(--rccc-primary-light));
  border-color: hsl(var(--rccc-primary-light));
  color: hsl(var(--primary-foreground));
}
form.btn.btn-secondary input[type="submit"],
form.btn.btn-secondary button {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 1px hsl(var(--input));
}
form.btn.btn-secondary input[type="submit"]:hover,
form.btn.btn-secondary button:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  box-shadow: inset 0 0 0 1px hsl(var(--input));
}
form.btn.btn-danger input[type="submit"],
form.btn.btn-danger button {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}
form.btn.btn-danger input[type="submit"]:hover,
form.btn.btn-danger button:hover {
  background: hsl(0 72% 42%);
  border-color: hsl(0 72% 42%);
  color: hsl(var(--destructive-foreground));
}
form.btn.btn-sm input[type="submit"],
form.btn.btn-sm button {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* --- Forms ---------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-4);
}

form label {
  display: block;
  font-weight: 500;
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  color: hsl(var(--foreground));
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="search"],
form select,
form textarea {
  width: 100%;
  max-width: 28rem;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  line-height: var(--leading-normal);
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background));
  min-height: var(--touch-target);
  transition: border-color 0.15s, box-shadow 0.15s;
}
form input:focus,
form select:focus,
form textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  outline: none;
}
form input::placeholder,
form textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

form textarea {
  min-height: 6rem;
  resize: vertical;
}

form .field_with_errors input,
form .field_with_errors select,
form .field_with_errors textarea {
  border-color: hsl(var(--destructive));
}
form .field-error {
  font-size: var(--text-sm);
  color: hsl(var(--destructive));
  margin-top: var(--space-1);
}

.form-actions {
  margin-top: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.form-actions .btn-primary { order: -1; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
}
.form-row .form-group { margin-bottom: 0; }
.form-row input,
.form-row select { max-width: none; }

/* --- Flash ---------------------------------------------------------------- */
.flash-messages {
  margin-bottom: var(--space-4);
}

.flash-notice,
.flash-alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  border: 1px solid;
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.flash-notice {
  background: hsl(var(--color-success-bg));
  border-color: hsl(var(--color-success) / 0.5);
  color: hsl(var(--color-success));
  border-left-width: 4px;
  border-left-style: solid;
  border-left-color: hsl(var(--color-success));
}
.flash-alert {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.35);
  color: hsl(var(--destructive));
  border-left-width: 4px;
  border-left-style: solid;
  border-left-color: hsl(var(--destructive));
}

.notice { color: hsl(var(--color-success)); }
.alert { color: hsl(var(--destructive)); }

/* --- Tables --------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--space-6);
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

table {
  width: 100%;
  border-collapse: collapse;
  caption-side: bottom;
  font-size: var(--text-sm);
}

thead tr {
  border-bottom: 1px solid hsl(var(--border));
}

th {
  height: 3rem;
  padding: 0 var(--space-4);
  text-align: left;
  vertical-align: middle;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

td {
  padding: var(--space-4);
  vertical-align: middle;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

tbody tr {
  transition: background-color 0.15s;
}
tbody tr:hover td {
  background: hsl(var(--muted) / 0.5);
}

tbody tr:last-child td {
  border-bottom: none;
}

th a,
td a {
  color: hsl(var(--primary));
  text-decoration: none;
  font-weight: 500;
}
th a:hover,
td a:hover {
  text-decoration: underline;
}

/* Actions cell: link/form buttons side by side with gap */
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.actions-cell form.btn button,
.actions-cell form.btn input[type="submit"] {
  width: auto;
}

.empty-state {
  padding: var(--space-12);
  text-align: center;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--card));
  border-radius: var(--radius);
  border: 1px dashed hsl(var(--border));
  margin-bottom: var(--space-6);
}
.empty-state p { margin: 0 0 var(--space-2); }

.list-divider {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list-divider li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.list-divider li:last-child { border-bottom: none; }
.list-divider .list-item-content { flex: 1; }

/* --- Member: My checkouts list -------------------------------------------- */
.checkouts-section { margin-bottom: var(--space-6); }
.checkout-list__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.checkout-list__title {
  font-weight: 500;
  color: hsl(var(--foreground));
}
.checkout-list__meta {
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
}
.checkout-list__badge {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 0.125rem var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
}
.checkout-list__badge--overdue {
  background: hsl(var(--color-warning-bg));
  color: hsl(var(--color-warning));
}
/* Highlight overdue rows */
.checkout-list__item--overdue {
  background: hsl(var(--destructive) / 0.1);
  border-left: 4px solid hsl(var(--destructive));
  margin-left: var(--space-2);
  padding: var(--space-4) var(--space-2) var(--space-4) var(--space-2);
}
.checkout-list__item--overdue .checkout-list__title {
  font-weight: 600;
}
.checkout-list__item--overdue .checkout-list__meta {
  color: hsl(var(--destructive));
  font-weight: 500;
}
.pagination-wrap {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border));
}

/* --- Cards (school.rccc.org section style) -------------------------------- */
.card {
  background: hsl(var(--card));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.card-title {
  margin-top: 0;
  margin-bottom: var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
  color: hsl(var(--card-foreground));
}

/* --- Confirm dialog -------------------------------------------------------- */
.confirm-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(28rem, calc(100vw - 2rem));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.confirm-dialog__content {
  padding: var(--space-6);
}
.confirm-dialog__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 700;
  color: hsl(var(--destructive));
}
.confirm-dialog__body {
  margin: 0 0 var(--space-5);
  color: hsl(var(--foreground));
  line-height: var(--leading-normal);
}
.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* --- Tabs ------------------------------------------------------------------ */
.tabs {
  display: flex;
  margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-6);
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 var(--space-2);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover {
  color: hsl(var(--foreground));
}
.tab--active {
  color: hsl(var(--primary));
  border-bottom-color: hsl(var(--primary));
}

/* --- Badge ----------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 var(--space-1);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.badge--danger {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

/* --- Staff dashboard CTA (actionable overview) ----------------------------- */
.dashboard-cta {
  margin-bottom: var(--space-8);
}
.dashboard-cta .dashboard-cta__grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .dashboard-cta .dashboard-cta__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1024px) {
  .dashboard-cta .dashboard-cta__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.dashboard-cta__card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: var(--space-6);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 10rem;
}
.dashboard-cta__card:hover {
  border-color: hsl(var(--primary) / 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.dashboard-cta__card:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
.dashboard-cta__label {
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  margin-bottom: var(--space-1);
}
.dashboard-cta__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: var(--leading-tight);
}
.dashboard-cta__desc {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: hsl(var(--muted-foreground));
  flex: 1;
}
.dashboard-cta__action {
  pointer-events: none;
}

/* --- Detail / record view (e.g. book show) ---------------------------------- */
.detail-hero {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}
.detail-hero__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: hsl(var(--foreground));
  flex: 1;
  min-width: 0;
}
.detail-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.detail-section {
  background: hsl(var(--card));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.detail-section__title {
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid hsl(var(--border));
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}
.detail-grid {
  display: grid;
  gap: var(--space-3) var(--space-8);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .detail-grid {
    grid-template-columns: minmax(10rem, auto) 1fr;
  }
}
.detail-grid__row {
  display: contents;
}
.detail-grid__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: var(--space-1) 0;
}
.detail-grid__value {
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  padding: var(--space-1) 0;
  min-width: 0;
}
.detail-grid__value--block {
  grid-column: 1 / -1;
}
@media (min-width: 640px) {
  .detail-grid__value--block {
    grid-column: 2;
  }
}
.detail-section__body {
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  line-height: var(--leading-normal);
  margin: 0;
}
.detail-section__footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border));
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
}

.detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}
.detail-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid hsl(var(--border));
}
.detail-list__item:last-child {
  border-bottom: none;
}
.detail-list__link {
  color: hsl(var(--primary));
  text-decoration: none;
  font-weight: 500;
}
.detail-list__link:hover {
  text-decoration: underline;
}
.detail-list__meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.875em;
}

/* --- Member: Book detail (show) ------------------------------------------- */
.book-detail {
  margin-bottom: var(--space-8);
}

.book-detail__layout {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 640px) {
  .book-detail__layout {
    grid-template-columns: minmax(10rem, 200px) 1fr;
    gap: var(--space-10);
  }
}

@media (min-width: 768px) {
  .book-detail__layout {
    grid-template-columns: minmax(12rem, 220px) 1fr;
  }
}

/* Book cover placeholder (spine + face) */
.book-detail__cover {
  position: sticky;
  top: var(--space-4);
}

.book-cover {
  display: flex;
  align-items: stretch;
  border-radius: 2px 6px 6px 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  max-width: 100%;
  aspect-ratio: 140 / 200;
  min-height: 180px;
}

.book-cover__spine {
  width: 12%;
  min-width: 14px;
  background: linear-gradient(90deg, hsl(var(--primary)) 0%, hsl(var(--rccc-primary-light)) 100%);
  flex-shrink: 0;
}

.book-cover__face {
  flex: 1;
  background: linear-gradient(145deg, hsl(var(--card)) 0%, hsl(var(--muted)) 100%);
  border: 1px solid hsl(var(--border));
  border-left: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-4);
  text-align: center;
  gap: var(--space-2);
}

.book-cover__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-cover__author {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-detail__main {
  min-width: 0;
}

.book-detail__header {
  margin-bottom: var(--space-6);
}

.book-detail__title {
  margin: 0 0 var(--space-2);
  font-size: clamp(1.35rem, 3vw, 1.875rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: hsl(var(--foreground));
}

.book-detail__authors {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  color: hsl(var(--muted-foreground));
  line-height: var(--leading-normal);
}

.book-detail__badge {
  margin-top: var(--space-2);
}

.book-detail__meta {
  margin-bottom: var(--space-6);
}

.book-detail__description {
  margin-bottom: var(--space-6);
}

.book-detail__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border));
}

.book-detail__reserve {
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
}

.book-detail__unavailable {
  font-size: var(--text-sm);
  margin: 0;
  padding: var(--space-2) 0;
}

/* --- Pagination ----------------------------------------------------------- */
/* Kaminari wraps each item in a span (e.g. <span class="page"><a>2</a></span>).
   Style only the visible control (a or span.current/span.gap), not wrapper spans,
   so we get a single border instead of span + inner a = double border. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}
.pagination nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}
/* Links (page numbers, prev, next): style the <a> only */
.pagination a {
  padding: var(--space-2) var(--space-3);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  text-decoration: none;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  font-weight: 500;
  border: 1px solid hsl(var(--border));
  box-shadow: none;
  outline: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pagination a:hover:not(.disabled) {
  background: hsl(var(--muted));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.pagination a:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
/* Current page: Kaminari outputs <span class="page current">1</span> (no inner a) */
.pagination span.current {
  padding: var(--space-2) var(--space-3);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 500;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: 1px solid hsl(var(--primary));
  cursor: default;
}
/* Gap (ellipsis): <span class="page gap">...</span> */
.pagination span.gap {
  padding: var(--space-2) var(--space-1);
  min-width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: default;
}
/* Wrapper spans (e.g. span.page with link inside, span.next): no border so only inner <a> shows one ring.
   Exclude span.page.current so the current page (no inner <a>) stays visible. */
.pagination span.page:not(.current),
.pagination span.prev,
.pagination span.next,
.pagination span.first,
.pagination span.last {
  border: none;
  background: none;
  box-shadow: none;
  padding: 0;
  min-width: 0;
  min-height: 0;
  display: contents;
}
.pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Page header --------------------------------------------------------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid hsl(var(--border));
}

.page-header__title-block {
  flex: 1;
  min-width: 0;
}

.page-header h1 {
  margin: 0 0 var(--space-1);
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: hsl(var(--foreground));
}

.page-header__description {
  margin: 0;
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  line-height: var(--leading-normal);
  max-width: 42rem;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

/* --- Scanner / barcode UX ------------------------------------------------- */
.scan-input-wrap {
  margin-bottom: var(--space-4);
}
.scan-input-wrap label {
  display: block;
  font-weight: 500;
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  color: hsl(var(--foreground));
}
.scan-input-wrap input {
  width: 100%;
  max-width: 20rem;
  padding: var(--space-3);
  font-size: var(--text-lg);
  font-family: inherit;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  min-height: var(--touch-target);
  background: hsl(var(--background));
}
.scan-input-wrap input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
  outline: none;
}
.scan-cart-list,
.scan-result-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 var(--space-4);
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}
.scan-cart-list li,
.scan-result-list li {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid hsl(var(--border));
}
.scan-cart-list li:last-child,
.scan-result-list li:last-child { border-bottom: none; }
.scan-result-list li.scan-result-success {
  color: hsl(var(--color-success));
  font-weight: 500;
}
.scan-result-list li.scan-result-error {
  color: hsl(var(--destructive));
  font-weight: 500;
}

.member-match-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.member-match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid hsl(var(--border));
}
.member-match-item:last-child { border-bottom: none; }
.member-match-info { flex: 1; min-width: 0; }
.member-match-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex-shrink: 0;
}

.checkout-member-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.checkout-member-row .checkout-member-label { margin: 0; flex: 1; min-width: 0; }

/* --- Grouped list header (e.g. reservations grouped by member) ------------- */
.grouped-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.grouped-list-header > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* --- Site footer — school.rccc.org style (聯絡資訊, 快速連結) ------------ */
.site-footer {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  margin-top: var(--space-10);
  padding: var(--space-8) var(--space-4);
}

footer.site-footer .site-footer__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

@media (min-width: 640px) {
  footer.site-footer .site-footer__inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
  }
  footer.site-footer .site-footer__brand {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  footer.site-footer .site-footer__inner {
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-10);
  }
  footer.site-footer .site-footer__brand {
    grid-column: auto;
  }
}

.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer__brand img {
  height: 40px;
  width: 60%;
  object-fit: contain;
  display: block;
  opacity: 0.95;
  flex-shrink: 0;
}
.site-footer__brand .site-footer__org {
  font-weight: 600;
  font-size: var(--text-base);
  color: hsl(var(--primary-foreground));
}
.site-footer__brand .site-footer__tagline {
  font-size: var(--text-sm);
  color: hsl(var(--primary-foreground) / 0.85);
}

.site-footer__section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--primary-foreground) / 0.9);
  margin: 0 0 var(--space-3);
}

.site-footer__contact address {
  font-style: normal;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: hsl(var(--primary-foreground) / 0.9);
}
.site-footer__contact a {
  color: hsl(var(--primary-foreground));
  text-decoration: none;
}
.site-footer__contact a:hover {
  text-decoration: underline;
}

.site-footer__links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer__links li {
  margin-bottom: var(--space-2);
}
.site-footer__links a {
  color: hsl(var(--primary-foreground) / 0.9);
  text-decoration: none;
  font-size: var(--text-sm);
}
.site-footer__links a:hover {
  color: hsl(var(--primary-foreground));
  text-decoration: underline;
}

.site-footer__bottom {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-top: var(--space-6);
  margin-top: var(--space-6);
  border-top: 1px solid hsl(var(--primary-foreground) / 0.2);
  font-size: var(--text-sm);
  color: hsl(var(--primary-foreground) / 0.8);
}
.site-footer__bottom a {
  color: hsl(var(--primary-foreground) / 0.9);
  text-decoration: none;
}
.site-footer__bottom a:hover {
  text-decoration: underline;
}

/* --- Home hero (school.rccc.org landing style) ---------------------------- */
.hero {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  background: linear-gradient(180deg, hsl(var(--muted)) 0%, hsl(var(--background)) 100%);
  border-radius: var(--radius);
  margin-bottom: var(--space-8);
  border: 1px solid hsl(var(--border));
}
.hero__title {
  margin: 0 0 var(--space-2);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  color: hsl(var(--foreground));
}
.hero__subtitle {
  margin: 0 0 var(--space-6);
  font-size: var(--text-lg);
  color: hsl(var(--muted-foreground));
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  align-items: center;
}

/* --- Utilities ----------------------------------------------------------- */
.text-muted {
  color: hsl(var(--muted-foreground));
}
.form-hint {
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  margin-top: var(--space-1);
}
.form-hint--inline {
  font-weight: 400;
  margin-top: 0;
}

/* --- Dependent rows ------------------------------------------------------- */
.dependent-rows {
  margin-bottom: var(--space-3);
}
.dependent-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
  background: hsl(var(--muted) / 0.4);
}
.dependent-row__fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  flex: 1;
  align-items: flex-end;
}
.dependent-row__fields .form-group {
  flex: 1;
  min-width: 9rem;
  margin-bottom: 0;
}
.dependent-row__grade {
  flex: 0 1 7rem !important;
}
.dependent-row__fields input {
  max-width: none;
  width: 100%;
}
.dependent-row__remove {
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}

.badge-ready {
  background: #d1fae5;
  color: #065f46;
}
