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

:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2c2416;
  --color-text-muted: #6b5d4d;
  --color-accent: #8b5a2b;
  --color-accent-hover: #6d4520;
  --color-border: #e8e0d4;
  --color-placeholder-start: #c4a882;
  --color-placeholder-end: #8b6f47;
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 1px 3px rgba(44, 36, 22, 0.08);
  --shadow-md: 0 4px 12px rgba(44, 36, 22, 0.1);
  --radius: 8px;
}

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* Header */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-logo:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.site-logo span {
  color: var(--color-accent);
}

/* Layout */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.catalog-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

/* Category tree */
.category-sidebar {
  width: 20%;
  min-width: 200px;
  flex-shrink: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.category-sidebar h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.category-tree {
  list-style: none;
}

.category-tree ul {
  list-style: none;
  padding-left: 1rem;
}

.category-tree li {
  margin: 0.15rem 0;
}

.category-tree button {
  background: none;
  border: none;
  font: inherit;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  text-align: left;
  width: 100%;
  transition: background 0.15s;
}

.category-tree button:hover {
  background: var(--color-bg);
}

.category-tree button.active {
  background: var(--color-accent);
  color: #fff;
}

.category-tree button.all-categories {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Product grid */
.catalog-main {
  flex: 1;
  min-width: 0;
}

.catalog-header {
  margin-bottom: 1.25rem;
}

.catalog-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.catalog-header p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}

.product-card__image {
  aspect-ratio: 1;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-placeholder-start), var(--color-placeholder-end));
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-card__info {
  padding: 0.85rem 1rem 1rem;
}

.product-card__name {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-accent);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

/* Product page */
.product-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.gallery {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
}

.gallery__main {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-placeholder-start), var(--color-placeholder-end));
  margin-bottom: 0.75rem;
}

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

.gallery__thumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery__arrow {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.gallery__arrow:hover:not(:disabled) {
  background: var(--color-bg);
}

.gallery__arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.gallery__thumbs-track {
  flex: 1;
  display: flex;
  gap: 0.5rem;
  overflow: hidden;
}

.gallery__thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(135deg, var(--color-placeholder-start), var(--color-placeholder-end));
  padding: 0;
}

.gallery__thumb.active {
  border-color: var(--color-accent);
}

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

.product-details h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.product-details__price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 1.25rem;
}

.product-details__section {
  margin-bottom: 1.5rem;
}

.product-details__section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
}

.product-details__description {
  color: var(--color-text);
  line-height: 1.65;
}

.characteristics-table {
  width: 100%;
  border-collapse: collapse;
}

.characteristics-table tr {
  border-bottom: 1px solid var(--color-border);
}

.characteristics-table td {
  padding: 0.5rem 0;
  font-size: 0.95rem;
}

.characteristics-table td:first-child {
  color: var(--color-text-muted);
  width: 40%;
}

.master-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.15s;
}

.master-link:hover {
  background: var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--color-text-muted);
}

.breadcrumb a:hover {
  color: var(--color-accent);
}

/* Master page */
.master-profile {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.master-profile__avatar {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-placeholder-start), var(--color-placeholder-end));
}

.master-profile__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.master-profile__info h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.master-profile__description {
  color: var(--color-text);
  line-height: 1.65;
}

.master-posts h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.post-card__date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.post-card__text {
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.post-card__image {
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 480px;
}

.post-card__image img {
  width: 100%;
  display: block;
}

.post-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.post-form h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.post-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.post-form input[type="file"] {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.post-form button {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.post-form button:hover {
  background: var(--color-accent-hover);
}

.post-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.loading,
.error-message {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-muted);
}

.error-message {
  color: #b33;
}

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

@media (max-width: 900px) {
  .catalog-layout {
    flex-direction: column;
  }

  .category-sidebar {
    width: 100%;
    position: static;
  }

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

  .master-profile {
    grid-template-columns: 1fr;
  }

  .master-profile__avatar {
    max-width: 200px;
  }
}

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

  .page-container {
    padding: 1rem;
  }
}
