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

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f1c25;
  background: #f7f3f8;
}

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

img {
  max-width: 100%;
  display: block;
}

.site-header {
  background: #1f1c25;
  color: #f7f3f8;
  padding: 24px clamp(16px, 5vw, 48px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.brand {
  flex: 1 1 240px;
}

.brand h1 {
  font-size: 24px;
  margin: 0;
}

.brand p {
  margin: 6px 0 0;
  color: #d7cfe1;
  font-size: 14px;
}

.main-nav ul {
  display: flex;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: 0.2s ease;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  border-color: #a79ac6;
  background: rgba(255, 255, 255, 0.08);
}

.breadcrumbs {
  padding: 12px clamp(16px, 5vw, 48px);
  font-size: 14px;
  color: #4c3f63;
}

.breadcrumbs a {
  color: #4c3f63;
}

.breadcrumbs span {
  margin: 0 6px;
}

main {
  padding: 0 clamp(16px, 5vw, 48px) 80px;
}

.hero {
  background: #efe8f4;
  border-radius: 16px;
  padding: 28px;
  margin: 16px 0 32px;
  display: grid;
  gap: 20px;
}

.hero h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.hero p {
  margin: 0;
  color: #5c4d73;
}

.section-title {
  font-size: 22px;
  margin: 32px 0 12px;
}

.product-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.product-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 18px;
  flex: 1 1 240px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(31, 28, 37, 0.08);
}

.product-thumb {
  position: relative;
  border-radius: 12px;
  background: #f1edf6;
  overflow: hidden;
}

.catalog-nav,
.detail-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: rgba(31, 28, 37, 0.4);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.catalog-nav.prev,
.detail-nav.prev {
  left: 10px;
}

.catalog-nav.next,
.detail-nav.next {
  right: 10px;
}

.catalog-nav {
  opacity: 0;
  pointer-events: none;
}

.product-card:hover .catalog-nav {
  opacity: 1;
  pointer-events: auto;
}

.catalog-nav:hover,
.detail-nav:hover {
  background: rgba(31, 28, 37, 0.65);
}

.image-scroll a {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.image-scroll a.is-active img {
  opacity: 0.55;
}

.product-card h3 {
  margin: 0;
  font-size: 18px;
}

.price {
  font-weight: 600;
  color: #5c4d73;
}

.button {
  background: #6d50a8;
  color: #ffffff;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.button.secondary {
  background: #f1edf6;
  color: #3d314f;
}

.product-detail {
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  display: grid;
  gap: 24px;
  box-shadow: 0 12px 30px rgba(31, 28, 37, 0.08);
}

.product-media {
  display: grid;
  gap: 16px;
}

.image-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
}

.image-scroll a {
  flex: 0 0 auto;
  scroll-snap-align: start;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #ede7f2;
}

.image-scroll img {
  width: 160px;
  height: auto;
}

.detail-info h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

.detail-info p {
  margin: 0 0 16px;
  color: #5c4d73;
  line-height: 1.6;
}

.detail-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.cart-flyout {
  position: fixed;
  right: 0;
  top: 0;
  width: 56px;
  height: 100%;
  z-index: 50;
}

.cart-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cart-button {
  position: absolute;
  right: 0;
  top: 40%;
  background: #1f1c25;
  color: #ffffff;
  padding: 12px 10px;
  border-radius: 12px 0 0 12px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  cursor: pointer;
  font-size: 14px;
}

.cart-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: min(90vw, 320px);
  height: 100%;
  background: #ffffff;
  box-shadow: -10px 0 30px rgba(31, 28, 37, 0.18);
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.cart-panel h3 {
  margin: 0;
}

.cart-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid #ede7f2;
  padding-bottom: 12px;
}

.cart-item label {
  font-size: 14px;
  color: #4c3f63;
}

.cart-item input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d9cfe5;
}

.cart-actions {
  margin-top: auto;
  display: flex;
  gap: 12px;
}

.cart-backdrop {
  display: none;
}

.cart-flyout:hover .cart-panel,
.cart-toggle:checked ~ .cart-panel {
  transform: translateX(0);
}

.cart-flyout:hover .cart-backdrop,
.cart-toggle:checked ~ .cart-backdrop {
  opacity: 0;
  pointer-events: none;
}

.cart-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: #6d50a8;
  cursor: pointer;
  font-size: 14px;
}

.footer {
  background: #1f1c25;
  color: #d7cfe1;
  padding: 20px clamp(16px, 5vw, 48px);
  font-size: 14px;
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: 1.2fr 1fr;
  }

  .product-detail {
    grid-template-columns: 1.1fr 1fr;
  }
}

@media (hover: none) {
  .cart-flyout:hover .cart-panel,
  .cart-flyout:hover .cart-backdrop {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }
}

.button.small,
a.button.small {
  padding: 6px 10px;
  font-size: 13px;
}

a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-auth {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.site-auth-status {
  margin: 0;
  font-size: 14px;
  color: #d7cfe1;
}

.site-auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.form-message {
  min-height: 20px;
  margin: 0;
  font-size: 14px;
}

.form-message.error {
  color: #c62828;
}

.form-message.success {
  color: #2e7d32;
}

.auth-page main {
  min-height: calc(100vh - 220px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(100%, 420px);
  background: #ffffff;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(31, 28, 37, 0.12);
}

.auth-card h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.auth-card p {
  color: #5c4d73;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-help {
  margin: 0;
  font-size: 13px;
  color: #7b6e92;
}

.page-narrow {
  max-width: 960px;
  margin: 0 auto 80px;
}

.page-wide {
  max-width: 1080px;
  margin: 0 auto 80px;
}

.admin-layout {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

.admin-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(31, 28, 37, 0.08);
}

.admin-card h2 {
  margin-top: 0;
  font-size: 20px;
}

.admin-form {
  display: grid;
  gap: 12px 18px;
  align-items: flex-start;
}

.admin-form.products {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.admin-form.categories {
  grid-template-columns: repeat(auto-fit, minmax(200px, auto));
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 14px;
  color: #4c3f63;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d9cfe5;
  box-sizing: border-box;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field input[type="file"] {
  border-radius: 8px;
  border: 1px dashed #d9cfe5;
  padding: 6px 8px;
  background: #f7f3f8;
}

.field small {
  font-size: 12px;
  color: #7b6e92;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.required::after {
  content: " *";
  color: #e53935;
}

.admin-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-card th,
.admin-card td {
  padding: 8px 10px;
  border-bottom: 1px solid #ede7f2;
  text-align: left;
  vertical-align: top;
}

.admin-card th {
  font-weight: 600;
  color: #4c3f63;
}

.admin-card .table-description {
  line-height: 1.5;
  white-space: pre-line;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.thumb-preview {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #f1edf6;
}

.thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.col-id {
  width: 60px;
}

.col-thumb {
  width: 80px;
}

.col-price {
  width: 90px;
}

.col-actions {
  width: 170px;
}

.col-actions-narrow {
  width: 160px;
}

@media (max-width: 720px) {
  .site-auth {
    align-items: flex-start;
  }

  .site-auth-actions {
    justify-content: flex-start;
  }

  .auth-card {
    padding: 24px;
  }
}

