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

:root {
  --blue: #1B3A5C;
  --blue-hover: #15304d;
  --bg: #FFFFFF;
  --bg-subtle: #F5F7FA;
  --border: #E8EDF2;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

/* Hero */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

/* Drop zone */
.upload-section {
  padding-bottom: 48px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--blue);
  background: #f0f4f8;
}

.drop-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
}

.drop-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.drop-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-full {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  font-size: 15px;
}

/* Sections */
.section {
  padding-bottom: 48px;
}

.hidden {
  display: none !important;
}

/* Loading */
.loading-card {
  text-align: center;
  padding: 48px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Options card */
.options-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.source-panel {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.source-panel h3,
.options-panel h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Preview */
.preview-container {
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 300px;
}

.preview-container img,
.preview-container video {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
}

/* Meta grid */
.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-tag {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-tag strong {
  color: var(--text);
  font-weight: 600;
}

/* Toggle group */
.option-group {
  margin-bottom: 20px;
}

.option-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.toggle-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--border);
}

.toggle-btn.active {
  background: var(--blue);
  color: #fff;
}

/* Resolution info */
.resolution-info {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}

.resolution-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.resolution-fields {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.resolution-fields .field {
  flex: 1;
}

.resolution-fields label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.resolution-fields input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.resolution-fields input:focus {
  outline: none;
  border-color: var(--blue);
}

.field-sep {
  padding-bottom: 8px;
  color: var(--text-secondary);
  font-size: 16px;
}

.field-unit {
  padding-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Progress */
.progress-card {
  text-align: center;
  padding: 48px 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.progress-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-step {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Trigger note */
.trigger-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 0;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Result */
.result-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.result-source {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.result-source h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.result-source-row {
  display: flex;
  gap: 16px;
  align-items: center;
}

.result-source-row .preview-container {
  width: 120px;
  min-width: 120px;
  max-height: 120px;
  margin-bottom: 0;
}

.result-source-row .preview-container img,
.result-source-row .preview-container video {
  max-height: 120px;
}

.result-output {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.result-output:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
  padding-bottom: 0;
}

.result-output-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.result-output-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.reduction-badge {
  font-size: 13px;
  font-weight: 600;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 2px 8px;
  border-radius: 4px;
}

.reduction-badge:empty {
  display: none;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-top: 16px;
}

/* Error */
.error-card {
  text-align: center;
  padding: 48px 32px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}

.error-card p {
  color: #b91c1c;
  margin-bottom: 20px;
  font-weight: 500;
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  font-size: 13px;
  color: var(--text-secondary);
}

.footer a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 24px;
  }

  .options-card {
    padding: 20px;
  }

  .result-source-row {
    flex-direction: column;
  }

  .toggle-btn {
    font-size: 12px;
    padding: 8px 10px;
  }
}

/* Transitions */
.section {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
