:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #5d6a84;
  --line: #d6dfef;
  --brand: #0c8c7a;
  --brand-dark: #0a6f62;
  --danger: #a62e2e;
  --danger-dark: #7f2222;
  --shadow: 0 14px 30px rgba(11, 20, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, #d5eef6 0%, rgba(213, 238, 246, 0) 40%),
    linear-gradient(180deg, #f8fbff, var(--bg));
  color: var(--ink);
}

.shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
}

.header-shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.75rem;
}

.site-title {
  margin: 0.15rem 0 0;
  font-size: 1.4rem;
}

.site-nav {
  display: flex;
  gap: 0.7rem;
}

.nav-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 0.45rem;
}

.nav-link:hover {
  background: #e7edf9;
}

.content-shell {
  padding-top: 1.35rem;
  padding-bottom: 2.5rem;
}

.hero {
  margin-bottom: 1.25rem;
}

.hero-kicker {
  color: var(--brand-dark);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  margin: 0;
}

.hero h2 {
  margin: 0.35rem 0 0.55rem;
  font-size: 1.95rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 65ch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 1rem;
  padding: 1rem;
}

.stats-panel {
  margin-bottom: 1rem;
}

.stats-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.stat-card {
  border: 1px solid #d3ddee;
  border-radius: 0.8rem;
  background: #f8fbff;
  padding: 0.65rem 0.75rem;
}

.stat-card-wide {
  grid-column: span 2;
}

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--ink);
}

.stat-meta {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-rank-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.stat-rank-list li {
  margin-bottom: 0.2rem;
}

.stat-rank-list li:last-child {
  margin-bottom: 0;
}

.currently-reading-panel {
  background: var(--currently-reading-bg, #a77e58);
  border-color: var(--currently-reading-bg, #a77e58);
  color: var(--currently-reading-text, #fff);
  margin-bottom: 1rem;
}

.currently-reading-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.7rem;
}

.currently-reading-item {
  border-bottom: 1px solid var(--currently-reading-divider, rgba(255, 255, 255, 0.28));
  padding-bottom: 0.45rem;
}

.currently-reading-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.currently-reading-name {
  margin: 0;
  font-weight: 700;
}

.currently-reading-author,
.currently-reading-empty {
  margin: 0.1rem 0 0;
  color: var(--currently-reading-subtle, rgba(255, 255, 255, 0.9));
}

.auth-panel {
  max-width: 440px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-actions form {
  margin: 0;
}

.currently-reading-preview-wrap {
  margin-top: 1rem;
}

.currently-reading-preview-wrap h3 {
  margin: 0 0 0.6rem;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-tab {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid #ccd7eb;
  background: #f3f7ff;
  border-radius: 0.55rem;
  padding: 0.4rem 0.7rem;
  font-weight: 650;
}

.admin-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.genres-panel {
  margin-top: 1rem;
}

.genre-chip-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.genre-chip {
  border: 1px solid #d3d9ea;
  background: #f4f7ff;
  color: #24324d;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.genre-list {
  color: var(--muted);
}

.count {
  color: var(--muted);
  font-size: 0.95rem;
}

.search-form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.search-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.search-form input[type="search"] {
  min-width: 260px;
  border: 1px solid #b9c6de;
  border-radius: 0.55rem;
  padding: 0.53rem 0.62rem;
  font: inherit;
}

.search-form select {
  border: 1px solid #b9c6de;
  border-radius: 0.55rem;
  padding: 0.53rem 0.62rem;
  font: inherit;
  background: #fff;
}

.sort-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
}

.sort-link.active {
  color: var(--brand-dark);
}

.table-wrap {
  overflow-x: auto;
}

.book-table {
  width: 100%;
  border-collapse: collapse;
}

.book-table th,
.book-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.3rem;
  text-align: left;
  vertical-align: top;
}

.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.pagination-info {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.actions-col {
  text-align: right;
  white-space: nowrap;
}

.actions-col form {
  display: inline;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.field input {
  width: 100%;
  border: 1px solid #b9c6de;
  border-radius: 0.55rem;
  padding: 0.6rem 0.65rem;
  font: inherit;
}

.field select {
  width: 100%;
  border: 1px solid #b9c6de;
  border-radius: 0.55rem;
  padding: 0.6rem 0.65rem;
  font: inherit;
  background: #fff;
}

.field input:focus {
  border-color: #4387e6;
  outline: 2px solid rgba(67, 135, 230, 0.18);
  outline-offset: 1px;
}

.field select:focus {
  border-color: #4387e6;
  outline: 2px solid rgba(67, 135, 230, 0.18);
  outline-offset: 1px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.checkbox-option input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.status-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid transparent;
}

.status-in_library {
  color: #12643a;
  background: #e1f6ea;
  border-color: #9ed8b5;
}

.status-lent {
  color: #8b2020;
  background: #fbe8e8;
  border-color: #e9b1b1;
}

.status-backlog {
  color: #8c4a06;
  background: #ffefdd;
  border-color: #f3cd9a;
}

.status-currently_reading {
  color: #5e432f;
  background: #ebddcf;
  border-color: #c8a98d;
}

.status-wishlist {
  color: #4f2e70;
  background: #efe3fb;
  border-color: #ceb0ec;
}

.button,
button,
input[type="submit"] {
  display: inline-block;
  border: 0;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  border-radius: 0.55rem;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--brand-dark);
}

.button-secondary {
  background: #eef2fb;
  color: var(--ink);
}

.button-secondary:hover {
  background: #dde6fa;
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: var(--danger-dark);
}

.empty-state {
  color: var(--muted);
}

.flash {
  border-radius: 0.65rem;
  padding: 0.7rem 0.8rem;
  margin: 0 0 0.95rem;
  font-weight: 600;
}

.flash-notice {
  background: #e2f7f3;
  color: #0d6356;
  border: 1px solid #a7ddd5;
}

.flash-alert {
  background: #fde9e9;
  color: #8e2b2b;
  border: 1px solid #f3baba;
}

.error-box {
  border: 1px solid #f3baba;
  border-radius: 0.7rem;
  background: #fff1f1;
  padding: 0.7rem;
}

.error-box h3 {
  margin: 0;
  font-size: 0.95rem;
}

.error-box ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

@media (max-width: 700px) {
  .header-shell,
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card-wide {
    grid-column: span 2;
  }

  .actions-col {
    text-align: left;
    white-space: normal;
  }

  .hero h2 {
    font-size: 1.6rem;
  }

  .search-form input[type="search"] {
    min-width: 100%;
  }
}

.chip-autocomplete {
  border: 1px solid #b9c6de;
  border-radius: 0.55rem;
  padding: 0.45rem;
  background: #fff;
  position: relative;
}

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.chip-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.52rem;
  border-radius: 999px;
  background: #edf3ff;
  color: #22324f;
  border: 1px solid #c8d5ef;
  font-size: 0.84rem;
  font-weight: 600;
}

.chip-remove {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: #44516a;
}

.chip-input {
  width: 100%;
  border: 0;
  outline: none;
  font: inherit;
  padding: 0.2rem 0;
  background: transparent;
}

.chip-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  background: #fff;
  border: 1px solid #cfdaf0;
  border-radius: 0.55rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  z-index: 20;
  overflow: hidden;
}

.chip-suggestion {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #edf1f9;
  background: #fff;
  color: #111;
  padding: 0.52rem 0.62rem;
  font: inherit;
  cursor: pointer;
}

.chip-suggestion:last-child {
  border-bottom: 0;
}

.chip-suggestion[data-highlighted='true'],
.chip-suggestion:hover {
  background: #f2f6ff;
}
