/* Estil de targetes pastel: fons clar, colors suaus, cantonades molt arrodonides,
   números grans i barra de navegació flotant. Lletra gran per llegir-ho bé. */
:root {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --text: #1c1c24;
  --secondary: #63636f;
  --tertiary: #a5a5b0;
  --line: rgba(28, 28, 36, .09);
  --fill: rgba(28, 28, 36, .06);
  --btn-dark: #1c1c24;
  --on-dark: #ffffff;
  --glass: rgba(255, 255, 255, .72);
  --accent: #4f46e5;
  --danger: #d1372a;

  --p-pink: #f6d0d3;
  --p-peach: #fde1c6;
  --p-lavender: #dcdafc;
  --p-mint: #caede5;
  --p-coral: #f7aaa5;
  --p-blue: #cdd1f9;
  --p-yellow: #fbe8aa;

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 2px 10px rgba(28, 28, 36, .05);
  --shadow-float: 0 12px 32px rgba(28, 28, 36, .14);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216;
    --surface: #1f1f26;
    --text: #f3f3f6;
    --secondary: #a3a3ae;
    --tertiary: #6b6b76;
    --line: rgba(255, 255, 255, .1);
    --fill: rgba(255, 255, 255, .08);
    --btn-dark: #f3f3f6;
    --on-dark: #121216;
    --glass: rgba(255, 255, 255, .1);
    --accent: #a5a1ff;
    --danger: #ff7b6e;

    --p-pink: #4a2f35;
    --p-peach: #4a3a2a;
    --p-lavender: #35335c;
    --p-mint: #213f39;
    --p-coral: #5b302c;
    --p-blue: #2d3159;
    --p-yellow: #4a4124;

    --shadow: none;
    --shadow-float: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(118px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
main {
  max-width: 640px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 24px;
}
.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.ico { width: 22px; height: 22px; flex-shrink: 0; }
svg { flex-shrink: 0; }

/* ---------- Colors pastel ---------- */
.pastel-pink { background: var(--p-pink); }
.pastel-peach { background: var(--p-peach); }
.pastel-lavender { background: var(--p-lavender); }
.pastel-mint { background: var(--p-mint); }
.pastel-coral { background: var(--p-coral); }
.pastel-blue { background: var(--p-blue); }
.pastel-yellow { background: var(--p-yellow); }

/* ---------- Capçalera ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 2px 18px; }
.hello { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--p-yellow); display: grid; place-items: center;
}
.avatar svg { width: 26px; height: 26px; }
.hello-small { font-size: 15px; color: var(--secondary); font-weight: 500; }
.hello-big { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 0; }
.section-title { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 28px 4px 12px; }
.section-title.sm { font-size: 17px; margin: 0; }

.circle-btn {
  width: 50px; height: 50px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.circle-btn svg { width: 22px; height: 22px; }
.circle-btn.white { background: var(--glass); box-shadow: none; }
.circle-btn:active { transform: scale(.94); }

/* ---------- Targetes ---------- */
.card {
  border-radius: var(--radius-xl); padding: 20px; margin-bottom: 14px;
}
.card.plain { background: var(--surface); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { font-size: 15px; color: var(--secondary); margin-top: 2px; }
.card-text { font-size: 16px; color: var(--secondary); margin-bottom: 4px; }
.card > .card-title:first-child { margin-bottom: 6px; }

.chip-ico {
  width: 46px; height: 46px; border-radius: 15px; flex-shrink: 0;
  background: var(--glass); display: grid; place-items: center; color: var(--text);
}
.chip-ico svg { width: 22px; height: 22px; }
.chip-ico.sm { width: 38px; height: 38px; border-radius: 12px; }
.chip-ico.sm svg { width: 20px; height: 20px; }
.chip-ico.big { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 12px; }
.chip-ico.big svg { width: 32px; height: 32px; }

.step-n {
  width: 46px; height: 46px; border-radius: 15px; flex-shrink: 0;
  background: var(--btn-dark); color: var(--on-dark); font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
}

/* Resum amb números grans */
.summary .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-label { display: block; font-size: 14px; color: var(--secondary); font-weight: 500; }
.stat-num { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }

/* ---------- Graella de targetes petites ---------- */
.tile-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  list-style: none; padding: 0; margin: 0 0 14px;
}
.tile {
  display: flex; flex-direction: column; text-align: left;
  border: 0; border-radius: 26px; padding: 16px; min-height: 156px;
  font: inherit; color: var(--text); cursor: pointer; position: relative;
  transition: transform .12s ease, box-shadow .15s ease;
}
.tile:active { transform: scale(.98); }
/* Icona a dalt i títol a sota, perquè el nom tingui tota l'amplada */
.tile-head { display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 12px; }
.tile-title { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: break-word; max-width: 100%; }
.tile-text { font-size: 15px; color: var(--secondary); margin-top: 4px; flex: 1; }
.tile-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; font-weight: 700; margin-top: 12px;
}
.tile-foot svg { width: 20px; height: 20px; }
.tile-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.mini-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 9px 12px; cursor: pointer;
  background: var(--glass); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 700; text-align: left;
}
.mini-btn svg { width: 18px; height: 18px; }
.mini-btn.danger { color: var(--danger); }
.mini-btn:active { transform: scale(.97); }
.tile.add-tile { background: transparent; border: 2px dashed var(--line); color: var(--secondary); align-items: center; justify-content: center; gap: 8px; }

