:root {
  --cream: #f4ecd8;
  --paper: #fbf6ea;
  --orange: #e8731d;
  --orange-deep: #c95e10;
  --ink: #23201b;
  --muted: #6d6556;
  --rule: #d9cdb2;
  --sans: "Gill Sans", "Gill Sans MT", "Gill Sans Nova", Seravek, Calibri, "Trebuchet MS", "Segoe UI", sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--cream); }
body {
  margin: 0 auto; max-width: 560px; min-height: 100dvh; color: var(--ink); background: var(--cream);
  font: 17px/1.45 var(--serif);
  padding: 0 0 max(24px, env(safe-area-inset-bottom));
  background-image: radial-gradient(rgba(120, 90, 40, .05) 1px, transparent 1px);
  background-size: 4px 4px;
}
h2, h3, button, label, legend, .kicker, .year, .cartouche, .muted, .empty { font-family: var(--sans); }

/* Three-band cover header */
.cover { display: grid; grid-template-rows: auto auto auto; box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.band { background: var(--orange); min-height: 48px; display: flex; align-items: center; justify-content: center; }
.band.top { padding-top: env(safe-area-inset-top); min-height: calc(56px + env(safe-area-inset-top)); }
.cartouche {
  background: var(--paper); color: var(--orange-deep); font-weight: 600; letter-spacing: .28em; padding: 4px 16px 4px 20px;
  border-radius: 999px; font-size: 14px; border: 2px solid var(--paper); box-shadow: inset 0 0 0 1.5px var(--orange);
}
.cover .panel { background: var(--paper); text-align: center; padding: 18px 16px 20px; border-top: 3px solid var(--paper); }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: .32em; font-size: 13px; color: var(--muted); }
.year { margin: 6px 0 0; font-size: 18px; }
.year strong { display: block; font-size: 54px; line-height: 1; font-weight: 400; color: var(--ink); }
.band-btn { background: transparent; border: 1.5px solid var(--paper); color: var(--paper); min-height: 36px; font-size: 14px; letter-spacing: .08em; }

main { padding: 8px 16px 0; }
section { margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--orange); padding-bottom: 6px; }
h2 { font-size: 15px; letter-spacing: .22em; text-transform: uppercase; font-weight: 600; margin: 0; }
.small-h { font-size: 13px; }
.muted { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); font-style: italic; margin: 14px 0; }
.empty[hidden], [hidden] { display: none !important; }

button, .button {
  font: 600 15px var(--sans); color: var(--ink); background: var(--paper); border: 1.5px solid var(--ink);
  border-radius: 3px; min-height: 44px; padding: 0 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
button.primary { background: var(--orange); border-color: var(--orange-deep); color: #fff; }
button.danger { color: #9b2a12; border-color: #9b2a12; }
button:focus-visible, .button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }

/* Now reading: each book is a small three-band card */
.reading { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 14px; }
.book { background: var(--paper); border: 1px solid var(--rule); box-shadow: 0 1px 0 rgba(0,0,0,.06); }
.book .stripe { height: 10px; background: var(--orange); }
.book .body { padding: 12px 14px 14px; }
.book h3 { margin: 0; font-size: 20px; font-weight: 400; line-height: 1.2; }
.book .author { margin: 2px 0 0; font-family: var(--sans); color: var(--muted); font-size: 15px; }
.meter { height: 8px; background: #eadfc6; border-radius: 4px; margin: 12px 0 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--orange); }
.book .where { font-family: var(--sans); font-size: 14px; color: var(--muted); margin: 0 0 10px; }

/* Shelf of spines */
.shelf-wrap { overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.shelf {
  list-style: none; margin: 0; padding: 0 6px; display: flex; align-items: flex-end; gap: 3px; min-height: 196px;
  border-bottom: 10px solid #8a5a2b; box-shadow: 0 6px 0 -2px #6b4320;
}
.spine {
  width: 38px; flex: none; display: grid; grid-template-rows: 22px 1fr 22px; border: 0; padding: 0;
  background: var(--paper); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 1px 0 0 rgba(0,0,0,.08); border-radius: 2px 2px 0 0;
  min-height: 0; cursor: pointer; color: var(--ink); align-items: stretch; justify-items: stretch; justify-content: stretch; align-content: stretch;
}
.spine .cap { background: var(--orange); }
.spine .label {
  writing-mode: vertical-rl; transform: rotate(180deg); font: 600 13px var(--sans); letter-spacing: .04em;
  padding: 6px 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; justify-self: center;
}
.spine.alt { width: 34px; }
.spine.alt .cap { background: var(--orange-deep); }

/* Dialogs */
dialog { width: min(92vw, 440px); border: 0; border-top: 10px solid var(--orange); border-bottom: 10px solid var(--orange); background: var(--paper); color: var(--ink); padding: 18px; }
dialog::backdrop { background: rgba(35, 32, 27, .45); }
dialog h3 { margin: 0 0 8px; font-weight: 400; font-size: 22px; font-family: var(--serif); }
dialog label { display: grid; gap: 4px; margin-top: 10px; font-size: 14px; }
input, textarea { font: 17px var(--serif); color: var(--ink); background: #fffdf6; border: 1.5px solid var(--rule); border-radius: 3px; padding: 8px 10px; min-height: 44px; width: 100%; }
textarea { resize: vertical; }
input[type=range] { padding: 0; accent-color: var(--orange); border: 0; background: transparent; }
.book-line { margin: 0; font-style: italic; }
.stars { border: 0; padding: 0; margin: 12px 0 0; display: flex; gap: 2px; }
.stars legend { font-size: 14px; margin-bottom: 4px; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { margin: 0; font-size: 34px; line-height: 1; color: #d8c9a8; cursor: pointer; min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.stars label.on { color: var(--orange); }
.stars input:focus-visible + label { outline: 3px solid var(--ink); }
.mini-cover { display: grid; grid-template-rows: 18px auto 18px; border: 1px solid var(--rule); margin-bottom: 12px; }
.mini-cover .band { min-height: 18px; }
.mini-cover .panel { background: var(--paper); text-align: center; padding: 14px; }
.mini-cover h3 { font-family: var(--sans); font-weight: 600; margin: 0; }
.mini-cover p { margin: 4px 0 0; font-family: var(--sans); color: var(--muted); }
.rating { font-size: 26px; color: var(--orange); margin: 4px 0; letter-spacing: 2px; }
.note { white-space: pre-wrap; margin: 6px 0; }
