/* 기본 리셋 및 변수 */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-sub: #6b7280;
  --primary: #667eea;
  --primary-hover: #5a6fd6;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f23;
    --surface: #1a1a2e;
    --text: #e2e8f0;
    --text-sub: #94a3b8;
    --border: #2d2d44;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* 헤더 */
header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

nav {
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  text-decoration: none;
}

/* 메인 */
main {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-sub);
  margin-bottom: 1.5rem;
}

/* 모드 탭 */
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mode-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mode-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* 옵션 */
.options {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.options[hidden] {
  display: none;
}

.mode-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.target-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.target-wrapper input[type="number"] {
  width: 80px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.target-wrapper select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

/* 품질 비교 테이블 */
.preview-table {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.preview-table th {
  color: var(--text-sub);
  font-weight: 500;
}

.preview-table .selected-row {
  background: rgba(102, 126, 234, 0.08);
}

.preview-table .btn-select {
  padding: 0.3rem 0.6rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

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

.options label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-wrapper input[type="range"] {
  width: 150px;
  accent-color: var(--primary);
}

.range-wrapper span {
  font-weight: 600;
  color: var(--text);
  min-width: 3ch;
}

.options input[type="number"] {
  width: 100px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

/* 드롭존 */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.05);
}

.dropzone-content svg {
  color: var(--text-sub);
  margin-bottom: 1rem;
}

.dropzone-content p {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* 결과 */
.results {
  margin-top: 2rem;
}

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

.results-header h2 {
  font-size: 1.25rem;
}

.btn-clear {
  padding: 0.35rem 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sub);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

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

.btn-remove {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.btn-remove:hover {
  color: #ef4444;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-item .thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.result-item .info {
  flex: 1;
  min-width: 0;
}

.result-item .filename {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-item .sizes {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.result-item .savings {
  font-size: 0.8rem;
  font-weight: 600;
  color: #10b981;
}

.result-item .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.result-item .btn-download {
  padding: 0.4rem 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

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

/* 진행 중 상태 */
.result-item.processing {
  opacity: 0.7;
}

.result-item .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* 모두 다운로드 버튼 */
.btn-download-all {
  margin-top: 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* 푸터 */
footer {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
}

/* 반응형 */
@media (max-width: 480px) {
  main {
    padding: 1.5rem 1rem;
  }

  .dropzone {
    padding: 2rem 1rem;
  }

  .result-item {
    flex-wrap: wrap;
  }

  .options {
    flex-direction: column;
    gap: 1rem;
  }
}
