:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-muted: #f5f5f4;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #750014;
  --accent-dark: #5f0010;
  --accent-light: #fef2f2;
  --shadow: 0 1px 3px rgba(0,0,0,0.06),
    0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
  --radius: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, p, label, input, button {
  font-family: inherit;
}

h1, h2, h3 {
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 700;
  margin-top: 0;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2.5vw, 2rem); }
h3 { font-size: 1.1rem; font-weight: 600; }

p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
  margin: 0;
}

.shell {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
}

#inventory { position: relative; scroll-margin-top: 72px; }

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- Header ---- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250,250,249,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.header-body {
  display: flex;
  align-items: center;
  gap: 16px;
}

.actions { margin-left: auto; }

.header-tagline {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Filters ---- */

.cat-toggle { display: none; }

.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 32px;
  margin-bottom: 24px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 0;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: all 150ms ease;
  user-select: none;
}

.filter-pill:hover {
  border-color: var(--ink);
  color: var(--ink);
}

#cat-all:checked ~ .filter-bar label[for="cat-all"],
#cat-electronics:checked ~ .filter-bar label[for="cat-electronics"],
#cat-furniture:checked ~ .filter-bar label[for="cat-furniture"],
#cat-instruments:checked ~ .filter-bar label[for="cat-instruments"],
#cat-other:checked ~ .filter-bar label[for="cat-other"],
#cat-bikes:checked ~ .filter-bar label[for="cat-bikes"],
#cat-clothes:checked ~ .filter-bar label[for="cat-clothes"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

#cat-electronics:checked ~ .items .card,
#cat-furniture:checked ~ .items .card,
#cat-instruments:checked ~ .items .card,
#cat-other:checked ~ .items .card,
#cat-bikes:checked ~ .items .card,
#cat-clothes:checked ~ .items .card {
  display: none;
}

#cat-electronics:checked ~ .items .card[data-category="electronics"],
#cat-furniture:checked ~ .items .card[data-category="furniture"],
#cat-instruments:checked ~ .items .card[data-category="instruments"],
#cat-other:checked ~ .items .card[data-category="other"],
#cat-bikes:checked ~ .items .card[data-category="bikes"],
#cat-clothes:checked ~ .items .card[data-category="clothes"] {
  display: flex;
}

/* ---- Cards ---- */

.section {
  padding: 0 0 80px;
}

.items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 200ms ease,
    border-color 200ms ease;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card:hover {
  border-color: #d6d3d1;
  box-shadow: var(--shadow-md);
}

.card-gallery {
  position: relative;
  height: 220px;
  background: var(--surface-muted);
  overflow: hidden;
}

.modal-gallery {
  height: clamp(200px, 40vw, 380px);
  border-radius: 8px;
  margin-bottom: 20px;
}

.card-gal-toggle { display: none; }
.card-gal-slide {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}

.card-image-link {
  display: block;
  width: 100%;
  height: 100%;
}

.card-gal-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

.card:hover .card-gal-slide img {
  transform: scale(1.03);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 8px;
}

