:root {
  --bg-color: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.3);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(15, 23, 42, 0.6);
  --font-main: "Outfit", "Pretendard", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  /* 전체 페이지 스크롤 방지 (개별 컨테이너 스크롤) */
  display: flex;
  flex-direction: column;
  position: relative;
}

.background-glow {
  position: fixed;
  top: -20%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
  animation: float 10s infinite ease-in-out alternate;
}

@keyframes float {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(20px, 40px);
  }
}

/* 공통 너비 제한 컨테이너 (기존 app-container 역할) */
.content-limiter {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

/* 상단 고정 헤더 영역 */
.fixed-header-container {
  width: 100%;
  padding-top: 2rem;
  padding-bottom: 0.5rem;
  /* Reduced from 1.5rem */
  background-color: var(--bg-color);
  /* 배경색 지정 필수 (투명하면 겹침) */
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  /* 헤더 구분감 추가 */
}

/* 스크롤 가능한 콘텐츠 영역 */
.scroll-content-container {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  /* 여기가 실제 스크롤 영역 */
  overflow-x: hidden;
  padding-top: 1rem;
  padding-bottom: 2rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.main-header {
  text-align: center;
  animation: fadeInDown 0.8s ease-out;
}

.logo {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

.logo .highlight {
  color: var(--accent-color);
  text-shadow: 0 0 20px var(--accent-glow);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.search-container {
  width: 100%;
  animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  /* Reduced from 1rem */
  padding: 0 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  font-family: var(--font-main);
  font-weight: 500;
}

.tab-btn:hover {
  color: var(--text-primary);
}



.tab-btn.active {
  color: var(--accent-color);
  font-weight: 700;
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent-color);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.input-wrapper {
  position: relative;
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.input-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-2px);
}

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  padding: 1rem 1.5rem;
  font-family: var(--font-main);
  outline: none;
}

#searchInput::placeholder {
  color: var(--text-secondary);
}

#searchBtn {
  background: var(--accent-color);
  border: none;
  border-radius: 14px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-color);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 4px;
}

#searchBtn:hover {
  transform: scale(1.05);
  background: #7dd3fc;
}

#searchBtn:active {
  transform: scale(0.95);
}

.results-container {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 0.5rem;
  /* 스크롤바 공간 */
  animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem;
  border: 1px dashed var(--glass-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.result-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 1.5rem;
  border-radius: 16px;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.result-number {
  position: absolute;
  top: auto;
  left: auto;
  bottom: 10px;
  right: 10px;
  background: var(--accent-color);
  color: var(--bg-color);
  min-width: 28px;
  width: auto;
  /* Fixed width removed for expansion */
  height: 28px;
  padding: 0 8px;
  /* Horizontal padding */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  /* Pill shape */
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.result-card:hover {
  background: rgba(45, 55, 72, 0.8);
  transform: translateX(5px);
  border-color: rgba(56, 189, 248, 0.5);
}

.result-card h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.result-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

footer {
  flex-shrink: 0;
  margin-top: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  opacity: 0.6;
  padding-top: 1rem;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #1e293b;
  /* Dark theme background */
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 16px;
  padding: 2rem;
  position: relative;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

/* Detail View Styles */
.detail-header {
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.print-btn,
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.print-btn:hover,
.close-btn:hover {
  color: var(--accent-color);
  background: rgba(56, 189, 248, 0.1);
}

.close-btn {
  font-size: 1.5rem;
  position: static;
  /* 절대 위치 제거 */
}

.print-btn:hover {
  color: var(--accent-color);
  background: rgba(56, 189, 248, 0.1);
}

.detail-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-color);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.detail-section {
  margin-bottom: 2rem;
}

.detail-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-content {
  line-height: 1.7;
  color: var(--text-primary);
  white-space: normal;

  /* 강력한 줄바꿈 규칙 적용 */
  overflow-wrap: anywhere;
  word-break: break-all;

  background: rgba(15, 23, 42, 0.3);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  overflow-x: hidden;
  /* 만일의 경우를 대비한 가로 스크롤 숨김 */
}

/* API 응답의 인라인 스타일 강제 초기화 */
/* API 응답의 인라인 스타일 강제 초기화 */
.detail-content * {
  font-family: var(--font-main) !important;
  font-size: 1rem !important;
  color: var(--text-primary) !important;
  background-color: transparent !important;
  line-height: 1.7 !important;
  height: auto !important;
  width: auto !important;
  /* 고정 너비 방지 */
  max-width: 100% !important;
  box-sizing: border-box !important;

  /* 텍스트 줄바꿈 강제 적용 (자식 요소까지 전파) */
  white-space: normal !important;
  word-break: break-all !important;
  overflow-wrap: anywhere !important;
}

/* Badge Group */
.badge-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.detail-badge.faq-no {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-secondary);
}

.detail-content img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px;
  margin: 1rem 0;
}

/* Law List Styles */
.law-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.law-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.law-item:last-child {
  border-bottom: none;
}

.law-item a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
}

.law-item a:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Skeleton Loading */
.skeleton-loader {
  width: 100%;
  height: 200px;
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Result Count */
.result-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  /* Reduced from 1rem */
  margin-bottom: 0.5rem;
  /* Reduced from 1rem */
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-radius: 12px;
  min-height: 3.5rem;
  /* Reserve space */
  box-sizing: border-box;
}

.result-count .search-query {
  color: var(--text-primary);
  font-weight: 500;
}

.result-count strong {
  color: var(--accent-color);
  font-weight: 700;
}

/* Loading Spinner */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
  gap: 1rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
    overflow: visible !important;
    /* 스크롤 잠금 해제 */
  }

  .background-glow,
  .fixed-header-container,
  .scroll-content-container,
  .close-btn,
  .print-btn,
  .search-container {
    display: none !important;
  }

  .modal-overlay {
    position: static;
    background: white;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: 100%;
    height: auto;
  }

  .modal-content {
    position: static;
    transform: none !important;
    width: 100%;
    max-width: 100%;
    background: white;
    color: black;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .detail-content,
  .law-list {
    background: white;
    border: 1px solid #ddd;
    color: black;
  }

  .detail-title {
    color: black;
  }

  .detail-content * {
    color: black !important;
  }

  a {
    text-decoration: underline;
    color: black !important;
  }
}

