:root {
  --mm-blue: #1268f3;
  --mm-blue-2: #4fa8e9;
  --mm-ink: #0f1f3a;
  --mm-muted: #66758f;
  --mm-soft: #f5f9ff;
  --mm-line: #dce8f7;
  --mm-card: #ffffff;
  --mm-green: #16a163;
  --mm-orange: #ff8a3d;
  --mm-red: #ef4444;
  --mm-shadow: 0 18px 45px rgba(24, 64, 128, 0.09);
}

* {
  box-sizing: border-box;
}

body.materials-page {
  margin: 0;
  min-height: 100vh;
  color: var(--mm-ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(79, 168, 233, 0.16), transparent 28rem),
    radial-gradient(circle at 92% 10%, rgba(22, 104, 243, 0.10), transparent 22rem),
    #f7fbff;
}

.materials-page button,
.materials-page input,
.materials-page select,
.materials-page textarea {
  font: inherit;
}

.materials-page button {
  cursor: pointer;
}

.materials-app {
  width: min(1480px, calc(100% - 44px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.materials-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(250px, 480px) auto;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  padding: 0 4px 18px;
}

.materials-brand,
.materials-topnav,
.materials-top-actions,
.materials-chip,
.materials-card__meta,
.materials-rating,
.materials-icon-button,
.materials-pager,
.materials-post-action {
  display: inline-flex;
  align-items: center;
}

.materials-brand {
  gap: 9px;
  color: var(--mm-ink);
  font-weight: 900;
  text-decoration: none;
}

.materials-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 8px;
}

.materials-topnav {
  gap: 30px;
  justify-content: center;
}

.materials-topnav a {
  position: relative;
  color: #34445f;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.materials-topnav a.is-active {
  color: var(--mm-blue);
}

.materials-topnav a.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -21px;
  left: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--mm-blue);
}

.materials-top-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  height: 42px;
  border: 1px solid var(--mm-line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.materials-top-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 14px;
  color: var(--mm-ink);
  background: transparent;
}

.materials-top-search button,
.materials-top-actions a,
.materials-icon-button {
  border: 0;
  background: transparent;
  color: #576987;
}

.materials-top-search svg,
.materials-main-search svg,
.materials-top-actions svg,
.materials-icon-button svg,
.materials-empty svg,
.materials-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.materials-top-actions {
  gap: 13px;
}

.materials-top-actions a {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  text-decoration: none;
}

.materials-top-actions a:hover {
  background: #edf5ff;
  color: var(--mm-blue);
}

.materials-loading,
.materials-empty {
  display: grid;
  place-items: center;
  min-height: 360px;
  gap: 12px;
  color: var(--mm-muted);
  text-align: center;
}

.materials-loading span {
  width: 34px;
  height: 34px;
  border: 3px solid #dce8f7;
  border-top-color: var(--mm-blue);
  border-radius: 50%;
  animation: mm-spin 0.9s linear infinite;
}

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

.materials-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 580px);
  gap: 32px;
  min-height: 245px;
  padding: 44px 48px;
  border: 1px solid #e4effb;
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(112deg, rgba(229, 244, 255, 0.95), rgba(248, 252, 255, 0.82)),
    url("/assets/cta-pattern.svg") right center / auto 120% no-repeat,
    #fff;
  box-shadow: var(--mm-shadow);
}

.materials-hero h1,
.materials-detail-title h1,
.materials-page h2,
.materials-page h3,
.materials-page p {
  margin-top: 0;
}

