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

[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
  padding: 24px 16px 48px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
}

/* ── Header ───────────────────────────── */
header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: #6e6e73;
  font-size: 0.9rem;
  margin-top: 6px;
}

/* ── Upload Area ──────────────────────── */
.upload-area {
  border: 2px dashed #c7c7cc;
  border-radius: 16px;
  background: #fff;
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: #0071e3;
  background: #f0f6ff;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.upload-sub {
  color: #6e6e73;
  font-size: 0.85rem;
}

/* ── Main Panel ───────────────────────── */
.main-panel {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
}

/* ── Settings Panel ───────────────────── */
.settings-panel {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  grid-row: 1;
  grid-column: 1;
}

.settings-panel h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #3a3a3c;
  margin-bottom: 8px;
}

/* Format Buttons */
.format-buttons {
  display: flex;
  gap: 8px;
}

.format-btn {
  flex: 1;
  padding: 8px 0;
  border: 1.5px solid #c7c7cc;
  border-radius: 8px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.format-btn.active {
  border-color: #0071e3;
  background: #0071e3;
  color: #fff;
}

/* Quality Slider */
#qualitySlider {
  width: 100%;
  accent-color: #0071e3;
  margin-bottom: 4px;
}

/* Size Inputs */
.size-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.size-input-wrap input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #c7c7cc;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.size-input-wrap input:focus {
  border-color: #0071e3;
}

.size-input-wrap span,
.size-separator {
  font-size: 0.85rem;
  color: #6e6e73;
  white-space: nowrap;
}

.hint {
  font-size: 0.78rem;
  color: #8e8e93;
  margin-top: 6px;
  line-height: 1.4;
}

/* Primary Button */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.btn-primary:hover {
  background: #0077ed;
}

.btn-primary:active {
  background: #005cbf;
}

/* ── Preview Panel ────────────────────── */
.preview-panel {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.preview-box {
  flex: 1;
}

.preview-box h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6e6e73;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-img-wrap {
  position: relative;
  background: #f5f5f7;
  border-radius: 10px;
  overflow: hidden;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-img-wrap img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}

.preview-img-wrap img[src=""] {
  display: none;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #aeaeb2;
  text-align: center;
  padding: 16px;
}

.preview-info {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.preview-info span {
  font-size: 0.82rem;
  color: #6e6e73;
  background: #f5f5f7;
  padding: 3px 8px;
  border-radius: 6px;
}

.reduction-badge {
  background: #d1fae5 !important;
  color: #065f46 !important;
  font-weight: 600;
}

.preview-arrow {
  font-size: 1.5rem;
  color: #c7c7cc;
  padding-top: 100px;
  flex-shrink: 0;
}

/* ── Download Area ────────────────────── */
.download-area {
  grid-column: 1 / -1;
  text-align: center;
}

.btn-download {
  padding: 14px 48px;
  background: #34c759;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-download:hover {
  background: #30b350;
}

/* ── DPI Buttons ──────────────────────── */
.dpi-buttons {
  display: flex;
  gap: 6px;
}

.dpi-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1.5px solid #c7c7cc;
  border-radius: 8px;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
}

.dpi-btn .dpi-label {
  font-size: 0.68rem;
  color: #8e8e93;
  font-weight: 400;
}

.dpi-btn.active {
  border-color: #0071e3;
  background: #0071e3;
  color: #fff;
}

.dpi-btn.active .dpi-label {
  color: #cce0ff;
}

/* ── Progress Bar ─────────────────────── */
.progress-bar-wrap {
  height: 6px;
  background: #e5e5ea;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
  margin-top: 4px;
}

.progress-bar {
  height: 100%;
  background: #0071e3;
  border-radius: 3px;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 0.78rem;
  color: #6e6e73;
  text-align: center;
  margin-bottom: 12px;
}

/* ── Warning Badge ────────────────────── */
.warning-badge {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: #fff8e1;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #92400e;
  line-height: 1.4;
  margin-bottom: 16px;
}

.warning-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Disabled Button ──────────────────── */
.btn-primary:disabled {
  background: #aeaeb2;
  cursor: not-allowed;
}

/* ── Responsive ───────────────────────── */
@media (max-width: 640px) {
  .main-panel {
    grid-template-columns: 1fr;
  }

  .settings-panel,
  .preview-panel {
    grid-column: 1;
  }

  .preview-panel {
    flex-direction: column;
  }

  .preview-arrow {
    padding-top: 0;
    transform: rotate(90deg);
    text-align: center;
  }
}
