:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-soft: #eee8dc;
  --surface-strong: #ffffff;
  --text: #151515;
  --muted: #716b61;
  --line: rgba(31, 31, 31, .12);
  --accent: #0f6a67;
  --accent-dark: #083f42;
  --gold: #d3b45d;
  --danger: #a63838;
  --radius: 26px;
  --radius-sm: 16px;
  --shadow: 0 22px 60px rgba(23, 19, 12, .08);
  --shadow-soft: 0 10px 30px rgba(23, 19, 12, .06);
}

html[data-theme="dark"] {
  --bg: #171714;
  --surface: #20201c;
  --surface-soft: #2a2a25;
  --surface-strong: #24241f;
  --text: #f7f3ea;
  --muted: #b8b0a2;
  --line: rgba(255, 255, 255, .10);
  --accent: #64c8c2;
  --accent-dark: #0f6a67;
  --gold: #dfc46c;
  --danger: #d06565;
  --shadow: 0 24px 70px rgba(0, 0, 0, .30);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, .22);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 12%, transparent), transparent 32rem),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  transition: background .2s ease, color .2s ease;
}

img { max-width: 100%; display: block; }
img[data-theme-icon] {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  object-fit: contain !important;
  flex: 0 0 22px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(20px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 850;
  letter-spacing: -.035em;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: .93rem;
  font-weight: 720;
}

.site-nav a { transition: color .15s ease; }
.site-nav a:hover { color: var(--text); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.theme-toggle:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.theme-toggle img { width: 22px; height: 22px; object-fit: contain; }
html[data-theme="dark"] .theme-toggle img { filter: invert(1); }

.page {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 58px;
  flex: 1 0 auto;
}
.narrow { max-width: 520px; }
.narrow-form { max-width: 880px; }

.hero-minimal {
  border: 1px solid var(--line);
  border-radius: 30px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.hero-minimal img {
  width: 100%;
  height: clamp(150px, 24vw, 245px);
  object-fit: cover;
}

.catalog-heading,
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 38px 0 18px;
}
.eyebrow {
  margin: 0 0 7px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .73rem;
  font-weight: 900;
  color: var(--accent);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(2.15rem, 5vw, 4rem); line-height: .95; letter-spacing: -.075em; }
h2 { margin-bottom: 5px; font-size: 1.05rem; letter-spacing: -.025em; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.catalog-heading .muted { max-width: 620px; margin-bottom: 0; }
.catalog-controls { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.catalog-count {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  font-size: .9rem;
  font-weight: 760;
}

.button,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--accent-dark);
  border-radius: 999px;
  background: var(--accent-dark);
  color: white;
  cursor: pointer;
  font-weight: 820;
  transition: transform .15s ease, opacity .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover,
.filter-button:hover { transform: translateY(-1px); }
.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.button.ghost:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.button.danger { background: var(--danger); border-color: var(--danger); }
.button.wide { width: 100%; }
.filter-button::before { content: none; }
.filter-button {
  gap: 8px;
  padding-inline: 18px;
}
.filter-button[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent-dark) 86%, white);
}

.filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 12px;
  margin: 6px 0 24px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.filters[hidden] { display: none; }

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 760;
  font-size: .84rem;
}
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
input:focus,
select:focus,
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 20px;
}
.product-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--shadow);
}
.product-card[hidden] { display: none; }
.product-image {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface-soft);
  aspect-ratio: 4 / 5;
}
.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .28s ease;
}
.product-card:hover .product-image img { transform: scale(1.035); }
.price-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: rgba(10, 14, 14, .72);
  color: #fff;
  backdrop-filter: blur(10px);
  font-size: .86rem;
  font-weight: 850;
}
.product-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 15px;
}
.product-info h2 {
  min-height: 2.42em;
  display: flex;
  align-items: flex-start;
}
.product-info h2 a:hover { color: var(--accent); }
.product-meta { margin-bottom: 7px; color: var(--accent); font-size: .78rem; font-weight: 900; letter-spacing: .02em; }
.product-type {
  min-height: 2.8em;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .93rem;
}
.sizes-block {
  min-height: 76px;
  margin: auto 0 15px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sizes-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
.size-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.size-row span {
  display: inline-flex;
  min-width: 33px;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: .76rem;
  font-weight: 850;
}
.size-row span.off { opacity: .34; text-decoration: line-through; }
.card-bottom { display: grid; gap: 12px; margin-top: 16px; }
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.card-actions .button { flex: 1; min-height: 38px; padding: 8px 12px; font-size: .88rem; }
.empty {
  grid-column: 1 / -1;
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.back-link { display: inline-flex; margin-bottom: 18px; color: var(--muted); font-weight: 760; }
.detail-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 28px; align-items: start; }
.gallery,
.detail-panel,
.admin-card,
.product-form,
.admin-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-soft);
}
.gallery { overflow: hidden; }
.main-photo { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--surface-soft); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; }
.thumbs img { aspect-ratio: 1 / 1; object-fit: cover; border-radius: 14px; }
.detail-panel { display: grid; gap: 16px; padding: 24px; }
.price-large { margin: 0; font-size: 1.55rem; font-weight: 920; letter-spacing: -.045em; }
.option-list { display: grid; gap: 8px; }
.check-line { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; }
.check-line input { width: auto; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.total-row strong { font-size: 1.35rem; }

.site-footer {
  width: 100%;
  margin-top: auto;
  padding: 22px max(18px, calc((100vw - 1180px) / 2)) 30px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: .9rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.alert { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }

.admin-card,
.product-form { padding: 20px; display: grid; gap: 18px; }
.admin-actions { display: flex; gap: 10px; align-items: center; }
.admin-actions form { margin: 0; }
.admin-list { display: grid; gap: 12px; padding-bottom: 28px; }
.admin-row { display: grid; grid-template-columns: 88px 1fr auto; gap: 16px; align-items: center; padding: 12px; }
.admin-row img { width: 88px; height: 88px; object-fit: cover; border-radius: 16px; background: var(--surface-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row-actions form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 0; }
legend { padding: 0 6px; font-weight: 850; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.checkbox-grid input { width: auto; }
.current-images { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.current-images label { gap: 8px; }
.current-images img { aspect-ratio: 1 / 1; object-fit: cover; border-radius: 16px; background: var(--surface-soft); }
.image-card { position: relative; display: grid; gap: 8px; transition: opacity .18s ease, transform .18s ease; }
.image-card.removing { opacity: .62; }
.image-card.removed { opacity: 0; transform: scale(.96); }
.image-delete { min-height: 36px; border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--line)); border-radius: 999px; background: transparent; color: var(--danger); cursor: pointer; font-weight: 800; }
.image-delete:disabled { cursor: wait; opacity: .72; }
.image-status { min-height: 18px; color: var(--muted); font-size: .8rem; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: min(320px, calc(100% - 36px)); padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 750; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .admin-row { grid-template-columns: 72px 1fr; }
  .admin-row img { width: 72px; height: 72px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 640px) {
  .site-header { align-items: flex-start; flex-direction: column; padding: 14px 18px; gap: 12px; }
  .site-nav { width: 100%; flex-wrap: wrap; gap: 13px; font-size: .95rem; }
  .site-nav .theme-toggle { margin-left: auto; }
  .theme-toggle { width: 40px; height: 40px; }
  .page { width: min(100% - 28px, 1180px); padding-top: 18px; }
  .hero-minimal { border-radius: 22px; }
  .hero-minimal img { height: 134px; }
  .catalog-heading, .admin-top { align-items: flex-start; flex-direction: column; padding: 30px 0 16px; }
  .catalog-controls { width: 100%; justify-content: space-between; }
  .filter-button { min-width: 126px; }
  .product-grid, .filters, .form-grid, .checkbox-grid, .current-images { grid-template-columns: 1fr; }
  .product-grid { gap: 16px; }
  .product-image { aspect-ratio: 4 / 4.65; }
  .card-actions { flex-direction: column; }
  .site-footer { flex-direction: column; padding-inline: 18px; }
  h1 { font-size: clamp(2.25rem, 12vw, 3.15rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
