/* Closet UI v1.7.9. Paper chrome, readable slot photos. */
:root {
  --bg: #f7f5f2;
  --bg-alt: #ffffff;
  --panel: #f0eeea;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --hairline: #e0ddd6;
  --accent: #1d1d1f;
  --accent-soft: rgba(29, 29, 31, 0.12);
  --chip: #ffffff;
  --chip-hover: #eae7e1;
  --chip-selected-border: #1d1d1f;
  --placeholder: #e8e5df;
  --radius: 12px;
  --radius-sm: 9px;
  --pad: 16px;
  --gap: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --equip-pct: 28%;
  --inv-pct: 72%;
  --slot-w: 72px;
  --slot-w-side: 72px;
  --slot-w-torso: 72px;
  --figure-w: 42%;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

@media (min-width: 768px) {
  :root {
    --pad: 20px;
    --gap: 14px;
  }
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
}

#app[hidden] {
  display: none !important;
}

.view[hidden],
[hidden] {
  display: none !important;
}

.catalog-status {
  text-align: center;
  font-size: 13px;
  margin: 0 0 10px;
  padding: 8px 0;
  color: var(--muted);
}

.tools-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.tools-back:hover {
  color: var(--ink);
}

.tools-back span {
  font-size: 20px;
  line-height: 1;
  margin-top: -1px;
}

/* Phone tabs */
.phone-tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}

.phone-tab {
  appearance: none;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.phone-tab.is-active {
  color: var(--ink);
  background: var(--bg-alt);
  box-shadow: 0 0 0 1px var(--hairline);
}

@media (min-width: 960px) {
  .phone-tabs {
    display: none !important;
  }
}

/* Stage: Equipment | Inventory */
.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

@media (min-width: 960px) {
  .stage {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
    min-height: calc(100dvh - 80px);
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (min-width: 960px) {
  .panel-equipment {
    flex: 0 0 var(--equip-pct);
    max-width: var(--equip-pct);
    position: sticky;
    top: var(--pad);
    align-self: flex-start;
    max-height: calc(100dvh - var(--pad) * 2);
  }

  .panel-inventory {
    flex: 1 1 var(--inv-pct);
    min-width: 0;
    background: var(--bg-alt);
  }
}

@media (max-width: 959px) {
  .stage[data-active="inventory"] .panel-equipment {
    display: none;
  }
  .stage[data-active="equipment"] .panel-inventory {
    display: none;
  }
  .stage[data-active="equipment"] .panel-equipment,
  .stage[data-active="inventory"] .panel-inventory {
    display: flex;
  }
}

/* Title bars — thin paper (no crimson) */
.panel-titlebar {
  background: transparent;
  border-bottom: 1px solid var(--hairline);
  padding: 14px 16px 12px;
  flex-shrink: 0;
}

.panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.2;
}

.equipment-body,
.inventory-body {
  padding: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

@media (min-width: 960px) {
  .equipment-body {
    overflow-y: auto;
    max-height: calc(100dvh - var(--pad) * 2 - 48px);
  }
}

/* Equipment board: figure center + slot chips */
.equip-board {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  height: 752px;
  min-height: 752px;
  background: var(--bg-alt);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
}

.figure-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--figure-w);
  height: min(70%, 500px);
  z-index: 0;
  pointer-events: auto;
}

.figure-stage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.equip-slots {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.wear-slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  width: 72px;
  z-index: 1;
  pointer-events: auto;
}

.wear-slot-label {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  color: #1d1d1f;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.15;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  text-align: center;
  max-height: 2.4em;
  word-break: keep-all;
  hyphens: none;
}

.wear-slot-frame {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
}

.wear-slot-frame.is-empty {
  border: 1px dashed rgba(29, 29, 31, 0.45);
  background: rgba(255, 255, 255, 0.55);
}

.wear-slot-frame.is-filled {
  border: 1px solid var(--ink);
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.wear-slot-frame.is-filled img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  opacity: 1;
  pointer-events: none;
}

.wear-slot-frame .card-placeholder {
  font-size: 8px;
  padding: 4px;
}

/* Slot map v1.7.7 — side rails. L: Hat→Ear→Outer→Layering→Tops→Bottoms→Socks→Shoes; R: Scarf→Ear→Belt→Socks→Shoes */
.wear-slot[data-slot="Hat"] { left: 8px; top: 8px; }
.wear-slot[data-slot="Scarf"] { right: 8px; left: auto; top: 8px; }
.wear-slot[data-slot="Ear rings L"] { left: 8px; top: 100px; }
.wear-slot[data-slot="Ear rings R"] { right: 8px; left: auto; top: 100px; }
.wear-slot[data-slot="Outerwear"] { left: 8px; top: 192px; }
.wear-slot[data-slot="Layering"] { left: 8px; top: 284px; }
.wear-slot[data-slot="Outerwear"] .wear-slot-label,
.wear-slot[data-slot="Layering"] .wear-slot-label {
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.wear-slot[data-slot="Tops"] { left: 8px; top: 376px; }
.wear-slot[data-slot="Belt"] { right: 8px; left: auto; top: 284px; }
.wear-slot[data-slot="Bottoms"] { left: 8px; top: 468px; }
.wear-slot[data-slot="Socks L"] { left: 8px; top: 560px; }
.wear-slot[data-slot="Socks R"] { right: 8px; left: auto; top: 560px; }
.wear-slot[data-slot="Shoes L"] { left: 8px; top: 652px; }
.wear-slot[data-slot="Shoes R"] { right: 8px; left: auto; top: 652px; }


.wear-unequip {
  appearance: none;
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.82);
  color: #fff;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  padding: 0;
  z-index: 2;
}

.wear-unequip:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

@media (max-width: 959px) {
  .equip-board {
    max-width: 420px;
    height: 752px;
    min-height: 752px;
  }
}

.clear-all-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #1d1d1f;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 14px 0 4px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  display: block;
}

