/* ══════════════════════════════════════════════════
   Variables
══════════════════════════════════════════════════ */
:root {
  --bg:         #f7f3ed;
  --bg2:        #f0ebe1;
  --bg3:        #e8e1d4;
  --surface:    #ffffff;
  --border:     #ddd7cc;
  --border2:    #ccc5b8;
  --ink:        #1e1a14;
  --ink2:       #3d3629;
  --muted:      #8c8070;
  --accent:     #7a2e0e;
  --accent-h:   #9e3c12;
  --gold:       #a8791e;
  --leido:      #1e5c3a;
  --leido-bg:   #e8f5ee;
  --r:          8px;
  --r-lg:       14px;
  --shadow-sm:  0 1px 6px rgba(30,26,20,.08);
  --shadow:     0 3px 16px rgba(30,26,20,.12);
  --shadow-lg:  0 8px 40px rgba(30,26,20,.2);
  --header-h:   56px;
  --sidebar-w:  214px;
  --bottom-h:   62px;
}

/* ══════════════════════════════════════════════════
   Reset
══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Jost', sans-serif;
  font-weight: 300;
  line-height: 1.5;
  min-height: 100dvh;
}
input, select, button, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════
   Config banner
══════════════════════════════════════════════════ */
.config-banner {
  background: var(--accent); color: #fff;
  text-align: center; padding: 10px 20px; font-size: .85rem;
}

/* ══════════════════════════════════════════════════
   Header
══════════════════════════════════════════════════ */
.header {
  height: var(--header-h);
  background: var(--ink);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(30,26,20,.3);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 0 16px; height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem; font-weight: 300; color: var(--bg);
  display: flex; align-items: center; gap: 7px;
  letter-spacing: .04em; white-space: nowrap;
}
.logo em { color: #c8a55a; font-style: italic; }
.logo svg { color: #c8a55a; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 8px; }
.stats-header {
  font-size: .75rem; color: rgba(255,255,255,.45);
  display: flex; gap: 12px; margin-right: 4px;
}
.stats-header strong { color: rgba(255,255,255,.8); }

/* ══════════════════════════════════════════════════
   Buttons
══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r);
  cursor: pointer; font-size: .85rem; font-weight: 400;
  border: none; transition: all .18s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--accent-h); }
.btn-scan {
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.18);
}
.btn-scan:hover { background: rgba(255,255,255,.2); }
.btn-outline {
  background: transparent; color: var(--ink2); border: 1px solid var(--border2);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: #b33; border: 1px solid #d9999944; }
.btn-danger:hover { background: #fff5f5; border-color: #d99; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* ══════════════════════════════════════════════════
   Layout
══════════════════════════════════════════════════ */
.layout {
  max-width: 1400px; margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--header-h));
}

/* ══════════════════════════════════════════════════
   Sidebar — desktop
══════════════════════════════════════════════════ */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 13px;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; background: var(--surface);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-overlay { display: none; }

