:root {
  --bg: #faf8f4;
  --surface: #f1ede5;
  --text: #22201c;
  --muted: #6d675d;
  --rule: #ddd6c9;
  --accent: #9a4a2b;
  --star: #b07a1c;
  --danger: #a3302a;
  --tone-0: #6b4f3a;
  --tone-1: #3f5a4c;
  --tone-2: #4a4f6e;
  --tone-3: #7a3e3e;
  --tone-4: #5c5a36;
  --tone-5: #35586a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #22201d;
    --text: #ebe6dc;
    --muted: #a39b8d;
    --rule: #38342e;
    --accent: #e0916c;
    --star: #e2b04f;
    --danger: #ec7a72;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }

.page { max-width: 60rem; margin: 0 auto; padding: 3rem 1rem 4rem; }

.cover {
  display: block;
  width: 100%;
  height: auto; /* let aspect-ratio win over the img height attribute */
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 4px 14px rgb(0 0 0 / 0.08);
}
.placeholder {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.9rem 0.75rem;
  color: #f6f1e7;
  overflow: hidden;
}
.ph-title { font-family: var(--serif); font-size: 1rem; line-height: 1.2; overflow-wrap: anywhere; }
.ph-author { font-size: 0.75rem; opacity: 0.85; }
.tone-0 { background: var(--tone-0); }
.tone-1 { background: var(--tone-1); }
.tone-2 { background: var(--tone-2); }
.tone-3 { background: var(--tone-3); }
.tone-4 { background: var(--tone-4); }
.tone-5 { background: var(--tone-5); }

/* Public page: dark only, Fraunces throughout. Scoped to html.public so the
   admin keeps its own look. */
html.public {
  --bg: #141311;
  --text: #ECE6DC;
  --muted: #A39C90;
  --faint: #8A8478;
  --rule: #2C2A26;
  --accent: #C9A66B;
  --serif: "Fraunces", Georgia, serif;
  color-scheme: dark;
  background: var(--bg);
}
.public body {
  font-family: var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.public h1, .public h2, .public h3 { font-weight: 400; line-height: 1.2; }
.public .page { max-width: calc(960px + 2 * 24px); padding: 96px 24px 120px; }

.public .masthead h1 { font-size: 60px; line-height: 1.02; letter-spacing: -0.02em; }
.public .lede { margin: 12px 0 0; color: var(--muted); font-size: 20px; font-style: italic; }

.public .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 32px 40px;
  margin-top: 72px;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.public .stat { display: flex; flex-direction: column; gap: 8px; }
.public .stat-value { font-size: 40px; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.public .stat-label { color: var(--muted); font-size: 15px; }

.public .section { margin-top: 72px; }
.public .label { margin-bottom: 24px; color: var(--muted); font-size: 15px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; }

.public .cover { box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.7); }
.public img.cover { background: var(--rule); }
.public .ph-author { font-family: var(--serif); }

.public .reading { list-style: none; margin: 0; padding: 0; display: grid; gap: 40px; }
.public .reading-item { display: flex; flex-wrap: wrap; gap: 20px 28px; align-items: center; }
.public .reading-item .cover { width: 120px; flex: none; }
.public .reading-meta { flex: 1 1 260px; min-width: 0; }
.public .reading-title { font-size: 28px; font-weight: 500; line-height: 1.15; }
.public .reading-meta .author { margin: 6px 0 0; color: var(--muted); font-size: 17px; }
.public .progress { display: flex; align-items: center; gap: 14px; margin-top: 20px; }
.public progress {
  appearance: none;
  flex: 1;
  min-width: 0;
  max-width: 420px;
  height: 2px;
  border: 0;
  background: var(--rule);
  color: var(--accent);
}
.public progress::-webkit-progress-bar { background: var(--rule); }
.public progress::-webkit-progress-value { background: var(--accent); }
.public progress::-moz-progress-bar { background: var(--accent); }
.public .progress-label { flex: none; color: var(--muted); font-size: 14px; font-variant-numeric: lining-nums tabular-nums; }

.public .year-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}
.public .year-head h2 { font-size: 32px; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.public .year-count { color: var(--muted); font-size: 15px; }

.public .shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 40px 28px; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
.public .book-meta { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.public .book .title { font-size: 16px; font-weight: 500; line-height: 1.25; }
.public .book .author { margin: 0; color: var(--muted); font-size: 14px; }
.public .stars { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.12em; }
.public .date { margin: 0; color: var(--faint); font-size: 13px; font-variant-numeric: lining-nums tabular-nums; }
.public .empty { color: var(--muted); font-style: italic; }

.public .footer { margin-top: 72px; color: var(--faint); font-size: 14px; font-style: italic; }

.public a:focus-visible { outline: 1px solid var(--muted); outline-offset: 4px; }

/* Two stats per row on phones instead of four stacked. */
@media (max-width: 30rem) {
  .public .stats { grid-template-columns: repeat(2, 1fr); gap: 24px 20px; }
}

/* Admin */
.admin { max-width: 72rem; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: baseline; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.admin-nav h1 { font-size: 1.5rem; margin-right: auto; }
.admin-nav h1 a { color: inherit; text-decoration: none; }
a { color: var(--accent); }
.flash { padding: 0.6rem 0.9rem; border-radius: 4px; background: var(--surface); margin-bottom: 1.5rem; }
.flash.error { color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr.is-hidden td { opacity: 0.5; }
.thumb { width: 3.25rem; }
.thumb .cover { width: 2.5rem; box-shadow: none; }
.thumb .placeholder { padding: 0; }
.thumb .placeholder span { display: none; }
.tag { display: inline-block; font-size: 0.72rem; padding: 0.05rem 0.4rem; border-radius: 3px; background: var(--surface); color: var(--muted); margin: 0 0.15rem 0.15rem 0; }
.tag.warn { color: var(--danger); }
form.stack { display: grid; gap: 1rem; max-width: 36rem; }
.field { display: grid; gap: 0.3rem; }
.field label { font-weight: 600; font-size: 0.875rem; display: flex; gap: 0.5rem; align-items: center; }
input, select, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], select {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--bg);
}
button, .button {
  padding: 0.45rem 0.9rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 0.75rem; text-decoration: underline; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.edit-layout { display: grid; grid-template-columns: 12rem 1fr; gap: 2rem; align-items: start; }
.panel { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.panel h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.muted { color: var(--muted); font-size: 0.85rem; }
code { font-size: 0.8rem; overflow-wrap: anywhere; }
@media (max-width: 40rem) {
  .edit-layout, .row { grid-template-columns: 1fr; }
  .edit-layout .cover { max-width: 10rem; }
}
