/* Mobile-First HEIC Converter Styles (iPhone/iOS Friendly) */

.heic-shell {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* Upload Dropzone - Thumb Friendly */
.heic-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 1.5rem 1rem;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .2s ease, background .2s ease, transform .1s ease;
}

.heic-dropzone:active {
  transform: scale(0.99);
  background: var(--bg-soft);
  border-color: var(--accent);
}

.heic-dropzone.dragover,
.heic-dropzone:focus-within {
  border-color: var(--accent);
  background: var(--bg-soft);
}

.heic-dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 1.6rem;
}

.heic-dropzone strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.heic-dropzone span {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.heic-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* File selected badge */
.heic-selected-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font: 0.82rem var(--mono);
}

.heic-selected-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
}

.heic-selected-badge small {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Format Selector - Segmented Pills with 48px Min Tap Target */
.format-segmented-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.format-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.65rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

.format-pill:hover,
.format-pill:focus-visible {
  border-color: var(--accent);
  background: var(--bg-soft);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.format-pill.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Quality Slider Container */
.quality-wrapper {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.quality-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.quality-header output {
  font: 0.85rem var(--mono);
  color: var(--accent);
}

.quality-wrapper input[type="range"] {
  width: 100%;
  height: 36px;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}

/* Cloudflare Turnstile container */
.heic-turnstile-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.25rem 0 0.5rem;
  min-height: 65px;
  width: 100%;
  overflow-x: auto;
}

/* Action Button - 48px+ thumb-friendly */
.heic-convert-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 52px;
  margin-top: 1.5rem;
  padding: 0.95rem 1.5rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.heic-convert-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.heic-convert-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Step-by-Step Progress Indicator */
.heic-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 1.75rem 0 1rem;
  padding: 0;
  list-style: none;
}

.heic-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  transition: all 0.2s ease;
}

.heic-step-num {
  font: 0.75rem var(--mono);
  margin-bottom: 0.25rem;
}

.heic-step.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent);
  font-weight: 700;
}

.heic-step.completed {
  border-color: #22c55e;
  color: #22c55e;
}

/* Live progress bar */
.heic-progress-bar-wrap {
  width: 100%;
  height: 6px;
  margin-bottom: 1rem;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.heic-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.heic-status-msg {
  display: block;
  min-height: 1.25rem;
  margin-top: 0.5rem;
  text-align: center;
  color: var(--muted);
  font: 0.8rem var(--mono);
}

/* Results section */
.heic-results {
  margin-top: 2rem;
  padding: 1.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.heic-results[hidden] {
  display: none !important;
}

.heic-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.heic-stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
  text-align: center;
}

.heic-stat-card span {
  font: 0.65rem var(--mono);
  color: var(--muted);
  text-transform: uppercase;
}

.heic-stat-card strong {
  margin-top: 0.25rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.heic-stat-card small {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Image Preview */
.heic-preview-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 380px;
  padding: 0.75rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
  overflow: hidden;
}

.heic-preview-card img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 4px;
}

/* Download / Share Actions - Mobile First */
.heic-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.heic-btn-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 50px;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.heic-btn-share:active {
  transform: scale(0.98);
}

.heic-btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 50px;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.heic-btn-download:hover,
.heic-btn-download:focus-visible {
  background: var(--bg-soft);
}

.heic-btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

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

/* R2 Storage Persistence Badge */
.r2-storage-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: 4px;
  background: color-mix(in srgb, #22c55e 12%, transparent);
  border: 1px solid color-mix(in srgb, #22c55e 30%, transparent);
  color: #22c55e;
  font: 0.75rem var(--mono);
  text-align: center;
  overflow-wrap: anywhere;
}

.r2-storage-badge a {
  color: inherit;
  text-decoration: underline;
}

/* Media Queries for Viewports Above iPhone Size */
@media (min-width: 600px) {
  .heic-actions {
    flex-direction: row;
  }

  .heic-btn-share,
  .heic-btn-download {
    flex: 1;
  }
}