/* 기본 컨테이너 */
.hex-rgb-converter {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  background: #f5f5f0;
  border: 2px solid #333;
  font-family: 'Noto Sans KR', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #222;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.15);
  box-sizing: border-box;
  line-height: 1.5;
}

.hex-rgb-converter * {
  box-sizing: border-box;
}

/* 헤더 */
.converter-header {
  text-align: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 3px double #333;
}

.converter-header h2 {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 700;
  color: #2c3e50;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 12px;
  color: #666;
  line-height: 1.4;
}

/* 빠른 액션 버튼 */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-random,
.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #333;
  font-size: 13px;
  font-weight: 600;
  color: #222;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-random:hover,
.btn-reset:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-random:active,
.btn-reset:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.btn-random:focus-visible,
.btn-reset:focus-visible {
  outline: 3px solid #e67e22;
  outline-offset: 2px;
}

.btn-random {
  background: #e67e22;
  color: #fff;
  border-color: #333;
}

/* 메인 그리드 */
.converter-main {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.input-section,
.preview-section,
.result-section {
  background: #fff;
  border: 1px solid #333;
  padding: 15px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
}

/* 섹션 타이틀 */
.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
  font-size: 15px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

.input-section .section-title {
  color: #3498db;
}

.preview-section .section-title {
  color: #9b59b6;
}

.result-section .section-title {
  color: #27ae60;
}

/* 입력 그룹 */
.input-group {
  margin-bottom: 10px;
}

.input-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  line-height: 1.2;
}

/* 컬러 피커 */
.color-picker-input {
  width: 100%;
  height: 50px;
  border: 1px solid #333;
  cursor: pointer;
  padding: 2px;
}

.color-picker-input:focus-visible {
  outline: 3px solid #e67e22;
  outline-offset: 2px;
}

/* 텍스트 입력 */
.text-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #333;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
}

.text-input:focus {
  outline: none;
  background: #fffacd;
  border-color: #e67e22;
}

.text-input.error {
  border-color: #e74c3c;
  background: #ffe6e6;
}

.text-input.warning {
  border-color: #f39c12;
  background: #fff8e6;
}

/* 입력 + 버튼 */
.input-with-btn {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-with-btn .text-input {
  flex: 1;
}

/* 작은 복사 버튼 */
.btn-copy-small {
  flex-shrink: 0;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-copy-small:hover {
  background: #f0f0f0;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-copy-small:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-copy-small:focus-visible {
  outline: 2px solid #e67e22;
  outline-offset: 2px;
}

/* 에러/경고 메시지 */
.error-message,
.alpha-warning {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  min-height: 14px;
}

.error-message {
  color: #e74c3c;
}

.alpha-warning {
  color: #f39c12;
}

/* 슬라이더 그룹 */
.slider-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 슬라이더 */
.color-slider {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: #ddd;
  border: 1px solid #333;
  outline: none;
  cursor: pointer;
}

.color-slider:focus-visible {
  outline: 2px solid #e67e22;
  outline-offset: 2px;
}

.color-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #e67e22;
  border: 2px solid #333;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.color-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #e67e22;
  border: 2px solid #333;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* 숫자 입력 */
.number-input {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid #333;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #222;
  text-align: center;
  font-family: 'Courier New', monospace;
}

.number-input:focus {
  outline: none;
  background: #fffacd;
  border-color: #e67e22;
}

/* 단위 + 입력 (개선됨) */
.input-with-unit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-unit .number-input {
  width: 60px;
}

.unit-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  min-width: 20px;
}

/* 미리보기 박스 */
.preview-box {
  position: relative;
  width: 100%;
  height: 250px;
  border: 2px solid #333;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: background-color 0.15s ease;
}

.preview-text-light,
.preview-text-dark {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.1);
  transition: opacity 0.3s;
}

.preview-text-light {
  color: #fff;
}

.preview-text-dark {
  color: #000;
}

/* 색상 정보 */
.color-info {
  padding: 10px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  margin-bottom: 10px;
}

.color-info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}

.color-info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-weight: 600;
  color: #555;
}

.info-value {
  font-weight: 700;
  color: #222;
}

/* 대비율 정보 */
.contrast-info {
  padding: 10px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  font-size: 11px;
}

.contrast-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #333;
  text-align: center;
}

.contrast-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  gap: 4px;
}

.contrast-item:last-child {
  margin-bottom: 0;
}

.contrast-label {
  font-weight: 600;
  color: #555;
  font-size: 11px;
}

.contrast-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contrast-value {
  font-weight: 700;
  color: #222;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.contrast-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid #333;
  background: #fff;
  color: #666;
  flex-shrink: 0;
}

.contrast-badge.pass-aaa {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
}

.contrast-badge.pass-aa {
  background: #f39c12;
  color: #fff;
  border-color: #f39c12;
}

