/* ========== 基本リセット ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #f5f0eb;
  color: #333;
  font-family: "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ========== ラッパー（広告と分離） ========== */
.app-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 20px;
}

/* ========== ステージ ========== */
.stage {
  position: relative;
  width: 500px;
  flex-shrink: 0;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  /* src空のとき壊れアイコン非表示 */
  display: block;
}

/* src が空の img を非表示にする */
.layer[src=""],
.layer:not([src]) {
  visibility: hidden;
}

/* baseだけは常に表示 & サイズ確保用 */
.stage > .layer:first-child {
  position: relative;
  visibility: visible;
}

/* ========== 操作パネル ========== */
.panel {
  width: 400px;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 0.1em;
}

/* ========== ALL RESET ========== */
.btn-reset {
  background: #c44;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.btn-reset:hover {
  background: #a33;
}

/* ========== タブ (male / female) ========== */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  padding: 8px 0;
  border: 2px solid #888;
  background: #fff;
  color: #888;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.tab.active {
  background: #555;
  color: #fff;
  border-color: #555;
}

/* ========== カテゴリバー ========== */
.category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.cat-btn {
  padding: 6px 12px;
  border: 1px solid #bbb;
  background: #fff;
  color: #666;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.cat-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* ========== サムネグリッド ========== */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.thumb-item {
  position: relative;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s, opacity 0.15s;
  background: #e8e3dd;
}

.thumb-item img {
  width: 100%;
  display: block;
}

.thumb-item:hover {
  opacity: 0.8;
}

/* 選択中のサムネ */
.thumb-item.selected {
  border-color: #e06030;
}

/* 選択中マーク */
.thumb-item.selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  background: #e06030;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
}

/* ========== レスポンシブ ========== */
@media (max-width: 960px) {
  .app-wrapper {
    flex-direction: column;
    align-items: center;
  }
  .stage {
    width: 90vw;
    max-width: 500px;
  }
  .panel {
    width: 90vw;
    max-width: 500px;
  }
}
