/**
 * Prompt Dashboard Styles
 * Dark/Light theme with emerald accent
 */

/* Dark Theme (기본값) */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1a1a1a;
  --text-primary: #ecfdf5;
  --text-secondary: #a1a1aa;
  --accent: #10b981;
  --accent-light: rgba(16, 185, 129, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --chart-grid: rgba(255, 255, 255, 0.05);
  --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent: #059669;
  --accent-light: rgba(5, 150, 105, 0.1);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --chart-grid: rgba(0, 0, 0, 0.05);
  --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Accessibility (Phase 2.5) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent);
  color: var(--bg-primary);
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  font-weight: 600;
  z-index: 9999;
  border-radius: 0 0 0.5rem 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: none;
}

.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;
}

/* 포커스 개선 - 모든 인터랙티브 요소 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 2rem;
  line-height: 1.5;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(16, 185, 129, 0.1);
}

.stat-card h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-card .value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.chart-container {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.chart-container h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.chart-container canvas {
  max-height: 300px;
}

/* Keywords Section */
.keywords-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 3rem;
}

.keywords-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.keyword {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform 0.2s, background 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.keyword:hover {
  transform: scale(1.05);
  background: rgba(16, 185, 129, 0.2);
}

.keyword:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.keyword .count {
  opacity: 0.7;
  margin-left: 0.25rem;
}

/* Insights Section */
.insights-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.insights-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.insight {
  padding: 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  margin-bottom: 0.75rem;
  border-radius: 0 0.5rem 0.5rem 0;
  transition: transform 0.2s, background-color 0.2s;
  cursor: pointer;
}

.insight:hover,
.insight:focus-visible {
  transform: translateX(4px);
  background: rgba(16, 185, 129, 0.15);
  outline: none;
}

[data-theme="light"] .insight:hover,
[data-theme="light"] .insight:focus-visible {
  background: rgba(5, 150, 105, 0.15);
}

.insight:last-child {
  margin-bottom: 0;
}

.insight .text {
  margin-bottom: 0.25rem;
  line-height: 1.6;
}

.insight .meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Loading State */
.loading {
  text-align: center;
  padding: 4rem;
  color: var(--text-secondary);
}

.loading p {
  margin-bottom: 0.5rem;
}

/* Error State */
.error {
  text-align: center;
  padding: 4rem;
  color: #ef4444;
}

.error .message {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.error .hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

footer a:hover {
  opacity: 0.8;
}

footer .separator {
  margin: 0 0.5rem;
}

/* Technique Section (기법 차트) */
.technique-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 3rem;
}

.technique-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.technique-chart-container {
  height: 300px;
  border: none;
  padding: 0;
  background: transparent;
}

/* Histogram Section (Phase 3.3) */
.histogram-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 3rem;
}

.histogram-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Efficiency Section (Phase 4.1) */
.efficiency-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 3rem;
}

.efficiency-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Partial Load Warning (부분 로드 경고) */
.partial-load-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.partial-load-warning .warning-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.partial-load-warning .warning-icon {
  font-size: 1.2rem;
}

.partial-load-warning .warning-text {
  flex: 1;
  font-size: 0.875rem;
  color: #f59e0b;
}

.partial-load-warning .warning-close {
  background: transparent;
  border: none;
  color: #f59e0b;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.partial-load-warning .warning-close:hover {
  opacity: 1;
}

/* Error Details (에러 상세) */
.error-details {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 0.5rem;
  text-align: left;
}

