:root {
  color-scheme: light dark;

  --bg: #fbfbfa;
  --fg: #1c1c1e;
  --muted: #6b6b70;
  --border: #d9d9d6;
  --surface: #ffffff;
  --surface-alt: #f2f2f0;
  --accent: #2b5fd9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --fg: #e8e8ea;
    --muted: #9a9aa0;
    --border: #35363a;
    --surface: #1f2023;
    --surface-alt: #26272b;
    --accent: #8ba9f5;
  }
}

/* Alpine has not booted yet: keep x-show elements hidden to avoid a flicker. */
[x-cloak] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

a {
  color: var(--accent);
}

h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

p {
  margin: 0.4rem 0;
}

/* Header ------------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
}

.site-header .count {
  font-size: 0.925rem;
  color: var(--muted);
}

/* Filter bar ---------------------------------------------------------- */

.list-filter {
  position: relative;
  max-width: 20rem;
  margin-top: 1rem;
}

.list-filter input[type="search"] {
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  appearance: none;
}

.list-filter input[type="search"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.list-filter input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.list-filter .clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 0.25rem;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
}

.list-filter .clear:hover {
  opacity: 1;
}

.list-filter .clear:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
  opacity: 1;
}

/* Table --------------------------------------------------------------- */

.books {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.books th,
.books td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.books th {
  background: var(--surface-alt);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.books tbody tr:last-child td {
  border-bottom: 0;
}

.books tbody tr:hover {
  background: var(--surface-alt);
}

.books .untitled {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty,
.generated {
  margin-top: 1rem;
  color: var(--muted);
}

.generated {
  font-size: 0.85rem;
}

/* Narrow screens: let the table scroll sideways instead of the page. */
@media (max-width: 40rem) {
  .books {
    display: block;
    overflow-x: auto;
  }
}
