/* ---------- tokens ---------- */
:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1c1a;
  --muted: #6f6b64;
  --border: #e2dfd8;
  --accent: #1d1c1a;
  --accent-text: #ffffff;
  --offer: #2f6f4f;
  --reserved-bg: #f6e7c1;
  --reserved-fg: #7a5410;
  --sold-bg: #1d1c1a;
  --sold-fg: #ffffff;
  --success-bg: #e3f1e7;
  --success-fg: #1f5a35;
  --error-bg: #fbe4e1;
  --error-fg: #8a2318;
  --warn-bg: #fbf0d6;
  --warn-fg: #6e4b0c;
  --focus: #3a6fd8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151413;
  --surface: #1f1e1c;
  --surface-2: #2a2926;
  --text: #eeece8;
  --muted: #a19c93;
  --border: #34322e;
  --accent: #eeece8;
  --accent-text: #151413;
  --offer: #7cc79c;
  --reserved-bg: #4a3a14;
  --reserved-fg: #f4d78f;
  --sold-bg: #eeece8;
  --sold-fg: #151413;
  --success-bg: #183324;
  --success-fg: #9fdcb5;
  --error-bg: #3d1b17;
  --error-fg: #f4b0a6;
  --warn-bg: #3a2e12;
  --warn-fg: #f1d491;
  --focus: #7ea6f5;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85em; }

/* ---------- header ---------- */
.site-header { padding: 18px 0; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.01em; }
.header-right { display: flex; align-items: center; gap: 14px; }
.admin-link { font-size: 0.9rem; color: var(--muted); text-decoration: none; }
.admin-link:hover { color: var(--text); }
.lang-switch { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.lang-switch a {
  font-size: 0.8rem; font-weight: 600; text-decoration: none; color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
}
.lang-switch a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.theme-toggle {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); text-decoration: none; flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .icon-sun, :root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

main.wrap { padding-bottom: 64px; }

/* ---------- buttons, forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 0.95rem; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { opacity: 0.88; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.field > span em { font-weight: 400; font-style: normal; color: var(--muted); }
.field small { color: var(--muted); font-size: 0.82rem; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
textarea { resize: vertical; min-height: 84px; }

.notice {
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 0.93rem; margin-bottom: 16px;
}
.notice.success { background: var(--success-bg); color: var(--success-fg); }
.notice.error { background: var(--error-bg); color: var(--error-fg); }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice a { font-weight: 600; }

/* ---------- badges ---------- */
.badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 9px; border-radius: 999px;
}
.badge.inline { position: static; vertical-align: middle; margin-left: 8px; }
.badge-reserved { background: var(--reserved-bg); color: var(--reserved-fg); }
.badge-sold { background: var(--sold-bg); color: var(--sold-fg); }

/* ---------- home ---------- */
.intro { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin: 10px 0 26px; white-space: pre-line; }

.search { position: relative; max-width: 420px; margin-bottom: 26px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px !important; border-radius: 999px !important; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(0 0 0 / 0.05), 0 10px 28px rgb(0 0 0 / 0.08); }
.card-img { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--surface-2); }
.card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; }
.card-title { font-size: 0.98rem; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { font-weight: 700; font-size: 1.05rem; }
.card-price.offer, .item-price.offer { color: var(--offer); }
.card.status-sold .card-img img { filter: grayscale(0.7); opacity: 0.6; }
.card.status-sold .card-price { color: var(--muted); text-decoration: line-through; }

.noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); opacity: 0.6; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- item page ---------- */
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.93rem; margin: 4px 0 18px; }
.back:hover { color: var(--text); }

.item-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; align-items: start; }

.gallery { min-width: 0; }
.gallery-main { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.slides {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; aspect-ratio: 4 / 3;
}
.slides::-webkit-scrollbar { display: none; }
.slide { position: relative; flex: 0 0 100%; margin: 0; scroll-snap-align: center; }
.slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.empty-gallery { aspect-ratio: 4 / 3; }

.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgb(255 255 255 / 0.88); color: #1d1c1a; box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  transition: opacity 0.15s;
}
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-nav:disabled { opacity: 0; pointer-events: none; }
.gallery-count {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 0.78rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.thumbs { position: relative; display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.thumb {
  flex: 0 0 72px; height: 72px; border-radius: var(--radius-sm); overflow: hidden;
  opacity: 0.55; outline: 2px solid transparent; outline-offset: 0; transition: opacity 0.15s, outline-color 0.15s;
  background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: 0.85; }
.thumb.active { opacity: 1; outline-color: var(--text); }

.item-info { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.item-title { font-size: 1.85rem; font-weight: 700; }
.item-price { font-size: 1.6rem; font-weight: 700; margin-top: -6px; }
.description { white-space: pre-line; color: var(--text); overflow-wrap: anywhere; }

.contact-box {
  background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; margin-top: 6px;
}
.contact-box h2 { font-size: 1.15rem; }
.contact-box .notice { margin: 0; }
.contact-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* lightbox */
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: rgb(10 10 10 / 0.96); color: #fff;
}
.lightbox[open] { display: grid; place-items: center; }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox::backdrop { background: rgb(0 0 0 / 0.6); }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; user-select: none; touch-action: pan-y pinch-zoom; }
.lb-btn {
  position: absolute; border: 0; background: rgb(255 255 255 / 0.12); color: #fff; cursor: pointer;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
}
.lb-btn:hover { background: rgb(255 255 255 / 0.22); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); font-size: 0.85rem; opacity: 0.8; }

.not-found { text-align: center; padding: 80px 0; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.not-found .big { font-size: 4rem; font-weight: 800; letter-spacing: -0.04em; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .item-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .item-info { position: static; }
  .item-title { font-size: 1.5rem; }
  .item-price { font-size: 1.4rem; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-body { padding: 10px 11px 12px; }
  .card-title { font-size: 0.92rem; }
  .card-price { font-size: 0.98rem; }
  .intro { font-size: 1rem; }
  .search { max-width: none; }
  .gallery-main { margin: 0 -14px; border-radius: 0; }
  .gallery-nav { display: none; }
  .contact-box { padding: 18px; }
}
@media (hover: none) {
  .card:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .slides { scroll-behavior: auto; }
  .card, .btn { transition: none; }
}