.error-details .details-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.error-details ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.error-details li {
  padding: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.error-details li strong {
  color: #ef4444;
}

/* Retry Button (다시 시도 버튼) */
.retry-btn {
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.retry-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.retry-btn:active {
  transform: translateY(0);
}

/* Modal (Phase 2.3) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  padding: 1rem;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 1rem;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border-subtle);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.open .modal-content {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  z-index: 1;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--border-subtle);
}

.modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  padding-right: 2rem;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.modal-meta-item.type {
  background: var(--accent-light);
  color: var(--accent);
}

.modal-body {
  padding: 1.5rem;
}

.modal-section {
  margin-bottom: 1.5rem;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.modal-section p {
  line-height: 1.6;
  color: var(--text-primary);
}

.modal-analysis {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 0.5rem;
  line-height: 1.7;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.modal-techniques {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-technique-tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.375rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.modal-stat {
  background: var(--bg-secondary);
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
}

.modal-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.modal-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.modal-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: color 0.2s, background 0.2s;
}

.modal-link:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.modal-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* 모달 오픈 시 body 스크롤 방지 */
body.modal-open {
  overflow: hidden;
}

/* Search Bar (Phase 2.2) */
.search-bar {
  margin-top: 1.5rem;
}

.search-input-wrapper {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 2.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 2rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:hover {
  border-color: var(--accent);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* 검색 기록 제거 (Chrome) */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.search-clear:hover {
  color: var(--text-primary);
  background: var(--border-subtle);
}

/* 검색 결과 섹션 */
.search-results-section {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.search-results-header h3 {
  font-size: 1rem;
  margin: 0;
}

.search-results-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.search-results-count strong {
  color: var(--accent);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.search-result-item:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.search-result-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.search-result-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: 0.75rem;
}

.search-result-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* 검색 하이라이트 */
.search-highlight {
  background: rgba(16, 185, 129, 0.3);
  color: var(--text-primary);
  padding: 0 0.125rem;
  border-radius: 2px;
}

/* 검색 결과 없음 */
.search-no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.search-no-results p {
  margin-bottom: 0.5rem;
}

.search-no-results .tip {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Filter Bar (Phase 2.1) */
/* 햄버거 필터 토글 버튼 (Phase 3.4) */
.filter-toggle-btn {
  display: none; /* 데스크톱에서는 숨김 */
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1rem;
  width: 100%;
  justify-content: center;
}

.filter-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-toggle-btn .icon-menu,
.filter-toggle-btn .icon-close {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.filter-toggle-btn .icon-close {
  display: none;
}

.filter-toggle-btn[aria-expanded="true"] .icon-menu {
  display: none;
}

.filter-toggle-btn[aria-expanded="true"] .icon-close {
  display: block;
}

.filter-toggle-btn[aria-expanded="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-subtle);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--text-primary);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  min-width: 140px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M3 4.5L6 8l3-3.5H3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:hover {
  border-color: var(--accent);
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.filter-date-group {
  flex-shrink: 0;
}

.filter-date-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-date {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  width: 140px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-date:hover {
  border-color: var(--accent);
}

.filter-date:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* 날짜 선택기 아이콘 색상 */
.filter-date::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.filter-date-separator {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.filter-presets {
  margin-left: auto;
}

.filter-preset-buttons {
  display: flex;
  gap: 0.375rem;
}

.filter-preset-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-preset-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.filter-preset-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.filter-reset-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-end;
}

.filter-reset-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.filter-reset-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* 필터 활성화 표시 */
.filter-bar.has-filters {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-light);
}

/* 필터 결과 카운트 */
.filter-result-count {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.filter-result-count strong {
  color: var(--accent);
}

/* Responsive (Phase 3.4: 3단 브레이크포인트) */

/* 데스크톱: max-width 1400px, 중앙 정렬 */
@media (min-width: 1025px) {
  body {
    max-width: 1400px;
    margin: 0 auto;
  }
}

/* 태블릿: 640px - 1024px */
@media (min-width: 641px) and (max-width: 1024px) {
  body {
    padding: 1.5rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar {
    flex-wrap: wrap;
  }

  .filter-group {
    flex: 1;
    min-width: 45%;
  }

  .filter-presets {
    width: 100%;
    margin-left: 0;
    margin-top: 0.5rem;
  }
}

/* 모바일: 640px 이하 */
@media (max-width: 640px) {
  body {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  header p {
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-card .value {
    font-size: 1.75rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .chart-container {
    padding: 1rem;
  }

  .technique-chart-container {
    height: 250px;
  }

  /* 검색 바 모바일 */
  .search-input-wrapper {
    max-width: 100%;
  }

  .search-input {
    padding: 0.625rem 2.25rem 0.625rem 2.5rem;
    font-size: 0.85rem;
  }

  /* 햄버거 필터 토글 버튼 모바일 (Phase 3.4) */
  .filter-toggle-btn {
    display: flex;
  }

  /* 필터 바 모바일 - 접기/펼치기 (Phase 3.4) */
  .filter-bar {
    padding: 1rem;
    gap: 0.75rem;
    max-height: 0;
    padding: 0;
    margin-bottom: 0;
    overflow: hidden;
    opacity: 0;
    border-width: 0;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease, opacity 0.3s ease, border-width 0.3s ease;
  }

  .filter-bar.expanded {
    max-height: 600px;
    padding: 1rem;
    margin-bottom: 1rem;
    opacity: 1;
    border-width: 1px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select,
  .filter-date {
    width: 100%;
    min-height: 44px; /* 터치 타겟 44px */
  }

  .filter-date-inputs {
    flex-wrap: wrap;
  }

  .filter-date {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
  }

  .filter-presets {
    width: 100%;
    margin-left: 0;
  }

  .filter-preset-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .filter-preset-btn {
    flex: 1;
    text-align: center;
    min-height: 44px; /* 터치 타겟 */
    padding: 0.625rem 0.5rem;
  }

  .filter-reset-btn {
    width: 100%;
    margin-top: 0.5rem;
    min-height: 44px;
  }

  /* 키워드 모바일 */
  .keyword {
    padding: 0.625rem 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* 통찰 모바일 */
  .insight {
    padding: 0.875rem;
  }

  /* 부분 로드 경고 모바일 */
  .partial-load-warning .warning-content {
    flex-wrap: wrap;
  }

  .partial-load-warning .warning-text {
    flex-basis: calc(100% - 3rem);
  }

  /* 검색 결과 모바일 */
  .search-results-list {
    max-height: 300px;
  }

  .search-result-item {
    padding: 0.875rem;
  }

  /* 모달 모바일 */
  .modal-content {
    max-height: 95vh;
    border-radius: 0.75rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
  }

  /* Footer 모바일 */
  footer {
    font-size: 0.75rem;
  }

  footer .separator {
    display: block;
    margin: 0.25rem 0;
  }
}

/* 레거시 768px 브레이크포인트 (호환성) */
@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 플로팅 버튼 그룹 (Phase 4.2, 4.3) ===== */

.floating-actions {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 100;
}

/* 플로팅 버튼 공통 */
.floating-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.floating-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px var(--shadow-color);
}

.floating-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.floating-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
  transition: transform 0.3s;
}

.floating-btn:hover svg {
  transform: rotate(15deg);
}

/* 아이콘 전환 */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
}

/* 다크 모드: 태양 아이콘 표시 */
.theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg);
}

.theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg);
}

/* 라이트 모드: 달 아이콘 표시 */
[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg);
}

/* ===== 내보내기 드롭다운 (Phase 4.3) ===== */

.export-dropdown {
  position: relative;
}

.export-menu {
  position: absolute;
  top: 0;
  right: calc(100% + 0.5rem);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 0.5rem;
  min-width: 160px;
  box-shadow: 0 4px 20px var(--shadow-color);
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.export-dropdown.open .export-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.export-menu-item:hover {
  background: var(--accent-light);
}

.export-menu-item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.export-menu-item svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* 내보내기 진행 중 상태 */
.export-menu-item.loading {
  pointer-events: none;
  opacity: 0.6;
}

.export-menu-item.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 내보내기 성공 토스트 */
.export-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: var(--bg-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px var(--shadow-color);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 1001;
}

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

/* 라이트 테마 특수 스타일 */
[data-theme="light"] header h1 {
  background: linear-gradient(135deg, #059669, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .stat-card:hover {
  box-shadow: 0 8px 30px rgba(5, 150, 105, 0.15);
}

[data-theme="light"] .search-highlight {
  background: rgba(5, 150, 105, 0.25);
}

/* 라이트 테마: 날짜 선택기 아이콘 */
[data-theme="light"] .filter-date::-webkit-calendar-picker-indicator {
  filter: none;
}

/* 라이트 테마: 부분 로드 경고 */
[data-theme="light"] .partial-load-warning {
  background: rgba(245, 158, 11, 0.08);
}

/* 라이트 테마: 에러 상세 */
[data-theme="light"] .error-details {
  background: rgba(239, 68, 68, 0.08);
}

/* 테마 전환 애니메이션 */
body,
.stat-card,
.chart-container,
.keywords-section,
.insights-section,
.technique-section,
.histogram-section,
.efficiency-section,
.filter-bar,
.search-input,
.modal-content {
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* 모바일 플로팅 버튼 */
@media (max-width: 640px) {
  .floating-actions {
    top: 1rem;
    right: 1rem;
    gap: 0.5rem;
  }

  .floating-btn {
    width: 40px;
    height: 40px;
  }

  .floating-btn svg {
    width: 18px;
    height: 18px;
  }

  /* 모바일에서 내보내기 메뉴 위치 조정 */
  .export-menu {
    top: auto;
    bottom: 0;
    right: calc(100% + 0.5rem);
    min-width: 150px;
  }
}
