* { box-sizing: border-box; }
body {
  margin: 0;
  color: #172026;
  background: #f6f7f3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: #245d63; text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #dfe4dc;
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 32px;
}
.brand { color: #172026; font-size: 22px; font-weight: 700; }
.github-link {
  align-items: center;
  background: #172026;
  border: 1px solid #172026;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(23, 32, 38, 0.12);
  color: #ffffff;
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
  line-height: 1;
  padding: 9px 14px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.github-link__icon {
  display: block;
  fill: currentColor;
  height: 16px;
  width: 16px;
}
.github-link:hover {
  background: #245d63;
  border-color: #245d63;
  box-shadow: 0 4px 12px rgba(36, 93, 99, 0.2);
  text-decoration: none;
  transform: translateY(-1px);
}
.github-link:focus-visible {
  outline: 3px solid rgba(47, 111, 115, 0.26);
  outline-offset: 3px;
}
.topbar nav { align-items: center; display: flex; gap: 18px; }
.inline-form { display: inline; margin: 0; }
.link-button { background: transparent; border: 0; color: #245d63; cursor: pointer; font: inherit; padding: 0; }
.page { margin: 0 auto; max-width: 1120px; padding: 32px; }
.library-header { align-items: end; display: flex; justify-content: space-between; margin-bottom: 24px; }
h1 { font-size: 34px; line-height: 1.15; margin: 0 0 6px; }
h2 { font-size: 20px; line-height: 1.25; margin: 12px 0 6px; }
p { line-height: 1.55; }
.muted, .library-header p { color: #65716b; margin: 0; }
.filters-bar { align-items: flex-end; border-bottom: 1px solid #d2d9d1; display: flex; justify-content: space-between; margin-bottom: 24px; }
.filters-bar .tabs { border-bottom: none; flex: 1; margin-bottom: 0; }
.year-filter-form, .rating-filter-form, .language-filter-form { padding-bottom: 8px; }
.year-filter-form select, .rating-filter-form select, .language-filter-form select { font-size: 0.85rem; padding: 4px 8px; }
.language-filter-form select { width: auto; }
.tabs { border-bottom: 1px solid #d2d9d1; display: flex; gap: 8px; margin-bottom: 24px; overflow-x: auto; }
.tab { border-bottom: 3px solid transparent; color: #46524e; padding: 12px 14px; white-space: nowrap; }
.tab span { color: #68746e; margin-left: 4px; }
.tab.active { border-color: #2f6f73; color: #172026; font-weight: 700; }
.book-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pagination-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-top: 20px;
}
.page-size-form {
  align-items: center;
  display: flex;
  gap: 10px;
}
.page-size-form label,
.pagination-summary {
  color: #65716b;
  font-size: 14px;
}
.page-size-form select {
  width: auto;
}
.pagination-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pagination-link,
.pagination-ellipsis {
  border: 1px solid #cbd4cc;
  border-radius: 6px;
  color: #24302d;
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  min-width: 38px;
  justify-content: center;
  padding: 8px 11px;
}
.pagination-link.current {
  background: #2f6f73;
  border-color: #2f6f73;
  color: #ffffff;
}
.pagination-link.disabled,
.pagination-ellipsis {
  background: #f1f4ef;
  color: #7a8781;
}
.pagination-link:hover { text-decoration: none; }
.book-card, .form-panel, .auth-panel, .empty-state {
  background: #ffffff;
  border: 1px solid #dfe4dc;
  border-radius: 8px;
  padding: 20px;
}
.book-card { display: flex; flex-direction: column; gap: 16px; min-height: 260px; }
.book-main { flex: 1; }
.status-pill { border-radius: 999px; display: inline-flex; font-size: 12px; font-weight: 700; padding: 5px 10px; }
.status-will_read { background: #e8edf1; color: #33404a; }
.status-reading { background: #e3f2eb; color: #1f6449; }
.status-read { background: #f8e7c7; color: #7a4e00; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill {
  background: #eef3ee;
  border: 1px solid #d7e0d8;
  border-radius: 999px;
  color: #3b4742;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
}
.book-meta { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }
.book-meta div { min-width: 88px; }
dt { color: #65716b; font-size: 12px; }
dd { margin: 2px 0 0; }
.book-cover-thumb {
  border-radius: 6px;
  display: block;
  height: 72px;
  object-fit: cover;
  width: 48px;
}
.book-cover-placeholder {
  align-items: center;
  background: #eef3ee;
  border: 1px dashed #c7d1c7;
  border-radius: 6px;
  color: #6b766f;
  display: inline-flex;
  height: 72px;
  justify-content: center;
  width: 48px;
}
.status-actions, .card-actions, .button-row { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.status-actions button, .primary-button, .danger-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 13px;
}
.status-actions button { background: #edf1ed; color: #26312e; }
.status-actions button:disabled { cursor: default; opacity: 0.45; }
.primary-button { background: #2f6f73; color: #ffffff; display: inline-block; }
.danger-button { background: #a33b31; color: #ffffff; }
.form-panel, .auth-panel { max-width: 680px; }
.form-stack { display: grid; gap: 14px; }
.form-stack p { display: grid; gap: 6px; margin: 0; }
input, select, textarea {
  border: 1px solid #cbd4cc;
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}
.empty-state { grid-column: 1 / -1; text-align: center; }
@media (max-width: 700px) {
  .topbar, .library-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .topbar { padding: 16px 20px; }
  .topbar nav { flex-wrap: wrap; }
  .page { padding: 24px 16px; }
  .filters-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 0;
  }
  .filters-bar .tabs {
    overflow-x: auto;
    padding-bottom: 0;
  }
  .year-filter-form, .rating-filter-form {
    padding-bottom: 4px;
    padding-top: 4px;
  }
  .tab { font-size: 14px; padding: 10px 10px; }
}

.table-wrap {
  background: #ffffff;
  border: 1px solid #dfe4dc;
  border-radius: 8px;
  overflow-x: auto;
}
.book-table {
  border-collapse: collapse;
  min-width: 940px;
  width: 100%;
}
.book-table th,
.book-table td {
  border-bottom: 1px solid #e4e8e1;
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}
.book-table th {
  background: #f1f4ef;
  color: #46524e;
  font-size: 13px;
  font-weight: 700;
}
.book-table th a { color: inherit; text-decoration: none; }
.sort-link {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}
.sort-link.active { color: #172026; }
.book-table th a:hover { text-decoration: none; }
.book-table tr:last-child td { border-bottom: 0; }
.empty-cell { color: #65716b; text-align: center; }

/* === Responsive: table → card rows on mobile === */
@media (max-width: 768px) {
  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow-x: visible;
  }
  .book-table,
  .book-table thead,
  .book-table tbody,
  .book-table tr,
  .book-table th,
  .book-table td {
    display: block;
  }
  .book-table {
    min-width: 0;
    width: 100%;
  }
  .book-table thead {
    display: none;
  }
  .book-table tr {
    background: #ffffff;
    border: 1px solid #dfe4dc;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 16px;
  }
  .book-table tr:last-child {
    margin-bottom: 0;
  }
  .book-table td {
    border: 0;
    padding: 4px 0;
  }
  .book-table td::before {
    color: #65716b;
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
  /* Title is the card heading — no label above it */
  .book-table .cell-title {
    font-size: 17px;
    font-weight: 700;
    padding-bottom: 6px;
    padding-top: 0;
  }
  .book-table .cell-title::before { display: none; }
  .book-table .cell-cover {
    align-items: start;
    display: flex;
    padding-bottom: 10px;
  }
  .book-table .cell-cover::before { display: none; }
  /* Status pill sits inline after the title row */
  .book-table .cell-status {
    padding-bottom: 10px;
  }
  .book-table .cell-status::before { display: none; }
  /* Notes gets breathing room */
  .book-table .cell-notes {
    border-top: 1px solid #e4e8e1;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 6px;
    padding-bottom: 0;
    padding-top: 10px;
  }
}