.materials-hero h1 {
  max-width: 610px;
  margin-bottom: 14px;
  font-size: clamp(30px, 4.2vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.materials-mobile-break {
  display: none;
}

.materials-hero p {
  max-width: 680px;
  color: #536783;
  font-size: 16px;
  line-height: 1.55;
}

.materials-hero-actions,
.materials-filter-row,
.materials-detail-tags,
.materials-card__tags,
.materials-detail-actions,
.materials-author-row,
.materials-card__footer,
.materials-card__stats,
.materials-toolbar,
.materials-purchase-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.materials-button,
.materials-button-light,
.materials-button-ghost,
.materials-button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 800;
  text-decoration: none;
}

.materials-button {
  background: linear-gradient(135deg, var(--mm-blue), #005bee);
  color: #fff;
  box-shadow: 0 12px 24px rgba(18, 104, 243, 0.24);
}

.materials-button-light {
  border-color: #cfe0f5;
  background: #fff;
  color: var(--mm-blue);
}

.materials-button-ghost {
  background: #edf6ff;
  color: #33516f;
}

.materials-button-danger {
  background: #fff1f1;
  color: var(--mm-red);
}

.materials-search-panel {
  align-self: center;
  padding: 16px;
  border: 1px solid #d8e7f7;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(24, 64, 128, 0.08);
}

.materials-main-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  min-height: 54px;
  border: 1px solid #cfdeef;
  border-radius: 11px;
  background: #fff;
  overflow: hidden;
}

.materials-main-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 18px;
  color: var(--mm-ink);
}

.materials-main-search button {
  border: 0;
  background: var(--mm-blue);
  color: #fff;
}

.materials-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.materials-quick button,
.materials-chip {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #d7e6f7;
  border-radius: 999px;
  background: #fff;
  color: #5c6f8c;
  font-size: 12px;
  font-weight: 750;
}

.materials-filter-row {
  margin: 20px 0;
  padding: 12px;
  border: 1px solid var(--mm-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(24, 64, 128, 0.05);
}

.materials-filter-row select,
.materials-filter-row button,
.materials-sort select,
.materials-purchase-search input,
.materials-purchase-tabs button {
  min-height: 36px;
  border: 1px solid #cfdeef;
  border-radius: 8px;
  background: #fff;
  color: #33445f;
  font-size: 12px;
  font-weight: 750;
}

.materials-filter-row select {
  padding: 0 30px 0 10px;
}

.materials-filter-row .materials-button-light {
  min-height: 36px;
  margin-left: auto;
}

.materials-catalog-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.materials-sidebar,
.materials-panel,
.materials-card,
.materials-detail-card,
.materials-buy-card,
.materials-purchases-card {
  border: 1px solid var(--mm-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 32px rgba(24, 64, 128, 0.06);
}

.materials-sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
  padding: 16px;
}

.materials-sidebar h3,
.materials-panel h3,
.materials-feed-head h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.materials-side-list {
  display: grid;
  gap: 7px;
}

.materials-side-list button,
.materials-author-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #445874;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
}

.materials-side-list button:hover {
  background: #edf6ff;
  color: var(--mm-blue);
}

.materials-side-list small {
  color: #8696ad;
}

.materials-results-head,
.materials-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.materials-results-head h2 {
  margin: 0 0 3px;
  font-size: 22px;
}

.materials-results-head p {
  margin: 0;
  color: var(--mm-muted);
  font-size: 13px;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.materials-card {
  overflow: hidden;
  min-width: 0;
}

.materials-card__cover {
  position: relative;
  display: block;
  height: 168px;
  overflow: hidden;
  background: #eaf4ff;
}

.materials-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s ease;
}

.materials-card:hover .materials-card__cover img {
  transform: scale(1.035);
}

.materials-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--mm-blue);
  font-size: 11px;
  font-weight: 900;
}

.materials-favorite {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #ff3157;
}

.materials-card__body {
  padding: 14px;
}

.materials-card__meta {
  gap: 7px;
  color: var(--mm-muted);
  font-size: 11px;
  font-weight: 750;
}

.materials-card h3 {
  min-height: 44px;
  margin: 8px 0;
  color: var(--mm-ink);
  font-size: 16px;
  line-height: 1.35;
}

.materials-card h3 a {
  color: inherit;
  text-decoration: none;
}