.clear-all-btn:hover {
  color: var(--ink);
}

/* Filters */
.filters {
  margin-bottom: 14px;
}

.filter-row-primary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.filter-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.filter-group-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
  flex-shrink: 0;
}

.filter-hint {
  font-size: 12px;
  font-weight: 500;
  color: #3a3a3e;
  letter-spacing: 0;
  text-transform: none;
  margin-right: 4px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--chip);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.chip:hover {
  background: var(--chip-hover);
}

.chip.is-selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.chip.is-selected:hover {
  background: #333336;
}

.chip:disabled,
.primary-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.chip:disabled:hover {
  background: var(--chip);
}

.primary-btn:disabled:hover {
  background: var(--ink);
}

.clear-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  padding: 8px 0;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

.clear-btn:hover {
  color: var(--ink);
}

.filter-more-wrap {
  margin-top: 10px;
}

.more-toggle {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  padding: 4px 0;
  cursor: pointer;
}

.more-toggle:hover,
.more-toggle[aria-expanded="true"] {
  color: var(--ink);
}

.filter-groups-more {
  margin-top: 10px;
}

/* Outfit bar */
.outfit-bar {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.outfit-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.outfit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.primary-btn {
  appearance: none;
  border: none;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.primary-btn:hover {
  background: #333336;
}

.outfit-hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: #3a3a3e;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

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

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

@media (min-width: 1280px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: block;
  width: 100%;
}

.card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.card.is-equipped .card-media {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.card-media {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--placeholder);
  border: 1px solid var(--hairline);
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  background: var(--placeholder);
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

.card-meta {
  padding: 8px 2px 0;
}

.card-brand {
  margin: 0;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-name {
  margin: 2px 0 0;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.empty p {
  margin: 0 0 12px;
  font-size: 15px;
}

.text-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

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

/* Detail overlay */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.detail-overlay[hidden] {
  display: none !important;
}

.detail-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 29, 31, 0.35);
}

.detail-overlay-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg-alt);
  border-left: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  padding: var(--pad);
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

@media (min-width: 640px) {
  .detail-overlay {
    align-items: center;
    padding: 24px;
  }
  .detail-overlay-panel {
    max-height: min(92dvh, 860px);
    border-radius: 14px;
    border: 1px solid var(--hairline);
  }
}

.detail-header {
  margin-bottom: 16px;
}

.back-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  padding: 4px 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.back-btn span {
  font-size: 20px;
  line-height: 1;
  margin-top: -1px;
}

.detail {
  max-width: 480px;
}

.detail-media {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--placeholder);
  border: 1px solid var(--hairline);
  width: auto;
  max-width: 100%;
  height: min(38vh, 380px);
  margin: 0 auto;
}

.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #fff;
}

.detail-body {
  padding: 16px 2px 0;
}

.detail-title {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
}

.detail-title .brand {
  color: var(--muted);
  font-weight: 400;
}

.detail-meta {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.detail-price {
  margin: 12px 0 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

.detail-note {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.45;
}

.detail-link {
  display: inline-block;
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Gate — paper */
.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  background: var(--bg);
}

.gate[hidden] {
  display: none !important;
}

.gate-form {
  width: 100%;
  max-width: 280px;
  text-align: center;
  background: var(--bg-alt);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 28px 22px;
}

.gate-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--ink);
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.gate-lede {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.4;
  color: #2c2c2e;
}

.gate-input {
  display: block;
  width: 100%;
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-align: center;
  outline: none;
}

.gate-input::placeholder {
  color: var(--muted);
}

.gate-input:focus {
  border-color: var(--ink);
}

.gate-enter {
  display: block;
  width: 100%;
  margin-top: 12px;
  appearance: none;
  border: none;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.gate-enter:hover {
  background: #333336;
}

.gate-error {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.gate-error[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #1d1d1f;
  color: #f7f5f2;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}