.contrast-badge.fail {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

/* 결과 아이템 */
.result-item {
  margin-bottom: 10px;
}

.result-item:last-child {
  margin-bottom: 0;
}

.result-item label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  line-height: 1.2;
}

.result-value-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #f9f9f9;
  border: 1px solid #333;
}

.result-value {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: #222;
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.result-value-small {
  font-size: 11px;
}

/* 복사 버튼 */
.btn-copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #333;
  font-size: 11px;
  font-weight: 600;
  color: #222;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-copy:hover {
  background: #f0f0f0;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-copy:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-copy:focus-visible {
  outline: 2px solid #e67e22;
  outline-offset: 2px;
}

/* 색상 조화 & 히스토리 섹션 */
.harmony-section,
.history-section {
  background: #fff;
  border: 1px solid #333;
  padding: 15px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
  margin-bottom: 15px;
}

.harmony-section .section-title,
.history-section .section-title {
  color: #e67e22;
}

/* 색상 조화 그리드 */
.harmony-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.harmony-item {
  text-align: center;
}

.harmony-label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  line-height: 1.2;
}

.harmony-color {
  width: 100%;
  height: 60px;
  border: 2px solid #333;
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  background: transparent;
}

.harmony-color:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.3);
}

.harmony-color:focus-visible {
  outline: 3px solid #e67e22;
  outline-offset: 2px;
}

.harmony-color:active {
  transform: scale(0.98);
}

.harmony-value {
  font-size: 11px;
  font-weight: 700;
  color: #222;
  font-family: 'Courier New', monospace;
  line-height: 1.2;
}

/* 히스토리 헤더 */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-header .section-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* 히스토리 삭제 버튼 */
.btn-clear-history {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #333;
  font-size: 11px;
  font-weight: 600;
  color: #e74c3c;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-clear-history:hover {
  background: #ffe6e6;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-clear-history:focus-visible {
  outline: 2px solid #e67e22;
  outline-offset: 2px;
}

/* 히스토리 색상 그리드 */
.history-colors {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
}

.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  font-size: 13px;
  color: #999;
}

.history-color {
  width: 100%;
  height: 50px;
  border: 2px solid #333;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  padding: 0;
}

.history-color:hover {
  transform: scale(1.1);
  z-index: 10;
}

.history-color:focus-visible {
  outline: 3px solid #e67e22;
  outline-offset: 2px;
  z-index: 11;
}

.history-color::after {
  content: attr(data-hex);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid #333;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-family: 'Courier New', monospace;
  z-index: 100;
}

.history-color:hover::after,
.history-color:focus-visible::after {
  opacity: 1;
}

/* 푸터 노트 */
.footer-note {
  margin-top: 15px;
  padding: 15px;
  background: #f0f0f0;
  border: 2px dashed #999;
}

.footer-note p {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: #333;
}

.footer-note ul {
  margin: 0;
  padding-left: 20px;
  list-style-type: disc;
}

.footer-note li {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  line-height: 1.5;
}

.footer-note li:last-child {
  margin-bottom: 0;
}

/* 토스트 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #27ae60;
  color: #fff;
  padding: 12px 20px;
  border: 2px solid #333;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
}

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

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
}

.toast-value {
  font-size: 11px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

/* 반응형: 태블릿 */
@media (max-width: 1024px) {
  .converter-main {
    grid-template-columns: 1fr 1fr;
  }
  
  .result-section {
    grid-column: 1 / -1;
  }
  
  .harmony-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* 반응형: 모바일 */
@media (max-width: 768px) {
  .hex-rgb-converter {
    padding: 10px;
  }
  
  .converter-main {
    grid-template-columns: 1fr;
  }
  
  .converter-header h2 {
    font-size: 22px;
  }
  
  .subtitle {
    font-size: 11px;
  }
  
  .harmony-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .history-colors {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .quick-actions {
    flex-direction: column;
  }
  
  .btn-random,
  .btn-reset {
    width: 100%;
    justify-content: center;
  }
  
  .preview-box {
    height: 200px;
  }
  
  .toast-value {
    max-width: 250px;
  }
}

/* 반응형: 작은 모바일 */
@media (max-width: 480px) {
  .hex-rgb-converter {
    padding: 8px;
  }
  
  .converter-header {
    margin-bottom: 12px;
  }
  
  .harmony-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .history-colors {
    grid-template-columns: repeat(4, 1fr);
  }
  
  /* 슬라이더 그룹 세로 정렬 (개선됨) */
  .slider-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  
  .color-slider {
    width: 100%;
  }
  
  /* 숫자 입력 + 단위 (개선됨) */
  .input-with-unit {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .input-with-unit .number-input {
    width: 80%;
    text-align: left;
    padding-left: 10px;
  }
  
  .unit-label {
    width: auto;
    text-align: right;
  }
  
  .toast-value {
    max-width: 200px;
  }
}