/* Selector d'opció a «Afegeix» */
.segmented .tile { min-height: 148px; }
.segmented .tile.active { box-shadow: 0 0 0 3px var(--text); }
.segmented .tile:not(.active) { opacity: .72; }

/* ---------- Llista de llibres ---------- */
.search-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px;
  color: var(--secondary); box-shadow: var(--shadow);
}
.chips-scroll { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.pill-select {
  max-width: 100%; cursor: pointer; text-overflow: ellipsis;
  background-color: var(--surface); color: var(--text); font-weight: 600; font-size: 16px;
  border-radius: 99px; padding: 10px 40px 10px 18px; box-shadow: var(--shadow);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%2363636f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}
/* Filtre amb creueta per treure'l */
.filter-pill {
  display: inline-flex; align-items: center; max-width: 100%;
  border-radius: 99px; background: var(--surface); box-shadow: var(--shadow);
}
.filter-pill .pill-select { box-shadow: none; background-color: transparent; min-width: 0; }
.filter-pill.active { background: var(--btn-dark); }
.filter-pill.active .pill-select {
  color: var(--on-dark); padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23a5a5b0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
}
.pill-clear {
  flex-shrink: 0; width: 34px; height: 34px; margin: 0 5px 0 0; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--on-dark); color: var(--btn-dark);
  display: grid; place-items: center;
}
.pill-clear svg { width: 18px; height: 18px; }
.pill-clear:active { transform: scale(.92); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.count-row { margin: 10px 4px 6px; min-height: 32px; }
.footnote { font-size: 15px; color: var(--secondary); margin: 10px 4px 0; }
.count-row .footnote { margin: 0; }

.card-list { list-style: none; margin: 0; padding: 0; }
.book-item, .shelf-item {
  display: flex; gap: 14px; align-items: center;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 12px 14px 12px 12px; margin-bottom: 10px;
}
.book-item { cursor: pointer; }
.book-item:active { transform: scale(.99); }
.book-item .info, .shelf-item .info { flex: 1; min-width: 0; }
.book-item .title {
  font-weight: 700; font-size: 18px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-item .author { color: var(--secondary); font-size: 16px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-item .place { color: var(--secondary); font-size: 14px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.book-item .place svg { width: 15px; height: 15px; }
.chev {
  width: 36px; height: 36px; padding: 9px; border-radius: 50%;
  background: var(--fill); color: var(--text);
}

.cover {
  width: 54px; height: 80px; object-fit: cover; border-radius: 10px; flex-shrink: 0;
  background: var(--fill);
}
.cover.xl { width: 128px; height: 190px; border-radius: 16px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
/* «Portada» provisional quan el llibre encara no té foto: color + inicial */
.cover.placeholder {
  display: grid; place-items: center; position: relative; overflow: hidden;
  color: var(--text); box-shadow: inset 4px 0 0 rgba(0, 0, 0, .06);
}
.cover.placeholder span { font-size: 24px; font-weight: 800; opacity: .55; }
.cover.placeholder svg { width: 45%; height: 45%; opacity: .45; }
.book-hero { display: flex; justify-content: center; padding: 8px 0 14px; }
/* Portada: tocar-la també obre la càmera */
.cover-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 16px; }
.cover-btn:active { transform: scale(.98); }
.cover-cam {
  position: absolute; right: -10px; bottom: -10px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--btn-dark); color: var(--on-dark); display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); border: 3px solid var(--bg);
}
.cover-cam svg { width: 20px; height: 20px; }
.cover-actions { display: flex; gap: 8px; margin-bottom: 4px; }
.cover-actions .btn { background: var(--surface); box-shadow: var(--shadow); font-size: 16px; padding: 12px 14px; }
.cover-actions .btn.grow { flex: 1; }
.cover-actions + .btn.block { margin-top: 2px; }

/* Capçaleres de lletra a la llista */
.letter-header {
  font-size: 20px; font-weight: 800; color: var(--text);
  margin: 18px 6px 8px; list-style: none;
}
.letter-header:first-child { margin-top: 4px; }

/* ---------- Índex A–Z ---------- */
.az-index {
  position: fixed; z-index: 9; right: 4px; top: 50%;
  transform: translateY(-50%);
  height: min(486px, calc(100dvh - 230px));
  width: 30px; padding: 6px 0;
  display: none; flex-direction: column; align-items: stretch;
  border-radius: 16px; touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.az-index.show { display: flex; }
.az-index.dragging { background: var(--surface); box-shadow: var(--shadow-float); cursor: grabbing; }
.az-index span {
  flex: 1 1 0; min-height: 0; display: grid; place-items: center;
  font-size: clamp(9px, 1.9dvh, 13px); font-weight: 800; color: var(--accent);
  transition: transform .08s ease;
}
.az-index span.off { color: var(--tertiary); opacity: .55; }
.az-index span.on { transform: scale(1.5); color: var(--text); }
body.has-az #books-section { padding-right: 26px; }

.az-bubble {
  position: fixed; z-index: 11; right: 54px; top: 50%;
  width: 72px; height: 72px; margin-top: -36px; border-radius: 24px;
  background: var(--btn-dark); color: var(--on-dark);
  font-size: 38px; font-weight: 800;
  display: grid; place-items: center; pointer-events: none;
  opacity: 0; transform: scale(.8); transition: opacity .12s ease, transform .12s ease;
  box-shadow: var(--shadow-float);
}
.az-bubble.show { opacity: 1; transform: scale(1); }

/* ---------- Botons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 18px; padding: 12px 20px; min-height: 52px;
  background: var(--glass); color: var(--text);
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn.dark { background: var(--btn-dark); color: var(--on-dark); }
.btn.white { background: var(--glass); color: var(--text); }
.btn.plain { background: none; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 58px; font-size: 18px; border-radius: 20px; }
.btn.block { display: flex; width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.file-btn { cursor: pointer; }
.link-btn {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--accent);
}
.link-btn.bold { font-weight: 800; }

/* ---------- Formularis ---------- */
input, select {
  font: inherit; font-size: 17px; color: var(--text);
  background: transparent; border: 0; outline: none; width: 100%;
  padding: 0; margin: 0; min-width: 0;
}
input::placeholder { color: var(--tertiary); }

.field {
  display: block; width: 100%; margin-top: 4px; cursor: pointer;
  background-color: var(--glass); border-radius: var(--radius-md); padding: 15px 44px 15px 16px;
  font-weight: 600; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%2363636f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 20px;
}

.inline-form { display: flex; align-items: stretch; gap: 8px; margin-top: 12px; }
.inline-form input {
  flex: 1; min-height: 52px; padding: 0 16px;
  background: var(--glass); border-radius: var(--radius-md);
}
.card.plain .inline-form input { background: var(--fill); }
/* Interruptor «L'he llegit» (estil iPhone) */
.toggle-card { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 16px 18px; }
.toggle-card .card-title, .toggle-card .card-sub { display: block; }
.read-ico { background: var(--fill); color: var(--tertiary); transition: background .2s ease, color .2s ease; }
.toggle-card:has(.switch:checked) .read-ico { background: var(--p-mint); color: var(--text); }
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; cursor: pointer; margin: 0;
  width: 60px; height: 36px; border-radius: 99px; position: relative;
  background: var(--fill); box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background .2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 30px; height: 30px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
.switch:checked { background: #34c759; box-shadow: none; }
.switch:checked::after { transform: translateX(24px); }
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.read-badge {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px;
  font-size: 13px; font-weight: 800; color: #1d6b3a;
  background: #d3f3dd; border-radius: 99px; padding: 3px 10px 3px 8px;
}
.read-badge svg { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { .read-badge { color: #a7f0bf; background: #1f4630; } }

.notes-input {
  display: block; width: 100%; min-height: 110px; resize: vertical;
  font: inherit; font-size: 17px; line-height: 1.45; color: var(--text);
  background: var(--glass); border: 0; outline: none;
  border-radius: var(--radius-md); padding: 14px 16px;
}
.notes-input::placeholder { color: var(--tertiary); }
.notes-input:focus { box-shadow: 0 0 0 2px var(--text); }
.book-item .note-line {
  display: flex; gap: 5px; align-items: flex-start; margin-top: 6px;
  font-size: 14px; color: var(--secondary); font-style: italic;
}
.book-item .note-line svg { width: 15px; height: 15px; margin-top: 2px; font-style: normal; }
.book-item .note-line span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.stack-form input { min-height: 52px; padding: 0 16px; background: var(--glass); border-radius: var(--radius-md); }
#title-results { margin: -4px 0 14px; }
.result-item .meta { font-size: 14px; color: var(--secondary); margin-top: 4px; }

.form-group .form-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 54px; margin: 0; border-top: 1px solid var(--line);
}
.form-group .card-title + .form-row { border-top: 0; margin-top: 4px; }
.form-row > span { width: 86px; flex-shrink: 0; color: var(--secondary); font-size: 16px; font-weight: 500; }
.form-row > input { font-weight: 600; }
.inline-select {
  flex: 1; min-width: 0; cursor: pointer; font-weight: 600;
  appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m8 9 4-4 4 4M8 15l4 4 4-4' fill='none' stroke='%2363636f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center; background-size: 18px;
}
select option { color: #1c1c24; background: #fff; }

/* ---------- Escàner ---------- */
#reader { width: 100%; border-radius: var(--radius-lg); overflow: hidden; background: #000; margin: 4px 0 6px; }
#reader:empty { display: none; }
#reader video { width: 100% !important; display: block; }
#reader img[alt="Info icon"], #reader img[alt="Camera based scan"] { display: none; }

/* ---------- Avisos ---------- */
.notice {
  margin: 0 0 14px; padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow); font-size: 17px; font-weight: 500;
}
.card .notice { margin: 10px 0; box-shadow: none; }
.notice.warn { background: var(--p-yellow); }
.notice.ok { background: var(--p-mint); }
.notice.err { background: var(--p-coral); }
.notice a { color: inherit; font-weight: 700; }
.notice .spinner { margin-right: 10px; }
.notice .btn { margin-top: 12px; }

.spinner {
  display: inline-block; width: 18px; height: 18px; vertical-align: -3px;
  border: 2.5px solid var(--line); border-top-color: var(--text); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Prestatgeria ---------- */
.shelf-preview { width: 100%; max-height: 240px; object-fit: cover; border-radius: var(--radius-xl); margin-bottom: 14px; }
.review-head { margin: 6px 4px 12px; }
.shelf-item input.s-title { font-weight: 700; }
.shelf-item input.s-authors { color: var(--secondary); font-size: 16px; margin-top: 2px; }
.shelf-item .meta { font-size: 14px; color: var(--secondary); margin-top: 6px; }
.shelf-item .meta.warn { color: #b26a00; font-weight: 600; }
@media (prefers-color-scheme: dark) { .shelf-item .meta.warn { color: #ffc46b; } }
.shelf-item.off { opacity: .5; }
.check {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; cursor: pointer;
  width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--tertiary); margin: 0;
  display: grid; place-items: center; background: none;
}
.check:checked { background: var(--btn-dark); border-color: var(--btn-dark); }
.check:checked::after {
  content: ""; width: 7px; height: 13px; margin-top: -3px;
  border: solid var(--on-dark); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.sticky-actions {
  position: sticky; bottom: calc(100px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 26%); padding-top: 20px; margin-top: 6px;
}

/* ---------- Estat buit ---------- */
.empty { text-align: center; padding: 28px 20px; }
.empty .card-text { margin: 6px 0 8px; }

/* ---------- Barra de navegació flotant ---------- */
.tabbar {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(420px, calc(100% - 32px));
  display: flex; justify-content: space-around; gap: 4px;
  background: var(--surface); border-radius: 30px; padding: 8px;
  box-shadow: var(--shadow-float);
}
.tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--secondary);
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 0 2px;
}
.tab-ico { width: 56px; height: 42px; border-radius: 16px; display: grid; place-items: center; transition: background .15s ease; }
.tab-ico svg { width: 25px; height: 25px; }
.tabbar button.active { color: var(--text); }
.tabbar button.active .tab-ico { background: var(--p-lavender); }

/* ---------- Fitxa del llibre ---------- */
dialog.sheet {
  border: 0; padding: 0 16px 28px; margin: auto auto 0;
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); color: var(--text);
  border-radius: 30px 30px 0 0;
}
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 30px; } }
dialog.sheet[open] { animation: up .25s ease; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 2px 10px; background: var(--bg);
}
.sheet-bar strong { font-size: 17px; font-weight: 800; }

/* ---------- Avís (llibre repetit) ---------- */
dialog.alert {
  border: 0; padding: 24px 18px 18px; width: min(420px, calc(100% - 32px));
  max-height: 86vh; overflow-y: auto;
  border-radius: 30px; background: var(--bg); color: var(--text); text-align: center;
  box-shadow: var(--shadow-float);
}
dialog.alert[open] { animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.alert-ico {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 12px;
  background: var(--p-yellow); display: grid; place-items: center;
}
.alert-ico svg { width: 32px; height: 32px; }
.alert-title { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.alert-text { font-size: 17px; color: var(--secondary); margin: 6px 4px 16px; }
.dupe-list { text-align: left; margin-bottom: 6px; }
.dupe-list .book-item { cursor: default; box-shadow: none; }
.dupe-list .where {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: 15px; font-weight: 700; background: var(--p-mint); border-radius: 99px; padding: 4px 10px;
}
.dupe-list .where svg { width: 15px; height: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(108px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none;
  background: var(--btn-dark); color: var(--on-dark);
  padding: 13px 22px; border-radius: 99px; font-size: 16px; font-weight: 700;
  transition: .25s ease; z-index: 30; max-width: calc(100% - 32px); text-align: center;
  box-shadow: var(--shadow-float);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 360px) {
  .stat-num { font-size: 25px; }
  .tile-grid { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
