:root {
  --primary: #5c4033;
  --secondary: #f5f0e1;
  --accent: #c9a96e;
  --crimson: #b03a2e;
  --gold: #d4a94a;
  --olive: #6b7d3a;
  --ink: #3a2d24;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
}

body {
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.08), transparent 40%),
    repeating-linear-gradient(105deg,
      #4a3328 0px, #53392c 8px, #4a3328 16px, #573c2f 24px);
  background-size: auto, 200px 200px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Cabinet drawer */
.cabinet {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.drawer {
  flex: 1;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0) 8%),
    linear-gradient(160deg, #6b4f3a, #5a4130 60%, #4a3328);
  border-radius: 18px;
  margin: 10px;
  padding: 14px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.35), 0 8px 20px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

/* Brass guide rod shadow running across the drawer face */
.drawer::after {
  content: '';
  position: absolute;
  left: -20px; right: -20px; top: 118px;
  height: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.05));
  filter: blur(3px);
  border-radius: 50%;
  pointer-events: none;
}

.topbar { padding: 6px 4px 26px; text-align: center; }
.brand {
  margin: 0;
  font-size: 30px;
  letter-spacing: 2px;
  color: var(--secondary);
  text-shadow: 0 2px 3px rgba(0,0,0,0.5);
  font-weight: normal;
}
.tagline { font-size: 12px; color: #d8c9ad; letter-spacing: 1px; }

#views { position: relative; z-index: 1; padding-bottom: 30px; }
.view { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; } }

