* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px; min-height: 100vh; color: #2c3e50;
}
.container { max-width: 1000px; margin: 0 auto; }
.header {
  text-align: center; margin-bottom: 20px; background: #fff;
  padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,.1);
  position: relative;
}
.header h1 { font-size: 1.8em; margin-bottom: 6px; }
.header .sub { color: #7f8c8d; font-size: .85em; display: flex; justify-content: center; gap: 12px; align-items: center; flex-wrap: wrap; }
.auth-box { position: absolute; top: 16px; right: 16px; }
.btn { border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all .2s; font-size: .85em; }
.btn:hover { opacity: .9; }
.btn-mini { background: #667eea; color: #fff; padding: 5px 12px; }
.btn-ghost { background: #ecf0f1; color: #2c3e50; padding: 5px 12px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  background: #fff; padding: 14px; border-radius: 12px; margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,.1);
}
.filter-btn {
  border: 2px solid #ddd; background: #fff; padding: 7px 14px; border-radius: 20px;
  font-size: .82em; font-weight: 600; cursor: pointer; transition: all .2s;
}
.filter-btn.active { color: #fff; }
.f-candidate { border-color: #16a085; color: #16a085; } .f-candidate.active { background: #16a085; color: #fff; }
.f-wishlist { border-color: #8e44ad; color: #8e44ad; } .f-wishlist.active { background: #8e44ad; color: #fff; }
.f-unborrowed { border-color: #95a5a6; color: #95a5a6; } .f-unborrowed.active { background: #95a5a6; color: #fff; }
.f-pending { border-color: #f39c12; color: #f39c12; } .f-pending.active { background: #f39c12; color: #fff; }
.f-borrowed { border-color: #e74c3c; color: #e74c3c; } .f-borrowed.active { background: #e74c3c; color: #fff; }
.f-returned { border-color: #27ae60; color: #27ae60; } .f-returned.active { background: #27ae60; color: #fff; }
.f-all { border-color: #667eea; color: #667eea; } .f-all.active { background: #667eea; color: #fff; }

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; margin: 0 auto 14px; }
.action-btn {
  border: none; background: #fff; padding: 9px 16px; border-radius: 8px; font-size: .82em;
  font-weight: 600; cursor: pointer; color: #2c3e50; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  display: inline-flex; align-items: center; gap: 5px;
}
.action-btn:hover { background: #f0f0f0; }
.action-btn.primary { background: #8e44ad; color: #fff; }
.action-btn.danger { background: #fdecea; color: #c0392b; }
.action-btn.danger:hover { background: #f9d6d1; }
.filter-count { text-align: center; color: rgba(255,255,255,.9); font-size: .85em; margin-bottom: 14px; }

.section-title { color: #fff; font-size: 1.2em; margin: 24px 0 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 28px; }
.card {
  background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.1);
  transition: transform .2s, box-shadow .2s; display: flex; flex-direction: column; cursor: pointer;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.card.hidden { display: none; }
.card-number { font-size: .72em; color: #95a5a6; font-weight: 600; margin-bottom: 6px; letter-spacing: .5px; }
.card-title { font-size: .95em; font-weight: 600; margin-bottom: 8px; line-height: 1.3; flex-grow: 1; }
.card-author { font-size: .8em; color: #7f8c8d; margin-bottom: 10px; line-height: 1.3; }
.card-holdings { font-size: .74em; color: #555; margin-bottom: 8px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; padding: 5px 10px; border-radius: 4px; font-size: .72em; font-weight: 600; color: #fff; align-self: flex-start; }
.b-candidate { background: #16a085; }
.b-wishlist { background: #8e44ad; } .b-unborrowed { background: #95a5a6; } .b-pending { background: #f39c12; }
.tracklist { margin: 4px 0 0 1.3em; padding: 0; }
.tracklist li { font-size: .84em; color: #34495e; padding: 2px 0; }
.b-borrowed { background: #e74c3c; } .b-returned { background: #27ae60; }
.section-wrapper.hidden { display: none; }
.footer { text-align: center; color: rgba(255,255,255,.8); padding: 20px; font-size: .85em; margin-top: 28px; }

/* Modal */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1000; justify-content: center; align-items: flex-end; }
.overlay.open { display: flex; }
.modal { background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 600px; max-height: 88vh; overflow-y: auto; padding: 22px; position: relative; animation: slideUp .25s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-close { position: sticky; top: 0; float: right; background: #ecf0f1; border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 1.2em; cursor: pointer; z-index: 1; }
.modal-title { font-size: 1.2em; font-weight: 700; margin-bottom: 16px; padding-right: 40px; line-height: 1.4; }
.row { display: flex; gap: 8px; margin-bottom: 10px; font-size: .9em; line-height: 1.5; }
.row .label { color: #95a5a6; font-weight: 600; min-width: 70px; flex-shrink: 0; }
.holdings-list { list-style: none; }
.holdings-list li { padding: 4px 0; border-bottom: 1px solid #f0f0f0; font-size: .85em; color: #34495e; }
.holdings-list li:last-child { border-bottom: none; }
.holdings-list li.hidden { display: none; }
.link-btn { background: none; border: none; color: #667eea; font-size: .85em; font-weight: 600; cursor: pointer; padding: 6px 0; }

/* form */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .82em; color: #7f8c8d; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: .95em; font-family: inherit;
}
.field textarea { min-height: 60px; resize: vertical; }
.status-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.status-pick { border: 2px solid #ddd; background: #fff; padding: 6px 12px; border-radius: 16px; font-size: .8em; font-weight: 600; cursor: pointer; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid #eee; }
.modal-actions .btn { padding: 10px 18px; font-size: .9em; }
.btn-go { background: #27ae60; color: #fff; }
.btn-sub { background: #667eea; color: #fff; }
.btn-warn { background: #e74c3c; color: #fff; }
.btn-gray { background: #ecf0f1; color: #2c3e50; }
.cand { display: flex; gap: 10px; padding: 10px; border: 2px solid #eee; border-radius: 8px; margin-bottom: 8px; cursor: pointer; align-items: flex-start; }
.cand:hover { border-color: #8e44ad; background: #faf6fd; }
.cand img { width: 44px; height: auto; flex-shrink: 0; border-radius: 3px; }
.cand img { width: 44px; height: auto; flex-shrink: 0; border-radius: 3px; }
.cand .ci-title { font-size: .88em; font-weight: 600; }
.cand .ci-sub { font-size: .76em; color: #95a5a6; margin-top: 2px; }
.cand-ph { width: 44px; height: 62px; flex-shrink: 0; border-radius: 3px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 1.4em; }

/* card cover */
.card-head { display: flex; gap: 10px; margin-bottom: 10px; }
.card-cover { width: 46px; height: 66px; object-fit: cover; border-radius: 3px; flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.card-cover.ph { background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 1.4em; box-shadow: none; }
.card-head-text { flex: 1; min-width: 0; }
.card-head .card-title, .card-head .card-author { margin-bottom: 4px; }

/* confirm */
.confirm-book { display: flex; gap: 14px; margin-bottom: 8px; }
.confirm-cover { width: 90px; height: auto; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.2); flex-shrink: 0; }
.confirm-cover.ph { width: 90px; height: 128px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 2.4em; }
.cb-info { flex: 1; min-width: 0; }
.cb-title { font-size: 1.05em; font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.cb-meta { font-size: .85em; color: #555; margin-bottom: 3px; }
.cb-src { margin-top: 6px; }
.detail-cover-wrap { text-align: center; margin-bottom: 14px; }
.detail-cover { max-height: 180px; width: auto; border-radius: 6px; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.toast { position: fixed; top: 18px; right: 18px; color: #fff; padding: 14px 20px; border-radius: 8px; z-index: 9999; font-size: .9em; box-shadow: 0 4px 12px rgba(0,0,0,.25); max-width: 320px; }
.muted { color: #95a5a6; font-size: .85em; }

@media (min-width: 641px) {
  .overlay { align-items: center; }
  .modal { border-radius: 16px; max-height: 84vh; }
}
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .filter-bar { display: grid; grid-template-columns: repeat(3, 1fr); }
  .filter-btn { text-align: center; }
}

/* print */
@page { margin: 10mm; }
.print-area { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  .header, .filter-bar, .filter-count, .footer, .action-bar, .card-grid, .section-title, .overlay { display: none !important; }
  .print-area { display: block !important; }
  .print-area h2 { font-size: 1.1em; margin: 10px 0 8px; }
  .print-area table { width: 100%; border-collapse: collapse; font-size: .8em; margin-bottom: 18px; }
  .print-area th, .print-area td { border: 1px solid #ccc; padding: 5px 8px; text-align: left; }
  .print-area th { background: #f5f5f5; }
  .print-head { text-align: center; font-size: 1.3em; font-weight: 700; margin-bottom: 12px; }
}