.sidebar-section { margin-bottom: 18px; }
.sidebar-label {
  font-size: .65rem; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.filter-btn {
  display: block; width: 100%; text-align: left;
  padding: 6px 10px; background: transparent; border: none;
  cursor: pointer; border-radius: 6px; font-size: .83rem;
  color: var(--ink2); transition: all .15s; margin-bottom: 1px;
  touch-action: manipulation;
}
.filter-btn:hover { background: var(--bg2); }
.filter-btn.active { background: var(--accent); color: #fff; }
.filter-dynamic .filter-btn {
  font-size: .79rem; padding: 5px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-select {
  width: 100%; padding: 7px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--ink); font-size: .83rem; outline: none;
}
.sidebar-select:focus { border-color: var(--accent); }
.btn-clear-filters {
  display: block; width: 100%; padding: 7px;
  border-radius: 6px; background: transparent;
  border: 1px dashed var(--border2); color: var(--muted);
  font-size: .79rem; cursor: pointer; transition: all .15s; margin-top: 4px;
}
.btn-clear-filters:hover { color: var(--accent); border-color: var(--accent); }

/* ══════════════════════════════════════════════════
   Main
══════════════════════════════════════════════════ */
.main { padding: 16px 20px 60px; min-width: 0; }

/* ══════════════════════════════════════════════════
   Search
══════════════════════════════════════════════════ */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 0 14px;
  margin-bottom: 12px; transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { color: var(--muted); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; background: transparent;
  padding: 11px 0; font-size: .9rem; color: var(--ink); outline: none;
}
.search-bar input::placeholder { color: var(--muted); }
.search-count { font-size: .73rem; color: var(--muted); white-space: nowrap; }

/* ══════════════════════════════════════════════════
   Toolbar row
══════════════════════════════════════════════════ */
.toolbar-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--ink); color: var(--bg);
  font-size: .73rem; cursor: pointer; border: none;
  transition: background .15s;
}
.filter-chip:hover { background: var(--accent); }
.view-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.view-btn {
  width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.view-btn.active, .view-btn:hover {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

/* ══════════════════════════════════════════════════
   Books grid
══════════════════════════════════════════════════ */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 14px;
}
.books-list { display: flex; flex-direction: column; gap: 8px; }

/* Card */
.book-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; cursor: pointer;
  transition: transform .2s, box-shadow .2s; position: relative;
  animation: cardIn .3s ease both;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-card:active { transform: scale(.97); }
@keyframes cardIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; } }

.card-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg2); }
.card-no-cover {
  width: 100%; aspect-ratio: 2/3;
  background: linear-gradient(160deg, var(--bg2), var(--bg3));
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 7px; padding: 10px; text-align: center;
}
.card-no-cover .nc-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: .8rem; line-height: 1.3; color: var(--ink2);
}
.card-leido-dot {
  position: absolute; top: 7px; right: 7px;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: .58rem;
}
.dot-leido   { background: var(--leido); color: #fff; }
.dot-noleido { background: rgba(255,255,255,.88); border: 1px solid var(--border); color: var(--muted); }

.card-body { padding: 9px 9px 11px; }
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: .9rem; font-weight: 500; line-height: 1.3; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-autor { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.card-tag {
  font-size: .62rem; padding: 2px 6px; border-radius: 10px;
  background: var(--bg2); color: var(--muted); border: 1px solid var(--border);
}

/* List row */
.book-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); display: flex; align-items: center;
  gap: 12px; padding: 10px 12px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s; animation: cardIn .2s ease both;
}
.book-row:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.book-row:active { background: var(--bg2); }
.row-cover { width: 38px; height: 57px; border-radius: 4px; object-fit: cover; background: var(--bg2); flex-shrink: 0; }
.row-no-cover {
  width: 38px; height: 57px; border-radius: 4px;
  background: var(--bg3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--border2);
}
.row-info { flex: 1; min-width: 0; }
.row-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: .96rem; font-weight: 500; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-meta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.row-meta span + span::before { content: ' · '; }
.row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.row-leido { font-size: .71rem; padding: 3px 8px; border-radius: 10px; }
.leido-badge   { background: var(--leido-bg); color: var(--leido); }
.noleido-badge { background: var(--bg2); color: var(--muted); border: 1px solid var(--border); }

/* State */
.state-box { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--muted); }
.state-box h3 { font-family: 'Cormorant Garamond', serif; font-size: 1.4rem; color: var(--ink); margin-bottom: 8px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink2);
  font-size: .82rem; cursor: pointer; transition: all .15s; touch-action: manipulation;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ══════════════════════════════════════════════════
   Mobile bottom nav