.materials-card p {
  display: -webkit-box;
  min-height: 54px;
  margin: 0 0 12px;
  overflow: hidden;
  color: #536783;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.materials-card__tags {
  gap: 6px;
  min-height: 28px;
}

.materials-card__tags span,
.materials-detail-tags span,
.materials-status {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf5ff;
  color: #33516f;
  font-size: 11px;
  font-weight: 800;
}

.materials-rating {
  gap: 5px;
  color: #f5ad00;
  font-weight: 900;
}

.materials-card__stats {
  justify-content: space-between;
  gap: 8px;
  margin: 13px 0;
  color: #65758f;
  font-size: 12px;
}

.materials-card__price {
  color: var(--mm-ink);
  font-size: 18px;
  font-weight: 900;
}

.materials-card__footer {
  justify-content: space-between;
}

.materials-author-mini {
  justify-content: flex-start;
}

.materials-author-mini img,
.materials-author-row img,
.materials-review img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.materials-panel {
  margin-top: 18px;
  padding: 16px;
}

.materials-category-pills {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.materials-category-pills button {
  min-height: 62px;
  border: 1px solid #d8e7f7;
  border-radius: 11px;
  background: linear-gradient(135deg, #fff, #edf6ff);
  color: #2c405c;
  font-weight: 850;
}

.materials-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
}

.materials-breadcrumbs {
  display: flex;
  gap: 7px;
  margin: 10px 0 18px;
  color: #687b96;
  font-size: 12px;
  font-weight: 750;
}

.materials-breadcrumbs a {
  color: var(--mm-blue);
  text-decoration: none;
}

.materials-detail-card,
.materials-buy-card,
.materials-purchases-card {
  padding: 18px;
}

.materials-detail-hero {
  display: grid;
  grid-template-columns: 46% minmax(0, 1fr);
  gap: 22px;
}

.materials-gallery-main {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 13px;
  background: #eaf4ff;
}

.materials-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.materials-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.materials-thumbs img,
.materials-thumb-placeholder {
  width: 100%;
  aspect-ratio: 1.28 / 1;
  border-radius: 8px;
  object-fit: cover;
  background: #f2f7fe;
  border: 1px solid #dbe8f6;
}

.materials-detail-title h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

.materials-detail-title p {
  color: #516782;
  line-height: 1.55;
}

.materials-detail-tags {
  margin: 14px 0;
}

.materials-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.materials-info-grid div {
  padding: 12px;
  border: 1px solid #dce8f7;
  border-radius: 10px;
  background: #fbfdff;
}

.materials-info-grid span {
  display: block;
  color: var(--mm-muted);
  font-size: 11px;
}

.materials-info-grid b {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.materials-tabs {
  display: flex;
  gap: 18px;
  margin-top: 22px;
  border-bottom: 1px solid #dce8f7;
}

.materials-tabs button {
  padding: 12px 0;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #61718c;
  font-size: 13px;
  font-weight: 850;
}

.materials-tabs button.is-active {
  border-color: var(--mm-blue);
  color: var(--mm-blue);
}

.materials-tab-panel {
  padding-top: 20px;
}

.materials-tab-panel p,
.materials-tab-panel li {
  color: #3f506c;
  line-height: 1.65;
}

.materials-tab-panel ul {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}

.materials-buy-card {
  position: sticky;
  top: 16px;
}

.materials-price {
  display: block;
  margin-bottom: 14px;
  font-size: 27px;
  font-weight: 900;
}

.materials-buy-card .materials-button,
.materials-buy-card .materials-button-light {
  width: 100%;
  margin-bottom: 9px;
}

.materials-license-note {
  margin: 10px 0 0;
  color: var(--mm-muted);
  font-size: 12px;
  line-height: 1.45;
}

.materials-author-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #f4f9ff;
}

.materials-author-row {
  gap: 10px;
}

.materials-author-row strong,
.materials-review strong {
  display: block;
}

.materials-author-row span,
.materials-review span {
  color: var(--mm-muted);
  font-size: 12px;
}

.materials-review-list {
  display: grid;
  gap: 12px;
}

.materials-review {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 13px;
  border: 1px solid #dce8f7;
  border-radius: 12px;
  background: #fff;
}

.materials-purchases-card {
  padding: 22px;
}

.materials-purchases-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.materials-purchases-head h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.materials-purchases-head p {
  margin: 0;
  color: var(--mm-muted);
}

.materials-purchase-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.materials-purchase-tabs button {
  padding: 0 12px;
}

.materials-purchase-tabs button.is-active {
  border-color: var(--mm-blue);
  background: #edf6ff;
  color: var(--mm-blue);
}

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

.materials-purchase-table th,
.materials-purchase-table td {
  padding: 13px 12px;
  border-bottom: 1px solid #e4edf7;
  color: #23364f;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.materials-purchase-table th {
  color: #65758f;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.materials-purchase-title {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 280px;
}

.materials-purchase-title img {
  width: 54px;
  height: 54px;
  border-radius: 9px;
  object-fit: cover;
}

.materials-purchase-title strong {
  display: block;
}

.materials-purchase-title span {
  color: var(--mm-muted);
  font-size: 12px;
}

.materials-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #13233d;
  color: #fff;
  box-shadow: 0 18px 44px rgba(15, 31, 58, 0.22);
}

