:root {
  color-scheme: light dark;
  --bg: #f3f4f8;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #5b6272;
  --border: #d5d9e2;
  --accent: #3b5bdb;
  --accent-hover: #2f4ac0;
  --accent-soft: #e7ecff;
  --error-bg: #fdecec;
  --error-text: #a11d1d;
  --success: #1b7f4a;
  --focus: #f59f00;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --card: #1c1f28;
    --text: #e8eaf0;
    --muted: #a0a7b8;
    --border: #353a48;
    --accent: #6c8cff;
    --accent-hover: #87a1ff;
    --accent-soft: #252c47;
    --error-bg: #3a1c1f;
    --error-text: #ffb3b3;
    --success: #5fd398;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(1rem, 5vw, 4rem) 1rem;
}

[hidden] { display: none !important; }

.card {
  width: 100%;
  max-width: 40rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.06);
}

h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.subtitle { margin: 0 0 1.5rem; color: var(--muted); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { width: 2.5rem; height: 2.5rem; color: var(--accent); }
.dropzone-text { margin: 0.5rem 0 0; font-weight: 600; }
.dropzone-or { margin: 0.25rem 0 0.75rem; color: var(--muted); }

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.file-details { display: flex; flex-direction: column; min-width: 0; }
.file-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { color: var(--muted); font-size: 0.9rem; }

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-weight: 600; font-size: 0.95rem; }

select {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-height: 2.75rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.button.secondary:hover:not(:disabled) { background: var(--accent-soft); }
.button.ghost { background: transparent; color: var(--accent); padding-inline: 0.75rem; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.progress-section { margin-top: 1.5rem; }
.progress-header { display: flex; justify-content: space-between; margin-bottom: 0.4rem; font-size: 0.95rem; }
#progress-value { font-variant-numeric: tabular-nums; color: var(--muted); }

progress {
  width: 100%;
  height: 0.75rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--accent-soft);
  accent-color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--accent-soft); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.status { min-height: 1.5em; margin: 1rem 0 0; color: var(--muted); }

.error {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 14rem;
  overflow-y: auto;
}

.result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.result-title { margin: 0; font-weight: 700; color: var(--success); }

@media (max-width: 30rem) {
  .actions .button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