.badge-new {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-used {
  background: #f5f5f5;
  color: #666;
}

.card-info-link {
  display: block;
  flex: 1;
}

.card-gal-toggle:nth-of-type(1):checked ~ .card-gal-slide:nth-of-type(1),
.card-gal-toggle:nth-of-type(2):checked ~ .card-gal-slide:nth-of-type(2),
.card-gal-toggle:nth-of-type(3):checked ~ .card-gal-slide:nth-of-type(3),
.card-gal-toggle:nth-of-type(4):checked ~ .card-gal-slide:nth-of-type(4),
.card-gal-toggle:nth-of-type(5):checked ~ .card-gal-slide:nth-of-type(5),
.card-gal-toggle:nth-of-type(6):checked ~ .card-gal-slide:nth-of-type(6),
.card-gal-toggle:nth-of-type(7):checked ~ .card-gal-slide:nth-of-type(7),
.card-gal-toggle:nth-of-type(8):checked ~ .card-gal-slide:nth-of-type(8) {
  display: block;
}

.card-gal-nav {
  position: absolute;
  top: 0; bottom: 0; width: 40px;
  display: flex; align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 24px;
  z-index: 5;
  opacity: 0;
  background: rgba(0,0,0,0.15);
  transition: opacity 200ms ease;
  user-select: none;
}

.card-gal-slide:hover .card-gal-nav,
.modal-gallery .card-gal-nav {
  opacity: 0.8;
}

.card-gal-nav:hover { opacity: 1; }

.card-gal-nav.prev { left: 0; }
.card-gal-nav.next { right: 0; }

.item-copy {
  padding: 16px 18px;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4em;
  min-height: 2.8em;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.price {
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.listing-submeta {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---- Buttons ---- */

.actions, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 180ms ease;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.actions:hover, button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* ---- Modals ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal:target { display: flex; }

body:has(.modal:target) {
  overflow: hidden;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28,25,23,0.3);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 5vw, 48px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: clamp(20px, 4vw, 36px);
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-muted);
  transition: all 150ms ease;
  margin-top: -4px;
  margin-right: -8px;
}

.modal-close:hover {
  background: var(--line);
  color: var(--ink);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(24px, 5vw, 56px);
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-details h4 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.modal-details p {
  color: var(--ink);
  font-size: 0.95rem;
}

/* ---- Forms ---- */

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

input, select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  background: var(--surface);
  transition: border-color 150ms ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
}

::placeholder {
  font-size: 0.85rem;
  opacity: 0.5;
}

.photo-upload-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.photo-upload-row .photo-upload-zone {
  min-width: 0;
  width: auto;
}

.photo-upload-extra .upload-hint h3 {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 4px;
}

.photo-upload-zone {
  display: block;
  position: relative;
  height: 160px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  cursor: pointer;
  transition: all 150ms ease;
  overflow: hidden;
}

.photo-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.photo-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  pointer-events: none;
}

.upload-hint h3 {
  margin-bottom: 2px;
  color: var(--ink);
}

.upload-hint p {
  margin: 0;
  font-size: 0.85rem;
}

.upload-state-selected { display: none; color: #2e7d32; }
.photo-upload-zone input:valid ~ .upload-hint .upload-state-initial { display: none; }
.photo-upload-zone input:valid ~ .upload-hint .upload-state-selected { display: block; }
.photo-upload-zone input:valid { cursor: pointer; }
.photo-upload-zone:has(input:valid) {
  border-color: #2e7d32;
  background: #f1f8e9;
  border-style: solid;
}

.modal-details-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-form-side h3 {
  margin-bottom: 12px;
}

/* ---- Seller modal ---- */

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.form-actions .buy-action { margin-left: auto; }

.btn-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  transition: all 180ms ease;
}

.btn-reset:hover {
  border-color: var(--ink);
  color: var(--ink);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.submit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}

.submit-overlay.active {
  display: flex;
}

.submit-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.submit-overlay p {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
}

.batch-toggle { display: none; }

.batch-slot-1,
.batch-slot-2,
.batch-slot-3,
.batch-slot-4,
.batch-slot-5,
.batch-slot-6,
.batch-slot-7,
.batch-slot-8,
.batch-slot-9 {
  display: none;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

#show-slot-1:checked ~ .batch-slot-1,
#show-slot-2:checked ~ .batch-slot-2,
#show-slot-3:checked ~ .batch-slot-3,
#show-slot-4:checked ~ .batch-slot-4,
#show-slot-5:checked ~ .batch-slot-5,
#show-slot-6:checked ~ .batch-slot-6,
#show-slot-7:checked ~ .batch-slot-7,
#show-slot-8:checked ~ .batch-slot-8,
#show-slot-9:checked ~ .batch-slot-9 {
  display: block;
}

.batch-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 100%;
  border: 2px dashed #d32f2f;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  color: #d32f2f;
  transition: all 150ms ease;
}