══════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: var(--bottom-h);
  background: var(--ink); border-top: 1px solid rgba(255,255,255,.07);
  padding: 8px 8px 8px;
  align-items: center; justify-content: space-around;
  box-shadow: 0 -4px 20px rgba(30,26,20,.25);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 18px; border: none; background: transparent;
  color: rgba(255,255,255,.45); font-size: .64rem; cursor: pointer;
  border-radius: 8px; transition: color .15s; position: relative;
  touch-action: manipulation;
}
.bottom-nav-btn:active { background: rgba(255,255,255,.07); }
.bottom-nav-btn.primary-action {
  background: var(--accent); color: #fff;
  border-radius: 12px; padding: 8px 22px;
}
.bottom-nav-btn.primary-action:active { background: var(--accent-h); }
.filter-active-dot {
  position: absolute; top: 6px; right: 12px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

/* ══════════════════════════════════════════════════
   Modals
══════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(30,26,20,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 12px; animation: bdIn .2s ease;
}
@keyframes bdIn { from { opacity: 0; } }

.modal {
  background: var(--surface); border-radius: var(--r-lg);
  width: 100%; max-width: 500px;
  max-height: 94dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .22s ease;
}
.modal-lg { max-width: 680px; }
@keyframes modalIn { from { opacity:0; transform: translateY(14px); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0; position: sticky; top: 0;
  background: var(--surface); z-index: 1;
  border-bottom: 1px solid transparent;
}
.modal-header h2 { font-family: 'Cormorant Garamond', serif; font-size: 1.35rem; font-weight: 500; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--bg2); color: var(--muted);
  cursor: pointer; font-size: .9rem; transition: all .15s; flex-shrink: 0;
}
.modal-close:hover { background: var(--bg3); color: var(--ink); }
.modal-body { padding: 16px 20px 24px; }

/* ══════════════════════════════════════════════════
   Scanner
══════════════════════════════════════════════════ */
#scanner-viewport { border-radius: 8px; overflow: hidden; min-height: 200px; }
.scanner-hint { font-size: .8rem; color: var(--muted); text-align: center; margin: 8px 0; }
.isbn-manual-row { display: flex; gap: 8px; margin-top: 8px; }
.isbn-manual-row input {
  flex: 1; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg); color: var(--ink); font-size: 1rem; outline: none;
}
.isbn-manual-row input:focus { border-color: var(--accent); }
.isbn-found {
  margin-top: 14px; padding: 12px;
  background: var(--bg2); border-radius: var(--r); border: 1px solid var(--border);
  display: flex; gap: 12px; align-items: flex-start;
}
.isbn-found-cover { width: 52px; height: 78px; border-radius: 4px; overflow: hidden; background: var(--bg3); flex-shrink: 0; }
.isbn-found-cover img { width: 100%; height: 100%; object-fit: cover; }
.isbn-found-info { flex: 1; min-width: 0; }
.isbn-found-title { font-family: 'Cormorant Garamond', serif; font-size: 1rem; font-weight: 500; margin-bottom: 3px; }
.isbn-found-meta  { font-size: .76rem; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.isbn-found-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════
   Form
══════════════════════════════════════════════════ */
.form-cover-row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.form-cover-thumb {
  width: 66px; height: 99px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg2);
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.form-cover-thumb img { width: 100%; height: 100%; object-fit: cover; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.col-2 { grid-column: 1/-1; }
.full-width { flex: 1; }
.form-group label {
  font-size: .68rem; font-weight: 500; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--bg);
  color: var(--ink); font-size: 1rem; outline: none; transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); background: #fff; }
.form-group textarea { resize: vertical; line-height: 1.5; }
.field-hint { font-size: .7rem; color: var(--muted); margin-top: 2px; }

.leido-row { margin: 14px 0; }
.leido-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.leido-toggle input { display: none; }
.toggle-track {
  width: 40px; height: 22px; border-radius: 12px;
  background: var(--border2); position: relative; transition: background .2s; flex-shrink: 0;
}
.leido-toggle input:checked + .toggle-track { background: var(--leido); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .2s;
}
.leido-toggle input:checked + .toggle-track .toggle-knob { left: 21px; }
.toggle-label { font-size: .88rem; }

.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════
   Autocomplete
══════════════════════════════════════════════════ */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow);
  z-index: 600; overflow: hidden; max-height: 190px; overflow-y: auto;
}
.autocomplete-item {
  padding: 9px 12px; cursor: pointer; font-size: .87rem;
  transition: background .1s; display: flex; align-items: center;
  touch-action: manipulation;
}
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--bg2); }
.autocomplete-item mark {
  background: transparent; color: var(--accent); font-weight: 500;
}

