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

:root {
  --bg: #0e0e0e;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --accent: #c8a96e;
  --accent-hover: #dfc08a;
  --text: #e0e0e0;
  --text-muted: #888;
  --sidebar-w: 240px;
  --header-h: 48px;
  --radius: 6px;
  --trans: 0.18s ease;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

/* ── Header ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
}

.site-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--trans);
}

/* ── Layout ── */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-inner { padding: 12px 8px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.all-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  font-weight: 600;
  transition: background var(--trans), color var(--trans);
  margin-bottom: 8px;
}
.all-btn:hover { background: var(--surface2); }
.all-btn.active { background: var(--accent); color: #111; }

/* Tree */
.tree-year {
  margin-bottom: 4px;
}

.tree-year-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--trans);
}
.tree-year-btn:hover { background: var(--surface2); }
.tree-year-btn.active { color: var(--accent); }

.tree-caret {
  display: inline-block;
  font-size: 10px;
  transition: transform var(--trans);
  color: var(--text-muted);
}
.tree-year.open > .tree-year-btn .tree-caret { transform: rotate(90deg); }

.tree-seasons {
  display: none;
  padding-left: 14px;
}
.tree-year.open > .tree-seasons { display: block; }

.tree-season { margin-bottom: 2px; }

.tree-season-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background var(--trans), color var(--trans);
}
.tree-season-btn:hover { background: var(--surface2); color: var(--text); }
.tree-season-btn.active { color: var(--accent); background: var(--surface2); }

.tree-categories {
  display: none;
  padding-left: 14px;
}
.tree-season.open > .tree-categories { display: block; }

.tree-cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--trans), color var(--trans);
}
.tree-cat-btn:hover { background: var(--surface2); color: var(--text); }
.tree-cat-btn.active { color: var(--accent); }
.tree-cat-count { margin-left: auto; font-size: 10px; color: var(--text-muted); }

/* ── Gallery Main ── */
.gallery-main {
  flex: 1;
  padding: 20px;
  min-width: 0;
}

.status {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Section headers */
.section-header {
  grid-column: 1 / -1;
  padding: 12px 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

/* ── Category filter bar ── */
.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 16px;
}
.cat-filter.hidden { display: none; }

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  white-space: nowrap;
}
.cat-pill:hover { background: var(--surface); color: var(--text); }
.cat-pill.active { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
}

.photo-card {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.photo-card img.loaded { opacity: 1; }
.photo-card:hover img { transform: scale(1.04); }

.photo-card .card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--trans);
  display: flex;
  align-items: flex-end;
  padding: 8px;
  pointer-events: none;
}
.photo-card:hover .card-overlay { opacity: 1; }
.card-label {
  font-size: 11px;
  color: #fff;
  font-weight: 500;
  line-height: 1.3;
}

.card-guard {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Card spinner */
.card-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-spinner::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox.hidden { display: none; }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
}

.lb-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
}

.lb-breadcrumb {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-counter {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.lb-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans);
  flex-shrink: 0;
}
.lb-btn:hover { background: rgba(255,255,255,0.2); }
.lb-btn.hidden { display: none; }

.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 48px;
  height: 80px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans);
}
.lb-arrow:hover { background: rgba(255,255,255,0.2); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-img-wrap {
  position: relative;
  z-index: 1;
  max-width: calc(100vw - 140px);
  max-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-img {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  object-fit: contain;
  display: block;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.lb-img.loaded { opacity: 1; }

.lb-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-spinner::after {
  content: '';
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.lb-spinner.hidden { display: none; }

/* ── Fullscreen overlay ── */
.fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: #000;
  display: flex;
  flex-direction: column;
}
.fs-overlay.hidden { display: none; }

.fs-controls {
  position: absolute;
  top: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
}

.fs-zoom-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.fs-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans);
}
.fs-btn:hover { background: rgba(255,255,255,0.25); }

.fs-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
}
.fs-stage.grabbing { cursor: grabbing; }

.fs-transform {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  will-change: transform;
}

.fs-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.fs-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.fs-spinner::after {
  content: '';
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.fs-spinner.hidden { display: none; }

.fs-qr {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 100px;
  height: 100px;
  border-radius: 6px;
  opacity: 0.75;
  pointer-events: none;
}
.fs-qr.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }

  .gallery-main { padding: 12px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px; }

  .lb-img-wrap { max-width: calc(100vw - 80px); }
  .lb-arrow { width: 36px; }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Order Modal ── */
.order-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.order-modal.hidden { display: none; }

.om-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
}

.om-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.om-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.om-close:hover { color: var(--text); }

.om-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.om-preview-wrap {
  width: 100%;
  aspect-ratio: 3/2;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.om-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Product type cards */
.om-products {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.om-product-card {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  transition: border-color var(--trans), color var(--trans);
}
.om-product-card:hover { border-color: var(--accent); color: var(--text); }
.om-product-card.active { border-color: var(--accent); color: var(--accent); }
.om-product-card .om-product-icon { font-size: 22px; display: block; margin-bottom: 4px; }

/* Size row */
.om-size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.om-size-row.hidden { display: none; }

.om-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.om-select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}

.om-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* Form */
.om-summary {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius);
}

.om-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.om-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
}
.om-input:focus { outline: none; border-color: var(--accent); }
.om-input::placeholder { color: var(--text-muted); }

.om-row { display: grid; grid-template-columns: 120px 1fr; gap: 8px; }

/* Buttons */
.om-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #111;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans);
}
.om-btn:hover { background: var(--accent-hover); }
.om-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.om-btn-outline {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.om-btn-outline:hover { background: var(--surface); }

.om-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Confirmation */
.om-confirm-icon {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #111;
  margin: 0 auto 16px;
}
.om-confirm-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
  white-space: pre-line;
}

/* Crop step */
.om-crop-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }

.om-crop-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.om-crop-wrap.grabbing { cursor: grabbing; }

#om-crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.om-dpi-badge {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #111;
  pointer-events: none;
  transition: background var(--trans);
}
.om-dpi-badge.dpi-ok     { background: #4caf50; }
.om-dpi-badge.dpi-good   { background: #8bc34a; }
.om-dpi-badge.dpi-warn   { background: #ffc107; }
.om-dpi-badge.dpi-low    { background: #ff7043; color: #fff; }
.om-dpi-badge.dpi-bad    { background: #f44336; color: #fff; }

.om-dpi-info {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 32px;
  line-height: 1.5;
}

.om-step.hidden { display: none; }

/* Watermark toggle */
.om-watermark-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  cursor: pointer;
}
.om-watermark-label { font-size: 12px; color: var(--text-muted); user-select: none; }
.om-toggle-track {
  position: relative;
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 10px;
  transition: background var(--trans);
  flex-shrink: 0;
}
.om-toggle-track input { position: absolute; opacity: 0; width: 0; height: 0; }
.om-toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--trans);
  pointer-events: none;
}
.om-toggle-track input:checked ~ .om-toggle-thumb { transform: translateX(16px); }
.om-toggle-track:has(input:checked) { background: var(--accent); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
