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

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #d1d1d6;
  --accent: #5e4cd6;
  --accent-dim: #4538b0;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --gpu-color: #1a7f4b;
  --wasm-color: #b45309;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Badge ── */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  border: 1px solid currentColor;
}
.badge.gpu  { color: var(--gpu-color); }
.badge.wasm { color: var(--wasm-color); }

/* ── Loader ── */
#loader {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Progress ── */
#progress-wrap { display: flex; flex-direction: column; gap: 0.4rem; }

#progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.2s ease;
}

#progress-text {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Controls ── */
#controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 5rem;
}

select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  outline: none;
}
select:focus { border-color: var(--accent); }
select:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
textarea:focus { border-color: var(--accent); }

/* ── Buttons ── */
button {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: var(--accent-dim); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
button.loading::before {
  content: '';
  width: 1em;
  height: 1em;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Audio player ── */
audio {
  width: 100%;
  border-radius: 6px;
  outline: none;
}

/* ── Utilities ── */
.hidden { display: none !important; }
