*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(160deg, #f0f4ff 0%, #e8f5e9 100%);
  min-height: 100vh;
  color: #1a1a2e;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0;
  color: #555;
  font-size: 0.95rem;
}

.upload-section {
  margin-bottom: 1.5rem;
}

.drop-zone {
  border: 2px dashed #90a4ae;
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: #fff;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.dragover {
  border-color: #1976d2;
  background: #e3f2fd;
}

.drop-hint {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.drop-sub {
  margin: 0 0 1.25rem;
  color: #777;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn-primary {
  background: #1976d2;
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: #1976d2;
  border: 2px solid #1976d2;
}

.btn-ghost {
  background: transparent;
  color: #666;
  border: 1px solid #ccc;
}

.preview-area {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.preview-area img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto 1rem;
  border-radius: 8px;
  object-fit: contain;
}

.preview-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.status-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #fff3e0;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.status-area p {
  margin: 0;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #ffcc80;
  border-top-color: #f57c00;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-area {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.result-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.elapsed {
  font-size: 0.85rem;
  color: #888;
}

#resultText {
  width: 100%;
  min-height: 160px;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.error-msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #ffebee;
  color: #c62828;
  border-radius: 8px;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.75rem 2rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .drop-zone {
    padding: 1.5rem 1rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .drop-zone {
    padding: 2.5rem 2rem;
  }
}