/* Scroll Lock */
body.no-scroll {
  overflow: hidden;
}

/* Filter Styles */
.search-filters {
  margin-top: 1rem;
  animation: fadeInUp 0.8s ease-out 0.3s backwards;
  display: flex;
  justify-content: flex-end;
  /* 오른쪽 정렬 */
}

.filter-wrapper {
  position: relative;
  min-width: 200px;
}

.dept-select {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
  outline: none;
  transition: all 0.3s ease;
}

.dept-select:hover,
.dept-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 15px var(--accent-glow);
}

.dept-select optgroup {
  background: #1e293b;
  /* 드롭다운 메뉴 배경색 (브라우저 기본값 오버라이드 시도) */
  color: var(--text-secondary);
  font-style: normal;
  font-weight: 600;
}

/* [Previous Filter Styles - Can be removed if confirmed unused] */
.dept-select option {
  background: #1e293b;
  color: var(--text-primary);
  padding: 10px;
}

/* Law HTML Content Styles */
.law-html-content {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.6;
}

.law-html-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.law-html-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-light);
  margin: 1.2rem 0 0.8rem;
}

.law-html-content p {
  margin-bottom: 1rem;
  word-break: keep-all;
}

.law-html-content .subtit1 {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-bottom: 1.5rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  display: inline-block;
}

.law-html-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.law-html-content th,
.law-html-content td {
  padding: 0.8rem;
  border: 1px solid var(--glass-border);
  text-align: left;
}

.law-html-content th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-weight: 600;
}

.law-html-content a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
  cursor: pointer !important;
}

.law-html-content a:hover {
  text-decoration: underline;
  color: var(--accent-light);
}

/* Print Styles Update */
@media print {
  .law-html-content {
    color: black;
  }

  .law-html-content .subtit1 {
    background: none;
    color: #555;
    border: 1px solid #ddd;
  }

  .law-html-content h4 {
    color: #000;
  }

  .law-html-content table {
    border-color: #000;
    background: none;
  }

  .law-html-content th,
  .law-html-content td {
    border-color: #000;
  }
}

/* Animation for Static Elements */
.result-count,
#noticeTextContainer,
footer {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.result-count {
  animation-delay: 0.1s;
}

#noticeTextContainer {
  animation-delay: 0.2s;
}

footer {
  animation-delay: 0.3s;
  margin-top: auto;
  /* Ensure it stays at bottom if flex container is used */
  padding: 2rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}