/* Counters: glass vials embedded in drawer face */
.counters {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin: 6px 0 20px;
}
.counter {
  flex: 1;
  background: linear-gradient(160deg, rgba(255,255,255,0.16), rgba(255,255,255,0.03));
  border: 2px solid rgba(201,169,110,0.7);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  box-shadow: inset 0 0 10px rgba(255,255,255,0.15), 0 3px 6px rgba(0,0,0,0.3);
  position: relative;
}
.counter::before {
  content: '';
  position: absolute; top: 5px; left: 6px; right: 6px; height: 4px;
  background: linear-gradient(90deg, #b89353, #e6c88a, #b89353);
  border-radius: 2px;
}
.counter-label { display: block; font-size: 11px; color: #e3d5b8; letter-spacing: 1px; }
.counter-value {
  display: block;
  font-size: 30px;
  color: var(--secondary);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.section-title {
  color: var(--secondary);
  font-size: 16px;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(201,169,110,0.5);
  padding-bottom: 6px;
  margin: 16px 0 10px;
}
.club-hint { color: #d8c9ad; font-size: 13px; margin: -6px 0 10px; }

/* Library cards */
.grouped .group { margin-bottom: 6px; }
.group-title {
  color: #e6c88a;
  font-size: 12px;
  letter-spacing: 2px;
  margin: 14px 0 8px;
  text-transform: uppercase;
}
.book-card {
  position: relative;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 6px;
}
.delete-btn {
  position: absolute; top: 0; bottom: 0; right: 0; width: 76px;
  background: var(--crimson); color: #fff;
  border: none; font-family: inherit; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.card-body {
  background: var(--secondary);
  border-left: 8px solid var(--accent);
  border-radius: 6px;
  padding: 12px 12px 8px;
  position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
  transition: transform 0.2s ease;
  touch-action: pan-y;
  transform: translateX(0);
}
.book-card.swiped .card-body { transform: translateX(-76px); }

/* Colored tab on left edge */
.card-body.status-reading { border-left-color: var(--crimson); }
.card-body.status-to-read { border-left-color: var(--gold); }
.card-body.status-finished { border-left-color: var(--olive); }

.card-title {
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: bold;
  margin: 0;
  color: #2f241c;
  letter-spacing: 0.3px;
}
.card-author {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: #6d5b49;
  margin: 3px 0 8px;
}
.card-foot {
  border-top: 1px dashed #b9a892;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.clip-date {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #6d5b49;
  border: 1px solid #b99353; border-radius: 3px;
  padding: 2px 6px;
}
.clip-date::before { content: '\2606'; color: #b99353; }
.ribbon {
  position: absolute; top: -1px; right: -1px;
  background: var(--crimson); color: #fff;
  font-size: 9px; letter-spacing: 1px; padding: 5px 8px 6px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
}
.ribbon::after { content: 'PICK'; }

.recent-list .book-card { margin-bottom: 10px; }
.book-card:hover { cursor: pointer; }

/* Search */
.search-wrap { margin: 8px 0 12px; }
.search {
  width: 100%;
  padding: 12px;
  font-family: inherit; font-size: 15px;
  background: var(--secondary);
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--ink);
}
.search:focus { outline: none; border-color: #e6c88a; box-shadow: 0 0 0 3px rgba(201,169,110,0.3); }

.empty-note { color: #cbbca0; font-style: italic; text-align: center; padding: 20px 10px; }

/* About / settings */
.about {
  background: var(--secondary);
  border-radius: 8px; padding: 14px;
  font-size: 14px; line-height: 1.5;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  margin-bottom: 16px;
}
.danger {
  width: 100%; padding: 14px;
  background: var(--crimson); color: #fff;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 15px; letter-spacing: 1px;
}

/* FAB */
.fab {
  position: fixed;
  right: 22px; bottom: 100px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e6c88a, #b89353);
  color: #4a3328;
  font-size: 34px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 14px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.5);
  border: none; z-index: 5;
}
.fab::before {
  content: '';
  position: absolute; top: 8px; left: 12px; right: 12px; height: 3px;
  background: rgba(255,255,255,0.4); border-radius: 2px;
}

/* Bottom tabs: four drawer pulls */
.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  margin: 0 auto;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  background: linear-gradient(180deg, #4a3328, #3a2820);
  border-top: 1px solid #2e2119;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.5);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab-spacer { height: 78px; }
.tab {
  background: transparent; border: none;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; flex: 1; padding: 0;
  font-family: inherit; cursor: pointer;
}
.knob {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7a5a3f, #4f3a2c);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.5);
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tab .plate {
  font-size: 10px; color: #a08f77; letter-spacing: 0.5px;
}
.tab.is-active .knob {
  transform: translateY(-4px);
  background: linear-gradient(145deg, #e6c88a, #b89353);
  box-shadow: 0 6px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.6);
}
.tab.is-active .plate { color: var(--accent); font-weight: bold; }

/* Overlays */
.overlay {
  position: fixed; inset: 0;
  background: rgba(30,20,12,0.72);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 20;
  padding: env(safe-area-inset-bottom);
}
.sheet {
  width: 100%; max-width: 480px;
  background: var(--secondary);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
  max-height: 92dvh;
  overflow-y: auto;
}
.stamp-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.stamp {
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 3px 10px; border-radius: 3px;
  letter-spacing: 2px; font-size: 12px;
  text-transform: uppercase;
}
.close { background: none; border: none; font-size: 26px; color: var(--primary); cursor: pointer; }
.card-sheet form label {
  display: block;
  font-size: 12px; letter-spacing: 1px;
  color: var(--primary); margin-bottom: 12px;
  font-weight: bold;
}
.card-sheet form input[type=text],
.card-sheet form input[type=date],
.card-sheet form select {
  width: 100%; margin-top: 5px;
  padding: 12px; font-family: inherit; font-size: 16px;
  border: 1px solid #c9b28a; border-radius: 6px;
  background: #fffdf6; color: var(--ink);
}
.card-sheet form input:focus, select:focus { outline: none; border-color: var(--accent); }
.card-sheet form input[readonly] { background: #f0e9d8; cursor: pointer; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.primary {
  width: 100%; padding: 14px;
  background: var(--primary); color: var(--secondary);
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 16px; letter-spacing: 1px;
  margin-top: 4px;
}

/* Note editor: ruled index card */
.note-sheet { min-height: 70dvh; display: flex; flex-direction: column; }
.note-sheet textarea {
  flex: 1; width: 100%; min-height: 300px;
  background:
    repeating-linear-gradient(180deg, transparent 0, transparent 27px, #d8c9ad 28px),
    #fffdf6;
  border: none; line-height: 28px;
  font-family: 'Courier New', monospace;
  font-size: 15px; color: var(--ink);
  padding: 4px 8px; resize: none;
}
.note-actions { display: flex; gap: 10px; margin-top: 12px; }
.ghost {
  flex: 1; padding: 14px;
  background: #e4dac4; color: var(--primary);
  border: none; border-radius: 8px; font-family: inherit; font-size: 16px;
}
.note-actions .primary { flex: 1; margin-top: 0; }

@media (min-width: 520px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 16px; }
}