:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --text: #20201e;
  --muted: #696761;
  --line: #ddd8cf;
  --accent: #2f5d50;
  --accent-soft: #e6eee9;
  --gold: #9a6a32;
  --shadow: 0 16px 40px rgba(31, 29, 25, 0.08);
  --sidebar-width: 286px;
  --detail-width: 600px;
  --tray-height: 0px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Malgun Gothic", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

body.is-resizing-detail {
  cursor: ew-resize;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button,
.card__actions a,
.detail__links a,
.cart-card__actions a {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  border-radius: 7px;
  text-decoration: none;
}

button:hover,
.card__actions a:hover,
.detail__links a:hover,
.cart-card__actions a:hover {
  border-color: var(--accent);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 24px 20px calc(var(--tray-height) + 28px);
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
  overflow-y: auto;
}

.brand {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.brand__name {
  font-size: 20px;
  font-weight: 800;
}

.brand__meta,
.toolbar p,
.field span,
.stats span,
.card__topline,
.detail__meta,
.score-note span,
.cart-drawer span,
.score-type__head span,
.score-category p,
.card__meta-line span {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 7px;
}

.filters {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.filter {
  text-align: left;
  padding: 8px 10px;
}

.filter.is-active,
.view-toggle.is-active,
.rank-sort.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats div,
.score-note {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  border-radius: 7px;
}

.stats strong {
  display: block;
  font-size: 25px;
}

.score-note {
  margin-top: 14px;
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.main {
  margin-left: var(--sidebar-width);
  margin-right: var(--detail-width);
  min-height: 100vh;
  padding: 26px 28px calc(var(--tray-height) + 34px);
}

.toolbar {
  position: relative;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 20px;
  background: var(--bg);
}

.toolbar h1 {
  margin: 0 0 5px;
  font-size: 26px;
}

.toolbar p {
  margin: 0;
}

.toolbar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar__actions button {
  padding: 0 12px;
}

.rank-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 18px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.rank-controls button {
  padding: 0 14px;
  min-width: 110px;
}

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

.card,
.score-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.card {
  overflow: hidden;
  display: grid;
  align-content: start;
  position: relative;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 420px 620px;
}

.card.is-selected,
.score-table tr.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 93, 80, 0.28), var(--shadow);
}

.card.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  z-index: 4;
}

.card.is-selected .thumb {
  filter: saturate(0.9) brightness(0.82);
}

.selected-ribbon {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(32, 32, 30, 0.22);
}

.card.is-selected .card__actions button[data-action="select"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #e7e2d9;
  object-fit: cover;
  display: block;
}

.load-more {
  grid-column: 1 / -1;
  min-height: 46px;
  background: var(--text);
  border-color: var(--text);
  color: white;
  font-weight: 800;
}

.card__body {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.card__topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.rank-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  border-radius: 999px;
  background: #f1eadf;
  color: var(--gold);
  font-weight: 800;
}

.card__title {
  font-size: 14px;
  font-weight: 800;
  min-height: 40px;
}

.variant-dots {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 30px;
}

.variant-dot {
  width: 27px;
  height: 27px;
  min-height: 0;
  border-radius: 50%;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--swatch, #ddd);
}

.variant-dot.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--text);
}

.variant-dots span {
  color: var(--muted);
  font-size: 12px;
}

.card__meta-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

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

.score-badges span,
.score-badges strong {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 3px 5px;
  font-size: 12px;
  background: #f1eee7;
  color: var(--text);
  white-space: nowrap;
}

.score-badges strong {
  background: var(--accent-soft);
  color: var(--accent);
}

.muted-score {
  grid-template-columns: 1fr;
}

.card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.card__actions button,
.card__actions a,
.cart-card__actions button,
.cart-card__actions a {
  min-height: 34px;
  padding: 7px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.detail {
  position: fixed;
  inset: 0 0 0 auto;
  width: var(--detail-width);
  border-left: 1px solid var(--line);
  background: var(--panel-soft);
  overflow-y: auto;
  padding: 22px 24px calc(var(--tray-height) + 28px);
}

.detail-resize {
  position: fixed;
  top: 0;
  right: calc(var(--detail-width) - 4px);
  width: 8px;
  height: 100vh;
  cursor: ew-resize;
  z-index: 20;
}

.detail-resize:hover {
  background: rgba(47, 93, 80, 0.12);
}

.detail__inner {
  display: grid;
  gap: 14px;
}

.detail-hero {
  position: relative;
}

.detail-image-button {
  width: 100%;
  display: block;
  padding: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: zoom-in;
}

.detail-image-button:hover .detail__image {
  box-shadow: 0 0 0 3px rgba(32, 32, 30, 0.16);
}

.detail__image {
  width: 100%;
  max-height: 760px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #e7e2d9;
  border-radius: 8px;
  display: block;
}

.detail-rank {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(32, 32, 30, 0.8);
  color: white;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.image-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
}

.image-strip button {
  padding: 0;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
}

.image-strip button.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.image-strip img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.detail h2 {
  font-size: 24px;
  margin: 2px 0 5px;
}

.section {
  border-top: 1px solid var(--line);
  padding: 15px 0;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
}

.score-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.score-detail div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  padding: 11px 8px;
  text-align: center;
}

