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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f5f6fa;
  color: #222;
  min-height: 100vh;
}

/* 헤더 */
header {
  background: #1a3a6b;
  color: white;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* 버튼 */
.btn-primary {
  background: #e8a020;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: #cf8c18; }

.btn-secondary {
  background: #eee;
  color: #444;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover { background: #ddd; }

.btn-sold {
  background: #888;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-sold:hover { background: #666; }

/* 검색/필터 */
.search-section {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 0 20px;
}

#searchInput {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #dde1ea;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

#searchInput:focus { border-color: #1a3a6b; }

.filters {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.filters select {
  padding: 8px 12px;
  border: 2px solid #dde1ea;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.filters select:focus { border-color: #1a3a6b; }

/* 책 목록 */
main {
  max-width: 1100px;
  margin: 20px auto 60px;
  padding: 0 20px;
}

.book-count {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* 책 카드 */
.book-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  border: 2px solid transparent;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border-color: #1a3a6b;
}

.book-card.sold {
  opacity: 0.5;
  pointer-events: none;
}

.sold-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #888;
  color: white;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.4;
  color: #1a1a2e;
}

.card-author {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 10px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tag {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.tag-dept {
  background: #e8f0fb;
  color: #1a3a6b;
}

.tag-subject {
  background: #fff3e0;
  color: #b35c00;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a3a6b;
}

.badge-condition {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.condition-상 { background: #d4edda; color: #155724; }
.condition-중 { background: #fff3cd; color: #856404; }
.condition-하 { background: #f8d7da; color: #721c24; }

.empty-msg {
  text-align: center;
  color: #aaa;
  font-size: 1.1rem;
  margin-top: 80px;
}

/* 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #888;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-close:hover { background: #eee; }

/* 폼 */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #1a3a6b;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* 상세 모달 */
.detail-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a3a6b;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.95rem;
}

.detail-row span:first-child {
  color: #888;
  font-weight: 600;
}

.detail-desc {
  background: #f8f9fc;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.92rem;
  color: #444;
  line-height: 1.6;
  min-height: 40px;
}

.contact-box {
  background: #e8f0fb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 14px;
  text-align: center;
}

.contact-box p {
  font-size: 0.85rem;
  color: #1a3a6b;
  margin-bottom: 4px;
}

.contact-box strong {
  font-size: 1.1rem;
  color: #1a3a6b;
}

.detail-actions {
  margin-top: 16px;
  text-align: right;
}

/* 로딩 */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
  font-size: 1rem;
}

/* 반응형 */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: 1fr 1fr; }
  header h1 { font-size: 1.1rem; }
}

@media (max-width: 400px) {
  .book-grid { grid-template-columns: 1fr; }
}
