:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --ink: #221e1a;
  --muted: #6f665c;
  --line: #e4ddd2;
  --accent: #7a5c3e;
  --accent-ink: #fff;
  --sold: #9b3b30;
  --reserved: #a8741a;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(34,30,26,.06), 0 8px 24px rgba(34,30,26,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --surface: #211d1a; --ink: #f1ebe3; --muted: #a89d90;
    --line: #342e29; --accent: #c89f73; --accent-ink: #171412; --shadow: none; --danger: #ef8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412; --surface: #211d1a; --ink: #f1ebe3; --muted: #a89d90;
  --line: #342e29; --accent: #c89f73; --accent-ink: #171412; --shadow: none; --danger: #ef8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* Author display rules (.busy grid, .thumbs flex) otherwise override the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 Inter, system-ui, sans-serif; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; }
h1, h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; letter-spacing: .01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 30px; line-height: 1; }
.tag { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { font: inherit; font-weight: 500; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.icon { width: 40px; padding: 9px 0; text-align: center; }
.btn.lang { padding-inline: 12px; appearance: none; text-align: center; }
.btn.danger { color: var(--danger); }
.editbar { background: var(--accent); color: var(--accent-ink); font-size: 13px; padding-block: 5px; }

.controls { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding-block: 22px 8px; }
.controls input, .controls select, .field input, .field select, .field textarea { font: inherit; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0; width: 100%; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip small { color: inherit; opacity: .6; margin-left: 4px; }
.count { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; padding-bottom: 40px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; display: flex; flex-direction: column; transition: transform .15s ease; }
.card:hover { transform: translateY(-2px); }
.card-img { position: relative; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; background: var(--line); flex: none; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; color: #fff; }
.badge.sold { background: var(--sold); } .badge.reserved { background: var(--reserved); }
.nphotos { position: absolute; bottom: 10px; right: 10px; font-size: 12px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 8px; border-radius: 999px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card-title { font-family: "Cormorant Garamond", Georgia, serif; font-size: 20px; line-height: 1.2; margin: 0; font-weight: 600; }
.card-meta { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.card-meta .price { color: var(--ink); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.foot { padding-block: 10px 40px; font-size: 13px; }
.foot a { color: var(--muted); }

dialog { color: var(--ink); }
.detail, .editor { width: min(1080px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: none; border-radius: var(--radius); background: var(--surface); }
.detail::backdrop, .editor::backdrop { background: rgba(20,16,12,.6); }
.close { position: absolute; top: 10px; right: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--bg); color: var(--ink); font-size: 24px; cursor: pointer; }
.detail-body { display: grid; grid-template-columns: 1.2fr 1fr; }
.gallery { background: #0f0d0b; display: flex; flex-direction: column; }
.gallery > img { width: 100%; max-height: 70vh; object-fit: contain; flex: 1; min-height: 0; }
.thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.thumbs button { flex: 0 0 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; background: none; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.info { padding: 28px; overflow-y: auto; max-height: calc(100vh - 32px); }
.eyebrow { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.info h2 { font-size: 30px; line-height: 1.15; margin: 6px 0 16px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.facts div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; min-height: 1.4em; }
.desc { white-space: pre-line; margin: 0 0 18px; }
.src { font-size: 13px; color: var(--accent); }

.editor form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.ed-head { position: relative; padding: 18px 24px 8px; border-bottom: 1px solid var(--line); }
.ed-head h2 { margin: 0; font-size: 26px; }
.ed-body { padding: 16px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.ed-section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ed-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.ed-photo { position: relative; width: 110px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.ed-photo img { width: 110px; height: 110px; object-fit: cover; display: block; }
.ed-photo .tools { display: flex; justify-content: space-between; }
.ed-photo .tools button { flex: 1; border: none; background: transparent; color: var(--ink); padding: 5px 0; cursor: pointer; font-size: 14px; }
.ed-photo .tools button:hover { background: var(--line); }
.ed-photo .cover { position: absolute; top: 4px; left: 4px; font-size: 10px; background: var(--accent); color: var(--accent-ink); padding: 1px 6px; border-radius: 4px; }
.upload { display: inline-block; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field textarea { min-height: 88px; resize: vertical; }
.langrow { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: start; margin-bottom: 6px; }
.langrow .code { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 11px; }
.langrow .code .auto { display: block; font-weight: 400; font-size: 10px; color: var(--accent); }
.ed-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ed-grid .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; }
.hint { margin: -10px 0 0; font-size: 12px; color: var(--muted); }
.ed-foot { display: flex; gap: 8px; align-items: center; padding: 12px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.status-line { flex: 1; font-size: 13px; color: var(--muted); min-width: 120px; }

.busy { position: fixed; inset: 0; background: rgba(20,16,12,.5); display: grid; place-items: center; z-index: 20; }
.busy-box { background: var(--surface); padding: 18px 24px; border-radius: 12px; display: flex; gap: 12px; align-items: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100vw - 32px); font-size: 14px; }

@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr; }
  .detail-body { grid-template-columns: 1fr; }
  .info { max-height: none; }
  .facts { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 26px; }
  .ed-grid { grid-template-columns: 1fr; }
  .ed-head, .ed-body, .ed-foot { padding-inline: 16px; }
}