.score-detail strong {
  display: block;
  font-size: 24px;
}

.score-detail span {
  color: var(--muted);
  font-size: 12px;
}

.score-reason {
  color: var(--muted);
}

.size-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.size-list span {
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 42px;
  text-align: center;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 13px;
}

.detail__links {
  position: sticky;
  bottom: calc(var(--tray-height) + 10px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 4px;
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: blur(10px);
  padding-top: 10px;
}

.detail-variants {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-variants button {
  width: 70px;
  min-height: 70px;
  padding: 4px;
  display: grid;
  gap: 4px;
  justify-items: center;
}

.detail-variants button.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.detail-variants i {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--swatch, #ddd);
  border: 1px solid var(--line);
  display: block;
}

.detail-variants span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.detail__links a,
.detail__links button {
  padding: 10px 12px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-link {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: white !important;
}

.empty-panel {
  color: var(--muted);
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.cart-toggle {
  position: static;
  z-index: 1;
  min-height: 42px;
  padding: 0 14px;
  background: var(--panel);
}

.cart-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  margin-left: 4px;
  background: var(--text);
  color: white;
  font-size: 12px;
}

.cart-toggle.has-items {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.cart-toggle.has-items span {
  background: white;
  color: var(--accent);
}

.cart-drawer {
  position: fixed;
  top: 68px;
  right: calc(var(--detail-width) + 18px);
  width: min(420px, calc(100vw - var(--sidebar-width) - var(--detail-width) - 48px));
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  z-index: 30;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.cart-drawer header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.cart-drawer strong,
.cart-drawer span {
  display: block;
}

.cart-stats {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.cart-items {
  display: grid;
  gap: 10px;
}

.cart-card {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--panel-soft);
}

.cart-card img {
  width: 74px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 5px;
}

.cart-card strong,
.cart-card span {
  display: block;
}

.cart-card strong {
  font-size: 13px;
  margin-bottom: 3px;
}

.cart-card span {
  color: var(--muted);
  font-size: 12px;
}

.cart-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 26px;
  background: rgba(16, 16, 15, 0.88);
}

.image-modal img {
  max-width: min(96vw, 1800px);
  max-height: 94vh;
  object-fit: contain;
  background: #f7f5f0;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.image-modal__close {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 101;
  min-width: 72px;
  background: white;
}

.score-page {
  display: grid;
  gap: 22px;
}

.ranking-board,
.score-type,
.score-category {
  display: grid;
  gap: 12px;
}

.score-type {
  margin-top: 8px;
}

.score-type__head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.score-type__head h2 {
  margin: 0;
  font-size: 22px;
}

.score-category h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.score-category p {
  margin: 0;
}

.score-table-wrap {
  overflow-x: auto;
}

.score-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 12px;
}

.score-table th,
.score-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.score-table th {
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.score-table th .table-sort {
  border: 0;
  background: transparent;
  min-height: 0;
  padding: 0;
  color: inherit;
  font-weight: 800;
}

.score-table th .table-sort:hover {
  color: var(--accent);
}

.score-table td:nth-child(1),
.score-table td:nth-last-child(4),
.score-table td:nth-last-child(3),
.score-table td:nth-last-child(2) {
  width: 58px;
  text-align: center;
}

.score-table td:nth-child(3),
.score-table td:nth-child(4) {
  white-space: nowrap;
}

.score-table tr:last-child td {
  border-bottom: 0;
}

.score-product {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(190px, 1fr);
  gap: 9px;
  align-items: center;
  text-align: left;
}

.score-product img {
  width: 48px;
  height: 64px;
  object-fit: cover;
  background: #e7e2d9;
  border-radius: 5px;
}

@media (min-width: 1700px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 1280px) {
  :root {
    --detail-width: 460px;
  }
}

@media (max-width: 1120px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
  }

  .main {
    margin: 0;
    padding-bottom: 360px;
  }

  .detail {
    position: fixed;
    inset: auto 0 var(--tray-height) 0;
    width: auto;
    height: 280px;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px;
  }

  .detail-resize {
    display: none;
  }

  .detail__inner {
    grid-template-columns: 140px 1fr;
    align-items: start;
  }

  .detail__image {
    height: 210px;
  }

  .image-strip,
  .detail__links {
    grid-column: 1 / -1;
  }

  .cart-drawer {
    right: 14px;
    left: 14px;
    width: auto;
  }
}

@media (max-width: 700px) {
  .toolbar {
    display: grid;
  }

  .toolbar__actions {
    justify-content: start;
  }

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

  .card__actions,
  .detail__links {
    grid-template-columns: 1fr;
  }

}
