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

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fff;
  color: #111;
  min-height: 100vh;
  padding: 2rem 1rem;
}

main {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */

header { text-align: center; }

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

.tagline {
  margin-top: 0.4rem;
  font-size: 1rem;
  color: #666;
}

/* Drop zone */

#drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 2rem;
  border: 2px dashed #ccc;
  border-radius: 12px;
  cursor: pointer;
  color: #555;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

#drop-zone:hover,
#drop-zone:focus-visible {
  border-color: #111;
  background: #f9f9f9;
  outline: none;
}

#drop-zone.drag-over {
  border-color: #111;
  background: #f3f3f3;
}

#drop-zone.has-image {
  padding: 0.9rem 1.5rem;
  border-style: solid;
  border-color: #e5e5e5;
  flex-direction: row;
  gap: 0.75rem;
  justify-content: center;
}

#drop-zone.has-image svg,
#drop-zone.has-image .drop-sub { display: none; }

#drop-zone.has-image .drop-label { font-size: 0.85rem; color: #888; }

.drop-label { font-size: 1rem; font-weight: 500; }
.drop-sub   { font-size: 0.85rem; color: #999; }

/* Settings */

#settings {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #444;
  min-width: 80px;
}

/* Ratio / Format buttons */

#ratio-selector,
#format-selector {
  display: flex;
  gap: 0.4rem;
}

.ratio-btn,
.format-btn {
  padding: 0.35rem 0.85rem;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: #555;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}

.ratio-btn:hover,
.format-btn:hover  { border-color: #888; color: #111; }

.ratio-btn.active,
.format-btn.active { border-color: #111; background: #111; color: #fff; }

/* Quality */

#quality-row { gap: 0.75rem; }

#quality-slider {
  width: 130px;
  accent-color: #111;
}

#quality-value {
  font-size: 0.85rem;
  color: #555;
  min-width: 2.5rem;
}

/* Toggle */

.toggle-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: inline-block;
  width: 36px;
  height: 20px;
  background: #ccc;
  border-radius: 10px;
  position: relative;
  transition: background 0.15s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.toggle-label input:checked + .toggle-track { background: #111; }
.toggle-label input:checked + .toggle-track::after { transform: translateX(16px); }

/* Overlap controls */

#overlap-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: 0.25rem;
}

#overlap-slider {
  width: 110px;
  accent-color: #111;
}

#overlap-value {
  font-size: 0.85rem;
  color: #555;
  min-width: 2.5rem;
}

/* Output section (badge + strip + button) */

#output-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  opacity: 0;
  transition: opacity 0.25s;
}

#output-section.visible { opacity: 1; }

/* Slide badge */

#slide-badge {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

#slide-count {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.badge-label {
  font-size: 1rem;
  color: #666;
}

/* Cap warning */

#cap-warning {
  font-size: 0.85rem;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

/* Thumbnail strip */

#slice-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.thumb-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.slice-thumb {
  border-radius: 4px;
  border: 1.5px solid #e5e5e5;
  display: block;
}

.thumb-label {
  font-size: 0.7rem;
  color: #999;
}

/* Download button */

#download-btn {
  align-self: flex-start;
  padding: 0.75rem 2.5rem;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

#download-btn:hover    { opacity: 0.85; }
#download-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Full preview */

#preview-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.25s;
}

#preview-section.visible { opacity: 1; }

#preview-canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  border: 1px solid #e5e5e5;
}

#image-info {
  font-size: 0.8rem;
  color: #aaa;
  text-align: center;
}

/* Mobile */

@media (max-width: 480px) {
  body { padding: 1.25rem 0.75rem; }

  h1 { font-size: 1.6rem; }

  .setting-label { min-width: 70px; font-size: 0.8rem; }

  .ratio-btn,
  .format-btn { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

  #quality-slider,
  #overlap-slider { width: 90px; }

  #download-btn { width: 100%; text-align: center; align-self: stretch; }

  #slide-count { font-size: 2rem; }
}
