:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-hover: #334155;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

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

h1 {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.6rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 620px;
  margin: 0 auto;
  word-break: keep-all;
}

/* Device Selector Tabs */
.device-selector-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.device-selector-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.device-tabs {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  max-width: 380px;
}

.device-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.device-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.device-tab.active {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border-color: #818cf8;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Control Panel */
.control-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.mode-selector {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.85rem 0.6rem;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

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

.mode-btn.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: #6366f1;
  color: var(--text-primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
}

.mode-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: keep-all;
}

.mode-btn.active .mode-desc {
  color: #c7d2fe;
}

/* Options */
.options-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.option-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 50%;
  max-width: 250px;
}

input[type="range"] {
  flex: 1;
  accent-color: #6366f1;
  cursor: pointer;
}

.slider-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #818cf8;
  min-width: 40px;
  text-align: right;
}

/* Folder Config Card */
.folder-config-card {
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid #6366f1;
}

.folder-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.folder-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.folder-input-header label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.folder-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.folder-input-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  transition: border-color 0.2s;
}

.folder-input-box:focus-within {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.folder-input-box input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
}

.folder-preview-tag {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
}

.folder-sub-options {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #6366f1;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.checkbox-label code {
  background: rgba(15, 23, 42, 0.7);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Drop Zone */
.drop-zone {
  display: block;
  border: 2px dashed #475569;
  border-radius: var(--radius-lg);
  padding: 2.75rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: rgba(30, 41, 59, 0.4);
  transition: all 0.25s ease;
  margin-bottom: 1.5rem;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-2px);
}

.drop-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  color: #818cf8;
}

.drop-text-main {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

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

/* Progress bar */
.overall-progress-container {
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.overall-progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c7d2fe;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.progress-track {
  height: 8px;
  background: var(--bg-hover);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 9999px;
  width: 0%;
  transition: width 0.3s ease;
}

/* Queue Actions Bar */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.queue-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-buttons, .action-buttons-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Folder status badge */
.folder-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(51, 65, 85, 0.4);
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.folder-status-badge.selected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 38px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-success {
  background: #059669;
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  background: #10b981;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: #64748b;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  min-height: 32px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

/* File Cards */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  gap: 1rem;
  transition: all 0.2s ease;
}

.file-card:hover {
  border-color: #475569;
}

.card-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.card-filename {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-pending {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.badge-processing {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.badge-done {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.progress-bar-container {
  margin-top: 0.4rem;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #3b82f6;
  width: 0%;
  transition: width 0.2s;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* Utility */
.hidden {
  display: none !important;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1.25rem 0.85rem;
  }

  h1 {
    font-size: 1.65rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  /* 모드 선택 버튼 모바일 최적화 */
  .mode-selector {
    flex-direction: column;
    gap: 0.5rem;
  }

  .mode-btn {
    padding: 0.7rem 0.6rem;
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .mode-title {
    font-size: 0.9rem;
    margin-bottom: 0;
  }

  .mode-desc {
    display: none; /* 모바일에서는 심플하게 타이틀만 강조 */
  }

  .queue-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  /* 기기 선택 탭 모바일 최적화 */
  .device-selector-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .device-tabs {
    max-width: 100%;
  }

  /* 모바일 액션 버튼: 2열 그리드 배치로 터치 극대화 */
  .action-buttons, .action-buttons-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  #btnProcessAllMobile, #btnProcessAllPc {
    grid-column: span 2;
    min-height: 44px;
    font-size: 0.95rem;
  }

  #btnDownloadZipMobile {
    grid-column: span 2;
    min-height: 44px;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  }

  #btnDownloadZipPc {
    grid-column: span 2;
    min-height: 40px;
  }

  #btnPickFolder {
    min-height: 38px;
  }

  .folder-status-badge {
    max-width: 100%;
    justify-content: center;
    text-align: center;
    padding: 0.4rem;
  }

  .file-card {
    padding: 0.65rem 0.75rem;
    gap: 0.75rem;
  }

  .card-thumb {
    width: 46px;
    height: 46px;
  }

  .card-filename {
    max-width: 140px;
    font-size: 0.85rem;
  }

  .btn-sm {
    min-height: 36px;
  }
}