/* ══════════════════════════════════════════════════
   Detail
══════════════════════════════════════════════════ */
.detail-layout { display: flex; gap: 20px; }
.detail-cover {
  width: 110px; flex-shrink: 0; border-radius: 8px;
  overflow: hidden; box-shadow: var(--shadow); background: var(--bg3);
  aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-info { flex: 1; min-width: 0; }
.detail-titulo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.45rem; font-weight: 500; line-height: 1.2; margin-bottom: 4px;
}
.detail-autor { color: var(--gold); font-size: .88rem; margin-bottom: 14px; }
.detail-dl { display: flex; flex-direction: column; gap: 7px; }
.detail-dl .row { display: flex; gap: 8px; font-size: .82rem; }
.detail-dl dt { color: var(--muted); min-width: 76px; flex-shrink: 0; }
.detail-dl dd { color: var(--ink2); }
.detail-para-leer {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px; padding: 4px 11px; border-radius: 20px; font-size: .78rem;
}
.detail-sinopsis {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: .86rem; line-height: 1.7; color: var(--ink2);
}
.detail-sinopsis-label {
  font-size: .68rem; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.detail-actions {
  display: flex; gap: 8px; margin-top: 18px;
  padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════
   Toast
══════════════════════════════════════════════════ */
.toast {
  position: fixed; left: 50%; z-index: 999; pointer-events: none;
  transform: translateX(-50%) translateY(60px);
  background: var(--ink); color: var(--bg);
  padding: 10px 20px; border-radius: 20px; font-size: .84rem;
  transition: transform .28s ease, opacity .28s ease; white-space: nowrap;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
  bottom: 20px;
  opacity: 0;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok  { background: var(--leido); }
.toast.err { background: #9b2c2c; }

/* ══════════════════════════════════════════════════
   RESPONSIVE — tablet / mobile
══════════════════════════════════════════════════ */
@media (max-width: 760px) {
  /* Show bottom nav */
  .bottom-nav { display: flex; }

  /* Hide desktop-only elements */
  .btn-scan, .btn-add-desktop { display: none; }

  /* Main gets bottom padding for nav */
  .main { padding: 12px 14px calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); }

  /* Layout: single column */
  .layout { grid-template-columns: 1fr; }

  /* Sidebar becomes slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 85vw);
    z-index: 300;
    transform: translateX(-110%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    height: 100dvh;
    padding-top: calc(var(--header-h) + 16px);
    border-right: 1px solid var(--border);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Overlay behind drawer */
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0; z-index: 299;
    background: rgba(30,26,20,.45); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity .28s;
  }
  .sidebar-overlay.visible { opacity: 1; pointer-events: all; }

  /* Toast above bottom nav */
  .toast { bottom: calc(var(--bottom-h) + 10px + env(safe-area-inset-bottom)); }

  /* Modal as bottom sheet */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 92dvh; max-width: 100%;
    animation: sheetUp .25s cubic-bezier(.4,0,.2,1);
  }
  @keyframes sheetUp { from { transform: translateY(100%); } }

  /* Drag handle on mobile modals */
  .modal-header::before {
    content: '';
    display: block;
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: var(--border2);
  }
  .modal-header { position: relative; margin-top: 8px; }

  /* Form single column on small screens */
  .form-grid { grid-template-columns: 1fr; }
  .form-group.col-2 { grid-column: 1; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; padding: 13px; font-size: .9rem; }

  /* Detail stacked */
  .detail-actions { flex-direction: column; }
  .detail-actions .btn { width: 100%; justify-content: center; padding: 12px; }

  /* Grid: 2 columns on narrow */
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
}

@media (max-width: 380px) {
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .logo { font-size: 1.15rem; }
}

@media (min-width: 761px) {
  /* Desktop: detail layout side by side */
  .detail-layout { gap: 22px; }
}