.materials-toast.is-error {
  background: #b42318;
}

@media (max-width: 1180px) {
  .materials-topbar {
    grid-template-columns: auto 1fr auto;
  }

  .materials-top-search {
    grid-column: 1 / -1;
    order: 4;
  }

  .materials-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .materials-category-pills {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 940px) {
  .materials-app {
    width: min(100% - 24px, 760px);
  }

  .materials-topbar,
  .materials-hero,
  .materials-catalog-grid,
  .materials-detail-grid,
  .materials-detail-hero {
    grid-template-columns: 1fr;
  }

  .materials-topbar > *,
  .materials-hero > *,
  .materials-search-panel {
    min-width: 0;
  }

  .materials-topnav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .materials-sidebar,
  .materials-buy-card {
    position: static;
  }

  .materials-hero {
    min-height: 0;
    padding: 28px;
  }

  .materials-filter-row .materials-button-light {
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  body.materials-page {
    overflow-x: hidden;
  }

  .materials-app {
    width: calc(100% - 16px);
    max-width: 560px;
    overflow: hidden;
    padding-top: 12px;
  }

  .materials-topbar {
    gap: 12px;
  }

  .materials-topnav {
    grid-column: 1 / -1;
    order: 3;
    gap: 18px;
  }

  .materials-hero {
    padding: 28px 16px;
  }

  .materials-hero h1 {
    max-width: 100%;
    font-size: 25px;
    line-height: 1.12;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .materials-mobile-break {
    display: inline;
  }

  .materials-hero p {
    max-width: 318px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .materials-hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .materials-search-panel {
    width: 100%;
    padding: 14px;
  }

  .materials-main-search {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .materials-quick {
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .materials-quick button {
    flex: 0 0 auto;
  }

  .materials-grid,
  .materials-category-pills,
  .materials-info-grid {
    grid-template-columns: 1fr;
  }

  .materials-results-head,
  .materials-purchases-head {
    display: grid;
  }

  .materials-filter-row {
    display: grid;
  }

  .materials-filter-row select,
  .materials-filter-row button,
  .materials-button,
  .materials-button-light {
    width: 100%;
  }

  .materials-purchase-table,
  .materials-purchase-table tbody,
  .materials-purchase-table tr,
  .materials-purchase-table td {
    display: block;
    width: 100%;
  }

  .materials-purchase-table thead {
    display: none;
  }

  .materials-purchase-table tr {
    padding: 12px 0;
    border-bottom: 1px solid #e4edf7;
  }

  .materials-purchase-table td {
    border: 0;
    padding: 7px 0;
  }
}
