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

/* ── 컬러 토큰 ── */
:root {
  --bg: #ffffff;
  --bg-subtle: #f5f6f8;
  --bg-card: #f9fafb;
  --border: #e5e7eb;
  --border-focus: #6366f1;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-2: #3b82f6;
  --accent-light: #eef2ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --green-border: #bbf7d0;
  --scroll-thumb: #d1d5db;
}

body {
  width: 100%;
  min-width: 300px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* 메인 스크롤 영역 */
.main-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.main-scroll::-webkit-scrollbar { width: 4px; }
.main-scroll::-webkit-scrollbar-track { background: transparent; }
.main-scroll::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 2px;
}

.container {
  padding: 16px 16px 12px;
}

/* ── 헤더 ── */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.logo-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* 좁은 패널 대응 */
@media (max-width: 380px) {
  .preview-container { flex-direction: column; }
  .arrow { transform: rotate(90deg); }
}

/* ── 업로드 영역 ── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-icon { font-size: 36px; margin-bottom: 10px; }

.upload-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 500;
}

.upload-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── 미리보기 ── */
.preview-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.preview-box { flex: 1; text-align: center; }

.preview-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.preview-box img {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.arrow {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* 체커보드 (투명 배경 표시) */
.checkerboard {
  width: 100%;
  min-height: 100px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.checkerboard img {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: 10px;
  background: transparent !important;
}

.processing { text-align: center; padding: 20px; }

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}

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

.processing p {
  font-size: 12px;
  color: var(--text-secondary);
}

.process-hint {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  margin-top: 3px;
}

/* ── 자동 저장 배너 ── */
.auto-saved-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 10px;
  padding: 9px 13px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--green);
}

.auto-saved-banner b { color: #166534; }
.auto-saved-banner .check-icon { font-size: 15px; }

/* ── 저장 옵션 ── */
.save-options {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.save-options h3 {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.resolution-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.res-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
  flex-wrap: wrap;
}

.res-option:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.res-option input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.res-label { color: var(--text); flex: 1; }

.res-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.custom-option { grid-column: 1 / -1; }

.custom-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  width: 100%;
}

.custom-inputs input {
  width: 76px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  text-align: center;
}

.custom-inputs input:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-inputs span { color: var(--text-muted); }

.format-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.format-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.format-option input { accent-color: var(--accent); }

.btn-save {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 9px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-save:hover { opacity: 0.9; }
.btn-save:active { transform: scale(0.98); }
.btn-save:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-reset {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

/* ── 하단 고정 광고박스 ── */
.promo-box {
  flex-shrink: 0;
  background: linear-gradient(180deg, #fff9e6, #fff3c4);
  border-top: 1px solid #f0d060;
  padding: 10px 16px 12px;
}

.promo-pill {
  display: inline-block;
  background: #fde68a;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 7px;
}

.promo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: opacity 0.25s ease;
}

.promo-item { display: flex; align-items: center; }

.promo-link {
  display: block;
  width: 100%;
  font-size: 13px;
  color: #78350f;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  padding-left: 12px;
}

.promo-link::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #d97706;
}

.promo-link:hover {
  color: #451a03;
  text-decoration: underline;
}
