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

:root {
  --bg:       #f8f5f0;
  --surface:  #ffffff;
  --border:   #ddd8d0;
  --accent:   #5a7a5a;
  --accent-h: #3e5c3e;
  --text:     #2a2a2a;
  --muted:    #6b6b6b;
  --danger:   #b94a4a;
  --radius:   8px;
  --shadow:   0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: 1rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
header h1 { font-size: 1.4rem; font-weight: 700; }

.btn {
  display: inline-block;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-ghost   { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost:hover { background: #eef3ee; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f3737; }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }

/* ── catalogue list ── */
#book-list { display: grid; gap: .75rem; }

.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem .5rem;
  align-items: start;
}
.book-card .title   { font-weight: 600; grid-column: 1; }
.book-card .authors { color: var(--muted); font-size: .9rem; grid-column: 1; }
.book-card .meta    { color: var(--muted); font-size: .82rem; grid-column: 1; }
.book-card .actions { grid-column: 2; grid-row: 1 / span 4; display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; }
.book-card .tags { grid-column: 1; display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
.book-card .tag {
  background: #eef3ee;
  color: var(--accent-h);
  border-radius: 999px;
  padding: .12rem .6rem;
  font-size: .78rem;
  font-weight: 600;
}

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

/* ── scan page ── */
#camera-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
}
#camera-wrap video, #camera-wrap canvas {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
#canvas { display: none; }

#capture-bar {
  display: flex; gap: .5rem; justify-content: center; margin-bottom: 1.5rem;
}

#confirm-section { max-width: 480px; margin: 0 auto; }
#confirm-section h2 { margin-bottom: 1rem; font-size: 1.1rem; }

.field-group { display: grid; gap: .9rem; margin-bottom: 1.2rem; }
.field-group label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 500; }
.field-group input, .field-group textarea {
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  width: 100%;
  background: var(--surface);
}
.field-group input:focus, .field-group textarea:focus { outline: 2px solid var(--accent); }

.form-actions { display: flex; gap: .75rem; }

/* ── spinner ── */
.spinner { display: none; text-align: center; padding: 2rem; color: var(--muted); }
.spinner.active { display: block; }

/* ── photo preview (confirm screen) ── */
#captured-preview {
  width: 100%; max-width: 480px; margin: 0 auto 1rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  display: none;
}

@media (max-width: 420px) {
  header h1 { font-size: 1.15rem; }
  .book-card { grid-template-columns: 1fr; }
  .book-card .actions { flex-direction: row; grid-column: 1; }
  /* Right-align the bar so Capture (now the last button) sits at the far
     right, under the thumb for one-handed use. */
  #capture-bar { justify-content: flex-end; }
}
