:root {
  --bg: #0f1216;
  --card: #151a21;
  --text: #e5e7eb;
  --muted: #9aa3af;
  --accent: #3b82f6;
  --control-h: 44px;
  --progress: 0%;
  --success: #10b981;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Cantarell, Noto Sans, Ubuntu, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}
header, footer { padding: 16px 20px; }
header h1 { margin: 0 0 6px; font-size: 20px; }
header p { margin: 0; color: var(--muted); }

/* New header */
.site-header { padding: 16px 20px; border-bottom: 1px solid #202632; background: linear-gradient(180deg, rgba(27,34,44,0.6), rgba(27,34,44,0)); }
.site-header .brand { display: flex; align-items: center; gap: 12px; max-width: 1000px; margin: 0 auto; }
.site-header .title { display: flex; flex-direction: column; gap: 2px; }
.site-header .title h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.site-header .title p { margin: 0; color: var(--muted); font-size: 13px; }
.site-header .badges { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.site-header .badge { background: rgba(59,130,246,0.12); color: #9ec1ff; border: 1px solid rgba(59,130,246,0.35); padding: 4px 8px; border-radius: 999px; font-size: 12px; line-height: 1; }
.site-header .badge-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.site-header .badge-link .icon { width: 16px; height: 16px; fill: currentColor; display: block; }

@media (max-width: 640px) {
  .site-header .brand { align-items: flex-start; }
  .site-header .badges { width: 100%; margin-left: 0; }
}

main { padding: 0 20px 40px; max-width: 1000px; margin: 0 auto; }

section { background: var(--card); border: 1px solid #202632; border-radius: 10px; padding: 16px; margin-top: 16px; }
section h2 { margin: 0 0 10px; font-size: 16px; color: var(--muted); font-weight: 600; }

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.input { display: flex; flex-direction: column; gap: 6px; }
.input label { font-size: 12px; color: var(--muted); }

input[type="file"], select, input[type="number"] {
  background: #0f131a;
  color: var(--text);
  border: 1px solid #232a36;
  padding: 0 12px;
  border-radius: 8px;
  height: var(--control-h);
  min-height: var(--control-h);
}

/* Cohesive, custom-styled file buttons */
input[type="file"] {
  width: 100%;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  padding-top: 6px;
}
/* Modern browsers */
input[type="file"]::file-selector-button {
  background: var(--accent);
  color: #fff;
  border: 0;
  margin-right: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]:hover::file-selector-button { filter: brightness(1.05); }
input[type="file"]:active::file-selector-button { transform: translateY(0.5px); }
input[type="file"]:disabled::file-selector-button { opacity: 0.5; cursor: not-allowed; }

/* WebKit fallback */
input[type="file"]::-webkit-file-upload-button {
  background: var(--accent);
  color: #fff;
  border: 0;
  margin-right: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]:hover::-webkit-file-upload-button { filter: brightness(1.05); }
input[type="file"]:active::-webkit-file-upload-button { transform: translateY(0.5px); }
input[type="file"]:disabled::-webkit-file-upload-button { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; align-items: end; }
/* Make the primary action row span full width and stack below inputs */
.inputs .actions { grid-column: 1 / -1; display: block; }
#processBtn { width: 100%; display: block; font-size: clamp(16px, 2.8vw, 24px); padding: clamp(10px, 2.2vw, 16px) clamp(12px, 3vw, 20px); }
button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Bake button with inline progress */
#processBtn { position: relative; overflow: hidden; isolation: isolate; }
#processBtn.baking { cursor: progress; opacity: 1; }
#processBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--progress);
  background: linear-gradient(0deg, rgba(255,255,255,0.18), rgba(255,255,255,0.18)) ,
              repeating-linear-gradient(-45deg, rgba(255,255,255,0.18) 0 10px, rgba(255,255,255,0.28) 10px 20px);
  mix-blend-mode: soft-light;
  z-index: -1; /* under text */
  transition: width 120ms ease-out;
}
#processBtn.baking::before { animation: stripeShift 800ms linear infinite; }
@keyframes stripeShift { from { background-position: 0 0, 0 0; } to { background-position: 40px 0, 40px 0; } }

/* Complete state */
#processBtn.complete { background: var(--success); }
#processBtn.complete::before { animation: none; width: 100%; background: rgba(255,255,255,0.18); }

.status pre {
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
  margin: 0;
  background: #0d1117;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #202632;
}

.log-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.log-controls label { color: var(--muted); font-size: 12px; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
video, canvas { width: 100%; max-height: 360px; background: black; border-radius: 8px; border: 1px solid #202632; }

.output #downloads a { display: inline-block; margin-right: 10px; margin-bottom: 10px; }

footer small { color: var(--muted); }

.hidden { display: none !important; }
.noninteractive { pointer-events: none; user-select: none; }
progress { width: 260px; height: 12px; }
