:root {
  --bg: #faf6ef;
  --ink: #2b241c;
  --muted: #7a6f5f;
  --card: #ffffff;
  --accent: #a8552c;
  --shadow: 0 4px 14px rgba(43, 36, 28, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Iowan Old Style", serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  padding: 2.5rem 2rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.02em;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.25rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 2rem 4rem;
}

.back-link {
  position: absolute;
  left: 2rem;
  top: 2.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.back-link:hover {
  color: var(--accent);
}

body.landing header {
  padding-top: 4rem;
}

.doorways {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 1rem 2rem 4rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.doorway {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 3rem 1.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.doorway:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.doorway-icon {
  font-size: 3rem;
}

.doorway-title {
  font-size: 1.3rem;
  font-weight: bold;
}

.doorway-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .doorways {
    grid-template-columns: 1fr;
  }
  .back-link {
    position: static;
    display: block;
    margin-bottom: 1rem;
  }
}

.toolbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.review-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px dotted var(--accent);
}

#publish-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

#publish-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

#publish-auth {
  max-width: 400px;
}

.toolbar select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #d8cdb8;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}

.shelf {
  margin-bottom: 2.5rem;
}

.shelf h2 {
  text-transform: capitalize;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 0.15rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.book-card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
}

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

.cover-wrap {
  aspect-ratio: 2 / 3;
  background: #e8e0d2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.shelf-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.pending-badge {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  right: 0.4rem;
  background: #b8860b;
  color: #fff;
  font-size: 0.62rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  box-shadow: var(--shadow);
  text-align: center;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem;
}

.book-title {
  font-size: 0.85rem;
  font-weight: bold;
  padding: 0.5rem 0.5rem 0;
  line-height: 1.2;
}

.book-author {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.15rem 0.5rem 0.6rem;
}

#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#modal-backdrop.hidden {
  display: none;
}

#modal {
  background: var(--card);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 10px;
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow);
}

#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-cover {
  float: left;
  width: 120px;
  margin: 0 1rem 0.5rem 0;
  border-radius: 4px;
}

.modal-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.3rem 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.empty-state code {
  background: #eee2cf;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1.5rem 1rem 2.5rem;
}

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

.auth-gate {
  max-width: 500px;
  margin: 0 auto 2rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-gate.hidden {
  display: none;
}

#auth-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

#auth-form input {
  font-family: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d8cdb8;
  border-radius: 6px;
}

#auth-form button {
  font-family: inherit;
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.auth-error {
  color: #b3261e;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

.auth-error.hidden {
  display: none;
}

.review-count {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  color: var(--muted);
}

.flag-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: #b3261e;
  color: #fff;
  font-size: 0.62rem;
  font-weight: bold;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.review-card {
  border: 2px solid #f0c9c4;
}

.flag-reasons {
  font-size: 0.7rem;
  color: #b3261e;
  padding: 0 0.5rem 0.6rem;
}

.modal-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.correction-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.correction-form label {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.correction-form input {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d8cdb8;
  border-radius: 6px;
}

.correction-form button {
  align-self: flex-start;
  font-family: inherit;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

#candidates {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.candidate {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid #eee2cf;
  border-radius: 8px;
  padding: 0.5rem;
}

.candidate-cover img,
.candidate-cover .cover-placeholder {
  width: 44px;
  height: 66px;
  object-fit: cover;
  border-radius: 3px;
}

.candidate-info {
  flex: 1;
  min-width: 0;
}

.candidate-title {
  font-weight: bold;
  font-size: 0.85rem;
}

.candidate-author,
.candidate-meta,
.candidate-isbn {
  font-size: 0.75rem;
  color: var(--muted);
}

.use-candidate-btn {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.save-status {
  font-size: 0.85rem;
  color: var(--accent);
}

.save-status.hidden {
  display: none;
}

.upload-area {
  max-width: 500px;
  margin: 0 auto 2rem;
  padding: 1.5rem;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.upload-area.hidden,
.upload-area form label.hidden {
  display: none;
}

#upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#upload-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

#upload-form input {
  font-family: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d8cdb8;
  border-radius: 6px;
}

#upload-btn {
  font-family: inherit;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}

#upload-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.queue-heading {
  max-width: 700px;
  margin: 0 auto 1rem;
  padding: 0 2rem;
}

.queue-entry {
  max-width: 700px;
  margin: 0 auto 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.queue-entry-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.queue-thumb {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.queue-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.discard-btn {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  margin-top: 0.4rem;
  border: 1px solid #b3261e;
  border-radius: 6px;
  background: #fff;
  color: #b3261e;
  cursor: pointer;
}

.queue-books {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.85rem;
}

.queue-books li {
  padding: 0.25rem 0;
  border-top: 1px solid #f0e9d8;
}

.queue-books li:first-child {
  border-top: none;
}

.queue-books li.low-confidence {
  color: #8a6d1f;
}

.unsure-tag {
  font-size: 0.65rem;
  background: #f7e6b0;
  color: #8a6d1f;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
