:root {
  --bg: #fbfbfd;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-solid: #ffffff;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --success: #1d8a3a;
  --danger: #d70015;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08), 0 24px 48px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 20px 60px -20px rgba(120, 60, 220, 0.4),
                 0 10px 30px -15px rgba(255, 100, 150, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0c;
    --surface: rgba(28, 28, 32, 0.7);
    --surface-solid: #1c1c1e;
    --text: #f5f5f7;
    --text-muted: #a1a1a6;
    --text-faint: #6e6e73;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6), 0 24px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Animated background blobs --- */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
  z-index: -1;
  animation: float 22s ease-in-out infinite;
}
body::before {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #ff6ec7 0%, transparent 70%);
  top: -150px; left: -120px;
}
body::after {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #6a8bff 0%, transparent 70%);
  top: -100px; right: -150px;
  animation-delay: -11s;
}
@media (prefers-color-scheme: dark) {
  body::before, body::after { opacity: 0.35; }
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
}

/* --- Header --- */
header {
  text-align: center;
  padding: 72px 24px 36px;
  position: relative;
}

.hero-frame {
  width: 120px;
  height: 67.5px;
  margin: 0 auto 28px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff6ec7 0%, #7e5cff 50%, #4facfe 100%);
  position: relative;
  box-shadow: var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hero-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4) 0%, transparent 50%),
    linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 100%);
}
.hero-frame .ratio-label {
  position: relative;
  color: white;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-variant-numeric: tabular-nums;
}

header h1 {
  margin: 0;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
  background: linear-gradient(180deg, var(--text) 0%, var(--text-muted) 130%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
header p {
  margin: 16px auto 0;
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.015em;
  max-width: 520px;
  line-height: 1.4;
}

.privacy-badge {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 12px;
  background: rgba(52, 199, 89, 0.12);
  color: var(--success);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
@media (prefers-color-scheme: dark) {
  .privacy-badge { background: rgba(52, 199, 89, 0.18); color: #5dd87a; }
}

.footnote {
  text-align: center;
  margin-top: 32px;
  font-size: 12px;
  color: var(--text-faint);
}
.footnote a { color: var(--accent); text-decoration: none; }
.footnote a:hover { text-decoration: underline; }
.footnote .dot { margin: 0 8px; opacity: 0.6; }

/* --- Main --- */
main {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px 96px;
  position: relative;
}

/* --- Dropzone --- */
#dropzone {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#dropzone:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
#dropzone.drag {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.08);
}

#dropzone .dz-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff8a5b 0%, #ff5e9c 50%, #7b5cff 100%);
  border-radius: 12px;
  color: white;
  box-shadow: 0 4px 12px -2px rgba(255, 90, 140, 0.45);
}

#dropzone .dz-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#dropzone .dz-text { flex: 1; min-width: 0; }
#dropzone .dz-text strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.012em;
}
#dropzone .dz-text span {
  display: block;
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 3px;
  letter-spacing: -0.005em;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  padding: 7px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: -0.005em;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 113, 227, 0.3), 0 2px 6px rgba(0, 113, 227, 0.2);
  line-height: 1.4;
}
.btn:hover { background: var(--accent-hover); box-shadow: 0 2px 4px rgba(0, 113, 227, 0.35), 0 6px 14px rgba(0, 113, 227, 0.25); }
.btn:active { transform: scale(0.97); }
.btn:disabled {
  background: var(--border-strong);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn.ghost:hover {
  background: var(--bg);
  border-color: var(--text-faint);
  box-shadow: var(--shadow-sm);
}

.btn.success {
  background: linear-gradient(180deg, #34c759 0%, #28a745 100%);
  box-shadow: 0 1px 2px rgba(40, 167, 69, 0.3), 0 2px 6px rgba(40, 167, 69, 0.2);
}
.btn.success:hover {
  background: linear-gradient(180deg, #3dd366 0%, #2eb850 100%);
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.35), 0 6px 14px rgba(40, 167, 69, 0.25);
}

/* --- Items --- */
#items {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.item {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.item-head-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 70%;
}
.item-head .name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.008em;
}
.item-head .size-info {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.002em;
}
.item-head .size-info strong {
  color: var(--text-muted);
  font-weight: 500;
}
.item-head .size-info .arrow {
  margin: 0 4px;
  color: var(--text-faint);
}
.item-head .size-info .out {
  color: var(--accent);
  font-weight: 600;
}
.item-head .status {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.item-head .status.done { color: var(--success); }
.item-head .status.err { color: var(--danger); }

.mode-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--surface-solid) 0%, rgba(0,0,0,0.015) 100%);
  border-bottom: 1px solid var(--border);
}
.mode-bar .rotate-btn {
  padding: 5px 12px;
  font-size: 16px;
  line-height: 1;
}
.mode-bar .enhance-btn {
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.3;
}
.mode-bar .enhance-btn.active {
  background: linear-gradient(180deg, #b569ff 0%, #8e3df1 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(142, 61, 241, 0.3), 0 2px 6px rgba(142, 61, 241, 0.2);
}
.preview img.src,
.preview .crop,
.letterbox-stage img.lb-img {
  image-orientation: from-image;
}
@media (prefers-color-scheme: dark) {
  .mode-bar { background: linear-gradient(180deg, var(--surface-solid) 0%, rgba(255,255,255,0.02) 100%); }
}
.mode-group .seg { padding: 6px 14px; font-size: 13px; }

.hidden { display: none !important; }

.preview-wrap {
  background: #0a0a0a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 180px;
  overflow: hidden;
}
.preview {
  position: relative;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
  line-height: 0;
}
.preview img.src {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  pointer-events: none;
}

.crop {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.98);
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.3) inset;
  cursor: move;
}
.crop::before, .crop::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.crop::before {
  left: 33.333%; right: 33.333%; top: 0; bottom: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}
.crop::after {
  top: 33.333%; bottom: 33.333%; left: 0; right: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.handle {
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease;
}
.handle:hover { transform: scale(1.25); }
.handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* Letterbox preview – obrázek na výšku s bílými pruhy */
.letterbox-preview {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.letterbox-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100%, 800px);
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.letterbox-stage img.lb-img {
  height: 100%;
  width: auto;
  display: block;
}
.lb-info {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
}

/* Success overlay – po exportu */
.success-overlay {
  padding: 28px 18px 32px;
  background: linear-gradient(180deg, rgba(52, 199, 89, 0.06) 0%, transparent 100%);
  border-top: 1px solid var(--border);
  text-align: center;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.success-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.success-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(180deg, #34c759 0%, #28a745 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 4px 14px -2px rgba(40, 167, 69, 0.5);
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.success-card h3 {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}
.success-name {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.success-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.crop-info {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  background: var(--surface-solid);
  flex-wrap: wrap;
}
.item-actions .spacer { flex: 1; min-width: 0; }

.align-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.07);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  padding: 3px;
}
@media (prefers-color-scheme: dark) {
  .align-group {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.06);
  }
}
.align-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 8px 0 6px;
}
.seg {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.seg:hover { background: rgba(0, 0, 0, 0.05); }
@media (prefers-color-scheme: dark) {
  .seg:hover { background: rgba(255, 255, 255, 0.08); }
}
.seg.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 113, 227, 0.4);
}

/* --- Footer bar --- */
#footer {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
#footer .global-quality {
  margin-right: auto;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  header { padding: 40px 16px 24px; }
  header h1 { font-size: 40px; }
  header p { font-size: 16px; }
  main { padding: 0 16px 60px; }
  #dropzone { flex-direction: column; text-align: center; padding: 22px 16px; }
}
