/* ========================= */
/* 🔥 색상 변수 (맨 위 추가) */
/* ========================= */
:root {
  --primary: #FF7A00;
  --primary-hover: #E66A00;

  --bg: #dfdfdf;
  --sub-bg: #FFF4E6;

  --text: #222222;
  --sub-text: #777777;

  --border: #E9ECEF;
}

/* 버튼 영역 */
.top-buttons {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;

  text-align: center;
  display: block;
  margin: 10px;
}

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

.history-bottom button {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--border);

  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;

  transition: 0.2s;
}

.history-bottom button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.top-buttons button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
}

.top-buttons button:hover {
  background: var(--primary-hover);
}

.title {
  text-align: center;
  color: var(--text);
}

/* 전체 배경 */
body {
  background: #f1f1f1;
  margin: 0;
  align-items: center;
  display: flex;
  justify-content: center;
}

.container {
  align-self: center;
  background: #f1f1f1;
  border-radius: 30px; /* 🔥 추가 */
  padding: 30px;
  width: 80%;
  margin: 0 auto;
  margin-top: 60px;
}

/* 🔥 랜덤 버튼만 따로 처리 */
.top-buttons button:last-child {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--border);
}

.top-buttons button:last-child:hover {
  background: var(--primary);
  color: white;
}

/* ========================= */
/* 🔥 태그 버튼 UI */
/* ========================= */

.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 버튼 기본 */
.tag-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  border-radius: 20px;
  font-size: 12px;
  white-space: nowrap;
}

/* hover */
.tag-btn:hover {
  background: #FF922B;
  color: white;
}

/* 선택됨 */
.tag-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 선택된 태그 영역 */
#selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  justify-content: center;
}

/* 선택된 태그 */
.selected-tag {
  background: var(--primary);
  color: white;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
}

.selected-tag span {
  margin-left: 6px;
  font-weight: bold;
}

/* 전체 감싸는 영역 */
#selected-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 30px;
  margin-bottom: 25px ;
}

/* 초기화 버튼 */
#clear-tags {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  border-radius: 20px;
  font-size: 12px;
}

#clear-tags:hover {
  background: var(--primary);
  color: white;
}

/* ========================= */
/* 필터 영역 */
/* ========================= */

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;

  width: 95%;
  margin: 0 auto;
}

.filter-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;

}

/* 제목 */
.filter-box h3 {
  grid-column: 1 / -1;
  color: var(--text);
}

/* ========================= */
/* 탭 영역 */
/* ========================= */

.tab-container {
  background-color: #FFFFFF;
  width: 90%;
  height: calc(100vh - 300px);
  margin: 20px auto;

  display: flex;
  flex-direction: column;
}

.tab-buttons {
  display: flex;
  border-bottom: 2px solid var(--border);
}

.tab-buttons button {
  flex: 1;
  padding: 10px;
  background: #eee;
  border: none;
}

.tab-buttons button.active {
  background: white;
  border-top: 2px solid black;
}

.tab-content {
  height: 60vh;
  max-height: 600px;
  min-height: 300px;
  overflow: hidden;
}

.tab {
  display: none;
  height: 100%;
}

.tab.active {
  display: block;
}

#list {
  display: none;
  height: 100%;
  overflow-y: auto;
}

#list.active {
  display: block;
}

/* ========================= */
/* 결과 카드 */
/* ========================= */

#result {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 10px;
  padding-bottom: 40px;
}

/* 반응형 */
@media (max-width: 480px) {
  #result {
    grid-template-columns: repeat(2, 1fr);
  }

  .container {
    max-width: 600px;
    
    margin: 0 auto;
    margin-top: 60px;
    padding: 20px;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 95%;
    margin: 0 auto;
  }

  .filter-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-box label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
  }

  .tab-content {
    height: 75vh;
    width: 100%;
  }

  .tab-container {
    width: 95%;
    margin: 20px auto;
  }
}

@media (min-width: 481px) and (max-width: 899px) {
  #result {
    grid-template-columns: repeat(3, 1fr);
  }

  .filters {
    grid-template-columns: 1fr 1fr;
    width: 90%;
    margin: 0 auto;
    gap: 15px;
  }

  .filter-box label {
    font-size: 13px;
  }

  .tab-container {
    width: 90%;
    margin: 20px auto;
  }

  .tab-content {
    height: 70vh;
  }
}

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

  .filters {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }
}

/* 메시지 */
#message {
  text-align: center;
  margin: 10px 0;
  font-weight: bold;
}

/* ========================= */
/* 히스토리 */
/* ========================= */

.history-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

#historyTab {
  display: none;
  flex-direction: column;
  height: 100%;
}

#historyTab.active {
  display: flex;
}

#history {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0;
}

.history-bottom {
  padding: 10px;
  border-top: 1px solid var(--border);
  background: white;
  display: flex;
  justify-content: center;
}

/* ========================= */
/* 카드 */
/* ========================= */

.card {
  width: 100%;
  border: 1px solid var(--border);
  background: white;
  border-radius: 10px;
  overflow: hidden;
  transition: 0.2s;
  align-items: center; 
}

.card:hover {
  transform: translateY(-5px);
}

/* 내용 */
.card-body {
  padding: 6px;
}

.card-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--text);
}

.card-reason {
  font-size: 12px;
  color: var(--sub-text);
  margin-top: 5px;
}

/* 이미지 */
.card-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #ddd;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1 / 1;
}


#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 16px;
  border-radius: 20px;

  opacity: 0;
  transition: 0.3s;
  pointer-events: none;

  z-index: 9999;  /* 🔥 핵심 */
}