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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #a65137;
  min-height: 100vh;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 20px;
  gap: 20px;
}

.downloader {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  width: 100%;
  max-width: 600px;
}

.downloader-content h2 {
  color: #333;
  margin-bottom: 8px;
  font-size: 24px;
}

.downloader-subtitle {
  color: #666;
  margin-bottom: 25px;
  font-size: 14px;
}

.image-source-group {
  margin-bottom: 20px;
}

.source-select {
  width: 100%;
  padding: 10px;
  border: 2px solid #a65137;
  border-radius: 8px;
  background: white;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.source-select:hover {
  border-color: #9e7163;
  background: #faf7f4;
}

.image-list-wrapper {
  margin-bottom: 20px;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #e0dbd6;
  border-radius: 8px;
  padding: 15px;
  background: #faf7f4;
}

.available-images {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loading-text {
  color: #999;
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.image-item {
  padding: 12px;
  background: white;
  border: 1px solid #e0dbd6;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.image-item:hover {
  border-color: #a65137;
  background: #fff5f1;
}

.image-item input[type="radio"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: #a65137;
}

.image-item-info {
  flex: 1;
}

.image-item-name {
  font-weight: 600;
  color: #333;
  font-size: 14px;
  margin-bottom: 3px;
}

.image-item-size {
  font-size: 12px;
  color: #999;
}

.downloader-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.btn-primary {
  background: #a65137;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(166, 81, 55, 0.4);
}

.btn-secondary {
  background: #e8d5c4;
  color: #333;
  border: 1px solid #dcc9bc;
}

.btn-secondary:hover {
  background: #dcc9bc;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  width: 100%;
  max-width: 600px;
}

h1 {
  color: #333;
  margin-bottom: 10px;
  font-size: 28px;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
  font-size: 14px;
}

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

label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 500;
  font-size: 14px;
}

.file-input-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

#imageFile {
  display: none;
}

.file-input-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border: 2px dashed #a65137;
  border-radius: 8px;
  background: #faf7f4;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  color: #a65137;
}

.file-input-label:hover {
  background: #f5ede8;
  border-color: #9e7163;
}

.file-input-label.has-file {
  border-color: #8b6f47;
  background: #f7f2ec;
  color: #8b6f47;
}

.file-info {
  display: none;
  margin-top: 8px;
  padding: 10px;
  background: #f7f2ec;
  border-left: 3px solid #a65137;
  border-radius: 4px;
  font-size: 12px;
  color: #9e7163;
}

.file-info.active {
  display: block;
}

button {
  width: 100%;
  padding: 12px 24px;
  background: #a65137;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(166, 81, 55, 0.4);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#log {
  margin-top: 30px;
  padding: 15px;
  background: #3d2e24;
  color: #e8d5c4;
  border-radius: 8px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.log-entry {
  margin-bottom: 5px;
}

.log-entry.error {
  color: #ff9999;
}

.log-entry.success {
  color: #a8d5a8;
}

.log-entry.info {
  color: #c9b89e;
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (max-width: 600px) {
  body {
    flex-direction: column;
  }

  .downloader,
  .container {
    padding: 25px;
    max-width: 100%;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  #log {
    min-height: 150px;
  }

  .downloader-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }
}
