:root {
  --paper: #ece7d8;
  --paper-card: #fbf8f0;
  --ink: #26241f;
  --ink-soft: #5a564a;
  --rule: #d8d0ba;
  --oxblood: #6b2737;
  --oxblood-dark: #521d2a;
  --moss: #6f8259;
  --moss-dark: #57654a;
  --radius: 3px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; }

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

.site-header {
  padding: 2.5rem 1.5rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wordmark-mark {
  color: var(--oxblood);
  font-size: 1.6rem;
}

.tagline {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- Mobile tab bar (hidden on wide screens) ---------- */

.tab-bar {
  display: none;
  border-bottom: 1px solid var(--rule);
}

.tab-btn {
  flex: 1;
  padding: 0.85rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab-btn.is-active {
  color: var(--ink);
  border-bottom-color: var(--oxblood);
  font-weight: 600;
}

.tab-count {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  background: var(--rule);
  border-radius: 999px;
  font-size: 0.75rem;
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.count {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---------- Reading list (left panel) ---------- */

.panel-list {
  position: sticky;
  top: 2rem;
}

.reading-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.list-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--moss);
  border-radius: var(--radius);
}

.list-item img {
  width: 36px;
  height: 54px;
  object-fit: cover;
  background: var(--rule);
  border-radius: 2px;
  flex-shrink: 0;
}

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

.list-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-author {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-remove {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}

.list-item-remove:hover { color: var(--oxblood); }

.empty-note {
  display: none;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0;
}

.panel-list.is-empty .empty-note { display: block; }
.panel-list.is-empty .reading-list { display: none; }

/* ---------- Search (right panel) ---------- */

.search-form {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.search-form input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-card);
  color: var(--ink);
}

.search-form input:focus {
  outline: 2px solid var(--oxblood);
  outline-offset: 1px;
}

.search-form button {
  padding: 0.7rem 1.4rem;
  background: var(--oxblood);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.search-form button:hover { background: var(--oxblood-dark); }

.hint, .empty-state, .error-state {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.error-state { color: var(--oxblood); }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}

.book-card {
  display: flex;
  gap: 0.85rem;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.book-cover {
  width: 56px;
  height: 84px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--rule);
  border-radius: 2px;
}

.book-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.book-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.book-author {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin: 0;
}

.book-year {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0;
}

.save-btn {
  margin-top: auto;
  align-self: flex-start;
  position: relative;
  padding: 0.35rem 0.7rem 0.35rem 1.4rem;
  background: none;
  border: 1px solid var(--moss);
  color: var(--moss-dark);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.save-btn::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 8px;
  background: var(--moss);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
}

.save-btn:hover { background: var(--moss); color: #fff; }
.save-btn:hover::before { background: #fff; }

.save-btn.is-saved {
  background: var(--moss);
  color: #fff;
  cursor: default;
}
.save-btn.is-saved::before { background: #fff; }

.pager {
  text-align: center;
  margin-top: 1.75rem;
}

.pager button {
  padding: 0.6rem 1.4rem;
  background: none;
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.pager button:hover { border-color: var(--ink); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: transform 0.25s ease;
  pointer-events: none;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .tab-bar { display: flex; }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 1.25rem;
  }

  .panel-list, .panel-search { display: none; }
  .panel-list.is-active, .panel-search.is-active { display: block; }

  .panel-list { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
