* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Georgia, serif;
  background: #faf8f5;
  color: #2c2c2c;
  min-height: 100vh;
}

header {
  background: #2c2c2c;
  color: #faf8f5;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header a {
  color: #faf8f5;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 0.03em;
}

header nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

header nav a,
header nav button {
  color: #faf8f5;
  text-decoration: none;
  background: none;
  border: 1px solid #faf8f5;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.9rem;
}

header nav a:hover,
header nav button:hover {
  background: #faf8f5;
  color: #2c2c2c;
}

main {
  max-width: 860px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h1 {
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
}

/* Book grid on home page */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.5rem;
}

.book-card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.book-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s;
}

.book-card:hover img {
  transform: translateY(-4px);
}

.book-card span {
  font-size: 0.9rem;
  text-align: center;
}

/* Entry list */
.entry {
  background: #fff;
  border: 1px solid #e0dcd6;
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1rem;
}

.entry-meta {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.entry-pages {
  background: #2c2c2c;
  color: #faf8f5;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

.entry-text {
  line-height: 1.65;
  white-space: pre-wrap;
}

.delete-btn {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.delete-btn:hover {
  color: #c0392b;
}

.edit-btn {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.edit-btn:hover {
  color: #2c6fad;
}

.entry-edit {
  padding: 1rem 1.4rem 1.2rem;
}

.entry-edit label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.entry-edit input,
.entry-edit textarea {
  font-family: Georgia, serif;
  font-size: 0.95rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  width: 100%;
}

.entry-edit textarea {
  min-height: 120px;
  resize: vertical;
}

.entry-edit-actions {
  display: flex;
  gap: 0.6rem;
}

.cancel-btn {
  background: none;
  border: 1px solid #ccc;
  padding: 0.45rem 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  color: #555;
}

.cancel-btn:hover {
  border-color: #999;
  color: #2c2c2c;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
}

label {
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

input[type="text"],
input[type="password"],
textarea {
  font-family: Georgia, serif;
  font-size: 1rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  width: 100%;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

button[type="submit"],
.btn {
  background: #2c2c2c;
  color: #faf8f5;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 1rem;
  align-self: flex-start;
  text-decoration: none;
  display: inline-block;
}

button[type="submit"]:hover,
.btn:hover {
  background: #444;
}

.error {
  color: #c0392b;
  font-size: 0.9rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: #888;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: #2c2c2c;
}

.book-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.book-header img {
  width: 100px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.book-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.empty {
  color: #aaa;
  font-style: italic;
}

.entry-row {
  border: 1px solid #e0dcd6;
  border-radius: 6px;
  margin-bottom: 0.6rem;
  background: #fff;
  overflow: hidden;
}

.entry-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.2rem;
  cursor: pointer;
  list-style: none;
  gap: 1rem;
  user-select: none;
}

.entry-summary::-webkit-details-marker { display: none; }

.entry-row:hover > .entry-summary {
  background: #f5f3ef;
}

.entry-row[open] > .entry-summary {
  border-bottom: 1px solid #e0dcd6;
}

.entry-date {
  font-size: 0.9rem;
  color: #555;
}

.entry-summary-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.entry-row .entry-text {
  padding: 1.2rem 1.4rem;
  line-height: 1.7;
  white-space: pre-wrap;
  font-size: 0.95rem;
}