.batch-add:hover {
  background: none;
  border-color: #b71c1c;
  color: #b71c1c;
}

.batch-add-2,
.batch-add-3,
.batch-add-4,
.batch-add-5,
.batch-add-6,
.batch-add-7,
.batch-add-8,
.batch-add-9 { display: none; }

#show-slot-1:checked ~ .batch-add-1 { display: none; }
#show-slot-1:checked ~ .batch-add-2 { display: inline-flex; }
#show-slot-2:checked ~ .batch-add-2 { display: none; }
#show-slot-2:checked ~ .batch-add-3 { display: inline-flex; }
#show-slot-3:checked ~ .batch-add-3 { display: none; }
#show-slot-3:checked ~ .batch-add-4 { display: inline-flex; }
#show-slot-4:checked ~ .batch-add-4 { display: none; }
#show-slot-4:checked ~ .batch-add-5 { display: inline-flex; }
#show-slot-5:checked ~ .batch-add-5 { display: none; }
#show-slot-5:checked ~ .batch-add-6 { display: inline-flex; }
#show-slot-6:checked ~ .batch-add-6 { display: none; }
#show-slot-6:checked ~ .batch-add-7 { display: inline-flex; }
#show-slot-7:checked ~ .batch-add-7 { display: none; }
#show-slot-7:checked ~ .batch-add-8 { display: inline-flex; }
#show-slot-8:checked ~ .batch-add-8 { display: none; }
#show-slot-8:checked ~ .batch-add-9 { display: inline-flex; }
#show-slot-9:checked ~ .batch-add-9 { display: none; }

.batch-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 100%;
  background: none;
  border: 2px dashed var(--line);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 150ms ease;
}

.batch-remove:hover {
  background: none;
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Notice pages ---- */

.notice {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  padding: 80px 0;
}

.notice h1 { margin-bottom: 16px; }

.notice-image {
  max-width: 280px;
  margin: 0 auto 24px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.notice-image img {
  width: 100%;
  height: auto;
  display: block;
}

.notice p {
  margin-bottom: 32px;
  font-size: 1rem;
}

/* ---- Footer ---- */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 48px 0;
  margin-top: 64px;
}

.footer-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.footer-logo { height: 36px; opacity: 0.7; }

.footer-contact {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .items { grid-template-columns: repeat(2, 1fr); }
  .modal-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .modal-panel { padding: 28px 24px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
}

@media (max-width: 600px) {
  .logo { height: 28px; }
  .header { padding: 10px 0; }
  .header-tagline { display: none; }
  .shell { width: calc(100% - 28px); }
  h2 { font-size: 1.4rem; }

  .section { padding: 0 0 48px; }

  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 4px;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-pill {
    flex-shrink: 0;
    height: 32px;
    padding: 0 14px;
    font-size: 0.78rem;
  }

  .items { grid-template-columns: 1fr; gap: 12px; }
  .card-gallery { height: 190px; }
  .item-copy { padding: 12px 14px; }
  .card-title { font-size: 0.9rem; }
  .price { font-size: 1rem; }

  .modal { padding: 0; }
  .modal-panel {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    padding: 20px 18px;
    -webkit-overflow-scrolling: touch;
  }
  .modal-head { margin-bottom: 20px; }
  .photo-upload-zone { height: 120px; }

  .batch-slot-1,
  .batch-slot-2,
  .batch-slot-3,
  .batch-slot-4,
  .batch-slot-5,
  .batch-slot-6,
  .batch-slot-7,
  .batch-slot-8,
  .batch-slot-9 { padding-top: 14px; }

  .actions, button {
    height: 40px;
    padding: 0 20px;
    font-size: 0.85rem;
  }

  .form-actions { gap: 8px; }
  .btn-reset, .form-actions .buy-action {
    padding: 0 16px;
  }

  .footer { padding: 32px 0; margin-top: 32px; }
  .footer-logo { height: 26px; }

  .notice { padding: 48px 0; }
  .notice p {
    font-size: 0.95rem;
    margin-bottom: 24px;
  }
}
